From b026cffe7013ded9e9d50b16118e92af445ce112 Mon Sep 17 00:00:00 2001 From: aikai Date: Sun, 18 Aug 2024 17:29:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(bpm):=20=E4=BC=98=E5=8C=96=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E6=94=AF=E4=BB=98=E5=AE=A1=E6=89=B9=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构财务支付模块中的审批通知逻辑,优化消息发送流程,并调整数据库查询以正确处理部门ID。改进了财务支付页面的MyBatis映射和VO参数命名,以提高代码的可读性和一致性。 -修正了在创建财务支付记录时向发起人发送审批结果通知的逻辑,确保根据审批结果正确发送消息。 - 调整了MyBatis映射文件中的部门ID查询条件,以使用正确的字段 --- .../FinancialPaymentMapper.java | 2 +- .../FinancialPaymentServiceImpl.java | 38 +++++++++++++++++-- .../FinancialPaymentMapper.xml | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/financialpayment/FinancialPaymentMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/financialpayment/FinancialPaymentMapper.java index d520f67a..346e3fe9 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/financialpayment/FinancialPaymentMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/financialpayment/FinancialPaymentMapper.java @@ -25,5 +25,5 @@ public interface FinancialPaymentMapper extends BaseMapperX * @param page * @return */ - IPage getFinancialPaymentPage(@Param("vp") FinancialPaymentPageReqVO vo, @Param("page") Page page); + IPage getFinancialPaymentPage(@Param("vo") FinancialPaymentPageReqVO vo, @Param("page") Page page); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java index 3874be70..963487d1 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/financialpayment/FinancialPaymentServiceImpl.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.bpm.service.financialpayment; +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.Constants; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; @@ -7,6 +9,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.Financia import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentSaveReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentSaveVO; import cn.iocoder.yudao.module.bpm.controller.admin.financialpaymentitem.vo.FinancialPaymentItemSaveReqVO; +import cn.iocoder.yudao.module.bpm.convert.message.BpmMessageConvert; import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpaymentitem.FinancialPaymentItemDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOACashDO; @@ -20,7 +23,13 @@ import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAImprestMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAProcurePayMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReimbursementMapper; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; +import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.core.metadata.IPage; +import lombok.extern.slf4j.Slf4j; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.runtime.ProcessInstance; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -34,6 +43,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi * @author 艾楷 */ @Service +@Slf4j @Validated public class FinancialPaymentServiceImpl implements FinancialPaymentService { @@ -49,6 +59,12 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { private BpmOAProcurePayMapper oAProcurePayMapper; @Resource private BpmOAReimbursementMapper reimbursementMapper; + @Resource + private SubscribeMessageSendApi subscribeMessageSendApi; + @Resource + private RuntimeService runtimeService; + @Resource + private AdminUserApi userApi; @Override public Long createFinancialPayment(FinancialPaymentSaveVO vo) { @@ -80,12 +96,26 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { } else if (financialPayment.getType() == 4) { reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult())); } - - // --- 发消息通知发起人 - - } this.updateById(financialPayment); + try { + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(financialPayment.getProcessInstanceId()).singleResult(); + AdminUserRespDTO adminUserRespDTO = userApi.getUser(financialPayment.getUserId()).getData(); + if (StrUtil.isNotEmpty(adminUserRespDTO.getOpenId())) { + // --- 发消息通知发起人 + String time = financialPaymentItem.getCreateTime().format(Constants.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + subscribeMessageSendApi.sendApprovalResultNotification( + BpmMessageConvert.INSTANCE.convertApprovalResultNotification( + adminUserRespDTO.getOpenId(), processInstance.getProcessDefinitionName(), time, vo.getStatus() == 1 ? "通过" : "拒绝", financialPaymentItem.getNotes(), + financialPayment.getProcessInstanceId(), + /** + * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 + */ + "formal")); + } + } catch (Exception e) { + log.error("财务管理审批发送通知人失败:{}", financialPayment); + } // 返回 return financialPayment.getId(); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml index e9429b9d..e67e467d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/mapper/financialpayment/FinancialPaymentMapper.xml @@ -23,7 +23,7 @@ a.deleted = 0 - and b.dept_id = #{vo.deptId} + and c.id = #{vo.deptId} and b.nickname like concat('%', #{vo.nickname}, '%')