|
@@ -2,7 +2,6 @@ package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -10,17 +9,19 @@ import com.qmth.sop.business.activiti.service.ActivitiService;
|
|
|
import com.qmth.sop.business.bean.params.FlowApproveParam;
|
|
|
import com.qmth.sop.business.bean.params.SopApplyParam;
|
|
|
import com.qmth.sop.business.bean.params.SopInfoListParam;
|
|
|
+import com.qmth.sop.business.bean.params.SopPublishParam;
|
|
|
+import com.qmth.sop.business.bean.result.CrmProjectResult;
|
|
|
import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
|
|
|
import com.qmth.sop.business.bean.result.FlowTaskResult;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
|
import com.qmth.sop.business.mapper.TBSopInfoMapper;
|
|
|
-import com.qmth.sop.business.service.TBSopInfoDetailService;
|
|
|
-import com.qmth.sop.business.service.TBSopInfoService;
|
|
|
-import com.qmth.sop.business.service.TFCustomFlowEntityService;
|
|
|
+import com.qmth.sop.business.service.*;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.sop.common.enums.FlowApprovePassEnum;
|
|
|
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
|
|
|
import com.qmth.sop.common.enums.WidgetCodeEnum;
|
|
|
+import com.qmth.sop.common.util.JacksonUtil;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.task.Task;
|
|
@@ -61,6 +62,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
@Resource
|
|
|
TBSopInfoService tbSopInfoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TBCrmService tbCrmService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TFCustomFlowService tfCustomFlowService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询动态sop表名是否存在
|
|
|
*
|
|
@@ -168,6 +175,23 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
return this.baseMapper.selectDynamicSop(tableName, flowDeploymentId, flowId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * sop发布信息
|
|
|
+ *
|
|
|
+ * @param sopPublishParam
|
|
|
+ * @return
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
|
|
|
+ Optional.ofNullable(sopPublishParam.getCrmNo()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
|
|
|
+ if (sopPublishParam.getApprove() != FlowApprovePassEnum.DRAFT) {
|
|
|
+ throw ExceptionResultEnum.PARAMS_ERROR.exception("sop发布只能为草稿");
|
|
|
+ }
|
|
|
+ return tbSopInfoService.sopApplyOrPublish(sopPublishParam.getSopNo(), sopPublishParam.getCrmNo(), sopPublishParam.getFlowDeploymentId(), sopPublishParam.getApprove(), sopPublishParam.getFormProperties());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* sop申请信息
|
|
|
*
|
|
@@ -177,31 +201,16 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException {
|
|
|
- if (Objects.isNull(sopApplyParam.getCrmNo())) {
|
|
|
- throw ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空");
|
|
|
- }
|
|
|
+ Optional.ofNullable(sopApplyParam.getCrmNo()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
|
|
|
if (sopApplyParam.getApprove() != FlowApprovePassEnum.START && sopApplyParam.getApprove() != FlowApprovePassEnum.DRAFT) {
|
|
|
throw ExceptionResultEnum.PARAMS_ERROR.exception("sop申请只能为提交或草稿");
|
|
|
}
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- FlowTaskResult flowTaskResult = JSONObject.parseObject(sopApplyParam.getFormProperties(), FlowTaskResult.class);
|
|
|
- Map<String, Object> mapVar = this.getApproveUserIds(flowTaskResult);
|
|
|
- Long regionUserId = (Long) mapVar.get(SystemConstant.REGION_USER_ID);
|
|
|
- Long engineerUserId = (Long) mapVar.get(SystemConstant.ENGINEER_USER_ID);
|
|
|
- String assistantEngineerUserIds = (String) mapVar.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
|
|
|
-
|
|
|
- List<String> approveUserIds = Objects.nonNull(engineerUserId) ? Arrays.asList(String.valueOf(engineerUserId)) : Arrays.asList(String.valueOf(sysUser.getId()));
|
|
|
- Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), approveUserIds, sopApplyParam.getCrmNo(), sopApplyParam.getFormProperties()));
|
|
|
- TFCustomFlow tfCustomFlow = (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM);
|
|
|
- TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
|
|
|
-
|
|
|
- TBSopInfo tbSopInfo = new TBSopInfo(sopApplyParam.getCrmNo(), tfCustomFlowEntity.getCode(), sopApplyParam.getServiceId(), sopApplyParam.getCustomId(), sopApplyParam.getProductId(), tfCustomFlow.getType(), sysUser.getId());
|
|
|
- TBSopInfoDetail tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), regionUserId, engineerUserId, assistantEngineerUserIds);
|
|
|
- tbSopInfoDetailService.save(tbSopInfoDetail);
|
|
|
+ return tbSopInfoService.sopApplyOrPublish(sopApplyParam.getSopNo(), sopApplyParam.getCrmNo(), sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), sopApplyParam.getFormProperties());
|
|
|
+ }
|
|
|
|
|
|
- tfCustomFlowEntity.setObjId(tbSopInfo.getId());
|
|
|
- tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
|
|
|
- return tbSopInfoService.save(tbSopInfo);
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String s = "{\"taskName\":\"项目内审\",\"taskKey\":\"f_usertask_office_inside_approve_3\",\"setup\":3,\"formKey\":\"office_sop_inside_approve.form\",\"formProperty\":[{\"id\":\"51\",\"code\":\"FORM_GROUP_TITLE\",\"type\":\"FORM\",\"formId\":\"inside_title_3\",\"formName\":\"inside_title_3\",\"title\":\"项目内审(请于24小时内完成内审\",\"inputType\":\"STRING\",\"required\":false,\"readable\":true,\"writable\":false,\"visable\":true,\"name\":\"带虚线分割线的标题\",\"span\":12},{\"id\":\"52\",\"code\":\"RADIO\",\"type\":\"FORM\",\"formId\":\"approve_radio_3\",\"formName\":\"approve_radio_3\",\"title\":\"我对以上项目关键信息已审核,确认内容无误:\",\"inputType\":\"STRING\",\"required\":true,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"单选框\",\"span\":12,\"options\":\"[{\\\"value\\\":\\\"1\\\",\\\"label\\\":\\\"同意\\\"},{\\\"value\\\":\\\"0\\\",\\\"label\\\":\\\"不同意\\\"}]\",\"value\":1},{\"id\":\"53\",\"code\":\"SIGN\",\"type\":\"FORM\",\"formId\":\"sign_3\",\"formName\":\"sign_3\",\"title\":\"添加签名\",\"inputType\":\"STRING\",\"required\":true,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"签名\",\"span\":6,\"value\":\"呵呵\"},{\"id\":\"54\",\"code\":\"TEXTAREA\",\"type\":\"FORM\",\"formId\":\"approve_ramark_3\",\"formName\":\"approve_ramark_3\",\"title\":\"审批意见\",\"inputType\":\"STRING\",\"required\":false,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"文本域\",\"span\":12,\"value\":\"1233456\"}],\"approveRejectList\":[{\"afterFlowTaskKey\":\"f_usertask_office_information_2\",\"beforeFlowTaskKey\":null,\"setup\":2}]}";
|
|
|
+ System.out.println(JacksonUtil.parseJson(s));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -233,9 +242,16 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
|
|
|
Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
|
|
|
+ TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+
|
|
|
TBSopInfo tbSopInfo = this.getOne(new QueryWrapper<TBSopInfo>().lambda().eq(TBSopInfo::getSopNo, tfCustomFlowEntity.getCode()));
|
|
|
Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
|
|
|
|
|
|
+ TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(new QueryWrapper<TBSopInfoDetail>().lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId()));
|
|
|
+ Optional.ofNullable(tbSopInfoDetail).orElseThrow(() -> ExceptionResultEnum.SOP_DETAIL_INFO_NO_DATA.exception());
|
|
|
+
|
|
|
+ //更新表单信息
|
|
|
FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(), FlowTaskResult.class);
|
|
|
Long engineerUserId = null;
|
|
|
if (flowTaskResult.getSetup().intValue() == 1) {
|
|
@@ -246,16 +262,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
|
|
|
assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
|
|
|
|
|
|
- UpdateWrapper<TBSopInfoDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId())
|
|
|
- .set(TBSopInfoDetail::getRegionUserId, regionUserId)
|
|
|
- .set(TBSopInfoDetail::getEngineerUserId, engineerUserId)
|
|
|
- .set(TBSopInfoDetail::getAssistantEngineerUserIds, assistantEngineerUserIds);
|
|
|
- tbSopInfoDetailService.update(updateWrapper);
|
|
|
+ tbSopInfoDetail.updateUserIdInfo(regionUserId, engineerUserId, assistantEngineerUserIds);
|
|
|
+ tbSopInfoDetailService.updateById(tbSopInfoDetail);
|
|
|
} else {
|
|
|
engineerUserId = Long.parseLong(taskApproveUserList.get(0));
|
|
|
}
|
|
|
- List<String> approveUserIds = Objects.nonNull(engineerUserId) ? Arrays.asList(String.valueOf(engineerUserId)) : Arrays.asList(String.valueOf(sysUser.getId()));
|
|
|
+ List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail);
|
|
|
flowApproveParam.setApproveUserIds(approveUserIds);
|
|
|
activitiService.taskApprove(flowApproveParam);
|
|
|
tbSopInfo.updateInfo(sysUser.getId());
|
|
@@ -273,6 +285,34 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
return this.baseMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), sopInfoListParam.getServiceId(), sopInfoListParam.getFormWidgetMetadataList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取下一级审批人
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @param flowTaskResult
|
|
|
+ * @param tbSopInfoDetail
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult, TBSopInfoDetail tbSopInfoDetail) {
|
|
|
+ List<String> approveUserIds = null;
|
|
|
+ if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
|
|
|
+ if (flowTaskResult.getSetup().intValue() == 1) {
|
|
|
+ approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
|
|
|
+ } else if (flowTaskResult.getSetup().intValue() == 2) {
|
|
|
+ approveUserIds = new ArrayList<>(2);
|
|
|
+ approveUserIds.add(String.valueOf(tbSopInfoDetail.getLeadId()));
|
|
|
+ approveUserIds.add(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
|
|
|
+ } else if (flowTaskResult.getSetup().intValue() == 3) {
|
|
|
+ approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
|
|
|
+ } else {
|
|
|
+ approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
|
|
|
+ }
|
|
|
+ } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
|
|
|
+
|
|
|
+ }
|
|
|
+ return approveUserIds;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取审批人
|
|
|
*
|
|
@@ -299,15 +339,67 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (Objects.isNull(regionUserId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("区域协调人不能为空");
|
|
|
- }
|
|
|
- if (Objects.isNull(engineerUserId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("实施工程师不能为空");
|
|
|
- }
|
|
|
+ Optional.ofNullable(regionUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("区域协调人不能为空"));
|
|
|
+ Optional.ofNullable(engineerUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实施工程师不能为空"));
|
|
|
map.put(SystemConstant.REGION_USER_ID, regionUserId);
|
|
|
map.put(SystemConstant.ENGINEER_USER_ID, engineerUserId);
|
|
|
map.put(SystemConstant.ASSISTANT_ENGINEER_USER_ID, assistantEngineerUserIds);
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * sop申请或发布
|
|
|
+ *
|
|
|
+ * @param sopNo
|
|
|
+ * @param crmNo
|
|
|
+ * @param flowDeploymentId
|
|
|
+ * @param approve
|
|
|
+ * @param formProperties
|
|
|
+ * @return
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve, String formProperties) throws InterruptedException {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
|
|
|
+ Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm数据为空"));
|
|
|
+ Optional.ofNullable(crmProjectResult.getRegionManagerId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm大区经理数据为空"));
|
|
|
+
|
|
|
+ TFCustomFlow tfCustomFlow = null;
|
|
|
+ TBSopInfoDetail tbSopInfoDetail = null;
|
|
|
+ List<String> approveUserIds = new ArrayList<>();
|
|
|
+ if (approve == FlowApprovePassEnum.DRAFT) {
|
|
|
+ approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));
|
|
|
+ } else if (approve == FlowApprovePassEnum.START) {
|
|
|
+ Optional.ofNullable(formProperties).orElseThrow(() -> ExceptionResultEnum.FLOW_FORM_PROPERTIES_IS_NULL.exception());
|
|
|
+
|
|
|
+ tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+
|
|
|
+ FlowTaskResult flowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
|
|
|
+ Map<String, Object> map = this.getApproveUserIds(flowTaskResult);
|
|
|
+ Long regionUserId = (Long) map.get(SystemConstant.REGION_USER_ID);
|
|
|
+ Long engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
|
|
|
+ String assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
|
|
|
+ tbSopInfoDetail = new TBSopInfoDetail(crmProjectResult.getRegionManagerId(), regionUserId, engineerUserId, assistantEngineerUserIds);
|
|
|
+ approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
|
|
|
+ tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
|
|
|
+
|
|
|
+ TBSopInfo tbSopInfo = new TBSopInfo(crmNo, tfCustomFlowEntity.getCode(), crmProjectResult.getServiceUnitId(), crmProjectResult.getCustomId(), crmProjectResult.getProductId(), tfCustomFlow.getType(), sysUser.getId());
|
|
|
+ if (Objects.isNull(tbSopInfoDetail)) {
|
|
|
+ tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), crmProjectResult.getRegionManagerId());
|
|
|
+ } else {
|
|
|
+ tbSopInfoDetail.setSopInfoId(tbSopInfo.getId());
|
|
|
+ }
|
|
|
+ tbSopInfoDetailService.save(tbSopInfoDetail);
|
|
|
+
|
|
|
+ tfCustomFlowEntity.setObjId(tbSopInfo.getId());
|
|
|
+ tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
|
|
|
+ return tbSopInfoService.save(tbSopInfo);
|
|
|
+ }
|
|
|
}
|