|
@@ -1,7 +1,17 @@
|
|
|
-package com.persagy.dmp.rwd.dic;
|
|
|
+package com.persagy.dmp.rwd.datautils;
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
+import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
|
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+import com.persagy.common.criteria.JacksonCriteria;
|
|
|
import com.persagy.common.date.DateUtils;
|
|
|
import com.persagy.common.json.JacksonMapper;
|
|
|
+import com.persagy.dmp.common.http.HttpUtils;
|
|
|
+import com.persagy.dmp.rwd.dic.DataTypeMapping;
|
|
|
+import com.persagy.dmp.rwd.dic.ExcelUtils;
|
|
|
+import com.persagy.dmp.rwd.dic.FuncidDefModel;
|
|
|
+import com.persagy.dmp.rwd.dic.FuncidUtils;
|
|
|
import com.persagy.dmp.rwd.enums.FuncidDataType;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -9,7 +19,13 @@ import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.util.Date;
|
|
@@ -23,15 +39,30 @@ import java.util.UUID;
|
|
|
* @verison: 1.0
|
|
|
*/
|
|
|
@Slf4j
|
|
|
+@SpringBootTest
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
public class ImportFuncid {
|
|
|
|
|
|
private String basepath = "C:\\Users\\24341\\Downloads\\数据字典附表(20210412)";
|
|
|
|
|
|
private String outPath = "C:/Users/24341/Downloads/20210413/funcid-" + DateUtils.format(new Date()) + ".dml.sql";
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HttpUtils httpUtils;
|
|
|
+
|
|
|
+ @Value("${persagy.dmp.rwdedit.server}")
|
|
|
+ private String rwdeditServer;
|
|
|
+
|
|
|
+ @Before
|
|
|
+ public void init() {
|
|
|
+ FuncidUtils.httpUtils = httpUtils;
|
|
|
+ FuncidUtils.rwdeditServer = rwdeditServer;
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void importFuncidDef() throws IOException {
|
|
|
List<FuncidDefModel> funcids = new LinkedList<>();
|
|
|
+// importBase(funcids);
|
|
|
importSpace(funcids);
|
|
|
importSystem(funcids);
|
|
|
importEquipment(funcids);
|
|
@@ -53,6 +84,13 @@ public class ImportFuncid {
|
|
|
writer.close();
|
|
|
}
|
|
|
|
|
|
+ private void importBase(List<FuncidDefModel> funcids) throws IOException {
|
|
|
+ funcids.addAll(readSheet("system", "/附表6-机电精装类对象通用属性点表.xlsx", "系统类"));
|
|
|
+ funcids.addAll(readSheet("equipment", "/附表6-机电精装类对象通用属性点表.xlsx", "设备类"));
|
|
|
+ funcids.addAll(readSheet("component", "/附表6-机电精装类对象通用属性点表.xlsx", "部件类"));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private String toSql(FuncidDefModel model) {
|
|
|
StringBuilder buff = new StringBuilder("");
|
|
|
buff.append("insert into rwd_def_funcid ");
|
|
@@ -162,14 +200,22 @@ public class ImportFuncid {
|
|
|
funcid.setSubFlag(false);
|
|
|
if (model.remark != null) {
|
|
|
funcid.setNote(model.remark.replace("\n", ""));
|
|
|
+ if (model.remark != null) {
|
|
|
+ if (model.remark.contains("YYYYMMDD-YYYYMMDD")) {
|
|
|
+ funcid.setFormater("YYYYMMDD-YYYYMMDD");
|
|
|
+ }else if (model.remark.contains("YYYYMMDD")) {
|
|
|
+ funcid.setFormater("YYYYMMDD");
|
|
|
+ }else if (model.remark.contains("YYYY")) {
|
|
|
+ funcid.setFormater("YYYY");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (model.origDataSource != null) {
|
|
|
funcid.setOrigDataSource(model.origDataSource.replace("\n", "nn")); // 去掉换行符
|
|
|
}
|
|
|
if (funcid.getDataType() == FuncidDataType.ENUM || funcid.getDataType() == FuncidDataType.MENUM || funcid.getDataType() == FuncidDataType.BOOLEAN) {
|
|
|
- FuncidUtils funcidUtils = new FuncidUtils();
|
|
|
- funcid.setDataSource(funcidUtils.transEnumDataSource(model.origDataSource)); // 解析datasource
|
|
|
+ funcid.setDataSource(FuncidUtils.transEnumDataSource(model.origDataSource)); // 解析datasource
|
|
|
}
|
|
|
return funcid;
|
|
|
}
|
|
@@ -191,6 +237,7 @@ public class ImportFuncid {
|
|
|
funcids.addAll(readSheet("SecurityZone", "/附表5-建筑空间类对象属性点表/附表5.5-空间.xlsx", "SCZ安防分区"));
|
|
|
funcids.addAll(readSheet("TenantZone", "/附表5-建筑空间类对象属性点表/附表5.5-空间.xlsx", "TNZ租户分区"));
|
|
|
funcids.addAll(readSheet("FunctionZone", "/附表5-建筑空间类对象属性点表/附表5.5-空间.xlsx", "FCZ功能分区"));
|
|
|
+ funcids.addAll(readSheet("PassengerFlowZone", "/附表5-建筑空间类对象属性点表/附表5.5-空间.xlsx", "PFZ客流分区"));
|
|
|
funcids.addAll(readSheet("OtherZone", "/附表5-建筑空间类对象属性点表/附表5.5-空间.xlsx", "OTZ其他分区"));
|
|
|
}
|
|
|
|
|
@@ -813,5 +860,29 @@ public class ImportFuncid {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void test() {
|
|
|
+ ArrayNode array = JsonNodeFactory.instance.arrayNode();
|
|
|
+ //查询知识库详情
|
|
|
+ String url = rwdeditServer + "/rwdedit/ref/type/infos/query";
|
|
|
+ JacksonCriteria criteria = JacksonCriteria.newInstance();
|
|
|
+ criteria.add("refKey", "classificationSystem");
|
|
|
+ HttpUtils.HttpResult response = httpUtils.post(url, JacksonMapper.toSimpleJson(criteria), 300000);
|
|
|
+ String content = response.getContent();
|
|
|
+ ObjectNode objectNode = JacksonMapper.toObject(content, ObjectNode.class);
|
|
|
+ ArrayNode data = JacksonMapper.getArray(objectNode, "data", JsonNodeFactory.instance.arrayNode());
|
|
|
+ for (JsonNode datum : data) {
|
|
|
+ ObjectNode obj = (ObjectNode) datum;
|
|
|
+ ObjectNode item = array.addObject();
|
|
|
+ item.put("code", JacksonMapper.getString(obj, "code"));
|
|
|
+ item.put("name", JacksonMapper.getString(obj, "name"));
|
|
|
+ String parentCode = JacksonMapper.getString(obj, "parentCode");
|
|
|
+ if (parentCode != null) {
|
|
|
+ item.put("parentCode", parentCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.err.println(JacksonMapper.toSimpleJson(array));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|