Commit cfdda15b by yukang

数据采集接收接口

parent 2d448aa8
package com.baosight.hpjx.hp.tc.service;
import com.baosight.hpjx.common.HPConstants;
import com.baosight.hpjx.equipment.hp.domain.CutterbarStatus;
import com.baosight.hpjx.equipment.hp.domain.CutterbarTime;
import com.baosight.hpjx.equipment.hp.domain.CutterbarWarning;
import com.baosight.hpjx.equipment.hp.domain.CutterbarWarningBase;
import com.baosight.hpjx.hp.sb.domain.HPSB001;
import com.baosight.hpjx.hp.sb.domain.HPSB002;
import com.baosight.hpjx.hp.sb.domain.HPSB00A;
import com.baosight.hpjx.util.DateUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.hpjx.xml.XmlUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
public class ServiceHPTCP001 extends ServiceBase {
public EiInfo logAnalysis(EiInfo inInfo) {
HPSB002 hpsb002 = new HPSB002();
HPSB001 hpsb001 = new HPSB001();
List<HPSB002> hpsb002List = new ArrayList<>();
List<HPSB001> hpsb001List = new ArrayList<>();
EiInfo outInfo = new EiInfo();
//TODO 根据TYPE来判断内容属于哪一种,然后再进行解析
//TODO TYPE = STARUS_TYPE --- 设备状态
//TODO TYPE = TIME_TYPE --- 开机时间
//TODO TYPE = WARNING_TYPE --- 报警内容
String equipmentType = inInfo.getString("equipmentType");
String dataContent = inInfo.getString("dataContent");
String equipmentCode = inInfo.getString("equipmentCode");
HPSB00A hpsb00A = new HPSB00A();
hpsb00A.setDataContent(dataContent);
hpsb00A.setEquipmentType(equipmentType);
hpsb00A.setEquipmentCode(equipmentCode);
if (StringUtils.isNotEmpty(equipmentType)) {
if (equipmentType.equals(HPConstants.STARUS_TYPE)) {
//解析设备状态
List<CutterbarStatus> cutterbarStatusList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarStatus.class);
hpsb002.setId(StringUtils.uuid());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(hpsb00A.getEquipmentType());
hpsb002.setLogValue(cutterbarStatusList.get(0).getStatus().toString());
hpsb002.setCreatedBy("自动化中转程序");
hpsb002.setCreatedTime(DateUtils.shortDateTime());
this.dao.insert("HPSB002.insert",hpsb002);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg(outInfo.getMsg());
return inInfo;
}
if (equipmentType.equals(HPConstants.TIME_TYPE)) {
//解析开机时间
List<CutterbarTime> cutterbarTimeList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarTime.class);
hpsb002.setId(StringUtils.uuid());
hpsb002.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb002.setEquipmentType(hpsb00A.getEquipmentType());
hpsb002.setLogValue(cutterbarTimeList.get(0).getTime());
hpsb002.setCreatedBy("自动化中转程序");
hpsb002.setCreatedTime(DateUtils.shortDateTime());
this.dao.insert("HPSB002.insert",hpsb002);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg(outInfo.getMsg());
return inInfo;
}
if (equipmentType.equals(HPConstants.WARNING_TYPE)) {
//解析报警内容
List<CutterbarWarningBase> cutterbarWarningBaseList = XmlUtils.readXml(hpsb00A.getDataContent(), CutterbarWarningBase.class);
CutterbarWarning cutterbarWarning = new CutterbarWarning();
if (CollectionUtils.isNotEmpty(cutterbarWarningBaseList)) {
cutterbarWarning = CutterbarWarning.convertBase(cutterbarWarningBaseList.get(0));
}
hpsb001.setId(StringUtils.uuid());
hpsb001.setErrorCode(cutterbarWarning.getErrorCode());
hpsb001.setPrio(cutterbarWarning.getPrio());
hpsb001.setProgramNo(cutterbarWarning.getProgramNo());
hpsb001.setRowno(cutterbarWarning.getRowNo());
hpsb001.setGotoRowNone(cutterbarWarning.getGotoRowNone());
hpsb001.setFileName(cutterbarWarning.getFileName());
hpsb001.setEquipmentCode(hpsb00A.getEquipmentCode());
hpsb001.setEquipmentType(hpsb00A.getEquipmentType());
hpsb001.setCreatedBy("自动化中转程序");
hpsb001.setCreatedTime(DateUtils.shortDateTime());
this.dao.insert("HPSB001.insert",hpsb002);
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg(outInfo.getMsg());
return inInfo;
}
}
inInfo.setStatus(500);
inInfo.setMsg("未解析到数据类型");
return inInfo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment