|  |  | 
 |  |  | package com.zy.asrs.wcs.asrs.controller; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSON; | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.zy.asrs.framework.common.R; | 
 |  |  | import com.zy.asrs.wcs.asrs.entity.FlowGraph; | 
 |  |  | import com.zy.asrs.wcs.asrs.entity.param.FlowLogicCodeParam; | 
 |  |  | import com.zy.asrs.wcs.asrs.service.FlowGraphService; | 
 |  |  | import com.zy.asrs.wcs.asrs.execute.FlowExecute; | 
 |  |  | import com.zy.asrs.wcs.system.controller.BaseController; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.LinkedHashMap; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | @RestController | 
 |  |  | @RequestMapping("/flow") | 
 |  |  | public class FlowController { | 
 |  |  | @RequestMapping("/api") | 
 |  |  | public class FlowController extends BaseController { | 
 |  |  |  | 
 |  |  |     @PostMapping("/analysisExportData") | 
 |  |  |     @Autowired | 
 |  |  |     private FlowGraphService flowGraphService; | 
 |  |  |     @Autowired | 
 |  |  |     private FlowExecute flowExecute; | 
 |  |  |  | 
 |  |  |     @PostMapping("/flow/analysisExportData") | 
 |  |  |     public R analysisExportData(@RequestBody HashMap<String, Object> param) { | 
 |  |  |         System.out.println(param); | 
 |  |  |         List<LinkedHashMap<String, Object>> data = (List<LinkedHashMap<String, Object>>) param.get("data"); | 
 |  |  |  | 
 |  |  |         ArrayList<FlowLogicCodeParam> list = new ArrayList<>(); | 
 |  |  | 
 |  |  |             Boolean isLogic = Boolean.parseBoolean(mapData.get("isLogic").toString()); | 
 |  |  |             String searchLogicId = mapData.get("searchLogicId").toString(); | 
 |  |  |             Boolean searchLogicBool = Boolean.parseBoolean(mapData.get("searchLogicBool").toString()); | 
 |  |  |             String codeContent = mapData.get("codeContent").toString(); | 
 |  |  |             String codeContent = mapData.get("codeContent") == null ? "" : mapData.get("codeContent").toString(); | 
 |  |  |             if (isLogic) { | 
 |  |  |                 FlowLogicCodeParam flowLogicCodeParam = new FlowLogicCodeParam(); | 
 |  |  |                 flowLogicCodeParam.setId(id); | 
 |  |  | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         System.out.println(list); | 
 |  |  |         FlowGraph flowGraph = new FlowGraph(); | 
 |  |  |         if (param.get("id") != null) { | 
 |  |  |             flowGraph.setId(Integer.parseInt(param.get("id").toString())); | 
 |  |  |         }else { | 
 |  |  |             flowGraph.setCreateTime(new Date()); | 
 |  |  |             flowGraph.setStatus(0); | 
 |  |  |         } | 
 |  |  |         flowGraph.setName(param.get("name").toString()); | 
 |  |  |         flowGraph.setMemo(param.get("memo") == null ? "" : param.get("memo").toString()); | 
 |  |  |         flowGraph.setOriginData(param.get("originData").toString()); | 
 |  |  |         flowGraph.setProcessData(JSON.toJSONString(param.get("data"))); | 
 |  |  |         flowGraph.setUpdateTime(new Date()); | 
 |  |  |         flowGraphService.saveOrUpdate(flowGraph); | 
 |  |  |  | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/flow/mockRun") | 
 |  |  |     public R mockRun(@RequestBody HashMap<String, Object> param) { | 
 |  |  |         FlowGraph flowGraph = flowGraphService.getById(param.get("id").toString()); | 
 |  |  |         if (flowGraph == null) { | 
 |  |  |             return R.error("流程图不存在"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //开始模拟执行 | 
 |  |  |         String processData = flowGraph.getProcessData(); | 
 |  |  | //        List<FlowLogicCodeParam> list = JSON.parseArray(processData, FlowLogicCodeParam.class); | 
 |  |  |         List<JSONObject> list = JSON.parseArray(processData, JSONObject.class); | 
 |  |  |         boolean execute = flowExecute.execute(list); | 
 |  |  |         return R.ok().add(execute); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |