Browse Source

新增自定义流程属性

wangliang 3 years ago
parent
commit
5608623904

+ 124 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowSaveDto.java

@@ -0,0 +1,124 @@
+package com.qmth.distributed.print.business.bean.flow;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @Description: 自定义流程save dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/1/21
+ */
+public class CustomFlowSaveDto implements Serializable {
+
+    @ApiModelProperty(value = "id")
+    @NotBlank(message = "流程名称")
+    String name;
+
+    @ApiModelProperty(value = "流程类型")
+    @NotNull(message = "流程类型不能为空")
+    TFCustomTypeEnum type;
+
+    @ApiModelProperty(value = "流程节点内容")
+    List<CustomFlowDto> customFlowLists;
+
+    @ApiModelProperty(value = "是否发布,0:否,1:是")
+    Boolean publish;
+
+    @ApiModelProperty(value = "学校id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long schoolId;
+
+    @ApiModelProperty(value = "机构id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long orgId;
+
+    public void setSchoolAndOrgInfo(Long schoolId, Long orgId) {
+        this.schoolId = schoolId;
+        this.orgId = orgId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public TFCustomTypeEnum getType() {
+        return type;
+    }
+
+    public void setType(TFCustomTypeEnum type) {
+        this.type = type;
+    }
+
+    public List<CustomFlowDto> getCustomFlowLists() {
+        return customFlowLists;
+    }
+
+    public void setCustomFlowLists(List<CustomFlowDto> customFlowLists) {
+        this.customFlowLists = customFlowLists;
+    }
+
+    public Boolean getPublish() {
+        return publish;
+    }
+
+    public void setPublish(Boolean publish) {
+        this.publish = publish;
+    }
+
+    public Long getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        CustomFlowSaveDto that = (CustomFlowSaveDto) o;
+        return name.equals(that.name) && type == that.type && schoolId.equals(that.schoolId) && orgId.equals(that.orgId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(name, type, schoolId, orgId);
+    }
+
+    @Override
+    public String toString() {
+        return "CustomFlowSaveDto{" +
+                "name='" + name + '\'' +
+                ", type=" + type +
+                ", schoolId=" + schoolId +
+                ", orgId=" + orgId +
+                '}';
+    }
+}

+ 4 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFCustomFlow.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -36,7 +37,7 @@ public class TFCustomFlow extends BaseEntity implements Serializable {
     private String name;
     private String name;
 
 
     @ApiModelProperty(value = "流程类型,ELECTRON_FLOW:电子交卷审核,QUESTION_ELECTRON_FLOW:题库试题提交审核,PAPER_ELECTRON_FLOW:题库试卷审核")
     @ApiModelProperty(value = "流程类型,ELECTRON_FLOW:电子交卷审核,QUESTION_ELECTRON_FLOW:题库试题提交审核,PAPER_ELECTRON_FLOW:题库试卷审核")
-    private String type;
+    private TFCustomTypeEnum type;
 
 
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     @ApiModelProperty(value = "是否启用,0:停用,1:启用")
     private Boolean enable;
     private Boolean enable;
@@ -81,11 +82,11 @@ public class TFCustomFlow extends BaseEntity implements Serializable {
         this.name = name;
         this.name = name;
     }
     }
 
 
-    public String getType() {
+    public TFCustomTypeEnum getType() {
         return type;
         return type;
     }
     }
 
 
-    public void setType(String type) {
+    public void setType(TFCustomTypeEnum type) {
         this.type = type;
         this.type = type;
     }
     }
 
 

+ 55 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/CustomFlowDynamicBuildEnum.java

@@ -0,0 +1,55 @@
+package com.qmth.distributed.print.business.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 流程动态创建 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/10/22
+ */
+public enum CustomFlowDynamicBuildEnum {
+
+    START("start", "开始节点"),
+
+    USER_TASK("usertask", "任务节点"),
+
+    GATE_WAY("exclusivegateway", "网关"),
+
+    SEQUENCE("flow", "箭头"),
+
+    END("end", "结束节点");
+
+    private String id;
+
+    private String title;
+
+    private CustomFlowDynamicBuildEnum(String id, String title) {
+        this.id = id;
+        this.title = title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (CustomFlowDynamicBuildEnum e : CustomFlowDynamicBuildEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 51 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/CustomFlowElementEnum.java

@@ -0,0 +1,51 @@
+package com.qmth.distributed.print.business.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 流程元素 enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/10/22
+ */
+public enum CustomFlowElementEnum {
+
+    APPROVE("approve", "审批"),
+
+    REJECT("reject", "驳回"),
+
+    END("end", "终止");
+
+    private String id;
+
+    private String title;
+
+    private CustomFlowElementEnum(String id, String title) {
+        this.id = id;
+        this.title = title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (CustomFlowElementEnum e : CustomFlowElementEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 44 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/TFCustomTypeEnum.java

@@ -0,0 +1,44 @@
+package com.qmth.distributed.print.business.enums;
+
+import java.util.Objects;
+
+/**
+ * @Description: 自定义流程类型enum
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/1/24
+ */
+public enum TFCustomTypeEnum {
+
+    ELECTRON_FLOW("电子交卷审核"),
+
+    QUESTION_ELECTRON_FLOW("题库试题提交审核"),
+
+    PAPER_ELECTRON_FLOW("题库试卷审核");
+
+    private String title;
+
+    private TFCustomTypeEnum(String title) {
+        this.title = title;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 状态转换 toName
+     *
+     * @param title
+     * @return
+     */
+    public static String convertToName(String title) {
+        for (TFCustomTypeEnum e : TFCustomTypeEnum.values()) {
+            if (Objects.equals(title, e.getTitle())) {
+                return e.name();
+            }
+        }
+        return null;
+    }
+}

+ 10 - 7
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -4,10 +4,9 @@ package com.qmth.distributed.print.api;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.distributed.print.business.bean.flow.CustomFlowDto;
-import com.qmth.teachcloud.common.util.JacksonUtil;
-import com.qmth.teachcloud.common.util.Result;
-import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.util.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponse;
@@ -22,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.validation.Valid;
 import javax.validation.Valid;
-import java.util.List;
+import java.security.NoSuchAlgorithmException;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -43,11 +42,15 @@ public class TFCustomFlowController {
     @ApiOperation(value = "保存和发布流程")
     @ApiOperation(value = "保存和发布流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @RequestMapping(value = "/save", method = RequestMethod.POST)
-    public Result save(@Valid @RequestBody List<CustomFlowDto> customFlowDtoList, BindingResult bindingResult) {
+    public Result save(@Valid @RequestBody CustomFlowSaveDto customFlowSaveDto, BindingResult bindingResult) throws NoSuchAlgorithmException {
         if (bindingResult.hasErrors()) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         }
-        log.info("customFlowDtoList:{}", JacksonUtil.parseJson(customFlowDtoList));
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        customFlowSaveDto.setSchoolAndOrgInfo(sysUser.getSchoolId(), sysUser.getOrgId());
+        log.info("customFlowSaveDto:{}", JacksonUtil.parseJson(customFlowSaveDto));
+        log.info("customFlowSaveDto.toString:{}", customFlowSaveDto.toString());
+        log.info("md5加密后得到id:{}", MD5Util.encoder(customFlowSaveDto.toString()));
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
 }
 }