CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
igds-protocol-iot/src/main/java/com/ld/igds/protocol/iot/height/analysis/AnalysisHeightService.java
@@ -1,13 +1,18 @@
package com.ld.igds.protocol.iot.height.analysis;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.grain.dto.GrainData;
import com.ld.igds.models.Building;
import com.ld.igds.models.Depot;
import com.ld.igds.models.DeviceIot;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.protocol.iot.height.analysis.message.DeviceAttr;
import com.ld.igds.protocol.iot.height.analysis.message.DeviceAttrInfo;
import com.ld.igds.util.RedisUtil;
import com.ld.igds.view.service.BuildingService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -27,7 +32,10 @@
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private CoreCommonService coreCommonService;
    @Autowired
    private BuildingService buildingService;
    /**
     * @param deviceAttr
@@ -36,12 +44,45 @@
    public void analysis(DeviceAttr deviceAttr , DeviceSer ser ,DeviceIot deviceIot)  {
        try{
            List<DeviceAttrInfo> deviceAttrInfos = deviceAttr.getTerminalAttrInfoList();
            String herght =(deviceAttrInfos.get(2).getValue());
            String height =(deviceAttrInfos.get(2).getValue());
            GrainData data = new GrainData();
            data.setOilHeight(herght);
            data.setOilHeight(height);
            data.setReceiveDate(new Date());
            data.setDepotId(deviceIot.getDepotId());
            data.setCompanyId(ser.getCompanyId());
//            //计算储量
//            Depot depot = coreCommonService.getCacheDepot(ser.getCompanyId(), deviceIot.getDepotId());
//
//            if(null != depot){
//                Building building;
//                //容重
//                Double bulkWeight = depot.getBulkWeight();
//                if (null != depot.getBuildingId()) {
//                    building = buildingService.getCacheBuilding(depot.getCompanyId(),depot.getDeptId(), depot.getBuildingId());
//                    if (null != building) {
//                        if (null != building.getHeight()) {
//                            height = building.getHeight() + "";
//                        }
//                        if (null != building.getLength()) {
//                            diameter = building.getLength();
//                        }
//                        if (null != building.getDeVolume()) {
//                            deVolume = building.getDeVolume();
//                        }
//                    }
//                }
//
//                grainData.setDepotData(depot);
//                grainData.setDepotHeight(height);
//                if (null != bulkWeight && StringUtils.isNotEmpty(grainData.getOilHeight())) {
//                    Double oilHeight = Double.valueOf(grainData.getOilHeight());
//                    //计算体积
//                    volume = 3.14 * Math.pow(diameter / 2, 2) * oilHeight  - deVolume;
//                    storage = volume * bulkWeight;
//                }
//
//                grainData.setStorage(storage);
//            }
            redisUtil.set(RedisConst.buildKey(ser.getCompanyId(),RedisConst.KEY_DEPOT_HEIGHT,deviceIot.getDepotId()),data);
            log.info("高度解析完成:" + data.toString());
        }catch (Exception e){