Commit cb057e5e authored by chenyuxi's avatar chenyuxi

feat: 审批代码+流程配置提交

parent 89fcbc77
package com.yifu.cloud.plus.v1.yifu.common.dapr.util; package com.yifu.cloud.plus.v1.yifu.common.dapr.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprProcessProperties; import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprProcessProperties;
import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
/** /**
* @Author huyc * 流程
* @Date 2022-07-18 * @author chenyuxi
* @Description * @date 2025-01-10 17:47:32
* @Version 1.0 * @since 1.7.5
*/ */
@Log4j2 @Log4j2
@EnableConfigurationProperties(DaprProcessProperties.class) @EnableConfigurationProperties(DaprProcessProperties.class)
...@@ -18,4 +22,32 @@ public class ProcessDaprUtils { ...@@ -18,4 +22,32 @@ public class ProcessDaprUtils {
@Autowired @Autowired
private DaprProcessProperties daprProcessProperties; private DaprProcessProperties daprProcessProperties;
/**
* 根据流程类型查询ProcessVo
* @param processType 流程类型
* @return R<ProcessVo>
* @since mvp1.7.5
**/
public R<ProcessVo> getProcessVoByType(String processType) {
R<ProcessVo> processVoR = HttpDaprUtil.invokeMethodPost(daprProcessProperties.getAppUrl(),daprProcessProperties.getAppId(),"/tprocess/inner/getProcessVoByType", processType, ProcessVo.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(processVoR)){
return R.failed("根据流程类型查询ProcessVo失败!");
}
return processVoR;
}
/**
* 根据流程Id查询ProcessVo
* @param processId 流程ID
* @return R<ProcessVo>
* @since mvp1.7.5
**/
public R<ProcessVo> getProcessVoById(String processId) {
R<ProcessVo> processVoR = HttpDaprUtil.invokeMethodPost(daprProcessProperties.getAppUrl(),daprProcessProperties.getAppId(),"/tprocess/inner/getProcessVoByProcessId", processId, ProcessVo.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(processVoR)){
return R.failed("根据流程ID查询ProcessVo失败!");
}
return processVoR;
}
} }
package com.yifu.cloud.plus.v1.yifu.common.dapr.util; package com.yifu.cloud.plus.v1.yifu.common.dapr.util;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AllUserNaVo; import com.yifu.cloud.plus.v1.yifu.admin.api.vo.*;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaMap;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
...@@ -113,4 +110,12 @@ public class UpmsDaprUtils { ...@@ -113,4 +110,12 @@ public class UpmsDaprUtils {
} }
return userR; return userR;
} }
public R<SysUserListVo> getUserByRoleIdForCrm(UserApprovalRoleVO userByApprovalRole) {
R<SysUserListVo> allUserVoR = HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId(),"/user/inner/getUser/getUserByRoleIdForCrm",userByApprovalRole, SysUserListVo.class, SecurityConstants.FROM_IN);
if (Common.isEmpty(allUserVoR)){
return R.failed("查询流程配置审批角色对应的审批人失败!");
}
return allUserVoR;
}
} }
...@@ -7,4 +7,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ ...@@ -7,4 +7,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.InsuranceDaprUtil,\ com.yifu.cloud.plus.v1.yifu.common.dapr.util.InsuranceDaprUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil,\ com.yifu.cloud.plus.v1.yifu.common.dapr.util.SalaryDaprUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.EkpDaprUtils,\ com.yifu.cloud.plus.v1.yifu.common.dapr.util.EkpDaprUtils,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.PermissionDaprUtil com.yifu.cloud.plus.v1.yifu.common.dapr.util.PermissionDaprUtil,\
com.yifu.cloud.plus.v1.yifu.common.dapr.util.ProcessDaprUtils
...@@ -38,10 +38,14 @@ dapr.permission.appId=yifu-permission ...@@ -38,10 +38,14 @@ dapr.permission.appId=yifu-permission
dapr.ekp.appUrl=http://yifu-ekp.qas-mvp.svc.cluster.local:3500/v1.0/invoke/ dapr.ekp.appUrl=http://yifu-ekp.qas-mvp.svc.cluster.local:3500/v1.0/invoke/
dapr.ekp.appId=yifu-ekp dapr.ekp.appId=yifu-ekp
dapr.process.appUrl=http://yifu-process.qas-mvp.svc.cluster.local:3500/v1.0/invoke/
dapr.process.appId=yifu-process
#\u6D4B\u8BD5\u73AF\u5883-\u85AA\u8D44\u670D\u52A1 #\u6D4B\u8BD5\u73AF\u5883-\u85AA\u8D44\u670D\u52A1
#dapr.salary.appUrl=http://yifu-salary.qas-mvp.svc.cluster.local:3500/v1.0/invoke/ #dapr.salary.appUrl=http://yifu-salary.qas-mvp.svc.cluster.local:3500/v1.0/invoke/
#dapr.salary.appId=yifu-salary #dapr.salary.appId=yifu-salary
#\u6D4B\u8BD5\u73AF\u5883-\u793E\u4FDD\u670D\u52A1 #\u6D4B\u8BD5\u73AF\u5883-\u793E\u4FDD\u670D\u52A1
#dapr.social.appUrl=http://yifu-social.qas-mvp.svc.cluster.local:3500/v1.0/invoke/ #dapr.social.appUrl=http://yifu-social.qas-mvp.svc.cluster.local:3500/v1.0/invoke/
#dapr.social.appId=yifu-social #dapr.social.appId=yifu-social
\ No newline at end of file
package com.yifu.cloud.plus.v1.yifu.process.constant; package com.yifu.cloud.plus.v1.yifu.process.constant;
/** /**
* @auther wangan * @author chenyuxi
* @date 2020/9/17 * @since 1.7.5
*/ */
public class ProcessConstants { public class ProcessConstants {
//审批中心各个节点类型 //审批中心各个节点类型
...@@ -14,9 +13,6 @@ public class ProcessConstants { ...@@ -14,9 +13,6 @@ public class ProcessConstants {
public static final String PROCESS_NODE_EMBED = "embed"; public static final String PROCESS_NODE_EMBED = "embed";
public static final String PROCESS_NODE_SERVICE = "service"; public static final String PROCESS_NODE_SERVICE = "service";
// 【含风险项目商险不购买申请流程】条件判断审批节点名称 // 【含风险项目商险不购买申请流程】条件判断审批节点名称
public static final String PROCESS_NODE_INSURANCEUNPURCHASE_REASON_TYPE = "是否为已购买社保"; public static final String PROCESS_NODE_INSURANCEUNPURCHASE_REASON_TYPE = "是否为已购买社保";
public static final String PROCESS_NODE_INSURANCEUNPURCHASE_DEPT_PROPERTY = "是否属于子分公司"; public static final String PROCESS_NODE_INSURANCEUNPURCHASE_DEPT_PROPERTY = "是否属于子分公司";
......
...@@ -84,7 +84,7 @@ public class TNodePrimission extends Model<TNodePrimission> { ...@@ -84,7 +84,7 @@ public class TNodePrimission extends Model<TNodePrimission> {
private String approvalRole; private String approvalRole;
@Length(max = 10, message = "指定事业部配置表负责人标识不能超过10个字符") @Length(max = 10, message = "指定事业部配置表负责人标识不能超过10个字符")
@Schema(description = "指定事业部配置表负责人标识") @Schema(description = "指定事业部配置表负责人标识(0事业部条线负责人;1事业部负责人;2分管副总)")
private String divisionIdentification; private String divisionIdentification;
@Length(max = 1, message = "是否允许直接通过不能超过1个字符") @Length(max = 1, message = "是否允许直接通过不能超过1个字符")
......
...@@ -23,40 +23,4 @@ public class CommonProcessUserUtil { ...@@ -23,40 +23,4 @@ public class CommonProcessUserUtil {
public static final String FEGIN_USER_FAIL = "调用用户服务失败"; public static final String FEGIN_USER_FAIL = "调用用户服务失败";
public static final String FEGIN_USER_RETURN_FAIL = "调用用户服务回失败"; public static final String FEGIN_USER_RETURN_FAIL = "调用用户服务回失败";
/**
* 获取crm部门审核人
* @param nodePrimission
* @param departId
* @return List<SysUser>
**/
public static List<SysUser> getDepartAuditUser(TNodePrimission nodePrimission, String departId) {
SysUser remoteSysUser = null;
List<SysUser> remoteSysUserList = new ArrayList<>();
if (CommonConstants.THREE_INT == nodePrimission.getType().intValue()) {
//3.指定用户
if (Common.isEmpty(nodePrimission.getUser())) {
throw new CheckedException("未查询当前流程权限对应的用户");
}
// 查找当前用户
// todo 通过用户id查询用户角色
// remoteSysUser = RemoteRequestUtil.getSysUser(remoteUserService, Integer.parseInt(nodePrimission.getUser()));
remoteSysUserList.add(remoteSysUser);
} else if (CommonConstants.TWO_INT == nodePrimission.getType().intValue()) {
//2.指定角色
if (Common.isEmpty(nodePrimission.getRole())) {
throw new CheckedException("未查询当前流程对应的组织权限");
}
//如果下个节点是角色这要取下个角色是否存在
// remoteSysUser = RemoteRequestUtil.getUserManagerByRoleAndDepartId(remoteUserService, departId, nodePrimission.getRole());
remoteSysUserList.add(remoteSysUser);
} else if (CommonConstants.FIVE_INT == nodePrimission.getType().intValue()){
// 5.指定角色(crm)
if (Common.isEmpty(nodePrimission.getApprovalRole())) {
throw new CheckedException("未查询当前节点配置的审核角色");
}
// remoteSysUserList = RemoteRequestUtil.getUserByRoleIdForCrm(remoteUserService, departId, nodePrimission.getApprovalRole());
}
return remoteSysUserList;
}
} }
package com.yifu.cloud.plus.v1.yifu.process.util; package com.yifu.cloud.plus.v1.yifu.process.util;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException; import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants; import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants;
import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRoute; import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRoute;
...@@ -10,6 +12,7 @@ import com.yifu.cloud.plus.v1.yifu.process.entity.TProcessNode; ...@@ -10,6 +12,7 @@ import com.yifu.cloud.plus.v1.yifu.process.entity.TProcessNode;
import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo; import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -30,41 +33,43 @@ public class ProcessAuditUtil { ...@@ -30,41 +33,43 @@ public class ProcessAuditUtil {
public static final String BEGIN_NODE_NO_FOUND = "未找到开始节点"; public static final String BEGIN_NODE_NO_FOUND = "未找到开始节点";
/**
* @param
* @param processId
* @Author: wangan
* @Date: 2020/9/21
* @Description: 获通过流程id, 获取流程
* @return: com.yifu.cloud.plus.v1.process.api.vo.ProcessVo
**/
public static ProcessVo getProcessVo(String processId) {
// todo 改成dapr请求
//R<ProcessVo> processVoR = remoteProcessService.getProcessVoByName(processId, SecurityConstants.FROM_IN);
R<ProcessVo> processVoR = new R<>();
if (processVoR == null) { /**
throw new CheckedException("调用流程服务返回为空"); * 根据流程类型查询ProcessVo
} * @param processType 流程类型
if (CommonConstants.SUCCESS != processVoR.getCode()) { * @return R<ProcessVo>
throw new CheckedException("调用流程服务返回失败"); * @since mvp1.7.5
} **/
ProcessVo processVo = processVoR.getData(); // public static ProcessVo getProcessVoByType(ProcessDaprUtils processDaprUtils, String processType) {
if (processVo == null) { // // todo 改成dapr请求
throw new CheckedException("调用流程服务返回数据为空"); // //R<ProcessVo> processVoR = remoteProcessService.getProcessVoByName(processId, SecurityConstants.FROM_IN);
} // R<SysUserListVo> res = upmsDaprUtils.getUserIdsByUserNames(domain.getServiceTeam());
return processVo; // if (Common.isNotNull(res) && Common.isNotNull(res.getData()) && Common.isNotNull(res.getData().getUserList())){
} // // 先清理缓存
// this.removeSettleCache(null, res.getData().getUserIds());
// saveForEkp(res.getData().getUserList(), domain);
// }
// R<ProcessVo> processVoR = new R<>();
//
// if (processVoR == null) {
// throw new CheckedException("调用流程服务返回为空");
// }
// if (CommonConstants.SUCCESS != processVoR.getCode()) {
// throw new CheckedException("调用流程服务返回失败");
// }
// ProcessVo processVo = processVoR.getData();
// if (processVo == null) {
// throw new CheckedException("调用流程服务返回数据为空");
// }
// return processVo;
// }
/** /**
* @param nodeRouteList * 通过条件表达式判断路由的下一个节点
* @param nodeRouteList
* @param nodeRouteConditionList * @param nodeRouteConditionList
* @param object * @param object
* @Author: wangan
* @Date: 2020/9/17
* @Description: 条件节点:通过条件表达式判断路由的下一个节点
* @return: com.yifu.cloud.plus.v1.process.api.entity.TNodeRoute
**/ **/
public static TNodeRoute getTNodeRoteByExpress(List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList, Object object, Class<?> parameterTypes) { public static TNodeRoute getTNodeRoteByExpress(List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList, Object object, Class<?> parameterTypes) {
TNodeRoute matchNodeRoute = null; TNodeRoute matchNodeRoute = null;
...@@ -149,10 +154,8 @@ public class ProcessAuditUtil { ...@@ -149,10 +154,8 @@ public class ProcessAuditUtil {
throw new CheckedException(END_PRE_NODE_NO_FOUND); throw new CheckedException(END_PRE_NODE_NO_FOUND);
} }
return preEndTProcessNode; return preEndTProcessNode;
} }
/** /**
* @param processVo * @param processVo
* @Author: wangan * @Author: wangan
...@@ -164,16 +167,16 @@ public class ProcessAuditUtil { ...@@ -164,16 +167,16 @@ public class ProcessAuditUtil {
//获取当前节点的下个节点 //获取当前节点的下个节点
List<TProcessNode> processNodeList = processVo.getProcessNodeList(); List<TProcessNode> processNodeList = processVo.getProcessNodeList();
//开始节点 //开始节点
TProcessNode startTProcessNode = null; TProcessNode startProcessNode = null;
for (TProcessNode processNode : processNodeList) { for (TProcessNode processNode : processNodeList) {
if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, processNode.getType())) { if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, processNode.getType())) {
startTProcessNode = processNode; startProcessNode = processNode;
} }
} }
if (startTProcessNode == null) { if (startProcessNode == null) {
throw new CheckedException(BEGIN_NODE_NO_FOUND); throw new CheckedException(BEGIN_NODE_NO_FOUND);
} }
return startTProcessNode; return startProcessNode;
} }
......
...@@ -99,53 +99,6 @@ public class TProcessApprovalConfController { ...@@ -99,53 +99,6 @@ public class TProcessApprovalConfController {
return new R<>(tProcessApprovalConfService.removeById(id)); return new R<>(tProcessApprovalConfService.removeById(id));
} }
/**
* todo
* @param type
* @param parentId
* @Author: wangan
* @Date: 2020/12/7
* @Description: 通过类型和父类名称去获取字段名称
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<TProcessApprovalConf>
* @see com.yifu.cloud.plus.v1.process.controller
**/
@Inner
@GetMapping("/inner/getRecord/byTypeAndParentId")
public R<TProcessApprovalConf> getRecordbyTypeAndParentId(@RequestParam("type") String type, @RequestParam("parentId") String parentId) {
List<TProcessApprovalConf> list = tProcessApprovalConfService.list(Wrappers.<TProcessApprovalConf>query().lambda()
.eq(TProcessApprovalConf::getType, type)
.eq(TProcessApprovalConf::getParentId, parentId)
.eq(TProcessApprovalConf::getDeleteFlag, CommonConstants.ZERO_STRING));
if (list.isEmpty()) {
return new R<>(null);
}
return new R<>(list.get(CommonConstants.ZERO_INT));
}
/**
* todo
* @param type
* @param parentId
* @Author: wangan
* @Date: 2020/12/7
* @Description: 通过相关条件获取正确的一个主流程
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<TProcessApprovalConf>
* @see com.yifu.cloud.plus.v1.process.controller
**/
@Inner
@GetMapping("/inner/getRecord/byCondition")
public R<TProcessApprovalConf> getRecordByCondition(@RequestParam("type") String type,
@RequestParam("parentId") String parentId,
@RequestParam("fieldName") String fieldName,
@RequestParam("fieldValue") String fieldValue) {
return tProcessApprovalConfService.getRecordByCondition(type,parentId,fieldName,fieldValue);
}
/** /**
* todo * todo
* @param processId * @param processId
......
...@@ -26,7 +26,7 @@ import java.time.LocalDateTime; ...@@ -26,7 +26,7 @@ import java.time.LocalDateTime;
/** /**
* 主流程表 * 主流程表
* *
* @author hgw * @author chenyuxi
* @date 2020-07-16 15:44:02 * @date 2020-07-16 15:44:02
*/ */
@RestController @RestController
...@@ -89,20 +89,29 @@ public class TProcessController { ...@@ -89,20 +89,29 @@ public class TProcessController {
} }
/** /**
* todo * 根据流程类型查询ProcessVo
* @param processId 流程名称 * @param processType 流程类型
* @Description: 根据流程名称查询ProcessVo * @return R<ProcessVo>
* @Author: hgw * @since mvp1.7.5
* @Date: 2020-7-22 18:17:29
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<ProcessVo>
**/ **/
@Operation(summary = "根据流程名称查询ProcessVo") @PostMapping("/inner/getProcessVoByType")
@PostMapping("/inner/getProcessVoByName")
@Inner @Inner
public R<ProcessVo> getProcessVoByName(String processId) { public ProcessVo getProcessVoByType(String processType) {
return tProcessService.getProcessVoByName(processId); return tProcessService.getProcessVoByType(processType);
} }
/**
* 根据流程Id查询ProcessVo
* @param processId 流程类型
* @return R<ProcessVo>
* @since mvp1.7.5
**/
@PostMapping("/inner/getProcessVoByProcessId")
@Inner
public ProcessVo getProcessVoByProcessId(String processId) {
return tProcessService.getProcessVoById(processId);
}
/** /**
* 新增记录 * 新增记录
* @param processVo * @param processVo
......
...@@ -33,14 +33,13 @@ public interface TProcessService extends IService<TProcess> { ...@@ -33,14 +33,13 @@ public interface TProcessService extends IService<TProcess> {
**/ **/
ProcessVo getProcessVoById(String id); ProcessVo getProcessVoById(String id);
/** /**
* @param processId * 根据流程类型查询ProcessVo
* @Description: 返回ProcessVo * @param processType 流程类型
* @Author: hgw *
* @Date: 2020-7-22 18:18:42 * @return R<ProcessVo>
* @return: ProcessVo **/
**/ ProcessVo getProcessVoByType(String processType);
R<ProcessVo> getProcessVoByName(String processId);
/** /**
* @param processVo * @param processVo
......
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.process.vo.DeleteProcessIdsVo; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.process.vo.DeleteProcessIdsVo;
import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo; import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo;
import com.yifu.cloud.plus.v1.yifu.process.vo.TProcessViewVo; import com.yifu.cloud.plus.v1.yifu.process.vo.TProcessViewVo;
import com.yifu.cloud.plus.v1.yifu.process.service.*; import com.yifu.cloud.plus.v1.yifu.process.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -44,6 +45,7 @@ import static com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants.F ...@@ -44,6 +45,7 @@ import static com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants.F
* @date 2020-07-16 15:44:02 * @date 2020-07-16 15:44:02
*/ */
@Service @Service
@Slf4j
public class TProcessServiceImpl extends ServiceImpl<TProcessMapper, TProcess> implements TProcessService { public class TProcessServiceImpl extends ServiceImpl<TProcessMapper, TProcess> implements TProcessService {
@Resource @Resource
...@@ -230,76 +232,67 @@ public class TProcessServiceImpl extends ServiceImpl<TProcessMapper, TProcess> i ...@@ -230,76 +232,67 @@ public class TProcessServiceImpl extends ServiceImpl<TProcessMapper, TProcess> i
return processVo; return processVo;
} }
/** /**
* @param processId * 根据流程类型查询ProcessVo
* @Description: 获取包装类 * @param processType 流程类型
* @Author: hgw * @return R<ProcessVo>
* @Date: 2020/7/17 11:05 * @since mvp1.7.5
* @return: ProcessVo **/
**/
@Override @Override
public R<ProcessVo> getProcessVoByName(String processId) { public ProcessVo getProcessVoByType(String processType) {
// 主流程表 TProcessApprovalConf approvalConf = processApprovalConfService.getOne(Wrappers.<TProcessApprovalConf>query().lambda()
.eq(TProcessApprovalConf::getType, processType)
.eq(TProcessApprovalConf::getDeleteFlag, CommonConstants.ZERO_STRING).last(CommonConstants.SQL_LIMIT_ONE));
if(Common.isEmpty(approvalConf)){
log.error("根据类型获取流程配置失败>>processType={}",processType);
return null;
}
// 获取主流程信息
ProcessVo processVo = new ProcessVo(); ProcessVo processVo = new ProcessVo();
TProcess process = this.getById(processId); TProcess process = this.getById(approvalConf.getProcessId());
if (process == null) { if (Common.isEmpty(process)) {
return R.failed("获取流程失败"); log.error("获取主流程信息失败>>processId={}",approvalConf.getProcessId());
return null;
} }
String processId = process.getId();
processVo.setProcessId(processId); processVo.setProcessId(processId);
processVo.setName(process.getName()); processVo.setName(process.getName());
// 节点
TProcessNode processNode = new TProcessNode(); // 获取节点列表信息
processNode.setProcessId(processId); List<TProcessNode> processNodeList = processNodeService.list(Wrappers.<TProcessNode>query().lambda()
// 节点查询 .eq(TProcessNode::getProcessId, processId));
QueryWrapper<TProcessNode> queryWrapperPn = new QueryWrapper<>(); if (Common.isNotNull(processNodeList)) {
queryWrapperPn.setEntity(processNode); // 定义审批用户列表
// 节点列表
List<TProcessNode> processNodeList = processNodeService.list(queryWrapperPn);
if (processNodeList != null && !processNodeList.isEmpty()) {
// 权限
TNodePrimission nodePrimission;
// 权限查询
QueryWrapper<TNodePrimission> queryWrapperNp;
// 权限列表
List<TNodePrimission> nodePrimissionList; List<TNodePrimission> nodePrimissionList;
// 抄送 // 定义抄送用户列表
TNodeReaderPromission nodeReaderPromission;
// 抄送查询
QueryWrapper<TNodeReaderPromission> queryWrapperNrp;
// 抄送列表
List<TNodeReaderPromission> nodeReaderPromissionList; List<TNodeReaderPromission> nodeReaderPromissionList;
for (TProcessNode proNode : processNodeList) {
nodePrimission = new TNodePrimission();
nodePrimission.setNodeId(proNode.getId());
queryWrapperNp = new QueryWrapper<>();
queryWrapperNp.setEntity(nodePrimission);
nodePrimissionList = nodePrimissionService.list(queryWrapperNp);
proNode.setNodePrimissionList(nodePrimissionList);
nodeReaderPromission = new TNodeReaderPromission();
nodeReaderPromission.setNodeId(proNode.getId());
queryWrapperNrp = new QueryWrapper<>();
queryWrapperNrp.setEntity(nodeReaderPromission);
nodeReaderPromissionList = nodeReaderPromissionService.list(queryWrapperNrp);
proNode.setNodeReaderPromissionList(nodeReaderPromissionList);
//子流程
proNode.setNodeTransferConfigs(nodeTransferConfigService.list(Wrappers.<TNodeTransferConfig>query().lambda().eq(TNodeTransferConfig::getNodeId, proNode.getId())));
for (TProcessNode nodeInfo : processNodeList) {
// 赋值审批用户列表
nodePrimissionList = nodePrimissionService.list(Wrappers.<TNodePrimission>query().lambda()
.eq(TNodePrimission::getNodeId, nodeInfo.getId()));
nodeInfo.setNodePrimissionList(nodePrimissionList);
// 赋值抄送用户列表
nodeReaderPromissionList = nodeReaderPromissionService.list(Wrappers.<TNodeReaderPromission>query().lambda()
.eq(TNodeReaderPromission::getNodeId, nodeInfo.getId()));
nodeInfo.setNodeReaderPromissionList(nodeReaderPromissionList);
} }
} }
processVo.setProcessNodeList(processNodeList); processVo.setProcessNodeList(processNodeList);
// 路由
TNodeRoute nodeRoute = new TNodeRoute();
nodeRoute.setProcessId(processId);
// 路由查询
QueryWrapper<TNodeRoute> queryWrapperNr = new QueryWrapper<>();
queryWrapperNr.setEntity(nodeRoute);
// 路由列表 // 路由列表
List<TNodeRoute> nodeRouteList = nodeRouteService.list(queryWrapperNr); List<TNodeRoute> nodeRouteList = nodeRouteService.list(Wrappers.<TNodeRoute>query().lambda()
for (TNodeRoute tNodeRoute : nodeRouteList) { tNodeRoute.setNodeRouteConditionList(nodeRouteConditionService.list(Wrappers.<TNodeRouteCondition>query().lambda().eq(TNodeRouteCondition::getNodeRouteId,tNodeRoute.getId()))); .eq(TNodeRoute::getProcessId, processId));
} // 路由条件判断列表
processVo.setNodeRouteList(nodeRouteList); if (Common.isNotNull(nodeRouteList)) {
return new R<>(processVo); List<TNodeRouteCondition> nodeRouteConditionList;
for (TNodeRoute tNodeRoute : nodeRouteList) {
nodeRouteConditionList = nodeRouteConditionService.list(Wrappers.<TNodeRouteCondition>query().lambda().eq(TNodeRouteCondition::getNodeRouteId,tNodeRoute.getId()));
tNodeRoute.setNodeRouteConditionList(nodeRouteConditionList);
}
processVo.setNodeRouteList(nodeRouteList);
}
return processVo;
} }
/** /**
......
...@@ -21,10 +21,10 @@ import java.time.LocalDateTime; ...@@ -21,10 +21,10 @@ import java.time.LocalDateTime;
* @since 1.7.5 * @since 1.7.5
*/ */
@Data @Data
@TableName("t_audit_node_proocess") @TableName("t_audit_node_process")
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Schema(description = "审批主流程记录表节点表") @Schema(description = "审批主流程记录表节点表")
public class TAuditNodeProocess extends BaseEntity { public class TAuditNodeProcess extends BaseEntity {
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键") @Schema(description = "主键")
......
package com.yifu.cloud.plus.v1.yifu.salary.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @Author: huyc
* @Date: 2023/7/28
* @Description:
* @return: 企业微信配置
**/
@Configuration
@Data
@Slf4j
public class WxConfig {
@Value("${wx.corpid}")
private String corpid;
@Value("${wx.corpsecret}")
private String corpsecret;
@Value("${wx.agentid}")
private String agentid;
@Value("${wx.authUrl}")
private String authUrl;
@Autowired
private RedisTemplate redisTemplate;
//未授权
private String accossTokenInvliad = "40014";
/**
* @param
* @Author: huyc
* @Date: 2023/7/28
* @Description: 获取微信accos_token
* @return: java.lang.String
**/
public String getAccessToken(RestTemplate restTemplate) {
if (Common.isNotNull(agentid)) {
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
public String getAccessToken(RestTemplate restTemplate,String corpsecret)throws AuthenticationServiceException {
if(Common.isEmpty(corpsecret)){
throw new AuthenticationServiceException("未找到对应的corpsecret请联系管理员配置");
}
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN.concat(agentid), corpsecret);
}
/**
* @param restTemplate
* @param tokenKey
* @param corpsecretKey
* @Description: 获取token
* @Author: huyc
* @Date: 2023/7/28 14:46
* @return: java.lang.String
**/
public String getToken(RestTemplate restTemplate,String tokenKey, String corpsecretKey) {
Object wxToken = redisTemplate.opsForValue().get(tokenKey);
if (null != wxToken) {
return String.valueOf(wxToken);
}
String requestTokenUrl = String.format(SecurityConstants.WX_GET_ACCOSS_TOKEN, corpid, corpsecretKey);
String result = restTemplate.getForObject(requestTokenUrl, String.class);
if (Common.isEmpty(result)) {
throw new CheckedException("微信授权失败");
}
String token = JSON.parseObject(result).getString("access_token");
if (Common.isEmpty(token)) {
log.info(result);
throw new CheckedException("获取微信token失败");
}
redisTemplate.opsForValue().set(tokenKey, token);
redisTemplate.expire(tokenKey, 3600, TimeUnit.SECONDS);
return token;
}
/**
* @param
* @Author: huyc
* @Date: 2023/7/28 14:43
* @Description: 移除微信accossToken
* @return: java.lang.String
**/
public void removeAccessToken() {
redisTemplate.delete(CacheConstants.WX_ACCOSS_TOKEN);
}
/**
* @param restTemplate
* @param requestMap 请求内容
* @Author: huyc
* @Date: 2023/7/28 14:48
* @Description: 发送卡片消息
* @return: java.lang.String
**/
public boolean sendTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) {
// 必须加上header说明
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Gson gson = new Gson();
log.info(gson.toJson(requestMap));
HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers);
String accessToken = getAccessToken(restTemplate);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class);
log.info(JSON.toJSONString(responseEntity));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity));
JSONObject jsonBody = jsonObject.getJSONObject("body");
if (jsonBody != null) {
String errcode = jsonBody.getString("errcode");
if (accossTokenInvliad.equals(errcode)) {
//删除accossToken缓存
removeAccessToken();
return false;
}
if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志
log.info(jsonObject.toJSONString());
}
} else {
log.info(jsonObject.toJSONString());
}
return true;
}
/**
* @param restTemplate
* @param requestMap 请求内容
* @Author: huyc
* @Date: 2023/7/28 14:50
* @Description: 发送卡片消息
* @return: java.lang.String
**/
public boolean sendAppTextCard(RestTemplate restTemplate, Map<String, Object> requestMap) {
// 必须加上header说明
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Gson gson = new Gson();
log.info("发企业微信===请求:{}", gson.toJson(requestMap));
HttpEntity<String> requestEntity = new HttpEntity<>(gson.toJson(requestMap), headers);
String accessToken = getAppAccessToken(restTemplate);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(String.format(SecurityConstants.WX_SEND_MESSAGE, accessToken), requestEntity, String.class);
log.info("发企业微信===返回:{}",JSON.toJSONString(responseEntity));
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(responseEntity));
JSONObject jsonBody = jsonObject.getJSONObject("body");
if (jsonBody != null) {
String errcode = jsonBody.getString("errcode");
if (accossTokenInvliad.equals(errcode)) {
//删除accossToken缓存
removeAccessToken();
return false;
}
if (!CommonConstants.ZERO_STRING.equals(errcode)) { //非正常,则打印错误日志
log.info(jsonObject.toJSONString());
}
} else {
log.info(jsonObject.toJSONString());
}
return true;
}
/**
* 功能描述: 获取微信accos_token
* @Author: huyc
* @Date: 2023/7/28 14:50
* @return: java.lang.String
*/
public String getAppAccessToken(RestTemplate restTemplate) {
return this.getToken(restTemplate, CacheConstants.WX_ACCOSS_TOKEN, corpsecret);
}
}
...@@ -2,8 +2,8 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller; ...@@ -2,8 +2,8 @@ package com.yifu.cloud.plus.v1.yifu.salary.controller;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess; import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProocessService; import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProcessService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
...@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
@Tag(name = "审批主流程记录表节点表管理") @Tag(name = "审批主流程记录表节点表管理")
public class TAuditNodeProocessController { public class TAuditNodeProocessController {
private final TAuditNodeProocessService tAuditNodeProocessService; private final TAuditNodeProcessService tAuditNodeProcessService;
/** /**
* 通过id查询审批主流程记录表节点表 * 通过id查询审批主流程记录表节点表
...@@ -34,34 +34,34 @@ public class TAuditNodeProocessController { ...@@ -34,34 +34,34 @@ public class TAuditNodeProocessController {
@Operation(summary = "通过id查询", description = "通过id查询:hasPermission('insurances_tauditnodeproocess_get')") @Operation(summary = "通过id查询", description = "通过id查询:hasPermission('insurances_tauditnodeproocess_get')")
@GetMapping("/{id}" ) @GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_get')" ) @PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_get')" )
public R<TAuditNodeProocess> getById(@PathVariable("id" ) String id) { public R<TAuditNodeProcess> getById(@PathVariable("id" ) String id) {
return R.ok(tAuditNodeProocessService.getById(id)); return R.ok(tAuditNodeProcessService.getById(id));
} }
/** /**
* 新增审批主流程记录表节点表 * 新增审批主流程记录表节点表
* @param tAuditNodeProocess 审批主流程记录表节点表 * @param tAuditNodeProcess 审批主流程记录表节点表
* @return R * @return R
*/ */
@Operation(summary = "新增审批主流程记录表节点表", description = "新增审批主流程记录表节点表:hasPermission('insurances_tauditnodeproocess_add')") @Operation(summary = "新增审批主流程记录表节点表", description = "新增审批主流程记录表节点表:hasPermission('insurances_tauditnodeproocess_add')")
@SysLog("新增审批主流程记录表节点表" ) @SysLog("新增审批主流程记录表节点表" )
@PostMapping @PostMapping
@PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_add')" ) @PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_add')" )
public R<Boolean> save(@RequestBody TAuditNodeProocess tAuditNodeProocess) { public R<Boolean> save(@RequestBody TAuditNodeProcess tAuditNodeProcess) {
return R.ok(tAuditNodeProocessService.save(tAuditNodeProocess)); return R.ok(tAuditNodeProcessService.save(tAuditNodeProcess));
} }
/** /**
* 修改审批主流程记录表节点表 * 修改审批主流程记录表节点表
* @param tAuditNodeProocess 审批主流程记录表节点表 * @param tAuditNodeProcess 审批主流程记录表节点表
* @return R * @return R
*/ */
@Operation(summary = "修改审批主流程记录表节点表", description = "修改审批主流程记录表节点表:hasPermission('insurances_tauditnodeproocess_edit')") @Operation(summary = "修改审批主流程记录表节点表", description = "修改审批主流程记录表节点表:hasPermission('insurances_tauditnodeproocess_edit')")
@SysLog("修改审批主流程记录表节点表" ) @SysLog("修改审批主流程记录表节点表" )
@PutMapping @PutMapping
@PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_edit')" ) @PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_edit')" )
public R<Boolean> updateById(@RequestBody TAuditNodeProocess tAuditNodeProocess) { public R<Boolean> updateById(@RequestBody TAuditNodeProcess tAuditNodeProcess) {
return R.ok(tAuditNodeProocessService.updateById(tAuditNodeProocess)); return R.ok(tAuditNodeProcessService.updateById(tAuditNodeProcess));
} }
/** /**
...@@ -74,7 +74,7 @@ public class TAuditNodeProocessController { ...@@ -74,7 +74,7 @@ public class TAuditNodeProocessController {
@DeleteMapping("/{id}" ) @DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_del')" ) @PreAuthorize("@pms.hasPermission('insurances_tauditnodeproocess_del')" )
public R<Boolean> removeById(@PathVariable String id) { public R<Boolean> removeById(@PathVariable String id) {
return R.ok(tAuditNodeProocessService.removeById(id)); return R.ok(tAuditNodeProcessService.removeById(id));
} }
} }
package com.yifu.cloud.plus.v1.yifu.salary.mapper; package com.yifu.cloud.plus.v1.yifu.salary.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess; import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
...@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
* @since 1.7.5 * @since 1.7.5
*/ */
@Mapper @Mapper
public interface TAuditNodeProocessMapper extends BaseMapper<TAuditNodeProocess> { public interface TAuditNodeProcessMapper extends BaseMapper<TAuditNodeProcess> {
} }
package com.yifu.cloud.plus.v1.yifu.salary.service; package com.yifu.cloud.plus.v1.yifu.salary.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess; import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
/** /**
* 审批主流程记录表节点表 * 审批主流程记录表节点表
...@@ -10,6 +10,6 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess; ...@@ -10,6 +10,6 @@ import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess;
* @date 2025-01-10 17:47:32 * @date 2025-01-10 17:47:32
* @since 1.7.5 * @since 1.7.5
*/ */
public interface TAuditNodeProocessService extends IService<TAuditNodeProocess> { public interface TAuditNodeProcessService extends IService<TAuditNodeProcess> {
} }
...@@ -3,22 +3,26 @@ package com.yifu.cloud.plus.v1.yifu.salary.service.impl; ...@@ -3,22 +3,26 @@ package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.SysUserListVo;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserApprovalRoleVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException; import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ProcessDaprUtils;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditRecord; import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditRecord;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess;
import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditRecordService; import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditRecordService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProocessService; import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProcessService;
import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants; import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants;
import com.yifu.cloud.plus.v1.yifu.process.entity.*; import com.yifu.cloud.plus.v1.yifu.process.entity.*;
import com.yifu.cloud.plus.v1.yifu.process.util.CommonProcessUserUtil;
import com.yifu.cloud.plus.v1.yifu.process.util.ProcessAuditUtil; import com.yifu.cloud.plus.v1.yifu.process.util.ProcessAuditUtil;
import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo; import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -34,15 +38,21 @@ import java.util.*; ...@@ -34,15 +38,21 @@ import java.util.*;
public abstract class AbastractAuditProcess<T,E extends T> { public abstract class AbastractAuditProcess<T,E extends T> {
@Resource @Resource
protected TAuditNodeProocessService auditNodeProocessService; protected TAuditNodeProcessService auditNodeProcessService;
@Resource @Resource
protected TAuditRecordService approvalRecordService; protected TAuditRecordService auditRecordService;
public static final String BIGIN_NODE_NO_FOUND = "未找到开始审批节点,请联系管理员"; public static final String BIGIN_NODE_NO_FOUND = "未找到开始审批节点,请联系管理员";
public static final String NEXT_NODE_USER_NULL = "未查询到下个节点的用户,请联系管理员"; public static final String NEXT_NODE_USER_NULL = "未查询到下个节点的用户,请联系管理员";
public static final String NEXT_AUDIT_NODE_NOT_FOUND = "未查询到下一个审核节点,请联系管理员"; public static final String NEXT_AUDIT_NODE_NOT_FOUND = "未查询到下一个审核节点,请联系管理员";
@Autowired
private ProcessDaprUtils processDaprUtils;
@Autowired
private UpmsDaprUtils upmsDaprUtils;
/** /**
* 审核成功并结束逻辑 * 审核成功并结束逻辑
* @param entity 业务实体 * @param entity 业务实体
...@@ -75,7 +85,7 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -75,7 +85,7 @@ public abstract class AbastractAuditProcess<T,E extends T> {
* @return TProcessNode * @return TProcessNode
**/ **/
abstract public TProcessNode choiceGetNode(ProcessVo processVo, List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList, abstract public TProcessNode choiceGetNode(ProcessVo processVo, List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList,
TProcessNode currentNode, T entity, String type, YifuUser loginUser); TProcessNode currentNode, T entity, String auditType, YifuUser loginUser);
/** /**
* 审批发消息 * 审批发消息
...@@ -97,48 +107,38 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -97,48 +107,38 @@ public abstract class AbastractAuditProcess<T,E extends T> {
/** /**
* 获取当前节点的审批人 * 获取当前节点的审批人
* @param sysUserTprocessNode 当前节点 *
* @param departId 部门id * @param processVo 审批流程完整配置
* @param entityId 实体id * @param currentProcessNode 当前节点
* @param departId 部门id
* @param entityId 实体id
* @param auditType 审核类型 0不购买商险审核
* @return List<SysUser> * @return List<SysUser>
**/ **/
private List<SysUser> getAuditUserByTprocessNode(TProcessNode sysUserTprocessNode, String departId, String entityId, String auditType, private List<SysUser> getAuditUseListByProcessNode(ProcessVo processVo, TProcessNode currentProcessNode, String departId, String entityId, String auditType,
T entity, TAuditRecord approvalRecord) { T entity, TAuditRecord approvalRecord) {
// todo 获取当前流程 改成dapr写法 // 定义审批用户
R<ProcessVo> processVoByName = null; List<TNodePrimission> nodePrimissionList = null;
// remoteProcessService.getProcessVoByName(sysUserTprocessNode.getProcessId());
// todo 临时
if(processVoByName == null){
throw new CheckedException("未找到审批节点,请联系管理员");
}
ProcessVo processVo = processVoByName.getData();
List<TNodePrimission> nodePrimissions = null;
for (TProcessNode processNode : processVo.getProcessNodeList()) { for (TProcessNode processNode : processVo.getProcessNodeList()) {
if (StringUtils.equals(sysUserTprocessNode.getLogoTitle(), processNode.getLogoTitle())) { if (StringUtils.equals(currentProcessNode.getLogoTitle(), processNode.getLogoTitle())) {
List<TNodePrimission> nodePrimissionList = processNode.getNodePrimissionList(); nodePrimissionList = processNode.getNodePrimissionList();
if (nodePrimissionList != null && !nodePrimissionList.isEmpty()) {
nodePrimissions = nodePrimissionList;
}
} }
} }
if (Common.isEmpty(nodePrimissionList)) {
if (nodePrimissions == null) { throw new CheckedException("未找到审批用户信息,请联系管理员");
throw new CheckedException("未找到审批节点,请联系管理员");
} }
// 获取所有审批用户 // 获取所有审批用户
List<SysUser> sysUserList = new ArrayList<>(); List<SysUser> sysUserList = new ArrayList<>();
// 节点是否允许跳过(0:不允许,1允许) // 节点是否允许跳过(0:不允许,1允许)
Integer isPass = CommonConstants.ZERO_INT; Integer isPass = CommonConstants.ZERO_INT;
for (TNodePrimission nodePrimission : nodePrimissions) { for (TNodePrimission nodePrimission : nodePrimissionList) {
// 审核用户改造; 2指定权限;3指定用户;5指定角色(crm);6指定事业部配置表 // 审核用户改造; 3指定用户;5指定角色(crm)
if (CommonConstants.THREE_INT == nodePrimission.getType().intValue() if (CommonConstants.THREE_INT == nodePrimission.getType().intValue()
|| CommonConstants.TWO_INT == nodePrimission.getType().intValue() || CommonConstants.TWO_INT == nodePrimission.getType().intValue()
|| CommonConstants.FIVE_INT == nodePrimission.getType().intValue()) { || CommonConstants.FIVE_INT == nodePrimission.getType().intValue()) {
// todo sysUserList = this.getDepartAuditUser(nodePrimission, departId);
sysUserList = CommonProcessUserUtil.getDepartAuditUser(nodePrimission, departId);
} }
// 6指定事业部配置表
if (CommonConstants.SIX_INT == nodePrimission.getType().intValue()) { if (CommonConstants.SIX_INT == nodePrimission.getType().intValue()) {
// todo 根据事业部条线获取审批用户 // todo 根据事业部条线获取审批用户
sysUserList = this.getDivisionAuditUser(nodePrimission, entity); sysUserList = this.getDivisionAuditUser(nodePrimission, entity);
...@@ -153,28 +153,28 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -153,28 +153,28 @@ public abstract class AbastractAuditProcess<T,E extends T> {
// 标记节点可以跳过 // 标记节点可以跳过
isPass = CommonConstants.ONE_INT; isPass = CommonConstants.ONE_INT;
// todo 系统自动给当前节点完成审核,将审核通过 // todo 系统自动给当前节点完成审核,将审核通过
// sysAutoAudit(sysUserTprocessNode,entity,processVo); //sysAutoAudit(sysUserTprocessNode,entity,processVo);
} else { } else {
if (Common.isEmpty(sysUserList)) { if (Common.isEmpty(sysUserList)) {
throw new CheckedException("未找到审批用户"); throw new CheckedException("未找到审批用户");
} }
//微信审批通知发送 // 微信审批通知发送
//发送审批消息 // todo 发送审批消息
sendMessage(sysUserList,entity,CommonConstants.ONE_STRING,approvalRecord); sendMessage(sysUserList,entity,CommonConstants.ONE_STRING,approvalRecord);
for (SysUser sysUser : sysUserList) { for (SysUser sysUser : sysUserList) {
// 新增指派审核流程记录 // 新增指派审核流程记录
TAuditRecord newEntity = new TAuditRecord(); TAuditRecord newEntity = new TAuditRecord();
newEntity.setDomainId(entityId); newEntity.setDomainId(entityId);
newEntity.setFlowId(sysUserTprocessNode.getProcessId()); newEntity.setFlowId(currentProcessNode.getProcessId());
newEntity.setNodeId(sysUserTprocessNode.getId()); newEntity.setNodeId(currentProcessNode.getId());
newEntity.setApprovalMan(String.valueOf(sysUser.getUserId())); newEntity.setApprovalMan(String.valueOf(sysUser.getUserId()));
newEntity.setApprovalManName(sysUser.getNickname()); newEntity.setApprovalManName(sysUser.getNickname());
newEntity.setDeleteFlag(CommonConstants.NOT_DELETE_FLAG); newEntity.setDeleteFlag(CommonConstants.NOT_DELETE_FLAG);
newEntity.setPreFlag(CommonConstants.ONE_STRING); newEntity.setPreFlag(CommonConstants.ONE_STRING);
newEntity.setApprovalResult(CommonConstants.TWO_STRING); newEntity.setApprovalResult(CommonConstants.TWO_STRING);
newEntity.setNodeName(sysUserTprocessNode.getName()); newEntity.setNodeName(currentProcessNode.getName());
// 获取提交人信息 // 获取提交人信息
TAuditRecord tAuditRecord = approvalRecordService.getOne(Wrappers.<TAuditRecord>query().lambda().eq(TAuditRecord::getDomainId, entityId) TAuditRecord tAuditRecord = auditRecordService.getOne(Wrappers.<TAuditRecord>query().lambda().eq(TAuditRecord::getDomainId, entityId)
.eq(TAuditRecord::getAuditType, auditType) .eq(TAuditRecord::getAuditType, auditType)
.eq(TAuditRecord::getPreFlag, CommonConstants.ONE_STRING) .eq(TAuditRecord::getPreFlag, CommonConstants.ONE_STRING)
.eq(TAuditRecord::getApprovalResult, CommonConstants.THREE_STRING) .eq(TAuditRecord::getApprovalResult, CommonConstants.THREE_STRING)
...@@ -188,9 +188,8 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -188,9 +188,8 @@ public abstract class AbastractAuditProcess<T,E extends T> {
newEntity.setAuditType(tAuditRecord.getAuditType()); newEntity.setAuditType(tAuditRecord.getAuditType());
} }
newEntity.setCreateTime(LocalDateTime.now()); newEntity.setCreateTime(LocalDateTime.now());
approvalRecordService.save(newEntity); auditRecordService.save(newEntity);
} }
// todo 存当前审核人信息[AUDIT_USER]多个用逗号隔开
} }
...@@ -208,44 +207,41 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -208,44 +207,41 @@ public abstract class AbastractAuditProcess<T,E extends T> {
/** /**
* 提交审核:获取审核人 * 提交审核:获取审核人
* @param id 实体id * @param entityId 实体id
* @param loginUser 当前登录人 * @param loginUser 当前登录人
* @param departId 部门id 通过该部门获取审批流程 * @param departId 部门id 通过该部门获取审批流程
* @param processType 流程类型 1不购买商险申请 * @param processType 流程类型 1不购买商险申请
* @param auditType 审核类型 0不购买商险审核 * @param auditType 审核类型 0不购买商险审核
* @param reason 申请原因(非必填)
* @param entityName 实体标识信息
* @return R<List<SysUser>> * @return R<List<SysUser>>
**/ **/
public R<List<SysUser>> commitAuditUserList(String id, YifuUser loginUser, String departId, String processType, String auditType, public R<List<SysUser>> getAuditUserList(String entityId, YifuUser loginUser, String departId, String processType, String auditType,
String reason, String entityName, T entity, Class<T> clazz) { String reason, String entityName, T entity, Class<T> clazz) {
// 获取审批流程完整配置
//获取合同审批流程与下一个审核人节点 ProcessVo processVo = this.getProcessVoByType(processType);
ProcessVo processVo = null; if (Common.isEmpty(processVo)) {
//获取正确流程
TProcessApprovalConf processApprovalConf = getProcessApprovalConf(processType);
// todo 改成dapr获取
//processVo = ProcessAuditUtil.getProcessVo(remoteProcessService, processApprovalConf.getProcessId());
if (processVo == null) {
throw new CheckedException("未找到满足条件的主流程,请联系管理员"); throw new CheckedException("未找到满足条件的主流程,请联系管理员");
} }
//获取开始节点 // 获取开始节点
TProcessNode startTProcessNode = ProcessAuditUtil.getBeginProcessNode(processVo); TProcessNode startProcessNode = ProcessAuditUtil.getBeginProcessNode(processVo);
if (startTProcessNode == null) { if (Common.isEmpty(startProcessNode)) {
return R.failed(BIGIN_NODE_NO_FOUND); return R.failed(BIGIN_NODE_NO_FOUND);
} }
String currentNode = startTProcessNode.getLogoTitle(); String startNodeLogo = startProcessNode.getLogoTitle();
// 保存TAuditNodeProocess节点信息 // 保存TAuditNodeProcess节点信息
saveNodeProcess(processVo, currentNode, id, auditType); saveNodeProcess(processVo, startNodeLogo, entityId, auditType);
// 获取开始节点下一个审核节点 // 获取开始节点下一个审核节点
TProcessNode sysUserTprocessNode = getNextNode(processVo, currentNode, id, auditType, entity, loginUser); TProcessNode nextProcessNode = getNextNode(processVo, startNodeLogo, entityId, auditType, entity, loginUser);
if (sysUserTprocessNode == null) { if (Common.isEmpty(nextProcessNode)) {
throw new CheckedException(NEXT_AUDIT_NODE_NOT_FOUND); throw new CheckedException(NEXT_AUDIT_NODE_NOT_FOUND);
} }
// 记录提交审核日志 // 记录提交审核日志
TAuditRecord submitAuditRecord = new TAuditRecord(); TAuditRecord submitAuditRecord = new TAuditRecord();
submitAuditRecord.setDomainId(id); submitAuditRecord.setDomainId(entityId);
submitAuditRecord.setFlowId(startTProcessNode.getProcessId()); submitAuditRecord.setFlowId(startProcessNode.getProcessId());
submitAuditRecord.setNodeId(startTProcessNode.getId()); submitAuditRecord.setNodeId(startProcessNode.getId());
submitAuditRecord.setApprovalMan(String.valueOf(loginUser.getId())); submitAuditRecord.setApprovalMan(String.valueOf(loginUser.getId()));
submitAuditRecord.setApprovalManName(loginUser.getNickname()); submitAuditRecord.setApprovalManName(loginUser.getNickname());
// 审批结果为“提交” // 审批结果为“提交”
...@@ -256,19 +252,20 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -256,19 +252,20 @@ public abstract class AbastractAuditProcess<T,E extends T> {
submitAuditRecord.setPreFlag(CommonConstants.ONE_STRING); submitAuditRecord.setPreFlag(CommonConstants.ONE_STRING);
submitAuditRecord.setSubmitMan(String.valueOf(loginUser.getId())); submitAuditRecord.setSubmitMan(String.valueOf(loginUser.getId()));
submitAuditRecord.setSubmitManName(loginUser.getNickname()); submitAuditRecord.setSubmitManName(loginUser.getNickname());
//申请原因 // 申请原因
submitAuditRecord.setReason(reason); submitAuditRecord.setReason(reason);
//审核类型 // 审核类型
submitAuditRecord.setAuditType(auditType); submitAuditRecord.setAuditType(auditType);
submitAuditRecord.setCreateTime(LocalDateTime.now()); submitAuditRecord.setCreateTime(LocalDateTime.now());
submitAuditRecord.setNodeName("提交"); // 提交节点名称
submitAuditRecord.setNodeName(startProcessNode.getName());
submitAuditRecord.setSubmitCreateTime(LocalDateTime.now()); submitAuditRecord.setSubmitCreateTime(LocalDateTime.now());
submitAuditRecord.setEntityName(entityName); submitAuditRecord.setEntityName(entityName);
approvalRecordService.save(submitAuditRecord); auditRecordService.save(submitAuditRecord);
// 获取节点审核人 // 获取节点审核人
List<SysUser> remoteSysUserList = getAuditUserByTprocessNode(sysUserTprocessNode, departId, id, auditType,entity, submitAuditRecord); List<SysUser> remoteSysUserList = getAuditUseListByProcessNode(processVo, nextProcessNode, departId, entityId, auditType, entity, submitAuditRecord);
if (remoteSysUserList == null) { if (Common.isEmpty(remoteSysUserList)) {
throw new CheckedException(NEXT_NODE_USER_NULL); throw new CheckedException(NEXT_NODE_USER_NULL);
} }
return new R<>(remoteSysUserList); return new R<>(remoteSysUserList);
...@@ -289,24 +286,24 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -289,24 +286,24 @@ public abstract class AbastractAuditProcess<T,E extends T> {
String auditType, T entity, String departId) { String auditType, T entity, String departId) {
String loginUserId = loginUser.getId(); String loginUserId = loginUser.getId();
// 判断当前审核是否为最新待审核记录 // 判断当前审核是否为最新待审核记录
List<TAuditRecord> approvalRecords = approvalRecordService.list List<TAuditRecord> auditRecordList = auditRecordService.list
(Wrappers.<TAuditRecord>query().lambda().eq(TAuditRecord::getDomainId, id) (Wrappers.<TAuditRecord>query().lambda().eq(TAuditRecord::getDomainId, id)
.eq(TAuditRecord::getAuditType, auditType) .eq(TAuditRecord::getAuditType, auditType)
.eq(TAuditRecord::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG) .eq(TAuditRecord::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG)
.eq(TAuditRecord::getApprovalResult, CommonConstants.TWO_STRING) .eq(TAuditRecord::getApprovalResult, CommonConstants.TWO_STRING)
.eq(TAuditRecord::getApprovalMan, loginUserId)); .eq(TAuditRecord::getApprovalMan, loginUserId));
if (approvalRecords.size() != CommonConstants.ONE_INT) { if (auditRecordList.size() != CommonConstants.ONE_INT) {
return R.failed("当前用户不能审核该记录"); return R.failed("当前用户不能审核该记录");
} }
// 更新审核记录信息 // 更新审核记录信息
TAuditRecord approvalRecord = approvalRecords.get(0); TAuditRecord auditRecord = auditRecordList.get(0);
approvalRecord.setApprovalResult(approvalResult); auditRecord.setApprovalResult(approvalResult);
approvalRecord.setApprovalOpinion(approvalOpinion); auditRecord.setApprovalOpinion(approvalOpinion);
approvalRecord.setApprovalTime(LocalDateTime.now()); auditRecord.setApprovalTime(LocalDateTime.now());
approvalRecordService.updateById(approvalRecord); auditRecordService.updateById(auditRecord);
// 移除同一个节点的另外审批人。多个节点一个人审批就够了,其他都移除 // 移除同一个节点的另外审批人。多个节点一个人审批就够了,其他都移除
approvalRecordService.remove(Wrappers.<TAuditRecord>query().lambda() auditRecordService.remove(Wrappers.<TAuditRecord>query().lambda()
.eq(TAuditRecord::getDomainId, id) .eq(TAuditRecord::getDomainId, id)
.eq(TAuditRecord::getAuditType, auditType) .eq(TAuditRecord::getAuditType, auditType)
.isNull(TAuditRecord::getApprovalTime)); .isNull(TAuditRecord::getApprovalTime));
...@@ -315,139 +312,131 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -315,139 +312,131 @@ public abstract class AbastractAuditProcess<T,E extends T> {
if (CommonConstants.ZERO_STRING.equals(approvalResult)) { if (CommonConstants.ZERO_STRING.equals(approvalResult)) {
// 获取流程,并判断是否是最后一个节点 // 获取流程,并判断是否是最后一个节点
// 获取流程的主流程 // 获取流程的主流程
TAuditNodeProocess auditNodeProocess = auditNodeProocessService.getOne(Wrappers.<TAuditNodeProocess>query().lambda() TAuditNodeProcess auditNodeProocess = auditNodeProcessService.getOne(Wrappers.<TAuditNodeProcess>query().lambda()
.eq(TAuditNodeProocess::getDomainId, id) .eq(TAuditNodeProcess::getDomainId, id)
.eq(TAuditNodeProocess::getType, auditType) .eq(TAuditNodeProcess::getType, auditType)
.eq(TAuditNodeProocess::getMainType, CommonConstants.ZERO_STRING) .eq(TAuditNodeProcess::getMainType, CommonConstants.ZERO_STRING)
.eq(TAuditNodeProocess::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG) .eq(TAuditNodeProcess::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG)
.orderByDesc(TAuditNodeProocess::getId) .orderByDesc(TAuditNodeProcess::getId)
.last(CommonConstants.SQL_LIMIT_ONE)); .last(CommonConstants.SQL_LIMIT_ONE));
if (auditNodeProocess == null) { if (auditNodeProocess == null) {
throw new CheckedException("未获取到审批记录流程数据"); throw new CheckedException("未获取到审批记录流程数据");
} }
// todo 改成dapr获取 // 改成dapr获取
ProcessVo processVo = null; ProcessVo processVo = this.getProcessVoById(auditNodeProocess.getProcessId());
// ProcessAuditUtil.getProcessVo(remoteProcessService, auditNodeProocess.getProcessId());
// todo 临时
if (processVo == null) {
throw new CheckedException("未获取到结束节点");
}
TProcessNode endProcessNode = ProcessAuditUtil.getEndProcessNode(processVo); TProcessNode endProcessNode = ProcessAuditUtil.getEndProcessNode(processVo);
if (endProcessNode == null) { if (endProcessNode == null) {
throw new CheckedException("未获取到结束节点"); throw new CheckedException("未获取到结束节点");
} }
TProcessNode preEndProcessNode = ProcessAuditUtil.getPreEndTProcessNode(processVo, endProcessNode);
TProcessNode preEndTProcessNode = ProcessAuditUtil.getPreEndTProcessNode(processVo, endProcessNode); if (preEndProcessNode == null) {
if (preEndTProcessNode == null) {
throw new CheckedException("未找到结束节点前一个节点"); throw new CheckedException("未找到结束节点前一个节点");
} }
// 当前是结束节点前的一个节点 // 当前是结束节点前的一个节点
if (StringUtils.equals(preEndTProcessNode.getId(), approvalRecord.getNodeId())) { if (StringUtils.equals(preEndProcessNode.getId(), auditRecord.getNodeId())) {
// 走审核通过处理 // 走审核通过处理
return auditSuccess(entity, approvalRecord, loginUser); return auditSuccess(entity, auditRecord, loginUser);
} else { } else {
// todo 改成dapr——获取自动下一个审核人 TProcessNode currentProcessNode = ProcessAuditUtil.getCurrentProcessNode(processVo, auditRecord.getNodeId());
// 获取流程的下一个节点,可能下一个节点是子流程,也可能是主节点,所以重新获取当前执行审批的流程和节点 TProcessNode nextProcessNode = getNextNode(processVo, currentProcessNode.getLogoTitle(), id, auditType, entity, loginUser);
ProcessVo processVoByApproval = null; if (nextProcessNode == null) {
// ProcessAuditUtil.getProcessVo(remoteProcessService, approvalRecord.getFlowId());
// todo 临时
if (processVoByApproval == null) {
throw new CheckedException("未获取到下一个审核人节点");
}
// todo 判断当前是否是当前审核节点到下一个审核节点前的加签节点
TProcessNode currentProcessNode = ProcessAuditUtil.getCurrentProcessNode(processVoByApproval, approvalRecord.getNodeId());
TProcessNode sysUserTprocessNode = getNextNode(processVoByApproval, currentProcessNode.getLogoTitle(), id, auditType, entity, loginUser);
if (sysUserTprocessNode == null) {
throw new CheckedException(NEXT_AUDIT_NODE_NOT_FOUND); throw new CheckedException(NEXT_AUDIT_NODE_NOT_FOUND);
} }
auditNodeProocess = auditNodeProcessService.getOne(Wrappers.<TAuditNodeProcess>query().lambda()
auditNodeProocess = auditNodeProocessService.getOne(Wrappers.<TAuditNodeProocess>query().lambda() .eq(TAuditNodeProcess::getDomainId, id)
.eq(TAuditNodeProocess::getDomainId, id) .eq(TAuditNodeProcess::getType, auditType)
.eq(TAuditNodeProocess::getType, auditType) .eq(TAuditNodeProcess::getMainType, CommonConstants.ZERO_STRING)
.eq(TAuditNodeProocess::getMainType, CommonConstants.ZERO_STRING) .eq(TAuditNodeProcess::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG)
.eq(TAuditNodeProocess::getDeleteFlag, CommonConstants.NOT_DELETE_FLAG) .orderByDesc(TAuditNodeProcess::getId)
.orderByDesc(TAuditNodeProocess::getId)
.last(CommonConstants.SQL_LIMIT_ONE)); .last(CommonConstants.SQL_LIMIT_ONE));
// 如果返回的是end节点:判断是不是返回的是不是主流程结束节点 // 如果返回的是end节点:判断是不是返回的是不是主流程结束节点
if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, sysUserTprocessNode.getType()) if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, nextProcessNode.getType())
&& StringUtils.equals(auditNodeProocess.getProcessId(), sysUserTprocessNode.getProcessId())) { && StringUtils.equals(auditNodeProocess.getProcessId(), nextProcessNode.getProcessId())) {
//审核通过流程 // 审核通过流程
return auditSuccess(entity, approvalRecord, loginUser); return auditSuccess(entity, auditRecord, loginUser);
} }
// 获取审批用户 // 获取审批用户
List<SysUser> remoteSysUserList = getAuditUserByTprocessNode(sysUserTprocessNode, departId, id, auditType, entity, approvalRecord); List<SysUser> remoteSysUserList = getAuditUseListByProcessNode(processVo,nextProcessNode, departId, id, auditType, entity, auditRecord);
if (remoteSysUserList == null) { if (Common.isEmpty(remoteSysUserList)) {
throw new CheckedException(NEXT_NODE_USER_NULL); throw new CheckedException(NEXT_NODE_USER_NULL);
} }
// 流程中的审核结束,继续下一个节点 // 流程中的审核结束,继续下一个节点
return auditSuccessAndNex(entity, remoteSysUserList, approvalRecord); return auditSuccessAndNex(entity, remoteSysUserList, auditRecord);
} }
} else { } else {
//审核不通过处理 //审核不通过处理
return auditFail(entity, approvalRecord); return auditFail(entity, auditRecord);
} }
} }
/** /**
* 获取下一个节点 * 获取下一个节点信息
* @param processVo 流程记录 * @param processVo 当前流程配置信息
* @param currentNodeString 当前节点 * @param currentNodeLogo 当前节点标识
* @param id 实体id * @param entityId 实体ID
**/ * @param auditType 审核类型 0不购买商险审核
private TProcessNode getNextNode(ProcessVo processVo, String currentNodeString, String id, String auditType, T entity, YifuUser loginUser) { * @param entity 实体信息
* @param loginUser 登录人信息
// 判断进行到的节点当前流程是主流程还是子流程,如果是主流程,则进行主流程,如果是子流程,则进行子流程判断 * @return TProcessNode
TAuditNodeProocess auditNodeProocess = auditNodeProocessService.getOne(Wrappers.<TAuditNodeProocess>query().lambda() **/
.eq(TAuditNodeProocess::getDomainId, id) private TProcessNode getNextNode(ProcessVo processVo, String currentNodeLogo, String entityId, String auditType, T entity, YifuUser loginUser) {
.eq(TAuditNodeProocess::getType, auditType)
.eq(TAuditNodeProocess::getDeleteFlag, CommonConstants.ZERO_STRING) // 获取已经过的节点信息
.isNotNull(TAuditNodeProocess::getLogoTitle) TAuditNodeProcess auditNodeProcess = auditNodeProcessService.getOne(Wrappers.<TAuditNodeProcess>query().lambda()
.orderByDesc(TAuditNodeProocess::getId).last(CommonConstants.SQL_LIMIT_ONE)); .eq(TAuditNodeProcess::getDomainId, entityId)
// 流程预览功能无需判断当前节点是否一致 .eq(TAuditNodeProcess::getType, auditType)
if (auditNodeProocess != null && !StringUtils.equals(currentNodeString, auditNodeProocess.getLogoTitle())) { .eq(TAuditNodeProcess::getDeleteFlag, CommonConstants.ZERO_STRING)
.isNotNull(TAuditNodeProcess::getLogoTitle)
.orderByDesc(TAuditNodeProcess::getId).last(CommonConstants.SQL_LIMIT_ONE));
if (Common.isNotNull(auditNodeProcess) && !StringUtils.equals(currentNodeLogo, auditNodeProcess.getLogoTitle())) {
throw new CheckedException("记录的流程节点和当前执行节点不匹配"); throw new CheckedException("记录的流程节点和当前执行节点不匹配");
} }
// 当前流程配置节点信息
List<TProcessNode> processNodeList = processVo.getProcessNodeList(); List<TProcessNode> processNodeList = processVo.getProcessNodeList();
// 当前流程配置路由信息
List<TNodeRoute> nodeRouteList = processVo.getNodeRouteList(); List<TNodeRoute> nodeRouteList = processVo.getNodeRouteList();
//判断当前节点类型,如果是选择节点则进行条件表达式判断判断 // 判断当前节点类型,如果是选择节点则进行条件表达式判断判断
TProcessNode currentNode = null; TProcessNode currentNode = null;
for (TProcessNode processNode : processNodeList) { for (TProcessNode processNode : processNodeList) {
if (StringUtils.equals(currentNodeString, processNode.getLogoTitle())) { if (StringUtils.equals(currentNodeLogo, processNode.getLogoTitle())) {
currentNode = processNode; currentNode = processNode;
} }
} }
if (currentNode == null) { if (Common.isEmpty(currentNode)) {
throw new CheckedException("未获取到当前节点"); throw new CheckedException("未获取到当前节点");
} }
// 当前节点为选择节点,获取当前节点路由类型
if (StringUtils.equals(ProcessConstants.PROCESS_NODE_TYPE_CHOICE, currentNode.getType())) { if (StringUtils.equals(ProcessConstants.PROCESS_NODE_TYPE_CHOICE, currentNode.getType())) {
// 当前节点为选择节点,获取当前节点路由类型
List<TNodeRouteCondition> nodeRouteConditionList = Lists.newArrayList(); List<TNodeRouteCondition> nodeRouteConditionList = Lists.newArrayList();
for (TNodeRoute nodeRoute : nodeRouteList) { for (TNodeRoute nodeRoute : nodeRouteList) {
// 获取选择节点下的判断分支信息存到nodeRouteConditionList
if (StringUtils.equals(currentNode.getLogoTitle(), nodeRoute.getPrewNode())) { if (StringUtils.equals(currentNode.getLogoTitle(), nodeRoute.getPrewNode())) {
nodeRouteConditionList.addAll(nodeRoute.getNodeRouteConditionList()); nodeRouteConditionList.addAll(nodeRoute.getNodeRouteConditionList());
} }
} }
// 根据判断条件获取下一个审批节点信息
return choiceGetNode(processVo, nodeRouteList, nodeRouteConditionList, currentNode, entity, auditType, loginUser); return choiceGetNode(processVo, nodeRouteList, nodeRouteConditionList, currentNode, entity, auditType, loginUser);
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, currentNode.getType())) {
// 当前到了结束节点
TProcessNode endNode = ProcessAuditUtil.getEndProcessNode(processVo); TProcessNode endNode = ProcessAuditUtil.getEndProcessNode(processVo);
if (StringUtils.equals(currentNode.getId(), endNode.getId())) { if (StringUtils.equals(currentNode.getId(), endNode.getId())) {
return endNode; return endNode;
} else { } else {
throw new CheckedException("当前不是结束节点"); throw new CheckedException("当前不是结束节点");
} }
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, currentNode.getType()) || StringUtils.equals(ProcessConstants.PROCESS_NODE_SERVICE, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, currentNode.getType())
//查找下个节点 || StringUtils.equals(ProcessConstants.PROCESS_NODE_SERVICE, currentNode.getType())) {
// 当前是开始节点或者服务节点
try { try {
TNodeRoute nexTNodeRoute = ProcessAuditUtil.getNexTNodeRoute(nodeRouteList, currentNodeString); // 查找节点后的路由信息
saveNodeProcess(processVo, nexTNodeRoute.getNextNode(), id, auditType); TNodeRoute nexNodeRoute = ProcessAuditUtil.getNexTNodeRoute(nodeRouteList, currentNodeLogo);
return validateTwoNextNode(processVo, nexTNodeRoute.getNextNode(), id, nexTNodeRoute.getRouteType(), auditType, entity, loginUser); // 存下一个节点的信息
saveNodeProcess(processVo, nexNodeRoute.getNextNode(), entityId, auditType);
// 校验即将进入的节点信息,是审批节点返回节点信息,不是继续找下一个节点信息
return validateNextNode(processVo, nexNodeRoute.getNextNode(), entityId, nexNodeRoute.getRouteType(), auditType, entity, loginUser);
}catch (Exception e){ }catch (Exception e){
if (Common.isEmpty(processVo.getIsPreview())){ // todo 优化报错展示形式
throw e; throw e;
}
return null;
} }
} else { } else {
throw new CheckedException("未知的流程节点类型"); throw new CheckedException("未知的流程节点类型");
...@@ -455,111 +444,165 @@ public abstract class AbastractAuditProcess<T,E extends T> { ...@@ -455,111 +444,165 @@ public abstract class AbastractAuditProcess<T,E extends T> {
} }
/** /**
* 通过表中配置的字段名称去取对应判断条件 * 校验即将进入的节点信息,是审批节点返回节点信息,不是继续找下一个节点信息
* @param type 流程类型:类型 1不购买商险申请 * @param processVo 流程配置信息
* @return TProcessApprovalConf * @param currentNodeLogo 当前节点标识
**/ * @param entityId 实体id
private TProcessApprovalConf getProcessApprovalConf(String type) { * @param preRouteType 上一个路由类型
return null; * @param auditType 审核类型 0不购买商险审核
// todo 找到对应的流程查看判断的类名和字段名
// R<TProcessApprovalConf> processApprovalConfR = remoteProcessService.getRecordbyTypeAndParentId(type);
// if (processApprovalConfR != null && processApprovalConfR.getData() != null && CommonConstants.SUCCESS == processApprovalConfR.getCode()) {
// return processApprovalConfR.getData();
// } else {
// throw new CheckedException("未获取到对应流程配置");
// }
// throw new CheckedException("调用流程服务返回数据为空");
}
/**
* 校验下一个节点
* @param processVo 流程配置信息
* @param currentNodeString 当前节点
* @param id 实体id
* @param routeType 上一个路由类型
* @return TProcessNode * @return TProcessNode
**/ **/
protected TProcessNode validateTwoNextNode(ProcessVo processVo, String currentNodeString, String id, String routeType, String auditType, protected TProcessNode validateNextNode(ProcessVo processVo, String currentNodeLogo, String entityId, String preRouteType, String auditType,
T entity, YifuUser loginUser) { T entity, YifuUser loginUser) {
// 获取节点配置信息
List<TProcessNode> processNodeList = processVo.getProcessNodeList(); List<TProcessNode> processNodeList = processVo.getProcessNodeList();
// 判断当前节点类型,如果是选择节点则进行条件表达式判断判断 // 获取即将进入的节点信息
TProcessNode currentNode = null; TProcessNode currentNode = null;
for (TProcessNode processNode : processNodeList) { for (TProcessNode processNode : processNodeList) {
if (StringUtils.equals(currentNodeString, processNode.getLogoTitle())) { if (StringUtils.equals(currentNodeLogo, processNode.getLogoTitle())) {
currentNode = processNode; currentNode = processNode;
} }
} }
if(Common.isEmpty(currentNode)){ if(Common.isEmpty(currentNode)){
throw new CheckedException("未获取到当前节点,请联系管理员处理"); throw new CheckedException("未获取到当前节点,请联系管理员处理");
} }
// 1.7.5 未引入抄送逻辑:获取下个抄送节点信息(暂未引入) // 即将进入的节点是选择判断节点,继续往找下一个节点信息
if (StringUtils.equals(ProcessConstants.PROCESS_NODE_TYPE_CHOICE, currentNode.getType())) { if (StringUtils.equals(ProcessConstants.PROCESS_NODE_TYPE_CHOICE, currentNode.getType())) {
return getNextNode(processVo, currentNodeString, id, auditType, entity, loginUser); return getNextNode(processVo, currentNodeLogo, entityId, auditType, entity, loginUser);
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_SERVICE, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_SERVICE, currentNode.getType())) {
if (StringUtils.equals(routeType, CommonConstants.ONE_STRING)) { // 即将进入的节点是选择服务节点,继续根据路由判断
// 是审批节点 if (StringUtils.equals(preRouteType, CommonConstants.ONE_STRING)) {
// 即将进入的节点是审批节点,返回节点信息
return currentNode; return currentNode;
} else if (StringUtils.equals(routeType, CommonConstants.THREE_STRING)) { } else if (StringUtils.equals(preRouteType, CommonConstants.THREE_STRING)) {
// 1.7.5 未引入抄送逻辑 // 1.7.5 未引入抄送逻辑
// 继续找下一个节点 // 即将进入的节点是抄送节点,继续找下一个节点
return getNextNode(processVo, currentNode.getLogoTitle(), id, auditType, entity, loginUser); return getNextNode(processVo, currentNode.getLogoTitle(), entityId, auditType, entity, loginUser);
} else { } else {
throw new CheckedException("未知的节点"); throw new CheckedException("未知的节点");
} }
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_BEGIN, currentNode.getType())) {
return getNextNode(processVo, currentNode.getLogoTitle(), id, auditType, entity, loginUser); return getNextNode(processVo, currentNode.getLogoTitle(), entityId, auditType, entity, loginUser);
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_END, currentNode.getType())) {
return getNextNode(processVo, currentNode.getLogoTitle(), id, auditType, entity, loginUser); return getNextNode(processVo, currentNode.getLogoTitle(), entityId, auditType, entity, loginUser);
} else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_EMBED, currentNode.getType())) { } else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_EMBED, currentNode.getType())) {
return getNextNode(processVo, currentNode.getLogoTitle(), id, auditType, entity, loginUser); return getNextNode(processVo, currentNode.getLogoTitle(), entityId, auditType, entity, loginUser);
} else { } else {
throw new CheckedException("未知的节点"); throw new CheckedException("未知的节点");
} }
} }
/** /**
* 保存经过流程节点记录 * 保存经过流程节点记录
* @param processVo * @param processVo 当前流程配置信息
* @param nextNodeString * @param currentNodeLogo 当前节点标识
* @param entityId * @param entityId 实体ID
* @param type 审核类型 0不购买商险审核
**/ **/
protected void saveNodeProcess(ProcessVo processVo, String nextNodeString, String entityId, String type) { protected void saveNodeProcess(ProcessVo processVo, String currentNodeLogo, String entityId, String type) {
// 当前节点的信息
TProcessNode processNode = null; TProcessNode processNode = null;
for (TProcessNode node : processVo.getProcessNodeList()) { for (TProcessNode node : processVo.getProcessNodeList()) {
if (StringUtils.equals(nextNodeString, node.getLogoTitle())) { if (StringUtils.equals(currentNodeLogo, node.getLogoTitle())) {
processNode = node; processNode = node;
} }
} }
if (processNode == null) { // todo 优化报错展示形式
throw new CheckedException("节点id为空"); if (Common.isEmpty(processNode)) {
throw new CheckedException("保存经过流程节点记录时,节点信息未找到");
} }
TAuditNodeProocess auditNodeProocess = new TAuditNodeProocess(); // 保存本次节点记录
saveProcessNodeProcess(processVo, entityId, type, processNode, auditNodeProocess); TAuditNodeProcess auditNodeProcess = new TAuditNodeProcess();
auditNodeProcess.setDomainId(entityId);
auditNodeProcess.setNodeId(processNode.getId());
auditNodeProcess.setProcessId(processNode.getProcessId());
auditNodeProcess.setCreateTime(LocalDateTime.now());
// 新版流程审批默认主节点
auditNodeProcess.setMainType(CommonConstants.ZERO_STRING);
auditNodeProcess.setLogoTitle(processNode.getLogoTitle());
auditNodeProcess.setNodeType(processNode.getType());
auditNodeProcess.setNodeName(processNode.getName());
auditNodeProcess.setProcessName(processVo.getName());
auditNodeProcess.setDeleteFlag(CommonConstants.ZERO_STRING);
auditNodeProcess.setType(type);
auditNodeProcessService.save(auditNodeProcess);
} }
/** /**
* 保存经过流程节点记录 * 根据流程类型查询ProcessVo
* @param processVo * @param processType 流程类型
* @param entityId * @return R<ProcessVo>
* @param processNode * @since mvp1.7.5
* @param auditNodeProocess **/
**/ private ProcessVo getProcessVoByType(String processType) {
private void saveProcessNodeProcess(ProcessVo processVo, String entityId, String type, TProcessNode processNode, TAuditNodeProocess auditNodeProocess) { // 改成dapr请求
auditNodeProocess.setDomainId(entityId); R<ProcessVo> processVoR = processDaprUtils.getProcessVoByType(processType);
auditNodeProocess.setNodeId(processNode.getId()); if (processVoR == null) {
auditNodeProocess.setProcessId(processNode.getProcessId()); throw new CheckedException("调用流程服务返回为空");
auditNodeProocess.setCreateTime(LocalDateTime.now()); }
if (CommonConstants.SUCCESS != processVoR.getCode()) {
// todo 新版流程审批默认主节点 throw new CheckedException("调用流程服务返回失败");
auditNodeProocess.setMainType(CommonConstants.ZERO_STRING); }
ProcessVo processVo = processVoR.getData();
auditNodeProocess.setLogoTitle(processNode.getLogoTitle()); if (processVo == null) {
auditNodeProocess.setNodeType(processNode.getType()); throw new CheckedException("调用流程服务返回数据为空");
auditNodeProocess.setNodeName(processNode.getName()); }
auditNodeProocess.setProcessName(processVo.getName()); return processVo;
auditNodeProocess.setDeleteFlag(CommonConstants.ZERO_STRING); }
auditNodeProocess.setType(type);
auditNodeProocessService.save(auditNodeProocess); /**
} * 根据流程Id查询ProcessVo
* @param processId 流程Id
* @return R<ProcessVo>
* @since mvp1.7.5
**/
private ProcessVo getProcessVoById(String processId) {
// 改成dapr请求
R<ProcessVo> processVoR = processDaprUtils.getProcessVoById(processId);
if (processVoR == null) {
throw new CheckedException("调用流程服务返回为空");
}
if (CommonConstants.SUCCESS != processVoR.getCode()) {
throw new CheckedException("调用流程服务返回失败");
}
ProcessVo processVo = processVoR.getData();
if (processVo == null) {
throw new CheckedException("调用流程服务返回数据为空");
}
return processVo;
}
/**
* 获取crm部门审核人
* @param nodePrimission
* @param departId
* @return List<SysUser>
**/
private List<SysUser> getDepartAuditUser(TNodePrimission nodePrimission, String departId) {
List<SysUser> remoteSysUserList = new ArrayList<>();
if (CommonConstants.THREE_INT == nodePrimission.getType().intValue()) {
// 3.指定用户
if (Common.isEmpty(nodePrimission.getUser())) {
throw new CheckedException("未查询当前流程权限对应的用户");
}
// 通过用户id查询,查找当前用户
R<SysUser> simpleUser = upmsDaprUtils.getSimpleUser(nodePrimission.getUser());
if(null != simpleUser && null != simpleUser.getData()) {
remoteSysUserList.add(simpleUser.getData());
}
} else if (CommonConstants.FIVE_INT == nodePrimission.getType().intValue()){
// 5.指定角色(crm)
if (Common.isEmpty(nodePrimission.getApprovalRole())) {
throw new CheckedException("未查询当前节点配置的审核角色");
}
UserApprovalRoleVO userByApprovalRole = new UserApprovalRoleVO();
userByApprovalRole.setDepartId(departId);
userByApprovalRole.setRoleId(nodePrimission.getApprovalRole());
R<SysUserListVo> simpleUserList = upmsDaprUtils.getUserByRoleIdForCrm(userByApprovalRole);
if(null != simpleUserList && null != simpleUserList.getData()) {
remoteSysUserList = simpleUserList.getData().getUserList();
}
}
return remoteSysUserList;
}
} }
package com.yifu.cloud.plus.v1.yifu.salary.service.impl; package com.yifu.cloud.plus.v1.yifu.salary.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess; import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TAuditNodeProocessMapper; import com.yifu.cloud.plus.v1.yifu.salary.mapper.TAuditNodeProcessMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProocessService; import com.yifu.cloud.plus.v1.yifu.salary.service.TAuditNodeProcessService;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -16,6 +16,6 @@ import org.springframework.stereotype.Service; ...@@ -16,6 +16,6 @@ import org.springframework.stereotype.Service;
*/ */
@Log4j2 @Log4j2
@Service @Service
public class TAuditNodeProocessServiceImpl extends ServiceImpl<TAuditNodeProocessMapper, TAuditNodeProocess> implements TAuditNodeProocessService { public class TAuditNodeProcessServiceImpl extends ServiceImpl<TAuditNodeProcessMapper, TAuditNodeProcess> implements TAuditNodeProcessService {
} }
...@@ -8,9 +8,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -8,9 +8,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
...@@ -500,7 +502,7 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance ...@@ -500,7 +502,7 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance
if(entity==null){ if(entity==null){
return R.failed(ResultConstants.FAIL_INFO_NO_MODEL); return R.failed(ResultConstants.FAIL_INFO_NO_MODEL);
} }
if(!StringUtils.equals(entity.getStatus(),CommonConstants.ONE_STRING)){ if(!CommonConstants.ONE_STRING.equals(entity.getStatus())){
return R.failed("当前记录不为待提交状态"); return R.failed("当前记录不为待提交状态");
} }
String[] reasonType = {"1", "2"}; String[] reasonType = {"1", "2"};
...@@ -518,12 +520,29 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance ...@@ -518,12 +520,29 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance
if(Common.isEmpty(entity.getCreateUserDeptId())){ if(Common.isEmpty(entity.getCreateUserDeptId())){
return R.failed("申请人所属部门id不能为空"); return R.failed("申请人所属部门id不能为空");
} }
// 传流程类型 1不购买商险申请,审核类型 0不购买商险审核 // 传:流程类型 1不购买商险申请;审核类型 0不购买商险审核
// R<List<SysUser>> auditUserListR = tInsuranceUnpurchaseApplyAuditProcess.commitAuditUserList(id, user, entity.getCreateUserDeptId(), CommonConstants.ONE_STRING, CommonConstants.ZERO_STRING, R<List<SysUser>> auditUserListR = tInsuranceUnpurchaseApplyAuditProcess.getAuditUserList(id, user, entity.getCreateUserDeptId(),
// "",entity.getApplyNo(),entity,TInsuranceUnpurchaseApply.class); CommonConstants.ONE_STRING, CommonConstants.ZERO_STRING,
// if (auditUserListR == null || auditUserListR.getCode() != CommonConstants.SUCCESS || auditUserListR.getData() == null) { "", entity.getApplyNo(), entity, TInsuranceUnpurchaseApply.class);
// throw new CheckedException("获取审批人失败,请联系管理员"); if (auditUserListR == null || auditUserListR.getCode() != CommonConstants.SUCCESS || auditUserListR.getData() == null) {
// } throw new CheckedException("获取审批人失败,请联系管理员");
}
// 存即将审批人的信息
String auditUserNameStrs = "";
String auditUserIdStrs = "";
for(SysUser userInfo : auditUserListR.getData()){
auditUserIdStrs = auditUserIdStrs.concat(";").concat(userInfo.getUserId());
auditUserNameStrs = auditUserNameStrs.concat(";").concat(userInfo.getNickname());
}
if(Common.isNotNull(auditUserNameStrs)){
auditUserNameStrs = auditUserNameStrs.substring(1);
}
if(Common.isNotNull(auditUserIdStrs)){
auditUserIdStrs = auditUserIdStrs.substring(1);
}
entity.setAuditUser(auditUserNameStrs);
entity.setAuditUserId(auditUserIdStrs);
entity.setStatus(CommonConstants.TWO_STRING); entity.setStatus(CommonConstants.TWO_STRING);
this.updateById(entity); this.updateById(entity);
return R.ok(null,"提交成功"); return R.ok(null,"提交成功");
...@@ -532,9 +551,8 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance ...@@ -532,9 +551,8 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance
@Override @Override
@Transactional @Transactional
public R<String> auditAndCommit(TInsuranceUnpurchaseApply insuranceUnpurchaseApply, String approvalResult, String approvalOpinion, YifuUser user) { public R<String> auditAndCommit(TInsuranceUnpurchaseApply insuranceUnpurchaseApply, String approvalResult, String approvalOpinion, YifuUser user) {
return R.ok("审核完毕"); return tInsuranceUnpurchaseApplyAuditProcess.auditUserList(insuranceUnpurchaseApply.getId(), approvalResult, approvalOpinion, user, CommonConstants.ZERO_STRING,
// return tInsuranceUnpurchaseApplyAuditProcess.auditUserList(insuranceUnpurchaseApply.getId(), approvalResult, approvalOpinion, user, CommonConstants.ZERO_STRING, insuranceUnpurchaseApply, insuranceUnpurchaseApply.getCreateUserDeptId());
// insuranceUnpurchaseApply, insuranceUnpurchaseApply.getCreateUserDeptId());
} }
} }
package com.yifu.cloud.plus.v1.yifu.salary.service.impl.process; package com.yifu.cloud.plus.v1.yifu.salary.service.impl.process;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser; import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.ResultConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException; import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpDivisionInfoVo;
import com.yifu.cloud.plus.v1.yifu.salary.config.WxConfig;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditRecord;
import com.yifu.cloud.plus.v1.yifu.salary.service.TInsuranceUnpurchaseApplyService;
import com.yifu.cloud.plus.v1.yifu.salary.service.impl.AbastractAuditProcess;
import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants; import com.yifu.cloud.plus.v1.yifu.process.constant.ProcessConstants;
import com.yifu.cloud.plus.v1.yifu.process.entity.TNodePrimission; import com.yifu.cloud.plus.v1.yifu.process.entity.TNodePrimission;
import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRoute; import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRoute;
...@@ -16,15 +25,12 @@ import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRouteCondition; ...@@ -16,15 +25,12 @@ import com.yifu.cloud.plus.v1.yifu.process.entity.TNodeRouteCondition;
import com.yifu.cloud.plus.v1.yifu.process.entity.TProcessNode; import com.yifu.cloud.plus.v1.yifu.process.entity.TProcessNode;
import com.yifu.cloud.plus.v1.yifu.process.util.ProcessAuditUtil; import com.yifu.cloud.plus.v1.yifu.process.util.ProcessAuditUtil;
import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo; import com.yifu.cloud.plus.v1.yifu.process.vo.ProcessVo;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditRecord;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TInsuranceUnpurchaseApply; import com.yifu.cloud.plus.v1.yifu.salary.entity.TInsuranceUnpurchaseApply;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TInsuranceUnpurchasePerson; import com.yifu.cloud.plus.v1.yifu.salary.entity.TInsuranceUnpurchasePerson;
import com.yifu.cloud.plus.v1.yifu.salary.service.TInsuranceUnpurchaseApplyService;
import com.yifu.cloud.plus.v1.yifu.salary.service.TInsuranceUnpurchasePersonService; import com.yifu.cloud.plus.v1.yifu.salary.service.TInsuranceUnpurchasePersonService;
import com.yifu.cloud.plus.v1.yifu.salary.service.impl.AbastractAuditProcess;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TInsuranceUnpurchaseApplySearchVo; import com.yifu.cloud.plus.v1.yifu.salary.vo.TInsuranceUnpurchaseApplySearchVo;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -48,23 +54,26 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -48,23 +54,26 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
@Resource @Resource
private TInsuranceUnpurchasePersonService personService; private TInsuranceUnpurchasePersonService personService;
@Autowired
private WxConfig wxConfig;
@Override @Override
public R<String> auditSuccess(TInsuranceUnpurchaseApply entity, TAuditRecord approvalRecord, YifuUser loginUser) { public R<String> auditSuccess(TInsuranceUnpurchaseApply entity, TAuditRecord auditRecord, YifuUser loginUser) {
// 改实体审核状态为审核通过 // 改实体审核状态为审核通过
entity.setAuditFlag(CommonConstants.THREE_STRING); entity.setStatus(CommonConstants.THREE_STRING);
entity.setAuditUser(""); entity.setAuditUser("");
entity.setAuditUserId(""); entity.setAuditUserId("");
boolean res = tInsuranceUnpurchaseApplyService.updateById(entity); boolean res = tInsuranceUnpurchaseApplyService.updateById(entity);
if (res) { if (res) {
// todo 删除当前实体所有的流程节点,数据量太大影响审批效率 // 删除当前实体所有的流程节点,数据量太大影响审批效率
// 防止死锁,先查询再删除 // 防止死锁,先查询再删除
TAuditNodeProocess auditNodeProocessInfo = auditNodeProocessService.getOne(Wrappers.<TAuditNodeProocess>query().lambda() TAuditNodeProcess auditNodeProcessInfo = auditNodeProcessService.getOne(Wrappers.<TAuditNodeProcess>query().lambda()
.eq(TAuditNodeProocess::getDomainId, entity.getId()) .eq(TAuditNodeProcess::getDomainId, entity.getId())
.in(TAuditNodeProocess::getType, approvalRecord.getAuditType()) .in(TAuditNodeProcess::getType, auditRecord.getAuditType())
.last(CommonConstants.SQL_LIMIT_ONE)); .last(CommonConstants.SQL_LIMIT_ONE));
if(Common.isNotKong(auditNodeProocessInfo)) { if(Common.isNotKong(auditNodeProcessInfo)) {
auditNodeProocessService.remove(Wrappers.<TAuditNodeProocess>query().lambda().eq(TAuditNodeProocess::getDomainId, entity.getId()) auditNodeProcessService.remove(Wrappers.<TAuditNodeProcess>query().lambda().eq(TAuditNodeProcess::getDomainId, entity.getId())
.in(TAuditNodeProocess::getType, approvalRecord.getAuditType())); .in(TAuditNodeProcess::getType, auditRecord.getAuditType()));
} }
//huych--更新明细审核状态 //huych--更新明细审核状态
...@@ -79,6 +88,24 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -79,6 +88,24 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
@Override @Override
public R<String> auditSuccessAndNex(TInsuranceUnpurchaseApply entity, List<SysUser> remoteSysUserList, TAuditRecord approvalRecord) { public R<String> auditSuccessAndNex(TInsuranceUnpurchaseApply entity, List<SysUser> remoteSysUserList, TAuditRecord approvalRecord) {
if (Common.isEmpty(remoteSysUserList)) {
throw new CheckedException(NEXT_NODE_USER_NULL);
}
// 存即将审批人的信息
String auditUserNameStrs = "";
String auditUserIdStrs = "";
for(SysUser userInfo : remoteSysUserList){
auditUserIdStrs = auditUserIdStrs.concat(";").concat(userInfo.getUserId());
auditUserNameStrs = auditUserNameStrs.concat(";").concat(userInfo.getNickname());
}
if(Common.isNotNull(auditUserNameStrs)){
auditUserNameStrs = auditUserNameStrs.substring(1);
}
if(Common.isNotNull(auditUserIdStrs)){
auditUserIdStrs = auditUserIdStrs.substring(1);
}
entity.setAuditUser(auditUserNameStrs);
entity.setAuditUserId(auditUserIdStrs);
return R.ok("审核通过"); return R.ok("审核通过");
} }
...@@ -86,21 +113,21 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -86,21 +113,21 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
public R<String> auditFail(TInsuranceUnpurchaseApply entity, TAuditRecord approvalRecord) { public R<String> auditFail(TInsuranceUnpurchaseApply entity, TAuditRecord approvalRecord) {
// 以后有抄送再加逻辑:参照crm-更改之前抄送记录状态为0 // 以后有抄送再加逻辑:参照crm-更改之前抄送记录状态为0
// 改实体审核状态为审核不通过 // 改实体审核状态为审核不通过
entity.setAuditFlag(CommonConstants.FOUR_STRING); entity.setStatus(CommonConstants.FOUR_STRING);
entity.setAuditUser(""); entity.setAuditUser("");
entity.setAuditUserId(""); entity.setAuditUserId("");
tInsuranceUnpurchaseApplyService.updateById(entity); tInsuranceUnpurchaseApplyService.updateById(entity);
// todo 删除当前实体所有的流程节点,数据量太大影响审批效率 // 删除当前实体所有的流程节点,数据量太大影响审批效率
// 防止死锁,先查询再删除 // 防止死锁,先查询再删除
TAuditNodeProocess auditNodeProocessInfo = auditNodeProocessService.getOne(Wrappers.<TAuditNodeProocess>query().lambda() TAuditNodeProcess auditNodeProocessInfo = auditNodeProcessService.getOne(Wrappers.<TAuditNodeProcess>query().lambda()
.eq(TAuditNodeProocess::getDomainId, entity.getId()) .eq(TAuditNodeProcess::getDomainId, entity.getId())
.in(TAuditNodeProocess::getType, approvalRecord.getAuditType()) .in(TAuditNodeProcess::getType, approvalRecord.getAuditType())
.last(CommonConstants.SQL_LIMIT_ONE)); .last(CommonConstants.SQL_LIMIT_ONE));
if(Common.isNotKong(auditNodeProocessInfo)) { if(Common.isNotKong(auditNodeProocessInfo)) {
auditNodeProocessService.remove(Wrappers.<TAuditNodeProocess>query().lambda() auditNodeProcessService.remove(Wrappers.<TAuditNodeProcess>query().lambda()
.eq(TAuditNodeProocess::getDomainId, entity.getId()) .eq(TAuditNodeProcess::getDomainId, entity.getId())
.in(TAuditNodeProocess::getType, approvalRecord.getAuditType())); .in(TAuditNodeProcess::getType, approvalRecord.getAuditType()));
} }
return R.ok("审核成功"); return R.ok("审核成功");
...@@ -108,19 +135,23 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -108,19 +135,23 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
@Override @Override
public TProcessNode choiceGetNode(ProcessVo processVo, List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList, public TProcessNode choiceGetNode(ProcessVo processVo, List<TNodeRoute> nodeRouteList, List<TNodeRouteCondition> nodeRouteConditionList,
TProcessNode currentNode, TInsuranceUnpurchaseApply entity, String type, YifuUser loginUser) { TProcessNode currentNode, TInsuranceUnpurchaseApply entity, String auditType, YifuUser loginUser) {
// 根据不购买原因判断 1 已购买社保 2 人员已离职选择 // 根据不购买原因判断 1 已购买社保 2 人员已离职选择
if (StringUtils.equals(ProcessConstants.PROCESS_NODE_INSURANCEUNPURCHASE_REASON_TYPE,currentNode.getName())){ if (StringUtils.equals(ProcessConstants.PROCESS_NODE_INSURANCEUNPURCHASE_REASON_TYPE,currentNode.getName())){
// 通过条件表达式判断路由的下一个节点
TNodeRoute nodeRoute = ProcessAuditUtil.getTNodeRoteByExpress(nodeRouteList, nodeRouteConditionList, entity.getReasonType(), null); TNodeRoute nodeRoute = ProcessAuditUtil.getTNodeRoteByExpress(nodeRouteList, nodeRouteConditionList, entity.getReasonType(), null);
saveNodeProcess(processVo, nodeRoute.getNextNode(), entity.getId(), type); // 存下一个节点的信息
saveNodeProcess(processVo, nodeRoute.getNextNode(), entity.getId(), auditType);
return validateTwoNextNode(processVo, nodeRoute.getNextNode(), entity.getId(), nodeRoute.getRouteType(), type, entity, loginUser); // 校验即将进入的节点信息,是审批节点返回节点信息,不是继续找下一个节点信息
return validateNextNode(processVo, nodeRoute.getNextNode(), entity.getId(), nodeRoute.getRouteType(), auditType, entity, loginUser);
}else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_INSURANCEUNPURCHASE_DEPT_PROPERTY,currentNode.getName())){ }else if (StringUtils.equals(ProcessConstants.PROCESS_NODE_INSURANCEUNPURCHASE_DEPT_PROPERTY,currentNode.getName())){
// 根据申请部门 是否属于子分公司 // 根据申请部门 是否属于子分公司
// 通过条件表达式判断路由的下一个节点
TNodeRoute nodeRoute = ProcessAuditUtil.getTNodeRoteByExpress(nodeRouteList, nodeRouteConditionList, entity.getCompanyFlag(), null); TNodeRoute nodeRoute = ProcessAuditUtil.getTNodeRoteByExpress(nodeRouteList, nodeRouteConditionList, entity.getCompanyFlag(), null);
saveNodeProcess(processVo, nodeRoute.getNextNode(), entity.getId(), type); // 存下一个节点的信息
saveNodeProcess(processVo, nodeRoute.getNextNode(), entity.getId(), auditType);
return validateTwoNextNode(processVo, nodeRoute.getNextNode(), entity.getId(), nodeRoute.getRouteType(), type, entity, loginUser); // 校验即将进入的节点信息,是审批节点返回节点信息,不是继续找下一个节点信息
return validateNextNode(processVo, nodeRoute.getNextNode(), entity.getId(), nodeRoute.getRouteType(), auditType, entity, loginUser);
} else{ } else{
throw new CheckedException("未知的条件节点类型,请联系管理员"); throw new CheckedException("未知的条件节点类型,请联系管理员");
} }
...@@ -128,7 +159,7 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -128,7 +159,7 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
@Override @Override
public R<String> sendMessage(List<SysUser> users, TInsuranceUnpurchaseApply entity, String type, TAuditRecord approvalRecord) { public R<String> sendMessage(List<SysUser> users, TInsuranceUnpurchaseApply entity, String type, TAuditRecord approvalRecord) {
sendMessageToWx(users,entity,type, approvalRecord); sendMessageToWx(users,entity,type);
return R.ok(null, ResultConstants.SUCCESS_INFO); return R.ok(null, ResultConstants.SUCCESS_INFO);
} }
...@@ -148,87 +179,69 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess ...@@ -148,87 +179,69 @@ public class TInsuranceUnpurchaseApplyAuditProcess extends AbastractAuditProcess
throw new CheckedException("未查询当前节点配置的事业部审批人标识"); throw new CheckedException("未查询当前节点配置的事业部审批人标识");
} }
// todo 根据配置条件查找用户 // todo 根据配置条件查找用户
EkpDivisionInfoVo divisionInfoVo = new EkpDivisionInfoVo();
// if(CommonConstants.ZERO_STRING.equals(nodePrimission.getDivisionIdentification())){
//
// }
// remoteSysUserList = RemoteRequestUtil.getUserByDivisionConfig(remoteUserService, advancePaymentEntity.getDivision(), advancePaymentEntity.getDivisionLine(), nodePrimission.getDivisionIdentification()); // remoteSysUserList = RemoteRequestUtil.getUserByDivisionConfig(remoteUserService, advancePaymentEntity.getDivision(), advancePaymentEntity.getDivisionLine(), nodePrimission.getDivisionIdentification());
} }
return remoteSysUserList; return remoteSysUserList;
} }
/**
* 功能描述: 企业微信发送通知
* @Param: [users, customerContract, type 发送提示类型 1审批 2抄送]
*/
private void sendMessageToWx(List<SysUser> users, TInsuranceUnpurchaseApply insuranceUnpurchaseApply, String type, TAuditRecord approvalRecord) {
StringBuilder sendUser = null;
for (SysUser user : users) {
if (Common.isNotKong(user.getWxMessage())) {
if (sendUser == null) {
sendUser = new StringBuilder(user.getWxMessage());
} else {
sendUser = sendUser.append("|").append(user.getWxMessage());
}
}
} private void sendMessageToWx(List<SysUser> users, TInsuranceUnpurchaseApply insuranceUnpurchaseApply, String type) {
if (sendUser != null) {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> requestMap = new HashMap<>();
Map<String, Object> textcard = new HashMap<>();
textcard.put("title", "含风险项目不购买商险申请"); StringBuilder sendUser = null;
// todo for (SysUser user : users) {
textcard.put("page", "pages/sale/page/businessAuditDetail/businessAuditDetail?businessId="+insuranceUnpurchaseApply.getId()); if (Common.isNotKong(user.getWxMessage())) {
// todo if (sendUser == null) {
textcard.put("appid", "111"); sendUser = new StringBuilder(user.getWxMessage());
textcard.put("emphasis_first_item", false); } else {
sendUser = sendUser.append("|").append(user.getWxMessage());
}
}
}
if (sendUser != null) {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> requestMap = new HashMap<>();
String authUrl = null;
Map<String, Object> textcard = new HashMap<>();
List<Map<String,String>> contentItemList = new ArrayList<>();
Map<String,String> contentItemMap = new HashMap<>(); authUrl = String.format(SecurityConstants.WX_GET_MESSAGE_AUTH_URL, wxConfig.getCorpid(), wxConfig.getAuthUrl(), CommonConstants.SIX_STRING + insuranceUnpurchaseApply.getId());
contentItemMap.put("key", "申请人:"); textcard.put("title", "含风险项目不购买商险申请");
contentItemMap.put("value", insuranceUnpurchaseApply.getCreateName().length()>CommonConstants.THIRTY_INT?insuranceUnpurchaseApply.getCreateName().substring(CommonConstants.ZERO_INT,CommonConstants.TWENTY_SEVEN_INT)+"...":insuranceUnpurchaseApply.getCreateName());
contentItemList.add(contentItemMap);
contentItemMap = new HashMap<>();
contentItemMap.put("key", "项目编码:");
contentItemMap.put("value", insuranceUnpurchaseApply.getDeptNo());
contentItemList.add(contentItemMap);
contentItemMap = new HashMap<>(); textcard.put("url", authUrl);
contentItemMap.put("key", "项目名称:"); StringBuilder description = new StringBuilder();
contentItemMap.put("value", insuranceUnpurchaseApply.getDeptName().length()>CommonConstants.THIRTY_INT?insuranceUnpurchaseApply.getDeptName().substring(CommonConstants.ZERO_INT,CommonConstants.TWENTY_SEVEN_INT)+"...":insuranceUnpurchaseApply.getDeptName()); description.append("申请人:").append(insuranceUnpurchaseApply.getCreateName()).append("<br>");
contentItemList.add(contentItemMap); description.append("项目编码:").append(insuranceUnpurchaseApply.getDeptNo()).append("<br>");
String departName = insuranceUnpurchaseApply.getDeptName();
if(departName.length()>CommonConstants.THIRTY_INT){
departName = insuranceUnpurchaseApply.getDeptName().substring(CommonConstants.ZERO_INT,CommonConstants.TWENTY_SEVEN_INT)+"...";
}
description.append("项目名称:").append(departName).append("<br>");
// 不购买原因 1 已购买社保 2 人员已离职 // 不购买原因 1 已购买社保 2 人员已离职
Map<String,String> reasonTypeMap = new HashMap<>(); Map<String,String> reasonTypeMap = new HashMap<>();
reasonTypeMap.put("1", "已购买社保"); reasonTypeMap.put("1", "已购买社保");
reasonTypeMap.put("2", "人员已离职"); reasonTypeMap.put("2", "人员已离职");
contentItemMap = new HashMap<>(); description.append("不购买原因:").append(reasonTypeMap.get(insuranceUnpurchaseApply.getReasonType())).append("<br>");
contentItemMap.put("key", "不购买原因:"); description.append("不购买人数:").append(insuranceUnpurchaseApply.getUnbuyNum()).append("<br>");
contentItemMap.put("value", reasonTypeMap.get(insuranceUnpurchaseApply.getReasonType()));
contentItemList.add(contentItemMap);
contentItemMap = new HashMap<>();
contentItemMap.put("key", "不购买人数:");
contentItemMap.put("value", insuranceUnpurchaseApply.getUnbuyNum());
contentItemList.add(contentItemMap);
textcard.put("content_item", contentItemList);
requestMap.put("touser", sendUser);
requestMap.put("msgtype", "miniprogram_notice");
requestMap.put("miniprogram_notice", textcard);
requestMap.put("enable_id_trans", 0);
requestMap.put("enable_duplicate_check", 0);
requestMap.put("duplicate_check_interval", 1800);
// todo 必须加上header说明 等房哥的企微
// if (!wxConfig.sendAppTextCard(restTemplate, requestMap)) {
// wxConfig.sendAppTextCard(restTemplate, requestMap);
// }
}
textcard.put("description", description.toString());
requestMap.put("touser", sendUser);
requestMap.put("agentid", wxConfig.getAgentid());
requestMap.put("msgtype", "textcard");
requestMap.put("textcard", textcard);
// 必须加上header说明
if (!wxConfig.sendTextCard(restTemplate, requestMap)) {
wxConfig.sendTextCard(restTemplate, requestMap);
}
}
}
}
} }
...@@ -25,4 +25,10 @@ spring: ...@@ -25,4 +25,10 @@ spring:
idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟) idle-timeout: 60000 # 空闲连接存活最大时间,默认600000(10分钟)
maximum-pool-size: 12 # 连接池最大连接数,默认是10 maximum-pool-size: 12 # 连接池最大连接数,默认是10
auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true auto-commit: true #此属性控制从池返回的连接的默认自动提交行为,默认值:true
max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟 max-lifetime: 0 #此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
\ No newline at end of file
wx:
corpid: wwbcb090af0dfe50e5
corpsecret: 16kqEL_eU-ARwYyqLgEBWHgxm8gXVnkzv_eJMLy9NpU
agentid: 1000010
authUrl: https://test-worfu.com/yifu-auth/method/oauth/wxLogin
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TAuditNodeProocessMapper"> <mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TAuditNodeProcessMapper">
<resultMap id="tAuditNodeProocessMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProocess"> <resultMap id="tAuditNodeProcessMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TAuditNodeProcess">
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="processId" column="process_id"/> <result property="processId" column="process_id"/>
<result property="nodeId" column="node_id"/> <result property="nodeId" column="node_id"/>
...@@ -43,61 +43,61 @@ ...@@ -43,61 +43,61 @@
a.add_sign_approval_man, a.add_sign_approval_man,
a.add_sign_approval_man_name a.add_sign_approval_man_name
</sql> </sql>
<sql id="tAuditNodeProocess_where"> <sql id="tAuditNodeProcess_where">
<if test="tAuditNodeProocess != null"> <if test="tAuditNodeProcess != null">
<if test="tAuditNodeProocess.id != null and tAuditNodeProocess.id.trim() != ''"> <if test="tAuditNodeProcess.id != null and tAuditNodeProcess.id.trim() != ''">
AND a.id = #{tAuditNodeProocess.id} AND a.id = #{tAuditNodeProcess.id}
</if> </if>
<if test="tAuditNodeProocess.processId != null and tAuditNodeProocess.processId.trim() != ''"> <if test="tAuditNodeProcess.processId != null and tAuditNodeProcess.processId.trim() != ''">
AND a.process_id = #{tAuditNodeProocess.processId} AND a.process_id = #{tAuditNodeProcess.processId}
</if> </if>
<if test="tAuditNodeProocess.nodeId != null and tAuditNodeProocess.nodeId.trim() != ''"> <if test="tAuditNodeProcess.nodeId != null and tAuditNodeProcess.nodeId.trim() != ''">
AND a.node_id = #{tAuditNodeProocess.nodeId} AND a.node_id = #{tAuditNodeProcess.nodeId}
</if> </if>
<if test="tAuditNodeProocess.nodeType != null and tAuditNodeProocess.nodeType.trim() != ''"> <if test="tAuditNodeProcess.nodeType != null and tAuditNodeProcess.nodeType.trim() != ''">
AND a.node_type = #{tAuditNodeProocess.nodeType} AND a.node_type = #{tAuditNodeProcess.nodeType}
</if> </if>
<if test="tAuditNodeProocess.createTime != null"> <if test="tAuditNodeProcess.createTime != null">
AND a.create_time = #{tAuditNodeProocess.createTime} AND a.create_time = #{tAuditNodeProcess.createTime}
</if> </if>
<if test="tAuditNodeProocess.domainId != null and tAuditNodeProocess.domainId.trim() != ''"> <if test="tAuditNodeProcess.domainId != null and tAuditNodeProcess.domainId.trim() != ''">
AND a.domain_id = #{tAuditNodeProocess.domainId} AND a.domain_id = #{tAuditNodeProcess.domainId}
</if> </if>
<if test="tAuditNodeProocess.mainType != null and tAuditNodeProocess.mainType.trim() != ''"> <if test="tAuditNodeProcess.mainType != null and tAuditNodeProcess.mainType.trim() != ''">
AND a.main_type = #{tAuditNodeProocess.mainType} AND a.main_type = #{tAuditNodeProcess.mainType}
</if> </if>
<if test="tAuditNodeProocess.logoTitle != null and tAuditNodeProocess.logoTitle.trim() != ''"> <if test="tAuditNodeProcess.logoTitle != null and tAuditNodeProcess.logoTitle.trim() != ''">
AND a.logo_title = #{tAuditNodeProocess.logoTitle} AND a.logo_title = #{tAuditNodeProcess.logoTitle}
</if> </if>
<if test="tAuditNodeProocess.nodeName != null and tAuditNodeProocess.nodeName.trim() != ''"> <if test="tAuditNodeProcess.nodeName != null and tAuditNodeProcess.nodeName.trim() != ''">
AND a.node_name = #{tAuditNodeProocess.nodeName} AND a.node_name = #{tAuditNodeProcess.nodeName}
</if> </if>
<if test="tAuditNodeProocess.processName != null and tAuditNodeProocess.processName.trim() != ''"> <if test="tAuditNodeProcess.processName != null and tAuditNodeProcess.processName.trim() != ''">
AND a.process_name = #{tAuditNodeProocess.processName} AND a.process_name = #{tAuditNodeProcess.processName}
</if> </if>
<if test="tAuditNodeProocess.parentProcessId != null and tAuditNodeProocess.parentProcessId.trim() != ''"> <if test="tAuditNodeProcess.parentProcessId != null and tAuditNodeProcess.parentProcessId.trim() != ''">
AND a.parent_process_id = #{tAuditNodeProocess.parentProcessId} AND a.parent_process_id = #{tAuditNodeProcess.parentProcessId}
</if> </if>
<if test="tAuditNodeProocess.deleteFlag != null and tAuditNodeProocess.deleteFlag.trim() != ''"> <if test="tAuditNodeProcess.deleteFlag != null and tAuditNodeProcess.deleteFlag.trim() != ''">
AND a.delete_flag = #{tAuditNodeProocess.deleteFlag} AND a.delete_flag = #{tAuditNodeProcess.deleteFlag}
</if> </if>
<if test="tAuditNodeProocess.type != null and tAuditNodeProocess.type.trim() != ''"> <if test="tAuditNodeProcess.type != null and tAuditNodeProcess.type.trim() != ''">
AND a.type = #{tAuditNodeProocess.type} AND a.type = #{tAuditNodeProcess.type}
</if> </if>
<if test="tAuditNodeProocess.addSignParentNodeId != null and tAuditNodeProocess.addSignParentNodeId.trim() != ''"> <if test="tAuditNodeProcess.addSignParentNodeId != null and tAuditNodeProcess.addSignParentNodeId.trim() != ''">
AND a.add_sign_parent_node_id = #{tAuditNodeProocess.addSignParentNodeId} AND a.add_sign_parent_node_id = #{tAuditNodeProcess.addSignParentNodeId}
</if> </if>
<if test="tAuditNodeProocess.addSignDepartmentId != null and tAuditNodeProocess.addSignDepartmentId.trim() != ''"> <if test="tAuditNodeProcess.addSignDepartmentId != null and tAuditNodeProcess.addSignDepartmentId.trim() != ''">
AND a.add_sign_department_id = #{tAuditNodeProocess.addSignDepartmentId} AND a.add_sign_department_id = #{tAuditNodeProcess.addSignDepartmentId}
</if> </if>
<if test="tAuditNodeProocess.domainName != null and tAuditNodeProocess.domainName.trim() != ''"> <if test="tAuditNodeProcess.domainName != null and tAuditNodeProcess.domainName.trim() != ''">
AND a.domain_name = #{tAuditNodeProocess.domainName} AND a.domain_name = #{tAuditNodeProcess.domainName}
</if> </if>
<if test="tAuditNodeProocess.addSignApprovalMan != null and tAuditNodeProocess.addSignApprovalMan.trim() != ''"> <if test="tAuditNodeProcess.addSignApprovalMan != null and tAuditNodeProcess.addSignApprovalMan.trim() != ''">
AND a.add_sign_approval_man = #{tAuditNodeProocess.addSignApprovalMan} AND a.add_sign_approval_man = #{tAuditNodeProcess.addSignApprovalMan}
</if> </if>
<if test="tAuditNodeProocess.addSignApprovalManName != null and tAuditNodeProocess.addSignApprovalManName.trim() != ''"> <if test="tAuditNodeProcess.addSignApprovalManName != null and tAuditNodeProcess.addSignApprovalManName.trim() != ''">
AND a.add_sign_approval_man_name = #{tAuditNodeProocess.addSignApprovalManName} AND a.add_sign_approval_man_name = #{tAuditNodeProcess.addSignApprovalManName}
</if> </if>
</if> </if>
</sql> </sql>
......
package com.yifu.cloud.plus.v1.yifu.admin.api.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author chenyuxi
* @date 2025/01/15
* @since 1.7.5
*/
@Data
public class UserApprovalRoleVO implements Serializable {
private static final long serialVersionUID = 1L;
private String departId;
private String roleId;
}
...@@ -589,4 +589,31 @@ public class UserController { ...@@ -589,4 +589,31 @@ public class UserController {
public R<String> updateUserAndDept(HttpServletRequest request,@RequestBody JSONObject json) { public R<String> updateUserAndDept(HttpServletRequest request,@RequestBody JSONObject json) {
return userService.updateUserAndDept(request,json); return userService.updateUserAndDept(request,json);
} }
/**
* 查询流程配置审批角色对应的审批人
*
* @param userByApprovalRole
* @author chenyuxi
* @date 2025-01-10 17:47:32
* @since 1.7.5
**/
@Inner
@PostMapping("/inner/getUser/getUserByRoleIdForCrm")
public SysUserListVo getUserByRoleIdForCrm(UserApprovalRoleVO userByApprovalRole) {
SysUserListVo naVo = new SysUserListVo();
if (Common.isEmpty(userByApprovalRole.getDepartId()) || Common.isEmpty(userByApprovalRole.getRoleId())) {
return naVo;
}
List<SysUser> sysUsers = userService.getUserByRoleIdForCrm(Integer.parseInt(userByApprovalRole.getDepartId()),userByApprovalRole.getRoleId());
if (Common.isEmpty(sysUsers)) {
//如果不存在则取上级所在部门负责人
sysUsers = userService.getUserManagerByUpDepartIdUp(Integer.parseInt(userByApprovalRole.getDepartId()), userByApprovalRole.getRoleId());
}
if (Common.isNotEmpty(sysUsers)) {
naVo.setUserList(sysUsers);
}
return naVo;
}
} }
...@@ -77,4 +77,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> { ...@@ -77,4 +77,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
void updateUser(@Param("list") List<Map<String,Object>> list); void updateUser(@Param("list") List<Map<String,Object>> list);
Page<BusinessUserVo> getBusinessUserVoPage(Page page,@Param("query") BusinessUserVo user); Page<BusinessUserVo> getBusinessUserVoPage(Page page,@Param("query") BusinessUserVo user);
List<SysUser> getUserByRoleIdForCrm(@Param("departId") Integer departId, @Param("roleId") String roleId);
List<SysUser> getUserManagerByUpDepartIdUp(@Param("departId") Integer departId, @Param("roleId")String roleId);
} }
...@@ -185,4 +185,9 @@ public interface SysUserService extends IService<SysUser> { ...@@ -185,4 +185,9 @@ public interface SysUserService extends IService<SysUser> {
* @return R * @return R
*/ */
R<String> updateUserAndDept(HttpServletRequest request, JSONObject json); R<String> updateUserAndDept(HttpServletRequest request, JSONObject json);
List<SysUser> getUserByRoleIdForCrm(Integer departId, String roleId);
List<SysUser> getUserManagerByUpDepartIdUp(Integer departId, String roleId);
} }
...@@ -942,4 +942,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl ...@@ -942,4 +942,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
} }
} }
@Override
public List<SysUser> getUserByRoleIdForCrm(Integer departId, String roleId) {
return baseMapper.getUserByRoleIdForCrm(departId,roleId);
}
@Override
public List<SysUser> getUserManagerByUpDepartIdUp(Integer departId, String roleId) {
return baseMapper.getUserManagerByUpDepartIdUp(departId,roleId);
}
} }
...@@ -342,4 +342,41 @@ ...@@ -342,4 +342,41 @@
</where> </where>
ORDER BY `user`.create_time DESC ORDER BY `user`.create_time DESC
</select> </select>
<select id="getUserByRoleIdForCrm" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser">
SELECT
*
FROM
sys_user
WHERE
user_id IN (
SELECT
b.user_id
FROM
sys_approval_role a
LEFT JOIN sys_approval_role_user_dept b ON a.role_id = b.approval_role_id
WHERE
b.dept_id = #{departId}
AND approval_role_id = #{roleId}
)
</select>
<select id="getUserManagerByUpDepartIdUp" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser">
SELECT * FROM sys_user WHERE user_id IN(
SELECT
user_id
FROM
sys_approval_role_user_dept
WHERE
dept_id = (
SELECT
ORGAN_PARENT
FROM
sys_organization_info
WHERE
id = #{departId}
)
AND approval_role_id = #{roleId}
)
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment