Parcourir la source

1103 无模型设备配置

zhaoyk il y a 3 ans
Parent
commit
e44f3f12aa

+ 24 - 18
src/main/java/com/persagy/bdtp/adm/controller/ToolController.java

@@ -2,12 +2,14 @@ package com.persagy.bdtp.adm.controller;
 
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.bdtp.adm.client.RwdClient;
 import com.persagy.bdtp.adm.common.AdmConst;
 import com.persagy.bdtp.adm.common.AdmRequest;
 import com.persagy.bdtp.adm.common.AdmResult;
+import com.persagy.bdtp.adm.dao.AdmContainerConfigMapper;
 import com.persagy.bdtp.adm.dao.AdmPipeConfigMapper;
 import com.persagy.bdtp.adm.dao.AdmRelsConfigMapper;
 import com.persagy.bdtp.adm.entity.*;
@@ -128,10 +130,12 @@ public class ToolController {
 		//配置数据查询
 		List<AdmRelsConfig> relConfig = configService.queryRelsConfig(projectId);
 		List<AdmPipeConfig> pipeConfig = configService.queryPipeConfig(projectId);
+		List<AdmContainerConfig> containerConfig = configService.queryContainerConfig(projectId);
 
 		HashMap<String, Object> data = new HashMap<>();
 		data.put("relConfig", relConfig);
 		data.put("pipeConfig", pipeConfig);
+		data.put("containerConfig", containerConfig);
 
 		return AdmResult.success(data);
 	}
@@ -140,6 +144,9 @@ public class ToolController {
 	private AdmRelsConfigMapper relsConfigMapper;
 	@Autowired
 	private AdmPipeConfigMapper pipeConfigMapper;
+	@Autowired
+	private AdmContainerConfigMapper containerConfigMapper;
+
 	@PostMapping("/updateCfgItem")
 	public AdmResult<Object> updateCfgItem(@RequestBody Map<String, Object> content) {
 		String type = (String) content.get("type");
@@ -151,30 +158,29 @@ public class ToolController {
 			itemMap.put("id", newId);
 		}
 
+		boolean create = newId != null;
 		if("rel".equals(type)) {
-			if(StrUtil.isNotBlank(delId))
-				relsConfigMapper.deleteById(delId);
-			else {
-				AdmRelsConfig cfg = mapToObj(itemMap, AdmRelsConfig.class);
-				if(newId != null)
-					relsConfigMapper.insert(cfg);
-				else
-					relsConfigMapper.updateById(cfg);
-			}
+			doUpdateItem(delId, itemMap, create, AdmRelsConfig.class, relsConfigMapper);
 		} else if ("pipe".equals(type)) {
-			if(StrUtil.isNotBlank(delId))
-				pipeConfigMapper.deleteById(delId);
-			else {
-				AdmPipeConfig cfg = mapToObj(itemMap, AdmPipeConfig.class);
-				if(newId != null)
-					pipeConfigMapper.insert(cfg);
-				else
-					pipeConfigMapper.updateById(cfg);
-			}
+			doUpdateItem(delId, itemMap, create, AdmPipeConfig.class, pipeConfigMapper);
+		} else if("container".equals(type)) {
+			doUpdateItem(delId, itemMap, create, AdmContainerConfig.class, containerConfigMapper);
 		}
 
 		return AdmResult.success(newId);
 	}
+	
+	private <T extends BaseAdmEntity> void doUpdateItem(String delId, Map<String, Object> itemMap, boolean create, Class<T> cls, BaseMapper<T> mapper){
+		if(StrUtil.isNotBlank(delId))
+			mapper.deleteById(delId);
+		else {
+			T cfg = mapToObj(itemMap, cls);
+			if(create)
+				mapper.insert(cfg);
+			else
+				mapper.updateById(cfg);
+		}
+	}
 
 	private <T extends BaseAdmEntity> T mapToObj(Map<String, Object> map, Class<T> cls){
 		try {

+ 11 - 0
src/main/java/com/persagy/bdtp/adm/dao/AdmContainerConfigMapper.java

@@ -0,0 +1,11 @@
+package com.persagy.bdtp.adm.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.bdtp.adm.entity.AdmConfig;
+import com.persagy.bdtp.adm.entity.AdmContainerConfig;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface AdmContainerConfigMapper extends BaseMapper<AdmContainerConfig> {
+
+}

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmConfig.java

@@ -40,7 +40,7 @@ public class AdmConfig extends BaseAdmEntity {
 			} catch (JsonProcessingException e) {
 
 			}
-			data = null;
+			//data = null;
 		}
 	}
 

+ 14 - 0
src/main/java/com/persagy/bdtp/adm/entity/AdmContainerConfig.java

@@ -0,0 +1,14 @@
+package com.persagy.bdtp.adm.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+@Data
+@TableName(value = "adm_container_config", autoResultMap = true)
+public class AdmContainerConfig extends BaseAdmEntity {
+
+	private String containerCode;
+
+	private String widgetCode;
+
+}

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmInfosConfig.java

@@ -47,7 +47,7 @@ public class AdmInfosConfig extends BaseAdmEntity {
             } catch (JsonProcessingException e) {
 
             }
-            infos = null;
+            //infos = null;
         }
     }
 

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmJobSpace.java

@@ -48,7 +48,7 @@ public class AdmJobSpace extends BaseAdmDataEntity {
             } catch (JsonProcessingException e) {
 
             }
-            outline = null;
+            //outline = null;
         }
     }
 

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmObject.java

@@ -70,7 +70,7 @@ public class AdmObject extends BaseDeliveryEntity {
 			} catch (JsonProcessingException e) {
 
 			}
-			infos = null;
+			//infos = null;
 		}
 	}
 

+ 2 - 2
src/main/java/com/persagy/bdtp/adm/entity/AdmPipe.java

@@ -60,7 +60,7 @@ public class AdmPipe extends BaseDeliveryEntity {
             } catch (JsonProcessingException e) {
 
             }
-            route = null;
+            //route = null;
         }
         if(infos != null) {
             ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
@@ -69,7 +69,7 @@ public class AdmPipe extends BaseDeliveryEntity {
             } catch (JsonProcessingException e) {
 
             }
-            infos = null;
+            //infos = null;
         }
     }
 

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmProblemArch.java

@@ -47,7 +47,7 @@ public class AdmProblemArch extends BaseAdmDataEntity {
             } catch (JsonProcessingException e) {
 
             }
-            geom = null;
+            //geom = null;
         }
     }
 

+ 1 - 1
src/main/java/com/persagy/bdtp/adm/entity/AdmQrCode.java

@@ -41,7 +41,7 @@ public class AdmQrCode extends BaseAdmDataEntity {
             } catch (JsonProcessingException e) {
 
             }
-            location = null;
+            //location = null;
         }
     }
 

+ 2 - 0
src/main/java/com/persagy/bdtp/adm/service/IConfigService.java

@@ -20,6 +20,8 @@ public interface IConfigService {
 
 	List<AdmComponent> queryComponent(String projectId);
 
+	List<AdmContainerConfig> queryContainerConfig(String projectId);
+
 	ArrayNode queryNewEquipTypes(String projectId);
 
 	ObjectNode queryRenameEquipTypes(String projectId);

+ 8 - 0
src/main/java/com/persagy/bdtp/adm/service/impl/ConfigServiceImpl.java

@@ -33,6 +33,9 @@ public class ConfigServiceImpl implements IConfigService {
 	@Autowired
 	private AdmComponentMapper componentMapper;
 
+	@Autowired
+	private AdmContainerConfigMapper containerConfigMapper;
+
 	@Override
 	public List<AdmM2dEquip> queryM2dEquip(String projectId) {
 		return m2dEquipMapper.selectList(null);
@@ -64,6 +67,11 @@ public class ConfigServiceImpl implements IConfigService {
 	}
 
 	@Override
+	public List<AdmContainerConfig> queryContainerConfig(String projectId) {
+		return containerConfigMapper.selectList(null);
+	}
+
+	@Override
 	public ArrayNode queryNewEquipTypes(String projectId) {
 		List<AdmConfig> list = commonConfigMapper.selectList(new QueryWrapper<AdmConfig>().eq("code", "new_equip_types"));
 		if(CollUtil.isNotEmpty(list)){

+ 5 - 3
src/main/java/com/persagy/bdtp/adm/service/impl/SyncAppImpl.java

@@ -101,6 +101,7 @@ public class SyncAppImpl implements ISyncApp {
 		List<AdmPipeConfig> pipeConfig = configService.queryPipeConfig(projectId);
 		List<AdmConfig> config = configService.queryCommonConfig(projectId);
 		List<AdmComponent> component = configService.queryComponent(projectId);
+		List<AdmContainerConfig> containerConfig = configService.queryContainerConfig(projectId);
 
 		HashMap<String, Object> data = new HashMap<>();
 		data.put("dict", dict);
@@ -110,6 +111,7 @@ public class SyncAppImpl implements ISyncApp {
 		data.put("pipeConfig", pipeConfig);
 		data.put("config", serializeJsonProp(config));
 		data.put("component", component);
+		data.put("containerConfig", containerConfig);
 
 		return data;
 	}
@@ -461,9 +463,9 @@ public class SyncAppImpl implements ISyncApp {
 
 	private <T extends BaseAdmEntity> List<T> serializeJsonProp(List<T> list){
 		//app端完善,不需要做tostr处理了
-//		for(BaseAdmEntity entity : list) {
-//			entity.serializeJsonProp();
-//		}
+		for(BaseAdmEntity entity : list) {
+			entity.serializeJsonProp();
+		}
 		return list;
 	}