feat: 工会报销-慰问优化2

This commit is contained in:
2026-11-17 16:24:15 +08:00
parent ca0c14df31
commit ad1c90d51f
20 changed files with 464 additions and 77 deletions
@@ -8,6 +8,7 @@ import com.budwk.app.flow.entity.ProcessInstance;
import com.budwk.app.flow.enums.ProcessTaskStateEnum;
import com.budwk.app.sys.services.SysUserService;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
@@ -168,8 +169,8 @@ public class FlowTodoCenterController {
ins.variable ->> '$.instanceName' AS instanceName,
GROUP_CONCAT(DISTINCT t.displayName) as taskName,
cat.`name` categoryName,
t.formKey,
t.h5FormKey
CASE WHEN def.name = @reimburseWorkflow THEN '/platform/unionReimburse/mine/index' ELSE t.formKey END AS formKey,
CASE WHEN def.name = @reimburseWorkflow THEN '/platform/unionReimburse/mine/h5' ELSE t.h5FormKey END AS h5FormKey
FROM
wf_process_instance ins
LEFT JOIN wf_process_task t ON t.processInstanceId = ins.id and t.taskState = 20
@@ -177,6 +178,7 @@ public class FlowTodoCenterController {
LEFT JOIN wf_process_category cat ON cat.id = def.category
$condition
""");
sql.setParam("reimburseWorkflow", UnionReimburseService.WORKFLOW_KEY);
Cnd cnd = Cnd.NEW();
cnd.and("ins.operator", "=", SecurityUtil.getUserId());
cnd.andEX("def.category", "=", category);
@@ -88,11 +88,7 @@ public class UnionReimburseApplyController {
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.apply", "h5.unionReimburse.apply"}, mode = SaMode.OR)
public Result submit(@Param("data") UnionReimburse unionReimburse) {
Result result = unionReimburseService.saveApply(unionReimburse, 2);
if (result.getCode() != 0) {
return result;
}
return Result.success();
return unionReimburseService.submitApply(unionReimburse, null);
}
@At
@@ -100,13 +96,7 @@ public class UnionReimburseApplyController {
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.apply", "h5.unionReimburse.apply"}, mode = SaMode.OR)
public Result submitAgain(@Param("data") UnionReimburse unionReimburse, @Param("taskId") Long taskId) {
// 退回重提也必须复用当前提交保存逻辑,避免绕过发票明细落库和提交校验。
Result result = unionReimburseService.saveApply(unionReimburse, 2);
if (result.getCode() != 0) {
return result;
}
return Result.success();
return unionReimburseService.submitApply(unionReimburse, taskId);
}
@At
@@ -10,10 +10,8 @@ import com.budwk.app.base.param.PageForm;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.utils.CommonDownloadUtil;
import com.budwk.app.base.utils.PageUtil;
import com.budwk.app.flow.engine.FlowEngine;
import com.budwk.app.web.commons.auth.utils.AuthUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseService;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseExportService;
import io.swagger.annotations.Api;
@@ -21,7 +19,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.SqlExpressionGroup;
@@ -54,10 +51,6 @@ public class UnionReimburseMineController {
private UnionReimburseService unionReimburseService;
@Inject
private UnionReimburseExportService unionReimburseExportService;
@Inject
private FlowEngine flowEngine;
@Inject
private Dao dao;
@At("/index")
@@ -98,12 +91,19 @@ public class UnionReimburseMineController {
t.taskParentId,
t.variable taskVariable,
IF((SELECT taskName FROM wf_process_task tt WHERE tt.id = t.taskParentId) = 'startTask', 1, 0) canRevoke,
(select MAX(id) from wf_process_task where processInstanceId = ins.id and taskName = 'startTask') AS startTaskId
(select MAX(id) from wf_process_task where processInstanceId = ins.id
and taskName = @startTask and taskState = 10 and ins.state = 10) AS startTaskId
FROM
union_reimburse info
LEFT JOIN `wf_process_instance` ins ON ins.businessNo = info.id
LEFT JOIN wf_process_task t ON t.processInstanceId = ins.id AND t.taskState = 10
LEFT JOIN wf_process_task_actor ta ON ta.processTaskId = t.id
LEFT JOIN wf_process_instance ins ON ins.id = (
SELECT MAX(i.id) FROM wf_process_instance i
JOIN wf_process_define d ON d.id = i.processDefineId
WHERE i.businessNo = info.id AND d.name = @workflowKey
)
LEFT JOIN wf_process_task t ON t.id = (
SELECT MAX(active.id) FROM wf_process_task active
WHERE active.processInstanceId = ins.id AND active.taskState = 10 AND ins.state = 10
)
$condition
""");
Cnd cnd = Cnd.NEW();
@@ -129,6 +129,8 @@ public class UnionReimburseMineController {
applyListSort(cnd, pageForm);
cnd.and("info.userId", "=", SecurityUtil.getUserId());
sql.setCondition(cnd);
sql.setParam("workflowKey", UnionReimburseService.WORKFLOW_KEY);
sql.setParam("startTask", UnionReimburseService.START_TASK);
Pagination<NutMap> pagination = unionReimburseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
return Result.success(pagination);
}
@@ -176,10 +178,7 @@ public class UnionReimburseMineController {
@SaCheckPermission(value = {"unionReimburse.mine", "h5.unionReimburse.mine"}, mode = SaMode.OR)
@SLog( tag = "撤回工会报销", msg = "撤回工会报销")
public Result revokeTask(@Param("id") String id) {
UnionReimburse unionReimburse = unionReimburseService.fetch(id);
unionReimburse.setStateId(1);//待审核
dao.insertOrUpdate(unionReimburse);
return Result.success();
return unionReimburseService.revokeApply(id);
}
@@ -9,6 +9,7 @@ import com.budwk.app.base.page.Pagination;
import com.budwk.app.base.param.PageForm;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.utils.PageUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.dayofficework.unionReimburse.model.UnionReimburse;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseService;
import com.budwk.app.zhgh.dayofficework.unionReimburse.service.UnionReimburseExportService;
@@ -62,18 +63,32 @@ public class UnionReimburseReviewController {
String unionId,
String unitId,
String reimburseProject) {
String reviewScope = approval ? "" : """
LEFT JOIN wf_process_instance ins ON ins.id = (
SELECT MAX(i.id) FROM wf_process_instance i
JOIN wf_process_define d ON d.id = i.processDefineId
WHERE i.businessNo = info.id AND d.name = @workflowKey
)
LEFT JOIN wf_process_task reviewTask ON reviewTask.id = (
SELECT MIN(t.id) FROM wf_process_task t
JOIN wf_process_task_actor a ON a.processTaskId = t.id
WHERE t.processInstanceId = ins.id AND ins.state = 10 AND t.taskState = 10
AND t.taskName <> @startTask AND a.actorId = @actorId
)
""";
Sql sql = Sqls.create("""
SELECT
info.*
FROM
union_reimburse info
$condition
""");
SELECT info.*
FROM union_reimburse info
""" + reviewScope + "$condition");
Cnd cnd = Cnd.NEW();
if (approval) {
cnd.and("info.stateId", "in", List.of(3, 4, 5));
} else {
cnd.and("info.stateId", "=", 2);
cnd.and(Cnd.exps("ins.id", "is", null).or("reviewTask.id", "is not", null));
sql.setParam("workflowKey", UnionReimburseService.WORKFLOW_KEY);
sql.setParam("startTask", UnionReimburseService.START_TASK);
sql.setParam("actorId", SecurityUtil.getUserId());
}
cnd.andEX("year(info.createTime)", "=", year);
cnd.andEX("info.unionId", "=", unionId);
@@ -111,11 +126,19 @@ public class UnionReimburseReviewController {
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission(value = {"unionReimburse.review", "h5.unionReimburse.review"}, mode = SaMode.OR)
@SLog(tag = "工会报销审核", msg = "审核工会报销")
public Result reviewTask(@Param("data") UnionReimburse unionReimburse, String submitType) {
if (submitType == null || !List.of("3", "4", "5").contains(submitType)) {
public Result reviewTask(@Param("data") UnionReimburse unionReimburse, String submitType, @Param("taskId") Long taskId) {
if (unionReimburse == null || StrUtil.isBlank(unionReimburse.getId())
|| submitType == null || !List.of("3", "4", "5").contains(submitType)) {
return Result.error("无效的审核操作类型");
}
return unionReimburseService.reviewApply(unionReimburse.getId(), unionReimburse.getReviewOpinion(), Integer.parseInt(submitType));
return unionReimburseService.reviewApply(unionReimburse.getId(), unionReimburse.getReviewOpinion(), Integer.parseInt(submitType), taskId);
}
@At
@ApiOperation("查询报销审核任务")
@SaCheckPermission(value = {"unionReimburse.review", "h5.unionReimburse.review"}, mode = SaMode.OR)
public Result taskInfo(@Param("bizId") String bizId, @Param("taskId") Long taskId) {
return unionReimburseService.reviewTaskInfo(bizId, taskId);
}
@At
@@ -429,4 +429,8 @@ public class UnionReimburse extends BaseModel {
*/
private List<UnionReimburseInvoiceDetail> invoiceDetails;
private String instanceId;
private String instanceProcessDefineId;
}
@@ -12,6 +12,15 @@ import java.math.BigDecimal;
import java.util.List;
public interface UnionReimburseService extends BaseService<UnionReimburse> {
String WORKFLOW_KEY = "GHBX";
String START_TASK = "startTask";
Result submitApply(UnionReimburse unionReimburse, Long taskId);
Result revokeApply(String id);
Result reviewTaskInfo(String reimburseId, Long taskId);
Sql getSql(UnionReimbursePageForm pageForm);
@@ -73,7 +82,7 @@ public interface UnionReimburseService extends BaseService<UnionReimburse> {
/**
* 审核报销,审核通过时扣减对应预算并新增预算使用详情。
*/
Result reviewApply(String reimburseId, String reviewOpinion, int submitType);
Result reviewApply(String reimburseId, String reviewOpinion, int submitType, Long taskId);
/**
* 管理员修改实际报销金额,已报销成功的数据需要同步调整经费预算管理台账。
@@ -1,6 +1,7 @@
package com.budwk.app.zhgh.dayofficework.unionReimburse.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.constant.RoleConstant;
@@ -8,6 +9,14 @@ import com.budwk.app.base.exception.BaseException;
import com.budwk.app.base.page.Pagination;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.flow.constant.FlowConst;
import com.budwk.app.flow.engine.FlowEngine;
import com.budwk.app.flow.entity.ProcessDefine;
import com.budwk.app.flow.entity.ProcessInstance;
import com.budwk.app.flow.entity.ProcessTask;
import com.budwk.app.flow.enums.ProcessInstanceStateEnum;
import com.budwk.app.flow.enums.ProcessSubmitTypeEnum;
import com.budwk.app.flow.enums.ProcessTaskStateEnum;
import com.budwk.app.sys.models.Sys_file;
import com.budwk.app.sys.views.View_user;
import com.budwk.app.sys.services.SysFileService;
@@ -84,6 +93,8 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
private UnionReimburseBankAccountService unionReimburseBankAccountService;
@Inject
private PropertiesProxy conf;
@Inject
private FlowEngine flowEngine;
public UnionReimburseServiceImpl(Dao dao) {
super(dao);
}
@@ -158,7 +169,7 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
}
UnionReimburse oldRecord = null;
if (StrUtil.isNotBlank(unionReimburse.getId())) {
oldRecord = this.fetch(unionReimburse.getId());
oldRecord = lockApply(unionReimburse.getId());
if (oldRecord == null) {
return Result.error("未找到对应的报销记录");
}
@@ -179,6 +190,13 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
return Result.error("协会报销仅允许修改草稿或退回的申请");
}
if (oldRecord != null && oldRecord.getStateId() != 1 && oldRecord.getStateId() != 5) {
return Result.error("仅可修改待提交或退回的报销申请");
}
if (stateId == 1 && oldRecord != null && oldRecord.getStateId() == 5) {
stateId = 5;
}
// 人员身份和敏感资料由服务端补齐,避免前端删减字段导致丢失或被篡改。
if (oldRecord == null) {
View_user handler = dao().fetch(View_user.class, Cnd.where("id", "=", SecurityUtil.getUserId()));
@@ -282,6 +300,14 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
unionReimburse.setCondolenceIdCard(null);
unionReimburse.setCondolenceBirthday(null);
unionReimburse.setCondolenceMobile(null);
ProcessInstance instance = findReimburseWorkflow(id);
if (instance == null) {
instance = dao().fetch(ProcessInstance.class, Cnd.where("businessNo", "=", id).desc("id"));
}
if (instance != null) {
unionReimburse.setInstanceId(instance.getId().toString());
unionReimburse.setInstanceProcessDefineId(instance.getProcessDefineId().toString());
}
return unionReimburse;
}
@@ -383,6 +409,11 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
throw new BaseException("无权删除该报销记录");
}
ProcessInstance instance = findReimburseWorkflow(id);
if (instance != null && ProcessInstanceStateEnum.DOING.getCode().equals(instance.getState())) {
flowEngine.processInstanceService().withdraw(instance.getId(), SecurityUtil.getUserId());
}
Sql detailSql = Sqls.create("SELECT * FROM outlay_use_detail WHERE outlayReimburseId=@id ORDER BY id FOR UPDATE");
detailSql.setParam("id", id);
detailSql.setEntity(dao().getEntity(OutlayUseDetail.class));
@@ -406,6 +437,117 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
this.delete(id);
}
@Override
@Aop(TransAop.READ_COMMITTED)
public Result submitApply(UnionReimburse form, Long taskId) {
if (form == null) {
return Result.error("报销数据不能为空");
}
UnionReimburse previous = StrUtil.isBlank(form.getId()) ? null : lockApply(form.getId());
if (previous != null && !Objects.equals(previous.getUserId(), SecurityUtil.getUserId())) {
return Result.error("仅经办人可提交该报销申请");
}
ProcessInstance instance = previous == null ? null : findReimburseWorkflow(previous.getId());
ProcessTask startTask = null;
ProcessDefine define = null;
String operator = SecurityUtil.getUserId();
if (instance != null && !ProcessInstanceStateEnum.WITHDRAW.getCode().equals(instance.getState())) {
if (previous.getStateId() != 5 || !ProcessInstanceStateEnum.DOING.getCode().equals(instance.getState())) {
return Result.error("当前报销流程不可重新提交");
}
List<ProcessTask> startTasks = flowEngine.processTaskService()
.getDoingTaskList(instance.getId(), new String[]{START_TASK});
if (startTasks.size() != 1 || !Objects.equals(instance.getOperator(), operator)
|| !flowEngine.processTaskService().getTaskActors(startTasks.get(0).getId()).contains(operator)
|| (taskId != null && !taskId.equals(startTasks.get(0).getId()))) {
return Result.error("没有可重新提交的报销任务");
}
startTask = startTasks.get(0);
} else {
if (taskId != null) {
return Result.error("报销申请任务已失效");
}
define = flowEngine.processDefineService().getLastByName(WORKFLOW_KEY);
if (define == null) {
return Result.error("请先发布工会报销流程(" + WORKFLOW_KEY + ")");
}
}
Result result = saveApply(form, 2);
if (result.getCode() != 0) {
return result;
}
Dict args = Dict.create();
args.set("reimburseFundSource", form.getReimburseFundSource());
args.set("reimburseProject", form.getReimburseProject());
args.set("unionId", form.getUnionId());
args.set("clubId", form.getClubId());
if (startTask == null) {
args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.APPLY.getCode());
instance = flowEngine.startProcessInstanceById(define.getId(), form.getId(), operator, args);
List<ProcessTask> startTasks = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null);
if (startTasks.size() != 1 || !START_TASK.equals(startTasks.get(0).getTaskName())
|| !flowEngine.processTaskService().getTaskActors(startTasks.get(0).getId()).contains(operator)) {
throw new BaseException("工会报销流程的第一个节点必须为分派给发起人的 " + START_TASK);
}
startTask = startTasks.get(0);
} else {
flowEngine.processInstanceService().addVariable(instance.getId(), args);
args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.RE_APPLY.getCode());
}
flowEngine.executeProcessTask(startTask.getId(), operator, args);
if (!ProcessInstanceStateEnum.DOING.getCode().equals(flowEngine.processInstanceService().getById(instance.getId()).getState())) {
throw new BaseException("请为工会报销配置申请后的审核节点");
}
requireReviewTasks(instance.getId());
return result;
}
@Override
@Aop(TransAop.READ_COMMITTED)
public Result revokeApply(String id) {
UnionReimburse form = lockApply(id);
String operator = SecurityUtil.getUserId();
if (form == null || !Objects.equals(form.getUserId(), operator) || form.getStateId() != 2) {
return Result.error("仅经办人可撤回待审核的报销申请");
}
ProcessInstance instance = findReimburseWorkflow(id);
if (instance != null) {
if (!Objects.equals(instance.getOperator(), operator)
|| !ProcessInstanceStateEnum.DOING.getCode().equals(instance.getState())) {
return Result.error("当前报销流程不可撤回");
}
flowEngine.processInstanceService().withdraw(instance.getId(), operator);
}
form.setStateId(1);
dao().update(form);
return Result.success();
}
private ProcessInstance findReimburseWorkflow(String reimburseId) {
Sql sql = Sqls.create("""
SELECT i.* FROM wf_process_instance i
JOIN wf_process_define d ON d.id = i.processDefineId
WHERE i.businessNo = @id AND d.name = @workflowKey
ORDER BY i.id DESC LIMIT 1
""");
sql.setParam("id", reimburseId).setParam("workflowKey", WORKFLOW_KEY);
sql.setEntity(dao().getEntity(ProcessInstance.class));
sql.setCallback(Sqls.callback.entity());
dao().execute(sql);
return sql.getObject(ProcessInstance.class);
}
private void requireReviewTasks(Long instanceId) {
List<ProcessTask> tasks = flowEngine.processTaskService().getDoingTaskList(instanceId, null);
if (tasks.isEmpty() || tasks.stream().anyMatch(task -> START_TASK.equals(task.getTaskName())
|| flowEngine.processTaskService().getTaskActors(task.getId()).isEmpty())) {
throw new BaseException("工会报销流程未生成有效的审核待办,请检查节点及办理人配置");
}
}
private UnionReimburse lockApply(String id) {
Sql sql = Sqls.create("SELECT * FROM union_reimburse WHERE id=@id FOR UPDATE");
sql.setParam("id", id);
@@ -627,12 +769,9 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
return Result.error("不支持的经费来源");
}
/**
* 审核通过时统一校验余额、扣减预算并写入预算使用详情,避免控制器分散业务逻辑。
*/
@Override
@Aop(TransAop.READ_COMMITTED)
public Result reviewApply(String reimburseId, String reviewOpinion, int submitType) {
public Result reviewApply(String reimburseId, String reviewOpinion, int submitType, Long taskId) {
if (!List.of(3, 4, 5).contains(submitType)) {
return Result.error("无效的审核操作类型");
}
@@ -640,19 +779,110 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
if (dbRecord == null) {
return Result.error("记录不存在");
}
if ("UNION_REIMBURSE_FUND_SOURCE_3".equals(dbRecord.getReimburseFundSource())) {
if (submitType == 3 && Integer.valueOf(3).equals(dbRecord.getStateId())) {
return Result.success();
ProcessInstance instance = findReimburseWorkflow(reimburseId);
if (instance != null) {
return reviewWorkflow(dbRecord, instance, reviewOpinion, submitType, taskId);
}
if (taskId == null && submitType == 3 && dbRecord.getStateId() == 3) {
return Result.success();
}
if (taskId != null || dbRecord.getStateId() != 2) {
return Result.error("报销单已处理或审核任务已失效");
}
return completeReview(dbRecord, reviewOpinion, submitType);
}
@Override
public Result reviewTaskInfo(String reimburseId, Long taskId) {
if (StrUtil.isBlank(reimburseId) || taskId == null) {
return Result.error("缺少报销编号或审核任务");
}
ProcessTask task = flowEngine.processTaskService().getById(taskId);
ProcessInstance instance = task == null ? null : flowEngine.processInstanceService().getById(task.getProcessInstanceId());
ProcessDefine define = instance == null ? null : flowEngine.processDefineService().getById(instance.getProcessDefineId());
UnionReimburse form = fetch(reimburseId);
String operator = SecurityUtil.getUserId();
if (define == null || !WORKFLOW_KEY.equals(define.getName()) || !reimburseId.equals(instance.getBusinessNo())
|| form == null || START_TASK.equals(task.getTaskName())) {
return Result.error("无权查看该审核任务");
}
boolean isActor = flowEngine.processTaskService().getTaskActors(taskId).contains(operator);
if (!isActor && !Objects.equals(task.getOperator(), operator)) {
return Result.error("无权查看该审核任务");
}
ProcessInstance latest = findReimburseWorkflow(reimburseId);
boolean canReview = isActor && form.getStateId() == 2 && latest != null && latest.getId().equals(instance.getId())
&& ProcessInstanceStateEnum.DOING.getCode().equals(instance.getState())
&& ProcessTaskStateEnum.DOING.getCode().equals(task.getTaskState());
return Result.success(NutMap.NEW().setv("id", reimburseId)
.setv("taskName", task.getDisplayName()).setv("canReview", canReview));
}
private Result reviewWorkflow(UnionReimburse form, ProcessInstance instance, String opinion, int submitType, Long taskId) {
if (form.getStateId() != 2 || !ProcessInstanceStateEnum.DOING.getCode().equals(instance.getState())) {
return Result.error("报销单已处理或审核任务已失效");
}
String operator = SecurityUtil.getUserId();
List<ProcessTask> tasks = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null);
List<ProcessTask> available = tasks.stream()
.filter(task -> !START_TASK.equals(task.getTaskName()))
.filter(task -> taskId == null || taskId.equals(task.getId()))
.filter(task -> flowEngine.processTaskService().getTaskActors(task.getId()).contains(operator))
.toList();
if (available.size() != 1) {
return Result.error(available.isEmpty() ? "没有可办理的报销审核任务" : "请从待办中心选择具体的审核任务");
}
ProcessTask task = available.get(0);
Dict args = Dict.create();
args.set(FlowConst.APPROVAL_COMMENT, opinion);
if (submitType == 3) {
args.set(FlowConst.SUBMIT_TYPE, ProcessSubmitTypeEnum.AGREE.getCode());
flowEngine.executeProcessTask(task.getId(), operator, args);
ProcessInstance updated = flowEngine.processInstanceService().getById(instance.getId());
if (ProcessInstanceStateEnum.DOING.getCode().equals(updated.getState())) {
requireReviewTasks(instance.getId());
return Result.success("当前节点审核通过,已流转至后续审核");
}
if (!Integer.valueOf(2).equals(dbRecord.getStateId())) {
return Result.error("仅可审核待审核确认的协会报销");
if (!ProcessInstanceStateEnum.FINISHED.getCode().equals(updated.getState())
|| !flowEngine.processTaskService().getDoingTaskList(instance.getId(), null).isEmpty()) {
throw new BaseException("工会报销流程结束状态异常,请检查节点配置");
}
} else {
args.set(FlowConst.SUBMIT_TYPE, submitType == 4
? ProcessSubmitTypeEnum.REJECT.getCode() : ProcessSubmitTypeEnum.ROLLBACK_TO_OPERATOR.getCode());
for (ProcessTask other : tasks) {
if (!other.getId().equals(task.getId())) {
flowEngine.processTaskService().abandonProcessTask(other.getId(), operator, args);
}
}
if (submitType == 4) {
flowEngine.executeAndJumpToEnd(task.getId(), operator, args);
if (!ProcessInstanceStateEnum.REJECT.getCode().equals(flowEngine.processInstanceService().getById(instance.getId()).getState())) {
throw new BaseException("工会报销流程未进入拒绝状态");
}
} else {
flowEngine.executeAndJumpToFirstTaskNode(task.getId(), operator, args);
List<ProcessTask> returned = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null);
if (returned.size() != 1 || !START_TASK.equals(returned.get(0).getTaskName())
|| !flowEngine.processTaskService().getTaskActors(returned.get(0).getId()).contains(instance.getOperator())) {
throw new BaseException("工会报销流程未正确退回发起人");
}
}
}
Result result = completeReview(form, opinion, submitType);
if (result.getCode() != 0) {
throw new BaseException(result.getMsg());
}
return result;
}
/**
* 最终审核通过时校验并扣减预算,同时写入预算使用明细。
*/
private Result completeReview(UnionReimburse dbRecord, String reviewOpinion, int submitType) {
if (submitType == 3) {
// 已通过的单据再次触发通过时直接返回,避免重复扣减预算。
if (Integer.valueOf(3).equals(dbRecord.getStateId())) {
return Result.success();
}
Result validateResult = validateFundSourceBeforeSubmit(dbRecord);
if (validateResult != null) {
return validateResult;
@@ -673,6 +903,7 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
* 批量审核前只查询前端勾选且仍处于待审核确认状态的数据,避免误处理未勾选或状态已变化的申请。
*/
@Override
@Aop(TransAop.READ_COMMITTED)
public Result batchReviewApply(String[] reimburseIds) {
if (reimburseIds == null || reimburseIds.length == 0) {
return Result.error("请选择需要审核的报销申请");
@@ -681,10 +912,11 @@ public class UnionReimburseServiceImpl extends BaseServiceImpl<UnionReimburse> i
if (reimbursements.isEmpty()) {
return Result.error("所选记录中没有待审核的数据");
}
reimbursements.sort(java.util.Comparator.comparing(UnionReimburse::getId));
for (UnionReimburse reimbursement : reimbursements) {
Result result = this.reviewApply(reimbursement.getId(), "通过", 3);
Result result = this.reviewApply(reimbursement.getId(), "通过", 3, null);
if (result.getCode() != 0) {
return result;
throw new BaseException(result.getMsg());
}
}
return Result.success("一键审核完成,共处理" + reimbursements.size() + "条记录");
@@ -125,7 +125,8 @@
#v4-home-app .todo-center .el-tabs__nav { display: flex; width: 100%; border-color: #e9eff6; border-radius: 6px 6px 0 0; }
#v4-home-app .todo-center .el-tabs__item { flex: 1; min-width: 0; padding: 0 7px; font-size: 12px; height: 36px; line-height: 36px; text-align: center; }
#v4-home-app .todo-center .el-tabs__item.is-active { border-bottom: 2px solid #1687f5; color: #1687f5; }
#v4-home-app .portal-task-list { display: flex; flex-direction: column; justify-content: space-evenly; flex: 1; min-height: 180px; }
#v4-home-app .portal-task-list { display: flex; flex-direction: column; justify-content: flex-start; flex: 1; min-height: 180px; }
#v4-home-app .portal-task-list > .portal-empty { flex: 1; }
#v4-home-app .portal-task-row { display: flex; gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid #eef3f8; }
#v4-home-app .portal-task-row:last-child { border-bottom: 0; }
#v4-home-app .portal-task-row:hover { background: #f7fbff; }
@@ -118,7 +118,7 @@ layout("/layouts/v4/baseLayout.html"){
</style>
<link rel="stylesheet" href="${base!}/assets/platform/css/home-portal.css?v=20261111-1" />
<link rel="stylesheet" href="${base!}/assets/platform/css/home-portal.css?v=20261117-1" />
<div class="v4-container home-portal" id="v4-home-app">
<!-- 首页banner -->
@@ -420,7 +420,7 @@ layout("/layouts/v4/baseLayout.html"){
this.$message.warning("当前流程没有配置地址")
return
}
window.open(formKey + "?taskId=" + taskId + "bizId=" + businessNo + "taskKey=" + taskKey)
window.open(formKey + "?taskId=" + taskId + "&bizId=" + businessNo + "&taskKey=" + taskKey)
},
// 获取空状态文本
@@ -464,7 +464,7 @@ layout("/layouts/v4/baseLayout.html"){
this.$message.warning("当前流程没有配置地址")
return
}
window.open(formKey + "?taskId=" + taskId + "bizId=" + businessNo + "taskKey=" + taskKey)
window.open(formKey + "?taskId=" + taskId + "&bizId=" + businessNo + "&taskKey=" + taskKey)
},
// 获取空状态文本
@@ -3,8 +3,25 @@ layout("/layouts/platform.html"){
#-->
<style>
.reimbursement-tabs {
margin-top: 10px;
.reimbursement-apply-card > .el-card__header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 20px;
}
.reimbursement-apply-card > .el-card__header > h3 {
margin: 0;
}
.reimbursement-apply-card > .el-card__header > .el-link {
margin-left: auto;
flex-shrink: 0;
}
.reimbursement-apply-card > .el-card__body {
padding-top: 8px;
}
/* 协会表单改为两组字段后,左侧标签仍保持原三组字段表单的六分之一宽度。 */
@@ -70,7 +87,7 @@ layout("/layouts/platform.html"){
</style>
<div id="app" v-cloak>
<el-card shadow="never">
<el-card shadow="never" class="reimbursement-apply-card">
<template #header>
<h3 style="color: rgb(24, 103, 176);" v-if="formData.reimburseProject === 'UNION_REIMBURSE_PROJECT_1'">
慰问申请</h3>
@@ -82,10 +99,11 @@ layout("/layouts/platform.html"){
专项活动申请</h3>
<h3 style="color: rgb(24, 103, 176);" v-else-if="formData.reimburseProject === 'UNION_REIMBURSE_PROJECT_5'">
协会活动申请</h3>
<el-link v-if="!bizId || formData.id" type="primary" @click="openChart">流程图</el-link>
</template>
<el-form :model="formData" ref="formRef" :rules="formRules" label-width="0" label-suffix=":"
class="flow-task-form">
<el-tabs class="reimbursement-tabs" v-model="activeTabName">
<el-tabs v-model="activeTabName">
<el-tab-pane label="申请基本信息" name="basic">
<!-- 来源或项目切换时重建表单项,避免动态布局复用旧字段的校验状态。 -->
<el-descriptions :column="formData.reimburseFundSource === 'UNION_REIMBURSE_FUND_SOURCE_3' ? 2 : 3" :class="{'club-reimbursement-form': formData.reimburseFundSource === 'UNION_REIMBURSE_FUND_SOURCE_3'}" border :key="formData.reimburseFundSource + ':' + formData.reimburseProject">
@@ -676,6 +694,7 @@ layout("/layouts/platform.html"){
</el-row>
</el-card>
<snaker-chart ref="snakerChartRef"></snaker-chart>
<el-dialog :close-on-click-modal="false"
:title="invoiceDialogMode === 'edit' ? '编辑发票明细' : '新增发票明细'"
:visible.sync="invoiceDialogVisible"
@@ -1048,6 +1067,16 @@ layout("/layouts/platform.html"){
}
},
methods: {
openChart() {
const chart = this.$refs.snakerChartRef
if (!chart) return
const {instanceProcessDefineId, instanceId} = this.formData
if (instanceProcessDefineId && instanceId) {
chart.onOpenFull(instanceProcessDefineId, instanceId)
} else {
chart.onOpen("GHBX")
}
},
buildDefaultDetailForm() {
return {
verified: false,
@@ -3,7 +3,8 @@ const unionReimburseInfo = {
<div>
<div class="process-title" style="display: flex; align-items: center; justify-content: space-between; gap: 12px;">
<span>申请信息</span>
<!-- <el-link type="primary" @click="openChart">点击查看流程图</el-link> -->
<el-link v-if="row && viewData.id === row.id && viewData.instanceId"
type="primary" @click="openChart">点击查看流程图</el-link>
</div>
<el-tabs v-model="activeTabName" style="margin-top: 10px;">
@@ -170,7 +171,8 @@ const unionReimburseInfo = {
<span>{{ viewData.participants }}</span>
</el-descriptions-item>
<el-descriptions-item label="报销事由" :span="3" v-if="viewData.reimburseProject">
<el-descriptions-item label="报销事由" :span="3"
v-if="viewData.reimburseProject && viewData.reimburseProject !== 'UNION_REIMBURSE_PROJECT_1'">
<span>{{ viewData.paymentNotes }}</span>
</el-descriptions-item>
@@ -380,7 +382,7 @@ const unionReimburseInfo = {
if (!this.row || !this.$refs.snakerChartRef) {
return
}
const {instanceProcessDefineId, instanceId} = this.row
const {instanceProcessDefineId, instanceId} = this.viewData
if (!instanceProcessDefineId || !instanceId) {
this.$message.warning("暂无流程图信息")
return
@@ -1,8 +1,17 @@
<!--#
layout("/layouts/platform.html"){
#-->
<style>
.union-reimburse-mine > .page-container > .page-content {
padding-top: 10px;
}
.union-reimburse-mine-detail > .process-title:first-child {
margin-top: 0;
}
</style>
<div id="app">
<guava ref="guava">
<guava ref="guava" class="union-reimburse-mine">
<el-card shadow="never">
<search @search="doSearch">
<search-item label="年度">
@@ -98,7 +107,7 @@ layout("/layouts/platform.html"){
<!--#include("/layouts/pagination.html"){}#-->
</el-card>
<template #view>
<union-reimburse-info ref="unionReimburseInfoRef"></union-reimburse-info>
<union-reimburse-info ref="unionReimburseInfoRef" class="union-reimburse-mine-detail"></union-reimburse-info>
</template>
</guava>
</div>
@@ -150,6 +159,8 @@ layout("/layouts/platform.html"){
if (res.code === 0) {
this.$message.success(res.msg)
this.pageData()
} else {
this.$message.error(res.msg)
}
})
})
@@ -176,6 +187,10 @@ layout("/layouts/platform.html"){
}
},
mounted() {
const id = GetQueryString("bizId")
if (id) this.onView({id})
},
created() {
this.pageData()
if (this.isAdmin) {
@@ -208,11 +208,12 @@ layout("/layouts/platform.html"){
})
},
openAudit(row) {
openAudit(row, taskId) {
this.$refs.guava.edit(() => {
this.showApprovalForm = true
this.formData = {
id: row.id,
taskId: taskId,
reviewOpinion: '已付款成功'
}
this.$refs.unionReimburseInfoRef.onOpen(row)
@@ -230,12 +231,15 @@ layout("/layouts/platform.html"){
this.formLoading = true
this.$axios.post("/platform/unionReimburse/review/reviewTask", {
data: JSON.stringify(Object.assign({}, this.formData)),
submitType: val
submitType: val,
taskId: this.formData.taskId
}).then((res) => {
if (res.code === 0) {
this.$refs.guava.index()
this.$message.success(res.msg)
this.doSearch()
} else {
this.$message.error(res.msg)
}
}).finally(() => {
this.formLoading = false
@@ -245,6 +249,22 @@ layout("/layouts/platform.html"){
})
}
},
mounted() {
const taskId = GetQueryString("taskId")
if (!taskId) return
const bizId = GetQueryString("bizId")
this.$axios.post("/platform/unionReimburse/review/taskInfo", {bizId, taskId}).then((res) => {
if (res.code !== 0) {
this.$message.error(res.msg)
return
}
if (res.data.canReview) {
this.openAudit(res.data, taskId)
} else {
this.onView(res.data)
}
})
},
created() {
this.pageData()
if (this.isAdmin) {
@@ -286,7 +286,11 @@ layout("/layouts/platform_h5.html"){
</style>
<div id="app" v-cloak class="union-reimburse-page union-reimburse-form">
<van-nav-bar title="报销申请" left-text="返回" left-arrow @click-left="onNavBack" placeholder fixed z-index="999"
class="custom-nav"></van-nav-bar>
class="custom-nav">
<template #right>
<a v-if="!bizId || formData.id" :href="processChartUrl" target="_blank" rel="noopener">查看流程图</a>
</template>
</van-nav-bar>
<div class="form-container">
<van-form ref="formRef">
@@ -1148,6 +1152,13 @@ layout("/layouts/platform_h5.html"){
}
},
computed: {
processChartUrl() {
const {instanceProcessDefineId, instanceId} = this.formData
if (instanceProcessDefineId && instanceId) {
return `/flow/define/preview?defineId=${instanceProcessDefineId}&instanceId=${instanceId}`
}
return "/flow/define/preview?defineKey=GHBX"
},
isManualReimburseAmount() {
return ["UNION_REIMBURSE_PROJECT_2", "UNION_REIMBURSE_PROJECT_3", "UNION_REIMBURSE_PROJECT_4"]
.includes(this.formData.reimburseProject)
@@ -4,7 +4,11 @@ const UNION_REIMBURSE_INFO = {
`
<van-popup v-model="visible" position="right" :style="{width: '100%', height: '100%'}" :get-container="false" :close-on-click-overlay="false" class="union-reimburse-info-sheet">
<div class="union-reimburse-info-detail">
<van-nav-bar :title="detailTitle" left-text="返回" left-arrow fixed @click-left="onClose"></van-nav-bar>
<van-nav-bar :title="detailTitle" left-text="返回" left-arrow fixed @click-left="onClose">
<template #right>
<a v-if="processChartUrl" :href="processChartUrl" target="_blank" rel="noopener">查看流程图</a>
</template>
</van-nav-bar>
<div class="detail-container">
<div class="union-info-scroll">
<div class="union-info-section">
@@ -160,7 +164,7 @@ const UNION_REIMBURSE_INFO = {
<div class="union-info-label">参加随行人员</div>
<div class="union-info-value">{{ viewData.participants }}</div>
</div>
<div class="union-info-row">
<div class="union-info-row" v-if="viewData.reimburseProject && viewData.reimburseProject !== 'UNION_REIMBURSE_PROJECT_1'">
<div class="union-info-label">报销事由</div>
<div class="union-info-value">{{ viewData.paymentNotes }}</div>
</div>
@@ -337,6 +341,11 @@ const UNION_REIMBURSE_INFO = {
}
},
computed: {
processChartUrl() {
const {id, instanceProcessDefineId, instanceId} = this.viewData
if (!this.row || this.row.id !== id || !instanceProcessDefineId || !instanceId) return ""
return `/flow/define/preview?defineId=${instanceProcessDefineId}&instanceId=${instanceId}`
},
// 详情接口按关联类型返回业务编码,避免不同环境的类型 ID 影响字段显示。
condolenceTypeCode() {
return this.viewData.reimburseProject === "UNION_REIMBURSE_PROJECT_1"
@@ -179,6 +179,10 @@ layout("/layouts/platform_h5.html"){
const manager = window.h5HistoryLayerManager
if (manager) { manager.ensureRegistered("union-reimburse-mine"); this.$set(this, "historyLayerUnsubscribe", manager.subscribe((layers) => { this.$set(this, "confirmVisible", layers.includes("union-reimburse-mine-confirm")) })) }
},
mounted() {
const id = GetQueryString("bizId")
if (id) this.onView({id})
},
beforeDestroy() {
if (this.historyLayerUnsubscribe) this.historyLayerUnsubscribe()
const manager = window.h5HistoryLayerManager
@@ -165,16 +165,37 @@ layout("/layouts/platform_h5.html"){
}).catch(() => {})
},
closeSubmitConfirm(afterClose) { const manager = window.h5HistoryLayerManager; if (manager) { manager.close("union-reimburse-review-confirm", afterClose); return } this.$set(this, "submitConfirmVisible", false); if (afterClose) afterClose() },
submitTaskAction() { const submitType = this.pendingSubmitType; this.closeSubmitConfirm(() => { this.$set(this, "formLoading", true); this.$axios.post("/platform/unionReimburse/review/reviewTask", {data: JSON.stringify(Object.assign({}, this.formData)), submitType: submitType}).then((res) => { if (res.code === 0) { this.$toast.success("提交成功"); this.doSearch(); this.$refs.unionReimburseInfoRef.onClose() } else { this.$toast.fail(res.msg) } }).finally(() => { this.$set(this, "formLoading", false) }) }) },
submitTaskAction() {
const submitType = this.pendingSubmitType
this.closeSubmitConfirm(() => {
this.$set(this, "formLoading", true)
this.$axios.post("/platform/unionReimburse/review/reviewTask", {
data: JSON.stringify(Object.assign({}, this.formData)),
submitType,
taskId: this.formData.taskId
}).then((res) => {
if (res.code === 0) {
this.$toast.success(res.msg || "提交成功")
this.doSearch()
this.$refs.unionReimburseInfoRef.onClose()
} else {
this.$toast.fail(res.msg)
}
}).finally(() => {
this.$set(this, "formLoading", false)
})
})
},
onView(row) {
this.$set(this, "showApprovalForm", false)
this.$refs.unionReimburseInfoRef.onOpen(row, "报销详情")
},
onAudit(row) {
onAudit(row, taskId) {
this.$set(this, "showApprovalForm", true)
this.$set(this, "formData", {
id: row.id,
taskName: "校工会审核",
taskId: taskId,
taskName: row.taskName || "校工会审核",
reviewOpinion: "已付款成功"
})
// 先完成审批意见及插槽渲染,再打开详情,避免首次打开时表单尚未更新。
@@ -201,6 +222,22 @@ layout("/layouts/platform_h5.html"){
const manager = window.h5HistoryLayerManager
if (manager) { manager.ensureRegistered("union-reimburse-review"); this.$set(this, "historyLayerUnsubscribe", manager.subscribe((layers) => { this.$set(this, "submitConfirmVisible", layers.includes("union-reimburse-review-confirm")) })) }
},
mounted() {
const taskId = GetQueryString("taskId")
if (!taskId) return
const bizId = GetQueryString("bizId")
this.$axios.post("/platform/unionReimburse/review/taskInfo", {bizId, taskId}).then((res) => {
if (res.code !== 0) {
this.$toast.fail(res.msg)
return
}
if (res.data.canReview) {
this.onAudit(res.data, taskId)
} else {
this.onView(res.data)
}
})
},
beforeDestroy() {
if (this.historyLayerUnsubscribe) this.historyLayerUnsubscribe()
const manager = window.h5HistoryLayerManager
@@ -285,7 +285,7 @@ const todo = {
this.$toast("当前流程暂不支持手机端审核,请前往PC端页面审核!");
return;
}
this.$pjaxReplace(h5FormKey + "?taskId=" + taskId + "bizId=" + businessNo + "taskKey=" + taskKey+ "&tab=" + this.activeTab)
this.$pjaxReplace(h5FormKey + "?taskId=" + taskId + "&bizId=" + businessNo + "&taskKey=" + taskKey+ "&tab=" + this.activeTab)
},
// 根据当前列表类型统一展示流程状态,发起列表保留流程实例的实际状态。