Merge branch 'main' of http://dev.xinyingpower.com:8080/git/cac/backend
commit
239e0c83f7
@ -0,0 +1,69 @@
|
||||
package com.xydl.cac.excel;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.xydl.cac.entity.NiecSensor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CacExcelListener extends AnalysisEventListener<CacLine> {
|
||||
|
||||
List<CacLine> list = new ArrayList<>();
|
||||
int base = 16385;
|
||||
int type;
|
||||
LinkedHashMap<String, NiecSensor> sensorList = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
public void invoke(CacLine line, AnalysisContext analysisContext) {
|
||||
int row = analysisContext.readRowHolder().getRowIndex();
|
||||
if (row > 1) {
|
||||
if (line.getPointId().contains("遥测")) {
|
||||
type = 0;
|
||||
} else if (line.getPointId().contains("遥信")) {
|
||||
type = 1;
|
||||
} else {
|
||||
processDate(line, row + 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void processDate(CacLine line, int row) {
|
||||
if (StringUtils.isNotBlank(line.getSensorCode())) {
|
||||
NiecSensor sensor = sensorList.get(line.getSensorCode());
|
||||
if (sensor == null) {
|
||||
sensor = new NiecSensor();
|
||||
sensor.setSensorCode(line.getSensorCode());
|
||||
Integer pointId = Integer.parseInt(line.getPointId()) + base;
|
||||
if (StringUtils.isBlank(line.getEquipmentCode())) {
|
||||
throw new RuntimeException("第" + row + "行的被监测设备的唯一标识不能为空");
|
||||
}
|
||||
sensor.setEquipmentId(line.getEquipmentCode());
|
||||
if (StringUtils.isBlank(line.getTableName())) {
|
||||
throw new RuntimeException("第" + row + "行的表名不能为空");
|
||||
}
|
||||
sensor.setTableName(line.getTableName());
|
||||
if (StringUtils.isNotBlank(line.getParentName()) && StringUtils.isNotBlank(line.getShortName())) {
|
||||
sensor.setName(line.getParentName() + line.getShortName());
|
||||
} else {
|
||||
sensor.setName(line.getLongName());
|
||||
}
|
||||
sensorList.put(line.getSensorCode(), sensor);
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.isBlank(line.getField())) {
|
||||
throw new RuntimeException("第" + row + "行的字段名不能为空");
|
||||
}
|
||||
list.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.xydl.cac.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CacLine {
|
||||
|
||||
@ExcelProperty("pointId")
|
||||
private String pointId;
|
||||
|
||||
@ExcelProperty("longName")
|
||||
private String longName;
|
||||
|
||||
@ExcelProperty("siteName")
|
||||
private String siteName;
|
||||
|
||||
@ExcelProperty("fullname")
|
||||
private String fullname;
|
||||
|
||||
@ExcelProperty("e")
|
||||
private String e;
|
||||
|
||||
@ExcelProperty("f")
|
||||
private String f;
|
||||
|
||||
@ExcelProperty("g")
|
||||
private String g;
|
||||
|
||||
@ExcelProperty("h")
|
||||
private String h;
|
||||
|
||||
@ExcelProperty("i")
|
||||
private String i;
|
||||
|
||||
@ExcelProperty("paramindex")
|
||||
private String paramindex;
|
||||
|
||||
@ExcelProperty("k")
|
||||
private String k;
|
||||
|
||||
@ExcelProperty("devid")
|
||||
private String devid;
|
||||
|
||||
@ExcelProperty("grpNo")
|
||||
private String grpNo;
|
||||
|
||||
@ExcelProperty("itemNo")
|
||||
private String itemNo;
|
||||
|
||||
@ExcelProperty("o")
|
||||
private String o;
|
||||
|
||||
@ExcelProperty("p")
|
||||
private String p;
|
||||
|
||||
@ExcelProperty("sensorCode")
|
||||
private String sensorCode;
|
||||
|
||||
@ExcelProperty("equipmentCode")
|
||||
private String equipmentCode;
|
||||
|
||||
@ExcelProperty("phase")
|
||||
private String phase;
|
||||
|
||||
@ExcelProperty("tableName")
|
||||
private String tableName;
|
||||
|
||||
@ExcelProperty("field")
|
||||
private String field;
|
||||
|
||||
@ExcelProperty("parentName")
|
||||
private String parentName;
|
||||
|
||||
@ExcelProperty("shortName")
|
||||
private String shortName;
|
||||
|
||||
@ExcelProperty("fieldDesc")
|
||||
private String fieldDesc;
|
||||
}
|
Loading…
Reference in New Issue