소스 검색

新增项目计划进场开始和结束时间

wangliang 1 년 전
부모
커밋
a57eb6296b

+ 14 - 0
sop-api/install/mysql/init/init.sql

@@ -1492,6 +1492,20 @@ CREATE TABLE `t_wxapp_info` (
                                 PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信信息表';
 
+DROP TABLE IF EXISTS `t_b_sop_plan_date_log`;
+CREATE TABLE `t_b_sop_plan_date_log` (
+                                         `id` bigint NOT NULL COMMENT '主键',
+                                         `sop_id` bigint DEFAULT NULL COMMENT 'sopId',
+                                         `flow_id` bigint NOT NULL COMMENT '流程id',
+                                         `begin_time` bigint NOT NULL COMMENT '计划开始时间',
+                                         `end_time` bigint NOT NULL COMMENT '计划结束时间',
+                                         `create_id` bigint DEFAULT NULL COMMENT '创建人id',
+                                         `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                                         `update_id` bigint DEFAULT NULL COMMENT '更新人id',
+                                         `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                                         PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop进程计划时间日志表';
+
 -- ----------------------------
 -- Function structure for currval
 -- ----------------------------

+ 108 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBSopPlanDateLog.java

@@ -0,0 +1,108 @@
+package com.qmth.sop.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * <p>
+ * sop进程计划时间日志表
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-11-20
+ */
+@ApiModel(value = "TBSopPlanDateLog对象", description = "sop进程计划时间日志表")
+public class TBSopPlanDateLog extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "sopId")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long sopId;
+
+    @ApiModelProperty(value = "流程Id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long flowId;
+
+    @ApiModelProperty(value = "计划开始时间")
+    private Long beginTime;
+
+    @ApiModelProperty(value = "计划结束时间")
+    private Long endTime;
+
+    public TBSopPlanDateLog() {
+
+    }
+
+    public TBSopPlanDateLog(Long sopId, Long flowId, Long beginTime, Long endTime, Long userId) {
+        setId(SystemConstant.getDbUuid());
+        this.sopId = sopId;
+        this.flowId = flowId;
+        this.beginTime = beginTime;
+        this.endTime = endTime;
+        setCreateId(userId);
+        setCreateTime(System.currentTimeMillis());
+    }
+
+    public void updateInfo(Long userId) {
+        setId(SystemConstant.getDbUuid());
+        setCreateId(userId);
+        setCreateTime(System.currentTimeMillis());
+    }
+
+    public Long getSopId() {
+        return sopId;
+    }
+
+    public void setSopId(Long sopId) {
+        this.sopId = sopId;
+    }
+
+    public Long getBeginTime() {
+        return beginTime;
+    }
+
+    public void setBeginTime(Long beginTime) {
+        this.beginTime = beginTime;
+    }
+
+    public Long getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Long endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getFlowId() {
+        return flowId;
+    }
+
+    public void setFlowId(Long flowId) {
+        this.flowId = flowId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TBSopPlanDateLog that = (TBSopPlanDateLog) o;
+        return Objects.equals(sopId, that.sopId) && Objects.equals(flowId, that.flowId) && Objects.equals(beginTime, that.beginTime) && Objects.equals(endTime, that.endTime);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(sopId, flowId, beginTime, endTime);
+    }
+}

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopPlanDateLogMapper.java

@@ -0,0 +1,16 @@
+package com.qmth.sop.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.sop.business.entity.TBSopPlanDateLog;
+
+/**
+ * <p>
+ * sop进程计划时间日志表 Mapper 接口
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-11-20
+ */
+public interface TBSopPlanDateLogMapper extends BaseMapper<TBSopPlanDateLog> {
+
+}

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

@@ -131,6 +131,17 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     public void saveJobRemind(Map<String, Object> map) throws InterruptedException;
 
+    /**
+     * 更新sop计划进场开始时间和结束时间
+     *
+     * @param flowTaskResult
+     * @param sopId
+     * @param flowId
+     * @param userId
+     * @throws InterruptedException
+     */
+    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId) throws InterruptedException;
+
     /**
      * sop保存设备信息
      *

+ 16 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBSopPlanDateLogService.java

@@ -0,0 +1,16 @@
+package com.qmth.sop.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.entity.TBSopPlanDateLog;
+
+/**
+ * <p>
+ * sop进程计划时间日志表 服务类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-11-20
+ */
+public interface TBSopPlanDateLogService extends IService<TBSopPlanDateLog> {
+
+}

+ 44 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -94,6 +94,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Resource
     TBServiceService tbServiceService;
 
+    @Resource
+    TBSopPlanDateLogService tbSopPlanDateLogService;
+
     /**
      * 查询动态sop表名是否存在
      *
@@ -329,6 +332,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
         if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
             map.put(SystemConstant.CRM_INFO, crmProjectResult);
+            map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
             tbSopInfoService.saveJobRemind(map);
         }
         TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
@@ -743,6 +747,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
         if (approve != FlowApprovePassEnum.DRAFT) {
             map.put(SystemConstant.CRM_INFO, crmProjectResult);
+            map.put(SystemConstant.SOP_ID, null);
             tbSopInfoService.saveJobRemind(map);
         }
 
@@ -756,6 +761,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             tbSopInfoDetail.setSopInfoId(tbSopInfo.getId());
         }
         tbSopInfoDetailService.save(tbSopInfoDetail);
+        TBSopPlanDateLog tbSopPlanDateLog = tbSopPlanDateLogService.getOne(new QueryWrapper<TBSopPlanDateLog>().lambda().eq(TBSopPlanDateLog::getFlowId, tfCustomFlowEntity.getFlowId()).orderByDesc(TBSopPlanDateLog::getCreateTime).last(" limit 1 "));
+        if (Objects.nonNull(tbSopPlanDateLog)) {
+            tbSopPlanDateLog.setSopId(tbSopInfo.getId());
+            tbSopPlanDateLogService.updateById(tbSopPlanDateLog);
+        }
 
         tfCustomFlowEntity.setObjId(tbSopInfo.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
@@ -784,6 +794,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         TFFlowLog tfFlowLog = (TFFlowLog) map.get(SystemConstant.FLOW_APPROVE_LOG);
         Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
 
+        Long sopId = (Long) map.get(SystemConstant.SOP_ID);
         List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
         if (!CollectionUtils.isEmpty(taskList) && (tfFlowApprove.getStatus() != FlowStatusEnum.DRAFT && tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END)) {
             Long processLimitedTime = null;
@@ -793,6 +804,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey());
                     execField = ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey();
+                    tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(), sysUser.getId());
                 } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
                     processLimitedTime = tfFlowApprove.getUpdateTime();
                     execField = ProcessLimitedEnum.APPROVE_RADIO.getKey();
@@ -823,6 +835,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                     FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
                     processLimitedTime = this.getProcessLimitedTime(flowTaskResult, ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey());
                     execField = ProcessLimitedEnum.PROJECT_KEY_INFO_DATE.getKey();
+                    tbSopInfoService.saveSopPlanDate(flowTaskResult, sopId, tfCustomFlowEntity.getFlowId(), sysUser.getId());
                 } else if (tfFlowApprove.getSetup().intValue() == 3) {//内审
                     processLimitedTime = tfFlowApprove.getUpdateTime();
                     execField = ProcessLimitedEnum.APPROVE_RADIO.getKey();
@@ -1009,7 +1022,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             map.put(SystemConstant.FLOW_APPROVE, tfFlowApprove);
             map.put(SystemConstant.FLOW_APPROVE_LOG, tfFlowLog);
             map.put(SystemConstant.CRM_INFO, crmProjectResult);
-
+            map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
             tbSopInfoService.saveJobRemind(map);
         }
 
@@ -1095,6 +1108,36 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return processLimitedTime;
     }
 
+    /**
+     * 更新sop计划进场开始时间和结束时间
+     *
+     * @param flowTaskResult
+     * @param sopId
+     * @param flowId
+     * @param userId
+     */
+    @Override
+    @Transactional
+    public void saveSopPlanDate(FlowTaskResult flowTaskResult, Long sopId, Long flowId, Long userId) {
+        Long serviceFinishPlanBeginDate = this.getProcessLimitedTime(flowTaskResult, ProcessLimitedEnum.SERVICE_FINISH_PLAN_BEGIN_DATE.getKey());
+        Long serviceFinishPlanEndDate = this.getProcessLimitedTime(flowTaskResult, ProcessLimitedEnum.SERVICE_FINISH_PLAN_DATE.getKey());
+        serviceFinishPlanBeginDate = serviceFinishPlanBeginDate + 1000;
+        TBSopPlanDateLog tbSopPlanDateLog = tbSopPlanDateLogService.getOne(new QueryWrapper<TBSopPlanDateLog>().lambda().eq(TBSopPlanDateLog::getFlowId, flowId).orderByDesc(TBSopPlanDateLog::getCreateTime).last(" limit 1 "));
+        if (Objects.isNull(tbSopPlanDateLog)) {
+            tbSopPlanDateLog = new TBSopPlanDateLog(sopId, flowId, serviceFinishPlanBeginDate, serviceFinishPlanEndDate, userId);
+            tbSopPlanDateLogService.save(tbSopPlanDateLog);
+        } else {
+            TBSopPlanDateLog tbSopPlanDateLogNew = new TBSopPlanDateLog();
+            BeanUtils.copyProperties(tbSopPlanDateLog, tbSopPlanDateLogNew);
+            tbSopPlanDateLogNew.setBeginTime(serviceFinishPlanBeginDate);
+            tbSopPlanDateLogNew.setEndTime(serviceFinishPlanEndDate);
+            if (!tbSopPlanDateLogNew.equals(tbSopPlanDateLog)) {
+                tbSopPlanDateLogNew.updateInfo(userId);
+                tbSopPlanDateLogService.save(tbSopPlanDateLogNew);
+            }
+        }
+    }
+
     /**
      * 根据crmNo查询在途的sop信息
      *

+ 20 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopPlanDateLogServiceImpl.java

@@ -0,0 +1,20 @@
+package com.qmth.sop.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.entity.TBSopPlanDateLog;
+import com.qmth.sop.business.mapper.TBSopPlanDateLogMapper;
+import com.qmth.sop.business.service.TBSopPlanDateLogService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * sop进程计划时间日志表 服务实现类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2023-11-20
+ */
+@Service
+public class TBSopPlanDateLogServiceImpl extends ServiceImpl<TBSopPlanDateLogMapper, TBSopPlanDateLog> implements TBSopPlanDateLogService {
+
+}

+ 15 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -2149,4 +2149,18 @@ SET code='TEXT', `type`='TABLE', form_id='school_job', form_name='school_job', t
 WHERE id=115;
 UPDATE t_d_form_widget
 SET code='TEXT', `type`='TABLE', form_id='school_tel', form_name='school_tel', title='项目联系人表格_电话输入框', input_type='STRING', required=1, readable=0, writable=1, visable=1, `scale`=NULL, `length`=NULL, binding=NULL, data_grid=NULL, tips=NULL, format=NULL, span=3, sub_title=NULL, `options`=NULL, flow_type='CLOUD_MARK_SOP_FLOW', form_setup=1, handle=0, form_group=NULL, role_type=NULL, create_id=1, create_time=26
-WHERE id=116;
+WHERE id=116;
+
+DROP TABLE IF EXISTS `t_b_sop_plan_date_log`;
+CREATE TABLE `t_b_sop_plan_date_log` (
+                                         `id` bigint NOT NULL COMMENT '主键',
+                                         `sop_id` bigint DEFAULT NULL COMMENT 'sopId',
+                                         `flow_id` bigint NOT NULL COMMENT '流程id',
+                                         `begin_time` bigint NOT NULL COMMENT '计划开始时间',
+                                         `end_time` bigint NOT NULL COMMENT '计划结束时间',
+                                         `create_id` bigint DEFAULT NULL COMMENT '创建人id',
+                                         `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                                         `update_id` bigint DEFAULT NULL COMMENT '更新人id',
+                                         `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                                         PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop进程计划时间日志表';

+ 5 - 0
sop-business/src/main/resources/mapper/TBSopPlanDateLogMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qmth.sop.business.mapper.TBSopPlanDateLogMapper">
+
+</mapper>

+ 1 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -326,6 +326,7 @@ public class SystemConstant {
     public static final String FLOW_ENTITY = "tfCustomFlowEntity";
     public static final String FLOW_SYS_USER = "sysUser";
     public static final String CRM_INFO = "crmInfo";
+    public static final String SOP_ID = "sopId";
 
     /**
      * 锁