浏览代码

1102
1,服务区域
2,无模型设备
3,配置工具

zhaoyk 3 年之前
父节点
当前提交
d3d4d8ceeb

+ 7 - 0
src/main/java/com/persagy/bdtp/adm/client/RwdClient.java

@@ -4,6 +4,7 @@ import com.persagy.bdtp.adm.entity.TypeDef;
 import com.persagy.dmp.basic.config.DigitalFeignConfig;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.define.entity.GraphDefine;
 import com.persagy.dmp.define.entity.RelationDefine;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -49,4 +50,10 @@ public interface RwdClient {
 											 @RequestParam("userId") String userId,
 											 @RequestBody QueryCriteria criteria);
 
+	@PostMapping("/rwd/def/graph/query")
+	CommonResult<List<GraphDefine>> queryGraphDef(@RequestParam("groupCode") String groupCode,
+														 @RequestParam("projectId") String projectId,
+														 @RequestParam("appId") String appId,
+														 @RequestParam("userId") String userId,
+														 @RequestBody QueryCriteria criteria);
 }

+ 189 - 0
src/main/java/com/persagy/bdtp/adm/controller/ToolController.java

@@ -0,0 +1,189 @@
+package com.persagy.bdtp.adm.controller;
+
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+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.AdmPipeConfigMapper;
+import com.persagy.bdtp.adm.dao.AdmRelsConfigMapper;
+import com.persagy.bdtp.adm.entity.*;
+import com.persagy.bdtp.adm.service.IConfigService;
+import com.persagy.bdtp.adm.service.ISyncApp;
+import com.persagy.bdtp.adm.service.ISyncOldAdm;
+import com.persagy.bdtp.adm.service.ServiceUtil;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.constant.ResponseCode;
+import com.persagy.dmp.common.exception.BusinessException;
+import com.persagy.dmp.common.helper.SpringHelper;
+import com.persagy.dmp.define.entity.GraphDefine;
+import com.persagy.dmp.define.entity.RelationDefine;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.*;
+
+@CrossOrigin
+@RestController
+@RequestMapping("/tool")
+public class ToolController {
+
+	@Autowired
+	private ObjectMapper objectMapper;
+
+	@Autowired
+	private ISyncApp syncApp;
+
+	@Autowired
+	private RwdClient rwdClient;
+
+	@Autowired
+	private IConfigService configService;
+
+	@RequestMapping("/dict")
+	public AdmResult<Object> dict(@RequestBody AdmRequest req){
+		Map<String,Object> map = syncApp.queryDict(req.getGroupCode(), req.getProjectId(), req.getUserId());
+
+		List<Map<String, Object>> majorList = (List)map.get("major");
+		List<TypeDef> sysList = (List)map.get("system");
+		List<TypeDef> equipList = (List)map.get("equipment");
+		distinct(sysList);
+		distinct(equipList);
+
+		clearTime(majorList);
+		clearTime(sysList);
+		clearTime(equipList);
+
+		//组织树形结构
+		for(Map<String, Object> major : majorList){
+			ArrayList<TypeDef> childrenSys = new ArrayList<>();
+			major.put("children", childrenSys);
+			String majorCode = (String) major.get("code");
+			for(Iterator<TypeDef> sysIter = sysList.iterator(); sysIter.hasNext();){
+				TypeDef sysDef = sysIter.next();
+				if(sysDef.getMajorCode() != null && sysDef.getMajorCode().equals(majorCode)){
+					childrenSys.add(sysDef);
+					sysIter.remove();
+				}
+			}
+		}
+		map.remove("system");
+
+		List<RelationDefine> relDefs = (List<RelationDefine>)map.get("relation");
+		List<GraphDefine> graph = ServiceUtil.call (() -> rwdClient.queryGraphDef(req.getGroupCode(), req.getProjectId(), AdmConst.APP_ID, req.getUserId(), new QueryCriteria()));
+		List<Map<String, Object>> rels = new ArrayList<>();
+		for(GraphDefine gd : graph){
+			HashMap<String, Object> m = new HashMap<>();
+			m.put("code", gd.getCode());
+			m.put("name", gd.getName());
+			m.put("type", "graph");
+			rels.add(m);
+
+			ArrayList<RelationDefine> chidren = new ArrayList<>();
+			m.put("children", chidren);
+			for(RelationDefine relDef : relDefs) {
+				if(relDef.getGraphCode().equals(gd.getCode()))
+					chidren.add(relDef);
+			}
+		}
+		map.put("relation", rels);
+
+		return AdmResult.success(map);
+	}
+
+	private void distinct(List<TypeDef> list){
+		List<TypeDef> result = new ArrayList<>();
+		ArrayList<String> codes = new ArrayList<>();
+		for(TypeDef def : list) {
+			if(!codes.contains(def.getCode())) {
+				codes.add(def.getCode());
+				result.add(def);
+			}
+		}
+		list.clear();
+		list.addAll(result);
+	}
+
+	private void clearTime(List<?> list){
+		for(Object o : list) {
+			if(o instanceof TypeDef) {
+				((TypeDef) o).setCreationTime(null);
+				((TypeDef) o).setModifiedTime(null);
+			} else if(o instanceof Map) {
+				((Map) o).put("creationTime", null);
+				((Map) o).put("modifiedTime", null);
+				((Map) o).put("name", ((Map) o).get("label")); //handle major
+			}
+		}
+	}
+
+	@RequestMapping("/cfgs")
+	public AdmResult<Object> cfgs(@RequestBody AdmRequest req){
+		String projectId = req.getProjectId();
+
+		//配置数据查询
+		List<AdmRelsConfig> relConfig = configService.queryRelsConfig(projectId);
+		List<AdmPipeConfig> pipeConfig = configService.queryPipeConfig(projectId);
+
+		HashMap<String, Object> data = new HashMap<>();
+		data.put("relConfig", relConfig);
+		data.put("pipeConfig", pipeConfig);
+
+		return AdmResult.success(data);
+	}
+
+	@Autowired
+	private AdmRelsConfigMapper relsConfigMapper;
+	@Autowired
+	private AdmPipeConfigMapper pipeConfigMapper;
+	@PostMapping("/updateCfgItem")
+	public AdmResult<Object> updateCfgItem(@RequestBody Map<String, Object> content) {
+		String type = (String) content.get("type");
+		Map<String, Object> itemMap = (Map<String, Object>) content.get("item");
+		String delId = (String) content.get("delId");
+		String newId = null;
+		if(itemMap != null && !itemMap.containsKey("id")){
+			newId = IdUtil.fastSimpleUUID();
+			itemMap.put("id", newId);
+		}
+
+		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);
+			}
+		} 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);
+			}
+		}
+
+		return AdmResult.success(newId);
+	}
+
+	private <T extends BaseAdmEntity> T mapToObj(Map<String, Object> map, Class<T> cls){
+		try {
+			String json = objectMapper.writeValueAsString(map);
+			return objectMapper.readValue(json, cls);
+		} catch (IOException e) {
+			e.printStackTrace();
+			throw new BusinessException(ResponseCode.A0427.getCode(), ResponseCode.A0427.getDesc());
+		}
+	}
+
+}

+ 8 - 0
src/main/java/com/persagy/bdtp/adm/dao/AdmServeAreaMapper.java

@@ -0,0 +1,8 @@
+package com.persagy.bdtp.adm.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.bdtp.adm.entity.AdmServeArea;
+
+public interface AdmServeAreaMapper extends BaseMapper<AdmServeArea> {
+
+}

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

@@ -42,6 +42,8 @@ public class AdmObject extends BaseDeliveryEntity {
 
 	private String updateApp;
 
+	private String containerId;
+
 	@TableField(
 			typeHandler = JacksonTypeHandler.class
 	)

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

@@ -1,10 +1,12 @@
 package com.persagy.bdtp.adm.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import lombok.Data;
 
 @Data
 @TableName(value = "adm_pipe_config",autoResultMap = true)
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class AdmPipeConfig extends BaseAdmEntity {
 
     private String classCodeFrom;

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

@@ -1,10 +1,12 @@
 package com.persagy.bdtp.adm.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import lombok.Data;
 
 @Data
 @TableName(value = "adm_rels_config",autoResultMap = true)
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class AdmRelsConfig extends BaseAdmEntity {
 
     private String objTypeFrom;

+ 26 - 0
src/main/java/com/persagy/bdtp/adm/entity/AdmServeArea.java

@@ -0,0 +1,26 @@
+package com.persagy.bdtp.adm.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data;
+
+@Data
+@TableName(value = "adm_serve_area",autoResultMap = true)
+public class AdmServeArea extends BaseAdmDataEntity {
+
+    private String objId;
+
+    private String geomType;
+
+    @TableField(
+            typeHandler = JacksonTypeHandler.class
+    )
+    private JsonNode geom;
+
+    private String serveType;
+
+    private String remark;
+
+}

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

@@ -25,6 +25,8 @@ public class SyncData {
 
 	private List<AdmQrCode> qrCode;
 
+	private List<AdmServeArea> serveArea;
+
 	private String timestamp;
 
 }

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

@@ -23,6 +23,8 @@ public class UploadRtn {
 
 	private List<String> expiredQrCodeIds;
 
+	private List<String> expiredServeAreaIds;
+
 	private String timestamp;
 
 	private String buildingId;

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

@@ -10,6 +10,8 @@ import java.util.Map;
  */
 public interface ISyncApp {
 
+	Map<String, Object> queryDict(String groupCode, String projectId, String userId);
+
 	Map<String, Object> downloadDictAndConfig(String groupCode, String projectId, String userId);
 
 	Map<String, Object> downloadFrameData(String groupCode, String projectId, String userId);

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

@@ -45,12 +45,12 @@ public class ConfigServiceImpl implements IConfigService {
 
 	@Override
 	public List<AdmRelsConfig> queryRelsConfig(String projectId) {
-		return relsConfigMapper.selectList(null);
+		return relsConfigMapper.selectList(new QueryWrapper<AdmRelsConfig>().orderByAsc("graph_code", "rel_code"));
 	}
 
 	@Override
 	public List<AdmPipeConfig> queryPipeConfig(String projectId) {
-		return pipeConfigMapper.selectList(null);
+		return pipeConfigMapper.selectList(new QueryWrapper<AdmPipeConfig>().orderByAsc("pipe_type", "pipe_sub_type"));
 	}
 
 	@Override

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

@@ -76,6 +76,9 @@ public class SyncAppImpl implements ISyncApp {
 	private AdmQrCodeMapper qrCodeMapper;
 
 	@Autowired
+	private AdmServeAreaMapper serveAreaMapper;
+
+	@Autowired
 	private ISyncModel syncModel;
 
 	@Autowired
@@ -111,9 +114,8 @@ public class SyncAppImpl implements ISyncApp {
 		return data;
 	}
 
-	private Map<String, Object> queryDict(String groupCode, String projectId, String userId){
-		ObjectMapper objectMapper = SpringHelper.getBean(ObjectMapper.class);
-
+	@Override
+	public Map<String, Object> queryDict(String groupCode, String projectId, String userId){
 		//从知识库服务获取专业分类
 		QueryCriteria majorCriteria = ServiceUtil.getQueryCriteria(null, objectMapper);
 		majorCriteria.getCriteria().put("type", "major");
@@ -242,6 +244,7 @@ public class SyncAppImpl implements ISyncApp {
 		List<AdmProblemEquip> problemEquip = problemEquipMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmProblemEquip>(), projectId, buildingId, uploadFlag, lastDownloadTime));
 		List<AdmFile> file = fileMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmFile>(), projectId, buildingId, uploadFlag, lastDownloadTime));
 		List<AdmQrCode> qrCode = qrCodeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmQrCode>(), projectId, buildingId, uploadFlag, lastDownloadTime));
+		List<AdmServeArea> serveArea = serveAreaMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmServeArea>(), projectId, buildingId, uploadFlag, lastDownloadTime));
 
 		SyncData data = new SyncData();
 		data.setBuildingId(buildingId);
@@ -255,6 +258,7 @@ public class SyncAppImpl implements ISyncApp {
 		data.setProblemEquip(problemEquip);
 		data.setFile(file);
 		data.setQrCode(serializeJsonProp(qrCode));
+		data.setServeArea(serveArea);
 		data.setTimestamp(DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN));
 
 		return data;
@@ -327,6 +331,11 @@ public class SyncAppImpl implements ISyncApp {
 			List<AdmQrCode> expired = uploadAdmData(deserializeJsonProp(uploadData.getQrCode()), dbObjs, uploadFlag, timestamp, qrCodeMapper, null);
 			rtn.setExpiredQrCodeIds(buildExpiredIds(expired));
 		}
+		if (CollUtil.isNotEmpty(uploadData.getServeArea())) {
+			List<AdmServeArea> dbObjs = serveAreaMapper.selectList(new QueryWrapper<AdmServeArea>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
+			List<AdmServeArea> expired = uploadAdmData(uploadData.getServeArea(), dbObjs, uploadFlag, timestamp, serveAreaMapper, null);
+			rtn.setExpiredServeAreaIds(buildExpiredIds(expired));
+		}
 
 		rtn.setTimestamp(timestamp);
 		rtn.setBuildingId(uploadData.getBuildingId());