| | |
| | | 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.MdcEquipmentDetailedDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | |
| | | * 设备监控 - 设备详细信息 |
| | | */ |
| | | @Override |
| | | public MdcEquipmentDto mdcEquipmentDetailedInfo(String id) { |
| | | MdcEquipmentDto mdcEquipmentDto = new MdcEquipmentDto(); |
| | | MdcEquipment mdcEquipment = this.baseMapper.selectById(id); |
| | | //封装基础信息 |
| | | mdcEquipmentDto.setSystemVersion(mdcEquipment.getSystemVersion()); |
| | | mdcEquipmentDto.setSystemType(mdcEquipment.getControlSystem()); |
| | | mdcEquipmentDto.setDevicePower(mdcEquipment.getDevicePower()); |
| | | mdcEquipmentDto.setDeviceType(mdcEquipment.getDriveType()); |
| | | mdcEquipmentDto.setRemark(mdcEquipment.getRemark()); |
| | | //设备编号 |
| | | mdcEquipmentDto.setEquipmentID(mdcEquipment.getEquipmentId()); |
| | | mdcEquipmentDto.setEquipmentName(mdcEquipment.getEquipmentName()); |
| | | mdcEquipmentDto.setEquipmentIP(mdcEquipment.getEquipmentIp()); |
| | | //设备型号 |
| | | mdcEquipmentDto.setEquipmentModel(mdcEquipment.getEquipmentModel()); |
| | | mdcEquipmentDto.setDriveType(mdcEquipment.getDriveType()); |
| | | mdcEquipmentDto.setDataPort(mdcEquipment.getDataPort()); |
| | | mdcEquipmentDto.setDataFlag(Integer.parseInt(CommonConstant.STATUS_1)); |
| | | ControlSystem controlSystem = controlSystemService.getByDriveType(mdcEquipmentDto.getDriveType()); |
| | | public Map<String, Object> mdcEquipmentDetailedInfo(String id) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | MdcEquipmentDetailedDto mdcEquipmentDetailedDto = this.baseMapper.findById(id); |
| | | result.put("equipment", mdcEquipmentDetailedDto); |
| | | // 查询设备状态 |
| | | EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipment.getEquipmentId()); |
| | | EquipmentLog equipmentLog = equipmentLogService.selectEquipmentOporation(mdcEquipmentDetailedDto.getEquipmentId()); |
| | | if (equipmentLog == null) { |
| | | return mdcEquipmentDto; |
| | | return result; |
| | | } |
| | | Integer oporation = equipmentLog.getOporation(); |
| | | |
| | | if (controlSystem != null) { |
| | | //获取工作数据并初始化 |
| | | String saveTableName = mdcEquipment.getSaveTableName(); |
| | | MdcEquipmentDto dto = equipmentWorkLineService.getMacingDataList(saveTableName); |
| | | if (dto != null) { |
| | | mdcEquipmentDto.setCollectTime(dto.getCollectTime()); |
| | | mdcEquipmentDto.setSpindlespeed(dto.getSpindlespeed()); |
| | | mdcEquipmentDto.setSpindleload(dto.getSpindleload()); |
| | | mdcEquipmentDto.setSpindlebeilv(dto.getSpindlebeilv()); |
| | | mdcEquipmentDto.setFeedrate(dto.getFeedrate()); |
| | | mdcEquipmentDto.setFeedbeilv(dto.getFeedbeilv()); |
| | | mdcEquipmentDto.setProgramnumber(dto.getProgramnumber()); |
| | | 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()); |
| | | } |
| | | |
| | | String saveTableName = mdcEquipmentDetailedDto.getSaveTableName(); |
| | | Map<String, Object> mapData = equipmentWorkLineService.getDataList(saveTableName); |
| | | if (mapData != null) { |
| | | Map<String, Object> runData = new LinkedHashMap<>(); |
| | | //获取 MDC 驱动对应的展示参数 并根据key 拼装从 workData 查询的数据 |
| | | List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipment.getDriveType()); |
| | | List<MdcDriveTypeParamConfig> mdcDriveTypeParamList = mdcDriveTypeParamConfigService.getShowDriveParam(mdcEquipmentDetailedDto.getDriveType()); |
| | | if (mdcDriveTypeParamList != null && !mdcDriveTypeParamList.isEmpty()) { |
| | | for (MdcDriveTypeParamConfig mdcDriveTypeParamConfig : mdcDriveTypeParamList) { |
| | | String englishName = mdcDriveTypeParamConfig.getEnglishName(); |
| | | JSONObject jsonObject = (JSONObject) JSONObject.toJSON(dto); |
| | | Object result = jsonObject.get(englishName); |
| | | String chineseName = mdcDriveTypeParamConfig.getChineseName(); |
| | | if (mapData.containsKey(englishName)) { |
| | | Object object = mapData.get(englishName); |
| | | String value = ""; |
| | | if ("CollectTime".equals(englishName)) { |
| | | Date date = result == null ? null : (Date) result; |
| | | Date date = object == null ? null : (Date) object; |
| | | value = DateUtils.format(date, DateUtils.STR_DATE_TIME_SMALL); |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "AI01".equals(englishName) && oporation == 3) { |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.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) { |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.getDriveType()) && "spindlespeed".equals(englishName) && oporation == 3) { |
| | | // ZUOLAN设备主轴转速字段spindlespeed |
| | | value = String.valueOf(((new Random().nextInt(35)) + 1) * 100); |
| | | } else if ("ZUOLAN".equals(mdcEquipment.getDriveType()) && "spindleload".equals(englishName) && oporation == 3) { |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.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) { |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.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) { |
| | | } else if ("ZUOLAN".equals(mdcEquipmentDetailedDto.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"); |
| | | String devicePower = mdcEquipmentDetailedDto.getDevicePower(); |
| | | Object spindleload = mapData.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 if ("torque".equals(englishName)) { |
| | | // 扭矩字段 |
| | | MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipment.getEquipmentId()); |
| | | MdcTorqueConfig mdcTorqueConfig = mdcTorqueConfigMapper.findLast(mdcEquipmentDetailedDto.getEquipmentId()); |
| | | if (mdcTorqueConfig != null) { |
| | | value = String.valueOf(mdcTorqueConfig.getTorqueValue()); |
| | | } else { |
| | |
| | | } |
| | | } 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)); |
| | | List<MdcAlarmInfo> mdcAlarmInfo = mdcAlarmInfoService.list(new LambdaQueryWrapper<MdcAlarmInfo>().eq(MdcAlarmInfo::getDriveType, mdcEquipmentDetailedDto.getDriveType()).eq(MdcAlarmInfo::getAlarmCode, equipmentLog.getAlarm()).eq(MdcAlarmInfo::getIsUse, 0)); |
| | | if (mdcAlarmInfo != null && !mdcAlarmInfo.isEmpty()) { |
| | | value = mdcAlarmInfo.get(0).getAlarmContent(); |
| | | } |
| | |
| | | value = "无"; |
| | | } |
| | | } else { |
| | | value = result == null ? null : result.toString(); |
| | | value = object == null ? "" : object.toString(); |
| | | } |
| | | mdcDriveTypeParamConfig.setValue(value); |
| | | } |
| | | mdcEquipmentDto.setMdcDriveTypeParamConfigList(mdcDriveTypeParamList); |
| | | } |
| | | EquipmentBaseInfo equipmentBaseInfo = equipmentBaseInfoService.getByEquipmentId(mdcEquipment.getEquipmentId()); |
| | | if (equipmentBaseInfo != null) { |
| | | mdcEquipmentDto.setMaxAxis(equipmentBaseInfo.getMaxAxis()); |
| | | mdcEquipmentDto.setValidAxis(equipmentBaseInfo.getValidAxis()); |
| | | runData.put(chineseName, value); |
| | | } |
| | | } |
| | | } |
| | | return mdcEquipmentDto; |
| | | result.put("runData", runData); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 查询单表数据 |
| | | * |
| | | * @param tableName |
| | | * @return |
| | | */ |