Sfoglia il codice sorgente

新增丢失量分类汇总接口

songxinlu 3 anni fa
parent
commit
097f92896e

+ 34 - 0
common/src/main/java/com/lantone/common/vo/BlockLossTypeGatherVO.java

@@ -0,0 +1,34 @@
+package com.lantone.common.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description: 丢失量分类汇总-接口入参
+ * @author: songxl
+ * @time: 2022/2/28 11:15
+ */
+@ApiModel(value = "丢失量分类汇总-接口入参")
+@Getter
+@Setter
+public class BlockLossTypeGatherVO implements Serializable {
+
+    private static final long serialVersionUID = -1684190802918443494L;
+
+    @ApiModelProperty(value = "开始日期")
+    private Date startDate;
+
+    @ApiModelProperty(value = "截止日期")
+    private Date endDate;
+
+
+    @ApiModelProperty(value = "操作url集合", hidden = true)
+    private List<String> operationUrls;
+
+}

+ 6 - 1
daqe-center/src/main/java/com/lantone/daqe/client/OperationLogService.java

@@ -2,7 +2,9 @@ package com.lantone.daqe.client;
 
 import com.lantone.common.api.CommonResult;
 import com.lantone.common.dto.GetOperationLogDTO;
+import com.lantone.common.vo.BlockLossTypeGatherVO;
 import com.lantone.common.vo.DataCompareVO;
+import io.swagger.models.auth.In;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -18,6 +20,9 @@ import java.util.List;
 public interface OperationLogService {
 
     @PostMapping("/logManage/getOperationLogs")
-    CommonResult<List<GetOperationLogDTO>> getOperationLog(@RequestBody DataCompareVO dataCompareVO);
+    CommonResult<List<GetOperationLogDTO>> getOperationLogs(@RequestBody DataCompareVO dataCompareVO);
+
+    @PostMapping("/logManage/getOperationLogNum")
+    CommonResult<Integer> getOperationLogNum(@RequestBody BlockLossTypeGatherVO blockLossTypeGatherVO);
 
 }

+ 48 - 0
daqe-center/src/main/java/com/lantone/daqe/dto/BlockLossTypeGatherDTO.java

@@ -0,0 +1,48 @@
+package com.lantone.daqe.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 丢失量分类汇总-接口出参
+ * @author: songxl
+ * @time: 2022/3/1 10:30
+ */
+@ApiModel(value = "丢失量分类汇总-接口出参")
+@Getter
+@Setter
+public class BlockLossTypeGatherDTO implements Serializable {
+
+
+    private static final long serialVersionUID = -4656915107891039438L;
+    @ApiModelProperty(value = "HIS数量")
+    private Integer hisNum;
+    @ApiModelProperty(value = "接口日志数量")
+    private Integer logNum;
+    @ApiModelProperty(value = "实际数量")
+    private Integer realNum;
+    @ApiModelProperty(value = "合计丢失数量")
+    private Integer allLossNum;
+    @ApiModelProperty(value = "外部丢失数量")
+    private Integer outLossNum;
+    @ApiModelProperty(value = "外部文书丢失数量")
+    private Integer outRecNum;
+    @ApiModelProperty(value = "外部病历号丢失数量")
+    private Integer outCodeNum;
+    @ApiModelProperty(value = "外部病案首页丢失数量")
+    private Integer outHomePageNum;
+    @ApiModelProperty(value = "内部丢失数量")
+    private Integer inLossNum;
+    @ApiModelProperty(value = "内部文书丢失数量")
+    private Integer inRecNum;
+    @ApiModelProperty(value = "内部病历号丢失数量")
+    private Integer inCodeNum;
+    @ApiModelProperty(value = "内部病案首页丢失数量")
+    private Integer inHomePageNum;
+
+
+}

+ 235 - 72
daqe-center/src/main/java/com/lantone/daqe/facade/BlockLossManagementFacade.java

@@ -11,7 +11,9 @@ import com.lantone.common.util.EntityUtil;
 import com.lantone.common.util.ListUtil;
 import com.lantone.common.util.StringUtil;
 import com.lantone.common.util.SysUserUtils;
+import com.lantone.common.vo.BlockLossTypeGatherVO;
 import com.lantone.daqe.client.OperationLogService;
+import com.lantone.daqe.dto.BlockLossTypeGatherDTO;
 import com.lantone.daqe.dto.GetBlockLossPageDTO;
 import com.lantone.common.dto.GetOperationLogDTO;
 import com.lantone.daqe.dto.HisMedicalRecordDTO;
@@ -20,6 +22,7 @@ import com.lantone.daqe.entity.BehospitalInfo;
 import com.lantone.daqe.entity.BlocklossResult;
 import com.lantone.daqe.entity.HomePage;
 import com.lantone.daqe.entity.MedicalRecord;
+import com.lantone.daqe.entity.MedicalRecordContent;
 import com.lantone.daqe.enums.LossStatusEnum;
 import com.lantone.daqe.enums.LossTypeEnum;
 import com.lantone.daqe.enums.LossWayEnum;
@@ -27,6 +30,7 @@ import com.lantone.daqe.facade.base.BehospitalInfoFacade;
 import com.lantone.daqe.facade.base.BlocklossResultFacade;
 import com.lantone.common.vo.DataCompareVO;
 import com.lantone.daqe.facade.base.HomePageFacade;
+import com.lantone.daqe.facade.base.MedicalRecordContentFacade;
 import com.lantone.daqe.facade.base.MedicalRecordFacade;
 import com.lantone.daqe.service.impl.BlocklossResultServiceImpl;
 import com.lantone.daqe.vo.GetBlockLossPageVO;
@@ -58,6 +62,8 @@ public class BlockLossManagementFacade {
     @Autowired
     private MedicalRecordFacade medicalRecordFacade;
     @Autowired
+    private MedicalRecordContentFacade medicalRecordContentFacade;
+    @Autowired
     private OperationLogService operationLogService;
 
 
@@ -97,8 +103,9 @@ public class BlockLossManagementFacade {
                 .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
                 .eq("status", LossStatusEnum.IS_LOSS.getKey())
                 .eq("is_deleted", IsDeleteEnum.N.getKey()));
+        Map<String, List<BlocklossResult>> lossResultMap = null;
         if (ListUtil.isNotEmpty(lossResults)) {
-            Map<String, List<BlocklossResult>> lossResultMap = EntityUtil.makeEntityListMap(lossResults, "lossType");
+            lossResultMap = EntityUtil.makeEntityListMap(lossResults, "lossType");
             //更新以缺失数据的状态
             flag = upBlockLossStatus(lossResultMap);
         }
@@ -112,13 +119,13 @@ public class BlockLossManagementFacade {
         //获取操作记录数据
         //病历数据
         dataCompareVO.setOperationUrl("save/saveBehospitalCode");
-        List<GetOperationLogDTO> behospitalCodeLogs = getOperationLog(dataCompareVO);
+        List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
         //病案首页数据
         dataCompareVO.setOperationUrl("save/saveHomePages");
-        List<GetOperationLogDTO> homePageLogs = getOperationLog(dataCompareVO);
+        List<GetOperationLogDTO> homePageLogs = getOperationLogs(dataCompareVO);
         //文书数据
         dataCompareVO.setOperationUrl("save/saveRecs");
-        List<GetOperationLogDTO> recLogs = getOperationLog(dataCompareVO);
+        List<GetOperationLogDTO> recLogs = getOperationLogs(dataCompareVO);
 
         //获取库中数据
         //病历数据
@@ -147,6 +154,43 @@ public class BlockLossManagementFacade {
                 .eq("is_deleted", IsDeleteEnum.N.getKey()))
                 .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
 
+        //==已丢失 外部|内部 病历、文书、病案首页 id集合
+        //外部
+        List<String> outLossCodes = null;
+        List<String> outLossHomepages = null;
+        List<String> outLossRecs = null;
+        //内部
+        List<String> inLossCodes = null;
+        List<String> inLossHomepages = null;
+        List<String> inLossRecs = null;
+        if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.REC_LOSS.getKey()))) {
+            Map<String, List<BlocklossResult>> lossWayRecMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.REC_LOSS.getKey()), "lossWay");
+            if (ListUtil.isNotEmpty(lossWayRecMap.get(LossWayEnum.OUT_LOSS))) {
+                outLossRecs = lossWayRecMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+            if (ListUtil.isNotEmpty(lossWayRecMap.get(LossWayEnum.IN_LOSS))) {
+                inLossRecs = lossWayRecMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+        }
+        if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()))) {
+            Map<String, List<BlocklossResult>> lossWayHomePageMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()), "lossWay");
+            if (ListUtil.isNotEmpty(lossWayHomePageMap.get(LossWayEnum.OUT_LOSS))) {
+                outLossHomepages = lossWayHomePageMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+            if (ListUtil.isNotEmpty(lossWayHomePageMap.get(LossWayEnum.IN_LOSS))) {
+                inLossHomepages = lossWayHomePageMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+        }
+        if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()))) {
+            Map<String, List<BlocklossResult>> lossWayCodeMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()), "lossWay");
+            if (ListUtil.isNotEmpty(lossWayCodeMap.get(LossWayEnum.OUT_LOSS))) {
+                outLossCodes = lossWayCodeMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+            if (ListUtil.isNotEmpty(lossWayCodeMap.get(LossWayEnum.IN_LOSS))) {
+                inLossCodes = lossWayCodeMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
+            }
+        }
+
 
         //=====2.2数据对比
         //his与log日志做对比
@@ -170,25 +214,26 @@ public class BlockLossManagementFacade {
             //外部丢失数据集合
             List<BlocklossResult> outInserts = new ArrayList<>();
             //文书数据对比
-            compareHisWithLog(recs, recLogs, "0", outInserts);
+            compareHisWithLog(recs, recLogs, "0", outInserts, outLossRecs);
             //病案首页数据对比
-            compareHisWithLog(medicalRecords, homePageLogs, "1", outInserts);
+            compareHisWithLog(medicalRecords, homePageLogs, "1", outInserts, outLossHomepages);
             //病历数据对比
-            compareHisWithLog(medicalRecords, behospitalCodeLogs, "2", outInserts);
+            compareHisWithLog(medicalRecords, behospitalCodeLogs, "2", outInserts, outLossCodes);
+
             flag = blocklossResultServiceImpl.saveBatch(outInserts);
         }
 
         //日志与入库数据对比
         //内部丢失数据集合
         List<BlocklossResult> inInserts = new ArrayList<>();
-        if (ListUtil.isNotEmpty(dataBaseRecIds)) {
-            compareLogWithLocal(recLogs, dataBaseRecIds, "0", inInserts);
+        if (ListUtil.isNotEmpty(recLogs)) {
+            compareLogWithLocal(recLogs, dataBaseRecIds, "0", inInserts, inLossRecs);
         }
-        if (ListUtil.isNotEmpty(dataBaseHomePageIds)) {
-            compareLogWithLocal(homePageLogs, dataBaseHomePageIds, "1", inInserts);
+        if (ListUtil.isNotEmpty(homePageLogs)) {
+            compareLogWithLocal(homePageLogs, dataBaseHomePageIds, "1", inInserts, inLossHomepages);
         }
-        if (ListUtil.isNotEmpty(dataBaseBehospitalCodes)) {
-            compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, "2", inInserts);
+        if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
+            compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, "2", inInserts, inLossCodes);
         }
         if (ListUtil.isNotEmpty(inInserts)) {
             flag = blocklossResultServiceImpl.saveBatch(inInserts);
@@ -199,45 +244,70 @@ public class BlockLossManagementFacade {
     /**
      * 日志与入库数据对比
      *
-     * @param logs      日志记录
-     * @param dataBases 入库数据
-     * @param type      对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
-     * @param inInserts 内部丢失插入集合
+     * @param logs          日志记录
+     * @param dataBases     入库数据
+     * @param type          对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
+     * @param inInserts     内部丢失插入集合
+     * @param havingLossIds 已经插入的id集合
      * @Return void
      */
-    private void compareLogWithLocal(List<GetOperationLogDTO> logs, List<String> dataBases, String type, List<BlocklossResult> inInserts) {
+    private void compareLogWithLocal(List<GetOperationLogDTO> logs, List<String> dataBases, String type,
+                                     List<BlocklossResult> inInserts, List<String> havingLossIds) {
         switch (type) {
             case "0":
                 //文书丢失
                 logs.stream().forEach(rec -> {
                     //存在记录但是没有入库
                     if (!dataBases.contains(rec.getRecId())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(rec.getBehospitalCode());
-                        blocklossResult.setRecId(rec.getRecId());
-                        blocklossResult.setRecTitle(rec.getRecTitle());
-                        blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        inInserts.add(blocklossResult);
+                        if (havingLossIds.contains(rec.getRecId())) {
+                            BlocklossResult blocklossResult = new BlocklossResult();
+                            blocklossResult.setBehospitalCode(rec.getBehospitalCode());
+                            blocklossResult.setRecId(rec.getRecId());
+                            blocklossResult.setRecTitle(rec.getRecTitle());
+                            blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
+                            blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
+                            //拼装病历数据块丢失明细其他信息
+                            assembleOtherBlocklossResult(blocklossResult);
+                            inInserts.add(blocklossResult);
+                        }
                     }
                 });
+                //判断只插入文书id的情况
+                List<String> havingRecIds = medicalRecordContentFacade.list(new QueryWrapper<MedicalRecordContent>()
+                        .select("rec_id")
+                        .in("rec_id", dataBases)).stream().map(MedicalRecordContent::getRecId).collect(Collectors.toList());
+                List<String> tempList = new ArrayList<>(dataBases);
+                tempList.removeAll(havingRecIds);
+                Map<String, GetOperationLogDTO> recMap = EntityUtil.makeEntityMap(logs, "recId");
+                tempList.stream().forEach(recId -> {
+                    BlocklossResult blocklossResult = new BlocklossResult();
+                    blocklossResult.setBehospitalCode(recMap.get(recId).getBehospitalCode());
+                    blocklossResult.setRecId(recId);
+                    blocklossResult.setRecTitle(recMap.get(recId).getRecTitle());
+                    blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
+                    blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
+                    blocklossResult.setLossCause("文书id插入成功,文书内容没有插入");
+                    //拼装病历数据块丢失明细其他信息
+                    assembleOtherBlocklossResult(blocklossResult);
+                    inInserts.add(blocklossResult);
+                });
                 break;
             case "1":
                 //病案首页丢失
                 logs.stream().forEach(homePages -> {
                     //存在记录但是没有入库
                     if (!dataBases.contains(homePages.getRecId())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(homePages.getBehospitalCode());
-                        blocklossResult.setRecId(homePages.getHomePageId());
-                        blocklossResult.setRecTitle("病案首页丢失");
-                        blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        inInserts.add(blocklossResult);
+                        if (havingLossIds.contains(homePages.getRecId())) {
+                            BlocklossResult blocklossResult = new BlocklossResult();
+                            blocklossResult.setBehospitalCode(homePages.getBehospitalCode());
+                            blocklossResult.setRecId(homePages.getHomePageId());
+                            blocklossResult.setRecTitle("病案首页丢失");
+                            blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
+                            blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
+                            //拼装病历数据块丢失明细其他信息
+                            assembleOtherBlocklossResult(blocklossResult);
+                            inInserts.add(blocklossResult);
+                        }
                     }
                 });
                 break;
@@ -246,19 +316,22 @@ public class BlockLossManagementFacade {
                 logs.stream().forEach(beHehospitalInfo -> {
                     //存在记录但是没有入库
                     if (!dataBases.contains(beHehospitalInfo.getBehospitalCode())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
-                        blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        inInserts.add(blocklossResult);
+                        if (havingLossIds.contains(beHehospitalInfo.getBehospitalCode())) {
+                            BlocklossResult blocklossResult = new BlocklossResult();
+                            blocklossResult.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
+                            blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
+                            blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
+                            //拼装病历数据块丢失明细其他信息
+                            assembleOtherBlocklossResult(blocklossResult);
+                            inInserts.add(blocklossResult);
+                        }
                     }
                 });
                 break;
             default:
                 break;
         }
+
     }
 
     /**
@@ -347,24 +420,31 @@ public class BlockLossManagementFacade {
      * @param logs           日志数据
      * @param type           对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
      * @param outInserts     外部丢失插入集合
+     * @param havingLossIds  已经插入的id集合
      * @Return void
      */
-    private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs, String type, List<BlocklossResult> outInserts) {
+    private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs,
+                                   String type, List<BlocklossResult> outInserts, List<String> havingLossIds) {
         switch (type) {
             case "0":
                 List<String> recLogs = logs.stream().map(GetOperationLogDTO::getRecId).collect(Collectors.toList());
                 medicalRecords.stream().forEach(medicalRecord -> {
                     //文书不存在操作记录
-                    if (StringUtil.isNotEmpty(medicalRecord.getRecId()) && !recLogs.contains(medicalRecord.getRecId())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
-                        blocklossResult.setRecId(medicalRecord.getRecId());
-                        blocklossResult.setRecTitle(medicalRecord.getRecTitle());
-                        blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        outInserts.add(blocklossResult);
+                    if (StringUtil.isNotEmpty(medicalRecord.getRecId())) {
+                        if (!recLogs.contains(medicalRecord.getRecId())) {
+                            //该记录没有插入
+                            if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getRecId())) {
+                                BlocklossResult blocklossResult = new BlocklossResult();
+                                blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
+                                blocklossResult.setRecId(medicalRecord.getRecId());
+                                blocklossResult.setRecTitle(medicalRecord.getRecTitle());
+                                blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
+                                blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
+                                //拼装病历数据块丢失明细其他信息
+                                assembleOtherBlocklossResult(blocklossResult);
+                                outInserts.add(blocklossResult);
+                            }
+                        }
                     }
                 });
                 break;
@@ -373,15 +453,17 @@ public class BlockLossManagementFacade {
                 medicalRecords.stream().forEach(medicalRecord -> {
                     //病案首页不存在操作记录
                     if (StringUtil.isNotEmpty(medicalRecord.getHomePageId()) && !homepageLogs.contains(medicalRecord.getHomePageId())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
-                        blocklossResult.setRecId(medicalRecord.getHomePageId());
-                        blocklossResult.setRecTitle("病案首页丢失");
-                        blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        outInserts.add(blocklossResult);
+                        if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getHomePageId())) {
+                            BlocklossResult blocklossResult = new BlocklossResult();
+                            blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
+                            blocklossResult.setRecId(medicalRecord.getHomePageId());
+                            blocklossResult.setRecTitle("病案首页丢失");
+                            blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
+                            blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
+                            //拼装病历数据块丢失明细其他信息
+                            assembleOtherBlocklossResult(blocklossResult);
+                            outInserts.add(blocklossResult);
+                        }
                     }
                 });
                 break;
@@ -390,13 +472,15 @@ public class BlockLossManagementFacade {
                 medicalRecords.stream().forEach(medicalRecord -> {
                     //病历数据不存在操作记录
                     if (!behospitalCodeLogs.contains(medicalRecord.getBehospitalCode())) {
-                        BlocklossResult blocklossResult = new BlocklossResult();
-                        blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
-                        blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
-                        blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
-                        //拼装病历数据块丢失明细其他信息
-                        assembleOtherBlocklossResult(blocklossResult);
-                        outInserts.add(blocklossResult);
+                        if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getBehospitalCode())) {
+                            BlocklossResult blocklossResult = new BlocklossResult();
+                            blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
+                            blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
+                            blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
+                            //拼装病历数据块丢失明细其他信息
+                            assembleOtherBlocklossResult(blocklossResult);
+                            outInserts.add(blocklossResult);
+                        }
                     }
                 });
                 break;
@@ -426,8 +510,8 @@ public class BlockLossManagementFacade {
      * @param dataCompareVO
      * @Return java.util.List<com.lantone.common.dto.GetOperationLogDTO>
      */
-    private List<GetOperationLogDTO> getOperationLog(DataCompareVO dataCompareVO) {
-        return operationLogService.getOperationLog(dataCompareVO).getData();
+    private List<GetOperationLogDTO> getOperationLogs(DataCompareVO dataCompareVO) {
+        return operationLogService.getOperationLogs(dataCompareVO).getData();
     }
 
     /**
@@ -441,4 +525,83 @@ public class BlockLossManagementFacade {
 
         return new ArrayList<>();
     }
+
+    /**
+     * 丢失量分类汇总
+     *
+     * @param blockLossTypeGatherVO
+     * @Return com.lantone.daqe.dto.BlockLossTypeGatherDTO
+     */
+    public BlockLossTypeGatherDTO blockLossTypeGather(BlockLossTypeGatherVO blockLossTypeGatherVO) {
+        BlockLossTypeGatherDTO blockLossTypeGatherDTO = new BlockLossTypeGatherDTO();
+        //获取该时间段的日志数量
+        Integer logNum = operationLogService.getOperationLogNum(blockLossTypeGatherVO).getData();
+        blockLossTypeGatherDTO.setLogNum(logNum);
+        //获取该时间段的实际数量
+        Integer codeNum = behospitalInfoFacade.count(new QueryWrapper<BehospitalInfo>()
+                .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate()));
+        Integer homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
+                .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate()));
+        Integer recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
+                .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate()));
+        blockLossTypeGatherDTO.setRealNum(codeNum + homePageNum + recNum);
+        //获取该时间段的丢失数量
+        List<BlocklossResult> blocklossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
+                .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
+                .eq("status", LossStatusEnum.IS_LOSS.getKey())
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate()));
+        Integer allLossNum = blocklossResults.size();
+        blockLossTypeGatherDTO.setAllLossNum(allLossNum);
+        blockLossTypeGatherDTO.setHisNum(logNum + allLossNum);
+
+        Map<String, List<BlocklossResult>> lossWayMap = EntityUtil.makeEntityListMap(blocklossResults, "lossWay");
+        //外部丢失
+        if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
+            Integer outLossNum = lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()).size();
+            blockLossTypeGatherDTO.setOutLossNum(outLossNum);
+            if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
+                Map<String, List<BlocklossResult>> outLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()), "lossType");
+                if (outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
+                    Integer outRecNum = outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setOutRecNum(outRecNum);
+                }
+                if (outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
+                    Integer outCodeNum = outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setOutCodeNum(outCodeNum);
+                }
+                if (outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
+                    Integer outHomePageNum = outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setOutHomePageNum(outHomePageNum);
+                }
+            }
+        }
+        //内部丢失
+        if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
+            Integer inLossNum = lossWayMap.get(LossWayEnum.IN_LOSS.getKey()).size();
+            blockLossTypeGatherDTO.setInLossNum(inLossNum);
+            if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
+                Map<String, List<BlocklossResult>> inLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.IN_LOSS.getKey()), "lossType");
+                if (inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
+                    Integer inRecNum = inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setInRecNum(inRecNum);
+                }
+                if (inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
+                    Integer inCodeNum = inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setInCodeNum(inCodeNum);
+                }
+                if (inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
+                    Integer inHomePageNum = inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
+                    blockLossTypeGatherDTO.setInHomePageNum(inHomePageNum);
+                }
+            }
+        }
+        return blockLossTypeGatherDTO;
+    }
 }

+ 58 - 0
daqe-center/src/main/java/com/lantone/daqe/task/BlockLossDataCompareTask.java

@@ -0,0 +1,58 @@
+package com.lantone.daqe.task;
+
+import com.lantone.common.enums.IsDeleteEnum;
+import com.lantone.common.util.DateUtil;
+import com.lantone.common.util.StringUtil;
+import com.lantone.common.vo.DataCompareVO;
+import com.lantone.daqe.facade.BlockLossManagementFacade;
+import com.lantone.daqe.facade.base.BlocklossResultFacade;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.Trigger;
+import org.springframework.scheduling.TriggerContext;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.support.CronTrigger;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+@EnableScheduling   // 2.开启定时任务
+@Slf4j
+public class BlockLossDataCompareTask implements SchedulingConfigurer {
+
+    @Autowired
+    private BlockLossManagementFacade blockLossManagementFacade;
+    @Value("${blockloss.compare.cron}")
+    private String cron = "0 0 1 * * ?";
+    @Value("${blockloss.compare.use}")
+    private String isUsed = "false";
+
+    /**
+     * 执行定时任务.
+     */
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+        taskRegistrar.addTriggerTask(new Runnable() {
+            @Override
+            public void run() {
+                if(Boolean.parseBoolean(isUsed)){
+                    DataCompareVO dataCompareVO = new DataCompareVO();
+                    dataCompareVO.setStartDate(DateUtil.addDate(DateUtil.now(),-1));
+                    dataCompareVO.setEndDate(DateUtil.now());
+                    blockLossManagementFacade.dataCompare(dataCompareVO);
+                }
+            }
+        }, new Trigger() {
+            @Override
+            public Date nextExecutionTime(TriggerContext triggerContext) {
+                CronTrigger trigger = new CronTrigger(cron);
+                return trigger.nextExecutionTime(triggerContext);
+            }
+        });
+    }
+}

+ 9 - 0
daqe-center/src/main/java/com/lantone/daqe/web/BlockLossManagementController.java

@@ -2,6 +2,8 @@ package com.lantone.daqe.web;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.lantone.common.api.CommonResult;
+import com.lantone.common.vo.BlockLossTypeGatherVO;
+import com.lantone.daqe.dto.BlockLossTypeGatherDTO;
 import com.lantone.daqe.dto.GetBlockLossPageDTO;
 import com.lantone.daqe.dto.UpBlockLossByIdVO;
 import com.lantone.daqe.facade.BlockLossManagementFacade;
@@ -50,4 +52,11 @@ public class BlockLossManagementController {
         return CommonResult.success(blockLossManagementFacade.dataCompare(dataCompareVO));
     }
 
+
+    @ApiOperation(value = "丢失量分类汇总 [by:songxl]", notes = "丢失量分类汇总")
+    @PostMapping("/blockLossTypeGather")
+    @Transactional
+    public CommonResult<BlockLossTypeGatherDTO> blockLossTypeGather(@RequestBody @Valid BlockLossTypeGatherVO blockLossTypeGatherVO) {
+        return CommonResult.success(blockLossManagementFacade.blockLossTypeGather(blockLossTypeGatherVO));
+    }
 }

+ 7 - 1
daqe-center/src/main/resources/bootstrap.yml

@@ -54,4 +54,10 @@ mybatis-plus:
 
 swagger.title: 数据及质量保障中心
 swagger.des: 数据及质量保障中心—相关接口文档
-swagger.version: 0.0.1-SNAPSHOT
+swagger.version: 0.0.1-SNAPSHOT
+
+#数据比对定时器
+blockloss:
+  compare:
+    cron: 0 0 1 * * ?
+    use: true

+ 13 - 0
security-center/src/main/java/com/lantone/security/facade/LogManagementFacade.java

@@ -9,6 +9,7 @@ import com.lantone.common.dto.LoginLogDTO;
 import com.lantone.common.dto.OperationLogDTO;
 import com.lantone.common.util.ListUtil;
 import com.lantone.common.util.StringUtil;
+import com.lantone.common.vo.BlockLossTypeGatherVO;
 import com.lantone.common.vo.DataCompareVO;
 import com.lantone.security.vo.GetAbnormalLogVO;
 import com.lantone.security.vo.GetAbnormalWayAndIpVO;
@@ -156,4 +157,16 @@ public class LogManagementFacade {
         return out;
     }
 
+    /**
+     * 获取该时间段的日志数量
+     *
+     * @param blockLossTypeGatherVO
+     * @Return java.lang.Integer
+     */
+    public Integer getOperationLogNum(BlockLossTypeGatherVO blockLossTypeGatherVO) {
+        return operationLogFacade.count(new QueryWrapper<OperationLog>()
+                .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
+                .in("operation_url", blockLossTypeGatherVO.getOperationUrls()));
+    }
 }

+ 7 - 0
security-center/src/main/java/com/lantone/security/web/LogManagementController.java

@@ -6,6 +6,7 @@ import com.lantone.common.dto.AbnormalLogDTO;
 import com.lantone.common.dto.GetOperationLogDTO;
 import com.lantone.common.dto.LoginLogDTO;
 import com.lantone.common.dto.OperationLogDTO;
+import com.lantone.common.vo.BlockLossTypeGatherVO;
 import com.lantone.common.vo.DataCompareVO;
 import com.lantone.security.vo.GetAbnormalLogVO;
 import com.lantone.security.vo.GetAbnormalWayAndIpVO;
@@ -102,4 +103,10 @@ public class LogManagementController {
         return CommonResult.success(logManagementFacade.getOperationLogs(dataCompareVO));
     }
 
+    @ApiOperation(value = "获取该时间段的日志数量[by:songxl]")
+    @PostMapping("/getOperationLogNum")
+    public CommonResult<Integer> getOperationLogNum(@RequestBody BlockLossTypeGatherVO blockLossTypeGatherVO) {
+        return CommonResult.success(logManagementFacade.getOperationLogNum(blockLossTypeGatherVO));
+    }
+
 }