| | |
| | | package com.fzzy.gateway.service; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | |
| | | import com.fzzy.gateway.GatewayUtils; |
| | | import com.fzzy.gateway.api.DeviceReportService; |
| | | import com.fzzy.gateway.api.GatewayRemoteManager; |
| | | import com.fzzy.gateway.data.QueryParam; |
| | | import com.fzzy.gateway.entity.GatewayDevice; |
| | | import com.fzzy.gateway.hx2023.ScConstant; |
| | | import com.fzzy.gateway.hx2023.data.GrainData; |
| | | import com.fzzy.gateway.hx2023.data.GrainDataDetail; |
| | | import com.fzzy.gateway.hx2023.data.KafaGrainData; |
| | | import com.fzzy.gateway.hx2023.data.KafkaGrainDataDetail; |
| | | import com.fzzy.gateway.hx2023.data.KafkaGrainTH; |
| | | import com.fzzy.gateway.hx2023.data.TRHInfo; |
| | | import com.fzzy.gateway.service.repository.GatewayDeviceRep; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String ajaxTestGrain(Map<String,Object> parameter) { |
| | | public String ajaxTestGrain(Map<String, Object> parameter) { |
| | | |
| | | //获取设备配置,只针对粮情设备进行执行 |
| | | |
| | |
| | | |
| | | |
| | | //如果部署FZZY-IGDS-V40版本系统 |
| | | return this.pushByV40(list, start,end); |
| | | return this.pushByV40(list, start, end); |
| | | |
| | | } |
| | | |
| | | private String pushByV40(List<GatewayDevice> list, Date start,Date end) { |
| | | private String pushByV40(List<GatewayDevice> list, Date start, Date end) { |
| | | |
| | | String depotIdSys; |
| | | List<Fz40Grain> listGrain; |
| | | |
| | | Fz40Grain lastData; |
| | | |
| | | GrainData pushData; |
| | | KafaGrainData pushData; |
| | | |
| | | DeviceReportService deviceReportService = null; |
| | | for (GatewayDevice device : list) { |
| | | depotIdSys = device.getDepotIdSys(); |
| | | |
| | | if (StringUtils.isEmpty(depotIdSys)) { |
| | | log.info("--------设备--{}-未配置系统相关仓库编码,无法执行当前操作",device.getDeviceName()); |
| | | log.info("--------设备--{}-未配置系统相关仓库编码,无法执行当前操作", device.getDeviceName()); |
| | | continue; |
| | | } |
| | | |
| | | listGrain = fzzy40CommonService.listGrain(depotIdSys, start, end); |
| | | |
| | | if (null == listGrain || listGrain.isEmpty()) { |
| | | log.info("---------设备---{}--未同步到粮情信息,请确认当前条件下是否有数据",device.getDeviceName()); |
| | | log.info("---------设备---{}--未同步到粮情信息,请确认当前条件下是否有数据", device.getDeviceName()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | * @param lastData |
| | | * @return |
| | | */ |
| | | private GrainData lastData2PushData(Fz40Grain lastData, GatewayDevice device) { |
| | | GrainData result = new GrainData(); |
| | | private KafaGrainData lastData2PushData(Fz40Grain lastData, GatewayDevice device) { |
| | | KafaGrainData result = new KafaGrainData(); |
| | | |
| | | result.setMessageId(ScConstant.getMessageId()); |
| | | result.setDeviceID(device.getDeviceId()); |
| | |
| | | //层-行-列 |
| | | String[] attrCable = lastData.getCable().split("-"); |
| | | |
| | | //层配置 |
| | | int layMax = Integer.valueOf(attrCable[0]); |
| | | |
| | | //针对筒仓配置 |
| | | String[] cableCirAtt = new String[0]; |
| | | if (StringUtils.isNotEmpty(lastData.getCableCir())) { |
| | | cableCirAtt = lastData.getCableCir().split("-"); |
| | | return lastData2PushData2(lastData, device); |
| | | } |
| | | |
| | | //层行列 |
| | | int cableZ = Integer.valueOf(attrCable[0]); |
| | | int cableY = Integer.valueOf(attrCable[1]); |
| | | int cableX = Integer.valueOf(attrCable[2]); |
| | | |
| | | //温度集合 |
| | | String[] attr = lastData.getPoints().split(","); |
| | | |
| | | //根号 |
| | | int cableNum = 1, layerNumber = 1, position = 0; |
| | | int cableNum = 1, position = 0; |
| | | |
| | | int curCir = 1;//所在圈 |
| | | int cirLay = 1;//当前圈的层 |
| | | String curTemp; |
| | | List<GrainDataDetail> details = new ArrayList<>(); |
| | | List<KafkaGrainDataDetail> temperature = new ArrayList<>(); |
| | | |
| | | int x = 0, y = 0, z = 0; |
| | | for (int i = 0; i < attr.length; i++) { |
| | | |
| | | position = i; |
| | | curTemp = attr[i]; |
| | | |
| | | z = i % cableZ + 1; |
| | | x = i / (cableZ * cableY); |
| | | y = x * (cableZ * cableY); |
| | | y = (i - y) / cableZ; |
| | | |
| | | // 倒转X轴 |
| | | x = cableX - 1 - x; |
| | | |
| | | //根号 |
| | | cableNum = (i / layMax) + 1; |
| | | layerNumber = (i % layMax) + 1; |
| | | cableNum = (i / cableZ) + 1; |
| | | |
| | | if (cableCirAtt.length > 0) { |
| | | curCir = getCurCir(cableNum, attrCable); |
| | | cirLay = Integer.valueOf(cableCirAtt[curCir - 1]); |
| | | |
| | | details.add(new GrainDataDetail(cableNum, cirLay, position, curTemp)); |
| | | } else { |
| | | |
| | | //判断最大 TODO 待优化 |
| | | if (curTemp.equals(result.getMaxTemperature())) { |
| | | result.setMaxX(cableNum + ""); |
| | | result.setMaxZ(curTemp); |
| | | } |
| | | curTemp = attr[i]; |
| | | |
| | | |
| | | //判断最小 TODO 待优化 |
| | | if (curTemp.equals(result.getMinTemperature())) { |
| | | result.setMinX(cableNum + ""); |
| | | result.setMinZ(curTemp); |
| | | } |
| | | |
| | | |
| | | details.add(new GrainDataDetail(cableNum, layerNumber, position, curTemp)); |
| | | //判断最大 |
| | | if (curTemp.equals(result.getMaxTemperature())) { |
| | | result.setMaxX(x); |
| | | result.setMaxY(y); |
| | | result.setMaxZ(position); |
| | | } |
| | | |
| | | |
| | | //判断最小 |
| | | if (curTemp.equals(result.getMinTemperature())) { |
| | | result.setMinX(x); |
| | | result.setMinY(y); |
| | | result.setMinZ(position); |
| | | } |
| | | |
| | | temperature.add(new KafkaGrainDataDetail(cableNum + "", z + "", curTemp, position + "", x, y)); |
| | | } |
| | | |
| | | result.setTemperature(details); |
| | | //粮温信息 |
| | | TRHInfo trhInfo = new TRHInfo(); |
| | | trhInfo.setTemperature(temperature); |
| | | |
| | | |
| | | //仓温度信息 |
| | | KafkaGrainTH grainTH = new KafkaGrainTH(); |
| | | grainTH.setHumidity(lastData.getHumidityIn() + ""); |
| | | grainTH.setTemperature(lastData.getTempIn() + ""); |
| | | grainTH.setAirHumidity(lastData.getHumidityOut() + ""); |
| | | grainTH.setAirTemperature(lastData.getTempOut() + ""); |
| | | |
| | | List<KafkaGrainTH> temperatureAndhumidity = new ArrayList<>(); |
| | | temperatureAndhumidity.add(grainTH); |
| | | |
| | | trhInfo.setTemperatureAndhumidity(temperatureAndhumidity); |
| | | |
| | | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("TRHInfo", trhInfo); |
| | | |
| | | result.setParams(params); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 针对筒仓 TODO ----- |
| | | * |
| | | * @param lastData |
| | | * @param device |
| | | * @return |
| | | */ |
| | | private KafaGrainData lastData2PushData2(Fz40Grain lastData, GatewayDevice device) { |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private int getCurCir(int curRoot, String[] cableRuleAtt) { |
| | | |
| | | int sum = 0; |