| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONNull; |
| | | import cn.hutool.json.JSONObject;; |
| | | import cn.hutool.json.XML; |
| | | import com.example.client.service.BaseService; |
| | | import com.example.client.utils.UUIDUtil; |
| | | import com.example.server.progressTrack.Dto.*; |
| | |
| | | import com.example.server.utils.TimeUtils; |
| | | import com.mxgraph.util.mxConstants; |
| | | import com.mxgraph.view.mxGraph; |
| | | import com.mxgraph.view.mxStylesheet; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | //状态分为:专业、已启动/进行中(浅灰)、临期(黄色)、已逾期(红色)、已完成(浅绿色)、超期完成(深绿色) |
| | | enum StatusEnum {zy, jxz, lq, yq, zcwc, cqwc} |
| | | |
| | | String[] fillColorArr = {"#e5e5e5", "#A9A9A9", "yellow", "#FF0000", "#90EE90", "#006400"}; |
| | | String[] fontColorArr = {"#e5e5e5", "#A9A9A9", "yellow", "#FF0000", "#90EE90", "#006400"}; |
| | | String[] fillColorArr = {"#e5e5e5", "#3498DB", "#F1C40F", "#E74C3C", "#2ECC71", "#006400"}; |
| | | String[] fontColorArr = {"#e5e5e5", "#3498DB", "#F1C40F", "#E74C3C", "#2ECC71", "#006400"}; |
| | | |
| | | InitParamDto initParamDto = new InitParamDto(); |
| | | ResultDataDto resultDataDto = new ResultDataDto(); |
| | |
| | | ) { |
| | | JSONObject jsonObject = dialgramJsonArray.getJSONObject(i); |
| | | String shape = jsonObject.get("shape").toString(); |
| | | StatusEnum status = StatusEnum.jxz;//StatusEnum.wqd; |
| | | StatusEnum status = StatusEnum.jxz; |
| | | if (shape.equals("custom-text")) { |
| | | JsonUtils2.setJsonValueByPath(jsonObject, "attrs/body/fill".split("/"), fillColorArr[StatusEnum.zy.ordinal()]); |
| | | JsonUtils2.setJsonValueByPath(jsonObject, "attrs/text/fill".split("/"), fontColorArr[StatusEnum.zy.ordinal()]); |
| | |
| | | JSONObject jsonObject = modelJsonArray.getJSONObject(i); |
| | | if (jsonObject.get("shape").equals("custom-circle")) { |
| | | Object nodeMarker = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/text".split("/")); |
| | | if ("专业".equals(nodeMarker)) { |
| | | /* if ("专业".equals(nodeMarker)) { |
| | | fillColorArr[StatusEnum.zy.ordinal()] = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/body/fill".split("/")).toString(); |
| | | fontColorArr[StatusEnum.zy.ordinal()] = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/fill".split("/")).toString(); |
| | | } |
| | |
| | | if ("超期完成".equals(nodeMarker)) { |
| | | fillColorArr[StatusEnum.cqwc.ordinal()] = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/body/fill".split("/")).toString(); |
| | | fontColorArr[StatusEnum.cqwc.ordinal()] = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/fill".split("/")).toString(); |
| | | } |
| | | }*/ |
| | | if ("阶段名称".equals(nodeMarker)) { |
| | | networkDiagramPetsDto.getCirclePet().setJson(jsonObject.toString()); |
| | | int width = Convert.toInt(JsonUtils2.getJsonValueByPath(jsonObject, "size/width".split("/")).toString()); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public mxGraph getCsDiagram(mxGraph graph, String json, List<NetworkNodeStatusDto> nodeStatusList, Integer panelWidth, Integer panelHeight) { |
| | | public mxGraph getCsDiagram(mxGraph graph, String json, List<NetworkNodeStatusDto> nodeStatusList, Integer panelWidth, Integer panelHeight, List<DiagramNodeDto> list) { |
| | | if (StringUtils.isBlank(json)) { |
| | | return graph; |
| | | } |
| | | |
| | | Map<Long, StatusEnum> statusMap = new HashMap<>(); |
| | | if (nodeStatusList != null) { |
| | | Date today = new Date(); |
| | |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | String shapeValue = jsonArray.getJSONObject(i).get("shape").toString(); |
| | | String idValue = jsonArray.getJSONObject(i).get("id").toString(); |
| | | StatusEnum status = StatusEnum.jxz;//StatusEnum.wqd; |
| | | StatusEnum status = StatusEnum.jxz; |
| | | if (!shapeValue.equals("edge")) { |
| | | status = statusMap.get(Long.parseLong(idValue)); |
| | | if ("1888761224410202114".equals(idValue)) { |
| | | System.out.println(2222); |
| | | } |
| | | Object insertVertex = createInsertVertex(graph, jsonArray.getJSONObject(i), defX, defY, status); |
| | | Object insertVertex = createInsertVertex(graph, jsonArray.getJSONObject(i), defX, defY, status, list); |
| | | map.put(idValue, insertVertex); |
| | | } |
| | | } |
| | |
| | | return graph; |
| | | } |
| | | |
| | | public Object createInsertVertex(mxGraph graph, JSONObject jsonObject, Integer defX, Integer defY, StatusEnum status) { |
| | | public Object createInsertVertex(mxGraph graph, JSONObject jsonObject, Integer defX, Integer defY, StatusEnum status, List<DiagramNodeDto> list) { |
| | | Object parent = graph.getDefaultParent(); |
| | | String shapeValue = jsonObject.get("shape").toString(); |
| | | Object graphObject = null; |
| | |
| | | case "custom-circle": |
| | | case "custom-circle1": |
| | | String text = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/text/text".split("/")); |
| | | //String title = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/title/text".split("/")); |
| | | String title = JsonUtils2.getJsonValueByPath(jsonObject, "attrs/title/text".split("/")) instanceof JSONNull ? null : (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/title/text".split("/")); |
| | | String idValue = jsonObject.get("id").toString(); |
| | | |
| | | Integer x = (Integer) JsonUtils2.getJsonValueByPath(jsonObject, "position/x".split("/")) + defX; |
| | |
| | | Integer height = (Integer) JsonUtils2.getJsonValueByPath(jsonObject, "size/height".split("/")); |
| | | if (status != null) { |
| | | String fontColor = "fontColor=" + fillColorArr[status.ordinal()] + ";"; |
| | | graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height, |
| | | "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE); |
| | | if (list != null && list.size() > 0) { |
| | | for (DiagramNodeDto node : list) { |
| | | if (text.equals(node.getProcessName())){ |
| | | graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height, |
| | | "whiteSpace=wrap;labelWidth=60;" + fontColor ); |
| | | break; |
| | | }else{ |
| | | graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height, |
| | | "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE); |
| | | } |
| | | } |
| | | }else{ |
| | | graphObject = graph.insertVertex(parent, idValue, text, x, y, width, height, |
| | | "whiteSpace=wrap;labelWidth=60;" + fontColor + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE); |
| | | } |
| | | } else { |
| | | if ("开始".equals(text) || "结束".equals(text)) { |
| | | graphObject = graph.insertVertex(parent, idValue, "", x + width / 4, y + height / 4, width / 2, height / 2, |
| | |
| | | "whiteSpace=wrap;labelWidth=60;" + mxConstants.STYLE_SHAPE + "=" + mxConstants.SHAPE_ELLIPSE); |
| | | } |
| | | } |
| | | /*if (StringUtils.isNotBlank(title)) { |
| | | if (StringUtils.isNotBlank(title)) { |
| | | createText(graph, title, x, y, width, height); |
| | | }*/ |
| | | } |
| | | break; |
| | | case "custom-rect": |
| | | String label = (String) JsonUtils2.getJsonValueByPath(jsonObject, "attrs/label/textWrap/text".split("/")); |