|
@@ -1,15 +1,14 @@
|
|
|
package com.persagy.dmp.rwd.dic;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.common.date.DateUtils;
|
|
|
import com.persagy.common.json.JacksonMapper;
|
|
|
import com.persagy.dmp.rwd.enums.ObjType;
|
|
|
import com.persagy.dmp.rwd.model.ClassDefModel;
|
|
|
import com.persagy.dmp.rwd.model.RwdeditRefTypeInfosModel;
|
|
|
-import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -47,20 +46,94 @@ public class ImportKnowledgeForEdit {
|
|
|
// initBaseClass(classes);
|
|
|
// 空间分区
|
|
|
// initSpace(classes);
|
|
|
- // 专业\系统\设备\部件
|
|
|
- initEquipment(classes,"major");
|
|
|
- writeFuncSqlToFile(classes, "major");
|
|
|
- classes.clear();
|
|
|
- // 工具
|
|
|
- initToolOrMaterial(classes,"tool","工具类");
|
|
|
- writeFuncSqlToFile(classes, "tool");
|
|
|
- classes.clear();
|
|
|
- // 耗材
|
|
|
- initToolOrMaterial(classes,"material","耗材类 ");
|
|
|
- writeFuncSqlToFile(classes, "material");
|
|
|
+// // 专业\系统\设备\部件
|
|
|
+// initEquipment(classes,"major");
|
|
|
+// writeFuncSqlToFile(classes, "major");
|
|
|
+// classes.clear();
|
|
|
+// // 工具
|
|
|
+// initToolOrMaterial(classes,"tool","工具类");
|
|
|
+// writeFuncSqlToFile(classes, "tool");
|
|
|
+// classes.clear();
|
|
|
+// // 耗材
|
|
|
+// initToolOrMaterial(classes,"material","耗材类 ");
|
|
|
+// writeFuncSqlToFile(classes, "material");
|
|
|
+// classes.clear();
|
|
|
+// // 省市区编号
|
|
|
+// initCityLocation(classes,"cityLocation","省市区编号");
|
|
|
+// writeFuncSqlToFile(classes, "cityLocation");
|
|
|
+// classes.clear();
|
|
|
+ // 省市区编号
|
|
|
+ initCityLocation(classes,"cityLocation","省市区编号");
|
|
|
+ writeFuncSqlToFile(classes, "cityLocation");
|
|
|
classes.clear();
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initCityLocation(List<RwdeditRefTypeInfosModel> models, String refKey, String sheetName) throws Exception {
|
|
|
+ String file = basepath + "/附表14-地域性信息表.xlsx";
|
|
|
+
|
|
|
+ FileInputStream inputStream = new FileInputStream(file);
|
|
|
+ Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
+ Sheet sheet = workbook.getSheet(sheetName);
|
|
|
+
|
|
|
+ // 行号从0开始, 从第2行开始读数据
|
|
|
+ int startRowNum = 2;
|
|
|
+ int lastRowNum = sheet.getLastRowNum();
|
|
|
+ CacheModel cache = new CacheModel();
|
|
|
+ for (int rowIndex = startRowNum; rowIndex <= lastRowNum; rowIndex++) {
|
|
|
+ Row row = sheet.getRow(rowIndex);
|
|
|
+ if (row == null) {
|
|
|
+ log.info("row[{}] is null", rowIndex);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 0专业, 3系统编码, 5系统名称, 6设备编码, 8设备名称
|
|
|
+ String cityCode = (String) ExcelUtils.parseCell(row.getCell(2), "string");// 市级code
|
|
|
+ String areaCode = (String) ExcelUtils.parseCell(row.getCell(4), "string");// 区级code
|
|
|
+ String name = (String) ExcelUtils.parseCell(row.getCell(5), "string");// 名称
|
|
|
+ Integer codeInt = (Integer)ExcelUtils.parseCell(row.getCell(6), "integer");// code
|
|
|
+ if (null==name || null == codeInt){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String code = codeInt.toString();
|
|
|
+ Double longitude = (Double) ExcelUtils.parseCell(row.getCell(7), "double");// 精度
|
|
|
+ Double latitude = (Double) ExcelUtils.parseCell(row.getCell(8), "double");// 维度
|
|
|
+ Double altitude = (Double) ExcelUtils.parseCell(row.getCell(9), "double");// 海拔
|
|
|
+ String climaticDivisionCode = (String) ExcelUtils.parseCell(row.getCell(10), "string");// 气候区
|
|
|
+ String cityDevelopmentLevelCode = (String) ExcelUtils.parseCell(row.getCell(11), "string");// 发展水平
|
|
|
+ RwdeditRefTypeInfosModel model = new RwdeditRefTypeInfosModel();
|
|
|
+ model.setRefKey(refKey);
|
|
|
+ model.setCode(code);
|
|
|
+ model.setName(name);
|
|
|
+ model.setParentCode(cache.equipCode);
|
|
|
+ if ("00".equals(cityCode) && "00".equals(areaCode)){
|
|
|
+ // 省
|
|
|
+ cache.systemCode = code;
|
|
|
+ cache.systemName = name;
|
|
|
+ model.setParentCode("-9999");
|
|
|
+ }
|
|
|
+ if (!"00".equals(cityCode) && "00".equals(areaCode)){
|
|
|
+ // 市
|
|
|
+ cache.equipCode = code;
|
|
|
+ cache.equipName = name;
|
|
|
+ model.setParentCode(cache.systemCode);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(climaticDivisionCode)){
|
|
|
+ cache.climaticDivisionCode = climaticDivisionCode;
|
|
|
+ }
|
|
|
+ ObjectNode objectNode = objectMapper.createObjectNode()
|
|
|
+ .put("altitude", altitude)
|
|
|
+ .put("latitude", latitude)
|
|
|
+ .put("longitude", longitude)
|
|
|
+ .put("climaticDivisionCode", cache.climaticDivisionCode)
|
|
|
+ .put("cityDevelopmentLevelCode", cityDevelopmentLevelCode);
|
|
|
+ model.setDataSource(objectNode);
|
|
|
+ model.setCreateUser(CREATE_USER_ID);
|
|
|
+ model.setUpdateUser(UPDATE_USER_ID);
|
|
|
+ models.add(model);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void writeFuncSqlToFile(List<RwdeditRefTypeInfosModel> classes,String refKey) throws IOException {
|
|
@@ -425,6 +498,7 @@ public class ImportKnowledgeForEdit {
|
|
|
String componentCode;
|
|
|
String componentName;
|
|
|
String componentEnglishName;
|
|
|
+ String climaticDivisionCode;
|
|
|
|
|
|
}
|
|
|
|