Browse Source

新增sop作废

wangliang 1 year ago
parent
commit
80fd0e473d

+ 7 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -619,6 +619,7 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     @Override
     @Transactional
     @Transactional
     public Boolean flowEnd(Long flowId) {
     public Boolean flowEnd(Long flowId) {
+        Optional.ofNullable(flowId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程id不能为空"));
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_END_PREFIX + flowId, flowId, SystemConstant.LOCK_FLOW_TIME_OUT);
         boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_END_PREFIX + flowId, flowId, SystemConstant.LOCK_FLOW_TIME_OUT);
         if (!lock) {
         if (!lock) {
@@ -628,6 +629,12 @@ public class ActivitiServiceImpl implements ActivitiService {
             TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, flowId));
             TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, flowId));
             Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
             Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
 
+            if (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH) {
+                throw ExceptionResultEnum.ERROR.exception("已结束的流程不能终止");
+            } else if (tfFlowApprove.getStatus() == FlowStatusEnum.END) {
+                throw ExceptionResultEnum.ERROR.exception("该流程已终止");
+            }
+
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
             Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
             Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
 
 

+ 0 - 382
sop-business/src/main/java/com/qmth/sop/business/bean/result/SopInfoResult.java

@@ -1,382 +0,0 @@
-//package com.qmth.sop.business.bean.result;
-//
-//import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-//import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-//import com.qmth.sop.common.enums.FlowStatusEnum;
-//import com.qmth.sop.common.enums.ProductTypeEnum;
-//import com.qmth.sop.common.enums.TFCustomTypeEnum;
-//import io.swagger.annotations.ApiModelProperty;
-//
-//import java.io.Serializable;
-//import java.util.Map;
-//import java.util.Objects;
-//
-///**
-// * @Description: appinfo result
-// * @Param:
-// * @return:
-// * @Author: wangliang
-// * @Date: 2023/2/17
-// */
-//public class SopInfoResult implements Serializable {
-//
-//    @ApiModelProperty(value = "sopid")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long id;
-//
-//    @ApiModelProperty(value = "服务单元id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long serviceId;
-//
-//    @ApiModelProperty(value = "服务单元名称")
-//    String serviceName;
-//
-//    @ApiModelProperty(value = "sop单号")
-//    String sopNo;
-//
-//    @ApiModelProperty(value = "crm单号")
-//    String crmNo;
-//
-//    @ApiModelProperty(value = "派单时间")
-//    Long beginTime;
-//
-//    @ApiModelProperty(value = "客户经理id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long customManagerId;
-//
-//    @ApiModelProperty(value = "客户类型,OFFICE:教务处,CLOUD_MARK:研究生")
-//    ProductTypeEnum customManagerType;
-//
-//    @ApiModelProperty(value = "客户类型str")
-//    String customManagerTypeStr;
-//
-//    @ApiModelProperty(value = "客户名称")
-//    String customName;
-//
-//    @ApiModelProperty(value = "crm名称")
-//    String crmName;
-//
-//    @ApiModelProperty(value = "产品id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long productId;
-//
-//    @ApiModelProperty(value = "产品名称")
-//    String productName;
-//
-//    @ApiModelProperty(value = "考试开始时间")
-//    Long examStartTime;
-//
-//    @ApiModelProperty(value = "考试结束时间")
-//    Long examEndTime;
-//
-//    @ApiModelProperty(value = "提交人id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long flowCreateId;
-//
-//    @ApiModelProperty(value = "提交人")
-//    String flowCreateName;
-//
-//    @ApiModelProperty(value = "提交时间")
-//    Long flowCreateTime;
-//
-//    @ApiModelProperty(value = "更新时间")
-//    Long flowUpdateTime;
-//
-//    @ApiModelProperty(value = "流程状态,START:已开始,AUDITING:审核中,REJECT:已驳回,END:已终止,FINISH:已结束")
-//    FlowStatusEnum status;
-//
-//    @ApiModelProperty(value = "流程状态str")
-//    String statusStr;
-//
-//    @ApiModelProperty(value = "流程类型,OFFICE_SOP_FLOW:教务处SOP,CLOUD_MARK_SOP_FLOW:研究生SOP,DING_EXCEPTION_FLOW:考勤异常审核流程,PROJECT_EXCHANGE_FLOW:项目计划变更流程,QUALITY_PROBLEM_FLOW:质量问题反馈流程")
-//    TFCustomTypeEnum type;
-//
-//    @ApiModelProperty(value = "流程类型str")
-//    String typeStr;
-//
-//    @ApiModelProperty(value = "流程版本号")
-//    Integer version;
-//
-//    @ApiModelProperty(value = "流程部署id")
-//    String flowDeploymentId;
-//
-//    @ApiModelProperty(value = "流程id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long flowId;
-//
-//    @ApiModelProperty(value = "流程节点名称")
-//    String taskName;
-//
-//    @ApiModelProperty(value = "流程节点key")
-//    String taskDefKey;
-//
-//    @ApiModelProperty(value = "流程节点id")
-//    @JsonSerialize(using = ToStringSerializer.class)
-//    Long taskId;
-//
-//    @ApiModelProperty(value = "当前节点负责人")
-//    String pendApproveName;
-//
-//    @ApiModelProperty(value = "动态节点")
-//    Map<String, Object> dynamicFieldMap;
-//
-//    public Long getId() {
-//        return id;
-//    }
-//
-//    public void setId(Long id) {
-//        this.id = id;
-//    }
-//
-//    public Long getServiceId() {
-//        return serviceId;
-//    }
-//
-//    public void setServiceId(Long serviceId) {
-//        this.serviceId = serviceId;
-//    }
-//
-//    public String getServiceName() {
-//        return serviceName;
-//    }
-//
-//    public void setServiceName(String serviceName) {
-//        this.serviceName = serviceName;
-//    }
-//
-//    public String getSopNo() {
-//        return sopNo;
-//    }
-//
-//    public void setSopNo(String sopNo) {
-//        this.sopNo = sopNo;
-//    }
-//
-//    public String getCrmNo() {
-//        return crmNo;
-//    }
-//
-//    public void setCrmNo(String crmNo) {
-//        this.crmNo = crmNo;
-//    }
-//
-//    public Long getBeginTime() {
-//        return beginTime;
-//    }
-//
-//    public void setBeginTime(Long beginTime) {
-//        this.beginTime = beginTime;
-//    }
-//
-//    public Long getCustomManagerId() {
-//        return customManagerId;
-//    }
-//
-//    public void setCustomManagerId(Long customManagerId) {
-//        this.customManagerId = customManagerId;
-//    }
-//
-//    public ProductTypeEnum getCustomManagerType() {
-//        return customManagerType;
-//    }
-//
-//    public void setCustomManagerType(ProductTypeEnum customManagerType) {
-//        this.customManagerType = customManagerType;
-//    }
-//
-//    public String getCustomManagerTypeStr() {
-//        if (Objects.nonNull(this.customManagerType)) {
-//            return this.customManagerType.getTitle();
-//        } else {
-//            return customManagerTypeStr;
-//        }
-//    }
-//
-//    public void setCustomManagerTypeStr(String customManagerTypeStr) {
-//        this.customManagerTypeStr = customManagerTypeStr;
-//    }
-//
-//    public String getCustomName() {
-//        return customName;
-//    }
-//
-//    public void setCustomName(String customName) {
-//        this.customName = customName;
-//    }
-//
-//    public String getCrmName() {
-//        return crmName;
-//    }
-//
-//    public void setCrmName(String crmName) {
-//        this.crmName = crmName;
-//    }
-//
-//    public Long getProductId() {
-//        return productId;
-//    }
-//
-//    public void setProductId(Long productId) {
-//        this.productId = productId;
-//    }
-//
-//    public String getProductName() {
-//        return productName;
-//    }
-//
-//    public void setProductName(String productName) {
-//        this.productName = productName;
-//    }
-//
-//    public Long getExamStartTime() {
-//        return examStartTime;
-//    }
-//
-//    public void setExamStartTime(Long examStartTime) {
-//        this.examStartTime = examStartTime;
-//    }
-//
-//    public Long getExamEndTime() {
-//        return examEndTime;
-//    }
-//
-//    public void setExamEndTime(Long examEndTime) {
-//        this.examEndTime = examEndTime;
-//    }
-//
-//    public Long getFlowCreateId() {
-//        return flowCreateId;
-//    }
-//
-//    public void setFlowCreateId(Long flowCreateId) {
-//        this.flowCreateId = flowCreateId;
-//    }
-//
-//    public String getFlowCreateName() {
-//        return flowCreateName;
-//    }
-//
-//    public void setFlowCreateName(String flowCreateName) {
-//        this.flowCreateName = flowCreateName;
-//    }
-//
-//    public Long getFlowCreateTime() {
-//        return flowCreateTime;
-//    }
-//
-//    public void setFlowCreateTime(Long flowCreateTime) {
-//        this.flowCreateTime = flowCreateTime;
-//    }
-//
-//    public Long getFlowUpdateTime() {
-//        return flowUpdateTime;
-//    }
-//
-//    public void setFlowUpdateTime(Long flowUpdateTime) {
-//        this.flowUpdateTime = flowUpdateTime;
-//    }
-//
-//    public FlowStatusEnum getStatus() {
-//        return status;
-//    }
-//
-//    public void setStatus(FlowStatusEnum status) {
-//        this.status = status;
-//    }
-//
-//    public String getStatusStr() {
-//        if (Objects.nonNull(this.status)) {
-//            return this.status.getTitle();
-//        } else {
-//            return statusStr;
-//        }
-//    }
-//
-//    public void setStatusStr(String statusStr) {
-//        this.statusStr = statusStr;
-//    }
-//
-//    public TFCustomTypeEnum getType() {
-//        return type;
-//    }
-//
-//    public void setType(TFCustomTypeEnum type) {
-//        this.type = type;
-//    }
-//
-//    public String getTypeStr() {
-//        if (Objects.nonNull(this.type)) {
-//            return this.type.getTitle();
-//        } else {
-//            return typeStr;
-//        }
-//    }
-//
-//    public void setTypeStr(String typeStr) {
-//        this.typeStr = typeStr;
-//    }
-//
-//    public Integer getVersion() {
-//        return version;
-//    }
-//
-//    public void setVersion(Integer version) {
-//        this.version = version;
-//    }
-//
-//    public String getFlowDeploymentId() {
-//        return flowDeploymentId;
-//    }
-//
-//    public void setFlowDeploymentId(String flowDeploymentId) {
-//        this.flowDeploymentId = flowDeploymentId;
-//    }
-//
-//    public Long getFlowId() {
-//        return flowId;
-//    }
-//
-//    public void setFlowId(Long flowId) {
-//        this.flowId = flowId;
-//    }
-//
-//    public String getTaskName() {
-//        return taskName;
-//    }
-//
-//    public void setTaskName(String taskName) {
-//        this.taskName = taskName;
-//    }
-//
-//    public String getTaskDefKey() {
-//        return taskDefKey;
-//    }
-//
-//    public void setTaskDefKey(String taskDefKey) {
-//        this.taskDefKey = taskDefKey;
-//    }
-//
-//    public Long getTaskId() {
-//        return taskId;
-//    }
-//
-//    public void setTaskId(Long taskId) {
-//        this.taskId = taskId;
-//    }
-//
-//    public String getPendApproveName() {
-//        return pendApproveName;
-//    }
-//
-//    public void setPendApproveName(String pendApproveName) {
-//        this.pendApproveName = pendApproveName;
-//    }
-//
-//    public Map<String, Object> getDynamicFieldMap() {
-//        return dynamicFieldMap;
-//    }
-//
-//    public void setDynamicFieldMap(Map<String, Object> dynamicFieldMap) {
-//        this.dynamicFieldMap = dynamicFieldMap;
-//    }
-//}

+ 21 - 0
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -1083,3 +1083,24 @@ ALTER TABLE t_b_sop_info_detail CHANGE COLUMN region_user_id region_user_id BIGI
 
 
 ALTER TABLE t_b_sop_info_detail CHANGE COLUMN engineer_user_id engineer_user_id BIGINT
 ALTER TABLE t_b_sop_info_detail CHANGE COLUMN engineer_user_id engineer_user_id BIGINT
     COMMENT '实施工程师id' NULL;
     COMMENT '实施工程师id' NULL;
+
+--2023.9.7update
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3045, 'sop作废', '/api/admin/sop/cancel', 'URL', 40, 9, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3046, 'sop批量作废', '/api/admin/sop/batch/cancel', 'URL', 40, 10, 'AUTH', NULL, 1, 1, 0);
+
+UPDATE sys_privilege
+SET name='作废', url='Cancel', `type`='BUTTON', parent_id=41, `sequence`=1, property='AUTH', related='3046', enable=1, default_auth=0, front_display=1
+WHERE id=173;
+UPDATE sys_privilege
+SET name='作废', url='Cancel', `type`='BUTTON', parent_id=42, `sequence`=1, property='AUTH', related='3046', enable=1, default_auth=0, front_display=1
+WHERE id=182;
+UPDATE sys_privilege
+SET name='作废', url='Cancel', `type`='LINK', parent_id=41, `sequence`=7, property='AUTH', related='3045', enable=1, default_auth=0, front_display=1
+WHERE id=3038;
+UPDATE sys_privilege
+SET name='作废', url='Cancel', `type`='LINK', parent_id=42, `sequence`=7, property='AUTH', related='3045', enable=1, default_auth=0, front_display=1
+WHERE id=3040;

+ 26 - 11
sop-server/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -1,18 +1,20 @@
 package com.qmth.sop.server.api;
 package com.qmth.sop.server.api;
 
 
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.SopApplyParam;
 import com.qmth.sop.business.bean.params.SopApplyParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
-import com.qmth.sop.business.bean.params.SopPublishParam;
 import com.qmth.sop.business.entity.TDFormWidgetMetadata;
 import com.qmth.sop.business.entity.TDFormWidgetMetadata;
 import com.qmth.sop.business.service.TBSopInfoService;
 import com.qmth.sop.business.service.TBSopInfoService;
 import com.qmth.sop.business.service.TDFormWidgetMetadataService;
 import com.qmth.sop.business.service.TDFormWidgetMetadataService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.springframework.util.CollectionUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
@@ -40,6 +42,9 @@ public class TBSopInfoController {
     @Resource
     @Resource
     TBSopInfoService tbSopInfoService;
     TBSopInfoService tbSopInfoService;
 
 
+    @Resource
+    ActivitiService activitiService;
+
     @ApiOperation(value = "sop元数据查询")
     @ApiOperation(value = "sop元数据查询")
     @RequestMapping(value = "/metadata/list", method = RequestMethod.POST)
     @RequestMapping(value = "/metadata/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TDFormWidgetMetadata.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TDFormWidgetMetadata.class)})
@@ -55,16 +60,6 @@ public class TBSopInfoController {
         return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
         return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
     }
     }
 
 
-    @ApiOperation(value = "sop发布")
-    @RequestMapping(value = "/publish", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Result publish(@Valid @ApiParam(value = "sop发布信息", required = true) @RequestBody SopPublishParam sopPublishParam, BindingResult bindingResult) throws InterruptedException {
-        if (bindingResult.hasErrors()) {
-            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
-        }
-        return ResultUtil.ok(tbSopInfoService.sopPublish(sopPublishParam));
-    }
-
     @ApiOperation(value = "sop申请")
     @ApiOperation(value = "sop申请")
     @RequestMapping(value = "/apply", method = RequestMethod.POST)
     @RequestMapping(value = "/apply", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
@@ -94,4 +89,24 @@ public class TBSopInfoController {
         }
         }
         return ResultUtil.ok(tbSopInfoService.list(sopInfoListParam));
         return ResultUtil.ok(tbSopInfoService.list(sopInfoListParam));
     }
     }
+
+    @ApiOperation(value = "sop作废")
+    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result cancel(@ApiParam(value = "流程id", required = true) @RequestParam Long flowId) throws InterruptedException {
+        return ResultUtil.ok(activitiService.flowEnd(flowId));
+    }
+
+    @ApiOperation(value = "sop批量作废")
+    @RequestMapping(value = "/batch/cancel", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result batchCancel(@ApiParam(value = "流程id数组", required = true) @RequestBody List<Long> flowIds) throws InterruptedException {
+        if (CollectionUtils.isEmpty(flowIds)) {
+            throw ExceptionResultEnum.ERROR.exception("流程id数组不能为空");
+        }
+        for (Long l : flowIds) {
+            activitiService.flowEnd(l);
+        }
+        return ResultUtil.ok(true);
+    }
 }
 }