Selaa lähdekoodia

新增sop表单处理时限

wangliang 1 vuosi sitten
vanhempi
commit
84bf769ae8

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

@@ -718,6 +718,9 @@ public class ActivitiServiceImpl implements ActivitiService {
      */
     @Override
     public FlowViewResult flowView(Long flowId, String code) {
+        if (Objects.isNull(flowId) && Objects.isNull(code)) {
+            throw ExceptionResultEnum.ERROR.exception("流程id和流程编码必须有一个不能为空");
+        }
         TFCustomFlowEntity tfCustomFlowEntity = null;
         if (Objects.nonNull(flowId)) {
             tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));

+ 45 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopSaveParam.java

@@ -0,0 +1,45 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: sop保存param
+ * @Param:
+ * @return:
+ * @Author: wngliang
+ * @Date: 2023/9/4
+ */
+public class SopSaveParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("sopId")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "sopId不能为空")
+    private Long id;
+
+    @ApiModelProperty(value = "流程表单数据")
+    @NotEmpty(message = "流程表单数据不能为空")
+    private String formProperties;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getFormProperties() {
+        return formProperties;
+    }
+
+    public void setFormProperties(String formProperties) {
+        this.formProperties = formProperties;
+    }
+}

+ 2 - 1
sop-business/src/main/java/com/qmth/sop/business/entity/TSJobRemind.java

@@ -97,7 +97,7 @@ public class TSJobRemind implements Serializable {
     }
 
 
-    public TSJobRemind(JobQuartzTypeEnum type, String code, Long objId, String objName, JobTypeEnum remindType, Long receiveUserId, FlowApproveOperationEnum approveOperation, Long createTime, Long userId) {
+    public TSJobRemind(JobQuartzTypeEnum type, String code, Long objId, String objName, JobTypeEnum remindType, Long receiveUserId, FlowApproveOperationEnum approveOperation, Long createTime, String execField, Long userId) {
         this.id = SystemConstant.getDbUuid();
         this.type = type;
         this.code = code;
@@ -108,6 +108,7 @@ public class TSJobRemind implements Serializable {
         this.approveOperation = approveOperation;
         this.createId = userId;
         this.createTime = createTime;
+        this.execField = execField;
         this.enable = true;
     }
 

+ 18 - 4
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -2,10 +2,8 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.params.FlowApproveParam;
-import com.qmth.sop.business.bean.params.SopApplyParam;
-import com.qmth.sop.business.bean.params.SopInfoListParam;
-import com.qmth.sop.business.bean.params.SopPublishParam;
+import com.qmth.sop.business.bean.params.*;
+import com.qmth.sop.business.bean.result.FlowResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.entity.*;
 import com.qmth.sop.common.enums.FlowApprovePassEnum;
@@ -123,4 +121,20 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @param map
      */
     public void saveJobRemind(Map<String, Object> map);
+
+    /**
+     * sop编辑
+     *
+     * @param id
+     * @return
+     */
+    public FlowResult sopEdit(Long id);
+
+    /**
+     * sop保存
+     *
+     * @param sopSaveParam
+     * @return
+     */
+    public Boolean sopSave(SopSaveParam sopSaveParam);
 }

+ 50 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -64,9 +64,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Resource
     TFCustomFlowService tfCustomFlowService;
 
-    @Resource
-    TFFlowApproveService tfFlowApproveService;
-
     @Resource
     TSJobRemindService tsJobRemindService;
 
@@ -521,41 +518,48 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).singleResult();
         if (Objects.nonNull(task) && (tfFlowApprove.getStatus() != FlowStatusEnum.DRAFT && tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END)) {
             Long processLimitedTime = null;
+            String execField = null;
             if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
                 if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.PROJECT_KEY_INFO_DATE);
+                    execField = SystemConstant.PROJECT_KEY_INFO_DATE;
                 } else if (tfFlowApprove.getSetup().intValue() == 3 || tfFlowApprove.getSetup().intValue() == 4) {//大区经理内审或工程师内审
                     processLimitedTime = tfFlowApprove.getUpdateTime();
                 } else if (tfFlowApprove.getSetup().intValue() == 6) {//扫描准备
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_START_TIME);
+                    execField = SystemConstant.SCAN_START_TIME;
                 } else if (tfFlowApprove.getSetup().intValue() == 8) {//校验收尾
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_END_TIME);
+                    execField = SystemConstant.SCAN_END_TIME;
                 } else if (tfFlowApprove.getSetup().intValue() == 9) {//评卷准备
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.MARK_START_TIME);
+                    execField = SystemConstant.MARK_START_TIME;
                 } else if (tfFlowApprove.getSetup().intValue() == 10) {//评卷收尾
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.MARK_END_TIME);
+                    execField = SystemConstant.MARK_END_TIME;
                 } else if (tfFlowApprove.getSetup().intValue() == 11) {//设备入库登记
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SERVICE_FINISH_PLAN_DATE);
+                    execField = SystemConstant.SERVICE_FINISH_PLAN_DATE;
                 }
             } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
 
             }
             List<TSJobRemind> tsJobRemindList = new ArrayList<>();
             if (Objects.nonNull(task.getAssignee())) {
-                tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
-                tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
+                tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, execField, sysUser.getId()));
+                tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, execField, sysUser.getId()));
             } else {
                 List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                 if (!CollectionUtils.isEmpty(identityLinkList)) {
                     for (IdentityLink i : identityLinkList) {
-                        tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
-                        tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
+                        tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, execField, sysUser.getId()));
+                        tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, execField, sysUser.getId()));
                     }
                 }
             }
@@ -563,6 +567,45 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         }
     }
 
+    /**
+     * sop编辑
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public FlowResult sopEdit(Long id) {
+        Optional.ofNullable(id).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("sopId不能为空"));
+        TBSopInfo tbSopInfo = this.getById(id);
+        Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
+
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getCode, tbSopInfo.getSopNo()));
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        return JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+    }
+
+    /**
+     * sop保存
+     *
+     * @param sopSaveParam
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean sopSave(SopSaveParam sopSaveParam) {
+        TBSopInfo tbSopInfo = this.getById(sopSaveParam.getId());
+        Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
+
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getCode, tbSopInfo.getSopNo()));
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        tfCustomFlowEntity.updateInfo(sysUser.getId());
+        tfCustomFlowEntity.setFlowProcessVar(sopSaveParam.getFormProperties());
+        return tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
+    }
+
     /**
      * 获取表单内容
      *

+ 2 - 2
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -60,8 +60,8 @@
                tbc.exam_end_time as examEndTime,
                tfcfe.create_id as flowCreateId,
                su2.real_name as flowCreateName,
-               tfcfe.create_time as flowCreateTime,
-               tfcfe.update_time as flowUpdateTime,
+               tffa.create_time as flowCreateTime,
+               tffa.update_time as flowUpdateTime,
                tffa.status,
                CASE
                 WHEN tffa.status = 'FINISH' THEN '已完结'

+ 20 - 1
sop-server/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -5,6 +5,7 @@ import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.params.SopApplyParam;
 import com.qmth.sop.business.bean.params.SopInfoListParam;
+import com.qmth.sop.business.bean.params.SopSaveParam;
 import com.qmth.sop.business.entity.TDFormWidgetMetadata;
 import com.qmth.sop.business.service.TBSopInfoService;
 import com.qmth.sop.business.service.TDFormWidgetMetadataService;
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -82,7 +84,7 @@ public class TBSopInfoController {
 
     @ApiOperation(value = "sop列表接口")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Map.class)})
     public Result list(@Valid @ApiParam(value = "sop列表信息", required = true) @RequestBody SopInfoListParam sopInfoListParam, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
@@ -109,4 +111,21 @@ public class TBSopInfoController {
         }
         return ResultUtil.ok(true);
     }
+
+    @ApiOperation(value = "sop编辑")
+    @RequestMapping(value = "/edit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result edit(@ApiParam(value = "sopId", required = true) @RequestParam Long id) throws InterruptedException {
+        return ResultUtil.ok(tbSopInfoService.sopEdit(id));
+    }
+
+    @ApiOperation(value = "sop保存")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result save(@Valid @ApiParam(value = "sop保存信息", required = true) @RequestBody SopSaveParam sopSaveParam, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbSopInfoService.sopSave(sopSaveParam));
+    }
 }

+ 1 - 1
sop-task/src/main/java/com/qmth/sop/task/job/service/impl/JobServiceImpl.java

@@ -68,7 +68,7 @@ public class JobServiceImpl implements JobService {
                                 SysConfig sysConfigBefore = commonCacheService.addSysConfigCache(SystemConstant.FLOW_JOB_BEFORE_TIME);
                                 Optional.ofNullable(sysConfigBefore).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程提前提醒任务时间未设置"));
                                 Long execTime = SystemConstant.processMiniuteMinus(t.getCreateTime(), Duration.ofMinutes(Long.parseLong(sysConfigBefore.getConfigValue())));
-                                if (Objects.nonNull(execTime) && execTime.longValue() < System.currentTimeMillis()) {
+                                if (Objects.nonNull(execTime) && execTime.longValue() > System.currentTimeMillis()) {
                                     t.setExecTime(execTime);
                                     this.setJobTime(execTime, t.getId().toString(), t, RemindTaskJob.class, JobEnum.REMIND_QUARTZ_JOB_GROUP);
                                     tsJobRemindUpdateList.add(t);