Browse Source

故障区段列表改造,增加默认数据

liuaini 1 month ago
parent
commit
986b69e4d5

+ 24 - 21
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FaultPowerCutServiceImpl.java

@@ -76,7 +76,7 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
     IFaultCreateClient faultCreateClient;
 
     @Override
-    @UserCountyCodeAuto(sourceFiled = "countyCode",targetFiled = "countyCodeList")
+//    @UserCountyCodeAuto(sourceFiled = "countyCode", targetFiled = "countyCodeList")
     public Page<FhzgFaultPowerCutVO> getSchemeList(FaultPowerCut obj) {
         Page<FhzgFaultPowerCutVO> page = new Page<>();
         page.setCurrent(obj.getPageNum());
@@ -96,22 +96,24 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
                     FhzgFaultPowerCutSectionVO::getFaultNo,
                     Collectors.collectingAndThen(
                             Collectors.toList(),
-                            ls->ls.stream().sorted(
-                                    Comparator.comparing(FhzgFaultPowerCutSectionVO::getSectionStatus,Comparator.reverseOrder())
-                                            .thenComparing(FhzgFaultPowerCutSectionVO::getCreateTime,Comparator.reverseOrder()))
+                            ls -> ls.stream().sorted(
+                                            Comparator.comparing(FhzgFaultPowerCutSectionVO::getSectionStatus, Comparator.reverseOrder())
+                                                    .thenComparing(FhzgFaultPowerCutSectionVO::getCreateTime, Comparator.reverseOrder()))
                                     .collect(Collectors.toList())))
             );
             //查询计划对应的线路图信息
             List<FhzgFaultDistMappingFileDTO> fileList = faultDistMappingFileMapper.getMappingFileByPlanId(idList);
-           if (CollUtil.isNotEmpty(faultPowerCutSectionList)) {
-               Map<Long, List<FhzgFaultDistMappingFileDTO>> fileListMap = fileList.stream().collect(Collectors.groupingBy(FhzgFaultDistMappingFileDTO::getFaultId));
-               list.forEach(e -> {
-                   //故障id
-                   String fId = e.getFaultId();
-                   List<FhzgFaultPowerCutSectionVO> faultPowerCuts = null != sectionMap.get(fId) ? sectionMap.get(fId) : new ArrayList<>();
-                   faultPowerCuts.forEach(section-> Optional.of(fileListMap).ifPresent(f->section.setFileList(Objects.nonNull(f.get(section.getFaultId()))?f.get(section.getFaultId()): Lists.newArrayList())));
-                   e.setSectionList(faultPowerCuts);
-               });
+            if (CollUtil.isNotEmpty(faultPowerCutSectionList)) {
+                Map<Long, List<FhzgFaultDistMappingFileDTO>> fileListMap = fileList.stream().collect(Collectors.groupingBy(FhzgFaultDistMappingFileDTO::getFaultId));
+                list.forEach(e -> {
+                    Long id = e.getId();
+                    Optional.of(fileListMap).ifPresent(p -> e.setFileList(Objects.nonNull(p.get(id)) ? p.get(id) : Lists.newArrayList()));
+                    //故障id
+                    String fId = e.getFaultId();
+                    List<FhzgFaultPowerCutSectionVO> faultPowerCuts = null != sectionMap.get(fId) ? sectionMap.get(fId) : new ArrayList<>();
+                    faultPowerCuts.forEach(section -> Optional.of(fileListMap).ifPresent(f -> section.setFileList(Objects.nonNull(f.get(section.getFaultId())) ? f.get(section.getFaultId()) : Lists.newArrayList())));
+                    e.setSectionList(faultPowerCuts);
+                });
             } else {
                 log.info("未查询到故障停电开关信息faultIdList:{}", idList);
             }
@@ -126,13 +128,13 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
                 Long id = e.getId();
                 FhzgFaultAwaitTransferUsersCountDTO userCountDtoDefault = fusersCountMap.get(id);
                 FaultPowerCutPvUsers faultPowerCutPvUsersDefault = cutPvUsersMap.get(id);
-                fillUserCountInfo(userCountDtoDefault,faultPowerCutPvUsersDefault,e,null,multiplyNumber);
+                fillUserCountInfo(userCountDtoDefault, faultPowerCutPvUsersDefault, e, null, multiplyNumber);
                 List<FhzgFaultPowerCutSectionVO> sectionList = e.getSectionList();
-                sectionList.forEach(section->{
+                sectionList.forEach(section -> {
                     Long faultId = section.getFaultId();
                     FhzgFaultAwaitTransferUsersCountDTO userCountDTO = fusersCountMap.get(faultId);
                     FaultPowerCutPvUsers faultPowerCutPvUsers = cutPvUsersMap.get(faultId);
-                    fillUserCountInfo(userCountDTO,faultPowerCutPvUsers,e,section,multiplyNumber);
+                    fillUserCountInfo(userCountDTO, faultPowerCutPvUsers, e, section, multiplyNumber);
                 });
             });
         } else {
@@ -146,9 +148,9 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
      */
     private void fillUserCountInfo(FhzgFaultAwaitTransferUsersCountDTO userCountDto, FaultPowerCutPvUsers powerCutPvUsers,
                                    FhzgFaultPowerCutVO vo, FhzgFaultPowerCutSectionVO sectionVO,
-                                   BigDecimal multiplyNumber){
+                                   BigDecimal multiplyNumber) {
         Integer pvCount = Objects.isNull(powerCutPvUsers) ? 0 : Objects.isNull(powerCutPvUsers.getCount()) ? 0 : powerCutPvUsers.getCount();
-        if(Objects.isNull(sectionVO)){
+        if (Objects.isNull(sectionVO)) {
             vo.setPvUsers(pvCount);
             if (Objects.nonNull(userCountDto)) {
                 //重要用户数量
@@ -163,7 +165,7 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
                 //保电用户数量
                 vo.setProtectUsers(userCountDto.getProtectUsers());
             }
-        }else{
+        } else {
             sectionVO.setPvUsers(pvCount);
             if (Objects.nonNull(userCountDto)) {
                 //重要用户数量
@@ -181,6 +183,7 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
         }
 
     }
+
     @Override
     public HasDataTagDTO getHasDataTag(FhzgFaultDistCustomerDTO dto) {
         Long faultId = dto.getFaultId();
@@ -262,8 +265,8 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
         FaultPowerCut entity = this.getById(faultId);
         Assert.notNull(entity, "故障区段信息不存在");
         List<FaultPowerCut> list = this.list(new LambdaQueryWrapper<FaultPowerCut>().eq(FaultPowerCut::getFaultNo, entity.getFaultNo()));
-        list.forEach(e->{
-            Integer sectionStatus = Objects.equals(faultId,e.getId())?1:0;
+        list.forEach(e -> {
+            Integer sectionStatus = Objects.equals(faultId, e.getId()) ? 1 : 0;
             e.setSectionStatus(sectionStatus);
         });
         this.updateBatchById(list);