服务管理初始化
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,6 +35,50 @@ 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 (searchKey != null && !searchKey.isEmpty() && searchFields != null && !searchFields.isEmpty()) {
|
||||||
|
queryWrapper.and(wrapper -> {
|
||||||
|
for (String field : searchFields) {
|
||||||
|
wrapper.or().like(field, searchKey);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 处理时间段查询
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD);
|
||||||
|
if (request != null) {
|
||||||
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||||
|
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
||||||
|
String paramName = entry.getKey();
|
||||||
|
// 检查参数名是否以 "STime" 或 "ETime" 结尾
|
||||||
|
if (paramName.endsWith(CommonConstants.Common.S_TIME)
|
||||||
|
|| paramName.endsWith(CommonConstants.Common.E_TIME)) {
|
||||||
|
// 提取字段名(去掉 "STime" 或 "ETime" 后缀)
|
||||||
|
String fieldName = paramName.substring(0, paramName.length() - 5);
|
||||||
|
// 驼峰转下划线
|
||||||
|
String dbFieldName = camelToUnderline(fieldName);
|
||||||
|
// 获取对应的 STime 和 ETime 值
|
||||||
|
String startValue = getParameterValue(request, fieldName + CommonConstants.Common.S_TIME);
|
||||||
|
String endValue = getParameterValue(request, fieldName + CommonConstants.Common.E_TIME);
|
||||||
|
// 如果 Start 和 End 都有值,则添加时间段查询条件
|
||||||
|
if (startValue != null && endValue != null) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat dateFormat;
|
||||||
|
if (isValidFormat(formatter, startValue)) {
|
||||||
|
dateFormat = new SimpleDateFormat(DateUtils.YYYY_MM_DD);
|
||||||
|
} else {
|
||||||
|
dateFormat = new SimpleDateFormat(DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||||
|
}
|
||||||
|
Date startDate = dateFormat.parse(startValue);
|
||||||
|
Date endDate = dateFormat.parse(endValue);
|
||||||
|
queryWrapper.ge(dbFieldName, startDate); // 大于等于 STime
|
||||||
|
queryWrapper.le(dbFieldName, endDate); // 小于等于 ETime
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
@@ -54,48 +98,6 @@ public class HisQueryUtils {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 处理模糊查询关键字
|
|
||||||
if (searchKey != null && !searchKey.isEmpty() && searchFields != null && !searchFields.isEmpty()) {
|
|
||||||
queryWrapper.and(wrapper -> {
|
|
||||||
for (String field : searchFields) {
|
|
||||||
wrapper.or().like(field, searchKey);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 处理时间段查询
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD);
|
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
||||||
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
|
|
||||||
String paramName = entry.getKey();
|
|
||||||
// 检查参数名是否以 "STime" 或 "ETime" 结尾
|
|
||||||
if (paramName.endsWith(CommonConstants.Common.S_TIME)
|
|
||||||
|| paramName.endsWith(CommonConstants.Common.E_TIME)) {
|
|
||||||
// 提取字段名(去掉 "STime" 或 "ETime" 后缀)
|
|
||||||
String fieldName = paramName.substring(0, paramName.length() - 5);
|
|
||||||
// 驼峰转下划线
|
|
||||||
String dbFieldName = camelToUnderline(fieldName);
|
|
||||||
// 获取对应的 STime 和 ETime 值
|
|
||||||
String startValue = getParameterValue(request, fieldName + CommonConstants.Common.S_TIME);
|
|
||||||
String endValue = getParameterValue(request, fieldName + CommonConstants.Common.E_TIME);
|
|
||||||
// 如果 Start 和 End 都有值,则添加时间段查询条件
|
|
||||||
if (startValue != null && endValue != null) {
|
|
||||||
try {
|
|
||||||
SimpleDateFormat dateFormat;
|
|
||||||
if (isValidFormat(formatter, startValue)) {
|
|
||||||
dateFormat = new SimpleDateFormat(DateUtils.YYYY_MM_DD);
|
|
||||||
} else {
|
|
||||||
dateFormat = new SimpleDateFormat(DateUtils.YYYY_MM_DD_HH_MM_SS);
|
|
||||||
}
|
|
||||||
Date startDate = dateFormat.parse(startValue);
|
|
||||||
Date endDate = dateFormat.parse(endValue);
|
|
||||||
queryWrapper.ge(dbFieldName, startDate); // 大于等于 STime
|
|
||||||
queryWrapper.le(dbFieldName, endDate); // 小于等于 ETime
|
|
||||||
} catch (ParseException 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