From 77d58298d00c11ade8862ca8acb0fdef5a45322e Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期五, 21 三月 2025 17:39:38 +0800
Subject: [PATCH] 修改
---
src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java | 278 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 214 insertions(+), 64 deletions(-)
diff --git a/src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java b/src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java
index 557a72c..fe05030 100644
--- a/src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java
+++ b/src/main/java/com/example/server/progressTrack/service/DjJdgzNetworkLevel3Service.java
@@ -2,7 +2,10 @@
import com.example.client.dto.JComboBoxItem;
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.StatistProductDto;
+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;
@@ -22,6 +25,8 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.*;
@@ -39,13 +44,24 @@
DjJdgzNetworkLevel3ListService DjJdgzNetworkLevel3ListService;
@Autowired
SysTeamGroupClassService sysTeamGroupClassService;
+ @Autowired
+ CabinService cabinService;
@Value("${zt.oss.local-path}")
private String path;
- public List<DjJdgzNetworkLevel3> getList(Long shipId) {
- List<DjJdgzNetworkLevel3> list = baseDao.getList(shipId);
+ public List<StatistProductDto> getStatist(Long level1Id) {
+ return baseDao.getStatist(level1Id);
+ }
+
+ 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);
return list;
}
@@ -120,15 +136,33 @@
sum = sum + num;
Map<Integer, String> mapProcessName = new HashMap<>();
- mapProcessName.put(1,"璁惧鎷嗗嵏鍑鸿埍");
- mapProcessName.put(2,"璁惧鍒嗕氦");
- mapProcessName.put(3,"鎷嗘閴村畾");
- mapProcessName.put(4,"璁惧杩斿巶");
- mapProcessName.put(5,"鍥炶");
+ mapProcessName.put(1, "璁惧鎷嗗嵏鍑鸿埍");
+ mapProcessName.put(2, "璁惧鍒嗕氦");
+ mapProcessName.put(3, "鎷嗘閴村畾");
+ mapProcessName.put(4, "璁惧杩斿巶");
+ mapProcessName.put(5, "鍥炶");
Map<String, String> mapTeamGroup = sysTeamGroupClassService.getMapGroup(false, "hld");
+ JComboBoxItem[] cabinList = cabinService.getList();
+ JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList();
+ JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null);
- for (int j = 1; j <= num; j++) {
+ Map<String, Long> cabinMap = new HashMap<>();
+ Map<String, Long> deptMap = new HashMap<>();
+ Map<String, Long> teamMap = new HashMap<>();
+
+ for (JComboBoxItem item : cabinList) {
+ cabinMap.put(item.getName(), item.getId());
+ }
+ for (JComboBoxItem item : deptList) {
+ deptMap.put(item.getName(), item.getId());
+ }
+ for (JComboBoxItem item : teamList) {
+ teamMap.put(item.getName(), item.getId());
+ }
+
+ for (int j = 2; j <= num; j++) {
+ int sort = 0;
DjJdgzNetworkLevel3 data = new DjJdgzNetworkLevel3();
DjJdgzNetworkLevel3List node = new DjJdgzNetworkLevel3List();
@@ -138,48 +172,97 @@
Row row = sheet.getRow(j);
String name = ImportUtil.getCellValue(row, 0, pattern);
- String teamGroup = ImportUtil.getCellValue(row, 1, pattern);
- String time1 = ImportUtil.getCellValue(row, 2, pattern);
- String time2 = ImportUtil.getCellValue(row, 3, pattern);
- String time3 = ImportUtil.getCellValue(row, 4, pattern);
- String time4 = ImportUtil.getCellValue(row, 5, pattern);
- String time5 = ImportUtil.getCellValue(row, 6, pattern);
- String repairUnit = ImportUtil.getCellValue(row, 7, pattern);
- String repairUnitDirector = ImportUtil.getCellValue(row, 8, pattern);
- String repairUnitContact = ImportUtil.getCellValue(row, 9, pattern);
- String generalRepairUnit = ImportUtil.getCellValue(row, 10, pattern);
- String generalRepairUnitDirector = ImportUtil.getCellValue(row, 11, pattern);
- String generalRepairUnitContact = ImportUtil.getCellValue(row, 12, pattern);
+ String deptStr = ImportUtil.getCellValue(row, 1, pattern);
+ String teamGroupStr = ImportUtil.getCellValue(row, 2, pattern);
+ String cabinStr = ImportUtil.getCellValue(row, 3, pattern);
+ String typeStr = ImportUtil.getCellValue(row, 4, pattern);
+ String time1 = ImportUtil.getCellValue(row, 5, pattern);
+ String time2 = ImportUtil.getCellValue(row, 6, pattern);
+ String time3 = ImportUtil.getCellValue(row, 7, pattern);
+ String time4 = ImportUtil.getCellValue(row, 8, pattern);
+ String time5 = ImportUtil.getCellValue(row, 9, pattern);
+ String repairUnit = ImportUtil.getCellValue(row, 10, pattern);
+ String repairUnitDirector = ImportUtil.getCellValue(row, 11, pattern);
+ String repairUnitContact = ImportUtil.getCellValue(row, 12, pattern);
+ String generalRepairUnit = ImportUtil.getCellValue(row, 13, pattern);
+ String generalRepairUnitDirector = ImportUtil.getCellValue(row, 14, pattern);
+ String generalRepairUnitContact = ImportUtil.getCellValue(row, 15, pattern);
Long id = UUIDUtil.generateId();
if (StringUtils.isEmpty(name)) {
- result = "绗�"+j+"琛�"+"璁惧鍚嶇О涓嶈兘涓虹┖";
+ result = "绗�" + j + "琛�" + "璁惧鍚嶇О涓嶈兘涓虹┖";
isErr = true;
+ continue;
} else {
data.setId(id);
+ node.setNetworkId(id);
data.setName(name);
data.setLevel1NetworkId(level1NetworkId);
data.setLevel2NetworkId(level2NetworkId);
data.setLevel2NodeId(level2NodeId);
}
- if (StringUtils.isEmpty(teamGroup)) {
- result = "绗�"+j+"琛�"+"涓撲笟涓嶈兘涓虹┖";
+ if (StringUtils.isEmpty(deptStr)) {
+ result = "绗�" + j + "琛�" + "閮ㄩ棬涓嶈兘涓虹┖";
isErr = true;
+ continue;
} else {
- Long teamGroupId = Long.valueOf(mapTeamGroup.get(teamGroup));
- //鍒犻櫎鏁版嵁搴撲腑鐩稿悓涓撲笟鍙婄浉鍚屼笁绾х綉缁滃浘鏁版嵁
- baseDao.deleteByTeamGroup(teamGroupId, name);
-
- node.setTeamgroupId(teamGroupId);
- node.setTeamgroupName(teamGroup);
- node.setNetworkId(id);
+ if (deptMap.get(deptStr) == null) {
+ result = "绗�" + j + "琛�" + "閮ㄩ棬涓嶅瓨鍦�";
+ isErr = true;
+ continue;
+ } else {
+ Long deptId = deptMap.get(deptStr);
+ data.setDeptId(deptId);
+ }
}
- if (StringUtils.isEmpty(time1)) {
- result = "绗�"+j+"琛�"+"绗�"+1+"涓�"+"鑺傜偣鏃堕棿涓嶈兘涓虹┖";
+ if (StringUtils.isEmpty(teamGroupStr)) {
+ result = "绗�" + j + "琛�" + "涓撲笟涓嶈兘涓虹┖";
isErr = true;
+ continue;
} else {
+ if (teamMap.get(teamGroupStr) == null) {
+ result = "绗�" + j + "琛�" + "涓撲笟涓嶅瓨鍦�";
+ isErr = true;
+ continue;
+ } else {
+ Long teamId = teamMap.get(teamGroupStr);
+ data.setTeamgroupId(teamId);
+ data.setTeamgroupName(teamGroupStr);
+ }
+ }
+
+ if (StringUtils.isEmpty(cabinStr)) {
+ result = "绗�" + j + "琛�" + "鑸卞涓嶈兘涓虹┖";
+ isErr = true;
+ continue;
+ } else {
+ String[] cabins = cabinStr.split(",");
+
+ // 鐢ㄤ簬瀛樺偍鎷兼帴鍚庣殑 id
+ StringBuilder idBuilder = new StringBuilder();
+
+ // 閬嶅巻姣忎釜閿�
+ for (String key : cabins) {
+ key = key.trim(); // 鍘婚櫎鍙兘鐨勭┖鏍�
+ Long cabinId = cabinMap.get(key);
+ // 濡傛灉閿湪 Map 涓瓨鍦�
+ if (cabinId != null) {
+ if (idBuilder.length() > 0) {
+ idBuilder.append(","); // 娣诲姞鍒嗛殧绗�
+ }
+ idBuilder.append(cabinId); // 娣诲姞 id
+ } else {
+ result = "绗�" + j + "琛�" + "鑸卞涓嶅瓨鍦�";
+ isErr = true;
+ continue;
+ }
+ }
+ data.setCabinId(idBuilder.toString());
+ }
+
+ if (StringUtils.isNotBlank(time1)) {
if (time1.matches("[0-9/]+")) {
time1 = time1.replace("/", "-");
node.setRequiredCompletionTime(time1);
@@ -198,16 +281,13 @@
node.setSort(1);
DjJdgzNetworkLevel3ListService.insert(node);
} else {
- result = "绗�"+j+"琛�"+"绗�"+1+"涓�"+"鑺傜偣鏃堕棿鏃ユ湡鏍煎紡涓嶈鑼�";
+ result = "绗�" + j + "琛�" + "绗�" + 1 + "涓�" + "鑺傜偣鏃堕棿鏃ユ湡鏍煎紡涓嶈鑼�";
isErr = true;
}
}
- if (StringUtils.isEmpty(time2)) {
- result = "绗�"+j+"琛�"+"绗�"+2+"涓�"+"鑺傜偣鏃堕棿涓嶈兘涓虹┖";
- isErr = true;
- } else {
- if (node.getId()!=null){
+ if (StringUtils.isNotBlank(time2)) {
+ if (node.getId() != null) {
node.setId(null);
}
if (time2.matches("[0-9/]+")) {
@@ -227,16 +307,13 @@
node.setSort(2);
DjJdgzNetworkLevel3ListService.insert(node);
} else {
- result = "绗�"+j+"琛�"+"绗�"+2+"涓�"+"鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
+ result = "绗�" + j + "琛�" + "绗�" + 2 + "涓�" + "鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
isErr = true;
}
}
- if (StringUtils.isEmpty(time3)) {
- result = "绗�"+j+"琛�"+"绗�"+3+"涓�"+"鑺傜偣鏃堕棿涓嶈兘涓虹┖";
- isErr = true;
- } else {
- if (node.getId()!=null){
+ if (StringUtils.isNotBlank(time3)) {
+ if (node.getId() != null) {
node.setId(null);
}
if (time3.matches("[0-9/]+")) {
@@ -257,16 +334,13 @@
node.setSort(3);
DjJdgzNetworkLevel3ListService.insert(node);
} else {
- result = "绗�"+j+"琛�"+"绗�"+3+"涓�"+"鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
+ result = "绗�" + j + "琛�" + "绗�" + 3 + "涓�" + "鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
isErr = true;
}
}
- if (StringUtils.isEmpty(time4)) {
- result = "绗�"+j+"琛�"+"绗�"+4+"涓�"+"鑺傜偣鏃堕棿涓嶈兘涓虹┖";
- isErr = true;
- } else {
- if (node.getId()!=null){
+ if (StringUtils.isNotBlank(time4)) {
+ if (node.getId() != null) {
node.setId(null);
}
if (time4.matches("[0-9/]+")) {
@@ -287,16 +361,13 @@
node.setSort(4);
DjJdgzNetworkLevel3ListService.insert(node);
} else {
- result = "绗�"+j+"琛�"+"绗�"+4+"涓�"+"鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
+ result = "绗�" + j + "琛�" + "绗�" + 4 + "涓�" + "鑺傜偣鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
isErr = true;
}
}
- if (StringUtils.isEmpty(time5)) {
- result = "绗�"+j+"琛�"+"绗�"+5+"涓�"+"鑺傜偣鏃堕棿涓嶈兘涓虹┖";
- isErr = true;
- } else {
- if (node.getId()!=null){
+ if (StringUtils.isNotBlank(time5)) {
+ if (node.getId() != null) {
node.setId(null);
}
if (time5.matches("[0-9/]+")) {
@@ -317,27 +388,31 @@
node.setSort(5);
DjJdgzNetworkLevel3ListService.insert(node);
} else {
- result = "绗�"+j+"琛�"+"绗�"+5+"涓�"+"瑕佹眰瀹屾垚鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
+ result = "绗�" + j + "琛�" + "绗�" + 5 + "涓�" + "瑕佹眰瀹屾垚鏃堕棿鐨勬棩鏈熸牸寮忎笉瑙勮寖";
isErr = true;
}
}
- if(StringUtils.isNotBlank(generalRepairUnit)){
+
+ if (StringUtils.isNotBlank(typeStr)) {
+ data.setType(typeStr);
+ }
+ if (StringUtils.isNotBlank(generalRepairUnit)) {
data.setGeneralRepairUnit(generalRepairUnit);
}
- if(StringUtils.isNotBlank(generalRepairUnitContact)){
+ if (StringUtils.isNotBlank(generalRepairUnitContact)) {
data.setGeneralRepairUnitContact(generalRepairUnitContact);
}
- if(StringUtils.isNotBlank(generalRepairUnitDirector)){
+ 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);
}
@@ -354,13 +429,88 @@
}
} catch (Exception e) {
e.printStackTrace();
- result = "瀵煎叆"+row1+"琛屾暟鎹椂妫�娴嬪埌寮傚父锛屼腑鏂鍏ユ搷浣溿��";
+ result = "瀵煎叆" + row1 + "琛屾暟鎹椂妫�娴嬪埌寮傚父锛屼腑鏂鍏ユ搷浣溿��";
}
suc = sum - err;
return result;
}
+
+ public JComboBoxItem[] getListByExport(Long projectId, Long deptId, Long teamId) {
+ 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"; //妯℃澘璺緞
--
Gitblit v1.9.1