jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/controller/DryEquipmentController.java
@@ -12,11 +12,15 @@ import javax.servlet.http.HttpServletResponse; import cn.hutool.core.bean.BeanUtil; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.config.TenantContext; import org.jeecg.common.constant.CommonCacheConstant; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.TokenUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.mybatis.MybatisPlusSaasConfig; import org.jeecg.modules.dry.common.CacheConstants; @@ -118,9 +122,16 @@ queryWrapper.orderByAsc("code"); List<DryEquipment> eqps = dryEquipmentService.list(queryWrapper); List<DryEquipmentVo> equipmentVos = new ArrayList<>(); if(eqps == null){ return equipmentVos; } eqps.stream().forEach(item -> { DryEquipmentVo dryEquipmentVo = BeanUtil.toBean(item, DryEquipmentVo.class); DryEqpType dryEqpType = dryEqpTypeService.getById(item.getType()); if(dryEqpType == null){ return; } dryEquipmentVo.setType(dryEqpType.getName()); dryEquipmentVo.setDryEfficiency(dryEqpType.getDryEfficiency()); dryEquipmentVo.setSteamConsumption(dryEqpType.getSteamConsumption()); jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/mqtt/MqttSampleCallback.java
@@ -173,7 +173,7 @@ @Override public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { System.err.println("消息传递成功"); // System.err.println("消息传递成功"); } // 解析admin角色指令 @@ -269,9 +269,11 @@ RealTimeDataParentVo vo = JSON.parseObject(message, RealTimeDataParentVo.class); // 向各租户移动端发送数据 String recTopic = String.format(MqttConstant.SERVICE_BROADCAST_TENANT_REAL_DATA, vo.getTenantid()); if(vo.getRealTime() != null){ vo.getRealTime().setWorkorder(vo.getWorkorder()); } MqMessage<RealTimeDataVo> mqMessage = new MqMessage<>(vo.getRealTime(), vo.getTenantid() + "", recTopic); sendMqttMessage(MqttConstant.SERVICE_BROADCAST_TENANT_REAL_DATA, mqMessage, 1); realTimeDataService.realTimeDataHandle(vo); @@ -331,7 +333,7 @@ List<DryFaultRecordVo> faultList = new ArrayList<DryFaultRecordVo>((dryFaultMap.values())); MqMessage<List<DryFaultRecordVo>> mqMessage = new MqMessage<>(faultList, tenantId, resTopic); //发送请求设备 System.err.println("发送给:" + resTopic); // System.err.println("发送给:" + resTopic); sendMqttMessage(resTopic, mqMessage, 2); } @@ -343,7 +345,7 @@ MqMessage<List<DryFaultRecord>> faultMessage = JSON.parseObject(message, new TypeReference<MqMessage<List<DryFaultRecord>>>() { }); // List<DryFaultRecord> faultRecords = JSON.parseArray(jsonObject.get("data").toString(), DryFaultRecord.class); System.err.println(faultMessage.toString()); // System.err.println(faultMessage.toString()); faultRecordService.saveBatch(faultMessage.getData()); } catch (Exception e) { @@ -405,8 +407,8 @@ switch (topic) { case MqttConstant.MOBILE_REQ_EQU_CMD: System.err.println("user收到" + topic); System.err.println(message); // System.err.println("user收到" + topic); // System.err.println(message); ThreadUtil.execute(() -> { //TODO 向PLC发送开关机操作,并返回信息 JSONObject res = new JSONObject(); jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/service/impl/DryRealTimeDataServiceImpl.java
@@ -108,7 +108,7 @@ @Transactional public Result<?> realTimeDataHandle(RealTimeDataVo realTimeDataVo) { TenantContext.setTenant(realTimeDataVo.getTenantid() + ""); log.info("实时数据:" + realTimeDataVo.toString()); // log.info("实时数据:" + realTimeDataVo.toString()); // 1 查询或创建工单 @@ -173,7 +173,7 @@ @Transactional public Result<?> realTimeDataHandle(RealTimeDataParentVo realTimeDataParentVo) { TenantContext.setTenant(realTimeDataParentVo.getTenantid() + ""); log.info("实时数据:" + realTimeDataParentVo.toString()); // log.info("实时数据:" + realTimeDataParentVo.toString()); if (realTimeDataParentVo.getRealTime() != null) { RealTimeDataVo realTimeDataVo = realTimeDataParentVo.getRealTime(); @@ -774,7 +774,7 @@ List<DryFaultRecordVo> faultList = new ArrayList<DryFaultRecordVo>((dryFaultMap.values())); MqMessage<List<DryFaultRecordVo>> mqMessage = new MqMessage<>(faultList, tenantId, recTopic); //发送广播 log.error("广播给:{}", recTopic); // log.error("广播给:{}", recTopic); mqttUtil.sendMqttMessage(MqttConstant.SERVICE_BROADCAST_TENANT_REAL_FAULT, mqMessage, 1); @@ -796,7 +796,7 @@ List<DryFaultRecord> result = new ArrayList<>(); if (StringUtils.isEmpty(fault)) return result; //数据样本:"eqp_fault": "滚筒降超时-报警,风机过流报警,滚筒升超时-报警,风箱升报警", System.err.println((faultType == 1 ? "类型:故障" : "类型:报警") + DateUtils.formatDateTime() + "--" + fault); // System.err.println((faultType == 1 ? "类型:故障" : "类型:报警") + DateUtils.formatDateTime() + "--" + fault); //redis中的故障 Map<Object, Object> rFauMap = redisUtil.hmget(String.format(MqttConstant.MQTT_REAL_FAULT, tenantId)); Map<String, Object> redFauMap = rFauMap.entrySet().stream() @@ -885,7 +885,7 @@ faultRecordService.save(vo); redisUtil.hdel(String.format(MqttConstant.MQTT_REAL_FAULT, tenantId), key); result.add(vo); System.err.println((faultType == 1 ? "类型:故障" : "类型:报警") + DateUtils.formatDateTime() + "存入数据库"); // System.err.println((faultType == 1 ? "类型:故障" : "类型:报警") + DateUtils.formatDateTime() + "存入数据库"); } });