From cf89583e4dd54632a0f11c06b859315c03958820 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期三, 17 一月 2024 17:36:41 +0800 Subject: [PATCH] 设备运行状态及利用率预警任务 --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java | 76 +++++++++++++++++++++++++++++++++++-- 1 files changed, 71 insertions(+), 5 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 83bebd6..a0fb120 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 @@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; +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; @@ -19,17 +22,17 @@ 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.*; +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.system.entity.MdcEquipmentDepart; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.entity.MdcProductionEquipment; 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.IMdcProductionService; -import org.jeecg.modules.system.service.IMdcUserProductionService; -import org.jeecg.modules.system.service.ISysDepartService; -import org.jeecg.modules.system.service.ISysUserDepartService; +import org.jeecg.modules.system.service.*; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,6 +80,13 @@ @Resource private IEquipmentBaseInfoService equipmentBaseInfoService; + + @Resource + private ISysDictService sysDictService; + + @Resource + private ISysBaseAPI sysBaseApi; + @Override public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { @@ -700,4 +710,60 @@ return this.baseMapper.pageList(page, mdcEquipment); } + /** + * 鐩戞帶璁惧杞�熶换鍔� + */ + @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::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() + "] 鐨勮澶囪繍琛岃浆閫熼珮鎶ヨ锛�"); + sysBaseApi.sendSysAnnouncement(messageDTO); + } else if (spindlespeed < actualspindlespeed) { + // 瀹為檯鍊煎皬浜庤瀹氬�� 浣� + messageDTO.setContent("璁惧缂栧彿涓� [" + mdcEquipment.getEquipmentId() + "] 鐨勮澶囪繍琛岃浆閫熶綆鎶ヨ锛�"); + sysBaseApi.sendSysAnnouncement(messageDTO); + } + } + } + + } + } + + } + } -- Gitblit v1.9.3