| | |
| | | |
| | | @GetMapping("getDiagram") |
| | | @ApiOperation("信息") |
| | | public Result<ModelRbd> getDiagram(){ |
| | | ModelRbd data = modelLineService.getDiagram(); |
| | | public Result<ModelRbd> getDiagram(Long modelId){ |
| | | ModelRbd data = modelLineService.getDiagram(modelId); |
| | | |
| | | return Result.ok(data); |
| | | } |
| | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PostMapping("analyze") |
| | | @ApiOperation("新增") |
| | | @LogOperation("新增") |
| | | public Result analyze(@RequestBody ModelRbd modelRbd){ |
| | | modelLineService.analyze(modelRbd); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zt.life.modules.taskReliability.dao; |
| | | |
| | | import com.zt.common.dao.BaseDao; |
| | | import com.zt.life.modules.taskReliability.model.Algorithm; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | |
| | | /** |
| | | * model_line |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-02-28 |
| | | */ |
| | | @Mapper |
| | | public interface AlgorithmDao extends BaseDao<Algorithm> { |
| | | |
| | | void deleteByModelId(Long modelId); |
| | | } |
| | |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import com.alibaba.excel.util.DateUtils; |
| | | import com.spire.pdf.tables.table.convert.Convert; |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.common.utils.JsonUtils2; |
| | | import com.zt.common.utils.UUIDUtil; |
| | | import com.zt.life.modules.taskReliability.dao.AlgorithmDao; |
| | | import com.zt.life.modules.taskReliability.dao.ModelLineDao; |
| | | import com.zt.life.modules.taskReliability.dao.ModelNodeDao; |
| | | import com.zt.life.modules.taskReliability.dao.ModelRbdDao; |
| | |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private ModelNodeDao modelNodeDao; |
| | | @Autowired |
| | | private ModelRbdDao modelRbdDao; |
| | | @Autowired |
| | | private AlgorithmDao algorithmDao; |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | return baseDao.getList(queryFilter.getQueryParams()); |
| | | } |
| | | |
| | | public ModelRbd getDiagram() { |
| | | return modelRbdDao.getDiagram(1L); |
| | | public ModelRbd getDiagram(Long modelId) { |
| | | return modelRbdDao.getDiagram(modelId); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // 删除既有数据 |
| | | modelRbdDao.deleteByModelId(modelId); |
| | | modelNodeDao.deleteByModelId(modelId); |
| | | modelLineDao.deleteByModelId(modelId); |
| | | |
| | | // 插入数据 |
| | | modelRbd.setId(UUIDUtil.generateId()); |
| | | modelRbdDao.insert(modelRbd); |
| | | analyzeRbdAndSave(modelId, modelRbd.getContent()); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | // 删除既有数据 |
| | | modelRbdDao.deleteByModelId(modelId); |
| | | modelNodeDao.deleteByModelId(modelId); |
| | | modelLineDao.deleteByModelId(modelId); |
| | | |
| | | // 插入数据 |
| | | modelRbd.setId(UUIDUtil.generateId()); |
| | | modelRbdDao.insert(modelRbd); |
| | | analyzeRbdAndSave(modelId, modelRbd.getContent()); |
| | | } |
| | | |
| | | public void analyzeRbdAndSave(Long modelId, String content) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void analyze(ModelRbd modelRbd) { |
| | | if (modelRbd==null) return; |
| | | if (modelRbd.getModelId()==null) return; |
| | | Long modelId = modelRbd.getModelId(); |
| | | |
| | | analyzeRbdAndSave(modelId, modelRbd.getContent(), true); |
| | | } |
| | | |
| | | public void analyzeRbdAndSave(Long modelId, String content, boolean saveFlag) { |
| | | String diagramJsonStr = content; |
| | | // String diagramJsonStr = "{\"cells\":[{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"26d1a5a6-0be8-4890-86a0-a33d429e6673\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"f2286e46-84c7-4702-8670-d7cda22c34e5\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"2ab8b7f8-7fe2-490f-89c5-4250d4a62a78\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"700c05a5-f151-4b28-8135-705ccf013522\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"feef2a57-3c72-4d69-92a6-c828c736b61a\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"port\":\"80d3bd61-1ed3-493a-b4e8-d4576e6fbfda\"},\"target\":{\"cell\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"49e36d6f-6a94-4edc-9894-6dd825091706\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"ed8c1bfa-c0a6-4e9b-8697-862aef109bcf\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"port\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},\"target\":{\"cell\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"70c6b5fb-1b48-4a2f-bacd-be0284134818\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"6a134969-623b-428e-9b0c-436bae2d6608\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#5F95FF\"}},\"id\":\"51de5faf-1766-4dd1-abd0-eec2e867a322\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"port\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}},{\"shape\":\"edge\",\"attrs\":{\"line\":{\"stroke\":\"#A2B1C3\"}},\"id\":\"161f78dc-1f44-4e43-9ced-e39d345aac78\",\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"#5F95FF\"},\"text\":{\"text\":\"\"}},\"position\":{\"distance\":0.5,\"angle\":180,\"options\":{\"keepGradient\":true,\"ensureLegibility\":true}}}],\"zIndex\":0,\"source\":{\"cell\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"port\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},\"target\":{\"cell\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"port\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}},{\"position\":{\"x\":-350,\"y\":-280},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"31585e99-58c7-4a98-8824-8000743b364d\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":1,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-350,\"y\":-180},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"5123ad82-18bb-46fe-9d93-138b24b54a15\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":2,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-620,\"y\":-200},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"start\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/start.88f586e1.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"f91765b1-af48-4396-84ba-eb16e3476aa5\",\"data\":{\"dataId\":\"\",\"nodeType\":\"start\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"2ad6a8d5-d86d-49e6-908a-d317b61997c1\"},{\"group\":\"right\",\"id\":\"839cb2d9-59ca-4a39-a63c-26bf60cc6989\"},{\"group\":\"bottom\",\"id\":\"7048578f-94d9-4f75-b653-eb5f43ff55db\"},{\"group\":\"left\",\"id\":\"e7bb1134-4b4c-401d-89ea-e77ae24cbd03\"}]},\"zIndex\":3,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":-153,\"y\":-240},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"switchRight\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/switchRight.74768797.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"6df9adc8-cb83-405c-8482-633db0f3644f\",\"data\":{\"dataId\":\"\",\"nodeType\":\"switchRight\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"adceedb7-f842-4d1e-be3a-8b3cb0a7e3ce\"},{\"group\":\"right\",\"id\":\"80d3bd61-1ed3-493a-b4e8-d4576e6fbfda\"},{\"group\":\"bottom\",\"id\":\"8fa84779-80b2-4c91-8366-7dd4fa0d93ff\"},{\"group\":\"left\",\"id\":\"f93ccd2f-dedd-47b1-9ad0-9be20c5db8a4\"}]},\"zIndex\":4},{\"position\":{\"x\":-21,\"y\":-240},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"da634b2e-5ffc-4e1b-a636-f86ace9eb082\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":5,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]},{\"position\":{\"x\":170,\"y\":-100},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"end\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/end.814a7041.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"0bb2ba89-a92d-4b32-b3cd-45df2300fa34\",\"data\":{\"dataId\":\"\",\"nodeType\":\"end\",\"nodeTypeExt\":\"\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"223c9b3a-6baa-4bb8-99ba-c3300db9a942\"},{\"group\":\"right\",\"id\":\"2806bc8a-4e11-4657-9af9-089907985671\"},{\"group\":\"bottom\",\"id\":\"c56eed35-95fa-4e3c-adba-9847ef705e1c\"},{\"group\":\"left\",\"id\":\"61eaafd2-095b-41d6-8e34-862fb470b7a6\"}]},\"zIndex\":6},{\"position\":{\"x\":-350,\"y\":-54},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"2b6df966-4e19-4055-bb13-c4c083b18e58\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":7},{\"position\":{\"x\":-330,\"y\":40},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"323f5abe-05ed-419d-9d81-d25c7d3b19f3\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":8},{\"position\":{\"x\":-153,\"y\":-20},\"size\":{\"width\":60,\"height\":60},\"attrs\":{\"text\":{\"refY\":\"100%\",\"textVerticalAnchor\":\"top\",\"text\":\"logo\",\"style\":{\"color\":\"#080808\"},\"refY2\":4},\"image\":{\"xlink:href\":\"dist/img/logo.36cbc06d.png\"},\"body\":{\"stroke\":\"#5F95FF\"},\"line\":{\"stroke\":\"orange\"}},\"visible\":true,\"shape\":\"image\",\"id\":\"1f378f5e-066d-49bb-a6cc-de24a8882d65\",\"data\":{\"dataId\":\"123456\",\"nodeType\":\"node\",\"nodeTypeExt\":\"aaa\"},\"ports\":{\"groups\":{\"top\":{\"position\":\"top\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"right\":{\"position\":\"right\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"bottom\":{\"position\":\"bottom\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}},\"left\":{\"position\":\"left\",\"attrs\":{\"circle\":{\"r\":4,\"magnet\":true,\"stroke\":\"#5F95FF\",\"strokeWidth\":1,\"fill\":\"#fff\",\"style\":{\"visibility\":\"hidden\"}}}}},\"items\":[{\"group\":\"top\",\"id\":\"bc0336ec-7912-4720-aea7-e5869de77692\"},{\"group\":\"right\",\"id\":\"a977d555-b8c8-4578-9a8b-3097c405c1a8\"},{\"group\":\"bottom\",\"id\":\"fef0f533-9581-4831-ba65-427f097a3d17\"},{\"group\":\"left\",\"id\":\"01eb49d9-4b1c-466f-8263-935542436c7e\"}]},\"zIndex\":9,\"labels\":[{\"attrs\":{\"body\":{\"stroke\":\"orange\"}}}]}]}"; |
| | | |
| | | JSONObject diagramJson = new JSONObject(diagramJsonStr); |
| | | JSONArray diagramJsonArray = diagramJson.getJSONArray("cells"); |
| | | if (diagramJsonArray == null) return; |
| | | |
| | | List<ModelLine> modelLineList = new ArrayList<>(); |
| | | List<ModelNode> modelNodeList = new ArrayList<>(); |
| | | |
| | | if (diagramJsonArray != null) { |
| | | // 1. 解析出节点与边 |
| | | for (int i = 0; i < diagramJsonArray.size(); i++) { |
| | | JSONObject jsonObject = diagramJsonArray.getJSONObject(i); |
| | | String shape = jsonObject.get("shape").toString(); |
| | |
| | | modelLine.setModelId(modelId); |
| | | modelLine.setBeginCell(JsonUtils2.getJsonValueByPath(jsonObject, "source/cell".split("/")).toString()); |
| | | modelLine.setEndCell(JsonUtils2.getJsonValueByPath(jsonObject, "target/cell".split("/")).toString()); |
| | | //modelLineDao.insert(modelLine); |
| | | modelLineList.add(modelLine); |
| | | } else if (shape.equals("image")){ |
| | | ModelNode modelNode = new ModelNode(); |
| | |
| | | modelNode.setNodeTypeExt(JsonUtils2.getJsonValueByPath(jsonObject, "data/nodeTypeExt".split("/")).toString()); |
| | | } |
| | | modelNodeList.add(modelNode); |
| | | //modelNodeDao.insert(modelNode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (ModelLine line : modelLineList) { |
| | | String beginCell = line.getBeginCell(); |
| | | String endCell = line.getEndCell(); |
| | | List<ModelNode> modelNodeList2 = modelNodeList.stream().filter(item->item.getPicId().equals(beginCell)).collect(Collectors.toList()); |
| | | // if (modelNodeList2.size()>0){ |
| | | // line.setBeginNode(modelNodeList2.get(0).getDataId()); |
| | | // } |
| | | List<ModelNode> modelNodeList3 = modelNodeList.stream().filter(item->item.getPicId().equals(endCell)).collect(Collectors.toList()); |
| | | // if (modelNodeList3.size()>0){ |
| | | // line.setEndNode(modelNodeList3.get(0).getDataId()); |
| | | // } |
| | | } |
| | | |
| | | // 2. 对于有多根入口线的产品节点,将其上的表决、旁联、并联关系剥离成运算符节点,添加到该产品节点的前面,并添加相应的边 |
| | | List<ModelNode> nodesToAdd = new ArrayList<>(); |
| | | List<ModelLine> linesToAdd = new ArrayList<>(); |
| | | for (ModelNode modelNode : modelNodeList) { |
| | | String picId = modelNode.getPicId(); |
| | | List<ModelLine> lineList = modelLineList.stream().filter(item->item.getEndCell().equals(picId)).collect(Collectors.toList()); |
| | | if (lineList.size()>1){ |
| | | if ("node".contains(modelNode.getNodeType())){ |
| | | String nodeTypeExt = modelNode.getNodeTypeExt(); |
| | | if ("node,end".contains(modelNode.getNodeType())){ |
| | | String nodeTypeExt = ""; |
| | | if ("node".equals(modelNode.getNodeType())) { |
| | | nodeTypeExt = modelNode.getNodeTypeExt(); |
| | | } else if ("end".equals(modelNode.getNodeType())) { |
| | | nodeTypeExt = "parallel"; |
| | | } |
| | | if (StringUtils.isNotBlank(nodeTypeExt)){ |
| | | ModelNode modelNodeNew = new ModelNode(); |
| | | Long dataId = UUIDUtil.generateId(); |
| | | modelNodeNew.setId(dataId); |
| | | modelNodeNew.setPicId(dataId.toString()); |
| | | Long nodeNewId = UUIDUtil.generateId(); |
| | | modelNodeNew.setId(nodeNewId); |
| | | modelNodeNew.setPicId(nodeNewId.toString()); |
| | | modelNodeNew.setModelId(modelId); |
| | | modelNodeNew.setNodeType(nodeTypeExt); |
| | | modelNodeList.add(modelNode); |
| | | nodesToAdd.add(modelNodeNew); |
| | | |
| | | ModelLine modelLineNew = new ModelLine(); |
| | | Long picId2 = UUIDUtil.generateId(); |
| | | modelLineNew.setId(picId2); |
| | | modelLineNew.setPicId(picId2.toString()); |
| | | Long lineNewId = UUIDUtil.generateId(); |
| | | modelLineNew.setId(lineNewId); |
| | | modelLineNew.setPicId(lineNewId.toString()); |
| | | modelLineNew.setModelId(modelId); |
| | | modelLineNew.setBeginCell(dataId.toString()); |
| | | modelLineNew.setBeginCell(nodeNewId.toString()); |
| | | modelLineNew.setEndCell(modelNode.getPicId()); |
| | | // modelLineNew.setBeginNode(null); |
| | | // modelLineNew.setEndNode(modelNode.getDataId()); |
| | | modelLineList.add(modelLineNew); |
| | | linesToAdd.add(modelLineNew); |
| | | |
| | | for(ModelLine nodelLine: lineList){ |
| | | nodelLine.setEndCell(dataId.toString()); |
| | | //nodelLine.setEndNode(dataId); |
| | | nodelLine.setEndCell(nodeNewId.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | modelNodeList.addAll(nodesToAdd); |
| | | modelLineList.addAll(linesToAdd); |
| | | |
| | | // 3. 将最基本的串、并、旁联、表决替换为虚节点,不断简化图形,直至无法简化为止 |
| | | List<Algorithm> algoList = new ArrayList<>(); |
| | | boolean hasLeastOne = false; |
| | | int stepNo = 0; |
| | | while (true) { |
| | | List<ModelNode> modelNodeList3 = modelNodeList.stream().filter(item -> "parallelRight, switchRight, voteRight, end".contains(item.getNodeType())).collect(Collectors.toList()); |
| | | do { |
| | | List<ModelNode> opNodeList = modelNodeList.stream().filter(item -> |
| | | "parallel,switch,vote,end".contains(item.getNodeType())).collect(Collectors.toList()); |
| | | if (opNodeList.size() <= 0) break; |
| | | |
| | | if (modelNodeList3.size() > 0) { |
| | | hasLeastOne = false; |
| | | for (ModelNode modelNode:modelNodeList3) { |
| | | hasLeastOne = false; // 至少能简化1个图形 |
| | | for (ModelNode opNode: opNodeList) { |
| | | // 右边运算符循环 |
| | | List<ModelLine> lineList3 = modelLineList.stream().filter(item -> item.getEndCell().equals(modelNode.getPicId())).collect(Collectors.toList()); |
| | | List<ModelLine> lineToOpNodeList = modelLineList.stream().filter(item -> |
| | | item.getEndCell().equals(opNode.getPicId())).collect(Collectors.toList()); |
| | | List<List<ModelNode>> listPath = new ArrayList<>(); |
| | | Long lastNode = null; |
| | | ModelNode lastNode = null; |
| | | boolean thisNodeSucc= true; |
| | | for (ModelLine modelLine:lineList3) { |
| | | for (ModelLine modelLine: lineToOpNodeList) { |
| | | // 右边运算符的逐个路径循环 |
| | | List<ModelNode> result = new ArrayList<>(); |
| | | handleOneLine(modelLineList, modelNodeList, modelLine, result); |
| | | Long myId = result.get(result.size()-1).getId(); |
| | | listPath.add(result); |
| | | ModelNode curLastNode = result.get(result.size()-1); |
| | | if (lastNode == null) { |
| | | lastNode = myId; |
| | | lastNode = curLastNode; |
| | | } else { |
| | | if (!lastNode.equals(myId)){ |
| | | if (!lastNode.getId().equals(curLastNode.getId())){ |
| | | thisNodeSucc = false; |
| | | break; |
| | | } |
| | |
| | | } |
| | | if (thisNodeSucc) { |
| | | //形成虚节点算法 |
| | | stepNo = replaceToVNode(modelId, modelNodeList, modelLineList, opNode, listPath, lastNode, algoList, stepNo); |
| | | hasLeastOne = true; |
| | | } |
| | | } // end for |
| | | } while (hasLeastOne); |
| | | |
| | | if (saveFlag) saveModel(modelId, modelNodeList, modelLineList, algoList); |
| | | } |
| | | |
| | | private void handleOneLine(List<ModelLine> modelLineList, |
| | | List<ModelNode> modelNodeList, |
| | | ModelLine modelLine, |
| | | List<ModelNode> result) { |
| | | ModelNode modelNode = modelNodeList.stream().filter(item -> |
| | | item.getPicId().equals(modelLine.getBeginCell())).collect(Collectors.toList()).get(0); |
| | | result.add(modelNode); |
| | | if ("start".equals(modelNode.getNodeType())) { |
| | | return; |
| | | } |
| | | List<ModelLine> lines =modelLineList.stream().filter(item -> |
| | | item.getBeginCell().equals(modelNode.getPicId())).collect(Collectors.toList()); |
| | | List<ModelLine> lines2 =modelLineList.stream().filter(item -> |
| | | item.getEndCell().equals(modelNode.getPicId())).collect(Collectors.toList()); |
| | | if (lines.size()>1 || lines2.size()>1) { |
| | | return; |
| | | } else { |
| | | handleOneLine(modelLineList, modelNodeList, lines2.get(0), result); |
| | | } |
| | | } |
| | | |
| | | private int replaceToVNode(Long modelId, |
| | | List<ModelNode> modelNodeList, |
| | | List<ModelLine> modelLineList, |
| | | ModelNode opNode, |
| | | List<List<ModelNode>> listPath, |
| | | ModelNode lastNode, |
| | | List<Algorithm> algoList, |
| | | int stepNo) { |
| | | String computerList = ""; |
| | | for (List<ModelNode> path : listPath) { |
| | | path.remove(path.get(path.size()-1)); |
| | | Long id = null; |
| | | if (path.size()==0) { |
| | | return stepNo; |
| | | } else if (path.size()==1) { |
| | | id = path.get(path.size()-1).getId(); |
| | | } else { |
| | | id = UUIDUtil.generateId(); |
| | | Algorithm algo = new Algorithm(); |
| | | Long id = UUIDUtil.generateId(); |
| | | computerList = computerList.equals("")?id.toString():computerList+","+id.toString(); |
| | | algo.setId(id); |
| | | algo.setModelId(modelId); |
| | | algo.setComputerId(id); |
| | | algo.setModelType("series"); |
| | | algo.setAlgorithmType("series"); |
| | | algo.setComputerList(StringUtils.join(path.stream().map(ModelNode::getId).collect(Collectors.toSet()), ",")); |
| | | algo.setStep(stepNo); |
| | | stepNo++; |
| | | algo.setComputerList(StringUtils.join(path.stream().map(ModelNode::getId).collect(Collectors.toSet()), ",")); |
| | | |
| | | algoList.add(algo); |
| | | } |
| | | computerList = computerList.equals("") ? id.toString() : computerList + "," + id.toString(); |
| | | for (ModelNode node : path) { |
| | | List<ModelLine> lineList4 = modelLineList.stream().filter(item -> item.getEndCell().equals(node.getPicId()) || item.getBeginCell().equals(node.getPicId())).collect(Collectors.toList()); |
| | | List<ModelLine> lineList4 = modelLineList.stream().filter(item -> |
| | | item.getEndCell().equals(node.getPicId()) || item.getBeginCell().equals(node.getPicId())).collect(Collectors.toList()); |
| | | modelLineList.removeAll(lineList4); |
| | | modelNodeList.remove(node); |
| | | } |
| | |
| | | algo.setId(id); |
| | | algo.setModelId(modelId); |
| | | algo.setComputerId(id); |
| | | algo.setModelType(modelNode.getNodeType()); |
| | | algo.setAlgorithmType(modelNode.getNodeType()); |
| | | algo.setModelType(opNode.getNodeType()); |
| | | algo.setAlgorithmType(opNode.getNodeType()); |
| | | algo.setComputerList(computerList); |
| | | algo.setStep(stepNo); |
| | | stepNo++; |
| | | algo.setComputerList(StringUtils.join(computerList)); |
| | | //形成虚节点 |
| | | algoList.add(algo); |
| | | |
| | | modelNode.setId(id); |
| | | modelNode.setPicId(id.toString()); |
| | | modelNode.setDataId(id); |
| | | modelNode.setNodeType("vNode"); |
| | | //将原运算节点改成虚节点 |
| | | opNode.setId(id); |
| | | // opNode.setPicId(id.toString()); |
| | | opNode.setNodeType("vnode"); |
| | | |
| | | ModelLine modelLineNew = new ModelLine(); |
| | | Long picId2 = UUIDUtil.generateId(); |
| | | modelLineNew.setId(picId2); |
| | | modelLineNew.setPicId(picId2.toString()); |
| | | modelLineNew.setModelId(modelId); |
| | | modelLineNew.setBeginCell(lastNode.toString()); |
| | | modelLineNew.setEndCell(modelNode.getPicId()); |
| | | // modelLineNew.setBeginNode(lastNode); |
| | | // modelLineNew.setEndNode(modelNode.getDataId()); |
| | | modelLineNew.setBeginCell(lastNode.getPicId()); |
| | | modelLineNew.setEndCell(opNode.getPicId()); |
| | | modelLineList.add(modelLineNew); |
| | | } |
| | | } |
| | | if (!hasLeastOne){ |
| | | // 一个都没简化成功 |
| | | break; |
| | | } |
| | | }else{ |
| | | break; |
| | | } |
| | | |
| | | return stepNo; |
| | | } |
| | | |
| | | } |
| | | public void handleOneLine(List<ModelLine> modelLineList, List<ModelNode> modelNodeList, ModelLine modelLine,List<ModelNode> result){ |
| | | ModelNode modelNode =modelNodeList.stream().filter(item->item.getPicId().equals(modelLine.getBeginCell())).collect(Collectors.toList()).get(0); |
| | | List<ModelLine> lines =modelLineList.stream().filter(item->item.getBeginCell().equals(modelNode.getPicId())).collect(Collectors.toList()); |
| | | List<ModelLine> lines2 =modelLineList.stream().filter(item->item.getEndCell().equals(modelNode.getPicId())).collect(Collectors.toList()); |
| | | result.add(modelNode); |
| | | if (lines.size()>1 || lines2.size()>1){ |
| | | return; |
| | | }else{ |
| | | handleOneLine(modelLineList, modelNodeList, lines2.get(0),result); |
| | | } |
| | | private void saveModel(Long modelId, |
| | | List<ModelNode> modelNodeList, |
| | | List<ModelLine> modelLineList, |
| | | List<Algorithm> algoList) { |
| | | // 删除既有数据 |
| | | modelNodeDao.deleteByModelId(modelId); |
| | | modelLineDao.deleteByModelId(modelId); |
| | | algorithmDao.deleteByModelId(modelId); |
| | | |
| | | // 插入数据 |
| | | for (ModelNode modelNode : modelNodeList) { |
| | | modelNodeDao.insert(modelNode); |
| | | } |
| | | for (ModelLine modelLine : modelLineList) { |
| | | modelLineDao.insert(modelLine); |
| | | } |
| | | for (Algorithm algorithm : algoList) { |
| | | algorithmDao.insert(algorithm); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.zt.life.modules.taskReliability.dao.AlgorithmDao"> |
| | | |
| | | <update id="deleteByModelId"> |
| | | delete from algorithm where model_id=#{modelId} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | label: '无' |
| | | }, { |
| | | value: 'parallel', |
| | | label: '旁连' |
| | | label: '并联' |
| | | },{ |
| | | value: 'switch', |
| | | label: '并联' |
| | | label: '旁连' |
| | | }, { |
| | | value: 'vote', |
| | | label: '表决' |
| | |
| | | }, |
| | | methods: { |
| | | drawRBD(modelId) { |
| | | // this.$nextTick(()=>{ |
| | | // this.$refs.RBDEditImg.init() |
| | | // }) |
| | | this.dialogVisible2 = true |
| | | // this.$router.push({path: 'taskReliability-RBD-edit-img', query: {modelId: modelId}}) |
| | | }, |
| | |
| | | <div class="fa-card-a"> |
| | | <el-form :inline="true"> |
| | | <el-form-item> |
| | | modelId |
| | | <el-input placeholder="搜索施工内容" v-model="dataForm.modelId" clearable class="input-with-select"> |
| | | <el-button slot="append" icon="el-icon-search" @click="search()"></el-button> |
| | | </el-input> |
| | | |
| | | <el-button type="primary" @click="saveDiagram()">保存</el-button> |
| | | <!-- <zt-button type="primary" v-show="pageCode === 'wlt_sp' && flowInfo.myStatus ===1" @click="reject()">驳回</zt-button>--> |
| | | <el-button v-show="pageCode === 'wlt_pz' && flowInfo.myStatus ===1" type="warning" @click="finish">完成 |
| | | </el-button> |
| | | <el-button type="primary" @click="analyzeDiagram()">解析</el-button> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-tooltip class="item" effect="dark" content="左对齐" placement="left"> |
| | |
| | | {imgPath:'start',imgName:'start',nodeType:'start',imgWidth:60,imgHeight:60,imgId:'1',data:{}}, |
| | | {imgPath:'end',imgName:'end',nodeType:'end',imgWidth:60,imgHeight:60,imgId:'2',data:{}}, |
| | | // {imgPath:'parallelLeft',imgName:'parallelLeft',nodeType:'parallelLeft',imgWidth:60,imgHeight:60,imgId:'3',data:{}}, |
| | | {imgPath:'parallelRight',imgName:'parallelRight',nodeType:'parallelRight',imgWidth:60,imgHeight:60,imgId:'4',data:{}}, |
| | | {imgPath:'switchRight',imgName:'switchRight',nodeType:'switchRight',imgWidth:60,imgHeight:60,imgId:'5',data:{}}, |
| | | {imgPath:'voteRight',imgName:'voteRight',nodeType:'voteRight',imgWidth:60,imgHeight:60,imgId:'6',data:{}}, |
| | | {imgPath:'parallelRight',imgName:'parallel',nodeType:'parallel',imgWidth:60,imgHeight:60,imgId:'4',data:{}}, |
| | | {imgPath:'switchRight',imgName:'switch',nodeType:'switch',imgWidth:60,imgHeight:60,imgId:'5',data:{}}, |
| | | {imgPath:'voteRight',imgName:'vote',nodeType:'vote',imgWidth:60,imgHeight:60,imgId:'6',data:{}}, |
| | | ], |
| | | imgsList2:[ |
| | | {imgPath:'logo',imgName:'logo',nodeType:'node',imgWidth:60,imgHeight:60,imgId:'100',data:{dataId:'123456',nodeTypeExt:'aaa'}}, |
| | | {imgPath:'logo',imgName:'logo',nodeType:'node',imgWidth:60,imgHeight:60,imgId:'100',data:{dataId:'123456',nodeTypeExt:''}}, |
| | | ], |
| | | nodeType:'', |
| | | first: true, |
| | |
| | | content: null, |
| | | publishContent: null, |
| | | hasPublish: 0, |
| | | modelId: 1, |
| | | modelId: '1', |
| | | }, |
| | | flowInfo: { |
| | | bizId: '', |
| | |
| | | this.getDiagram() |
| | | },*/ |
| | | async getDiagram() { |
| | | let params = {} |
| | | let params = { |
| | | modelId : this.dataForm.modelId |
| | | } |
| | | let res = await this.$http.get(`/taskReliability/ModelLine/getDiagram`, {params: params}) |
| | | if (res.data !== null && res.data.content != null) { |
| | | this.dataForm = res.data |
| | | console.log(this.dataForm, 'this.dataForm in getDiagram') |
| | | this.diagramJson = JSON.parse(this.dataForm.content) |
| | | // console.log(this.dataForm.content,'this.Diagram content') |
| | | console.log(this.diagramJson, 'this.Diagram json') |
| | |
| | | // } |
| | | // return this.curCel; |
| | | // }, |
| | | async search() { |
| | | await this.getDiagram(); |
| | | }, |
| | | async saveDiagram() { |
| | | console.log(JSON.stringify(this.graph.toJSON()), 'graph.toJSON()') |
| | | this.dataForm.content = JSON.stringify(this.graph.toJSON()) |
| | |
| | | } |
| | | }) |
| | | }, |
| | | async analyzeDiagram() { |
| | | console.log(JSON.stringify(this.graph.toJSON()), 'graph.toJSON()') |
| | | this.dataForm.content = JSON.stringify(this.graph.toJSON()) |
| | | console.log(this.dataForm, 'dataFrom') |
| | | await this.$http['post'](`/taskReliability/ModelLine/analyze`, this.dataForm).then(async res => { |
| | | if (res.msg === 'success') { |
| | | this.$alert('解析成功', '提示', { |
| | | confirmButtonText: '确定' |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | // AlignmentsChanges(val){ |
| | | // console.log(val,'align.value') |
| | | // if(val ==='选项1'){ |