| | |
| | | |
| | | 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.dao.DjJdgzNetworkLevel3Dao; |
| | | import com.example.server.progressTrack.model.DjJdgzNetworkLevel3; |
| | |
| | | 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<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; |
| | | } |
| | | |
| | |
| | | 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); |
| | | |
| | | 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 = 1; j <= num; j++) { |
| | | int sort = 0; |
| | | DjJdgzNetworkLevel3 data = new DjJdgzNetworkLevel3(); |
| | | DjJdgzNetworkLevel3List node = new DjJdgzNetworkLevel3List(); |
| | | |
| | |
| | | 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); |
| | | node.setProcessName(mapProcessName.get(1)); |
| | | node.setSort(1); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time1.matches("[0-9.]+")) { |
| | | time1 = time1.replace(".", "-"); |
| | | node.setRequiredCompletionTime(time1); |
| | | node.setProcessName(mapProcessName.get(1)); |
| | | node.setSort(1); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time1.matches("[0-9-]+")) { |
| | | node.setRequiredCompletionTime(time1); |
| | | node.setProcessName(mapProcessName.get(1)); |
| | | node.setSort(1); |
| | | node.setSort(sort + 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/]+")) { |
| | | node.setRequiredCompletionTime(time2); |
| | | node.setProcessName(mapProcessName.get(2)); |
| | | node.setSort(2); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time2.matches("[0-9.]+")) { |
| | | time2 = time2.replace(".", "-"); |
| | | node.setRequiredCompletionTime(time2); |
| | | node.setProcessName(mapProcessName.get(2)); |
| | | node.setSort(2); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time2.matches("[0-9-]+")) { |
| | | node.setRequiredCompletionTime(time2); |
| | | node.setProcessName(mapProcessName.get(2)); |
| | | node.setSort(2); |
| | | node.setSort(sort + 1); |
| | | 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/]+")) { |
| | | time3 = time3.replace("/", "-"); |
| | | node.setRequiredCompletionTime(time3); |
| | | node.setProcessName(mapProcessName.get(3)); |
| | | node.setSort(3); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time3.matches("[0-9.]+")) { |
| | | time3 = time3.replace(".", "-"); |
| | | node.setRequiredCompletionTime(time3); |
| | | node.setProcessName(mapProcessName.get(3)); |
| | | node.setSort(3); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time3.matches("[0-9-]+")) { |
| | | node.setRequiredCompletionTime(time3); |
| | | node.setProcessName(mapProcessName.get(3)); |
| | | node.setSort(3); |
| | | node.setSort(sort + 1); |
| | | 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/]+")) { |
| | | time4 = time4.replace("/", "-"); |
| | | node.setRequiredCompletionTime(time4); |
| | | node.setProcessName(mapProcessName.get(4)); |
| | | node.setSort(4); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time4.matches("[0-9.]+")) { |
| | | time4 = time4.replace(".", "-"); |
| | | node.setRequiredCompletionTime(time4); |
| | | node.setProcessName(mapProcessName.get(4)); |
| | | node.setSort(4); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time4.matches("[0-9-]+")) { |
| | | node.setRequiredCompletionTime(time4); |
| | | node.setProcessName(mapProcessName.get(4)); |
| | | node.setSort(4); |
| | | node.setSort(sort + 1); |
| | | 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/]+")) { |
| | | time5 = time5.replace("/", "-"); |
| | | node.setRequiredCompletionTime(time5); |
| | | node.setProcessName(mapProcessName.get(5)); |
| | | node.setSort(5); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time5.matches("[0-9.]+")) { |
| | | time5 = time5.replace(".", "-"); |
| | | node.setRequiredCompletionTime(time5); |
| | | node.setProcessName(mapProcessName.get(5)); |
| | | node.setSort(5); |
| | | node.setSort(sort + 1); |
| | | DjJdgzNetworkLevel3ListService.insert(node); |
| | | } else if (time5.matches("[0-9-]+")) { |
| | | node.setRequiredCompletionTime(time5); |
| | | node.setProcessName(mapProcessName.get(5)); |
| | | node.setSort(5); |
| | | node.setSort(sort + 1); |
| | | 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(generalRepairUnit)) { |
| | | data.setRepairUnit(repairUnit); |
| | | } |
| | | if(StringUtils.isNotBlank(generalRepairUnit)){ |
| | | if (StringUtils.isNotBlank(generalRepairUnit)) { |
| | | data.setRepairUnitContact(repairUnitContact); |
| | | } |
| | | if(StringUtils.isNotBlank(generalRepairUnit)){ |
| | | if (StringUtils.isNotBlank(generalRepairUnit)) { |
| | | data.setRepairUnitDirector(repairUnitDirector); |
| | | } |
| | | |
| | |
| | | } |
| | | } 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 void exportExcelTemplate(HttpServletResponse response, HttpServletRequest request) throws IOException { |
| | | String excelName="三级网络图批量模版"; |
| | | String excelPath = path + "template/jx-model/" + excelName + ".xlsx"; //模板路径 |