| | |
| | | @Transactional |
| | | public Result<?> realTimeDataHandle(RealTimeDataVo realTimeDataVo) { |
| | | TenantContext.setTenant(realTimeDataVo.getTenantid() + ""); |
| | | log.info("实时数据:" + realTimeDataVo.toString()); |
| | | // log.info("实时数据:" + realTimeDataVo.toString()); |
| | | |
| | | |
| | | // 1 查询或创建工单 |
| | |
| | | @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(); |
| | | |
| | |
| | | saveOrderTrendVo(trendVo, orderVo); |
| | | orderVo.setTrendVo(trendVo); |
| | | orderVo.getBellowsTemp().put(realTimeDataVo.getTime3(), realTimeDataVo.getTemp2()); |
| | | |
| | | if (realTimeDataParentVo.getFault() != null) { |
| | | if (realTimeDataParentVo.getFault().getError() != null) { |
| | | orderVo.setFault(realTimeDataParentVo.getFault().getError()); |
| | | } |
| | | if (realTimeDataParentVo.getFault().getWarning() != null) { |
| | | orderVo.setWarning(realTimeDataParentVo.getFault().getWarning()); |
| | | } |
| | | } |
| | | |
| | | // 2.3 更新到redis缓存 |
| | | redisUtil.hset(CacheConstants.RedisKeyEnum.WORK_ORDER.getCode(), |
| | |
| | | log.error("新增设备失败:数据库保存异常!equipment={}", addEqu); |
| | | return null; |
| | | } |
| | | redisUtil.del(CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST); |
| | | redisUtil.del(CommonCacheConstant.DRY_CACHE_TENANT_EQUS); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | |
| | | queryWrapper.last("LIMIT 1"); |
| | | DryHerbFormula one = dryHerbFormulaService.getOne(queryWrapper); |
| | | |
| | | if (one == null) { |
| | | one = new DryHerbFormula(realTimeDataVo); |
| | | DryEquipment dryEquipment = equipmentService.selectByTenantIdEquipmentId(realTimeDataVo.getTenantid() + "", realTimeDataVo.getMachineid()); |
| | | if (dryEquipment != null && dryEquipment.getType() != null) { |
| | | one.setEqpType(dryEquipment.getType()); |
| | | } |
| | | |
| | | dryHerbFormulaService.save(one); |
| | | } |
| | | // if (one == null) { |
| | | // one = new DryHerbFormula(realTimeDataVo); |
| | | // DryEquipment dryEquipment = equipmentService.selectByTenantIdEquipmentId(realTimeDataVo.getTenantid() + "", realTimeDataVo.getMachineid()); |
| | | // if (dryEquipment != null && dryEquipment.getType() != null) { |
| | | // one.setEqpType(dryEquipment.getType()); |
| | | // } |
| | | // |
| | | // dryHerbFormulaService.save(one); |
| | | // } |
| | | return one; |
| | | } |
| | | |
| | |
| | | if (order != null) { |
| | | orderVo.setEnvHum(order.getEnvHum()); |
| | | orderVo.setEnvTemp(order.getEnvTemp()); |
| | | double watt = order.getWatt() - order.getDetailList().get(0).getWatt(); |
| | | double watt = order.getWatt() - (order.getDetailList().size() > 0 ?order.getDetailList().get(0).getWatt():0); |
| | | orderVo.setWatt(orderVo.getWatt() == null ? watt : orderVo.getWatt() + watt); |
| | | double steam = order.getSteam() - order.getDetailList().get(0).getSteam(); |
| | | double steam = order.getSteam() - ( order.getDetailList().size() > 0 ?order.getDetailList().get(0).getSteam():0); |
| | | orderVo.setSteam(orderVo.getSteam() == null ? steam : orderVo.getSteam() + steam); |
| | | orderVo.setOriginWeight(orderVo.getOriginWeight() == null ? order.getOriginWeight() : orderVo.getOriginWeight() + order.getOriginWeight()); |
| | | |
| | |
| | | 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); |
| | | |
| | | |
| | |
| | | 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() |
| | |
| | | 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() + "存入数据库"); |
| | | } |
| | | }); |
| | | |