jinlin
2025-03-18 d30e385951ce03335a5023f0775fd144da3c0b88
src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java
@@ -4,6 +4,7 @@
import com.example.client.service.BaseService;
import com.example.server.cabin.service.CabinService;
import com.example.server.progressTrack.Dto.NetworkNodeStatusDto;
import com.example.server.progressTrack.Dto.TableNodeDto;
import com.example.server.progressTrack.dao.DjJdgzNetworkLevel3Dao;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel3;
import com.example.server.progressTrack.model.DjJdgzNetworkLevel3List;
@@ -23,6 +24,8 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -46,6 +49,11 @@
    @Value("${zt.oss.local-path}")
    private String path;
    enum StatusEnum {zy, jxz, lq, yq, zcwc, cqwc}
    String[] fillColorArr = {"#e5e5e5", "#3498DB", "#F1C40F", "#E74C3C", "#2ECC71", "#006400"};
    String[] fontColorArr = {"#e5e5e5", "#3498DB", "#F1C40F", "#E74C3C", "#2ECC71", "#006400"};
    public List<DjJdgzNetworkLevel3> getList(Long shipId, Long deptId, Long teamId, Long cabinId, String type, String name) {
        List<DjJdgzNetworkLevel3> list = baseDao.getList(shipId, deptId, teamId, cabinId, type, name);
@@ -148,7 +156,7 @@
                teamMap.put(item.getName(), item.getId());
            }
            for (int j = 1; j <= num; j++) {
            for (int j = 2; j <= num; j++) {
                int sort = 0;
                DjJdgzNetworkLevel3 data = new DjJdgzNetworkLevel3();
                DjJdgzNetworkLevel3List node = new DjJdgzNetworkLevel3List();
@@ -254,18 +262,18 @@
                        time1 = time1.replace("/", "-");
                        node.setRequiredCompletionTime(time1);
                        node.setProcessName(mapProcessName.get(1));
                        node.setSort(sort + 1);
                        node.setSort(1);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time1.matches("[0-9.]+")) {
                        time1 = time1.replace(".", "-");
                        node.setRequiredCompletionTime(time1);
                        node.setProcessName(mapProcessName.get(1));
                        node.setSort(sort + 1);
                        node.setSort(1);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time1.matches("[0-9-]+")) {
                        node.setRequiredCompletionTime(time1);
                        node.setProcessName(mapProcessName.get(1));
                        node.setSort(sort + 1);
                        node.setSort(1);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else {
                        result = "第" + j + "行" + "第" + 1 + "个" + "节点时间日期格式不规范";
@@ -280,18 +288,18 @@
                    if (time2.matches("[0-9/]+")) {
                        node.setRequiredCompletionTime(time2);
                        node.setProcessName(mapProcessName.get(2));
                        node.setSort(sort + 1);
                        node.setSort(2);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time2.matches("[0-9.]+")) {
                        time2 = time2.replace(".", "-");
                        node.setRequiredCompletionTime(time2);
                        node.setProcessName(mapProcessName.get(2));
                        node.setSort(sort + 1);
                        node.setSort(2);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time2.matches("[0-9-]+")) {
                        node.setRequiredCompletionTime(time2);
                        node.setProcessName(mapProcessName.get(2));
                        node.setSort(sort + 1);
                        node.setSort(2);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else {
                        result = "第" + j + "行" + "第" + 2 + "个" + "节点时间的日期格式不规范";
@@ -307,18 +315,18 @@
                        time3 = time3.replace("/", "-");
                        node.setRequiredCompletionTime(time3);
                        node.setProcessName(mapProcessName.get(3));
                        node.setSort(sort + 1);
                        node.setSort(3);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time3.matches("[0-9.]+")) {
                        time3 = time3.replace(".", "-");
                        node.setRequiredCompletionTime(time3);
                        node.setProcessName(mapProcessName.get(3));
                        node.setSort(sort + 1);
                        node.setSort(3);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time3.matches("[0-9-]+")) {
                        node.setRequiredCompletionTime(time3);
                        node.setProcessName(mapProcessName.get(3));
                        node.setSort(sort + 1);
                        node.setSort(3);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else {
                        result = "第" + j + "行" + "第" + 3 + "个" + "节点时间的日期格式不规范";
@@ -334,18 +342,18 @@
                        time4 = time4.replace("/", "-");
                        node.setRequiredCompletionTime(time4);
                        node.setProcessName(mapProcessName.get(4));
                        node.setSort(sort + 1);
                        node.setSort(4);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time4.matches("[0-9.]+")) {
                        time4 = time4.replace(".", "-");
                        node.setRequiredCompletionTime(time4);
                        node.setProcessName(mapProcessName.get(4));
                        node.setSort(sort + 1);
                        node.setSort(4);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time4.matches("[0-9-]+")) {
                        node.setRequiredCompletionTime(time4);
                        node.setProcessName(mapProcessName.get(4));
                        node.setSort(sort + 1);
                        node.setSort(4);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else {
                        result = "第" + j + "行" + "第" + 4 + "个" + "节点时间的日期格式不规范";
@@ -361,18 +369,18 @@
                        time5 = time5.replace("/", "-");
                        node.setRequiredCompletionTime(time5);
                        node.setProcessName(mapProcessName.get(5));
                        node.setSort(sort + 1);
                        node.setSort(5);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time5.matches("[0-9.]+")) {
                        time5 = time5.replace(".", "-");
                        node.setRequiredCompletionTime(time5);
                        node.setProcessName(mapProcessName.get(5));
                        node.setSort(sort + 1);
                        node.setSort(5);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else if (time5.matches("[0-9-]+")) {
                        node.setRequiredCompletionTime(time5);
                        node.setProcessName(mapProcessName.get(5));
                        node.setSort(sort + 1);
                        node.setSort(5);
                        DjJdgzNetworkLevel3ListService.insert(node);
                    } else {
                        result = "第" + j + "行" + "第" + 5 + "个" + "要求完成时间的日期格式不规范";
@@ -393,13 +401,13 @@
                if (StringUtils.isNotBlank(generalRepairUnitDirector)) {
                    data.setGeneralRepairUnitDirector(generalRepairUnitDirector);
                }
                if (StringUtils.isNotBlank(generalRepairUnit)) {
                if (StringUtils.isNotBlank(repairUnit)) {
                    data.setRepairUnit(repairUnit);
                }
                if (StringUtils.isNotBlank(generalRepairUnit)) {
                if (StringUtils.isNotBlank(repairUnitContact)) {
                    data.setRepairUnitContact(repairUnitContact);
                }
                if (StringUtils.isNotBlank(generalRepairUnit)) {
                if (StringUtils.isNotBlank(repairUnitDirector)) {
                    data.setRepairUnitDirector(repairUnitDirector);
                }
@@ -428,6 +436,76 @@
        JComboBoxItem[] list = baseDao.getListByExport(projectId, deptId, teamId);
        return list;
    }
    public List<TableNodeDto> getNodeList(Long shipId, Long deptId, Long teamId, Long cabinId, String type, String name) {
        List<TableNodeDto> list = baseDao.getNodeList(shipId, deptId, teamId, cabinId, type, name);
        Map<Long, StatusEnum> statusMap = new HashMap<>();
        Date today = new Date();
        for (TableNodeDto node : list) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date requiredCompletionDate = null;
            Date actualCompletionDate = null;
            try {
                if (StringUtils.isNotBlank(node.getRequiredCompletionTime())) {
                    requiredCompletionDate = sdf.parse(node.getRequiredCompletionTime());
                }
                if (StringUtils.isNotBlank(node.getActualCompletion())) {
                    actualCompletionDate = sdf.parse(node.getActualCompletion());
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
            if (node.getCurrentStatus() == null || node.getCurrentStatus() == 0) {
                if (today.after(requiredCompletionDate)) {
                    statusMap.put(node.getId(), StatusEnum.yq);
                } else if ((requiredCompletionDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24) < 7) {
                    statusMap.put(node.getId(), StatusEnum.lq);
                } else {
                    statusMap.put(node.getId(), StatusEnum.jxz);
                }
            } else if (node.getCurrentStatus() == 1) {
                // 已完成
                if (node.getActualCompletion() != null && actualCompletionDate.after(requiredCompletionDate)) {
                    statusMap.put(node.getId(), StatusEnum.cqwc);
                } else {
                    statusMap.put(node.getId(), StatusEnum.zcwc);
                }
            }
        }
        StatusEnum status = StatusEnum.jxz;
        List<TableNodeDto> dataList = new ArrayList<>();
        Long oldId = 0L;
        TableNodeDto data = null;
        for (TableNodeDto node : list) {
            if (oldId.equals(node.getNetworkId())){
            }else{
                data = new TableNodeDto();
                data.setName(node.getName());
                data.setNetworkId(node.getNetworkId());
                dataList.add(data);
                oldId = node.getNetworkId();
            }
            status = statusMap.get(node.getId());
            if (node.getProcessName().equals("设备拆卸出舱")) {
                data.setTime1Color(fillColorArr[status.ordinal()]);
            } else if (node.getProcessName().equals("设备分交")) {
                data.setTime2Color(fillColorArr[status.ordinal()]);
            } else if (node.getProcessName().equals("拆检鉴定")) {
                data.setTime3Color(fillColorArr[status.ordinal()]);
            } else if (node.getProcessName().equals("设备返厂")) {
                data.setTime4Color(fillColorArr[status.ordinal()]);
            } else if (node.getProcessName().equals("回装")) {
                data.setTime5Color(fillColorArr[status.ordinal()]);
            }
        }
        return dataList;
    }
  /*  public void exportExcelTemplate(HttpServletResponse response, HttpServletRequest request) throws IOException {
        String excelName="三级网络图批量模版";
        String excelPath = path + "template/jx-model/" + excelName + ".xlsx"; //模板路径