|
@@ -1,6 +1,9 @@
|
|
|
package org.hswebframework.web.workflow.flowable.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
|
|
+import org.hswebframework.utils.ClassUtils;
|
|
|
+import org.hswebframework.utils.StringUtils;
|
|
|
import org.hswebframework.web.controller.message.ResponseMessage;
|
|
|
import org.hswebframework.web.entity.workflow.ActDefEntity;
|
|
|
import org.hswebframework.web.service.workflow.ActDefService;
|
|
@@ -8,10 +11,13 @@ import org.hswebframework.web.workflow.flowable.service.BpmActivityService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import static org.hswebframework.web.commons.entity.param.QueryParamEntity.single;
|
|
|
+
|
|
|
/**
|
|
|
* @Author wangwei
|
|
|
* @Date 2017/9/4.
|
|
@@ -26,23 +32,52 @@ public class FlowableUtilsController {
|
|
|
@Autowired
|
|
|
ActDefService actDefService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取流程所有配置节点
|
|
|
+ * @param procDefId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@GetMapping("{procDefId}/acts")
|
|
|
- public ResponseMessage<Map<String, Object>> acts(@PathVariable String procDefId) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+ public ResponseMessage<List<Map<String, Object>>> acts(@PathVariable String procDefId) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
List<ActivityImpl> activities = bpmActivityService.getActivitiesById(procDefId, null);
|
|
|
for (ActivityImpl activity : activities) {
|
|
|
- if (activity.getProperty("type").equals("userTask")) map.put(activity.getId(), activity.getProperty("name"));
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ if(activity.getProperty("type").equals("startEvent")){
|
|
|
+ map.put("id", activity.getId());
|
|
|
+ map.put("name", "流程发起者");
|
|
|
+ map.put("info", actDefService.selectSingle(single(ActDefEntity.actId, activity.getId())));
|
|
|
+ }else if (activity.getProperty("type").equals("userTask")){
|
|
|
+ map.put("id", activity.getId());
|
|
|
+ map.put("name", activity.getProperty("name").toString());
|
|
|
+ map.put("info", actDefService.selectSingle(single(ActDefEntity.actId, activity.getId())));
|
|
|
+ }
|
|
|
+ if(map.size()>0) list.add(map);
|
|
|
}
|
|
|
- return ResponseMessage.ok(map);
|
|
|
+ return ResponseMessage.ok(list);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("act/{actId}-{defId}")
|
|
|
- public ResponseMessage<Map<String, Object>> setActClaimDef(@PathVariable String actId, @PathVariable String defId){
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- ActDefEntity actDefEntity = actDefService.createEntity();
|
|
|
- actDefEntity.setActId(actId);
|
|
|
- actDefEntity.setDefId(defId);
|
|
|
- actDefService.insert(actDefEntity);
|
|
|
- return ResponseMessage.ok(map);
|
|
|
+ /**
|
|
|
+ * 给流程节点配置表单与人员矩阵
|
|
|
+ * @param entity
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("act/{entity}")
|
|
|
+ public ResponseMessage<String> setActClaimDef(@PathVariable String entity){
|
|
|
+ try{
|
|
|
+ List<Map> list = JSON.parseArray(entity,Map.class);
|
|
|
+ for(Map map : list){
|
|
|
+ ActDefEntity actDefEntity = actDefService.selectSingle(single(ActDefEntity.actId,map.get("act_id").toString()));
|
|
|
+ if(actDefEntity==null) actDefEntity = actDefService.createEntity();
|
|
|
+ actDefEntity.setActId(map.get("act_id").toString());
|
|
|
+ actDefEntity.setFormId(map.get("form_id").toString());
|
|
|
+ actDefEntity.setDefId(map.get("def_id").toString());
|
|
|
+ actDefService.saveOrUpdate(actDefEntity);
|
|
|
+ }
|
|
|
+ return ResponseMessage.ok("保存成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return ResponseMessage.ok("保存失败");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|