فهرست منبع

1016 字典新增自定义设备类

zhaoyk 3 سال پیش
والد
کامیت
55649a4150

+ 16 - 0
src/main/java/com/persagy/bdtp/adm/service/impl/SyncAppImpl.java

@@ -3,9 +3,11 @@ package com.persagy.bdtp.adm.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.persagy.bdtp.adm.client.DicClient;
 import com.persagy.bdtp.adm.client.RwdClient;
@@ -25,6 +27,8 @@ import com.persagy.dmp.common.lang.PsDateTime;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.define.entity.RelationDefine;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -77,6 +81,9 @@ public class SyncAppImpl implements ISyncApp {
 	@Autowired
 	private ISyncModel syncModel;
 
+	@Autowired
+	ResourceLoader resourceLoader;
+
 	@Override
 	public Map<String, Object> downloadDictAndConfig(String groupCode, String projectId, String userId) {
 		Map<String, Object> dict = queryDict(groupCode, projectId, userId);
@@ -126,6 +133,15 @@ public class SyncAppImpl implements ISyncApp {
 				equipList.add(def);
 		}
 
+		//加载新增的自定义设备类
+		try{
+			Resource resource = resourceLoader.getResource("classpath:equip.json");
+			List<TypeDef> types = objectMapper.readValue(resource.getInputStream(), new TypeReference<List<TypeDef>>(){});
+			equipList.addAll(types);
+		}catch (Exception e) {
+
+		}
+
 		//组织树形结构
 //		for(Map<String, Object> major : majorList){
 //			ArrayList<TypeDef> childrenSys = new ArrayList<>();

+ 92 - 0
src/main/resources/equip.json

@@ -0,0 +1,92 @@
+[
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFA01",
+    "name": "火灾报警显示盘",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFA"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFA02",
+    "name": "消防电话分机",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFA"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFA03",
+    "name": "消防模块",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFA"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS01",
+    "name": "消防关断阀",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS02",
+    "name": "消防快速排气阀",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS03",
+    "name": "消防泄压阀",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS04",
+    "name": "消防压力开关",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS05",
+    "name": "消防水锤消除器",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS06",
+    "name": "消防流量开关",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  },
+  {
+    "id": "",
+    "valid": 1,
+    "code": "FFFS07",
+    "name": "消防水流指示器",
+    "objType": "equipment",
+    "majorCode": "FF",
+    "systemCode": "FFFS"
+  }
+]

+ 21 - 0
src/test/java/com/persagy/bdtp/adm/test/AdmApplicationTests.java

@@ -2,6 +2,9 @@ package com.persagy.bdtp.adm.test;
 
 import cn.hutool.core.util.IdUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.bdtp.adm.dao.*;
 import com.persagy.bdtp.adm.entity.*;
 import com.persagy.bdtp.adm.service.ISyncModel;
@@ -13,6 +16,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.*;
@@ -183,4 +188,20 @@ public class AdmApplicationTests {
 		info.put("options", ops);
 	}
 
+	@Autowired
+	ObjectMapper objectMapper;
+	@Autowired
+	ResourceLoader resourceLoader;
+	@Test
+	public void testCustomEquip(){
+		try{
+			Resource resource = resourceLoader.getResource("classpath:equip.json");
+			List<TypeDef> types = objectMapper.readValue(resource.getInputStream(), new TypeReference<List<TypeDef>>(){});
+			types.stream().forEach(type -> type.setId(IdUtil.simpleUUID()));
+			System.out.println(objectMapper.writeValueAsString(types));
+		}catch (Exception e) {
+
+		}
+	}
+
 }