|
@@ -470,34 +470,24 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
throws InterruptedException {
|
|
|
TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
|
|
|
Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
|
|
|
-
|
|
|
if (Objects.nonNull(tbCrmDetail.getSopNo())) {
|
|
|
//已发布且状态为草稿的sop可以修改
|
|
|
- if (tbCrmDetail.getStatus() == CrmStatusEnum.PUBLISH) {
|
|
|
- FlowStatusEnum flowStatus = tbCrmDetailService.findById(tbCrmDetail.getId());
|
|
|
- if (Objects.nonNull(flowStatus) && (flowStatus == FlowStatusEnum.FINISH
|
|
|
- || flowStatus == FlowStatusEnum.END)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("流程已结束,无法转审");
|
|
|
- }
|
|
|
- }
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbCrmDetail.getSopNo());
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity)
|
|
|
+ .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(tfCustomFlowEntity.getFlowId());
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
|
|
|
- .singleResult();
|
|
|
- List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
|
|
|
- if (!CollectionUtils.isEmpty(allocationParamList)) {
|
|
|
- for (AllocationParam a : allocationParamList) {
|
|
|
- if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
|
|
|
- activitiService.taskApproverExchange(a.getUserIdList().get(0), Long.parseLong(task.getId()));
|
|
|
- } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
|
|
|
- //修改流程one里面的工程师
|
|
|
- List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
|
|
|
- .collect(Collectors.toList());
|
|
|
- tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
|
|
|
- engineerUserIdList);
|
|
|
- }
|
|
|
+ if (tbCrmDetail.getStatus() == CrmStatusEnum.PUBLISH) {
|
|
|
+ if (Objects.nonNull(tfFlowApprove.getStatus()) && (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH
|
|
|
+ || tfFlowApprove.getStatus() == FlowStatusEnum.END)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("流程已结束,无法转审");
|
|
|
}
|
|
|
}
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+ tbSopInfoService.updateFlowInfo(sopAllocationParam.getAllocationParams(), tfCustomFlow, tfCustomFlowEntity,
|
|
|
+ tfFlowApprove, tbCrmDetail);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -525,31 +515,21 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
@Transactional
|
|
|
public Boolean sopAllocation(SopAllocationParam sopAllocationParam) throws InterruptedException {
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(sopAllocationParam.getFlowId());
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
|
|
|
- FlowStatusEnum flowStatus = tbCrmDetailService.findById(
|
|
|
- Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null);
|
|
|
- if (Objects.nonNull(flowStatus) && (flowStatus == FlowStatusEnum.FINISH || flowStatus == FlowStatusEnum.END)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("流程已结束,无法分配人员");
|
|
|
- }
|
|
|
- Task task = taskService.createTaskQuery().processInstanceId(sopAllocationParam.getFlowId().toString())
|
|
|
- .singleResult();
|
|
|
- Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
|
|
|
+ Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(tfCustomFlowEntity.getFlowId());
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
|
|
|
- List<AllocationParam> allocationParamList = sopAllocationParam.getAllocationParams();
|
|
|
- if (!CollectionUtils.isEmpty(allocationParamList)) {
|
|
|
- for (AllocationParam a : allocationParamList) {
|
|
|
- if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
|
|
|
- activitiService.taskApproverExchange(a.getUserIdList().get(0), Long.parseLong(task.getId()));
|
|
|
- } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
|
|
|
- //修改流程one里面的工程师
|
|
|
- List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
|
|
|
- .collect(Collectors.toList());
|
|
|
- tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
|
|
|
- engineerUserIdList);
|
|
|
- }
|
|
|
- }
|
|
|
- tbUserArchivesAllocationService.editCrmAllocation(new UserArchivesAllocationParam(sopAllocationParam));
|
|
|
+ if (Objects.nonNull(tfFlowApprove.getStatus()) && (tfFlowApprove.getStatus() == FlowStatusEnum.FINISH
|
|
|
+ || tfFlowApprove.getStatus() == FlowStatusEnum.END)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("流程已结束,无法分配人员");
|
|
|
}
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.findById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+ tbSopInfoService.updateFlowInfo(sopAllocationParam.getAllocationParams(), tfCustomFlow, tfCustomFlowEntity,
|
|
|
+ tfFlowApprove, tbCrmDetail);
|
|
|
+ tbUserArchivesAllocationService.editCrmAllocation(new UserArchivesAllocationParam(sopAllocationParam));
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -619,6 +599,57 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新流程信息
|
|
|
+ *
|
|
|
+ * @param allocationParamList
|
|
|
+ * @param tfCustomFlow
|
|
|
+ * @param tfCustomFlowEntity
|
|
|
+ * @param tfFlowApprove
|
|
|
+ * @param tbCrmDetail
|
|
|
+ * @return
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean updateFlowInfo(List<AllocationParam> allocationParamList, TFCustomFlow tfCustomFlow,
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity, TFFlowApprove tfFlowApprove, TBCrmDetail tbCrmDetail)
|
|
|
+ throws InterruptedException {
|
|
|
+ List<Task> taskList = taskService.createTaskQuery().processInstanceId(tfCustomFlowEntity.getFlowId().toString())
|
|
|
+ .list();
|
|
|
+ if (CollectionUtils.isEmpty(taskList)) {
|
|
|
+ throw ExceptionResultEnum.FLOW_TASK_NO_DATA.exception();
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(allocationParamList)) {
|
|
|
+ for (AllocationParam a : allocationParamList) {
|
|
|
+ if (a.getSopRoleType() == SopRoleTypeEnum.PROJECT_MANAGER) {
|
|
|
+ if (taskList.size() == 1) {
|
|
|
+ activitiService.taskApproverExchange(a.getUserIdList().get(0),
|
|
|
+ Long.parseLong(taskList.get(0).getId()));
|
|
|
+ } else {
|
|
|
+ CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
|
|
|
+ tfCustomFlowEntity.getCode(), tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
|
|
|
+ List<Task> taskTempList = taskList.stream().filter(s -> Objects.equals(s.getAssignee(),
|
|
|
+ crmProjectResult.getProjectManagerList().get(0).getUserId().toString()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(taskTempList)) {
|
|
|
+ throw ExceptionResultEnum.FLOW_TASK_NO_DATA.exception();
|
|
|
+ }
|
|
|
+ activitiService.taskApproverExchange(a.getUserIdList().get(0),
|
|
|
+ Long.parseLong(taskTempList.get(0).getId()));
|
|
|
+ }
|
|
|
+ } else if (a.getSopRoleType() == SopRoleTypeEnum.ENGINEER) {
|
|
|
+ //修改流程one里面的工程师
|
|
|
+ List<String> engineerUserIdList = a.getUserIdList().stream().map(s -> s.toString())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ tbSopInfoService.updateFlowSetupOne(tfCustomFlowEntity.getFlowId(), tbCrmDetail.getId(),
|
|
|
+ engineerUserIdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* sop填报信息
|
|
|
*
|
|
@@ -723,9 +754,78 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
SopStatusEnum.START);
|
|
|
tbSopInfo.updateInfo(sysUser.getId());
|
|
|
tbSopInfoService.updateById(tbSopInfo);
|
|
|
+
|
|
|
+ //研究生流程,如果下一步审批是大区经理内审并且项目经理和大区经理为同一人时,后台自动审批
|
|
|
+ tbSopInfoService.sopSystemApprove(tfCustomFlow, tfCustomFlowEntity, tfFlowApprove, crmProjectResult,
|
|
|
+ flowApproveParam.getCrmNo(), tbCrmDetail.getId());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * sop自动审批
|
|
|
+ *
|
|
|
+ * @param tfCustomFlow
|
|
|
+ * @param tfCustomFlowEntity
|
|
|
+ * @param tfFlowApprove
|
|
|
+ * @param crmProjectResult
|
|
|
+ * @param crmNo
|
|
|
+ * @param crmDetailId
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void sopSystemApprove(TFCustomFlow tfCustomFlow, TFCustomFlowEntity tfCustomFlowEntity,
|
|
|
+ TFFlowApprove tfFlowApprove, CrmProjectResult crmProjectResult, String crmNo, Long crmDetailId)
|
|
|
+ throws InterruptedException {
|
|
|
+ //如果下一步审批是内审并且项目经理和大区经理为同一人时,后台自动审批
|
|
|
+ if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
|
|
|
+ && tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END
|
|
|
+ && tfFlowApprove.getStatus() == FlowStatusEnum.AUDITING && tfFlowApprove.getSetup().intValue() == 3
|
|
|
+ && crmProjectResult.getRegionManagerId().longValue() == crmProjectResult.getProjectManagerList().get(0)
|
|
|
+ .getUserId().longValue()) {
|
|
|
+ List<Task> taskList = taskService.createTaskQuery()
|
|
|
+ .processInstanceId(String.valueOf(tfFlowApprove.getFlowId()))
|
|
|
+ .taskAssignee(String.valueOf(crmProjectResult.getRegionManagerId())).list();
|
|
|
+ if (!CollectionUtils.isEmpty(taskList) && taskList.size() == 2) {
|
|
|
+ Task taskNew = taskList.get(0);
|
|
|
+ FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(),
|
|
|
+ FlowResult.class);
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
+ FlowTaskResult nextFlowTaskResult = null;
|
|
|
+ for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
+ if (entry.getValue().getSetup().intValue() == 3) {
|
|
|
+ nextFlowTaskResult = entry.getValue();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(nextFlowTaskResult)) {
|
|
|
+ List<FlowFormWidgetResult> flowFormWidgetResultList = nextFlowTaskResult.getFormProperty();
|
|
|
+ for (FlowFormWidgetResult f : flowFormWidgetResultList) {
|
|
|
+ if (f.getFormId().contains(SystemConstant.APPROVE_RADIO_REGION)) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("value", "1");
|
|
|
+ f.setValue(jsonObject.toString());
|
|
|
+ } else if (f.getFormId().contains(SystemConstant.APPROVE_REMARK_REGION)) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("value", SystemConstant.SYSTEM_AUTO_APPROVE);
|
|
|
+ f.setValue(jsonObject.toString());
|
|
|
+ } else if (f.getFormId().contains(SystemConstant.SIGN_REGION)) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("value", "https://sop-file.qmth.com.cn/logo/logo.png");
|
|
|
+ f.setValue(jsonObject.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ activitiService.taskApprove(
|
|
|
+ new FlowApproveParam(Long.parseLong(taskNew.getId()), FlowApprovePassEnum.PASS,
|
|
|
+ this.getNextApproveUserIds(tfCustomFlow.getType(), nextFlowTaskResult,
|
|
|
+ nextFlowTaskResult, crmProjectResult, crmDetailId), crmNo,
|
|
|
+ SystemConstant.SYSTEM_AUTO_APPROVE, JacksonUtil.parseJson(nextFlowTaskResult)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* sop管理列表
|
|
|
*
|
|
@@ -929,7 +1029,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
sopInfoListParam.getCustomName(), sopInfoListParam.getTaskKey(), sopInfoListParam.getCrmName(),
|
|
|
sopInfoListParam.getSopNo(),
|
|
|
Objects.nonNull(sopInfoListParam.getDingPlan()) ? sopInfoListParam.getDingPlan().toString() : null);
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
for (Map m : list.getRecords()) {
|
|
|
String engineerUsersId = (String) m.get("engineer_users_id_1");
|
|
|
List<Long> userIdList = new ArrayList<>();
|
|
@@ -1077,14 +1176,6 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
if (currFlowTaskResult.getSetup().intValue() == 1) {
|
|
|
approveUserIds = Arrays.asList(String.valueOf(crmProjectResult.getRegionManagerId()));
|
|
|
} else if (currFlowTaskResult.getSetup().intValue() == 2) {
|
|
|
- // TBCrmDetail tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
|
|
|
- // Objects.requireNonNull(tbCrmDetail, "未找到派单sop信息");
|
|
|
- // TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByCode(tbCrmDetail.getSopNo());
|
|
|
- // Optional.ofNullable(tfCustomFlowEntity)
|
|
|
- // .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
- //
|
|
|
- // List<Task> taskList = taskService.createTaskQuery()
|
|
|
- // .processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
|
|
|
approveUserIds = crmProjectResult.getProjectManagerList().stream()
|
|
|
.map(s -> String.valueOf(s.getUserId())).collect(Collectors.toList());
|
|
|
approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));
|