| | |
| | | package org.jeecg.modules.mdc.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | 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.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; |
| | | import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.mdc.service.*; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | |
| | | private IEquipmentWorkLineService equipmentWorkLineService; |
| | | @Resource |
| | | private IMdcDriveTypeParamConfigService mdcDriveTypeParamConfigService; |
| | | @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) { |
| | |
| | | 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(mdcEquipmentDetailedDto.getEquipmentId()); |
| | | if (mdcTorqueConfig != null) { |
| | | value = String.valueOf(mdcTorqueConfig.getTorqueValue()); |
| | | } else { |
| | | value = "0"; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 监控设备运行参数任务 |
| | | */ |
| | | @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")); |
| | | |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | 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); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 导出list |
| | | * |
| | | * @param mdcEquipment |
| | |
| | | //填充设备数据 |
| | | FillEquipmentByProduction(treeList); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * 查询单表数据 |
| | | * |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MdcEquipmentDto getWorkLineLast(String tableName) { |
| | | try { |
| | | return this.baseMapper.findWorkLineLast(tableName); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |