fix(bpm): 优化财务支付审批通知和数据库查询

重构财务支付模块中的审批通知逻辑,优化消息发送流程,并调整数据库查询以正确处理部门ID。改进了财务支付页面的MyBatis映射和VO参数命名,以提高代码的可读性和一致性。

-修正了在创建财务支付记录时向发起人发送审批结果通知的逻辑,确保根据审批结果正确发送消息。
- 调整了MyBatis映射文件中的部门ID查询条件,以使用正确的字段
This commit is contained in:
aikai 2024-08-18 17:29:13 +08:00
parent 237db15944
commit b026cffe70
3 changed files with 36 additions and 6 deletions

View File

@ -25,5 +25,5 @@ public interface FinancialPaymentMapper extends BaseMapperX<FinancialPaymentDO>
* @param page * @param page
* @return * @return
*/ */
IPage<FinancialPaymentDO> getFinancialPaymentPage(@Param("vp") FinancialPaymentPageReqVO vo, @Param("page") Page page); IPage<FinancialPaymentDO> getFinancialPaymentPage(@Param("vo") FinancialPaymentPageReqVO vo, @Param("page") Page page);
} }

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.bpm.service.financialpayment; 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.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; 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.FinancialPaymentSaveReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentSaveVO; 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.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.financialpayment.FinancialPaymentDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpaymentitem.FinancialPaymentItemDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpaymentitem.FinancialPaymentItemDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOACashDO; 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.BpmOAProcurePayMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReimbursementMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReimbursementMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; 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 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.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -34,6 +43,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi
* @author 艾楷 * @author 艾楷
*/ */
@Service @Service
@Slf4j
@Validated @Validated
public class FinancialPaymentServiceImpl implements FinancialPaymentService { public class FinancialPaymentServiceImpl implements FinancialPaymentService {
@ -49,6 +59,12 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
private BpmOAProcurePayMapper oAProcurePayMapper; private BpmOAProcurePayMapper oAProcurePayMapper;
@Resource @Resource
private BpmOAReimbursementMapper reimbursementMapper; private BpmOAReimbursementMapper reimbursementMapper;
@Resource
private SubscribeMessageSendApi subscribeMessageSendApi;
@Resource
private RuntimeService runtimeService;
@Resource
private AdminUserApi userApi;
@Override @Override
public Long createFinancialPayment(FinancialPaymentSaveVO vo) { public Long createFinancialPayment(FinancialPaymentSaveVO vo) {
@ -80,12 +96,26 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
} else if (financialPayment.getType() == 4) { } else if (financialPayment.getType() == 4) {
reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult())); reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult()));
} }
// --- 发消息通知发起人
} }
this.updateById(financialPayment); 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(); return financialPayment.getId();
} }

View File

@ -23,7 +23,7 @@
<where> <where>
a.deleted = 0 a.deleted = 0
<if test="vo.deptId != null"> <if test="vo.deptId != null">
and b.dept_id = #{vo.deptId} and c.id = #{vo.deptId}
</if> </if>
<if test="vo.nickname != null and vo.nickname != ''"> <if test="vo.nickname != null and vo.nickname != ''">
and b.nickname like concat('%', #{vo.nickname}, '%') and b.nickname like concat('%', #{vo.nickname}, '%')