Browse Source

feat(adm-diagram): 1、新增接口:判断系统实例下是否有以发布的系统图 2、新增查询系统图数据范围标识逻辑

liyang 3 years ago
parent
commit
a23a561869

+ 12 - 1
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/DiagramController.java

@@ -61,7 +61,7 @@ public class DiagramController {
         String projectId = current.getProjectId();
 
         List<Diagram> diagramList = dataStrategy.getDiagrams(null, projectId,
-                diagram.getSystemId(), groupCode, diagram.getName());
+                diagram.getSystemId(), groupCode, diagram.getName(), diagram.getFlag());
 
         return ResultHelper.multi(diagramList);
     }
@@ -229,4 +229,15 @@ public class DiagramController {
     public CommonResult<Boolean> updateState(@RequestBody Map<String, String> params) {
         return ResultHelper.single(dataStrategy.updateState(params.get("state"), params.get("id")));
     }
+
+    /**
+     * 查看系统实例是否有发布状态的系统图
+     *
+     * @return 是否成功
+     */
+    @ApiOperation("查看系统实例是否有发布状态的系统图")
+    @PostMapping("/system/instance/diagram/list")
+    public CommonResult<Map<String, Boolean>> querySystemInstanceDiagramList() {
+        return ResultHelper.single(dataStrategy.querySystemInstanceDiagramList());
+    }
 }

+ 148 - 5
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/DataStrategy.java

@@ -7,6 +7,7 @@ import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
 import com.persagy.adm.diagram.entity.DiagramType;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * IO策略接口
@@ -17,51 +18,186 @@ public interface DataStrategy {
 
     String IMPL_QUALIFIER = "dataStrategyImpl";
 
+    /**
+     * 获取或有系统类型
+     *
+     * @return
+     */
     List<DiagramType> getDiagramTypes();
 
-    //模板
+    /**
+     * 获取所有模板
+     *
+     * @return 列表
+     */
     List<DiagramTemplate> getTemplates();
 
+    /**
+     * 根据系统图类型获取所有模板
+     *
+     * @param diagramType 系统图类型
+     * @return 列表
+     */
     List<DiagramTemplate> getTemplates(String diagramType);
 
+    /**
+     * 保存模板
+     *
+     * @param template 模板信息
+     * @return 列表
+     */
     DiagramTemplate saveTemplate(DiagramTemplate template);
 
+    /**
+     * 删除模板
+     *
+     * @param templateId 模板id
+     * @return
+     */
     boolean deleteTemplate(String templateId);
 
+    /**
+     * 根据模板id获取信息
+     *
+     * @param templateId 模板id
+     * @return 模板信息
+     */
     DiagramTemplate getTemplate(String templateId);
 
 
-    //图例
+    /**
+     * 根据系统code获取图例列表
+     *
+     * @param systemCode 系统code
+     * @return 图例列表
+     */
     List<Legend> getLegends(String systemCode);
 
+    /**
+     * 保存图例
+     *
+     * @param legend     图例信息
+     * @param systemCode 系统code
+     * @return 图例信息
+     */
     Legend saveLegend(Legend legend, String systemCode);
 
+    /**
+     * 删除图例
+     *
+     * @param legendId   图例id
+     * @param systemCode 系统code
+     * @return 是否成功
+     */
     boolean deleteLegend(String legendId, String systemCode);
 
+    /**
+     * 根据图例id 系统code 获取图例信息
+     *
+     * @param legendId   图例id
+     * @param systemCode 系统code
+     * @return 图例信息
+     */
     Legend getLegend(String legendId, String systemCode);
 
+    /**
+     * 根据设备类型获取图例信息
+     *
+     * @param equipmentType 设备类型
+     * @return
+     */
     List<Legend> getLegendsForEquipment(String equipmentType);
 
 
-    //系统图
+    /**
+     * 根据项目id 系统实例id 集团code 获取系统图列表
+     *
+     * @param projectId 项目id
+     * @param systemId  系统实例id
+     * @param groupCode 集团code
+     * @return 列表数据
+     */
     List<Diagram> getDiagrams(String projectId, String systemId, String groupCode);
 
-    List<Diagram> getDiagrams(String diagramType, String projectId, String systemId, String groupCode, String name); //按系统图类型查询
+    /**
+     * 按系统图类型查询
+     *
+     * @param diagramType 系统图类型
+     * @param projectId   项目id
+     * @param systemId    系统实例id
+     * @param groupCode   集团code
+     * @param name        名称
+     * @param flag        标识
+     * @return 列表数据
+     */
+    List<Diagram> getDiagrams(String diagramType, String projectId, String systemId,
+                              String groupCode, String name, Boolean flag);
 
+    /**
+     * 保存系统图
+     *
+     * @param diagram 系统图信息
+     * @return 系统图信息
+     */
     Diagram saveDiagram(Diagram diagram);
 
+    /**
+     * 删除系统图
+     *
+     * @param diagramId 系统图id
+     * @return 是否成功
+     */
     boolean deleteDiagram(String diagramId);
 
+    /**
+     * 根据系统id获取系统图信息
+     *
+     * @param diagramId 系统图id
+     * @return 系统图数据
+     */
     Diagram getDiagram(String diagramId);
 
 
-    //系统图数据
+    /**
+     * 系统图数据
+     *
+     * @param equipmentTypes 设备类型列表
+     * @param projectId      项目id
+     * @param systemId       系统实例id
+     * @param groupCode      集团code
+     * @return 列表数据
+     */
     List<ObjectNode> loadObjectsByType(List<String> equipmentTypes, String projectId, String systemId, String groupCode);
 
+    /**
+     * 根据关联类型、节点id列表、项目id 集团code获取信息
+     *
+     * @param relationTypes 关联类型列表
+     * @param objectIds     节点id列表
+     * @param projectId     项目id
+     * @param groupCode     集团code
+     * @return 列表数据
+     */
     List<ObjectNode> loadRelationsByType(List<String[]> relationTypes, List<String> objectIds, String projectId, String groupCode);
 
+    /**
+     * 根据节点id列表、项目id、集团code获取列表数据
+     *
+     * @param objectIds 节点id列表
+     * @param projectId 项目id
+     * @param groupCode 集团code
+     * @return 列表数据
+     */
     List<ObjectNode> loadObjectsById(List<String> objectIds, String projectId, String groupCode);
 
+    /**
+     * 根据关联id列表 项目id 集团code获取关联数据
+     *
+     * @param relationIds 关联关系id列表
+     * @param projectId   项目id
+     * @param groupCode   集团code
+     * @return 列表数据
+     */
     List<ObjectNode> loadRelationsById(List<String> relationIds, String projectId, String groupCode);
 
     /**
@@ -96,4 +232,11 @@ public interface DataStrategy {
      * @return
      */
     boolean updateState(String state, String id);
+
+    /**
+     * 获取系统实例下是否有系统图
+     *
+     * @return 例如: {"系统图实例id1":true,"系统图实例id2":false}
+     */
+    Map<String, Boolean> querySystemInstanceDiagramList();
 }

+ 26 - 4
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/impl/DataStrategyImpl.java

@@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -261,7 +262,8 @@ public class DataStrategyImpl implements DataStrategy {
      */
     @Override
     public List<Diagram> getDiagrams(String projectId, String systemId, String groupCode) {
-        List<DiagramEntity> diagrams = diagramMapper.getDiagrams(null, projectId, systemId, groupCode, null);
+        List<DiagramEntity> diagrams = diagramMapper.getDiagrams(null, projectId,
+                systemId, groupCode, null, true);
         if (CollectionUtil.isNotEmpty(diagrams)) {
             return diagrams.stream().map(diagramEntity ->
                     modelAdapter.toDiagram(diagramEntity)).collect(Collectors.toList());
@@ -281,7 +283,7 @@ public class DataStrategyImpl implements DataStrategy {
      */
     @Override
     public List<Diagram> getDiagrams(String diagramType, String projectId,
-                                     String systemId, String groupCode, String name) {
+                                     String systemId, String groupCode, String name,Boolean flag) {
 
         Set<DiagramEntity> result = new HashSet<>();
         //所有系统实例
@@ -303,7 +305,7 @@ public class DataStrategyImpl implements DataStrategy {
         }
         //直接去系统图表根据名称模糊查询查出来的数据
         List<DiagramEntity> diagrams = diagramMapper.getDiagrams(diagramType,
-                projectId, systemId, groupCode, name);
+                projectId, systemId, groupCode, name, flag);
         //合并
         result.addAll(diagrams);
 
@@ -338,7 +340,7 @@ public class DataStrategyImpl implements DataStrategy {
             }
         }
         diagram.setId(IdUtil.simpleUUID());
-        diagram.setExtraProp("state","Draft");
+        diagram.setExtraProp("state", "Draft");
         diagramMapper.saveDiagram(modelAdapter.toDiagramEntity(diagram));
         return diagram;
     }
@@ -665,4 +667,24 @@ public class DataStrategyImpl implements DataStrategy {
         diagramMapper.updateById(entity);
         return true;
     }
+
+    /**
+     * 获取系统实例下是否有系统图
+     *
+     * @return 例如: {"系统图实例id1":true,"系统图实例id2":false}
+     */
+    @Override
+    public Map<String, Boolean> querySystemInstanceDiagramList() {
+        BdtpRequest req = BdtpRequest.getCurrent();
+        String groupCode = req.getGroupCode();
+        String projectId = req.getProjectId();
+        HashMap<String, Boolean> result = new HashMap<>();
+        List<DiagramEntity> diagrams = diagramMapper.getDiagrams(null, projectId,
+                null, groupCode, null, false);
+        if (CollectionUtil.isNotEmpty(diagrams)) {
+            diagrams.stream().collect(Collectors.groupingBy(DiagramEntity::getSystemId))
+                    .forEach((s, diagramEntities) -> result.put(s, CollectionUtil.isNotEmpty(diagramEntities)));
+        }
+        return result;
+    }
 }

+ 293 - 273
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/core/model/Diagram.java

@@ -10,285 +10,305 @@ import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
 import com.persagy.adm.diagram.core.model.template.MainPipe;
 import com.persagy.dmp.common.lang.PsDateTime;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 系统图
+ *
  * @author zhaoyk
  */
 public class Diagram {
 
-	@Expose(serialize = false)
-	private String id;
-
-	/**
-	 * 系统图名称
-	 */
-	@Expose(serialize = false)
-	private String name;
-
-	/**
-	 * 描述信息
-	 */
-	@Expose(serialize = false)
-	private String remark;
-
-	/**
-	 * 系统图类型编码
-	 */
-	@Expose(serialize = false)
-	private String type;
-
-	/**
-	 * 引用的模板id
-	 */
-	@Expose(serialize = false)
-	private String templateId;
-
-	/**
-	 * 所属的系统类型
-	 */
-	@Expose(serialize = false)
-	private String system;
-
-	/**
-	 * 项目id
-	 */
-	@Expose(serialize = false)
-	private String projectId;
-
-	/**
-	 * 对应的系统实例id
-	 */
-	@Expose(serialize = false)
-	private String systemId;
-
-	/**
-	 * 集团编码
-	 */
-	@Expose(serialize = false)
-	private String groupCode;
-
-	/**
-	 * 其他字段信息
-	 */
-	@Expose(serialize = false)
-	private Map<String, Object> extraProps;
-
-	/**
-	 * 节点列表
-	 */
-	@Expose
-	private List<DiagramNode> nodes = new ArrayList<>();
-
-	/**
-	 * 连线列表
-	 */
-	@Expose
-	private List<Line> lines = new ArrayList();
-
-	private PsDateTime createTime;
-	//运行时
-	private DiagramTemplate template;
-
-
-	public void init(){
-		if (template != null) {
-			template.init();
-		}
-
-		nodes.sort(new Comparator<DiagramNode>() {
-			@Override
-			public int compare(DiagramNode o1, DiagramNode o2) {
-				return o1.getLayoutIndex() - o2.getLayoutIndex();
-			}
-		});
-		for (DiagramNode node : nodes) {
-			Container con = template.getContainerById(node.getContainerId());
-			if (con != null) {
-				con.addComp(node);
-			}
-		}
-	}
-
-	public void layout(DiagramBuilder builder){
-		this.layout(builder, false);
-	}
-
-	public void layout(DiagramBuilder builder, boolean absoluteLocation){
-		template.layout(new XY(0, 0));
-
-		LineLayoutManager lineLayoutManager = new LineLayoutManager(builder);
-		for(Line line : lines) {
-			line.layout(lineLayoutManager);
-		}
-
-		if(absoluteLocation) {
-			for (DiagramNode node : nodes) {
-				node.setLocation(node.locationToRoot());
-				if(node instanceof EquipmentNode) {
-					EquipmentNode en = (EquipmentNode) node;
-					if(en.getAnchorLocations() != null) {
-						for(XY point : en.getAnchorLocations().values()){
-							point.x += en.getLocation().x;
-							point.y += en.getLocation().y;
-						}
-					}
-					if(en.getLabel() != null) {
-						XY point = en.getLabel().getLocation();
-						point.x += en.getLocation().x;
-						point.y += en.getLocation().y;
-					}
-				}
-			}
-		}
-	}
-
-	public List<String> getObjIds(){
-		List<String> ids = new ArrayList<>();
-		for(DiagramNode node : nodes) {
-			if(EquipmentNode.TYPE.equals(node.getCompType())) {
-				ids.add(((EquipmentNode) node).getObjId());
-			}
-		}
-		if(template.getMainPipes() != null) {
-			for(MainPipe mainPipe : template.getMainPipes()) {
-				if(mainPipe.isBindEquipment() && StrUtil.isNotBlank(mainPipe.getDataObjectId())) {
-					ids.add(mainPipe.getDataObjectId());
-				}
-			}
-		}
-		return ids;
-	}
-
-	public List<String> getRelIds(){
-		List<String> ids = new ArrayList<>();
-		for(Line line : lines) {
-			if(StrUtil.isNotBlank(line.getDataObjectId())) {
-				ids.add(line.getDataObjectId());
-			}
-		}
-		return ids;
-	}
-
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getRemark() {
-		return remark;
-	}
-
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	public String getTemplateId() {
-		return templateId;
-	}
-
-	public void setTemplateId(String templateId) {
-		this.templateId = templateId;
-	}
-
-	public List<DiagramNode> getNodes() {
-		return nodes;
-	}
-
-	public void setNodes(List<DiagramNode> nodes) {
-		this.nodes = nodes;
-	}
-
-	public List<Line> getLines() {
-		return lines;
-	}
-
-	public void setLines(List<Line> lines) {
-		this.lines = lines;
-	}
-
-	public String getSystem() {
-		return system;
-	}
-
-	public void setSystem(String system) {
-		this.system = system;
-	}
-
-	public String getProjectId() {
-		return projectId;
-	}
-
-	public void setProjectId(String projectId) {
-		this.projectId = projectId;
-	}
-
-	public String getSystemId() {
-		return systemId;
-	}
-
-	public void setSystemId(String systemId) {
-		this.systemId = systemId;
-	}
-
-	public String getGroupCode() {
-		return groupCode;
-	}
-
-	public void setGroupCode(String groupCode) {
-		this.groupCode = groupCode;
-	}
-
-	public Object getExtraProp(String propName) {
-		return extraProps != null ? extraProps.get(propName) : null;
-	}
-
-	public void setExtraProp(String propName, Object propValue) {
-		if(extraProps == null) {
-			extraProps = new HashMap<>();
-		}
-
-		if(propValue != null) {
-			extraProps.put(propName, propValue);
-		} else {
-			extraProps.remove(propName);
-		}
-	}
-
-	public PsDateTime getCreateTime() {
-		return createTime;
-	}
-
-	public void setCreateTime(PsDateTime createTime) {
-		this.createTime = createTime;
-	}
-
-	public DiagramTemplate getTemplate() {
-		return template;
-	}
-
-	public void setTemplate(DiagramTemplate template) {
-		this.template = template;
-	}
+    @Expose(serialize = false)
+    private String id;
+
+    /**
+     * 系统图名称
+     */
+    @Expose(serialize = false)
+    private String name;
+
+    /**
+     * 描述信息
+     */
+    @Expose(serialize = false)
+    private String remark;
+
+    /**
+     * 系统图类型编码
+     */
+    @Expose(serialize = false)
+    private String type;
+
+    /**
+     * 引用的模板id
+     */
+    @Expose(serialize = false)
+    private String templateId;
+
+    /**
+     * 所属的系统类型
+     */
+    @Expose(serialize = false)
+    private String system;
+
+    /**
+     * 项目id
+     */
+    @Expose(serialize = false)
+    private String projectId;
+
+    /**
+     * 对应的系统实例id
+     */
+    @Expose(serialize = false)
+    private String systemId;
+
+    /**
+     * 集团编码
+     */
+    @Expose(serialize = false)
+    private String groupCode;
+
+    /**
+     * 其他字段信息
+     */
+    @Expose(serialize = false)
+    private Map<String, Object> extraProps;
+
+    /**
+     * 节点列表
+     */
+    @Expose
+    private List<DiagramNode> nodes = new ArrayList<>();
+
+    /**
+     * 连线列表
+     */
+    @Expose
+    private List<Line> lines = new ArrayList();
+
+    /**
+     * 系统图创建时间
+     */
+    private PsDateTime createTime;
+    /**
+     * 是否查所有系统图
+     */
+    private Boolean flag;
+    //运行时
+    private DiagramTemplate template;
+
+
+    public void init() {
+        if (template != null) {
+            template.init();
+        }
+
+        nodes.sort(new Comparator<DiagramNode>() {
+            @Override
+            public int compare(DiagramNode o1, DiagramNode o2) {
+                return o1.getLayoutIndex() - o2.getLayoutIndex();
+            }
+        });
+        for (DiagramNode node : nodes) {
+            Container con = template.getContainerById(node.getContainerId());
+            if (con != null) {
+                con.addComp(node);
+            }
+        }
+    }
+
+    public void layout(DiagramBuilder builder) {
+        this.layout(builder, false);
+    }
+
+    public void layout(DiagramBuilder builder, boolean absoluteLocation) {
+        template.layout(new XY(0, 0));
+
+        LineLayoutManager lineLayoutManager = new LineLayoutManager(builder);
+        for (Line line : lines) {
+            line.layout(lineLayoutManager);
+        }
+
+        if (absoluteLocation) {
+            for (DiagramNode node : nodes) {
+                node.setLocation(node.locationToRoot());
+                if (node instanceof EquipmentNode) {
+                    EquipmentNode en = (EquipmentNode) node;
+                    if (en.getAnchorLocations() != null) {
+                        for (XY point : en.getAnchorLocations().values()) {
+                            point.x += en.getLocation().x;
+                            point.y += en.getLocation().y;
+                        }
+                    }
+                    if (en.getLabel() != null) {
+                        XY point = en.getLabel().getLocation();
+                        point.x += en.getLocation().x;
+                        point.y += en.getLocation().y;
+                    }
+                }
+            }
+        }
+    }
+
+    public List<String> getObjIds() {
+        List<String> ids = new ArrayList<>();
+        for (DiagramNode node : nodes) {
+            if (EquipmentNode.TYPE.equals(node.getCompType())) {
+                ids.add(((EquipmentNode) node).getObjId());
+            }
+        }
+        if (template.getMainPipes() != null) {
+            for (MainPipe mainPipe : template.getMainPipes()) {
+                if (mainPipe.isBindEquipment() && StrUtil.isNotBlank(mainPipe.getDataObjectId())) {
+                    ids.add(mainPipe.getDataObjectId());
+                }
+            }
+        }
+        return ids;
+    }
+
+    public List<String> getRelIds() {
+        List<String> ids = new ArrayList<>();
+        for (Line line : lines) {
+            if (StrUtil.isNotBlank(line.getDataObjectId())) {
+                ids.add(line.getDataObjectId());
+            }
+        }
+        return ids;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public List<DiagramNode> getNodes() {
+        return nodes;
+    }
+
+    public void setNodes(List<DiagramNode> nodes) {
+        this.nodes = nodes;
+    }
+
+    public List<Line> getLines() {
+        return lines;
+    }
+
+    public void setLines(List<Line> lines) {
+        this.lines = lines;
+    }
+
+    public String getSystem() {
+        return system;
+    }
+
+    public void setSystem(String system) {
+        this.system = system;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getSystemId() {
+        return systemId;
+    }
+
+    public void setSystemId(String systemId) {
+        this.systemId = systemId;
+    }
+
+    public String getGroupCode() {
+        return groupCode;
+    }
+
+    public void setGroupCode(String groupCode) {
+        this.groupCode = groupCode;
+    }
+
+    public Object getExtraProp(String propName) {
+        return extraProps != null ? extraProps.get(propName) : null;
+    }
+
+    public void setExtraProp(String propName, Object propValue) {
+        if (extraProps == null) {
+            extraProps = new HashMap<>();
+        }
+
+        if (propValue != null) {
+            extraProps.put(propName, propValue);
+        } else {
+            extraProps.remove(propName);
+        }
+    }
+
+    public PsDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(PsDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public Boolean getFlag() {
+        return flag;
+    }
+
+    public void setFlag(Boolean flag) {
+        this.flag = flag;
+    }
+
+    public DiagramTemplate getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(DiagramTemplate template) {
+        this.template = template;
+    }
 
 }

+ 36 - 3
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/dao/DiagramMapper.java

@@ -15,20 +15,53 @@ import java.util.List;
 public interface DiagramMapper extends BaseMapper<DiagramEntity> {
 
 
-    //按系统图类型查询
+    /**
+     * 按系统图类型查询
+     *
+     * @param diagramType 系统图类型
+     * @param projectId   项目id
+     * @param systemId    系统实例id
+     * @param groupCode   集团code
+     * @param name        名称
+     * @param flag        根据标识查出特定数据(true:查出所有数据,false:只查发布状态数据)
+     * @return 系统图列表
+     */
     List<DiagramEntity> getDiagrams(@Param("diagramType") String diagramType,
                                     @Param("projectId") String projectId,
                                     @Param("systemId") String systemId,
                                     @Param("groupCode") String groupCode,
-                                    @Param("name") String name);
+                                    @Param("name") String name,
+                                    @Param("flag") Boolean flag);
 
-    //按系统图类型查询
+    /**
+     * 根据系统实例id进行查询
+     *
+     * @param ids 系统实例id列表
+     * @return 系统图列表
+     */
     List<DiagramEntity> getDiagramsBySystemIds(@Param("systemIds") List<String> ids);
 
+    /**
+     * 系统图保存
+     *
+     * @param diagramEntity 系统图信息
+     */
     void saveDiagram(DiagramEntity diagramEntity);
 
+    /**
+     * 删除系统图
+     *
+     * @param diagramId 系统图id
+     * @return 是否成功
+     */
     boolean deleteByDiagramId(String diagramId);
 
+    /**
+     * 获取系统图信息
+     *
+     * @param diagramId 系统图id
+     * @return 系统图信息
+     */
     DiagramEntity getDiagram(String diagramId);
 
 }

+ 27 - 19
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/demo/DemoDataStrategy.java

@@ -4,12 +4,12 @@ import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.persagy.adm.diagram.entity.DiagramType;
 import com.persagy.adm.diagram.core.ContentParser;
 import com.persagy.adm.diagram.core.DataStrategy;
 import com.persagy.adm.diagram.core.model.Diagram;
 import com.persagy.adm.diagram.core.model.legend.Legend;
 import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
+import com.persagy.adm.diagram.entity.DiagramType;
 import com.persagy.adm.diagram.frame.BdtpRequest;
 import com.persagy.adm.diagram.service.BdtpDataService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +20,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 测试开发使用的io策略实现类
@@ -207,8 +208,8 @@ public class DemoDataStrategy implements DataStrategy {
     public List<Legend> getLegends(String systemCode) {
         File file = new File(DIR_LEGEND, systemCode + ".json");
         if (!file.exists()) {
-			FileUtil.writeUtf8String("[]", file);
-		}
+            FileUtil.writeUtf8String("[]", file);
+        }
 
         Legend[] legends = parser.parseContent(FileUtil.readUtf8String(file), Legend[].class);
         ArrayList<Legend> list = new ArrayList<>();
@@ -264,8 +265,8 @@ public class DemoDataStrategy implements DataStrategy {
         List<Legend> list = getLegends(systemCode);
         for (Legend legend : list) {
             if (legend.getId().equals(legendId)) {
-				return legend;
-			}
+                return legend;
+            }
         }
         return null;
     }
@@ -278,24 +279,26 @@ public class DemoDataStrategy implements DataStrategy {
         List<Legend> list = getLegends(systemCode);
         for (Legend legend : list) {
             if (legend.getEquipmentTypes() != null && legend.getEquipmentTypes().contains(equipmentType)) {
-				rtn.add(legend);
-			}
+                rtn.add(legend);
+            }
         }
 
         return rtn;
     }
 
 
-    /** 系统图部分 */
+    /**
+     * 系统图部分
+     */
     private static final String DIR_DIAGRAM = "store/diagram/";
 
     @Override
     public List<Diagram> getDiagrams(String projectId, String systemId, String groupCode) {
-        return getDiagrams(null, projectId, systemId, groupCode, null);
+        return getDiagrams(null, projectId, systemId, groupCode, null, null);
     }
 
     @Override
-    public List<Diagram> getDiagrams(String diagramType, String projectId, String systemId, String groupCode, String name) {
+    public List<Diagram> getDiagrams(String diagramType, String projectId, String systemId, String groupCode, String name, Boolean flag) {
         ArrayList<Diagram> diagrams = new ArrayList<>();
 
         File dir = new File(DIR_DIAGRAM);
@@ -305,14 +308,14 @@ public class DemoDataStrategy implements DataStrategy {
                 Diagram diagram = parser.parseContent(FileUtil.readUtf8String(f), Diagram.class);
                 if (projectId.equals(diagram.getProjectId())) {
                     if (StrUtil.isNotBlank(groupCode) && !groupCode.equals(diagram.getGroupCode())) {
-						continue;
-					}
+                        continue;
+                    }
                     if (StrUtil.isNotBlank(diagramType) && !diagramType.equals(diagram.getType())) {
-						continue;
-					}
+                        continue;
+                    }
                     if (StrUtil.isNotBlank(systemId) && !systemId.equals(diagram.getSystemId())) {
-						continue;
-					}
+                        continue;
+                    }
 
                     diagrams.add(diagram);
                 }
@@ -351,8 +354,8 @@ public class DemoDataStrategy implements DataStrategy {
     public Diagram getDiagram(String diagramId) {
         File file = new File(DIR_DIAGRAM, diagramId + ".json");
         if (file.exists()) {
-			return parser.parseContent(FileUtil.readUtf8String(file), Diagram.class);
-		}
+            return parser.parseContent(FileUtil.readUtf8String(file), Diagram.class);
+        }
         return null;
     }
 
@@ -406,8 +409,13 @@ public class DemoDataStrategy implements DataStrategy {
         return null;
     }
 
-    // @Override
+    @Override
     public boolean updateState(String state, String id) {
         return false;
     }
+
+    @Override
+    public Map<String, Boolean> querySystemInstanceDiagramList() {
+        return null;
+    }
 }

+ 3 - 0
adm-business/adm-diagram/src/main/resources/mapper/Diagram.xml

@@ -70,6 +70,9 @@
         <if test="null != name and name.length > 0">
             AND name LIKE CONCAT('%',#{name},'%')
         </if>
+        <if test="null != flag and (flag == false) ">
+            AND state = 'Publish'
+        </if>
     </select>
 
     <select id="getDiagramsBySystemIds" resultMap="diagramBaseMap">