wangliang 1 anno fa
parent
commit
78787b3380

+ 11 - 10
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -700,20 +700,20 @@ public class ActivitiServiceImpl implements ActivitiService {
             TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
             Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
 
-//            FlowTaskResult flowTaskResultOne = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 1);
-//            ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(tfCustomFlow.getType(), flowTaskResultOne);
+            //            FlowTaskResult flowTaskResultOne = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 1);
+            //            ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(tfCustomFlow.getType(), flowTaskResultOne);
 
             FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
             LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
             FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(
                     GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
 
-//            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
-//                if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN
-//                        && currFlowTaskResult.getSetup().intValue() > 3) {
-//                    return true;
-//                }
-//            }
+            //            if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
+            //                if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN
+            //                        && currFlowTaskResult.getSetup().intValue() > 3) {
+            //                    return true;
+            //                }
+            //            }
 
             BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
             FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(task.getTaskDefinitionKey());
@@ -742,8 +742,9 @@ public class ActivitiServiceImpl implements ActivitiService {
             //            }
 
             boolean replace = false;
+            String oldUserId = null;
             if (!multiInstance) {
-                String oldUserId = task.getAssignee();
+                oldUserId = task.getAssignee();
                 if (Objects.nonNull(task.getAssignee())) {
                     oldUserId = task.getAssignee();
                 } else {
@@ -772,7 +773,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             if (!replace) {
                 return true;
             }
-            TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getOrgId(), sysUser.getId(), sysUser.getId(),
+            TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getOrgId(), Long.parseLong(oldUserId), sysUser.getId(),
                     currFlowTaskResult.getSetup(), Long.parseLong(task.getProcessInstanceId()),
                     Long.parseLong(task.getId()), tfCustomFlowEntity.getId(), String.valueOf(userId));
             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.EXCHANGE);

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/WorkTaskResult.java

@@ -129,6 +129,18 @@ public class WorkTaskResult implements Serializable {
     @ApiModelProperty(value = "客户类型str")
     private String customTypeStr;
 
+    @ApiModelProperty(value = "派单crmDetailid")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long crmDetailId;
+
+    public Long getCrmDetailId() {
+        return crmDetailId;
+    }
+
+    public void setCrmDetailId(Long crmDetailId) {
+        this.crmDetailId = crmDetailId;
+    }
+
     public ProductTypeEnum getCustomType() {
         return customType;
     }

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFFlowLogMapper.java

@@ -40,4 +40,14 @@ public interface TFFlowLogMapper extends BaseMapper<TFFlowLog> {
      * @return
      */
     String findByLastFlowLogApproveUser(@Param("flowId") Long flowId);
+
+    /**
+     * 根据taskId和approveOperation查询最后一条日志审批记录
+     *
+     * @param taskId
+     * @param approveOperation
+     * @return
+     */
+    TFFlowLog findByLastFlowLogByTaskId(@Param("taskId") Long taskId,
+            @Param("approveOperation") String approveOperation);
 }

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFFlowLogService.java

@@ -3,6 +3,7 @@ package com.qmth.sop.business.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.result.TFFlowLogResult;
 import com.qmth.sop.business.entity.TFFlowLog;
+import com.qmth.sop.common.enums.FlowApproveOperationEnum;
 
 import java.util.List;
 
@@ -39,4 +40,13 @@ public interface TFFlowLogService extends IService<TFFlowLog> {
      * @return
      */
     String findByLastFlowLogApproveUser(Long flowId);
+
+    /**
+     * 根据taskId和approveOperation查询最后一条日志审批记录
+     *
+     * @param taskId
+     * @param approveOperation
+     * @return
+     */
+    TFFlowLog findByLastFlowLogByTaskId(Long taskId, FlowApproveOperationEnum approveOperation);
 }

+ 13 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -1272,13 +1272,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(tfCustomFlow.getType(), flowTaskResult);
             if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
                 List<AllocationParam> allocationParams = new ArrayList<>();
+                Task task = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
+                        .singleResult();
+                Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
+
+                TFFlowLog tfFlowLogExchange = tfFlowLogService.findByLastFlowLogByTaskId(Long.parseLong(task.getId()),
+                        FlowApproveOperationEnum.EXCHANGE);
                 if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN
                         && tfFlowApprove.getSetup().intValue() > 3) {
                     allocationParams.add(new AllocationParam(SopRoleTypeEnum.PROJECT_MANAGER,
-                            Arrays.asList(crmProjectResult.getRegionManagerId()), "[系统]"));
+                            Objects.nonNull(tfFlowLogExchange) ?
+                                    Arrays.asList(tfFlowLogExchange.getApproveId()) :
+                                    Arrays.asList(crmProjectResult.getRegionManagerId()), "[系统]"));
                 } else if (Objects.nonNull(scopeEnum) && scopeEnum == ServiceScopeEnum.SCAN_MARK) {
                     allocationParams.add(new AllocationParam(SopRoleTypeEnum.PROJECT_MANAGER,
-                            Arrays.asList(crmProjectResult.getProjectManagerList().get(0).getUserId()), "[系统]"));
+                            Objects.nonNull(tfFlowLogExchange) ?
+                                    Arrays.asList(tfFlowLogExchange.getApproveId()) :
+                                    Arrays.asList(crmProjectResult.getProjectManagerList().get(0).getUserId()),
+                            "[系统]"));
                 }
                 if (!CollectionUtils.isEmpty(allocationParams)) {
                     tbSopInfoService.sopApproverExchange(tbCrmDetail.getId(), new SopAllocationParam(

+ 22 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFFlowLogServiceImpl.java

@@ -8,6 +8,7 @@ import com.qmth.sop.business.mapper.TFFlowLogMapper;
 import com.qmth.sop.business.service.SysUserService;
 import com.qmth.sop.business.service.TFFlowLogService;
 import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.FlowApproveOperationEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
@@ -43,13 +44,17 @@ public class TFFlowLogServiceImpl extends ServiceImpl<TFFlowLogMapper, TFFlowLog
         for (TFFlowLogResult t : tfFlowLogResultList) {
             if (Objects.nonNull(t) && Objects.nonNull(t.getPendApproveId())) {
                 List<String> userList = Arrays.asList(t.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT));
-                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
-                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName()).collect(Collectors.toList());
+                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(
+                        userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
+                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName())
+                        .collect(Collectors.toList());
                 t.setPendApproveUserName(StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
             }
             if (Objects.nonNull(t) && Objects.nonNull(t.getApproveId())) {
-                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(Arrays.asList(t.getApproveId()));
-                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName()).collect(Collectors.toList());
+                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(
+                        Arrays.asList(t.getApproveId()));
+                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName())
+                        .collect(Collectors.toList());
                 t.setApproveUserName(StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
             }
         }
@@ -77,4 +82,17 @@ public class TFFlowLogServiceImpl extends ServiceImpl<TFFlowLogMapper, TFFlowLog
     public String findByLastFlowLogApproveUser(Long flowId) {
         return this.baseMapper.findByLastFlowLogApproveUser(flowId);
     }
+
+    /**
+     * 根据taskId和approveOperation查询最后一条日志审批记录
+     *
+     * @param taskId
+     * @param approveOperation
+     * @return
+     */
+    @Override
+    public TFFlowLog findByLastFlowLogByTaskId(Long taskId, FlowApproveOperationEnum approveOperation) {
+        return this.baseMapper.findByLastFlowLogByTaskId(taskId,
+                Objects.nonNull(approveOperation) ? approveOperation.name() : null);
+    }
 }

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

@@ -194,3 +194,8 @@ WHERE id=42;
 
 ALTER TABLE t_b_sop_quick_search DROP KEY t_b_sop_quick_search_unique;
 ALTER TABLE t_b_sop_quick_search ADD CONSTRAINT t_b_sop_quick_search_unique UNIQUE KEY (`type`,name,content_type,user_id);
+
+-- 2024-05-29
+UPDATE sys_privilege
+SET name='人员调配可选人员查询', url='/api/admin/user/archives/allocation/can_choose', `type`='URL', parent_id=3079, `sequence`=10, property='SYS', related=NULL, enable=1, default_auth=1, front_display=0
+WHERE id=2062;

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

@@ -34,7 +34,8 @@
         tfcf.flow_deployment_id as flowDeploymentId,
         tfcfe.id as customFlowEntityid,
         tffa.update_time as flowTime,
-        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime
+        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime,
+        tbcd.id as crmDetailId
         from
         ACT_RU_TASK art
         join t_f_flow_approve tffa on art.PROC_INST_ID_ = tffa.flow_id
@@ -44,6 +45,7 @@
         left join t_b_service tbs on tbs.id = tbc.service_id
         left join sys_custom sc on sc.id = tbc.custom_id
         left join sys_user su ON tfcfe.create_id = su.id
+        left join t_b_crm_detail tbcd on tbcd.sop_no = tfcfe.code
         <where> 1 = 1
             and tbs.status!='CANCEL'
             and art.ASSIGNEE_ = cast(#{userId} as char)
@@ -98,7 +100,8 @@
         tfcf.flow_deployment_id as flowDeploymentId,
         tfcfe.id as customFlowEntityid,
         tffa.update_time as flowTime,
-        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime
+        datediff(now(),FROM_UNIXTIME(tffa.update_time / 1000,'%Y-%m-%d %H:%i:%s')) as diffTime,
+        tbcd.id as crmDetailId
         from
         ACT_RU_TASK art
         left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_
@@ -109,6 +112,7 @@
         left join t_b_service tbs on tbs.id = tbc.service_id
         left join sys_custom sc on sc.id = tbc.custom_id
         left join sys_user su ON tfcfe.create_id = su.id
+        left join t_b_crm_detail tbcd on tbcd.sop_no = tfcfe.code
         <where> 1 = 1
             and tbs.status!='CANCEL'
             and art.ASSIGNEE_ is null

+ 8 - 0
sop-business/src/main/resources/mapper/TFFlowLogMapper.xml

@@ -65,4 +65,12 @@
     <select id="findByLastFlowLogApproveUser" resultType="java.lang.String">
         select group_concat(tffl.approve_id) from t_f_flow_log tffl where tffl.flow_id = #{flowId} and tffl.approve_setup > 1
     </select>
+
+    <select id="findByLastFlowLogByTaskId" resultType="com.qmth.sop.business.entity.TFFlowLog">
+        select * from t_f_flow_log tffl where tffl.task_id = #{taskId}
+            <if test="approveOperation != null and approveOperation != ''">
+                and tffl.approve_operation = #{approveOperation}
+            </if>
+            order by tffl.create_time desc limit 1
+    </select>
 </mapper>