From ad1c90d51ffe282d6d0d93420cf85ceb40927583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=8C=E5=85=88=E8=88=9C?= <2499071264@qq.com> Date: Tue, 17 Nov 2026 16:24:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BC=9A=E6=8A=A5=E9=94=80-?= =?UTF-8?q?=E6=85=B0=E9=97=AE=E4=BC=98=E5=8C=962?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FlowTodoCenterController.java | 6 +- .../UnionReimburseApplyController.java | 14 +- .../UnionReimburseMineController.java | 29 +- .../UnionReimburseReviewController.java | 41 ++- .../unionReimburse/model/UnionReimburse.java | 4 + .../service/UnionReimburseService.java | 11 +- .../impl/UnionReimburseServiceImpl.java | 264 ++++++++++++++++-- .../assets/platform/css/home-portal.css | 3 +- .../views/layouts/v4/home/index.html | 2 +- src/main/resources/views/layouts/v4/todo.html | 2 +- .../views/platform/flow/todoCenter/index.html | 2 +- .../unionReimburse/apply/index.html | 37 ++- .../zhgh/dayofficework/unionReimburse/info.js | 8 +- .../unionReimburse/mine/index.html | 19 +- .../unionReimburse/review/index.html | 24 +- .../unionReimburse/apply/index.html | 13 +- .../dayofficework/unionReimburse/info.js | 13 +- .../unionReimburse/mine/index.html | 4 + .../unionReimburse/review/index.html | 43 ++- .../views/platform/zhghh5/sys/home/todo.js | 2 +- 20 files changed, 464 insertions(+), 77 deletions(-) diff --git a/src/main/java/com/budwk/app/flow/controller/FlowTodoCenterController.java b/src/main/java/com/budwk/app/flow/controller/FlowTodoCenterController.java index d377689..037150f 100644 --- a/src/main/java/com/budwk/app/flow/controller/FlowTodoCenterController.java +++ b/src/main/java/com/budwk/app/flow/controller/FlowTodoCenterController.java @@ -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); diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseApplyController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseApplyController.java index fcae94b..cb532a4 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseApplyController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseApplyController.java @@ -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 diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseMineController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseMineController.java index 2693fe2..5e9cb76 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseMineController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseMineController.java @@ -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 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); } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseReviewController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseReviewController.java index f2c7d08..065e518 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseReviewController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/controller/UnionReimburseReviewController.java @@ -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 diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/model/UnionReimburse.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/model/UnionReimburse.java index 7c58cc0..ce5627e 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/model/UnionReimburse.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/model/UnionReimburse.java @@ -429,4 +429,8 @@ public class UnionReimburse extends BaseModel { */ private List invoiceDetails; + private String instanceId; + + private String instanceProcessDefineId; + } diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/UnionReimburseService.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/UnionReimburseService.java index 7a21e95..125c4c0 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/UnionReimburseService.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/UnionReimburseService.java @@ -12,6 +12,15 @@ import java.math.BigDecimal; import java.util.List; public interface UnionReimburseService extends BaseService { + 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 { /** * 审核报销,审核通过时扣减对应预算并新增预算使用详情。 */ - Result reviewApply(String reimburseId, String reviewOpinion, int submitType); + Result reviewApply(String reimburseId, String reviewOpinion, int submitType, Long taskId); /** * 管理员修改实际报销金额,已报销成功的数据需要同步调整经费预算管理台账。 diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseServiceImpl.java b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseServiceImpl.java index fbc3d31..84c7a7c 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/unionReimburse/service/impl/UnionReimburseServiceImpl.java @@ -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 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 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 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 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 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 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 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 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 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 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 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 tasks = flowEngine.processTaskService().getDoingTaskList(instance.getId(), null); + List 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 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 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 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() + "条记录"); diff --git a/src/main/resources/static/assets/platform/css/home-portal.css b/src/main/resources/static/assets/platform/css/home-portal.css index 8e13fe6..1e7a76b 100644 --- a/src/main/resources/static/assets/platform/css/home-portal.css +++ b/src/main/resources/static/assets/platform/css/home-portal.css @@ -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; } diff --git a/src/main/resources/views/layouts/v4/home/index.html b/src/main/resources/views/layouts/v4/home/index.html index 0aa80af..22ad853 100644 --- a/src/main/resources/views/layouts/v4/home/index.html +++ b/src/main/resources/views/layouts/v4/home/index.html @@ -118,7 +118,7 @@ layout("/layouts/v4/baseLayout.html"){ - +
diff --git a/src/main/resources/views/layouts/v4/todo.html b/src/main/resources/views/layouts/v4/todo.html index 06bfeca..6493d33 100644 --- a/src/main/resources/views/layouts/v4/todo.html +++ b/src/main/resources/views/layouts/v4/todo.html @@ -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) }, // 获取空状态文本 diff --git a/src/main/resources/views/platform/flow/todoCenter/index.html b/src/main/resources/views/platform/flow/todoCenter/index.html index e7458d5..01e8d11 100644 --- a/src/main/resources/views/platform/flow/todoCenter/index.html +++ b/src/main/resources/views/platform/flow/todoCenter/index.html @@ -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) }, // 获取空状态文本 diff --git a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html index ac01ee2..5c78bf6 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/apply/index.html @@ -3,8 +3,25 @@ layout("/layouts/platform.html"){ #-->
- + - + @@ -676,6 +694,7 @@ layout("/layouts/platform.html"){ +
申请信息 - + 点击查看流程图
@@ -170,7 +171,8 @@ const unionReimburseInfo = { {{ viewData.participants }} - + {{ viewData.paymentNotes }} @@ -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 diff --git a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/mine/index.html b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/mine/index.html index ca64a11..a155a61 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/mine/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/mine/index.html @@ -1,8 +1,17 @@ +
- + @@ -98,7 +107,7 @@ layout("/layouts/platform.html"){
@@ -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) { diff --git a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/review/index.html b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/review/index.html index c06a6f3..9373ac3 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/review/index.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/unionReimburse/review/index.html @@ -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) { diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html index a998367..6b88bc0 100644 --- a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html +++ b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/apply/index.html @@ -286,7 +286,11 @@ layout("/layouts/platform_h5.html"){
+ class="custom-nav"> + +
@@ -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) diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/info.js b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/info.js index fff1ad8..599b69b 100644 --- a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/info.js +++ b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/info.js @@ -4,7 +4,11 @@ const UNION_REIMBURSE_INFO = { `
- + + +
@@ -160,7 +164,7 @@ const UNION_REIMBURSE_INFO = {
参加随行人员
{{ viewData.participants }}
-
+
报销事由
{{ viewData.paymentNotes }}
@@ -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" diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/mine/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/mine/index.html index 9527f6f..05e0c92 100644 --- a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/mine/index.html +++ b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/mine/index.html @@ -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 diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/review/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/review/index.html index fba9bef..bcb78ad 100644 --- a/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/review/index.html +++ b/src/main/resources/views/platform/zhghh5/dayofficework/unionReimburse/review/index.html @@ -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 diff --git a/src/main/resources/views/platform/zhghh5/sys/home/todo.js b/src/main/resources/views/platform/zhghh5/sys/home/todo.js index 8621665..100b8a7 100644 --- a/src/main/resources/views/platform/zhghh5/sys/home/todo.js +++ b/src/main/resources/views/platform/zhghh5/sys/home/todo.js @@ -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) }, // 根据当前列表类型统一展示流程状态,发起列表保留流程实例的实际状态。