diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/controller/HealthcareServiceController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/controller/HealthcareServiceController.java new file mode 100644 index 00000000..d45cb09f --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/controller/HealthcareServiceController.java @@ -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 activeFlagOptions = Stream.of(AccountStatus.values()) + .map(status -> new HealthcareServiceInitDto.activeFlagOption(status.getValue(), status.getInfo())) + .collect(Collectors.toList()); + healthcareServiceInitDto.setActiveFlagOptions(activeFlagOptions); + // 构建查询条件 + QueryWrapper queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey, + new HashSet<>(Arrays.asList("name")), null); + Page LocationPage = HisPageUtils.selectPage( + locationMapper, queryWrapper, pageNo, pageSize, Location.class); + List LocationList = LocationPage.getRecords(); + // 位置信息 + List locationIdOptions = LocationList.stream() + .map(location -> new HealthcareServiceInitDto.locationIdOption(location.getId(), location.getName())) + .collect(Collectors.toList()); + healthcareServiceInitDto.setLocationIdOptions(locationIdOptions); + return R.ok(healthcareServiceInitDto); + } + + +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/dto/HealthcareServiceInitDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/dto/HealthcareServiceInitDto.java new file mode 100644 index 00000000..4dc1b3ce --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/dto/HealthcareServiceInitDto.java @@ -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 activeFlagOptions; + private List 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; + } + } + +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/mapper/HealthcareServiceBizMapper.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/mapper/HealthcareServiceBizMapper.java new file mode 100644 index 00000000..a4444503 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basicservice/mapper/HealthcareServiceBizMapper.java @@ -0,0 +1,10 @@ +package com.openhis.web.basicservice.mapper; + +import org.springframework.stereotype.Repository; + +/** + * 服务管理 自定义Mapper + */ +@Repository +public interface HealthcareServiceBizMapper { +} diff --git a/openhis-server/openhis-application/src/main/resources/application.yml b/openhis-server/openhis-application/src/main/resources/application.yml index 4144e50a..46f4f629 100644 --- a/openhis-server/openhis-application/src/main/resources/application.yml +++ b/openhis-server/openhis-application/src/main/resources/application.yml @@ -47,6 +47,8 @@ user: # Spring配置 spring: + main: + allow-circular-references: true # 资源信息 messages: # 国际化资源文件路径 diff --git a/openhis-server/openhis-application/src/main/resources/mapper/basicservice/HealthcareServiceBizMapper.xml b/openhis-server/openhis-application/src/main/resources/mapper/basicservice/HealthcareServiceBizMapper.xml new file mode 100644 index 00000000..85dec8ae --- /dev/null +++ b/openhis-server/openhis-application/src/main/resources/mapper/basicservice/HealthcareServiceBizMapper.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/openhis-server/openhis-common/src/main/java/com/openhis/common/utils/HisQueryUtils.java b/openhis-server/openhis-common/src/main/java/com/openhis/common/utils/HisQueryUtils.java index c2765cae..057de430 100644 --- a/openhis-server/openhis-common/src/main/java/com/openhis/common/utils/HisQueryUtils.java +++ b/openhis-server/openhis-common/src/main/java/com/openhis/common/utils/HisQueryUtils.java @@ -35,6 +35,50 @@ public class HisQueryUtils { QueryWrapper queryWrapper = new QueryWrapper<>(); // 添加租户id查询条件 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 parameterMap = request.getParameterMap(); + for (Map.Entry 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) { return queryWrapper; } @@ -54,48 +98,6 @@ public class HisQueryUtils { 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 parameterMap = request.getParameterMap(); - for (Map.Entry 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; } diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/HealthcareService.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/HealthcareService.java index 2076efff..e77e76b0 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/HealthcareService.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/HealthcareService.java @@ -1,12 +1,8 @@ package com.openhis.administration.domain; -import java.math.BigDecimal; -import java.util.Date; - import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import com.core.common.core.domain.HisBaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -44,7 +40,7 @@ public class HealthcareService extends HisBaseEntity { private String specialtyCode; /** 地点 */ - private String locationId; + private Long locationId; /** 服务名称 */ private String name;