ソースを参照

Merge branch 'dev/20220228_v3.0.1通用版_渠道管理第一期' into Jasypt

rengb 3 年 前
コミット
294fe1641c

+ 4 - 0
common/src/main/java/com/lantone/common/vo/DataCompareVO.java

@@ -7,6 +7,7 @@ import lombok.Setter;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @Description: 数据对比-接口入参
@@ -34,4 +35,7 @@ public class DataCompareVO implements Serializable {
     @ApiModelProperty(value = "操作url", hidden = true)
     private String operationUrl;
 
+    @ApiModelProperty(value = "病历号集合", hidden = true)
+    private List<String> behospitalCodes;
+
 }

+ 4 - 0
daqe-center/src/main/java/com/lantone/daqe/dto/HisMedicalRecordDTO.java

@@ -6,6 +6,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.io.Serializable;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -29,6 +30,9 @@ public class HisMedicalRecordDTO implements Serializable {
     @ApiModelProperty(value = "文书列表")
     private List<HisRecDTO> hisRecs;
 
+    @ApiModelProperty(value = "入院时间")
+    private Date behospitalDate;
+
 
 
 }

+ 6 - 0
daqe-center/src/main/java/com/lantone/daqe/entity/BlocklossResult.java

@@ -86,6 +86,12 @@ public class BlocklossResult implements Serializable {
     @TableField("audit_time")
     private Date auditTime;
 
+    /**
+     * 入院时间
+     */
+    @TableField("behospital_date")
+    private Date behospitalDate;
+
     /**
      * 状态: 0:已丢失,1:已恢复
      */

+ 143 - 62
daqe-center/src/main/java/com/lantone/daqe/facade/BlockLossManagementFacade.java

@@ -107,8 +107,6 @@ public class BlockLossManagementFacade {
         //====1.获取已丢失状态记录,去数据库中对比判断是否补录
         List<BlocklossResult> lossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
                 .select("id,behospital_code,rec_id,loss_type,loss_way")
-//                .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
-//                .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
                 .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
                 .eq("status", LossStatusEnum.IS_LOSS.getKey())
                 .eq("is_deleted", IsDeleteEnum.N.getKey()));
@@ -124,47 +122,58 @@ public class BlockLossManagementFacade {
 
         //获取his对应的数据
         List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
+        Map<String, HisMedicalRecordDTO> hisMedicalRecordMap = EntityUtil.makeEntityMap(hisMedicalRecords, "behospitalCode");
 
         //获取操作记录数据
         //病历数据
         dataCompareVO.setOperationUrl("save/saveBehospitalCode");
         List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
         //病案首页数据
-        dataCompareVO.setOperationUrl("save/saveHomePages");
-        List<GetOperationLogDTO> homePageLogs = getOperationLogs(dataCompareVO);
+        List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
         //文书数据
-        dataCompareVO.setOperationUrl("save/saveRecs");
-        List<GetOperationLogDTO> recLogs = getOperationLogs(dataCompareVO);
+        List<GetOperationLogDTO> recLogs = new ArrayList<>();
+
+        List<String> logCodes = null;
+        //没有病历数据就不用去查病案首页和文书
+        if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
+            logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
+            dataCompareVO.setBehospitalCodes(logCodes);
+            //病案首页数据
+            dataCompareVO.setOperationUrl("save/saveHomePages");
+            homePageLogs = getOperationLogs(dataCompareVO);
+            //文书数据
+            dataCompareVO.setOperationUrl("save/saveRecs");
+            recLogs = getOperationLogs(dataCompareVO);
+        }
 
         //获取库中数据
         //病历数据
         List<String> dataBaseBehospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
                 .select("behospital_code")
-                .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getStartDate())
-                .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getEndDate())
-                .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())
+                .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "gmt_create", dataCompareVO.getStartDate())
+                .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "gmt_create", dataCompareVO.getEndDate())
+                .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
                 .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
                 .eq("is_deleted", IsDeleteEnum.N.getKey()))
                 .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
         //病案首页数据
-        List<String> dataBaseHomePageIds = homePageFacade.list(new QueryWrapper<HomePage>()
-                .select("home_page_id")
-                .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getStartDate())
-                .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getEndDate())
-                .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())
-                .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
-                .eq("is_deleted", IsDeleteEnum.N.getKey()))
-                .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
-
+        List<String> dataBaseHomePageIds = new ArrayList<>();
         //文书数据
-        List<String> dataBaseRecIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
-                .select("rec_id")
-                .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getStartDate())
-                .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "gmt_create", dataCompareVO.getEndDate())
-                .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())
-                .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
-                .eq("is_deleted", IsDeleteEnum.N.getKey()))
-                .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
+        List<String> dataBaseRecIds = new ArrayList<>();
+        if (ListUtil.isNotEmpty(dataBaseBehospitalCodes)) {
+            dataBaseHomePageIds = homePageFacade.list(new QueryWrapper<HomePage>()
+                    .select("home_page_id")
+                    .in("behospital_code", dataBaseBehospitalCodes)
+                    .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
+                    .eq("is_deleted", IsDeleteEnum.N.getKey()))
+                    .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
+            dataBaseRecIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
+                    .select("rec_id")
+                    .in("behospital_code", dataBaseBehospitalCodes)
+                    .eq(SysUserUtils.getCurrentHospitalId() != null, "hospital_id", SysUserUtils.getCurrentHospitalId())
+                    .eq("is_deleted", IsDeleteEnum.N.getKey()))
+                    .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
+        }
 
         //==已丢失 外部|内部 病历、文书、病案首页 id集合
         //外部
@@ -227,11 +236,11 @@ public class BlockLossManagementFacade {
             //外部丢失数据集合
             List<BlocklossResult> outInserts = new ArrayList<>();
             //文书数据对比
-            compareHisWithLog(recs, recLogs, LossTypeEnum.REC_LOSS.getKey(), outInserts, outLossRecs);
+            compareHisWithLog(recs, recLogs, LossTypeEnum.REC_LOSS.getKey(), outInserts, outLossRecs, hisMedicalRecordMap);
             //病案首页数据对比
-            compareHisWithLog(medicalRecords, homePageLogs, LossTypeEnum.HOMEPAGE_LOSS.getKey(), outInserts, outLossHomepages);
+            compareHisWithLog(medicalRecords, homePageLogs, LossTypeEnum.HOMEPAGE_LOSS.getKey(), outInserts, outLossHomepages, hisMedicalRecordMap);
             //病历数据对比
-            compareHisWithLog(medicalRecords, behospitalCodeLogs, LossTypeEnum.CODE_LOSS.getKey(), outInserts, outLossCodes);
+            compareHisWithLog(medicalRecords, behospitalCodeLogs, LossTypeEnum.CODE_LOSS.getKey(), outInserts, outLossCodes, hisMedicalRecordMap);
 
             flag = blocklossResultServiceImpl.saveBatch(outInserts);
         }
@@ -240,13 +249,13 @@ public class BlockLossManagementFacade {
         //内部丢失数据集合
         List<BlocklossResult> inInserts = new ArrayList<>();
         if (ListUtil.isNotEmpty(recLogs)) {
-            compareLogWithLocal(recLogs, dataBaseRecIds, LossTypeEnum.REC_LOSS.getKey(), inInserts, inLossRecs);
+            compareLogWithLocal(recLogs, dataBaseRecIds, LossTypeEnum.REC_LOSS.getKey(), inInserts, inLossRecs, hisMedicalRecordMap);
         }
         if (ListUtil.isNotEmpty(homePageLogs)) {
-            compareLogWithLocal(homePageLogs, dataBaseHomePageIds, LossTypeEnum.HOMEPAGE_LOSS.getKey(), inInserts, inLossHomepages);
+            compareLogWithLocal(homePageLogs, dataBaseHomePageIds, LossTypeEnum.HOMEPAGE_LOSS.getKey(), inInserts, inLossHomepages, hisMedicalRecordMap);
         }
         if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
-            compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, LossTypeEnum.CODE_LOSS.getKey(), inInserts, inLossCodes);
+            compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, LossTypeEnum.CODE_LOSS.getKey(), inInserts, inLossCodes, hisMedicalRecordMap);
         }
         if (ListUtil.isNotEmpty(inInserts)) {
             flag = blocklossResultServiceImpl.saveBatch(inInserts);
@@ -257,15 +266,17 @@ public class BlockLossManagementFacade {
     /**
      * 日志与入库数据对比
      *
-     * @param logs          日志记录
-     * @param dataBases     入库数据
-     * @param type          对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
-     * @param inInserts     内部丢失插入集合
-     * @param havingLossIds 已经插入的id集合
+     * @param logs                日志记录
+     * @param dataBases           入库数据
+     * @param type                对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
+     * @param inInserts           内部丢失插入集合
+     * @param havingLossIds       已经插入的id集合
+     * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
      * @Return void
      */
     private void compareLogWithLocal(List<GetOperationLogDTO> logs, List<String> dataBases, String type,
-                                     List<BlocklossResult> inInserts, List<String> havingLossIds) {
+                                     List<BlocklossResult> inInserts, List<String> havingLossIds,
+                                     Map<String, HisMedicalRecordDTO> hisMedicalRecordMap) {
         switch (type) {
             case "0":
                 //文书丢失
@@ -279,6 +290,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setRecTitle(rec.getRecTitle());
                             blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(rec.getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             inInserts.add(blocklossResult);
@@ -287,7 +299,7 @@ public class BlockLossManagementFacade {
                 });
                 //判断只插入文书id的情况
                 //获取插入的文书
-                if(ListUtil.isNotEmpty(dataBases)){
+                if (ListUtil.isNotEmpty(dataBases)) {
                     List<String> havingRecIds = medicalRecordContentFacade.list(new QueryWrapper<MedicalRecordContent>()
                             .select("rec_id")
                             .in("rec_id", dataBases)).stream().map(MedicalRecordContent::getRecId).collect(Collectors.toList());
@@ -306,6 +318,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
                             blocklossResult.setLossCause("文书id插入成功,文书内容没有插入");
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(recMap.get(recId).getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             inInserts.add(blocklossResult);
@@ -326,6 +339,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setRecTitle("病案首页丢失");
                             blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(homePages.getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             inInserts.add(blocklossResult);
@@ -343,6 +357,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
                             blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(beHehospitalInfo.getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             inInserts.add(blocklossResult);
@@ -441,17 +456,19 @@ public class BlockLossManagementFacade {
     }
 
     /**
-     * @param medicalRecords his数据
-     * @param logs           日志数据
-     * @param type           对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
-     * @param outInserts     外部丢失插入集合
-     * @param havingLossIds  已经插入的id集合
+     * @param medicalRecords      his数据
+     * @param logs                日志数据
+     * @param type                对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
+     * @param outInserts          外部丢失插入集合
+     * @param havingLossIds       已经插入的id集合
+     * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
      * @Return void
      */
     private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs,
-                                   String type, List<BlocklossResult> outInserts, List<String> havingLossIds) {
+                                   String type, List<BlocklossResult> outInserts, List<String> havingLossIds,
+                                   Map<String, HisMedicalRecordDTO> hisMedicalRecordMap) {
         //his数据为空直接返回
-        if(ListUtil.isEmpty(medicalRecords)){
+        if (ListUtil.isEmpty(medicalRecords)) {
             return;
         }
         switch (type) {
@@ -469,6 +486,7 @@ public class BlockLossManagementFacade {
                                 blocklossResult.setRecTitle(medicalRecord.getRecTitle());
                                 blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
                                 blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
+                                blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
                                 //拼装病历数据块丢失明细其他信息
                                 assembleOtherBlocklossResult(blocklossResult);
                                 outInserts.add(blocklossResult);
@@ -489,6 +507,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setRecTitle("病案首页丢失");
                             blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             outInserts.add(blocklossResult);
@@ -506,6 +525,7 @@ public class BlockLossManagementFacade {
                             blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
                             blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
                             blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
+                            blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
                             //拼装病历数据块丢失明细其他信息
                             assembleOtherBlocklossResult(blocklossResult);
                             outInserts.add(blocklossResult);
@@ -566,33 +586,67 @@ public class BlockLossManagementFacade {
                 "save/saveHomePages",
                 "save/saveRecs"));
 
+        DataCompareVO dataCompareVO = new DataCompareVO();
+        dataCompareVO.setStartDate(blockLossTypeGatherVO.getStartDate());
+        dataCompareVO.setEndDate(blockLossTypeGatherVO.getEndDate());
+        //获取his数据
+        List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
+
         BlockLossTypeGatherDTO blockLossTypeGatherDTO = new BlockLossTypeGatherDTO();
+        //his数据量
+        blockLossTypeGatherDTO.setHisNum(getHisMedicalRecordsCount(hisMedicalRecords));
+
         //获取该时间段的日志数量
-        Integer logNum = operationLogService.getOperationLogNum(blockLossTypeGatherVO).getData();
-        blockLossTypeGatherDTO.setLogNum(logNum);
+        //病历数据
+        dataCompareVO.setOperationUrl("save/saveBehospitalCode");
+        List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
+        //病案首页数据
+        List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
+        //文书数据
+        List<GetOperationLogDTO> recLogs = new ArrayList<>();
+
+        if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
+            List<String> logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
+            dataCompareVO.setBehospitalCodes(logCodes);
+            //病案首页数据
+            dataCompareVO.setOperationUrl("save/saveHomePages");
+            homePageLogs = getOperationLogs(dataCompareVO);
+            //文书数据
+            dataCompareVO.setOperationUrl("save/saveRecs");
+            recLogs = getOperationLogs(dataCompareVO);
+            Integer logNum = logCodes.size() + homePageLogs.size() + recLogs.size();
+            blockLossTypeGatherDTO.setLogNum(logNum);
+        }
+
         //获取该时间段的实际数量
-        Integer codeNum = behospitalInfoFacade.count(new QueryWrapper<BehospitalInfo>()
-                .eq("hospital_id",SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
-                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
-                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
-        Integer homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
-                .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
-                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
-                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
-        Integer recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
+        List<String> codes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
                 .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
-                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
-                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()))
+                .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
+
+        Integer codeNum = codes.size();
+        Integer homePageNum = 0;
+        Integer recNum = 0;
+        if (ListUtil.isNotEmpty(codes)) {
+            homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
+                    .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
+                    .in("behospital_code", codes));
+            recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
+                    .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
+                    .in("behospital_code", codes));
+        }
+
         blockLossTypeGatherDTO.setRealNum(codeNum + homePageNum + recNum);
         //获取该时间段的丢失数量
         List<BlocklossResult> blocklossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
                 .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
                 .eq("status", LossStatusEnum.IS_LOSS.getKey())
-                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
-                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()));
         Integer allLossNum = blocklossResults.size();
         blockLossTypeGatherDTO.setAllLossNum(allLossNum);
-        blockLossTypeGatherDTO.setHisNum(codeNum + homePageNum + recNum + allLossNum);
+        //        blockLossTypeGatherDTO.setHisNum(codeNum + homePageNum + recNum + allLossNum);
 
         Map<String, List<BlocklossResult>> lossWayMap = EntityUtil.makeEntityListMap(blocklossResults, "lossWay");
         //外部丢失
@@ -638,6 +692,33 @@ public class BlockLossManagementFacade {
         return blockLossTypeGatherDTO;
     }
 
+    /**
+     * 获取这段时间内his的数据量
+     *
+     * @param hisMedicalRecords
+     * @Return java.lang.Integer
+     */
+    private Integer getHisMedicalRecordsCount(List<HisMedicalRecordDTO> hisMedicalRecords) {
+
+        AtomicReference<Integer> num = new AtomicReference<>(0);
+        if (ListUtil.isNotEmpty(hisMedicalRecords)) {
+            hisMedicalRecords.stream().forEach(hisMedicalRecordDTO -> {
+                //病历+1
+                num.getAndSet(num.get() + 1);
+                //病案首页+1
+                if (StringUtil.isNotEmpty(hisMedicalRecordDTO.getHomePageId())) {
+                    num.getAndSet(num.get() + 1);
+                }
+                //文书
+                if (ListUtil.isNotEmpty(hisMedicalRecordDTO.getHisRecs())) {
+                    num.getAndSet(num.get() + hisMedicalRecordDTO.getHisRecs().size());
+                }
+
+            });
+        }
+        return num.get();
+    }
+
     /**
      * 数据补录
      *

+ 39 - 50
daqe-center/src/main/java/com/lantone/daqe/facade/HisDataManagementFacade.java

@@ -8,6 +8,7 @@ import com.lantone.common.exception.Asserts;
 import com.lantone.common.util.BeanUtil;
 import com.lantone.common.util.EntityUtil;
 import com.lantone.common.util.ListUtil;
+import com.lantone.common.util.StringUtil;
 import com.lantone.common.vo.DataCompareVO;
 import com.lantone.common.vo.DataRepariVO;
 import com.lantone.daqe.dto.HisMedicalRecordDTO;
@@ -73,24 +74,24 @@ public class HisDataManagementFacade {
         //病历数据
         List<HisBehospitalInfo> hisBehospitalInfos = hisBehospitalInfoFacade.list(new QueryWrapper<HisBehospitalInfo>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "behospital_date", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "behospital_date", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode()));
+                .ge(dataRepariVO.getStartDate() != null && StringUtil.isBlank(dataRepariVO.getBehospitalCode()), "behospital_date", dataRepariVO.getStartDate())
+                .le(dataRepariVO.getEndDate() != null && StringUtil.isBlank(dataRepariVO.getBehospitalCode()), "behospital_date", dataRepariVO.getEndDate())
+                .eq(StringUtil.isNotBlank(dataRepariVO.getBehospitalCode()), "behospital_code", dataRepariVO.getBehospitalCode()));
+        //通过病历获取病案首页和文书
+        if (ListUtil.isEmpty(hisBehospitalInfos)) {
+            return true;
+        }
+        List<String> codes = hisBehospitalInfos.stream().map(HisBehospitalInfo::getBehospitalCode).collect(Collectors.toList());
+
         //病案首页
         List<HisHomePage> hisHomePages = hisHomePageFacade.list(new QueryWrapper<HisHomePage>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "behospital_date", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "behospital_date", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode())
-        );
+                .in("behospital_code", codes));
 
         //文书
         List<HisMedicalRecord> hisMedicalRecords = hisMedicalRecordFacade.list(new QueryWrapper<HisMedicalRecord>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "rec_date", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "rec_date", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode())
-        );
+                .in("behospital_code", codes));
         List<HisMedicalRecordContent> hisMedicalRecordContents = null;
         if (ListUtil.isNotEmpty(hisMedicalRecords)) {
             hisMedicalRecordContents = hisMedicalRecordContentFacade.list(new QueryWrapper<HisMedicalRecordContent>()
@@ -98,34 +99,28 @@ public class HisDataManagementFacade {
                     .in("rec_id", hisMedicalRecords.stream().map(HisMedicalRecord::getRecId).collect(Collectors.toList())));
         }
 
-        //=====删除该时间段插入我们库中的数据,重新插入
+        //=====删除以插入病历数据,重新插入
         behospitalInfoServiceImpl.remove(new UpdateWrapper<BehospitalInfo>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode()));
+                .in("behospital_code", codes));
         homePageServiceImpl.remove(new UpdateWrapper<HomePage>()
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode()));
-        medicalRecordServiceImpl.remove(new UpdateWrapper<MedicalRecord>()
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode()));
-        //删除改时间段文书内容
+                .in("behospital_code", codes));
+
+        //删除文书内容
         List<String> delRecIds = medicalRecordServiceImpl.list(new QueryWrapper<MedicalRecord>().select("rec_id")
                 .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .ge(dataRepariVO.getStartDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getStartDate())
-                .le(dataRepariVO.getEndDate() != null && dataRepariVO.getBehospitalCode() == null, "gmt_create", dataRepariVO.getEndDate())
-                .eq(dataRepariVO.getBehospitalCode() != null, "behospital_code", dataRepariVO.getBehospitalCode()))
+                .in("behospital_code", codes))
                 .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
         if (ListUtil.isNotEmpty(delRecIds)) {
             medicalRecordContentServiceImpl.remove(new UpdateWrapper<MedicalRecordContent>()
                     .eq("is_deleted", IsDeleteEnum.N.getKey())
                     .in("rec_id", delRecIds));
         }
+        //删除文书
+        medicalRecordServiceImpl.remove(new UpdateWrapper<MedicalRecord>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .in("behospital_code", codes));
 
         //插入新查出的his数据
         try {
@@ -150,45 +145,39 @@ public class HisDataManagementFacade {
     public List<HisMedicalRecordDTO> getHisMedicalRecords(DataCompareVO dataCompareVO) {
         List<HisMedicalRecordDTO> out = new ArrayList<>();
         //病历数据
-        List<String> codes = hisBehospitalInfoFacade.list(new QueryWrapper<HisBehospitalInfo>().select("behospital_code")
+        List<HisBehospitalInfo> hisBehospitalInfos = hisBehospitalInfoFacade.list(new QueryWrapper<HisBehospitalInfo>().select("behospital_code,behospital_date")
                 .eq(dataCompareVO.getHospitalId() != null, "hospital_id", dataCompareVO.getHospitalId())
-                .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "behospital_date", dataCompareVO.getStartDate())
-                .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "behospital_date", dataCompareVO.getEndDate())
-                .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())).stream().map(HisBehospitalInfo::getBehospitalCode).collect(Collectors.toList());
+                .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
+                .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
+                .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode()));
         //通过病历获取病案首页和文书
-        if (ListUtil.isEmpty(codes)) {
+        if (ListUtil.isEmpty(hisBehospitalInfos)) {
             return out;
         }
+        List<String> codes = hisBehospitalInfos.stream().map(HisBehospitalInfo::getBehospitalCode).collect(Collectors.toList());
         //病案首页
         List<HisHomePage> homePages = hisHomePageFacade.list(new QueryWrapper<HisHomePage>().select("home_page_id,behospital_code")
-                        .eq(dataCompareVO.getHospitalId() != null, "hospital_id", dataCompareVO.getHospitalId())
-                        .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "behospital_date", dataCompareVO.getStartDate())
-                        .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "behospital_date", dataCompareVO.getEndDate())
-                        .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())
-                //                .in("behospital_code", codes)
-        );
+                .eq(dataCompareVO.getHospitalId() != null, "hospital_id", dataCompareVO.getHospitalId())
+                .in("behospital_code", codes));
         Map<String, List<HisHomePage>> homePageMap = EntityUtil.makeEntityListMap(homePages, "behospitalCode");
 
         //文书
         List<HisMedicalRecord> hisMedicalRecords = hisMedicalRecordFacade.list(new QueryWrapper<HisMedicalRecord>().select("rec_id,rec_title,behospital_code")
-                        .eq(dataCompareVO.getHospitalId() != null, "hospital_id", dataCompareVO.getHospitalId())
-                        .ge(dataCompareVO.getStartDate() != null && dataCompareVO.getBehospitalCode() == null, "rec_date", dataCompareVO.getStartDate())
-                        .le(dataCompareVO.getEndDate() != null && dataCompareVO.getBehospitalCode() == null, "rec_date", dataCompareVO.getEndDate())
-                        .eq(dataCompareVO.getBehospitalCode() != null, "behospital_code", dataCompareVO.getBehospitalCode())
-                //                .in("behospital_code", codes)
-        );
+                .eq(dataCompareVO.getHospitalId() != null, "hospital_id", dataCompareVO.getHospitalId())
+                .in("behospital_code", codes) );
         Map<String, List<HisMedicalRecord>> medicalRecordMap = EntityUtil.makeEntityListMap(hisMedicalRecords, "behospitalCode");
 
         //拼装
-        codes.stream().forEach(code -> {
+        hisBehospitalInfos.stream().forEach(hisBehospitalInfo -> {
             HisMedicalRecordDTO oneData = new HisMedicalRecordDTO();
-            oneData.setBehospitalCode(code);
-            if (homePageMap != null && ListUtil.isNotEmpty(homePageMap.get(code))) {
-                oneData.setHomePageId(homePageMap.get(code).get(0).getHomePageId());
+            oneData.setBehospitalCode(hisBehospitalInfo.getBehospitalCode());
+            oneData.setBehospitalDate(hisBehospitalInfo.getBehospitalDate());
+            if (homePageMap != null && ListUtil.isNotEmpty(homePageMap.get(hisBehospitalInfo.getBehospitalCode()))) {
+                oneData.setHomePageId(homePageMap.get(hisBehospitalInfo.getBehospitalCode()).get(0).getHomePageId());
             }
             List<HisRecDTO> recs = new ArrayList<>();
-            if (medicalRecordMap != null && ListUtil.isNotEmpty(medicalRecordMap.get(code))) {
-                medicalRecordMap.get(code).stream().forEach(hisMedicalRecord -> {
+            if (medicalRecordMap != null && ListUtil.isNotEmpty(medicalRecordMap.get(hisBehospitalInfo.getBehospitalCode()))) {
+                medicalRecordMap.get(hisBehospitalInfo.getBehospitalCode()).stream().forEach(hisMedicalRecord -> {
                     HisRecDTO rec = new HisRecDTO();
                     rec.setRecId(hisMedicalRecord.getRecId());
                     rec.setRecTitle(hisMedicalRecord.getRecTitle());

+ 2 - 2
daqe-center/src/main/resources/mapper/BlocklossResultMapper.xml

@@ -22,10 +22,10 @@
             AND hospital_id = #{getBlockLossPageVO.hospitalId}
         </if>
         <if test="getBlockLossPageVO.startDate != null">
-            <![CDATA[AND gmt_create >= #{getBlockLossPageVO.startDate}]]>
+            <![CDATA[AND behospital_date >= #{getBlockLossPageVO.startDate}]]>
         </if>
         <if test="getBlockLossPageVO.endDate != null">
-            <![CDATA[ AND gmt_create <= #{getBlockLossPageVO.endDate}]]>
+            <![CDATA[ AND behospital_date <= #{getBlockLossPageVO.endDate}]]>
         </if>
         <if test="getBlockLossPageVO.behospitalCode != null and getBlockLossPageVO.behospitalCode != ''">
             AND behospital_code = #{getBlockLossPageVO.behospitalCode}

+ 1 - 0
daqe-center/src/main/resources/mapper/base/BaseBlocklossResultMapper.xml

@@ -15,6 +15,7 @@
         <result column="loss_way" property="lossWay"/>
         <result column="is_audited" property="isAudited"/>
         <result column="audit_time" property="auditTime"/>
+        <result column="behospital_date" property="behospitalDate"/>
         <result column="status" property="status"/>
         <result column="solve_time" property="solveTime"/>
         <result column="repair_time" property="repairTime"/>

+ 4 - 2
security-center/src/main/java/com/lantone/security/facade/LogManagementFacade.java

@@ -138,8 +138,10 @@ public class LogManagementFacade {
         List<GetOperationLogDTO> out = new ArrayList<>();
         List<String> operationParams = operationLogFacade.list(new QueryWrapper<OperationLog>()
                 .select("operation_param")
-                .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
-                .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
+                .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()) && ListUtil.isEmpty(dataCompareVO.getBehospitalCodes()), "gmt_create", dataCompareVO.getStartDate())
+                .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()) && ListUtil.isEmpty(dataCompareVO.getBehospitalCodes()), "gmt_create", dataCompareVO.getEndDate())
+                .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
+                .in(ListUtil.isNotEmpty(dataCompareVO.getBehospitalCodes()), "remark", dataCompareVO.getBehospitalCodes())
                 .eq("operation_url", dataCompareVO.getOperationUrl()))
                 .stream().map(OperationLog::getOperationParam).collect(Collectors.toList());
         if (ListUtil.isNotEmpty(operationParams)) {