Browse Source

大屏-整改

zhuang 6 months ago
parent
commit
bfddabdda8

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxProjectManageDao.java

@@ -142,4 +142,10 @@ public interface ZhcxProjectManageDao extends BaseMapper<ZhcxProjectManageDo> {
             "</where>" +
             "</script>")
     List<ZhcxProjectRectifyMachineVo> getListApiData(Map<String, Object> map);
+
+    @Select("SELECT a.* FROM ZHCX_PROJECT_RECTIFY_MACHINE a \n" +
+            "WHERE a.STATUS IS NOT NULL AND EXISTS (" +
+            "SELECT * FROM ZHCX_SHIP_OFFSHORE_DETAIL b " +
+            "WHERE b.PROJECTID = a.PRJID AND a.REALMACHINENO = b.MACHINENO and  b.DELETED = '0')")
+    List<ZhcxProjectRectifyMachineVo> getScreenRectifyData();
 }

+ 2 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxProjectManageService.java

@@ -111,4 +111,6 @@ public interface ZhcxProjectManageService extends IService<ZhcxProjectManageDo>
      * @return
      */
     ZhcxProjectManageDo getByCode(String prjCode);
+
+    void addScreenRectifyData();
 }

+ 77 - 4
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -23,6 +23,7 @@ import com.rongwei.bscommon.sys.dao.ZhcxProjectManageDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.*;
 import com.rongwei.bsentity.dto.project.*;
+import com.rongwei.bsentity.dto.project.indicator.DelPhysicalParam;
 import com.rongwei.bsentity.vo.RectifySnapVo;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifySnapVo;
@@ -47,12 +48,14 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -96,6 +99,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     private ZhcxProjectManageRectifyBatchService projectManageRectifyBatchService;
     @Autowired
     private ZhcxProjectRectifySnapService zhcxProjectRectifySnapService;
+    @Autowired
+    private ZhcxProjectDeviceIndicatorService zhcxProjectDeviceIndicatorService;
 
     @Value("${file.writeRootPath}")
     private String writeRootPath;
@@ -491,6 +496,76 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         return getOne(queryWrapper);
     }
 
+    @Override
+    public void addScreenRectifyData() {
+        //删除整改数据
+        DelPhysicalParam param = DelPhysicalParam.builder()
+                .type("rectify_complete")
+                .build();
+        zhcxProjectDeviceIndicatorService.delPhysical(param);
+        List<ZhcxProjectRectifyMachineVo> listData = zhcxProjectManageDao.getScreenRectifyData();
+        Map<String, List<ZhcxProjectRectifyMachineVo>> collect =
+                listData.stream().filter(item -> Objects.nonNull(item.getPrjid()))
+                        .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getPrjid));
+        collect.forEach((prjid, list) -> {
+            Map<String, List<ZhcxProjectRectifyMachineVo>> collect2 = list.stream().filter(item -> Objects.nonNull(item.getMachineno()))
+                    .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getMachineno));
+
+            ZhcxProjectManageDo projectManageDo = zhcxProjectManageDao.selectById(prjid);
+            collect2.forEach((machineno, list2) -> {
+                ZhcxProjectDeviceIndicatorDo indicator = new ZhcxProjectDeviceIndicatorDo();
+                indicator.setId(SecurityUtil.getUUID());
+                indicator.setDate(new Date());
+                indicator.setDeleted("0");
+                indicator.setProjectid(prjid);
+                indicator.setProjectcode(projectManageDo.getProjectCode());
+                indicator.setProjectname(projectManageDo.getProjectName());
+                indicator.setProjectshortname(projectManageDo.getProjectEname());
+                indicator.setMachineid(list2.get(0).getRealmachineid());
+                indicator.setMachineno(list2.get(0).getRealmachineno());
+                indicator.setDisplayboard("绿");
+                indicator.setIndicatorname("整改完成情况");
+                indicator.setType("rectify_complete");
+                indicator.setSort(8);
+                List<RectifyMachineDto> rectifyMachineDtoList = createRectifyMachineDtoList(list2, null);
+
+                indicator.setCompleted(rectifyMachineDtoList.get(0).getClosedCount() + rectifyMachineDtoList.get(0).getTbcCount());
+                indicator.setTotal(rectifyMachineDtoList.get(0).getTotalCount());
+
+                final BigDecimal denominator = BigDecimal.valueOf(indicator.getCompleted());
+                if(ObjectUtil.isNull(denominator) || BigDecimal.ZERO.equals(denominator)) { //分母为空,完成率为0
+                    indicator.setCompletionrate(BigDecimal.ZERO);
+                } else {
+                    Float f = indicator.getCompleted().floatValue() / indicator.getTotal().floatValue() * 100;
+                    indicator.setCompletionrate(new BigDecimal(String.format("%.2f", f)));
+                }
+                Map<String, List<ZhcxProjectRectifyMachineVo>> collect3 = list2.stream().filter(item -> Objects.nonNull(item.getFirstdeptid()))
+                        .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getFirstdeptid)).entrySet().stream() // 将分组结果转换为流
+                        .sorted((e1, e2) -> Integer.compare(e2.getValue().size(), e1.getValue().size())) // 按组大小降序排序
+                        .limit(2) // 只保留前两组
+                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+                StringBuilder sb = new StringBuilder();
+                AtomicInteger count = new AtomicInteger(0);
+                int totalSize = collect3.size();
+                collect3.forEach((deptid, list3) -> {
+                    List<RectifyMachineDto> deptDataVos = createRectifyMachineDtoList(list2, null);
+                    if (deptDataVos.size() > 0) {
+                        sb.append(list3.get(0).getFirstdeptname() + ",");
+                        Integer i = deptDataVos.get(0).getTbcCount() + deptDataVos.get(0).getClosedCount();
+                        sb.append(i+"/"+deptDataVos.get(0).getTotalCount() + ",");
+                        Float f = i.floatValue() / deptDataVos.get(0).getTotalCount().floatValue() * 100;
+                        sb.append(new BigDecimal(String.format("%.2f", f)));
+                        if (count.incrementAndGet() < totalSize) {
+                            sb.append("-;-");
+                        }
+                    }
+                });
+                indicator.setRoption(sb.toString());
+                zhcxProjectDeviceIndicatorService.save(indicator);
+            });
+        });
+    }
+
     //private static final BeanCopier copier = BeanCopier.create(ZhcxProjectRectifyDo.class, ZhcxProjectRectifyVo.class, false);
     @Override
     public R getRectifyListData(Map<String, Object> map) {
@@ -1141,7 +1216,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                     //组装项目和机号
                     assembletProjectAndMachine(machineNo, summaryDataBo, machine, pmMap, dnMap);
 
-                    machine.setFinishdate(LuckySheet4SummaryHelp.getDateDefaultNull(machineObj, "完成日期"));
+                    machine.setFinishdate(machineObj.getString("完成日期"));
                     String mochineStatus = machineObj.getString("状态");
                     machine.setStatus(LuckySheet4SummaryHelp.getCommonStatus(mochineStatus));
 
@@ -2557,9 +2632,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                 cells.get(rowIndex, colIndex + 2).putValue(rectifyMachineVo.getSubcontractorname());
                 cells.get(rowIndex, colIndex + 3).putValue(rectifyMachineVo.getDutydeptname());
                 cells.get(rowIndex, colIndex + 4).putValue(rectifyMachineVo.getDutysubcontractorname());
-                String formattedDate = rectifyMachineVo.getFinishdate() != null
-                        ? DateUtil.format(rectifyMachineVo.getFinishdate(), "yyyy.MM.dd")
-                        : "";
+                String formattedDate = rectifyMachineVo.getFinishdate();
                 cells.get(rowIndex, colIndex + 5).putValue(formattedDate);
                 // 设置颜色
                 for (int j = colIndex; j < colIndex + 6; j++) {

+ 1 - 1
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxProjectRectifyMachineDo.java

@@ -73,7 +73,7 @@ public class ZhcxProjectRectifyMachineDo extends BaseDo {
      * 完成日期
      */
     @TableField("FINISHDATE")
-    private Date finishdate;
+    private String finishdate;
     /**
      * 备注1
      */

+ 5 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxProjectManageController.java

@@ -224,5 +224,10 @@ public class ZhcxProjectManageController {
     public void exportRectifySnapData(@RequestBody Map<String,Object> map , HttpServletResponse response) {
         service.exportRectifySnapData(map,response);
     }
+
+    @PostMapping("/addScreenRectifyData")
+    public void addScreenRectifyData() {
+        service.addScreenRectifyData();
+    }
 }