package com.ld.igds.protocol.fzzy.analysis;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.ld.igds.common.CoreCommonService;
|
import com.ld.igds.constant.BizType;
|
import com.ld.igds.gas.dto.GasProgressData;
|
import com.ld.igds.io.notify.NotifyWebInvoker;
|
import com.ld.igds.io.constant.OrderRespEnum;
|
import com.ld.igds.models.DepotConf;
|
import com.ld.igds.models.DeviceSer;
|
import com.ld.igds.models.Pest;
|
import com.ld.igds.models.PestInfo;
|
import com.ld.igds.order.ExeOrderService;
|
import com.ld.igds.pest.CorePestService;
|
import com.ld.igds.protocol.fzzy.ServerUtils;
|
import com.ld.igds.protocol.fzzy.command.BaseRemoteImpl;
|
import com.ld.igds.protocol.fzzy.dto.ReMessage;
|
import com.ld.igds.protocol.fzzy.dto.SendMessage;
|
import com.ld.igds.protocol.fzzy.req.Request2202;
|
import com.ld.igds.protocol.fzzy.req.Request2203;
|
import com.ld.igds.protocol.fzzy.req.RequestBody2203;
|
import com.ld.igds.protocol.fzzy.builder.SimpleCommandBuilder;
|
import com.ld.igds.util.ContextUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 气体解析
|
*
|
* @author vince
|
*/
|
@Slf4j
|
@Component(AnalysisPest.BEAN_ID)
|
public class AnalysisPest extends BaseRemoteImpl {
|
|
public static final String BEAN_ID = "fzzy.analysisPest";
|
|
@Autowired
|
private CorePestService pestService;
|
@Autowired
|
private CoreCommonService commonService;
|
@Autowired
|
private ExeOrderService exeOrderService;
|
|
@Autowired
|
private NotifyWebInvoker notifyInvoker;
|
|
|
public void analysis2201(ReMessage reMessage, DeviceSer ser) {
|
//DO NOTHING
|
}
|
|
public void analysis2202(ReMessage reMessage, DeviceSer ser) {
|
//平台不反馈
|
|
//终端请求-返回的进度信息
|
Request2202 request2202 = JSONObject.parseObject(reMessage.getContent().replaceAll(" ", ""), Request2202.class);
|
|
GasProgressData gasProgress = new GasProgressData();
|
gasProgress.setCompanyId(ser.getCompanyId());
|
gasProgress.setCheckPoint(request2202.getPoint());
|
gasProgress.setSerId(ser.getId());
|
gasProgress.setDepotId(request2202.getHouseId());
|
gasProgress.setSumCheckNum(0);
|
|
DepotConf depotConf = commonService.getCacheDepotConf(
|
ser.getCompanyId(), request2202.getHouseId());
|
|
|
gasProgress.setMsg("虫害检测进度:仓库=" + depotConf.getDepotName() + " 当前:"
|
+ gasProgress.getCheckPoint());
|
|
notifyInvoker.notifyGasProgress(gasProgress);
|
}
|
|
//检测结果
|
public void analysis2203(ReMessage reMessage, DeviceSer ser) {
|
|
//平台反馈
|
SimpleCommandBuilder commandBuilder = SimpleCommandBuilder.getInstance();
|
SendMessage message = commandBuilder.buildMessage(ser, ServerUtils.FUNCTION_2203);
|
send(message);
|
|
|
// 清除采集锁
|
// exeOrderService.removeCache(ser.getCompanyId(), ser.getId(), BizType.PEST.getCode());
|
|
//解析结果
|
Request2203 request2203 = JSONObject.parseObject(reMessage.getContent().replaceAll(" ", ""), Request2203.class);
|
|
|
DepotConf depotConf = commonService.getCacheDepotConf(ser.getCompanyId(), request2203.getHouseId());
|
|
|
//主体信息
|
Pest pest = new Pest();
|
pest.setBatchId(request2203.getTime().substring(0, 12));
|
pest.setCheckNum(request2203.getPoints().size());
|
pest.setCompanyId(ser.getCompanyId());
|
pest.setDepotId(request2203.getHouseId());
|
pest.setPestEnd(depotConf.getPestEnd());
|
pest.setPestStart(depotConf.getPestStart());
|
pest.setReceiveDate(new Date());
|
pest.setPestMax(0);
|
|
StringBuffer points = new StringBuffer();
|
List<PestInfo> items = new ArrayList<>();
|
PestInfo info;
|
|
for (RequestBody2203 point : request2203.getPoints()) {
|
if (point.getNum() > pest.getPestMax()) {
|
pest.setPestMax(point.getNum());
|
}
|
|
info = new PestInfo();
|
info.setId(ContextUtil.buildInfoId(pest.getCompanyId(), pest.getDepotId(), pest.getBatchId()));
|
info.setPassCode(point.getPoint());
|
info.setPestNum(point.getNum());
|
info.setPestType(point.getType());
|
items.add(info);
|
|
points.append(info.getPassCode() + ",");
|
points.append(info.getPestNum() + ";");
|
}
|
pest.setPoints(points.toString());
|
|
|
pestService.saveInfoPest(items);
|
pestService.saveOrUpdateData(pest);
|
|
// 调用通知前端
|
notifyInvoker.notifyWeb(pest.getCompanyId(), OrderRespEnum.MSG_SUCCESS,
|
BizType.PEST, depotConf.getDepotName() + " 虫害检测:结果返回成功.");
|
|
|
log.info("控制柜----->>>平台:虫害解析完成-仓库={},批次={}", depotConf.getDepotName(), pest.getBatchId());
|
}
|
|
public void analysis2204(ReMessage reMessage, DeviceSer ser) {
|
//DO NOTHING
|
}
|
}
|