| | |
| | | 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.constant.enums.MessageSplitTypeEnum; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | 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.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.ControlSystem; |
| | | import org.jeecg.modules.mdc.entity.MdcDriveTypeParamConfig; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | | import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.mdc.service.IControlSystemService; |
| | | import org.jeecg.modules.mdc.service.IEquipmentWorkLineService; |
| | | import org.jeecg.modules.mdc.service.IMdcDriveTypeParamConfigService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | 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.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | @Resource |
| | | private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService; |
| | | // @Resource |
| | | // private XYZAliasesMapper xyzAliasesMapper; |
| | | // @Resource |
| | | // private IEquipmentXYZService equipmentXYZService; |
| | | // @Resource |
| | | // private IEquipmentBaseInfoService equipmentBaseInfoService; |
| | | // @Resource |
| | | // private IEquipmentTemperatureService equipmentTemperatureService; |
| | | @Resource |
| | | private MdcTorqueConfigMapper mdcTorqueConfigMapper; |
| | | |
| | | @Resource |
| | | private IEquipmentLogService equipmentLogService; |
| | | |
| | | @Resource |
| | | private IEquipmentBaseInfoService equipmentBaseInfoService; |
| | | |
| | | @Resource |
| | | private ISysBaseAPI sysBaseApi; |
| | | |
| | | @Resource |
| | | private IMdcAlarmInfoService mdcAlarmInfoService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentThresholdService mdcEquipmentThresholdService; |
| | | |
| | | @Resource |
| | | private IMdcOverrunAlarmService mdcOverrunAlarmService; |
| | | |
| | | |
| | | @Override |
| | | public Map<String, String> getDepNamesByEquipmentIds(List<String> equipmentIds) { |
| | |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | |
| | |
| | | mdcEquipmentDto.setDataPort(mdcEquipment.getDataPort()); |
| | | mdcEquipmentDto.setDataFlag(Integer.parseInt(CommonConstant.STATUS_1)); |
| | | ControlSystem controlSystem = controlSystemService.getByDriveType(mdcEquipmentDto.getDriveType()); |
| | | // 查询设备状态 |
| | | EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId()); |
| | | if (equipmentLog == null) { |
| | | return mdcEquipmentDto; |
| | | } |
| | | Integer oporation = equipmentLog.getOporation(); |
| | | |
| | | if (controlSystem != null) { |
| | | //获取工作数据并初始化 |
| | | String saveTableName = mdcEquipment.getSaveTableName(); |
| | |
| | | mdcEquipmentDto.setSequencenumber(dto.getSequencenumber()); |
| | | mdcEquipmentDto.setExecutingcode(dto.getExecutingcode()); |
| | | mdcEquipmentDto.setProductName(dto.getProductName()); |
| | | if ("LSV2".equals(mdcEquipment.getDriveType())) { |
| | | mdcEquipmentDto.setSpindlebeilv(dto.getSFeed()); |
| | | mdcEquipmentDto.setFeedbeilv(dto.getFFeed()); |
| | | mdcEquipmentDto.setRapidfeed(dto.getRapidfeed()); |
| | | mdcEquipmentDto.setNCVersion(dto.getNCVersion()); |
| | | mdcEquipmentDto.setTNCVersion(dto.getTNCVersion()); |
| | | mdcEquipmentDto.setOPTVersion(dto.getOPTVersion()); |
| | | mdcEquipmentDto.setPLCVersion(dto.getPLCVersion()); |
| | | } |
| | | |
| | | //获取 MDC 驱动对应的展示参数 并根据key 拼装从 workData 查询的数据 |
| | | List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipment.getDriveType()); |
| | |
| | | if ("CollectTime".equals(englishName)) { |
| | | Date date = result == null ? null : (Date) result; |
| | | value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL); |
| | | } 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(); |
| | | } 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(); |
| | | Object spindleload = jsonObject.get("spindleload"); |
| | | BigDecimal load = spindleload == null ? BigDecimal.ZERO : new BigDecimal(spindleload.toString()); |
| | | if (StringUtils.isNotEmpty(devicePower) && oporation == 3) { |
| | | value = new BigDecimal(devicePower).divide(new BigDecimal("380"), 2, BigDecimal.ROUND_HALF_UP).add(load).toString(); |
| | | } else { |
| | | value = "0"; |
| | | } |
| | | } else if ("torque".equals(englishName)) { |
| | | // 扭矩字段 |
| | | MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipment.getEquipmentId()); |
| | | if (mdcTorqueConfig != null) { |
| | | value = String.valueOf(mdcTorqueConfig.getTorqueValue()); |
| | | } else { |
| | | value = "0"; |
| | | } |
| | | } else if ("alarm".equals(englishName)) { |
| | | if (oporation == 22) { |
| | | value = equipmentLog.getAlarm(); |
| | | } else { |
| | | value = "无"; |
| | | } |
| | | } 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()) { |
| | | value = mdcAlarmInfo.get(0).getAlarmContent(); |
| | | } |
| | | } else { |
| | | value = "无"; |
| | | } |
| | | } else { |
| | | value = result == null ? null : result.toString(); |
| | | } |
| | |
| | | } |
| | | mdcEquipmentDto.setMdcDriveTypeParamConfigList(mdcDriveTypeParamList); |
| | | } |
| | | EquipmentBaseInfo equipmentBaseInfo = equipmentBaseInfoService.getByEquipmentId(mdcEquipment.getEquipmentId()); |
| | | if (equipmentBaseInfo != null) { |
| | | mdcEquipmentDto.setMaxAxis(equipmentBaseInfo.getMaxAxis()); |
| | | mdcEquipmentDto.setValidAxis(equipmentBaseInfo.getValidAxis()); |
| | | } |
| | | } |
| | | // // 设备坐标数 获取设备需要采集的坐标信息 |
| | | // List<XYZAliases> equipmentCoordinateList = xyzAliasesMapper.getCoordinateByEquipmentId(mdcEquipment.getEquipmentId()); |
| | | // // 设备采集的坐标信息 |
| | | // EquipmentXYZ equipmentXYZ = equipmentXYZService.getByEquipmentId(mdcEquipment.getEquipmentId()); |
| | | // JSONObject jsonEquipmentXYZ = (JSONObject) JSONObject.toJSON(equipmentXYZ); |
| | | // if (equipmentCoordinateList != null && !equipmentCoordinateList.isEmpty()) { |
| | | // for (XYZAliases xyzAliases : equipmentCoordinateList) { |
| | | // String englishName = xyzAliases.getXYZFieldName().toLowerCase(); |
| | | // englishName = englishName.substring(0, 1) + "_" + englishName.substring(1, englishName.length()); |
| | | // englishName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, englishName); |
| | | // Object orgValue = jsonEquipmentXYZ.get(englishName); |
| | | // String value = orgValue != null ? orgValue.toString() : null; |
| | | // // 坐标数据的title 来自 xyzAliases 表, 根据 是否包含 absolute 和 machine 判断是绝对坐标还是机床坐标 |
| | | // String title = englishName.substring(0, 1).toUpperCase(); |
| | | // title = englishName.contains("absolute") ? "绝对坐标" + title : "机床坐标" + title; |
| | | // xyzAliases.setTitle(title); |
| | | // xyzAliases.setValue(value); |
| | | // } |
| | | // mdcEquipmentDto.setXyzAliasesList(equipmentCoordinateList); |
| | | // } |
| | | |
| | | // if (equipmentXYZ != null) { |
| | | // mdcEquipmentDto.setXmachine(equipmentXYZ.getXMachine()); |
| | | // mdcEquipmentDto.setYmachine(equipmentXYZ.getYMachine()); |
| | | // mdcEquipmentDto.setZmachine(equipmentXYZ.getZMachine()); |
| | | // mdcEquipmentDto.setAmachine(equipmentXYZ.getAMachine()); |
| | | // mdcEquipmentDto.setBmachine(equipmentXYZ.getBMachine()); |
| | | // mdcEquipmentDto.setXabsolute(equipmentXYZ.getXAbsolute()); |
| | | // mdcEquipmentDto.setYabsolute(equipmentXYZ.getYAbsolute()); |
| | | // mdcEquipmentDto.setZabsolute(equipmentXYZ.getZAbsolute()); |
| | | // mdcEquipmentDto.setAabsolute(equipmentXYZ.getAAbsolute()); |
| | | // mdcEquipmentDto.setBabsolute(equipmentXYZ.getBAbsolute()); |
| | | // } |
| | | // EquipmentBaseInfo equipmentBaseInfo = equipmentBaseInfoService.getByEquipmentId(mdcEquipment.getEquipmentId()); |
| | | // if (equipmentBaseInfo != null) { |
| | | // mdcEquipmentDto.setMaxAxis(equipmentBaseInfo.getMaxAxis()); |
| | | // mdcEquipmentDto.setValidAxis(equipmentBaseInfo.getValidAxis()); |
| | | // } |
| | | // if (controlSystem.getDriveType().equals("SIEMENS840DSL")) { |
| | | // EquipmentTemperatureDto equipmentTemperature = equipmentTemperatureService.getEquipmentTemperature(mdcEquipment.getEquipmentId()); |
| | | // if (equipmentTemperature != null) { |
| | | // mdcEquipmentDto.setTemperatureX(equipmentTemperature.getX()); |
| | | // mdcEquipmentDto.setTemperatureY(equipmentTemperature.getY()); |
| | | // mdcEquipmentDto.setTemperatureZ(equipmentTemperature.getZ()); |
| | | // mdcEquipmentDto.setTemperatureA(equipmentTemperature.getA()); |
| | | // mdcEquipmentDto.setTemperatureB(equipmentTemperature.getB()); |
| | | // } |
| | | // EquipmentTemperatureDto equipmentLagError = equipmentTemperatureService.getEquipmentLagError(mdcEquipment.getEquipmentId()); |
| | | // if (equipmentLagError != null) { |
| | | // mdcEquipmentDto.setEquipmentLagErrorX(equipmentLagError.getX()); |
| | | // mdcEquipmentDto.setEquipmentLagErrorY(equipmentLagError.getY()); |
| | | // mdcEquipmentDto.setEquipmentLagErrorZ(equipmentLagError.getZ()); |
| | | // mdcEquipmentDto.setEquipmentLagErrorA(equipmentLagError.getA()); |
| | | // mdcEquipmentDto.setEquipmentLagErrorB(equipmentLagError.getB()); |
| | | // } |
| | | // } |
| | | // EquipmentTemperatureDto equipmentCurrent = equipmentTemperatureService.getEquipmentCurrent(mdcEquipment.getEquipmentId()); |
| | | // if (equipmentCurrent != null) { |
| | | // mdcEquipmentDto.setEquipmentCurrentX(equipmentCurrent.getX()); |
| | | // mdcEquipmentDto.setEquipmentCurrentY(equipmentCurrent.getY()); |
| | | // mdcEquipmentDto.setEquipmentCurrentZ(equipmentCurrent.getZ()); |
| | | // mdcEquipmentDto.setEquipmentCurrentA(equipmentCurrent.getA()); |
| | | // mdcEquipmentDto.setEquipmentCurrentB(equipmentCurrent.getB()); |
| | | // } |
| | | } |
| | | return mdcEquipmentDto; |
| | | } |
| | |
| | | /** |
| | | * 产线设备树填充设备数据 |
| | | */ |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | return this.baseMapper.getEquipmentByWorkshopId(page, workshopEquipmentVo); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listEquipmentId(MdcEfficiencyReportQueryVo vo) { |
| | | LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDriveType())) { |
| | | queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); |
| | | } |
| | | 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()); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<MdcEquipment> pageList(Page<MdcEquipment> page, MdcEquipmentVo mdcEquipment, HttpServletRequest req) { |
| | | if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { |
| | | // 递归查询所有子节点 |
| | | List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); |
| | | mdcEquipment.setProductionIds(productionIds); |
| | | } |
| | | 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(); |
| | | //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(); |
| | | 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("【设备异常提醒】" + 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.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | mdcOverrunAlarm.setSetValue(min + "-" + max); |
| | | mdcOverrunAlarm.setRealValue(actualValue.toString()); |
| | | if (actualValue > max) { |
| | | // 高 |
| | | messageDTO.setContent("【设备异常提醒】" + productionName + "车间设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备" + mdcEquipmentThreshold.getChineseName() + "高报警!"); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | mdcOverrunAlarm.setAlarmContent("【设备异常提醒】" + productionName + "车间设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备" + mdcEquipmentThreshold.getChineseName() + "高报警!"); |
| | | mdcOverrunAlarmService.save(mdcOverrunAlarm); |
| | | } else if (actualValue < min) { |
| | | // 低 |
| | | messageDTO.setContent("【设备异常提醒】" + productionName + "车间设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备" + mdcEquipmentThreshold.getChineseName() + "低报警!"); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | mdcOverrunAlarm.setAlarmContent("【设备异常提醒】" + productionName + "车间设备编号为 [" + mdcEquipment.getEquipmentId() + "] 的设备" + mdcEquipmentThreshold.getChineseName() + "低报警!"); |
| | | mdcOverrunAlarmService.save(mdcOverrunAlarm); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 导出list |
| | | * |
| | | * @param mdcEquipment |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipment> exportXlsList(MdcEquipmentVo mdcEquipment) { |
| | | if (StringUtils.isNotBlank(mdcEquipment.getProductionName())) { |
| | | // 递归查询所有子节点 |
| | | List<String> productionIds = mdcProductionService.recursionChildren(mdcEquipment.getProductionName()); |
| | | mdcEquipment.setProductionIds(productionIds); |
| | | } |
| | | 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, null); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * 查询单表数据 |
| | | * |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdcEquipmentDto getWorkLineLast(String tableName) { |
| | | try { |
| | | return this.baseMapper.findWorkLineLast(tableName); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<String> listEquipmentIdShift(MdcEfficiencyReportShiftQueryVo vo) { |
| | | LambdaQueryWrapper<MdcEquipment> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (vo.getEquipmentIdList() != null && !vo.getEquipmentIdList().isEmpty()) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentId, vo.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getEquipmentType())) { |
| | | queryWrapper.in(MdcEquipment::getEquipmentType, Arrays.asList(vo.getEquipmentType().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDeviceLevel())) { |
| | | queryWrapper.in(MdcEquipment::getDeviceLevel, Arrays.asList(vo.getDeviceLevel().split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(vo.getDriveType())) { |
| | | queryWrapper.in(MdcEquipment::getDriveType, Arrays.asList(vo.getDriveType().split(","))); |
| | | } |
| | | 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()); |
| | | } |
| | | |
| | | } |