|
@@ -4,6 +4,8 @@ import cn.hutool.json.JSONObject;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.willalp.common.core.domain.entity.SysUser;
|
|
|
+import com.willalp.common.core.domain.model.LoginUser;
|
|
|
import com.willalp.common.exception.base.BaseException;
|
|
|
import com.willalp.common.utils.DateUtils;
|
|
|
import com.willalp.common.utils.SecurityUtils;
|
|
@@ -16,7 +18,9 @@ import com.willalp.flow.mapper.*;
|
|
|
import com.willalp.flow.service.*;
|
|
|
import com.willalp.msg.domain.HsAppUserMsg;
|
|
|
import com.willalp.msg.service.IHsAppUserMsgService;
|
|
|
+import com.willalp.system.domain.HsPostConfig;
|
|
|
import com.willalp.system.domain.vo.PostTreeVo;
|
|
|
+import com.willalp.system.service.IHsPostConfigService;
|
|
|
import com.willalp.system.service.ISysConfigService;
|
|
|
import com.willalp.wx.domain.WxMsgTemplateApproval;
|
|
|
import com.willalp.wx.enums.WxTemplateKeyEnum;
|
|
@@ -80,9 +84,12 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
@Resource
|
|
|
private ISysConfigService sysConfigService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IHsPostConfigService postConfigService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> submitATask(HsFlowTask task, Map<String, Object> params) {
|
|
|
+ public Map<String, Object> submitTask(HsFlowTask task, Map<String, Object> params) {
|
|
|
String examplesId = task.getExamplesId();
|
|
|
if (StringUtils.isBlank(examplesId)) {
|
|
|
throw new BaseException("EXAMPLES_ID - IS_NULL");
|
|
@@ -130,8 +137,8 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
//启动超时删除线程
|
|
|
taskService.removeWaitTimeOutTask(task);
|
|
|
Map<String, Object> map = new HashMap<>(4);
|
|
|
- map.put("taskId" , task.getId());
|
|
|
- map.put("tree" , getApprovalTreePost(task.getBaseGroupId(), task.getBaseId()));
|
|
|
+ map.put("taskId", task.getId());
|
|
|
+ map.put("tree", getApprovalTreePost(task.getBaseGroupId(), task.getBaseId()));
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -167,7 +174,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
"<p>申请数量:" + formData.get("apply_amount") + "</p>";
|
|
|
}
|
|
|
//异步生成审批消息列表
|
|
|
- userMsgService.saveApprovalMsgAndPush("1" ,
|
|
|
+ userMsgService.saveApprovalMsgAndPush("1",
|
|
|
String.valueOf(formData.get("title")), content, taskId,
|
|
|
candidate, applyUserName, new Date());
|
|
|
} catch (ParseException e) {
|
|
@@ -191,11 +198,14 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
if (StringUtils.isBlank(flow.getResult())) {
|
|
|
throw new BaseException("FLOW_RESULT - IS_NULL");
|
|
|
}
|
|
|
- //获取任务实例
|
|
|
+ //获取任务实例并验证
|
|
|
HsFlowTask hsFlowTask = hsFlowTaskMapper.selectById(flow.getTaskId());
|
|
|
if (null == hsFlowTask) {
|
|
|
throw new BaseException("没有找到任务实例");
|
|
|
}
|
|
|
+ if (!SecurityUtils.getUsername().equals(hsFlowTask.getOperator())) {
|
|
|
+ throw new BaseException("无操作权限");
|
|
|
+ }
|
|
|
if ("1".equals(hsFlowTask.getIsEnd())) {
|
|
|
throw new BaseException("任务已结束");
|
|
|
}
|
|
@@ -205,40 +215,44 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
if (StringUtils.isBlank(hsFlowTask.getBaseGroupId())) {
|
|
|
throw new BaseException("FLOW_BASE_GROUP_ID - IS_NULL");
|
|
|
}
|
|
|
- //获取当前基础组件
|
|
|
- HsFlowBase hsFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), flow.getBaseId());
|
|
|
- if (null == hsFlowBase) {
|
|
|
- throw new BaseException("没有找到组件");
|
|
|
- }
|
|
|
+ //获取当前基础组件并验证
|
|
|
+ HsFlowBase flowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), flow.getBaseId());
|
|
|
//判断是否存在上级节点 不存在则为父级组件 然后跳过
|
|
|
- if (StringUtils.isBlank(hsFlowBase.getUpStepId())) {
|
|
|
- if (StringUtils.isNotBlank(hsFlowBase.getDownStepId())) {
|
|
|
- hsFlowBase = hsFlowBaseMapper.selectById(hsFlowBase.getDownStepId());
|
|
|
+ if (StringUtils.isBlank(flowBase.getUpStepId())) {
|
|
|
+ if (StringUtils.isNotBlank(flowBase.getDownStepId())) {
|
|
|
+ flowBase = hsFlowBaseMapper.selectById(flowBase.getDownStepId());
|
|
|
} else {
|
|
|
throw new BaseException("流程配置错误");
|
|
|
}
|
|
|
}
|
|
|
- if (!SecurityUtils.getUsername().equals(hsFlowTask.getOperator())) {
|
|
|
- throw new BaseException("无操作权限");
|
|
|
- }
|
|
|
- if (FlowEnum.IS_ONE.getValue().equals(hsFlowTask.getIsEnd())) {
|
|
|
- throw new BaseException("任务已经结束");
|
|
|
- }
|
|
|
String stepId = null;
|
|
|
//获取是否 是同意结果
|
|
|
boolean resultTrue = FlowEnum.RESULT_TRUE.getValue().equals(flow.getResult());
|
|
|
boolean resultCaseOf = FlowEnum.RESULT_CASE_OF.getValue().equals(flow.getResult());
|
|
|
Map<String, Object> formData = flow.getFormData();
|
|
|
+ //申请人[userCode]
|
|
|
+ String applyUserId = String.valueOf(formData.get("apply_user_id"));
|
|
|
+ //操作人信息
|
|
|
+ SysUser operator;
|
|
|
+ String username = null;
|
|
|
+ String nickName = null;
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ if (null != loginUser && null != loginUser.getUser()) {
|
|
|
+ operator = loginUser.getUser();
|
|
|
+ username = operator.getUserName();
|
|
|
+ nickName = operator.getNickName();
|
|
|
+ }
|
|
|
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());
|
|
|
+ //当前流程名 + 操作人
|
|
|
+ String frrComment = hsFlowTask.getBaseName() + ":" + nickName;
|
|
|
frr.setOperator(username);
|
|
|
- String baseName = null;
|
|
|
+ frr.setYesOrNo(flow.getResult());
|
|
|
+ list.add(frr);
|
|
|
if (resultCaseOf) {
|
|
|
//转交
|
|
|
hsFlowTask.setOperator(flow.getNextApproval());
|
|
@@ -247,180 +261,91 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
frr.setYesOrNo(flow.getResult());
|
|
|
} else {
|
|
|
if (resultTrue) {
|
|
|
- //查看有无条件组件
|
|
|
- hsFlowBase = getFlowBaseByTermResult(flow.getTaskId(), hsFlowBase, formData);
|
|
|
- stepId = hsFlowBase.getDownStepId();
|
|
|
+ //同意
|
|
|
+ frr.setComment(frrComment + (StringUtils.equals(CONSENT, flow.getComment()) ? " - " + CONSENT : " - " + CONSENT + ":" + flow.getComment()));
|
|
|
+ flowBase = baseRun(flowBase, hsFlowTask, formData);
|
|
|
+ stepId = flowBase.getDownStepId();
|
|
|
} else {
|
|
|
+ //拒绝
|
|
|
+ frr.setComment(frrComment + (StringUtils.equals(REJECT, flow.getComment()) ? " - " + REJECT : " - " + REJECT + ":" + flow.getComment()));
|
|
|
stepId = flow.getRejectBaseId();
|
|
|
+ flowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
}
|
|
|
- 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());
|
|
|
- }
|
|
|
- List<HsAppUserMsg> msgs = new ArrayList<>();
|
|
|
- //先持久化抄送数据
|
|
|
- flowCcService.save(cc);
|
|
|
- //再发送推送和生成审批结果消息列表
|
|
|
- if (0 != assignedUser.size()) {
|
|
|
- for (Operators.OperatorDto operatorDto : assignedUser) {
|
|
|
- //再发送推送和生成审批结果消息列表
|
|
|
- HsAppUserMsg appUserMsg = new HsAppUserMsg();
|
|
|
- appUserMsg.setMsgContent(String.valueOf(formData.get("apply_user_name")) + "的" + formData.get("title"));
|
|
|
- appUserMsg.setMsgTitle("审批抄送");
|
|
|
- appUserMsg.setMsgIsRead("0");
|
|
|
- appUserMsg.setUserCode(operatorDto.getId());
|
|
|
- appUserMsg.setMsgType("4");
|
|
|
- appUserMsg.setRemark(hsFlowTask.getId());
|
|
|
- appUserMsg.setCreateTime(new Date());
|
|
|
- msgs.add(appUserMsg);
|
|
|
- if (StringUtils.isBlank(nextFlowBase.getDownStepId())) {
|
|
|
- if (resultTrue) {
|
|
|
- wxMsgService.sendResultMsg("审批抄送 - " + formData.get("title"), "已通过" , operatorDto.getId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- stepId = nextFlowBase.getDownStepId();
|
|
|
- nextFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
- baseName = nextFlowBase.getFlowModuleName();
|
|
|
- wxMsgService.sendResultMsg("审批抄送 - " + formData.get("title"), "进行中" , operatorDto.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- userMsgService.saveBatch(msgs);
|
|
|
- }
|
|
|
- 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.setYesOrNo(flow.getResult());
|
|
|
- }
|
|
|
- list.add(frr);
|
|
|
- if (StringUtils.isNotBlank(stepId) && StringUtils.isBlank(nextFlowBase.getCcId())) {
|
|
|
- hsFlowTask.setBaseId(stepId);
|
|
|
- //判断新组件下一步是否需要选择人员
|
|
|
- if (StringUtils.isNotBlank(flow.getNextApproval())) {
|
|
|
- frr.setOperator(SecurityUtils.getUsername());
|
|
|
- hsFlowTask.setOperator(flow.getNextApproval());
|
|
|
- //如果有抄送获取抄送下一级的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.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
- hsFlowTask.setBaseName(currentFlowTaskBase.getFlowModuleName());
|
|
|
- } else {
|
|
|
- //避免异常找不到任务默认admin
|
|
|
- hsFlowTask.setOperator("admin");
|
|
|
- throw new BaseException("未选择下一步审批人员");
|
|
|
- }
|
|
|
- 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 {
|
|
|
- isCandidate = "0";
|
|
|
- }
|
|
|
- hsFlowTask.setIsCandidate(isCandidate);
|
|
|
- } else {
|
|
|
- stepId = null;
|
|
|
}
|
|
|
//任务结束
|
|
|
if (StringUtils.isBlank(stepId) && !resultCaseOf) {
|
|
|
hsFlowTask.setBaseId(null);
|
|
|
hsFlowTask.setOperator(hsFlowTask.getOperator());
|
|
|
- hsFlowTask.setIsEnd("1");
|
|
|
- hsFlowTask.setRemark("任务已结束");
|
|
|
- HsFlowRunningRecord frr1 = new HsFlowRunningRecord();
|
|
|
- frr1.setComment("自动结束");
|
|
|
- frr1.setOperator(SecurityUtils.getUsername());
|
|
|
- frr1.setTaskId(flow.getTaskId());
|
|
|
- frr1.setCreateTime(new Date(System.currentTimeMillis() + 1000));
|
|
|
- list.add(frr1);
|
|
|
+ hsFlowTask.setIsEnd(ONE);
|
|
|
+ hsFlowTask.setRemark(TASK_END_CN_TEXT);
|
|
|
+ HsFlowRunningRecord frrEnd = new HsFlowRunningRecord();
|
|
|
+ frrEnd.setComment(TASK_AUTO_END_CN_TEXT);
|
|
|
+ frrEnd.setOperator(SecurityUtils.getUsername());
|
|
|
+ frrEnd.setTaskId(flow.getTaskId());
|
|
|
+ frrEnd.setCreateTime(new Date(System.currentTimeMillis() + 1000));
|
|
|
+ list.add(frrEnd);
|
|
|
//生成审批结果消息列表
|
|
|
HsAppUserMsg appUserMsg = new HsAppUserMsg();
|
|
|
- appUserMsg.setMsgContent("您的 [" + formData.get("title") + "] 申请" + (resultTrue ? "已通过" : "已拒绝"));
|
|
|
+ appUserMsg.setMsgContent("您的 [" + formData.get(TITLE) + "] 申请" + (resultTrue ? APPROVED : DENIED));
|
|
|
appUserMsg.setMsgTitle("审批结果");
|
|
|
- appUserMsg.setMsgIsRead("0");
|
|
|
- appUserMsg.setUserCode(String.valueOf(formData.get("apply_user_id")));
|
|
|
- appUserMsg.setMsgType("4");
|
|
|
+ appUserMsg.setMsgIsRead(ZERO);
|
|
|
+ appUserMsg.setUserCode(applyUserId);
|
|
|
+ appUserMsg.setMsgType(FOUR);
|
|
|
+ appUserMsg.setIsPush(ZERO);
|
|
|
appUserMsg.setRemark(hsFlowTask.getId());
|
|
|
appUserMsg.setCreateTime(new Date());
|
|
|
userMsgService.save(appUserMsg);
|
|
|
//推送微信审批结果通知
|
|
|
- wxMsgService.sendResultMsg(String.valueOf(formData.get("title")), resultTrue ? "已通过" : "已拒绝" , String.valueOf(formData.get("apply_user_id")));
|
|
|
+ wxMsgService.sendResultMsg(String.valueOf(formData.get(TITLE)), resultTrue ? APPROVED : DENIED, applyUserId);
|
|
|
} else {
|
|
|
//任务继续
|
|
|
- hsFlowTask.setMsgIsRead("0");
|
|
|
+ hsFlowTask.setMsgIsRead(ZERO);
|
|
|
+ hsFlowTask.setOperator(flow.getNextApproval());
|
|
|
+ hsFlowTask.setBaseName(flowBase.getFlowModuleName());
|
|
|
+ hsFlowTask.setBaseId(flowBase.getId());
|
|
|
+ if (StringUtils.isNotBlank(flowBase.getDownStepId())) {
|
|
|
+ HsFlowBase nextFlowBase = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(hsFlowTask.getBaseGroupId(), stepId);
|
|
|
+ if (nextFlowBase != null && nextFlowBase.getModelType().equals(APPROVAL)) {
|
|
|
+ hsFlowTask.setIsCandidate(ZERO);
|
|
|
+ } else {
|
|
|
+ hsFlowTask.setIsCandidate(ONE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ hsFlowTask.setIsCandidate(ONE);
|
|
|
+ }
|
|
|
//生成审批结果消息列表
|
|
|
HsAppUserMsg appUserMsg = new HsAppUserMsg();
|
|
|
String content = null;
|
|
|
String examplesId = hsFlowTask.getExamplesId();
|
|
|
if (examplesId.equals(sysConfigService.selectConfigByKey(HsFlowEngineService.BIZ_LEAVE_FLOW_KEY))) {
|
|
|
- content = "<p>标题:" + formData.get("title") + "</p>" +
|
|
|
+ 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>" +
|
|
|
+ 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>" +
|
|
|
+ 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")));
|
|
|
- appUserMsg.setMsgIsRead("0");
|
|
|
+ appUserMsg.setMsgTitle(String.valueOf(formData.get(TITLE)));
|
|
|
+ appUserMsg.setMsgIsRead(ZERO);
|
|
|
appUserMsg.setUserCode(hsFlowTask.getOperator());
|
|
|
- appUserMsg.setMsgType("1");
|
|
|
+ appUserMsg.setMsgType(ONE);
|
|
|
+ appUserMsg.setIsPush(ZERO);
|
|
|
appUserMsg.setRemark(hsFlowTask.getId());
|
|
|
appUserMsg.setCreateTime(new Date());
|
|
|
userMsgService.save(appUserMsg);
|
|
|
//推送微信待审批通知
|
|
|
WxMsgTemplateApproval wxMsgTemplateApproval = new WxMsgTemplateApproval();
|
|
|
- wxMsgTemplateApproval.setThing5(wxUtils.getFormat(String.valueOf(formData.get("title"))));
|
|
|
+ wxMsgTemplateApproval.setThing5(wxUtils.getFormat(String.valueOf(formData.get(TITLE))));
|
|
|
wxMsgTemplateApproval.setThing11(wxUtils.getFormat(String.valueOf(formData.get("apply_user_name"))));
|
|
|
- wxMsgTemplateApproval.setTime12(wxUtils.getFormat(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss" , new Date())));
|
|
|
+ wxMsgTemplateApproval.setTime12(wxUtils.getFormat(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date())));
|
|
|
wxMsgService.sendQRCodeMsg(hsFlowTask.getOperator(), wxMsgTemplateApproval, WxTemplateKeyEnum.APPROVAL_WAIT, true);
|
|
|
}
|
|
|
hsFlowTaskMapper.updateById(hsFlowTask);
|
|
@@ -428,6 +353,109 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HsFlowBase baseRun(HsFlowBase base, HsFlowTask task, Map<String, Object> formData) {
|
|
|
+ switch (base.getModelType()) {
|
|
|
+ case APPROVAL:
|
|
|
+ //直接获取下一级节点
|
|
|
+ base = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(task.getBaseGroupId(), base.getDownStepId());
|
|
|
+ //如果下一个不是审批组件则再进行一步,如抄送,延时处理,触发器等
|
|
|
+ if (!APPROVAL.equals(base.getModelType())) {
|
|
|
+ return baseRun(base, task, formData);
|
|
|
+ } else {
|
|
|
+ return base;
|
|
|
+ }
|
|
|
+ case DELAY:
|
|
|
+ //延时处理节点
|
|
|
+ break;
|
|
|
+ case TRIGGER:
|
|
|
+ //触发器节点
|
|
|
+ break;
|
|
|
+ case CONCURRENT:
|
|
|
+ //并行节点
|
|
|
+ break;
|
|
|
+ case CONDITIONS:
|
|
|
+ //设置条件组ID,并与父级ID组合为复合主键确认唯一性(逻辑唯一)
|
|
|
+ return getFlowBaseByTermResult(task.getId(), base, formData);
|
|
|
+ case CONDITION:
|
|
|
+ //解析单个条件中的详细数据
|
|
|
+ break;
|
|
|
+ case CC:
|
|
|
+ //抄送节点
|
|
|
+ HsFlowCc cc = new HsFlowCc();
|
|
|
+ cc.setExamplesId(task.getExamplesId());
|
|
|
+ cc.setFormData(JSON.toJSONString(formData));
|
|
|
+ cc.setTaskId(task.getId());
|
|
|
+ cc.setTitle(task.getTaskName());
|
|
|
+ cc.setCreateTime(new Date());
|
|
|
+ cc.setUpdateTime(new Date());
|
|
|
+ Operators operators = JSON.parseObject(base.getOperator(), Operators.class);
|
|
|
+ List<Operators.OperatorDto> assignedUser = operators.getAssignedUser();
|
|
|
+ List<String> sbUid = new ArrayList<>();
|
|
|
+ StringBuilder sbUname = new StringBuilder();
|
|
|
+ if (0 != assignedUser.size()) {
|
|
|
+ for (int i = 0; i < assignedUser.size(); i++) {
|
|
|
+ if (i != (assignedUser.size() - 1)) {
|
|
|
+ sbUid.add(assignedUser.get(i).getId() + ",");
|
|
|
+ sbUname.append(assignedUser.get(i).getName()).append(",");
|
|
|
+ } else {
|
|
|
+ sbUid.add(assignedUser.get(i).getId());
|
|
|
+ sbUname.append(assignedUser.get(i).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PostTreeVo> postTreeVos = new ArrayList<>();
|
|
|
+ for (String id : sbUid) {
|
|
|
+ HsPostConfig postConfig = postConfigService.getBaseMapper().selectOne(new QueryWrapper<HsPostConfig>()
|
|
|
+ .eq("id", id));
|
|
|
+ cc.setUsers(postConfig.getPostUserG());
|
|
|
+ postTreeVos.addAll(postConfigService.setUsers(postConfig));
|
|
|
+ }
|
|
|
+ HsFlowRunningRecord frrCc = new HsFlowRunningRecord();
|
|
|
+ frrCc.setBaseId(base.getId());
|
|
|
+ frrCc.setTaskId(task.getId());
|
|
|
+ frrCc.setCreateTime(new Date());
|
|
|
+ frrCc.setComment("已抄送至:" + sbUname);
|
|
|
+ frrCc.setOperator(SecurityUtils.getUsername());
|
|
|
+ frrCc.setYesOrNo(FlowEnum.CC.getValue());
|
|
|
+ frrCc.setCreateTime(new Date());
|
|
|
+ //先持久化抄送数据
|
|
|
+ flowCcService.save(cc);
|
|
|
+ flowRunningRecordService.save(frrCc);
|
|
|
+ List<HsAppUserMsg> msgs = new ArrayList<>();
|
|
|
+ //再发送推送和生成审批结果消息列表
|
|
|
+ if (0 != postTreeVos.size()) {
|
|
|
+ for (PostTreeVo postTreeVo : postTreeVos) {
|
|
|
+ //再发送推送和生成审批结果消息列表
|
|
|
+ HsAppUserMsg appUserMsg = new HsAppUserMsg();
|
|
|
+ appUserMsg.setMsgContent(formData.get("apply_user_name") + "的 [" + formData.get("title") + "]");
|
|
|
+ appUserMsg.setMsgTitle(CC_TITLE);
|
|
|
+ appUserMsg.setMsgIsRead(ZERO);
|
|
|
+ appUserMsg.setUserCode(postTreeVo.getValue());
|
|
|
+ appUserMsg.setMsgType(SEVEN);
|
|
|
+ appUserMsg.setIsPush(ZERO);
|
|
|
+ appUserMsg.setRemark(task.getId());
|
|
|
+ appUserMsg.setCreateTime(new Date());
|
|
|
+ msgs.add(appUserMsg);
|
|
|
+ if (StringUtils.isBlank(base.getDownStepId())) {
|
|
|
+ wxMsgService.sendResultMsg(CC_TITLE + " - " + formData.get(TITLE), APPROVED, postTreeVo.getValue());
|
|
|
+ } else {
|
|
|
+ base = flowBaseService.getFlowTaskBaseByGroupIdAndBaseId(task.getBaseGroupId(), base.getDownStepId());
|
|
|
+ wxMsgService.sendResultMsg(CC_TITLE + " - " + formData.get(TITLE), UNDERWAY, postTreeVo.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ userMsgService.saveBatch(msgs);
|
|
|
+ }
|
|
|
+ return base;
|
|
|
+ case ROOT:
|
|
|
+
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ throw new BaseException("流程配置出错");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 通过条件组件判断结果获取流程组件
|
|
@@ -458,7 +486,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
if (conditionModelService.executeConditionJudgment(item, params.get(paramName))) {
|
|
|
//对应条件组件
|
|
|
HsFlowBase termModule = hsFlowBaseMapper.selectOne(
|
|
|
- new QueryWrapper<HsFlowBase>().eq("term_module_id" , item.getId()));
|
|
|
+ new QueryWrapper<HsFlowBase>().eq("term_module_id", item.getId()));
|
|
|
if (null == termModule) {
|
|
|
throw new BaseException("流程条件配置出错");
|
|
|
}
|
|
@@ -477,7 +505,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
}
|
|
|
hsFlowTaskMapper.deleteById(taskId);
|
|
|
flowRunningRecordService.remove(new QueryWrapper<HsFlowRunningRecord>()
|
|
|
- .eq("task_id" , taskId));
|
|
|
+ .eq("task_id", taskId));
|
|
|
throw new BaseException("流程条件未满足,流程关闭,请重新发起");
|
|
|
} else {
|
|
|
return hsFlowBase;
|
|
@@ -490,7 +518,7 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
return null;
|
|
|
}
|
|
|
List<HsFlowTask> hsFlowTasks = hsFlowTaskMapper.selectList(new QueryWrapper<HsFlowTask>()
|
|
|
- .eq("id" , taskId));
|
|
|
+ .eq("id", taskId));
|
|
|
return getHsFlowTasks(hsFlowTasks);
|
|
|
}
|
|
|
|
|
@@ -533,8 +561,8 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
.selectBusinessCase(example.getBusinessTableName(), businessId);
|
|
|
if (ObjectUtils.isNotNull(stringObjectMap)) {
|
|
|
if ("biz_leave".equals(example.getBusinessTableName())) {
|
|
|
- List<Map<String, Object>> leaveImgs = leaveImgService.getBaseMapper().selectMaps(new QueryWrapper<BizLeaveImg>().eq("biz_leave_id" , businessId));
|
|
|
- stringObjectMap.put("imgUrls" , leaveImgs);
|
|
|
+ List<Map<String, Object>> leaveImgs = leaveImgService.getBaseMapper().selectMaps(new QueryWrapper<BizLeaveImg>().eq("biz_leave_id", businessId));
|
|
|
+ stringObjectMap.put("imgUrls", leaveImgs);
|
|
|
}
|
|
|
//统一时间类型字段处理
|
|
|
Set<String> strings = stringObjectMap.keySet();
|
|
@@ -569,6 +597,10 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
@Override
|
|
|
public List<HsFlowRunningRecord> rejectTaskRecords(String taskId) {
|
|
|
if (StringUtils.isNotBlank(taskId)) {
|
|
|
+ HsFlowTask task = taskService.getById(taskId);
|
|
|
+ if (task == null) {
|
|
|
+ throw new BaseException("task not found");
|
|
|
+ }
|
|
|
List<HsFlowRunningRecord> flowRunningRecords = new ArrayList<>();
|
|
|
HsFlowRunningRecord hsFlowRunningRecord = new HsFlowRunningRecord();
|
|
|
hsFlowRunningRecord.setTaskId(taskId);
|
|
@@ -576,22 +608,27 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
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"));
|
|
|
- records.forEach(flowRunningRecord -> {
|
|
|
- String comment = flowRunningRecord.getComment();
|
|
|
- flowRunningRecord.setComment(comment.substring(0, comment.indexOf("-")));
|
|
|
- });
|
|
|
- flowRunningRecords.addAll(records);
|
|
|
+ .eq("task_id", taskId).last("AND yes_or_no = 'RESULT_TRUE' GROUP BY base_id"));
|
|
|
+
|
|
|
+ for (HsFlowRunningRecord record : records) {
|
|
|
+ if (StringUtils.isNotBlank(record.getBaseId()) &&
|
|
|
+ StringUtils.equals(record.getBaseId(), task.getBaseId())) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String comment = record.getComment();
|
|
|
+ record.setComment(comment.substring(0, comment.indexOf("-")));
|
|
|
+ flowRunningRecords.add(record);
|
|
|
+ }
|
|
|
return flowRunningRecords;
|
|
|
}
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int revoke(String taskId) {
|
|
|
if (StringUtils.isNotBlank(taskId)) {
|
|
|
long selectCount = flowRunningRecordService.getBaseMapper().selectCount(new QueryWrapper<HsFlowRunningRecord>()
|
|
|
- .eq("task_id" , taskId));
|
|
|
+ .eq("task_id", taskId));
|
|
|
if (selectCount > 0) {
|
|
|
throw new BaseException("已有审批结果无法撤销");
|
|
|
}
|
|
@@ -623,33 +660,24 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
return null;
|
|
|
}
|
|
|
//如果是抄送组件
|
|
|
- if (StringUtils.isNotBlank(flowTaskCurrentBase.getCcId())) {
|
|
|
+ if (CC.equals(flowTaskCurrentBase.getModelType())) {
|
|
|
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());
|
|
|
Operators operators = JSON.parseObject(flowTaskCurrentBase.getOperator(), Operators.class);
|
|
|
List<Operators.OperatorDto> assignedUser = operators.getAssignedUser();
|
|
|
List<PostTreeVo> list = new ArrayList<>();
|
|
|
+ PostTreeVo postTreeVo = new PostTreeVo();
|
|
|
+ postTreeVo.setText(flowTaskCurrentBase.getFlowModuleName());
|
|
|
+ postTreeVo.setValue(flowTaskCurrentBase.getId());
|
|
|
if (0 != assignedUser.size()) {
|
|
|
- List<PostTreeVo> postTreeCcVos = new ArrayList<>();
|
|
|
- assignedUser.forEach(item -> {
|
|
|
- PostTreeVo postTreeCcVo = new PostTreeVo();
|
|
|
- postTreeCcVo.setText(item.getName());
|
|
|
- postTreeCcVo.setValue(item.getId());
|
|
|
- postTreeCcVos.add(postTreeCcVo);
|
|
|
- });
|
|
|
- if (postTreeCcVos.size() != 0) {
|
|
|
- postTreeVo.setChildren(postTreeCcVos);
|
|
|
- } else {
|
|
|
- postTreeVo.setChildren(null);
|
|
|
- }
|
|
|
- list.add(postTreeVo);
|
|
|
+ List<HsPostConfig> postConfigs = postConfigService.getBaseMapper().selectList(new QueryWrapper<HsPostConfig>()
|
|
|
+ .eq("id", assignedUser.get(0).getId()));
|
|
|
+ postTreeVo.setChildren(postConfigService.getTreePost(postConfigs).get(0).getChildren());
|
|
|
}
|
|
|
+ list.add(postTreeVo);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -661,5 +689,41 @@ public class HsFlowEngineServiceImpl implements HsFlowEngineService {
|
|
|
}
|
|
|
return getApprovalTreePost(groupId, nextFlowTaskBase.getId());
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ int[][] array = {
|
|
|
+ {1, 2, 3, 1, 2, 3},
|
|
|
+ {4, 5, 6, 1, 2, 3},
|
|
|
+ {7, 8, 9, 1, 2, 3},
|
|
|
+ {7, 8, 9, 1, 2, 3},
|
|
|
+ {7, 8, 9, 1, 2, 3},
|
|
|
+ {7, 8, 9, 1, 2, 3}
|
|
|
+ };
|
|
|
+ int column = 0;
|
|
|
+ int sum = 0;
|
|
|
+ //高
|
|
|
+ int height = array.length;
|
|
|
+ //宽
|
|
|
+ int width = array[0].length;
|
|
|
+ if (width != height) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int sumItem = width * height;
|
|
|
+ if (sumItem % 2 == 0) {
|
|
|
+ //偶数
|
|
|
+ for (int i = 0; i < array.length; i++) {
|
|
|
+ sum += array[i][column];
|
|
|
+ column++;
|
|
|
+ }
|
|
|
+ column = width - 1;
|
|
|
+ for (int i = array.length - 1; i >= 0; i--) {
|
|
|
+ sum += array[i][column];
|
|
|
+ column--;
|
|
|
+ }
|
|
|
+ System.out.println("SUM - " + sum);
|
|
|
+ } else {
|
|
|
+ //奇数
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|