| | |
| | | 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; |
| | |
| | | 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; |
| | | 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; |
| | |
| | | private IEquipmentBaseInfoService equipmentBaseInfoService; |
| | | |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | |
| | | @Resource |
| | | private ISysBaseAPI sysBaseApi; |
| | | |
| | | @Resource |
| | | private IMdcAlarmInfoService mdcAlarmInfoService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentThresholdService mdcEquipmentThresholdService; |
| | | |
| | | @Resource |
| | | private IMdcOverrunAlarmService mdcOverrunAlarmService; |
| | | |
| | | |
| | | @Override |
| | |
| | | } 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()) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 监控设备转速任务 |
| | | * 监控设备运行参数任务 |
| | | */ |
| | | @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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | 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<>(); |
| | | //找到所有产线id的上级id |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 设备运行状态统计 |
| | | */ |
| | | @Override |
| | | public List<MdcCommonVo> getEquipmentStatusStatistics(String userId, String key) { |
| | | List<MdcCommonVo> result = new ArrayList<>(); |
| | | MdcCommonVo mdcCommonVo1 = new MdcCommonVo(); |
| | | mdcCommonVo1.setName("关机"); |
| | | mdcCommonVo1.setValue(0); |
| | | result.add(mdcCommonVo1); |
| | | MdcCommonVo mdcCommonVo2 = new MdcCommonVo(); |
| | | mdcCommonVo2.setName("报警"); |
| | | mdcCommonVo2.setValue(0); |
| | | result.add(mdcCommonVo2); |
| | | MdcCommonVo mdcCommonVo3 = new MdcCommonVo(); |
| | | mdcCommonVo3.setName("待机"); |
| | | mdcCommonVo3.setValue(0); |
| | | result.add(mdcCommonVo3); |
| | | MdcCommonVo mdcCommonVo4 = new MdcCommonVo(); |
| | | mdcCommonVo4.setName("运行"); |
| | | mdcCommonVo4.setValue(0); |
| | | result.add(mdcCommonVo4); |
| | | MdcEquipmentStatusVo mdcEquipmentStatusVo = new MdcEquipmentStatusVo(); |
| | | List<String> equipmentIdList = this.getEquipmentIdsProduction(userId, key); |
| | | if (equipmentIdList == null || equipmentIdList.isEmpty()) { |
| | | return result; |
| | | } |
| | | List<EquipmentLog> logList = this.baseMapper.getEquipmentStatusList(equipmentIdList); |
| | | if (logList != null && !logList.isEmpty()) { |
| | | for (EquipmentLog equipmentLog : logList) { |
| | | if (equipmentLog.getOporation() != null) { |
| | | switch (equipmentLog.getOporation()) { |
| | | case 1: |
| | | case 2: |
| | | mdcEquipmentStatusVo.setWaitCount(mdcEquipmentStatusVo.getWaitCount() + 1); |
| | | break; |
| | | case 3: |
| | | mdcEquipmentStatusVo.setRunCount(mdcEquipmentStatusVo.getRunCount() + 1); |
| | | break; |
| | | case 22: |
| | | mdcEquipmentStatusVo.setAlarmCount(mdcEquipmentStatusVo.getAlarmCount() + 1); |
| | | break; |
| | | default: |
| | | mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); |
| | | break; |
| | | } |
| | | } else { |
| | | mdcEquipmentStatusVo.setCloseCount(mdcEquipmentStatusVo.getCloseCount() + 1); |
| | | } |
| | | } |
| | | } |
| | | result.clear(); |
| | | MdcCommonVo mdcCommonVo5 = new MdcCommonVo(); |
| | | mdcCommonVo5.setName("关机"); |
| | | mdcCommonVo5.setValue(mdcEquipmentStatusVo.getCloseCount()); |
| | | result.add(mdcCommonVo5); |
| | | MdcCommonVo mdcCommonVo6 = new MdcCommonVo(); |
| | | mdcCommonVo6.setName("报警"); |
| | | mdcCommonVo6.setValue(mdcEquipmentStatusVo.getAlarmCount()); |
| | | result.add(mdcCommonVo6); |
| | | MdcCommonVo mdcCommonVo7 = new MdcCommonVo(); |
| | | mdcCommonVo7.setName("待机"); |
| | | mdcCommonVo7.setValue(mdcEquipmentStatusVo.getWaitCount()); |
| | | result.add(mdcCommonVo7); |
| | | MdcCommonVo mdcCommonVo8 = new MdcCommonVo(); |
| | | mdcCommonVo8.setName("运行"); |
| | | mdcCommonVo8.setValue(mdcEquipmentStatusVo.getRunCount()); |
| | | result.add(mdcCommonVo8); |
| | | return result; |
| | | } |
| | | |
| | | } |