Browse Source

新增sop编辑log,延期预警跨节点和流程结束不预警

wangliang 1 year ago
parent
commit
8d52e6007a

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

@@ -4,7 +4,6 @@ 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.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.FlowApproveOperationEnum;
 import com.qmth.sop.common.enums.FlowApproveOperationEnum;
-import com.qmth.sop.common.enums.FlowStatusEnum;
 import com.qmth.sop.common.enums.JobQuartzTypeEnum;
 import com.qmth.sop.common.enums.JobQuartzTypeEnum;
 import com.qmth.sop.common.enums.JobTypeEnum;
 import com.qmth.sop.common.enums.JobTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
@@ -35,12 +34,6 @@ public class TSJobRemind implements Serializable {
     @ApiModelProperty(value = "编码")
     @ApiModelProperty(value = "编码")
     private String code;
     private String code;
 
 
-    @ApiModelProperty(value = "流程步骤")
-    private Integer setup;
-
-    @ApiModelProperty(value = "状态,START:已开始,AUDITING:审核中,REJECT:已驳回,END:已终止,FINISH:已结束")
-    private FlowStatusEnum status;
-
     @ApiModelProperty(value = "实体id")
     @ApiModelProperty(value = "实体id")
     @JsonSerialize(using = ToStringSerializer.class)
     @JsonSerialize(using = ToStringSerializer.class)
     private Long objId;
     private Long objId;
@@ -83,7 +76,7 @@ public class TSJobRemind implements Serializable {
 
 
     public TSJobRemind(JobQuartzTypeEnum type, String code, Long objId, String objName, JobTypeEnum remindType,
     public TSJobRemind(JobQuartzTypeEnum type, String code, Long objId, String objName, JobTypeEnum remindType,
             Long receiveUserId, FlowApproveOperationEnum approveOperation, Long createTime, String execField,
             Long receiveUserId, FlowApproveOperationEnum approveOperation, Long createTime, String execField,
-            Long userId, String crmNo, Integer setup, FlowStatusEnum status) {
+            Long userId, String crmNo) {
         this.id = SystemConstant.getDbUuid();
         this.id = SystemConstant.getDbUuid();
         this.type = type;
         this.type = type;
         this.code = code;
         this.code = code;
@@ -97,24 +90,6 @@ public class TSJobRemind implements Serializable {
         this.execField = execField;
         this.execField = execField;
         this.enable = true;
         this.enable = true;
         this.crmNo = crmNo;
         this.crmNo = crmNo;
-        this.setup = setup;
-        this.status = status;
-    }
-
-    public Integer getSetup() {
-        return setup;
-    }
-
-    public void setSetup(Integer setup) {
-        this.setup = setup;
-    }
-
-    public FlowStatusEnum getStatus() {
-        return status;
-    }
-
-    public void setStatus(FlowStatusEnum status) {
-        this.status = status;
     }
     }
 
 
     public String getCrmNo() {
     public String getCrmNo() {

+ 0 - 8
sop-business/src/main/java/com/qmth/sop/business/mapper/TSJobRemindMapper.java

@@ -35,12 +35,4 @@ public interface TSJobRemindMapper extends BaseMapper<TSJobRemind> {
      * @return
      * @return
      */
      */
     List<WorkTaskResult> getJobRemindProcessHour(@Param("userId") Long userId, @Param("sopNoSet") Set<String> sopNoSet);
     List<WorkTaskResult> getJobRemindProcessHour(@Param("userId") Long userId, @Param("sopNoSet") Set<String> sopNoSet);
-
-    /**
-     * 根据enable查询
-     *
-     * @param enable
-     * @return
-     */
-    List<TSJobRemind> getJobRemindEnable(@Param("enable") Boolean enable);
 }
 }

+ 0 - 7
sop-business/src/main/java/com/qmth/sop/business/service/TSJobRemindService.java

@@ -58,11 +58,4 @@ public interface TSJobRemindService extends IService<TSJobRemind> {
      * @return
      * @return
      */
      */
     List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet);
     List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet);
-
-    /**
-     * 根据enable查询
-     *
-     * @return
-     */
-    List<TSJobRemind> getJobRemindEnable(Boolean enable);
 }
 }

+ 4 - 8
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -1103,13 +1103,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                         tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                         tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                                 Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                 Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                 JobTypeEnum.BEFORE, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(),
                                 JobTypeEnum.BEFORE, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(),
-                                processLimitedTime, execField, sysUser.getId(), tfCustomFlowEntity.getCrmNo(),
-                                tfFlowApprove.getSetup(), tfFlowApprove.getStatus()));
+                                processLimitedTime, execField, sysUser.getId(), tfCustomFlowEntity.getCrmNo()));
                         tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                         tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                                 Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                 Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                 JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(),
                                 JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(),
-                                processLimitedTime, execField, sysUser.getId(), tfCustomFlowEntity.getCrmNo(),
-                                tfFlowApprove.getSetup(), tfFlowApprove.getStatus()));
+                                processLimitedTime, execField, sysUser.getId(), tfCustomFlowEntity.getCrmNo()));
                     } else {
                     } else {
                         List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                         List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                         if (!CollectionUtils.isEmpty(identityLinkList)) {
                         if (!CollectionUtils.isEmpty(identityLinkList)) {
@@ -1120,16 +1118,14 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                                                 tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                                 tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                                 JobTypeEnum.BEFORE, Long.parseLong(i.getUserId()),
                                                 JobTypeEnum.BEFORE, Long.parseLong(i.getUserId()),
                                                 tfFlowLog.getApproveOperation(), processLimitedTime, execField,
                                                 tfFlowLog.getApproveOperation(), processLimitedTime, execField,
-                                                sysUser.getId(), tfCustomFlowEntity.getCrmNo(),
-                                                tfFlowApprove.getSetup(), tfFlowApprove.getStatus()));
+                                                sysUser.getId(), tfCustomFlowEntity.getCrmNo()));
                                 tsJobRemindList.add(
                                 tsJobRemindList.add(
                                         new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                                         new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(),
                                                 Long.parseLong(i.getTaskId()),
                                                 Long.parseLong(i.getTaskId()),
                                                 tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                                 tfCustomFlow.getType().getTitle() + ";" + task.getName(),
                                                 JobTypeEnum.AFTER, Long.parseLong(i.getUserId()),
                                                 JobTypeEnum.AFTER, Long.parseLong(i.getUserId()),
                                                 tfFlowLog.getApproveOperation(), processLimitedTime, execField,
                                                 tfFlowLog.getApproveOperation(), processLimitedTime, execField,
-                                                sysUser.getId(), tfCustomFlowEntity.getCrmNo(),
-                                                tfFlowApprove.getSetup(), tfFlowApprove.getStatus()));
+                                                sysUser.getId(), tfCustomFlowEntity.getCrmNo()));
                             }
                             }
                         }
                         }
                     }
                     }

+ 0 - 11
sop-business/src/main/java/com/qmth/sop/business/service/impl/TSJobRemindServiceImpl.java

@@ -86,15 +86,4 @@ public class TSJobRemindServiceImpl extends ServiceImpl<TSJobRemindMapper, TSJob
     public List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet) {
     public List<WorkTaskResult> getJobRemindProcessHour(Long userId, Set<String> sopNoSet) {
         return this.baseMapper.getJobRemindProcessHour(userId, sopNoSet);
         return this.baseMapper.getJobRemindProcessHour(userId, sopNoSet);
     }
     }
-
-    /**
-     * 根据enable查询
-     *
-     * @param enable
-     * @return
-     */
-    @Override
-    public List<TSJobRemind> getJobRemindEnable(Boolean enable) {
-        return this.baseMapper.getJobRemindEnable(enable);
-    }
 }
 }

+ 13 - 4
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -2480,7 +2480,16 @@ CREATE INDEX t_f_flow_approve_flow_id_IDX USING BTREE ON t_f_flow_approve (flow_
 ALTER TABLE t_f_custom_flow_entity DROP INDEX t_f_custom_flow_entity_UN_code;
 ALTER TABLE t_f_custom_flow_entity DROP INDEX t_f_custom_flow_entity_UN_code;
 CREATE INDEX t_f_custom_flow_entity_code_IDX USING BTREE ON t_f_custom_flow_entity (code);
 CREATE INDEX t_f_custom_flow_entity_code_IDX USING BTREE ON t_f_custom_flow_entity (code);
 
 
-ALTER TABLE t_s_job_remind ADD setup INT NOT NULL COMMENT '计划步骤';
-ALTER TABLE t_s_job_remind CHANGE setup setup INT NOT NULL COMMENT '计划步骤' AFTER code;
-ALTER TABLE t_s_job_remind ADD status varchar(50) NULL COMMENT '状态,START:已开始,AUDITING:审核中,REJECT:已驳回,END:已终止,FINISH:已结束';
-ALTER TABLE t_s_job_remind CHANGE status status varchar(50) NULL COMMENT '状态,START:已开始,AUDITING:审核中,REJECT:已驳回,END:已终止,FINISH:已结束' AFTER setup;
+DROP TABLE IF EXISTS `t_b_sop_log`;
+CREATE TABLE `t_b_sop_log` (
+                               `id` bigint NOT NULL COMMENT '主键',
+                               `sop_id` bigint NOT NULL COMMENT 'sop主键',
+                               `type` varchar(30) CHARACTER SET utf8mb4 DEFAULT NULL COMMENT '类型,APPROVE:sop审核,EDIT:sop编辑,CHANGE_EFFECT_ENGINEER:更改实施工程师,CHANGE_ASSISTANT_ENGINEER:更改助理工程师,ADD_EFFECT_ENGINEER:新增实施工程师,ADD_ASSISTANT_ENGINEER:新增助理工程师,REMOVE_EFFECT_ENGINEER:删除实施工程师,REMOVE_ASSISTANT_ENGINEER:删除助理工程师',
+                               `status` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT '状态,START:已开始,AUDITING:审核中,REJECT:已驳回,END:已终止,FINISH:已结束',
+                               `setup` tinyint NOT NULL COMMENT '计划步骤',
+                               `update_before_obj` mediumtext CHARACTER SET COMMENT '更改前内容',
+                               `update_after_obj` mediumtext CHARACTER SET COMMENT '更改后内容',
+                               `create_id` bigint NOT NULL COMMENT '创建人id',
+                               `create_time` bigint NOT NULL COMMENT '创建时间',
+                               PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop日志';

+ 0 - 4
sop-business/src/main/resources/mapper/TSJobRemindMapper.xml

@@ -50,8 +50,4 @@
             tsjr.code,
             tsjr.code,
             tsjr.exec_time
             tsjr.exec_time
     </select>
     </select>
-
-    <select id="getJobRemindEnable" resultType="com.qmth.sop.business.entity.TSJobRemind">
-        select jsjr.* from t_s_job_remind jsjr left join t_s_job_log tsjl on jsjr.id  = tsjl.job_remind_id where jsjr.enable = #{enable}
-    </select>
 </mapper>
 </mapper>

+ 1 - 2
sop-task/src/main/java/com/qmth/sop/task/job/RemindTaskJob.java

@@ -70,8 +70,7 @@ public class RemindTaskJob extends QuartzJobBean {
                         Optional.ofNullable(tfFlowApprove)
                         Optional.ofNullable(tfFlowApprove)
                                 .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
                                 .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
 
-                        if (tfFlowApprove.getSetup().intValue() > 0 && Objects.nonNull(tsJobRemind.getSetup())
-                                && tsJobRemind.getSetup().intValue() == tfFlowApprove.getSetup().intValue()) {
+                        if (tfFlowApprove.getSetup().intValue() > 0) {
                             FlowTaskSmsResult flowTaskSmsResult = tsJobRemindService.getFlowTaskRemindSmsInfo(
                             FlowTaskSmsResult flowTaskSmsResult = tsJobRemindService.getFlowTaskRemindSmsInfo(
                                     tsJobRemind.getId());
                                     tsJobRemind.getId());
                             Optional.ofNullable(flowTaskSmsResult)
                             Optional.ofNullable(flowTaskSmsResult)

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

@@ -154,7 +154,9 @@ public class JobServiceImpl implements JobService {
             }
             }
         }
         }
 
 
-        List<TSJobRemind> tsJobRemindFalseList = tsJobRemindService.getJobRemindEnable(false);
+        List<TSJobRemind> tsJobRemindFalseList = tsJobRemindService.list(
+                new QueryWrapper<TSJobRemind>().lambda().eq(TSJobRemind::getEnable, false)
+                        .last(" " + sysConfig.getConfigValue() + " "));
         if (!CollectionUtils.isEmpty(tsJobRemindFalseList)) {
         if (!CollectionUtils.isEmpty(tsJobRemindFalseList)) {
             List<Long> tsJobRemindFalseIdList = new ArrayList<>(tsJobRemindFalseList.size());
             List<Long> tsJobRemindFalseIdList = new ArrayList<>(tsJobRemindFalseList.size());
             for (TSJobRemind t : tsJobRemindFalseList) {
             for (TSJobRemind t : tsJobRemindFalseList) {

+ 33 - 31
sop-task/src/main/java/com/qmth/sop/task/listener/MyJobListener.java

@@ -54,41 +54,43 @@ public class MyJobListener implements JobListener {
             try {
             try {
                 JobDataMap map = context.getJobDetail().getJobDataMap();
                 JobDataMap map = context.getJobDetail().getJobDataMap();
                 TSJobRemindService tsJobRemindService = SpringContextHolder.getBean(TSJobRemindService.class);
                 TSJobRemindService tsJobRemindService = SpringContextHolder.getBean(TSJobRemindService.class);
-                TSJobRemind tsJobRemind = (TSJobRemind) map.get(SystemConstant.JOB_DATA);
-                tsJobRemind = tsJobRemindService.getById(tsJobRemind.getId());
-                if (Objects.nonNull(tsJobRemind)) {
-                    tsJobRemind.setEnable(false);
-                    tsJobRemindService.updateById(tsJobRemind);
-                    TSJobLogService tsJobLogService = SpringContextHolder.getBean(TSJobLogService.class);
-                    TSJobLog tsJobLog = new TSJobLog(tsJobRemind);
-                    tsJobLogService.save(tsJobLog);
+                TSJobRemind tsJobRemindTask = (TSJobRemind) map.get(SystemConstant.JOB_DATA);
+                if (Objects.nonNull(tsJobRemindTask)) {
+                    TSJobRemind tsJobRemind = tsJobRemindService.getById(tsJobRemindTask.getId());
+                    if (Objects.nonNull(tsJobRemind)) {//数据还在则说明要发送提醒短信
+                        tsJobRemind.setEnable(false);
+                        tsJobRemindService.updateById(tsJobRemind);
+                        TSJobLogService tsJobLogService = SpringContextHolder.getBean(TSJobLogService.class);
+                        TSJobLog tsJobLog = new TSJobLog(tsJobRemind);
+                        tsJobLogService.save(tsJobLog);
 
 
-                    //往延期预警表插数据
-                    if (tsJobRemind.getType() == JobQuartzTypeEnum.FLOW
-                            && tsJobRemind.getRemindType() == JobTypeEnum.AFTER) {
-                        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(
-                                TFCustomFlowEntityService.class);
-                        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
-                                new QueryWrapper<TFCustomFlowEntity>().lambda()
-                                        .eq(TFCustomFlowEntity::getCode, tsJobRemind.getCode()));
-                        Optional.ofNullable(tfCustomFlowEntity)
-                                .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+                        //往延期预警表插数据
+                        if (tsJobRemind.getType() == JobQuartzTypeEnum.FLOW
+                                && tsJobRemind.getRemindType() == JobTypeEnum.AFTER) {
+                            TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(
+                                    TFCustomFlowEntityService.class);
+                            TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                                    new QueryWrapper<TFCustomFlowEntity>().lambda()
+                                            .eq(TFCustomFlowEntity::getCode, tsJobRemind.getCode()));
+                            Optional.ofNullable(tfCustomFlowEntity)
+                                    .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
 
 
-                        if (tsJobRemind.getCode().contains(SystemConstant.SOP)) {
-                            TBDelayWarnService tbDelayWarnService = SpringContextHolder.getBean(
-                                    TBDelayWarnService.class);
-                            SequenceService sequenceService = SpringContextHolder.getBean(SequenceService.class);
+                            if (tsJobRemind.getCode().contains(SystemConstant.SOP)) {
+                                TBDelayWarnService tbDelayWarnService = SpringContextHolder.getBean(
+                                        TBDelayWarnService.class);
+                                SequenceService sequenceService = SpringContextHolder.getBean(SequenceService.class);
 
 
-                            TBSopInfoService tbSopInfoService = SpringContextHolder.getBean(TBSopInfoService.class);
-                            TBSopInfo tbSopInfo = tbSopInfoService.getById(tfCustomFlowEntity.getObjId());
-                            Optional.ofNullable(tbSopInfo)
-                                    .orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
+                                TBSopInfoService tbSopInfoService = SpringContextHolder.getBean(TBSopInfoService.class);
+                                TBSopInfo tbSopInfo = tbSopInfoService.getById(tfCustomFlowEntity.getObjId());
+                                Optional.ofNullable(tbSopInfo)
+                                        .orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
 
 
-                            String code = DelayWarnSeqTypeEnum.DELAY_WARN.getMark() + sequenceService.createCode(
-                                    DelayWarnSeqTypeEnum.DELAY_WARN.getCode());
-                            tbDelayWarnService.save(new TBDelayWarn(tbSopInfo.getCrmNo(), tbSopInfo.getSopNo(),
-                                    tbSopInfo.getServiceId(), code, tsJobLog.getCreateTime(),
-                                    tsJobRemind.getReceiveUserId(), tsJobRemind.getExecField()));
+                                String code = DelayWarnSeqTypeEnum.DELAY_WARN.getMark() + sequenceService.createCode(
+                                        DelayWarnSeqTypeEnum.DELAY_WARN.getCode());
+                                tbDelayWarnService.save(new TBDelayWarn(tbSopInfo.getCrmNo(), tbSopInfo.getSopNo(),
+                                        tbSopInfo.getServiceId(), code, tsJobLog.getCreateTime(),
+                                        tsJobRemind.getReceiveUserId(), tsJobRemind.getExecField()));
+                            }
                         }
                         }
                     }
                     }
                 }
                 }