package com.ld.igds.protocol.fzzy.analysis;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.ld.igds.es.dto.EsData;
|
import com.ld.igds.es.service.CoreEsService;
|
import com.ld.igds.models.DeviceSer;
|
import com.ld.igds.protocol.fzzy.dto.ReMessage;
|
import com.ld.igds.protocol.fzzy.resp.Response4001;
|
|
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 andy
|
*/
|
@Slf4j
|
@Component(AnalysisEs.BEAN_ID)
|
public class AnalysisEs {
|
|
public static final String BEAN_ID = "fzzy.analysisEnergy";
|
|
@Autowired
|
private CoreEsService esService;
|
|
/**
|
* 能耗解析 2022-12-17弃用,改用新的解析方式
|
* <p>
|
* "ep":"4340.100","eq":"4802.100","houseId":"3P07","ia":"0.300","ib":"0.300","ic":"0.000","seqId":0,"ua":"229.4","ub":"229.2","uc":"229.0"
|
*
|
* @param reMessage
|
* @param ser
|
*/
|
// public void analysis4001(ReMessage reMessage, DeviceSer ser) {
|
//
|
// Response4001 response = JSONObject.parseObject(reMessage.getContent(), Response4001.class);
|
//
|
// //有功电能判断是否返回有效数据
|
// if (null == response.getEp()) {
|
// log.error("---能耗数据返回数据不完整,停止解析----{}", reMessage.toString());
|
// return;
|
// }
|
//
|
// EsData esData = new EsData();
|
// esData.setCompanyId(ser.getCompanyId());
|
// esData.setDepotId(response.getHouseId());
|
// esData.setUpdateTime(new Date());
|
// esData.setUa(response.getUa());
|
// esData.setUb(response.getUb());
|
// esData.setUc(response.getUc());
|
//
|
// esData.setIa(response.getIa());
|
// esData.setIb(response.getIb());
|
// esData.setIc(response.getIc());
|
// esData.setF(response.getF() == null ? 0.0 : response.getF());
|
//
|
// esData.setEp(response.getEp());
|
// esData.setEq(response.getEq());
|
// if (null != response.getEs()) {
|
// esData.setEs(response.getEs());
|
// } else {
|
// esData.setEs(0.0);
|
// }
|
//
|
// esData.setEsFan(response.getEsFan() == null ? 0.0 : response.getEsFan());
|
// esData.setEsAir(response.getEsAir() == null ? 0.0 : response.getEsAir());
|
// esData.setEsLamp(response.getEsLamp() == null ? 0.0 : response.getEsLamp());
|
//
|
// log.info("控制柜----->>>平台:能耗数据解析完成-仓库={}", esData.getDepotId());
|
//
|
// esService.saveAndUpdateInc(esData);
|
// }
|
|
/**
|
* 2022-12-17启用,报文内容为列表集合
|
* "content": [{"houseId": "0135","deviceId": "6001","deviceName": "1号仓主控柜电表","ua": "220","ub": "220","uc": "220","ia": "0.1","ib": "0.1","ic": "0.1","pa": "50","pb": "50","pc": "50","pfa": "0.4","pfb": "0.4","pfc": "0.4","f": "50","ep": "123","eq": "123","es": "456","esFan": "0","esAir": "0", "esLamp": "0"}]
|
* @param reMessage
|
* @param ser
|
*/
|
public void analysis4001(ReMessage reMessage, DeviceSer ser) {
|
|
List<Response4001> result = JSON.parseArray(reMessage.getContent(), Response4001.class);
|
|
//有功电能判断是否返回有效数据
|
if (null == result || result.isEmpty()) {
|
log.error("---能耗返回数据为空,停止解析----{}", reMessage.toString());
|
return;
|
}
|
|
EsData esData;
|
for (Response4001 response : result) {
|
if (null == response.getEp()) {
|
log.error("---能耗数据返回数据不完整,停止解析----{}", reMessage.toString());
|
return;
|
}
|
esData = new EsData();
|
esData.setCompanyId(ser.getCompanyId());
|
esData.setDepotId(response.getHouseId());
|
esData.setDeviceId(StringUtils.isEmpty(response.getDeviceId())?"0":response.getDeviceId());
|
esData.setDeviceName(response.getDeviceName());
|
esData.setUpdateTime(new Date());
|
esData.setUa(response.getUa());
|
esData.setUb(response.getUb());
|
esData.setUc(response.getUc());
|
|
esData.setIa(response.getIa());
|
esData.setIb(response.getIb());
|
esData.setIc(response.getIc());
|
esData.setF(response.getF() == null ? 0.0 : response.getF());
|
|
esData.setEp(response.getEp());
|
esData.setEq(response.getEq());
|
if (null != response.getEs()) {
|
esData.setEs(response.getEs());
|
} else {
|
esData.setEs(0.0);
|
}
|
|
esData.setEsFan(response.getEsFan() == null ? 0.0 : response.getEsFan());
|
esData.setEsAir(response.getEsAir() == null ? 0.0 : response.getEsAir());
|
esData.setEsLamp(response.getEsLamp() == null ? 0.0 : response.getEsLamp());
|
|
log.info("控制柜----->>>平台:能耗数据解析完成-仓库={}", esData.getDepotId());
|
|
esService.saveAndUpdateInc(esData);
|
}
|
}
|
|
}
|