|
@@ -19,6 +19,7 @@ import com.qmth.sop.common.enums.*;
|
|
|
import com.qmth.sop.common.util.JacksonUtil;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
+import org.activiti.engine.task.IdentityLink;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -66,6 +67,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
@Resource
|
|
|
TFFlowApproveService tfFlowApproveService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TSJobRemindService tsJobRemindService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询动态sop表名是否存在
|
|
|
*
|
|
@@ -273,14 +277,17 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail);
|
|
|
flowApproveParam.setApproveUserIds(approveUserIds);
|
|
|
|
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
|
|
|
- if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW && flowApproveParam.getApprove() == FlowApprovePassEnum.PASS && tfFlowApprove.getSetup().intValue() == 2
|
|
|
- && tbSopInfoDetail.getLeadId().longValue() == tbSopInfoDetail.getRegionUserId().longValue()) {
|
|
|
- flowApproveParam.setVar(Collections.singletonMap(SystemConstant.APPROVE, SystemConstant.APPROVE_AUTO));
|
|
|
- }
|
|
|
+// TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
|
|
|
+// if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW && flowApproveParam.getApprove() == FlowApprovePassEnum.PASS && tfFlowApprove.getSetup().intValue() == 2
|
|
|
+// && tbSopInfoDetail.getLeadId().longValue() == tbSopInfoDetail.getRegionUserId().longValue()) {
|
|
|
+// flowApproveParam.setVar(Collections.singletonMap(SystemConstant.APPROVE, SystemConstant.APPROVE_AUTO));
|
|
|
+// }
|
|
|
|
|
|
Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
|
|
|
- tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
|
|
|
+ if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
|
|
|
+ tbSopInfoService.saveJobRemind(map);
|
|
|
+ }
|
|
|
+ TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
|
|
|
|
|
|
tbSopInfo.updateInfo(sysUser.getId());
|
|
|
this.updateById(tbSopInfo);
|
|
@@ -470,6 +477,10 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
}
|
|
|
|
|
|
Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
|
|
|
+ if (approve != FlowApprovePassEnum.DRAFT) {
|
|
|
+ tbSopInfoService.saveJobRemind(map);
|
|
|
+ }
|
|
|
+
|
|
|
tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
|
|
|
TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
|
|
|
|
|
@@ -486,6 +497,112 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
|
|
|
return tbSopInfoService.save(tbSopInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存提醒/延时任务
|
|
|
+ *
|
|
|
+ * @param map
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void saveJobRemind(Map<String, Object> map) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ TFCustomFlow tfCustomFlow = (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM);
|
|
|
+ Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
|
|
|
+
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
|
|
|
+ Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
|
|
|
+
|
|
|
+ TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
|
|
|
+ Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
|
|
|
+
|
|
|
+ TFFlowLog tfFlowLog = (TFFlowLog) map.get(SystemConstant.FLOW_APPROVE_LOG);
|
|
|
+ Optional.ofNullable(tfFlowLog).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_LOG_NO_DATA.exception());
|
|
|
+
|
|
|
+ Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).singleResult();
|
|
|
+ if (Objects.nonNull(task) && (tfFlowApprove.getStatus() != FlowStatusEnum.DRAFT && tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END)) {
|
|
|
+ Long processLimitedTime = null;
|
|
|
+ if (tfCustomFlow.getType() == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop
|
|
|
+ if (tfFlowApprove.getSetup().intValue() == 2) {//项目关键信息
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.PROJECT_KEY_INFO_DATE);
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 3 || tfFlowApprove.getSetup().intValue() == 4) {//大区经理内审或工程师内审
|
|
|
+ processLimitedTime = tfFlowApprove.getUpdateTime();
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 6) {//扫描准备
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_START_TIME);
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 8) {//校验收尾
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SCAN_END_TIME);
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 9) {//评卷准备
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.MARK_START_TIME);
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 10) {//评卷收尾
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 2);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.MARK_END_TIME);
|
|
|
+ } else if (tfFlowApprove.getSetup().intValue() == 11) {//设备入库登记
|
|
|
+ FlowTaskResult flowTaskResult = this.getFormProperties(tfCustomFlowEntity, 1);
|
|
|
+ processLimitedTime = this.getProcessLimitedTime(flowTaskResult, SystemConstant.SERVICE_FINISH_PLAN_DATE);
|
|
|
+ }
|
|
|
+ } else if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop
|
|
|
+
|
|
|
+ }
|
|
|
+ List<TSJobRemind> tsJobRemindList = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(task.getAssignee())) {
|
|
|
+ tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
|
|
|
+ tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
|
|
|
+ } else {
|
|
|
+ List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
|
|
|
+ if (!CollectionUtils.isEmpty(identityLinkList)) {
|
|
|
+ for (IdentityLink i : identityLinkList) {
|
|
|
+ tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.BEFORE, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
|
|
|
+ tsJobRemindList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), processLimitedTime, sysUser.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tsJobRemindService.saveJobRemind(tsJobRemindList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取表单内容
|
|
|
+ *
|
|
|
+ * @param tfCustomFlowEntity
|
|
|
+ * @param setup
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public FlowTaskResult getFormProperties(TFCustomFlowEntity tfCustomFlowEntity, Integer setup) {
|
|
|
+ FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
|
|
|
+ LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
|
|
|
+ FlowTaskResult flowTaskResult = null;
|
|
|
+ for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
|
|
|
+ if (entry.getValue().getSetup().intValue() == setup.intValue()) {
|
|
|
+ flowTaskResult = entry.getValue();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flowTaskResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取处理时限时间
|
|
|
+ *
|
|
|
+ * @param flowTaskResult
|
|
|
+ * @param fieldId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Long getProcessLimitedTime(FlowTaskResult flowTaskResult, String fieldId) {
|
|
|
+ Long processLimitedTime = null;
|
|
|
+ List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
|
|
|
+ for (FlowFormWidgetResult f : formProperty) {
|
|
|
+ if (f.getFormId().contains(fieldId) && Objects.nonNull(f.getValue())) {
|
|
|
+ processLimitedTime = Long.parseLong(f.getValue());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Optional.ofNullable(processLimitedTime).orElseThrow(() -> ExceptionResultEnum.ERROR.exception(fieldId + "处理时限时间为空"));
|
|
|
+ return processLimitedTime;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据crmNo查询在途的sop信息
|
|
|
*
|