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 | 121 +++++++++++++++++++++++++++++++++++----- 1 files changed, 105 insertions(+), 16 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 0a74de7..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,22 +22,23 @@ 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; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -73,6 +77,16 @@ @Resource private IEquipmentLogService equipmentLogService; + + @Resource + private IEquipmentBaseInfoService equipmentBaseInfoService; + + @Resource + private ISysDictService sysDictService; + + @Resource + private ISysBaseAPI sysBaseApi; + @Override public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { @@ -393,15 +407,23 @@ if ("CollectTime".equals(englishName)) { Date date = result == null ? null : (Date) result; value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL); - } else { - value = result == null ? null : result.toString(); - } - // ZUOLAN璁惧鐢垫祦瀛楁AI01 - if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "AI01".equals(englishName) && oporation == 3) { + } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "AI01".equals(englishName) && oporation == 3) { + // ZUOLAN璁惧鐢垫祦瀛楁AI01 value = BigDecimal.valueOf(Math.random() * 15 + 0).setScale(1, RoundingMode.HALF_UP).toString(); - } - // 鍏朵粬璁惧鐢垫祦瀛楁 - if ("spindle_current".equals(englishName)) { + } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) { + // ZUOLAN璁惧涓昏酱杞�熷瓧娈祍pindlespeed + value = String.valueOf(((new Random().nextInt(35)) + 1) * 100); + } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) { + // ZUOLAN璁惧涓昏酱璐熻嵎瀛楁spindleload + value = String.valueOf(Integer.valueOf(new Random().nextInt(21))); + } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlebeilv".equals(englishName) && oporation == 3) { + // ZUOLAN璁惧涓昏酱鍊嶇巼瀛楁spindlebeilv + value = String.valueOf((new Random().nextInt(13)) * 10); + } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "feedbeilv".equals(englishName) && oporation == 3) { + // ZUOLAN璁惧杩涚粰鍊嶇巼瀛楁feedbeilv + value = String.valueOf((new Random().nextInt(13)) * 10); + } else if ("spindle_current".equals(englishName)) { + // 鍏朵粬璁惧鐢垫祦瀛楁 String devicePower = mdcEquipment.getDevicePower(); Object spindleload = jsonObject.get("spindleload"); BigDecimal load = spindleload == null ? BigDecimal.ZERO : new BigDecimal(spindleload.toString()); @@ -410,19 +432,25 @@ } else { value = "0"; } - } - // 鎵煩瀛楁 - if ("torque".equals(englishName)) { + } else if ("torque".equals(englishName)) { + // 鎵煩瀛楁 MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipment.getEquipmentId()); if (mdcTorqueConfig != null) { value = String.valueOf(mdcTorqueConfig.getTorqueValue()); } else { value = "0"; } + } else { + value = result == null ? null : result.toString(); } mdcDriveTypeParamConfig.setValue(value); } mdcEquipmentDto.setMdcDriveTypeParamConfigList(mdcDriveTypeParamList); + } + EquipmentBaseInfo equipmentBaseInfo = equipmentBaseInfoService.getByEquipmentId(mdcEquipment.getEquipmentId()); + if (equipmentBaseInfo != null) { + mdcEquipmentDto.setMaxAxis(equipmentBaseInfo.getMaxAxis()); + mdcEquipmentDto.setValidAxis(equipmentBaseInfo.getValidAxis()); } } } @@ -677,4 +705,65 @@ return list.stream().map(MdcEquipment::getEquipmentId).collect(Collectors.toList()); } + @Override + public IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req) { + 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