From c51323e6fcc84f08bc8c01e3dd6c916427f83f4e Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期四, 07 三月 2024 10:41:50 +0800 Subject: [PATCH] 设备状态长时间未变化算法更新 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 138 ++++++++++++++++++++++++++++++--------------- 1 files changed, 92 insertions(+), 46 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 9648ae1..83817f6 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 @@ -9,7 +9,6 @@ import org.jeecg.common.api.dto.message.MessageDTO; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.api.ISysBaseAPI; -import org.jeecg.common.system.vo.DictModel; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.mdc.dto.MdcEquDepDto; import org.jeecg.modules.mdc.dto.MdcEquProDto; @@ -32,7 +31,10 @@ import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper; import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; -import org.jeecg.modules.system.service.*; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.IMdcUserProductionService; +import org.jeecg.modules.system.service.ISysDepartService; +import org.jeecg.modules.system.service.ISysUserDepartService; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -82,13 +84,16 @@ private IEquipmentBaseInfoService equipmentBaseInfoService; @Resource - private ISysDictService sysDictService; - - @Resource private ISysBaseAPI sysBaseApi; @Resource private IMdcAlarmInfoService mdcAlarmInfoService; + + @Resource + private IMdcEquipmentThresholdService mdcEquipmentThresholdService; + + @Resource + private IMdcOverrunAlarmService mdcOverrunAlarmService; @Override @@ -450,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()) { @@ -735,56 +740,60 @@ } /** - * 鐩戞帶璁惧杞�熶换鍔� + * 鐩戞帶璁惧杩愯鍙傛暟浠诲姟 */ @Override public void monitoringSpeedProcess() { - List<MdcEquipment> equipmentList = super.list(new LambdaQueryWrapper<MdcEquipment>().eq(MdcEquipment::getDriveType, "FANUC")); +// 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")); - // 鑾峰彇瀛楀吀鏁版嵁 - List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_OPERATING_SPEED_RANGE); - Integer range = 0; - if (dictModelList != null && !dictModelList.isEmpty()) { - range = Integer.valueOf(dictModelList.get(0).getValue()); - } + for (MdcEquipment mdcEquipment : equipmentList) { - String saveTableName = mdcEquipment.getSaveTableName(); - //鏌ヨ鍗曡〃鏁版嵁 - 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() + "] 鐨勮澶囪繍琛岃浆閫熼珮鎶ヨ锛�"); + List<MdcEquipmentThreshold> mdcEquipmentThresholdList = mdcEquipmentThresholdService.list(new LambdaQueryWrapper<MdcEquipmentThreshold>().eq(MdcEquipmentThreshold::getControlSystemType, mdcEquipment.getDriveType())); + if (mdcEquipmentThresholdList != null && !mdcEquipmentThresholdList.isEmpty()) { + String saveTableName = mdcEquipment.getSaveTableName(); + StringBuilder builder = new StringBuilder(); + for (MdcEquipmentThreshold mdcEquipmentThreshold : mdcEquipmentThresholdList) { + builder.append(",").append(mdcEquipmentThreshold.getEnglishName()).append(" as \"").append(mdcEquipmentThreshold.getEnglishName()).append("\" "); + } + Map<String, Object> param = new HashMap<>(); + param.put("columns", builder.toString()); + param.put("tableName", saveTableName); + 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.setFromUser("admin"); + messageDTO.setToUser("admin"); + MdcOverrunAlarm mdcOverrunAlarm = new MdcOverrunAlarm(); + mdcOverrunAlarm.setEquipmentId(mdcEquipment.getEquipmentId()); + mdcOverrunAlarm.setSetValue(min + "-" + max); + mdcOverrunAlarm.setRealValue(actualValue.toString()); + if (actualValue > max) { + // 楂� + messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "楂樻姤璀︼紒"); sysBaseApi.sendSysAnnouncement(messageDTO); - } else if (spindlespeed < actualspindlespeed) { - // 瀹為檯鍊煎皬浜庤瀹氬�� 浣� - messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熶綆鎶ヨ锛�"); + mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "楂樻姤璀�"); + mdcOverrunAlarmService.save(mdcOverrunAlarm); + } else if (actualValue < min) { + // 浣� + messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶�" + mdcEquipmentThreshold.getChineseName() + "浣庢姤璀︼紒"); sysBaseApi.sendSysAnnouncement(messageDTO); + mdcOverrunAlarm.setAlarmContent(mdcEquipmentThreshold.getChineseName() + "浣庢姤璀�"); + mdcOverrunAlarmService.save(mdcOverrunAlarm); } } } - } } @@ -806,4 +815,41 @@ 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); + return treeList; + } + + /** + * 鏌ヨ鍗曡〃鏁版嵁 + * @param tableName + * @return + */ + @Override + public MdcEquipmentDto getWorkLineLast(String tableName) { + return this.baseMapper.findWorkLineLast(tableName); + } + } -- Gitblit v1.9.3