|
@@ -107,6 +107,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
@Resource
|
|
|
MemoryLock memoryLock;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TBUserArchivesAllocationService tbUserArchivesAllocationService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询动态sop表名是否存在
|
|
|
*
|
|
@@ -377,12 +380,14 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
* sop转审
|
|
|
*
|
|
|
* @param crmDetailId
|
|
|
+ * @param sopAllocationParam
|
|
|
* @return
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Boolean sopApproverExchange(Long crmDetailId) throws InterruptedException {
|
|
|
+ public Boolean sopApproverExchange(Long crmDetailId, SopAllocationParam sopAllocationParam)
|
|
|
+ throws InterruptedException {
|
|
|
TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
|
|
|
Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
|
|
|
|
|
@@ -403,16 +408,20 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
|
|
|
Task task = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
|
|
|
.singleResult();
|
|
|
- Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
|
|
|
- //todo 需要调曹子轩人员配置方法,项目经理变更后调用转审
|
|
|
- CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
|
|
|
- crmDetailId, tfCustomFlowEntity.getCrmNo());
|
|
|
- Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
|
|
|
- if (!CollectionUtils.isEmpty(crmProjectResult.getProjectManagerList())) {
|
|
|
- activitiService.taskApproverExchange(crmProjectResult.getProjectManagerList().get(0).getUserId(),
|
|
|
- Long.parseLong(task.getId()));
|
|
|
- //修改流程one里面的工程师
|
|
|
- tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId());
|
|
|
+ List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
|
|
|
+ if (!CollectionUtils.isEmpty(allocationParamList)) {
|
|
|
+ for (AllocationParam a : allocationParamList) {
|
|
|
+ if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
|
|
|
+ activitiService.taskApproverExchange(a.getArchivesIdList().get(0),
|
|
|
+ Long.parseLong(task.getId()));
|
|
|
+ } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
|
|
|
+ //修改流程one里面的工程师
|
|
|
+ List<String> engineerUserIdList = a.getArchivesIdList().stream().map(s -> s.toString())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
|
|
|
+ engineerUserIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -434,14 +443,15 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
/**
|
|
|
* sop人员配置
|
|
|
*
|
|
|
- * @param flowId
|
|
|
+ * @param sopAllocationParam
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Boolean sopAllocation(Long flowId) {
|
|
|
+ public Boolean sopAllocation(SopAllocationParam sopAllocationParam) throws InterruptedException {
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
|
|
|
- new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
|
|
|
+ new QueryWrapper<TFCustomFlowEntity>().lambda()
|
|
|
+ .eq(TFCustomFlowEntity::getFlowId, sopAllocationParam.getFlowId()));
|
|
|
Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
|
|
|
TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
|
|
@@ -449,17 +459,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
if (Objects.nonNull(flowStatus) && (flowStatus == FlowStatusEnum.FINISH || flowStatus == FlowStatusEnum.END)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束,无法分配人员");
|
|
|
}
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(flowId.toString()).singleResult();
|
|
|
+ Task task = taskService.createTaskQuery().processInstanceId(sopAllocationParam.getFlowId().toString())
|
|
|
+ .singleResult();
|
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
|
|
|
- //todo 需要调曹子轩人员配置方法,项目经理变更后调用转审
|
|
|
- CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
|
|
|
- tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
|
|
|
- Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
|
|
|
- if (!CollectionUtils.isEmpty(crmProjectResult.getProjectManagerList())) {
|
|
|
- activitiService.taskApproverExchange(crmProjectResult.getProjectManagerList().get(0).getUserId(),
|
|
|
- Long.parseLong(task.getId()));
|
|
|
- //修改流程one里面的工程师
|
|
|
- tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId());
|
|
|
+
|
|
|
+ List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
|
|
|
+ if (!CollectionUtils.isEmpty(allocationParamList)) {
|
|
|
+ for (AllocationParam a : allocationParamList) {
|
|
|
+ if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
|
|
|
+ activitiService.taskApproverExchange(a.getArchivesIdList().get(0), Long.parseLong(task.getId()));
|
|
|
+ } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
|
|
|
+ //修改流程one里面的工程师
|
|
|
+ List<String> engineerUserIdList = a.getArchivesIdList().stream().map(s -> s.toString())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
|
|
|
+ engineerUserIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tbUserArchivesAllocationService.editCrmAllocation(new UserArchivesAllocationParam(sopAllocationParam));
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -469,11 +486,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
*
|
|
|
* @param flowId
|
|
|
* @param crmDetailId
|
|
|
+ * @param engineerUserIdList
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Boolean updateFlowSetupOne(Long flowId, Long crmDetailId) {
|
|
|
+ public Boolean updateFlowSetupOne(Long flowId, Long crmDetailId, List<String> engineerUserIdList) {
|
|
|
boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_PROPERTIES_PREFIX + crmDetailId, crmDetailId,
|
|
|
SystemConstant.LOCK_FLOW_TIME_OUT);
|
|
|
if (!lock) {
|
|
@@ -489,19 +507,31 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
FlowTaskResult flowTaskResult = tbSopInfoService.getFormProperties(tfCustomFlowEntity, 1);
|
|
|
if (flowTaskResult.getSetup() > 0) {
|
|
|
- CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
|
|
|
- crmDetailId, tfCustomFlowEntity.getCrmNo());
|
|
|
- Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
|
|
|
List<FlowFormWidgetResult> flowFormWidgetResultList = flowTaskResult.getFormProperty();
|
|
|
- for (FlowFormWidgetResult f : flowFormWidgetResultList) {
|
|
|
- if (f.getFormId().contains(ProcessLimitedEnum.ENGINEER_USERS_ID.getKey())) {
|
|
|
- List<String> list = new ArrayList<>(crmProjectResult.getEngineerList().size());
|
|
|
- crmProjectResult.getEngineerList().stream().peek(s -> list.add(s.getUserId().toString()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put(SystemConstant.VALUE, list);
|
|
|
- f.setValue(jsonObject.toJSONString());
|
|
|
- break;
|
|
|
+ if (!CollectionUtils.isEmpty(engineerUserIdList)) {
|
|
|
+ for (FlowFormWidgetResult f : flowFormWidgetResultList) {
|
|
|
+ if (f.getFormId().contains(ProcessLimitedEnum.ENGINEER_USERS_ID.getKey())) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(SystemConstant.VALUE, engineerUserIdList);
|
|
|
+ f.setValue(jsonObject.toJSONString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
|
|
|
+ crmDetailId, tfCustomFlowEntity.getCrmNo());
|
|
|
+ Optional.ofNullable(crmProjectResult)
|
|
|
+ .orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
|
|
|
+ for (FlowFormWidgetResult f : flowFormWidgetResultList) {
|
|
|
+ if (f.getFormId().contains(ProcessLimitedEnum.ENGINEER_USERS_ID.getKey())) {
|
|
|
+ List<String> list = new ArrayList<>(crmProjectResult.getEngineerList().size());
|
|
|
+ crmProjectResult.getEngineerList().stream().peek(s -> list.add(s.getUserId().toString()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put(SystemConstant.VALUE, list);
|
|
|
+ f.setValue(jsonObject.toJSONString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -583,7 +613,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
FlowTaskResult currFlowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(),
|
|
|
FlowTaskResult.class);
|
|
|
List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResultOne,
|
|
|
- currFlowTaskResult, crmProjectResult);
|
|
|
+ currFlowTaskResult, crmProjectResult, tbCrmDetail.getId());
|
|
|
flowApproveParam.setApproveUserIds(approveUserIds);
|
|
|
}
|
|
|
|
|
@@ -880,10 +910,11 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
* @param type
|
|
|
* @param flowTaskResult
|
|
|
* @param crmProjectResult
|
|
|
+ * @param crmDetailId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult,
|
|
|
- FlowTaskResult currFlowTaskResult, CrmProjectResult crmProjectResult) {
|
|
|
+ FlowTaskResult currFlowTaskResult, CrmProjectResult crmProjectResult, Long crmDetailId) {
|
|
|
List<String> approveUserIds = new ArrayList<>();
|
|
|
ServiceScopeEnum scopeEnum = tbSopInfoService.findServiceScope(type, flowTaskResult);
|
|
|
if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
|
|
@@ -897,10 +928,14 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
approveUserIds.add(u.getUserId().toString());
|
|
|
}
|
|
|
} else {
|
|
|
- //todo 需要调用曹子轩项目经理变更的方法,并且注释是[系统]
|
|
|
Objects.requireNonNull(crmProjectResult.getRegionManagerId(), "未设置大区经理");
|
|
|
try {
|
|
|
tbUserArchivesService.findByUserId(crmProjectResult.getRegionManagerId());
|
|
|
+ List<AllocationParam> allocationParams = new ArrayList<>();
|
|
|
+ allocationParams.add(new AllocationParam(SopRoleTypeEnum.PROJECT_MANAGER,
|
|
|
+ Arrays.asList(crmProjectResult.getRegionManagerId()), "[系统]"));
|
|
|
+ tbUserArchivesAllocationService.editCrmAllocation(
|
|
|
+ new UserArchivesAllocationParam(allocationParams, crmDetailId));
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
|
if (e instanceof ApiException) {
|