From 36deabe1df249a56a553fb606447dd326a2c81a7 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期四, 06 三月 2025 15:22:54 +0800 Subject: [PATCH] UPDATE --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 185 ++++++++++++++++++++++++++++++---------------- 1 files changed, 120 insertions(+), 65 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java index 5891439..0f7bbce 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java @@ -21,10 +21,7 @@ import org.jeecg.modules.mdc.util.DateUtils; import org.jeecg.modules.mdc.util.FindsEquipmentDepartUtil; import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; -import org.jeecg.modules.mdc.vo.MdcEquipmentDepVo; -import org.jeecg.modules.mdc.vo.MdcEquipmentProVo; -import org.jeecg.modules.mdc.vo.MdcEquipmentVo; -import org.jeecg.modules.mdc.vo.WorkshopEquipmentVo; +import org.jeecg.modules.mdc.vo.*; import org.jeecg.modules.system.entity.MdcEquipmentDepart; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.entity.MdcProductionEquipment; @@ -230,7 +227,7 @@ } @Override - public List<MdcEquipmentTree> loadTreeListByDepart(String userId) { + public List<MdcEquipmentTree> loadTreeListByDepart(String userId, String key) { //鑾峰彇鎵�鏈夐儴闂ㄦ暟鎹� List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(SysDepart::getDepartOrder)); //鏍规嵁鐢ㄦ埛ID鑾峰彇鎷ユ湁鐨勯儴闂╥d闆嗗悎 @@ -247,7 +244,7 @@ //缁勮閮ㄩ棬璁惧鏍� List<MdcEquipmentTree> treeList = FindsEquipmentDepartUtil.wrapEquipmentDepartTreeList(list); //濉厖璁惧鏁版嵁 - FillEquipmentByDepart(treeList); + FillEquipmentByDepart(treeList, key); return treeList; } @@ -256,9 +253,9 @@ * * @param treeList */ - private void FillEquipmentByDepart(List<MdcEquipmentTree> treeList) { + private void FillEquipmentByDepart(List<MdcEquipmentTree> treeList, String key) { for (MdcEquipmentTree mdcEquipmentTree : treeList) { - List<MdcEquipment> equipmentList = this.baseMapper.queryByDepartId(mdcEquipmentTree.getKey()); + List<MdcEquipment> equipmentList = this.baseMapper.queryByDepartId(mdcEquipmentTree.getKey(), key); if (equipmentList != null && !equipmentList.isEmpty()) { for (MdcEquipment mdcEquipment : equipmentList) { MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); @@ -268,7 +265,7 @@ mdcEquipmentTree.setLeaf(false); } if (!mdcEquipmentTree.getChildren().isEmpty()) { - FillEquipmentByDepart(mdcEquipmentTree.getChildren()); + FillEquipmentByDepart(mdcEquipmentTree.getChildren(), key); } } } @@ -295,7 +292,7 @@ @Override - public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { + public List<MdcEquipmentTree> loadTreeListByProduction(String userId, String key) { //鑾峰彇鎵�鏈変骇绾挎暟鎹� List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); //鏍规嵁鐢ㄦ埛id鑾峰彇鎷ユ湁鐨勪骇绾夸俊鎭泦鍚� @@ -312,7 +309,7 @@ //缁勮浜х嚎璁惧鏍� List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); //濉厖璁惧鏁版嵁 - FillEquipmentByProduction(treeList); + FillEquipmentByProduction(treeList, key); return treeList; } @@ -378,6 +375,9 @@ ControlSystem controlSystem = controlSystemService.getByDriveType(mdcEquipmentDto.getDriveType()); // 鏌ヨ璁惧鐘舵�� EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId()); + if (equipmentLog == null) { + return mdcEquipmentDto; + } Integer oporation = equipmentLog.getOporation(); if (controlSystem != null) { @@ -455,7 +455,7 @@ } else { value = "鏃�"; } - } else if ("alarmContent".equals(englishName)) { + } else if ("alarmContent".equals(englishName)) { if (oporation == 22) { List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, mdcEquipment.getDriveType()).eq(MdcAlarmInfo::getAlarmCode, equipmentLog.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0)); if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) { @@ -632,9 +632,9 @@ /** * 浜х嚎璁惧鏍戝~鍏呰澶囨暟鎹� */ - private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList) { + private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList, String key) { for (MdcEquipmentTree mdcEquipmentTree : treeList) { - List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey()); + List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey(), key); if (equipmentList != null && !equipmentList.isEmpty()) { for (MdcEquipment mdcEquipment : equipmentList) { MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); @@ -644,7 +644,7 @@ mdcEquipmentTree.setLeaf(false); } if (!mdcEquipmentTree.getChildren().isEmpty()) { - FillEquipmentByProduction(mdcEquipmentTree.getChildren()); + FillEquipmentByProduction(mdcEquipmentTree.getChildren(), key); } } } @@ -724,8 +724,28 @@ } @Override - public List<String> listEquipmentId(String equipmentType, List<String> equipmentIdList) { - List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList)); + public List<String> listEquipmentId(MdcEfficiencyReportQueryVo vo) { + LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); + if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { + queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); + } + if (StringUtils.isNotEmpty(vo.getEquipmentType())) { + queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { + queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDriveType())) { + queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDeviceCategory())) { + queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(","))); + } + if (vo.getDeviceImportanceLevel() != null) { + queryWrapper.eq(MdcEquipment::getDeviceImportanceLevel, vo.getDeviceImportanceLevel()); + } + List<MdcEquipment> list = super.list(queryWrapper); +// List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList)); return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); } @@ -747,8 +767,9 @@ // List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getDriveType, "FANUC")); List<MdcEquipment> equipmentList = super.list(); //List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentId, "2140198")); - + Map<String, String> proNamesByEquipmentIds = this.getProNamesByEquipmentIds(equipmentList.stream().map(MdcEquipment::getId).collect(Collectors.toList())); for (MdcEquipment mdcEquipment : equipmentList) { + String productionName = proNamesByEquipmentIds.get(mdcEquipment.getId()); List<MdcEquipmentThreshold> mdcEquipmentThresholdList = mdcEquipmentThresholdService.list(new LambdaQueryWrapper<MdcEquipmentThreshold>().eq(MdcEquipmentThreshold::getControlSystemType, mdcEquipment.getDriveType())); if (mdcEquipmentThresholdList != null && !mdcEquipmentThresholdList.isEmpty()) { String saveTableName = mdcEquipment.getSaveTableName(); @@ -759,15 +780,20 @@ Map<String, Object> param = new HashMap<>(); param.put("columns", builder.toString()); param.put("tableName", saveTableName); - Map<String, Object> map = this.baseMapper.getWorkLineLast(param); - if (map != null) { + Map<String, Object> map = new HashMap<>(); + try { + map = this.baseMapper.getWorkLineLast(param); + } catch (Exception e) { + log.error("鏌ヨ鍗曡〃鏁版嵁鍑哄樊锛�", e); + } + if (!map.isEmpty()) { for (MdcEquipmentThreshold mdcEquipmentThreshold : mdcEquipmentThresholdList) { Integer actualValue = Integer.valueOf(map.get(mdcEquipmentThreshold.getEnglishName()).toString()); Integer max = mdcEquipmentThreshold.getMaxThreshold(); Integer min = mdcEquipmentThreshold.getMinThreshold(); MessageDTO messageDTO = new MessageDTO(); - messageDTO.setTitle("璁惧" + mdcEquipmentThreshold.getChineseName() + "鎶ヨ锛�"); - messageDTO.setCategory("棰勮娑堟伅"); + messageDTO.setTitle("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "鎶ヨ锛�"); + messageDTO.setCategory(CommonConstant.MSG_CATEGORY_2); messageDTO.setFromUser("admin"); messageDTO.setToUser("admin"); MdcOverrunAlarm mdcOverrunAlarm = new MdcOverrunAlarm(); @@ -776,59 +802,20 @@ mdcOverrunAlarm.setRealValue(actualValue.toString()); if (actualValue > max) { // 楂� - messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒"); + messageDTO.setContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒"); sysBaseApi.sendSysAnnouncement(messageDTO); - mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "楂樻姤璀�"); + mdcOverrunAlarm.setAlarmContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒"); mdcOverrunAlarmService.save(mdcOverrunAlarm); } else if (actualValue < min) { // 浣� - messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒"); + messageDTO.setContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒"); sysBaseApi.sendSysAnnouncement(messageDTO); - mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "浣庢姤璀�"); + mdcOverrunAlarm.setAlarmContent("銆愯澶囧紓甯告彁閱掋��" + productionName + "杞﹂棿璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒"); mdcOverrunAlarmService.save(mdcOverrunAlarm); } } } } - - -// //鏌ヨ鍗曡〃鏁版嵁 -// MdcEquipmentDto mdcEquipmentDto = this.baseMapper.getWorkLineLast(saveTableName); -// if (mdcEquipmentDto != null) { -// MessageDTO messageDTO = new MessageDTO(); -// messageDTO.setTitle("璁惧杩愯杞�熸姤璀︼紒"); -// messageDTO.setCategory("棰勮娑堟伅"); -// messageDTO.setFromUser("admin"); -// messageDTO.setToUser("admin"); -// Integer spindlespeed = Integer.valueOf(mdcEquipmentDto.getSpindlespeed()); -// Integer actualspindlespeed = Integer.valueOf(mdcEquipmentDto.getActualspindlespeed()); -// if (range.equals(0)) { -// if (spindlespeed > actualspindlespeed) { -// // 瀹為檯鍊煎ぇ浜庤瀹氬�� 楂� -// messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熼珮鎶ヨ锛�"); -// sysBaseApi.sendSysAnnouncement(messageDTO); -// } else if (spindlespeed < actualspindlespeed) { -// // 瀹為檯鍊煎皬浜庤瀹氬�� 浣� -// messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熶綆鎶ヨ锛�"); -// sysBaseApi.sendSysAnnouncement(messageDTO); -// } -// } else { -// int max = actualspindlespeed + actualspindlespeed * (range / 100); -// int min = actualspindlespeed - actualspindlespeed * (range / 100); -// if (spindlespeed > max || spindlespeed < min) { -// if (spindlespeed > actualspindlespeed) { -// // 瀹為檯鍊煎ぇ浜庤瀹氬�� 楂� -// messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熼珮鎶ヨ锛�"); -// sysBaseApi.sendSysAnnouncement(messageDTO); -// } else if (spindlespeed < actualspindlespeed) { -// // 瀹為檯鍊煎皬浜庤瀹氬�� 浣� -// messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熶綆鎶ヨ锛�"); -// sysBaseApi.sendSysAnnouncement(messageDTO); -// } -// } -// } -// -// } } } @@ -849,4 +836,72 @@ return this.baseMapper.exportXlsList(mdcEquipment); } + /** + * 閫氳繃杞﹂棿ids鑾峰彇璁惧鏍� + * + * @param ids + * @return + */ + @Override + public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { + List<String> productionIds = Arrays.asList(ids.split(",")); + //鑾峰彇鎵�鏈変骇绾挎暟鎹� + List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); + List<String> allProductionIds = new ArrayList<>(); + //鎵惧埌鎵�鏈変骇绾縤d鐨勪笂绾d + if (!productionIds.isEmpty()) { + for (String productionId : productionIds) { + this.getAllProductionIds(productionList, productionId, allProductionIds); + } + } + //杩囨护浜х嚎鏁版嵁 + List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); + //缁勮浜х嚎璁惧鏍� + List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); + //濉厖璁惧鏁版嵁 + FillEquipmentByProduction(treeList, null); + return treeList; + } + + /** + * 鏌ヨ鍗曡〃鏁版嵁 + * + * @param tableName + * @return + */ + @Override + public MdcEquipmentDto getWorkLineLast(String tableName) { + try { + return this.baseMapper.findWorkLineLast(tableName); + } catch (Exception e) { + return null; + } + } + + @Override + public List<String> listEquipmentIdShift(MdcEfficiencyReportShiftQueryVo vo) { + LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); + if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { + queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); + } + if (StringUtils.isNotEmpty(vo.getEquipmentType())) { + queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { + queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDriveType())) { + queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); + } + if (StringUtils.isNotEmpty(vo.getDeviceCategory())) { + queryWrapper.in(MdcEquipment::getDeviceCategory, Arrays.asList(vo.getDeviceCategory().split(","))); + } + if (vo.getDeviceImportanceLevel() != null) { + queryWrapper.eq(MdcEquipment::getDeviceImportanceLevel, vo.getDeviceImportanceLevel()); + } + List<MdcEquipment> list = super.list(queryWrapper); +// List<MdcEquipment> list = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getEquipmentType, equipmentType).in(MdcEquipment::getEquipmentId, equipmentIdList)); + return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); + } + } -- Gitblit v1.9.3