yxk-20260525-办理的时候,写入新建的审批意见表
This commit is contained in:
+198
-71
@@ -3,6 +3,7 @@ package org.jeecg.modules.extbpm.process.service.impl;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.flowable.engine.HistoryService;
|
import org.flowable.engine.HistoryService;
|
||||||
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.RuntimeService;
|
||||||
@@ -11,45 +12,55 @@ import org.flowable.engine.history.HistoricProcessInstance;
|
|||||||
import org.flowable.engine.runtime.ProcessInstance;
|
import org.flowable.engine.runtime.ProcessInstance;
|
||||||
import org.flowable.task.api.Task;
|
import org.flowable.task.api.Task;
|
||||||
import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
|
import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
|
||||||
import org.jeecg.common.api.dto.message.TemplateDTO;
|
|
||||||
import org.jeecg.common.constant.CommonSendStatus;
|
import org.jeecg.common.constant.CommonSendStatus;
|
||||||
import org.jeecg.common.constant.enums.EmailTemplateEnum;
|
import org.jeecg.common.constant.enums.EmailTemplateEnum;
|
||||||
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
|
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.*;
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.jeecg.modules.extbpm.process.entity.ExtActBpmFile;
|
import org.jeecg.modules.extbpm.process.entity.ExtActBpmFile;
|
||||||
import org.jeecg.modules.extbpm.process.entity.ExtActBpmLog;
|
import org.jeecg.modules.extbpm.process.entity.ExtActBpmLog;
|
||||||
|
import org.jeecg.modules.extbpm.process.entity.ExtActFlowData;
|
||||||
import org.jeecg.modules.extbpm.process.entity.ExtActTaskCc;
|
import org.jeecg.modules.extbpm.process.entity.ExtActTaskCc;
|
||||||
import org.jeecg.modules.extbpm.process.mapper.ExtActBpmFileMapper;
|
import org.jeecg.modules.extbpm.process.mapper.ExtActBpmFileMapper;
|
||||||
import org.jeecg.modules.extbpm.process.mapper.ExtActBpmLogMapper;
|
import org.jeecg.modules.extbpm.process.mapper.ExtActBpmLogMapper;
|
||||||
|
import org.jeecg.modules.extbpm.process.mapper.ExtActFlowDataMapper;
|
||||||
import org.jeecg.modules.extbpm.process.mapper.ExtActTaskCcMapper;
|
import org.jeecg.modules.extbpm.process.mapper.ExtActTaskCcMapper;
|
||||||
import org.jeecg.modules.extbpm.process.service.IExtActBpmLogService;
|
import org.jeecg.modules.extbpm.process.service.IExtActBpmLogService;
|
||||||
import org.jeecg.modules.extbpm.util.BpmSytemMsgPushUtil;
|
import org.jeecg.modules.extbpm.util.BpmSytemMsgPushUtil;
|
||||||
|
import org.jeecg.modules.taskapprovalopinion.entity.TaskApprovalOpinion;
|
||||||
|
import org.jeecg.modules.taskapprovalopinion.service.ITaskApprovalOpinionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 流程审批日志
|
* 流程审批日志服务。
|
||||||
* @author: jeecg-boot
|
|
||||||
* @date: 2019-03-28
|
|
||||||
* @version: V1.0
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("extActBpmLogService")
|
@Service("extActBpmLogService")
|
||||||
public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, ExtActBpmLog> implements IExtActBpmLogService {
|
public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, ExtActBpmLog> implements IExtActBpmLogService {
|
||||||
|
private static final String RECORD_TYPE_PROCESS = "PROCESS";
|
||||||
|
private static final String RECORD_TYPE_SYSTEM = "SYSTEM";
|
||||||
|
|
||||||
|
private static final String ACTION_APPROVE = "APPROVE";
|
||||||
|
private static final String ACTION_REJECT = "REJECT";
|
||||||
|
private static final String ACTION_TRANSFER = "TRANSFER";
|
||||||
|
private static final String ACTION_ENTRUST = "ENTRUST";
|
||||||
|
private static final String ACTION_ADD_SIGN = "ADD_SIGN";
|
||||||
|
private static final String ACTION_INVALID = "INVALID";
|
||||||
|
private static final String ACTION_CALLBACK = "CALLBACK";
|
||||||
|
private static final String ACTION_SYSTEM = "SYSTEM";
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysBaseAPI sysBaseAPI;
|
private ISysBaseAPI sysBaseAPI;
|
||||||
@@ -58,6 +69,12 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ExtActBpmFileMapper extActBpmFileMapper;
|
private ExtActBpmFileMapper extActBpmFileMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private ExtActFlowDataMapper extActFlowDataMapper;
|
||||||
|
@Autowired
|
||||||
|
private ITaskApprovalOpinionService taskApprovalOpinionService;
|
||||||
|
@Autowired(required = false)
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
@Autowired
|
||||||
protected RuntimeService runtimeService;
|
protected RuntimeService runtimeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected HistoryService historyService;
|
protected HistoryService historyService;
|
||||||
@@ -65,13 +82,7 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
protected TaskService taskService;
|
protected TaskService taskService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存审批意见和附件
|
* 保存任务办理意见和附件,旧审批日志写入成功后再尝试双写新表。
|
||||||
*
|
|
||||||
* @param username
|
|
||||||
* @param map
|
|
||||||
* @param task
|
|
||||||
* @param processInstanceId
|
|
||||||
* @param rejectDescription
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveTaskHandBpmLog(String username, Map map, Task task, String processInstanceId, String rejectDescription) {
|
public void saveTaskHandBpmLog(String username, Map map, Task task, String processInstanceId, String rejectDescription) {
|
||||||
@@ -82,8 +93,8 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
taskCc(ccUserNames, task, username);
|
taskCc(ccUserNames, task, username);
|
||||||
//每个task节点执行完成后,处理审批日志
|
//每个task节点执行完成后,处理审批日志
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||||
|
String reason = appendRejectDescription(oConvertUtils.getString(map.get("reason")), rejectDescription);
|
||||||
|
|
||||||
String reason = oConvertUtils.getString(map.get("reason"));
|
|
||||||
ExtActBpmLog bpmlog = new ExtActBpmLog();
|
ExtActBpmLog bpmlog = new ExtActBpmLog();
|
||||||
if (processInstance != null) {
|
if (processInstance != null) {
|
||||||
bpmlog.setBusinessKey(processInstance.getBusinessKey());
|
bpmlog.setBusinessKey(processInstance.getBusinessKey());
|
||||||
@@ -97,9 +108,6 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
bpmlog.setOpUserName(user.getRealname());
|
bpmlog.setOpUserName(user.getRealname());
|
||||||
}
|
}
|
||||||
bpmlog.setProcInstId(processInstanceId);
|
bpmlog.setProcInstId(processInstanceId);
|
||||||
if (oConvertUtils.isNotEmpty(rejectDescription)) {
|
|
||||||
reason = reason + " 『 " + rejectDescription + " 』";
|
|
||||||
}
|
|
||||||
bpmlog.setRemarks(reason);
|
bpmlog.setRemarks(reason);
|
||||||
bpmlog.setTaskDefKey(task.getTaskDefinitionKey());
|
bpmlog.setTaskDefKey(task.getTaskDefinitionKey());
|
||||||
bpmlog.setTaskId(task.getId());
|
bpmlog.setTaskId(task.getId());
|
||||||
@@ -108,6 +116,10 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
//保存附件
|
//保存附件
|
||||||
String fileList = oConvertUtils.getString(map.get("fileList"));
|
String fileList = oConvertUtils.getString(map.get("fileList"));
|
||||||
saveBpmFiles(bpmlog.getId(), fileList);
|
saveBpmFiles(bpmlog.getId(), fileList);
|
||||||
|
|
||||||
|
//写入新的审批意见表
|
||||||
|
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS,
|
||||||
|
resolveHandleActionType(map, rejectDescription), resolveActionResult(reason, "同意"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,23 +143,21 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
taskLog.setProcInstId(processInstanceId);
|
taskLog.setProcInstId(processInstanceId);
|
||||||
taskLog.setRemarks(comment);
|
taskLog.setRemarks(comment);
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
//根据流程实例 ID 获取当前活动任务
|
|
||||||
task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult();
|
task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult();
|
||||||
}
|
}
|
||||||
taskLog.setTaskDefKey(task.getTaskDefinitionKey());
|
if (task != null) {
|
||||||
taskLog.setTaskId(task.getId());
|
taskLog.setTaskDefKey(task.getTaskDefinitionKey());
|
||||||
taskLog.setTaskName(task.getName());
|
taskLog.setTaskId(task.getId());
|
||||||
|
taskLog.setTaskName(task.getName());
|
||||||
|
}
|
||||||
this.baseMapper.insert(taskLog);
|
this.baseMapper.insert(taskLog);
|
||||||
|
|
||||||
|
saveTaskApprovalOpinion(taskLog, processInstance, RECORD_TYPE_SYSTEM,
|
||||||
|
resolveSystemActionType(comment), resolveActionResult(comment, "系统记录"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存审批意见和附件
|
* 保存审批意见。当前调用方主要用于加签等不带附件的记录。
|
||||||
*
|
|
||||||
* @param username 审批人
|
|
||||||
* @param reason 审批意见
|
|
||||||
* @param task
|
|
||||||
* @param processInstanceId
|
|
||||||
* @param rejectDescription 驳回理由
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveBpmLog(String username, String reason, Task task, String processInstanceId, String rejectDescription) {
|
public void saveBpmLog(String username, String reason, Task task, String processInstanceId, String rejectDescription) {
|
||||||
@@ -155,6 +165,7 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
// 任务抄送处理
|
// 任务抄送处理
|
||||||
//每个task节点执行完成后,处理审批日志
|
//每个task节点执行完成后,处理审批日志
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
||||||
|
reason = appendRejectDescription(reason, rejectDescription);
|
||||||
|
|
||||||
ExtActBpmLog bpmlog = new ExtActBpmLog();
|
ExtActBpmLog bpmlog = new ExtActBpmLog();
|
||||||
if (processInstance != null) {
|
if (processInstance != null) {
|
||||||
@@ -169,16 +180,14 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
bpmlog.setOpUserName(user.getRealname());
|
bpmlog.setOpUserName(user.getRealname());
|
||||||
}
|
}
|
||||||
bpmlog.setProcInstId(processInstanceId);
|
bpmlog.setProcInstId(processInstanceId);
|
||||||
if (oConvertUtils.isNotEmpty(rejectDescription)) {
|
|
||||||
reason = reason + " 『 " + rejectDescription + " 』";
|
|
||||||
}
|
|
||||||
bpmlog.setRemarks(reason);
|
bpmlog.setRemarks(reason);
|
||||||
bpmlog.setTaskDefKey(task.getTaskDefinitionKey());
|
bpmlog.setTaskDefKey(task.getTaskDefinitionKey());
|
||||||
bpmlog.setTaskId(task.getId());
|
bpmlog.setTaskId(task.getId());
|
||||||
bpmlog.setTaskName(task.getName());
|
bpmlog.setTaskName(task.getName());
|
||||||
this.baseMapper.insert(bpmlog);
|
this.baseMapper.insert(bpmlog);
|
||||||
}
|
|
||||||
|
|
||||||
|
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS, ACTION_ADD_SIGN, resolveActionResult(reason, "加签"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ExtActBpmLog> getBpmLogsbyProcessId(String processInstanceId) {
|
public List<ExtActBpmLog> getBpmLogsbyProcessId(String processInstanceId) {
|
||||||
@@ -188,10 +197,147 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存审批附件
|
* 以旧表写入结果为准,新审批意见表只做尽力双写,失败不能影响办理主流程。
|
||||||
*
|
*/
|
||||||
* @param bpmLogId
|
private void saveTaskApprovalOpinion(ExtActBpmLog bpmLog, ProcessInstance processInstance,
|
||||||
* @param fileList
|
String recordType, String actionType, String actionResult) {
|
||||||
|
try {
|
||||||
|
TaskApprovalOpinion opinion = new TaskApprovalOpinion();
|
||||||
|
opinion.setRecordType(recordType);
|
||||||
|
opinion.setProcessInstId(bpmLog.getProcInstId());
|
||||||
|
opinion.setFlowTaskId(bpmLog.getTaskId());
|
||||||
|
opinion.setTaskDefKey(bpmLog.getTaskDefKey());
|
||||||
|
opinion.setTaskName(bpmLog.getTaskName());
|
||||||
|
opinion.setActionType(actionType);
|
||||||
|
opinion.setActionResult(actionResult);
|
||||||
|
opinion.setOpinion(bpmLog.getRemarks());
|
||||||
|
opinion.setOpUserId(bpmLog.getOpUserId());
|
||||||
|
opinion.setOpUserName(bpmLog.getOpUserName());
|
||||||
|
opinion.setOpTime(bpmLog.getOpTime());
|
||||||
|
opinion.setDelFlag("0");
|
||||||
|
opinion.setCreateBy(bpmLog.getOpUserId());
|
||||||
|
opinion.setCreateTime(bpmLog.getOpTime());
|
||||||
|
|
||||||
|
fillBusinessSnapshot(opinion, resolveBusinessKey(bpmLog, processInstance));
|
||||||
|
|
||||||
|
taskApprovalOpinionService.save(opinion);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("保存 task_approval_opinion 失败,已保留原 ext_act_bpm_log。procInstId={}, taskId={}",
|
||||||
|
bpmLog.getProcInstId(), bpmLog.getTaskId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String appendRejectDescription(String reason, String rejectDescription) {
|
||||||
|
if (oConvertUtils.isNotEmpty(rejectDescription)) {
|
||||||
|
return reason + " 【" + rejectDescription + "】";
|
||||||
|
}
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveBusinessKey(ExtActBpmLog bpmLog, ProcessInstance processInstance) {
|
||||||
|
if (oConvertUtils.isNotEmpty(bpmLog.getBusinessKey())) {
|
||||||
|
return bpmLog.getBusinessKey();
|
||||||
|
}
|
||||||
|
return processInstance == null ? null : processInstance.getBusinessKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillBusinessSnapshot(TaskApprovalOpinion opinion, String businessKey) {
|
||||||
|
ExtActFlowData flowData = queryFlowData(opinion.getProcessInstId());
|
||||||
|
if (flowData != null) {
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getTaskTaskId())) {
|
||||||
|
opinion.setTaskTaskId(flowData.getFormDataId());
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getFlowCode())) {
|
||||||
|
opinion.setFlowCode(flowData.getRelationCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getTaskTaskId()) && oConvertUtils.isNotEmpty(businessKey)) {
|
||||||
|
opinion.setTaskTaskId(businessKey);
|
||||||
|
}
|
||||||
|
fillTaskTaskFields(opinion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExtActFlowData queryFlowData(String processInstanceId) {
|
||||||
|
if (oConvertUtils.isEmpty(processInstanceId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<ExtActFlowData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(ExtActFlowData::getProcessInstId, processInstanceId);
|
||||||
|
List<ExtActFlowData> flowDataList = extActFlowDataMapper.selectList(queryWrapper);
|
||||||
|
return flowDataList.isEmpty() ? null : flowDataList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* task_task 属于其他业务表,这里只做可选补齐,避免新表双写反向影响办理流程。
|
||||||
|
*/
|
||||||
|
private void fillTaskTaskFields(TaskApprovalOpinion opinion) {
|
||||||
|
if (jdbcTemplate == null || oConvertUtils.isEmpty(opinion.getTaskTaskId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
|
||||||
|
"select business_id, flow_code, sys_org_code from task_task where id = ?",
|
||||||
|
opinion.getTaskTaskId());
|
||||||
|
if (rows.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, Object> row = rows.get(0);
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getBusinessId())) {
|
||||||
|
opinion.setBusinessId(getStringValue(row, "business_id"));
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getFlowCode())) {
|
||||||
|
opinion.setFlowCode(getStringValue(row, "flow_code"));
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(opinion.getSysOrgCode())) {
|
||||||
|
opinion.setSysOrgCode(getStringValue(row, "sys_org_code"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("补全 task_task 业务字段失败,跳过。taskTaskId={}", opinion.getTaskTaskId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStringValue(Map<String, Object> row, String key) {
|
||||||
|
for (Map.Entry<String, Object> entry : row.entrySet()) {
|
||||||
|
if (entry.getKey() != null && entry.getKey().equalsIgnoreCase(key) && entry.getValue() != null) {
|
||||||
|
return String.valueOf(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveHandleActionType(Map map, String rejectDescription) {
|
||||||
|
String processModel = oConvertUtils.getString(map.get("processModel"));
|
||||||
|
if ("3".equals(processModel) || oConvertUtils.isNotEmpty(rejectDescription)) {
|
||||||
|
return ACTION_REJECT;
|
||||||
|
}
|
||||||
|
return ACTION_APPROVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveSystemActionType(String comment) {
|
||||||
|
if (oConvertUtils.isEmpty(comment)) {
|
||||||
|
return ACTION_SYSTEM;
|
||||||
|
}
|
||||||
|
if (comment.contains("作废")) {
|
||||||
|
return ACTION_INVALID;
|
||||||
|
}
|
||||||
|
if (comment.contains("取回")) {
|
||||||
|
return ACTION_CALLBACK;
|
||||||
|
}
|
||||||
|
if (comment.contains("转办")) {
|
||||||
|
return ACTION_TRANSFER;
|
||||||
|
}
|
||||||
|
if (comment.contains("委派")) {
|
||||||
|
return ACTION_ENTRUST;
|
||||||
|
}
|
||||||
|
return ACTION_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveActionResult(String value, String defaultValue) {
|
||||||
|
return oConvertUtils.isNotEmpty(value) ? value : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件仍保存到原审批日志附件表,不迁移到新审批意见表。
|
||||||
*/
|
*/
|
||||||
private void saveBpmFiles(String bpmLogId, String fileList) {
|
private void saveBpmFiles(String bpmLogId, String fileList) {
|
||||||
if (oConvertUtils.isNotEmpty(fileList)) {
|
if (oConvertUtils.isNotEmpty(fileList)) {
|
||||||
@@ -210,22 +356,16 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务抄送
|
* 处理抄送记录和通知,保持原流程图/历史相关行为不变。
|
||||||
*
|
|
||||||
* @param ccUserNames
|
|
||||||
* @param task
|
|
||||||
* @param username
|
|
||||||
*/
|
*/
|
||||||
private void taskCc(String ccUserNames, Task task, String username) {
|
private void taskCc(String ccUserNames, Task task, String username) {
|
||||||
if (oConvertUtils.isEmpty(ccUserNames)) {
|
if (oConvertUtils.isEmpty(ccUserNames)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] ccUserNameArr = ccUserNames.split(",");
|
String[] ccUserNameArr = ccUserNames.split(",");
|
||||||
ExtActTaskCc taskCcEntity = null;
|
|
||||||
for (String ccUserName : ccUserNameArr) {
|
for (String ccUserName : ccUserNameArr) {
|
||||||
taskCcEntity = new ExtActTaskCc();
|
ExtActTaskCc taskCcEntity = new ExtActTaskCc();
|
||||||
taskCcEntity.setProcDefId(task.getProcessDefinitionId());
|
taskCcEntity.setProcDefId(task.getProcessDefinitionId());
|
||||||
taskCcEntity.setProcInstId(task.getProcessInstanceId());
|
taskCcEntity.setProcInstId(task.getProcessInstanceId());
|
||||||
taskCcEntity.setExecutionId(task.getExecutionId());
|
taskCcEntity.setExecutionId(task.getExecutionId());
|
||||||
@@ -235,55 +375,40 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
taskCcEntity.setFromUserName(username);
|
taskCcEntity.setFromUserName(username);
|
||||||
taskCcEntity.setCcUserName(ccUserName);
|
taskCcEntity.setCcUserName(ccUserName);
|
||||||
extActTaskCcMapper.insert(taskCcEntity);
|
extActTaskCcMapper.insert(taskCcEntity);
|
||||||
//新抄送任务通知
|
|
||||||
this.ccNotice(username, taskCcEntity);
|
this.ccNotice(username, taskCcEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务抄送提醒
|
* 发送任务抄送提醒。
|
||||||
*
|
|
||||||
* @param taskCcEntity
|
|
||||||
*/
|
*/
|
||||||
private void ccNotice(String username, ExtActTaskCc taskCcEntity) {
|
private void ccNotice(String username, ExtActTaskCc taskCcEntity) {
|
||||||
log.info("--------邮件通知----------");
|
log.info("--------邮件通知----------");
|
||||||
LoginUser user = sysBaseAPI.getUserByName(taskCcEntity.getCcUserName());
|
LoginUser user = sysBaseAPI.getUserByName(taskCcEntity.getCcUserName());
|
||||||
//流程名称
|
//流程名称
|
||||||
String processDefinitionName = null;
|
String processDefinitionName = null;
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(taskCcEntity.getProcInstId()).singleResult();
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||||
|
.processInstanceId(taskCcEntity.getProcInstId()).singleResult();
|
||||||
|
|
||||||
if (processInstance != null) {
|
if (processInstance != null) {
|
||||||
processDefinitionName = processInstance.getProcessDefinitionName();
|
processDefinitionName = processInstance.getProcessDefinitionName();
|
||||||
} else {
|
} else {
|
||||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(taskCcEntity.getProcInstId()).singleResult();
|
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
|
||||||
|
.processInstanceId(taskCcEntity.getProcInstId()).singleResult();
|
||||||
if (historicProcessInstance != null) {
|
if (historicProcessInstance != null) {
|
||||||
processDefinitionName = historicProcessInstance.getProcessDefinitionName();
|
processDefinitionName = historicProcessInstance.getProcessDefinitionName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user != null && user.getEmail() != null) {
|
if (user != null && user.getEmail() != null) {
|
||||||
try {
|
try {
|
||||||
// JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
|
||||||
// MimeMessage message = mailSender.createMimeMessage();
|
|
||||||
// MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
|
||||||
// // 设置发送方邮箱地址
|
|
||||||
// helper.setFrom(user.getEmail());
|
|
||||||
// helper.setTo(user.getEmail());
|
|
||||||
// helper.setSubject("流程抄送提醒");
|
|
||||||
JSONObject mp = new JSONObject();
|
JSONObject mp = new JSONObject();
|
||||||
mp.put("bpm_name", processDefinitionName);
|
mp.put("bpm_name", processDefinitionName);
|
||||||
mp.put("bpm_task", taskCcEntity.getTaskName());
|
mp.put("bpm_task", taskCcEntity.getTaskName());
|
||||||
mp.put("remark", "抄送任务");
|
mp.put("remark", "抄送任务");
|
||||||
mp.put("datetime", DateUtils.formatDateTime());
|
mp.put("datetime", DateUtils.formatDateTime());
|
||||||
// TemplateDTO templateDTO = new TemplateDTO(CommonSendStatus.TZMB_BPM_CUIBAN_EMAIL, mp);
|
|
||||||
// String content = sysBaseAPI.parseTemplateByCode(templateDTO);
|
|
||||||
// //markdown格式转为html
|
|
||||||
// content = HTMLUtils.parseMarkdown(content);
|
|
||||||
// helper.setText(content, true);
|
|
||||||
// mailSender.send(message);
|
|
||||||
sysBaseAPI.sendHtmlTemplateEmail(user.getEmail(), "任务抄送提醒", EmailTemplateEnum.BPM_CUIBAN_EMAIL, mp);
|
sysBaseAPI.sendHtmlTemplateEmail(user.getEmail(), "任务抄送提醒", EmailTemplateEnum.BPM_CUIBAN_EMAIL, mp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("--------邮件通知异常----------", e);
|
||||||
log.error("--------邮件通知异常----------", e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +422,9 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
//详情页面所需路由参数
|
//详情页面所需路由参数
|
||||||
mp.put(CommonSendStatus.MSG_ABSTRACT_JSON, BpmSytemMsgPushUtil.getCcRouteInfo(processInstance, taskCcEntity));
|
mp.put(CommonSendStatus.MSG_ABSTRACT_JSON, BpmSytemMsgPushUtil.getCcRouteInfo(processInstance, taskCcEntity));
|
||||||
|
|
||||||
BusTemplateMessageDTO message = new BusTemplateMessageDTO(username, taskCcEntity.getCcUserName(), "流程抄送提醒", mp, CommonSendStatus.TZMB_BPM_CC, SysAnnmentTypeEnum.BPM_VIEW.getType(), taskCcEntity.getId());
|
BusTemplateMessageDTO message = new BusTemplateMessageDTO(username, taskCcEntity.getCcUserName(),
|
||||||
|
"任务抄送提醒", mp, CommonSendStatus.TZMB_BPM_CC,
|
||||||
|
SysAnnmentTypeEnum.BPM_VIEW.getType(), taskCcEntity.getId());
|
||||||
sysBaseAPI.sendBusTemplateAnnouncement(message);
|
sysBaseAPI.sendBusTemplateAnnouncement(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user