服务管理初始化
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||||
|
*/
|
||||||
|
package com.openhis.web.basicservice.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.openhis.administration.domain.Location;
|
||||||
|
import com.openhis.administration.mapper.LocationMapper;
|
||||||
|
import com.openhis.administration.service.IHealthcareServiceService;
|
||||||
|
import com.openhis.common.enums.AccountStatus;
|
||||||
|
import com.openhis.common.utils.HisPageUtils;
|
||||||
|
import com.openhis.common.utils.HisQueryUtils;
|
||||||
|
import com.openhis.medication.domain.Medication;
|
||||||
|
import com.openhis.medication.domain.MedicationQueryDto;
|
||||||
|
import com.openhis.web.basicservice.dto.HealthcareServiceInitDto;
|
||||||
|
import com.openhis.web.basicservice.mapper.HealthcareServiceBizMapper;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务管理 controller
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/basic-service/healthcare")
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class HealthcareServiceController {
|
||||||
|
|
||||||
|
private final IHealthcareServiceService iHealthcareServiceService;
|
||||||
|
private final HealthcareServiceBizMapper healthcareServiceBizMapper;
|
||||||
|
private final LocationMapper locationMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务管理基础数据初始化
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/init")
|
||||||
|
public R<?> init(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(value = "searchKey", defaultValue = "") String searchKey) {
|
||||||
|
HealthcareServiceInitDto healthcareServiceInitDto = new HealthcareServiceInitDto();
|
||||||
|
// 活动标记
|
||||||
|
List<HealthcareServiceInitDto.activeFlagOption> activeFlagOptions = Stream.of(AccountStatus.values())
|
||||||
|
.map(status -> new HealthcareServiceInitDto.activeFlagOption(status.getValue(), status.getInfo()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
healthcareServiceInitDto.setActiveFlagOptions(activeFlagOptions);
|
||||||
|
// 构建查询条件
|
||||||
|
QueryWrapper<Location> queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey,
|
||||||
|
new HashSet<>(Arrays.asList("name")), null);
|
||||||
|
Page<Location> LocationPage = HisPageUtils.selectPage(
|
||||||
|
locationMapper, queryWrapper, pageNo, pageSize, Location.class);
|
||||||
|
List<Location> LocationList = LocationPage.getRecords();
|
||||||
|
// 位置信息
|
||||||
|
List<HealthcareServiceInitDto.locationIdOption> locationIdOptions = LocationList.stream()
|
||||||
|
.map(location -> new HealthcareServiceInitDto.locationIdOption(location.getId(), location.getName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
healthcareServiceInitDto.setLocationIdOptions(locationIdOptions);
|
||||||
|
return R.ok(healthcareServiceInitDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.openhis.web.basicservice.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务管理 基础数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class HealthcareServiceInitDto {
|
||||||
|
|
||||||
|
|
||||||
|
private List<activeFlagOption> activeFlagOptions;
|
||||||
|
private List<locationIdOption> locationIdOptions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动标记
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class activeFlagOption {
|
||||||
|
private Integer value;
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
public activeFlagOption(Integer value, String label) {
|
||||||
|
this.value = value;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 位置信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class locationIdOption {
|
||||||
|
private Long value;
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
public locationIdOption(Long value, String label) {
|
||||||
|
this.value = value;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.openhis.web.basicservice.mapper;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务管理 自定义Mapper
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface HealthcareServiceBizMapper {
|
||||||
|
}
|
||||||
@@ -47,6 +47,8 @@ user:
|
|||||||
|
|
||||||
# Spring配置
|
# Spring配置
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-circular-references: true
|
||||||
# 资源信息
|
# 资源信息
|
||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.openhis.web.basicservice.mapper.HealthcareServiceBizMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -35,25 +35,6 @@ public class HisQueryUtils {
|
|||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||||
// 添加租户id查询条件
|
// 添加租户id查询条件
|
||||||
queryWrapper.eq(CommonConstants.Common.TENANT_ID, getCurrentTenantId());
|
queryWrapper.eq(CommonConstants.Common.TENANT_ID, getCurrentTenantId());
|
||||||
if (entity == null) {
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
// 反射获取实体类的字段
|
|
||||||
Field[] fields = entity.getClass().getDeclaredFields();
|
|
||||||
for (Field field : fields) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
try {
|
|
||||||
Object value = field.get(entity);
|
|
||||||
if (value != null && !value.toString().equals("")) {
|
|
||||||
// 将驼峰命名的字段名转换为下划线命名的数据库字段名
|
|
||||||
String fieldName = camelToUnderline(field.getName());
|
|
||||||
// 处理等于条件
|
|
||||||
queryWrapper.eq(fieldName, value);
|
|
||||||
}
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 处理模糊查询关键字
|
// 处理模糊查询关键字
|
||||||
if (searchKey != null && !searchKey.isEmpty() && searchFields != null && !searchFields.isEmpty()) {
|
if (searchKey != null && !searchKey.isEmpty() && searchFields != null && !searchFields.isEmpty()) {
|
||||||
queryWrapper.and(wrapper -> {
|
queryWrapper.and(wrapper -> {
|
||||||
@@ -64,6 +45,7 @@ public class HisQueryUtils {
|
|||||||
}
|
}
|
||||||
// 处理时间段查询
|
// 处理时间段查询
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD);
|
||||||
|
if (request != null) {
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||||
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
||||||
String paramName = entry.getKey();
|
String paramName = entry.getKey();
|
||||||
@@ -96,6 +78,26 @@ public class HisQueryUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (entity == null) {
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
// 反射获取实体类的字段
|
||||||
|
Field[] fields = entity.getClass().getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
try {
|
||||||
|
Object value = field.get(entity);
|
||||||
|
if (value != null && !value.toString().equals("")) {
|
||||||
|
// 将驼峰命名的字段名转换为下划线命名的数据库字段名
|
||||||
|
String fieldName = camelToUnderline(field.getName());
|
||||||
|
// 处理等于条件
|
||||||
|
queryWrapper.eq(fieldName, value);
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package com.openhis.administration.domain;
|
package com.openhis.administration.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
import com.core.common.core.domain.HisBaseEntity;
|
import com.core.common.core.domain.HisBaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -44,7 +40,7 @@ public class HealthcareService extends HisBaseEntity {
|
|||||||
private String specialtyCode;
|
private String specialtyCode;
|
||||||
|
|
||||||
/** 地点 */
|
/** 地点 */
|
||||||
private String locationId;
|
private Long locationId;
|
||||||
|
|
||||||
/** 服务名称 */
|
/** 服务名称 */
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
Reference in New Issue
Block a user