| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.enums.MessageSplitTypeEnum; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.mdc.dto.MdcEquDepDto; |
| | |
| | | } |
| | | |
| | | @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获取拥有的部门id集合 |
| | |
| | | //组装部门设备树 |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentDepartUtil.wrapEquipmentDepartTreeList(list); |
| | | //填充设备数据 |
| | | FillEquipmentByDepart(treeList); |
| | | FillEquipmentByDepart(treeList, key); |
| | | return treeList; |
| | | } |
| | | |
| | |
| | | * |
| | | * @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); |
| | |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByDepart(mdcEquipmentTree.getChildren()); |
| | | FillEquipmentByDepart(mdcEquipmentTree.getChildren(), key); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @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获取拥有的产线信息集合 |
| | |
| | | //组装产线设备树 |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //填充设备数据 |
| | | FillEquipmentByProduction(treeList); |
| | | FillEquipmentByProduction(treeList, key); |
| | | return treeList; |
| | | } |
| | | |
| | |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设备主轴转速字段spindlespeed |
| | | value = String.valueOf(((new Random().nextInt(35)) + 1) * 100); |
| | | mdcEquipmentDto.setSpindlespeed(value); |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设备主轴负荷字段spindleload |
| | | value = String.valueOf(Integer.valueOf(new Random().nextInt(21))); |
| | | mdcEquipmentDto.setSpindleload(value); |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindlebeilv".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设备主轴倍率字段spindlebeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | mdcEquipmentDto.setSpindlebeilv(value); |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "feedbeilv".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设备进给倍率字段feedbeilv |
| | | value = String.valueOf((new Random().nextInt(13)) * 10); |
| | | mdcEquipmentDto.setFeedbeilv(value); |
| | | } else if ("spindle_current".equals(englishName)) { |
| | | // 其他设备电流字段 |
| | | String devicePower = mdcEquipment.getDevicePower(); |
| | |
| | | /** |
| | | * 产线设备树填充设备数据 |
| | | */ |
| | | 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); |
| | |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren()); |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren(), key); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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()); |
| | |
| | | // 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(); |
| | |
| | | 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.setMessageType(MessageSplitTypeEnum.deviceRunError.getType()); |
| | | messageDTO.setFromUser("admin"); |
| | | messageDTO.setToUser("admin"); |
| | | MdcOverrunAlarm mdcOverrunAlarm = new MdcOverrunAlarm(); |
| | |
| | | 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); |
| | | } |
| | | } |
| | |
| | | //组装产线设备树 |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //填充设备数据 |
| | | FillEquipmentByProduction(treeList); |
| | | FillEquipmentByProduction(treeList, null); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * 查询单表数据 |
| | | * |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | |
| | | 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()); |