|
@@ -19,7 +19,6 @@ import com.willalp.msg.service.IHsAppUserMsgService;
|
|
|
import com.willalp.system.domain.vo.PostTreeVo;
|
|
|
import com.willalp.system.service.ISysConfigService;
|
|
|
import com.willalp.wx.domain.WxMsgTemplateApproval;
|
|
|
-import com.willalp.wx.domain.WxMsgTemplateApprovalResult;
|
|
|
import com.willalp.wx.enums.WxTemplateKeyEnum;
|
|
|
import com.willalp.wx.service.WxMsgService;
|
|
|
import com.willalp.wx.utils.WxUtils;
|
|
@@ -42,6 +41,9 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
@Resource
|
|
|
private IHsFlowBaseService flowBaseService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IHsFlowCcService flowCcService;
|
|
|
+
|
|
|
@Resource
|
|
|
private HsFlowExamplesMapper hsFlowExamplesMapper;
|
|
|
|
|
@@ -204,7 +206,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
throw new BaseException("FLOW_BASE_GROUP_ID - IS_NULL");
|
|
|
}
|
|
|
//获取当前基础组件
|
|
|
- HsFlowBase hsFlowBase = flowBaseService.getCurrentFlowTaskBase(hsFlowTask.getBaseGroupId(), flow.getBaseId());
|
|
|
+ HsFlowBase hsFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), flow.getBaseId());
|
|
|
if (null == hsFlowBase) {
|
|
|
throw new BaseException("没有找到组件");
|
|
|
}
|
|
@@ -228,11 +230,15 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
boolean resultCaseOf = FlowEnum.RESULT_CASE_OF.getValue().equals(flow.getResult());
|
|
|
Map<String, Object> formData = flow.getFormData();
|
|
|
List<HsFlowRunningRecord> list = new ArrayList<>();
|
|
|
- //生成记录
|
|
|
+ HsFlowBase nextFlowBase = null;
|
|
|
+ //生成审批记录
|
|
|
HsFlowRunningRecord frr = new HsFlowRunningRecord();
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
frr.setBaseId(flow.getBaseId());
|
|
|
frr.setTaskId(flow.getTaskId());
|
|
|
frr.setCreateTime(new Date());
|
|
|
+ frr.setOperator(username);
|
|
|
+ String baseName = null;
|
|
|
if (resultCaseOf) {
|
|
|
//转交
|
|
|
hsFlowTask.setOperator(flow.getNextApproval());
|
|
@@ -240,64 +246,102 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
frr.setOperator(SecurityUtils.getUsername());
|
|
|
frr.setYesOrNo(flow.getResult());
|
|
|
} else {
|
|
|
- //查看有无条件组件
|
|
|
if (resultTrue) {
|
|
|
+ //查看有无条件组件
|
|
|
hsFlowBase = getFlowBaseByTermResult(flow.getTaskId(), hsFlowBase, formData);
|
|
|
- }
|
|
|
- if (resultTrue) {
|
|
|
stepId = hsFlowBase.getDownStepId();
|
|
|
} else {
|
|
|
- // stepId = hsFlowBase.getUpStepId();
|
|
|
stepId = flow.getRejectBaseId();
|
|
|
}
|
|
|
- String username = SecurityUtils.getUsername();
|
|
|
+ nextFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
+ //判断新组件下一步是否需要抄送
|
|
|
+ if (nextFlowBase != null && StringUtils.isNotBlank(nextFlowBase.getCcId())) {
|
|
|
+ HsFlowCc cc = new HsFlowCc();
|
|
|
+ cc.setExamplesId(hsFlowTask.getExamplesId());
|
|
|
+ cc.setFormData(JSON.toJSONString(formData));
|
|
|
+ cc.setApply(hsFlowTask.getInitiator());
|
|
|
+ cc.setTitle(hsFlowTask.getTaskName());
|
|
|
+ Operators operators = JSON.parseObject(nextFlowBase.getOperator(), Operators.class);
|
|
|
+ List<Operators.OperatorDto> assignedUser = operators.getAssignedUser();
|
|
|
+ StringBuilder sbUid = new StringBuilder();
|
|
|
+ StringBuilder sbUname = new StringBuilder();
|
|
|
+ if (0 != assignedUser.size()) {
|
|
|
+ for (int i = 0; i < assignedUser.size(); i++) {
|
|
|
+ if (i != (assignedUser.size() - 1)) {
|
|
|
+ sbUid.append(assignedUser.get(i).getId()).append(",");
|
|
|
+ sbUname.append(assignedUser.get(i).getName()).append(",");
|
|
|
+ } else {
|
|
|
+ sbUid.append(assignedUser.get(i).getId());
|
|
|
+ sbUname.append(assignedUser.get(i).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cc.setUsers(sbUid.toString());
|
|
|
+ }
|
|
|
+ flowCcService.save(cc);
|
|
|
+ if (StringUtils.isBlank(nextFlowBase.getDownStepId())) {
|
|
|
+ if (resultTrue) {
|
|
|
+ wxMsgService.sendResultMsg("审批抄送 - " + formData.get("title"), "已通过", String.valueOf(formData.get("apply_user_id")));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ stepId = nextFlowBase.getDownStepId();
|
|
|
+ nextFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
+ baseName = nextFlowBase.getFlowModuleName();
|
|
|
+ wxMsgService.sendResultMsg("审批抄送 - " + formData.get("title"), "进行中", String.valueOf(formData.get("apply_user_id")));
|
|
|
+ }
|
|
|
+ HsFlowRunningRecord frrCc = new HsFlowRunningRecord();
|
|
|
+ frrCc.setBaseId(flow.getBaseId());
|
|
|
+ frrCc.setTaskId(flow.getTaskId());
|
|
|
+ frrCc.setCreateTime(new Date());
|
|
|
+ frrCc.setComment("已抄送至下述人员:" + sbUname);
|
|
|
+ frrCc.setOperator(username);
|
|
|
+ frrCc.setYesOrNo(FlowEnum.CC.getValue());
|
|
|
+ list.add(frrCc);
|
|
|
+ } else {
|
|
|
+ nextFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
+ }
|
|
|
frr.setComment(hsFlowTask.getBaseName() + ":" + SecurityUtils.getLoginUser().getUser().getNickName() + " - " + flow.getComment());
|
|
|
- frr.setOperator(username);
|
|
|
frr.setYesOrNo(flow.getResult());
|
|
|
}
|
|
|
list.add(frr);
|
|
|
- if (StringUtils.isNotBlank(stepId)) {
|
|
|
+ if (StringUtils.isNotBlank(stepId) && StringUtils.isBlank(nextFlowBase.getCcId())) {
|
|
|
hsFlowTask.setBaseId(stepId);
|
|
|
//判断新组件下一步是否需要选择人员
|
|
|
- HsFlowBase hsFlowBase1 = flowBaseService.getCurrentFlowTaskBase(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
if (StringUtils.isNotBlank(flow.getNextApproval())) {
|
|
|
frr.setOperator(SecurityUtils.getUsername());
|
|
|
hsFlowTask.setOperator(flow.getNextApproval());
|
|
|
- hsFlowTask.setBaseName(hsFlowBase1.getFlowModuleName());
|
|
|
+ //如果有抄送获取抄送下一级的baseName
|
|
|
+ if (StringUtils.isNotBlank(nextFlowBase.getCcId())) {
|
|
|
+ hsFlowTask.setBaseName(baseName);
|
|
|
+ } else {
|
|
|
+ hsFlowTask.setBaseName(nextFlowBase.getFlowModuleName());
|
|
|
+ }
|
|
|
} else if (!resultTrue) {
|
|
|
hsFlowTask.setBaseId(stepId);
|
|
|
hsFlowTask.setOperator(flow.getNextApproval());
|
|
|
- HsFlowBase currentFlowTaskBase = flowBaseService.getCurrentFlowTaskBase(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
+ HsFlowBase currentFlowTaskBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
hsFlowTask.setBaseName(currentFlowTaskBase.getFlowModuleName());
|
|
|
- //拒绝时 通过记录 反向比对 查找上一步 同意的数据并 更新任务
|
|
|
-// List<HsFlowRunningRecord> flowRunningRecords = flowRunningRecordService.selectHsFlowRunningRecordTrue(flow.getTaskId());
|
|
|
-// int count = 0;
|
|
|
-// for (int i = 0; i < flowRunningRecords.size(); i++) {
|
|
|
-// String baseId = flowRunningRecords.get(i).getBaseId();
|
|
|
-// if (StringUtils.isNotBlank(baseId) && StringUtils.equals(baseId, stepId)) {
|
|
|
-// hsFlowTask.setBaseId(flowRunningRecords.get(i).getBaseId());
|
|
|
-// hsFlowTask.setOperator(flowRunningRecords.get(i).getOperator());
|
|
|
-// HsFlowBase currentFlowTaskBase = flowBaseService.getCurrentFlowTaskBase(hsFlowTask.getBaseGroupId(), baseId);
|
|
|
-// hsFlowTask.setBaseName(currentFlowTaskBase.getFlowModuleName());
|
|
|
-// count++;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
- //没有找到 直接结束
|
|
|
-// if (count == 0) {
|
|
|
-// stepId = null;
|
|
|
-// }
|
|
|
} else {
|
|
|
//避免异常找不到任务默认admin
|
|
|
hsFlowTask.setOperator("admin");
|
|
|
throw new BaseException("未选择下一步审批人员");
|
|
|
}
|
|
|
- if (null != hsFlowBase1 && StringUtils.isBlank(hsFlowBase1.getDownStepId()) &&
|
|
|
- StringUtils.isBlank(hsFlowBase1.getTermModuleId())) {
|
|
|
- hsFlowTask.setIsCandidate("1");
|
|
|
+ String isCandidate = null;
|
|
|
+ if (StringUtils.isNotBlank(nextFlowBase.getDownStepId())) {
|
|
|
+ //查询是否是抄送组件
|
|
|
+ HsFlowBase base = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), nextFlowBase.getDownStepId());
|
|
|
+ if (base != null && StringUtils.isNotBlank(base.getCcId())) {
|
|
|
+ isCandidate = "1";
|
|
|
+ } else {
|
|
|
+ isCandidate = "0";
|
|
|
+ }
|
|
|
+ } else if (StringUtils.isBlank(nextFlowBase.getTermModuleId())) {
|
|
|
+ isCandidate = "1";
|
|
|
} else {
|
|
|
- hsFlowTask.setIsCandidate("0");
|
|
|
+ isCandidate = "0";
|
|
|
}
|
|
|
+ hsFlowTask.setIsCandidate(isCandidate);
|
|
|
+ } else {
|
|
|
+ stepId = null;
|
|
|
}
|
|
|
//任务结束
|
|
|
if (StringUtils.isBlank(stepId) && !resultCaseOf) {
|
|
@@ -321,39 +365,29 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
appUserMsg.setRemark(hsFlowTask.getId());
|
|
|
appUserMsg.setCreateTime(new Date());
|
|
|
userMsgService.save(appUserMsg);
|
|
|
-
|
|
|
//推送微信审批结果通知
|
|
|
- WxMsgTemplateApprovalResult wxMsgTemplateApproval = new WxMsgTemplateApprovalResult();
|
|
|
- wxMsgTemplateApproval.setPhrase4(wxUtils.getFormat(resultTrue ? "已通过" : "已拒绝"));
|
|
|
- wxMsgTemplateApproval.setDate3(wxUtils.getFormat(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date())));
|
|
|
- wxMsgTemplateApproval.setThing6(wxUtils.getFormat(String.valueOf(formData.get("title"))));
|
|
|
- wxMsgService.sendQRCodeMsg(String.valueOf(formData.get("apply_user_id")), wxMsgTemplateApproval, WxTemplateKeyEnum.APPROVAL_RESULT, true);
|
|
|
+ wxMsgService.sendResultMsg(String.valueOf(formData.get("title")), resultTrue ? "已通过" : "已拒绝", String.valueOf(formData.get("apply_user_id")));
|
|
|
} else {
|
|
|
//任务继续
|
|
|
hsFlowTask.setMsgIsRead("0");
|
|
|
//生成审批结果消息列表
|
|
|
HsAppUserMsg appUserMsg = new HsAppUserMsg();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String content = null;
|
|
|
- try {
|
|
|
- String examplesId = hsFlowTask.getExamplesId();
|
|
|
- if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.BIZ_LEAVE_FLOW_KEY))) {
|
|
|
- content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
- "<p>申请人:" + formData.get("apply_user_name") + "</p>" +
|
|
|
- "<p>开始时间:" + DateUtils.dateTime(sdf.parse(formData.get("leave_start_time").toString())) + "</p>" +
|
|
|
- "<p>结束时间:" + DateUtils.dateTime(sdf.parse(formData.get("leave_end_time").toString())) + "</p>";
|
|
|
- } else if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.FILE_APPROVAL_FLOW_KEY))) {
|
|
|
- //异步生成审批消息列表
|
|
|
- content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
- "<p>申请人:" + formData.get("apply_user_name") + "</p>";
|
|
|
- } else if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.RESERVE_FLOW_KEY))) {
|
|
|
- content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
- "<p>申请人:" + formData.get("apply_user_name") + "</p>" +
|
|
|
- "<p>物资名称:" + formData.get("reserve_name") + "</p>" +
|
|
|
- "<p>申请数量:" + formData.get("apply_amount") + "</p>";
|
|
|
- }
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ String examplesId = hsFlowTask.getExamplesId();
|
|
|
+ if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.BIZ_LEAVE_FLOW_KEY))) {
|
|
|
+ content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
+ "<p>申请人:" + formData.get("apply_user_name") + "</p>" +
|
|
|
+ "<p>开始时间:" + formData.get("leave_start_time").toString() + "</p>" +
|
|
|
+ "<p>结束时间:" + formData.get("leave_end_time").toString() + "</p>";
|
|
|
+ } else if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.FILE_APPROVAL_FLOW_KEY))) {
|
|
|
+ //异步生成审批消息列表
|
|
|
+ content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
+ "<p>申请人:" + formData.get("apply_user_name") + "</p>";
|
|
|
+ } else if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.RESERVE_FLOW_KEY))) {
|
|
|
+ content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
+ "<p>申请人:" + formData.get("apply_user_name") + "</p>" +
|
|
|
+ "<p>物资名称:" + formData.get("reserve_name") + "</p>" +
|
|
|
+ "<p>申请数量:" + formData.get("apply_amount") + "</p>";
|
|
|
}
|
|
|
appUserMsg.setMsgContent(content);
|
|
|
appUserMsg.setMsgTitle(String.valueOf(formData.get("title")));
|
|
@@ -413,7 +447,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
if (StringUtils.isBlank(termModule.getDownStepId())) {
|
|
|
throw new BaseException("流程条件配置出错,没有后续审批人");
|
|
|
}
|
|
|
- HsFlowBase taskCurrentBase = flowBaseService.getCurrentFlowTaskBase(termModule.getGroupId()
|
|
|
+ HsFlowBase taskCurrentBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(termModule.getGroupId()
|
|
|
, termModule.getDownStepId());
|
|
|
if (null == taskCurrentBase) {
|
|
|
throw new BaseException("流程条件配置出错");
|
|
@@ -516,12 +550,19 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
@Override
|
|
|
public List<HsFlowRunningRecord> rejectTaskRecords(String taskId) {
|
|
|
if (StringUtils.isNotBlank(taskId)) {
|
|
|
- List<HsFlowRunningRecord> flowRunningRecords = flowRunningRecordService.getBaseMapper().selectList(new QueryWrapper<HsFlowRunningRecord>()
|
|
|
+ List<HsFlowRunningRecord> flowRunningRecords = new ArrayList<>();
|
|
|
+ HsFlowRunningRecord hsFlowRunningRecord = new HsFlowRunningRecord();
|
|
|
+ hsFlowRunningRecord.setTaskId(taskId);
|
|
|
+ hsFlowRunningRecord.setComment("发起人");
|
|
|
+ hsFlowRunningRecord.setYesOrNo("LAUNCH");
|
|
|
+ flowRunningRecords.add(hsFlowRunningRecord);
|
|
|
+ List<HsFlowRunningRecord> records = flowRunningRecordService.getBaseMapper().selectList(new QueryWrapper<HsFlowRunningRecord>()
|
|
|
.eq("task_id", taskId).last("AND yes_or_no = 'RESULT_TRUE' GROUP BY base_id"));
|
|
|
- flowRunningRecords.forEach(flowRunningRecord -> {
|
|
|
+ records.forEach(flowRunningRecord -> {
|
|
|
String comment = flowRunningRecord.getComment();
|
|
|
flowRunningRecord.setComment(comment.substring(0, comment.indexOf("-")));
|
|
|
});
|
|
|
+ flowRunningRecords.addAll(records);
|
|
|
return flowRunningRecords;
|
|
|
}
|
|
|
return null;
|
|
@@ -558,10 +599,17 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
|
|
|
@Override
|
|
|
public List<PostTreeVo> getApprovalTreePost(String groupId, String baseId) {
|
|
|
- HsFlowBase flowTaskCurrentBase = flowBaseService.getCurrentFlowTaskBase(groupId, baseId);
|
|
|
+ HsFlowBase flowTaskCurrentBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(groupId, baseId);
|
|
|
if (null == flowTaskCurrentBase) {
|
|
|
return null;
|
|
|
}
|
|
|
+ //如果是抄送组件
|
|
|
+ if (StringUtils.isNotBlank(flowTaskCurrentBase.getCcId())) {
|
|
|
+ String downStepId = flowTaskCurrentBase.getDownStepId();
|
|
|
+ if (StringUtils.isNotBlank(downStepId)) {
|
|
|
+ flowTaskCurrentBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(groupId, downStepId);
|
|
|
+ }
|
|
|
+ }
|
|
|
PostTreeVo postTreeVo = new PostTreeVo();
|
|
|
postTreeVo.setText(flowTaskCurrentBase.getFlowModuleName());
|
|
|
postTreeVo.setValue(flowTaskCurrentBase.getId());
|