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;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 协议解析入口
|
*
|
* @author vince
|
*/
|
@Slf4j
|
@Component(AnalysisHeightService.BEAN_ID)
|
public class AnalysisHeightService {
|
|
public static final String BEAN_ID = "iot.analysisHeightService";
|
|
@Autowired
|
private RedisUtil redisUtil;
|
@Autowired
|
private CoreCommonService coreCommonService;
|
@Autowired
|
private BuildingService buildingService;
|
|
/**
|
* @param deviceAttr
|
* @param ser
|
*/
|
public void analysis(DeviceAttr deviceAttr , DeviceSer ser ,DeviceIot deviceIot) {
|
try{
|
List<DeviceAttrInfo> deviceAttrInfos = deviceAttr.getTerminalAttrInfoList();
|
String height =(deviceAttrInfos.get(2).getValue());
|
GrainData data = new GrainData();
|
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){
|
log.error(e.getMessage(),e);
|
}
|
}
|
}
|