Browse Source

项目计划变更加入审批历史

wangliang 1 năm trước cách đây
mục cha
commit
50173a175f

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/FlowResult.java

@@ -32,6 +32,9 @@ public class FlowResult implements Serializable {
     @ApiModelProperty(value = "流程版本")
     private Integer version;
 
+    @ApiModelProperty(value = "crm信息")
+    CrmProjectResult crmInfo;
+
     public FlowResult() {
 
     }
@@ -42,6 +45,14 @@ public class FlowResult implements Serializable {
         this.setupMap = setupMap;
     }
 
+    public CrmProjectResult getCrmInfo() {
+        return crmInfo;
+    }
+
+    public void setCrmInfo(CrmProjectResult crmInfo) {
+        this.crmInfo = crmInfo;
+    }
+
     public Long getId() {
         return id;
     }

+ 18 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBProjectExchangeViewResult.java

@@ -4,6 +4,7 @@ import com.qmth.sop.business.entity.TBProjectExchange;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * @Description: 项目计划变更view result
@@ -20,6 +21,9 @@ public class TBProjectExchangeViewResult implements Serializable {
     @ApiModelProperty(value = "项目变更计划信息")
     TBProjectExchange tbProjectExchange;
 
+    @ApiModelProperty(value = "流程审批信息")
+    List<TFFlowViewLogResult> flowApproveHistoryList;
+
     public TBProjectExchangeViewResult() {
 
     }
@@ -29,6 +33,20 @@ public class TBProjectExchangeViewResult implements Serializable {
         this.tbProjectExchange = tbProjectExchange;
     }
 
+    public TBProjectExchangeViewResult(CrmProjectResult crmInfo, TBProjectExchange tbProjectExchange, List<TFFlowViewLogResult> flowApproveHistoryList) {
+        this.crmInfo = crmInfo;
+        this.tbProjectExchange = tbProjectExchange;
+        this.flowApproveHistoryList = flowApproveHistoryList;
+    }
+
+    public List<TFFlowViewLogResult> getFlowApproveHistoryList() {
+        return flowApproveHistoryList;
+    }
+
+    public void setFlowApproveHistoryList(List<TFFlowViewLogResult> flowApproveHistoryList) {
+        this.flowApproveHistoryList = flowApproveHistoryList;
+    }
+
     public CrmProjectResult getCrmInfo() {
         return crmInfo;
     }

+ 34 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -1,22 +1,24 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.reflect.TypeToken;
 import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.dto.UserDto;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
-import com.qmth.sop.business.bean.result.CrmProjectResult;
-import com.qmth.sop.business.bean.result.ProjectExchangeResult;
-import com.qmth.sop.business.bean.result.TBProjectExchangeViewResult;
+import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBProjectExchange;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
+import com.qmth.sop.business.entity.TFFlowApprove;
 import com.qmth.sop.business.mapper.TBProjectExchangeMapper;
 import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
+import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.task.IdentityLink;
@@ -61,6 +63,12 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Resource
     SysUserService sysUserService;
 
+    @Resource
+    TFFlowLogService tfFlowLogService;
+
+    @Resource
+    TFFlowApproveService tfFlowApproveService;
+
     /**
      * 新增项目变更计划申请
      *
@@ -184,6 +192,28 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tbProjectExchange.getSopNo(), tbProjectExchange.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
-        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange);
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getCode, tbProjectExchange.getExchangeNo()));
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        //获取当前流程节点
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
+        Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
+
+        FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+
+        //获取流程审批历史
+        List<TFFlowViewLogResult> flowApproveHistoryList = null;
+        Map<Integer, Integer> approveSetupMap = new HashMap<>();
+        List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByObjectId(tfCustomFlowEntity.getId());
+        if (!CollectionUtils.isEmpty(tfFlowLogResultList)) {
+            flowApproveHistoryList = GsonUtil.fromJson(GsonUtil.toJson(tfFlowLogResultList), new TypeToken<List<TFFlowViewLogResult>>() {
+            }.getType());
+            for (TFFlowViewLogResult t : flowApproveHistoryList) {
+                t.setMessageType(FlowMsgTypeEnum.STANDARD);
+                approveSetupMap.put(t.getApproveSetup(), t.getApproveSetup());
+            }
+        }
+        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange, flowApproveHistoryList);
     }
 }

+ 5 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -803,6 +803,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             }
         }
         flowResultNew.setSetupMap(setupMapNew);
+
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(), tfCustomFlowEntity.getCrmNo());
+        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
+
+        flowResultNew.setCrmInfo(crmProjectResult);
         return flowResultNew;
     }