From 6e0a98eea79016f27c1c22f3a6541809c6d353d1 Mon Sep 17 00:00:00 2001 From: aikai Date: Sun, 18 Aug 2024 21:41:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(bpm):=20=E4=BF=AE=E5=A4=8D=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E6=94=AF=E4=BB=98=E8=AF=A6=E6=83=85=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=92=8C=E5=AD=90=E8=A1=A8=E9=99=84=E4=BB=B6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了查询财务支付详情时的错误,调整了财务支付子表的附件信息处理方式。现在,通过FinancialPaymentController获取财务支付详情时,将正确转换FinancialPaymentItemDO的附件信息字段,并避免在查询时出现SQL错误。此外,优化了FinancialPaymentMapper的查询方式,增加了直接查询FinancialPaymentDO的方法,提高了查询效率。 --- .../FinancialPaymentController.java | 17 ++++++++++- .../vo/FinancialPaymentItemRespVO.java | 6 ++-- .../vo/FinancialPaymentItemSaveReqVO.java | 9 ++++-- .../FinancialPaymentItemDO.java | 21 ++++++++------ .../FinancialPaymentMapper.java | 10 +++++-- .../FinancialPaymentServiceImpl.java | 28 ++++++++++++++----- .../FinancialPaymentMapper.xml | 15 ++++++++++ 7 files changed, 83 insertions(+), 23 deletions(-) diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/FinancialPaymentController.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/FinancialPaymentController.java index a65dab39..7753f89a 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/FinancialPaymentController.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpayment/FinancialPaymentController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.bpm.controller.admin.financialpayment; +import cn.hutool.core.collection.CollectionUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -8,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.FinancialPaymentItemRespVO; +import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile; 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.service.financialpayment.FinancialPaymentService; @@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.util.ArrayList; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -75,7 +78,19 @@ public class FinancialPaymentController { FinancialPaymentDO financialPayment = financialPaymentService.getFinancialPayment(id); FinancialPaymentRespVO vo = BeanUtils.toBean(financialPayment, FinancialPaymentRespVO.class); List list = financialPaymentItemService.getByFinancialPaymentId(id); - List items = BeanUtils.toBean(list, FinancialPaymentItemRespVO.class); + List items = new ArrayList<>(); + for (FinancialPaymentItemDO financialPaymentItemDO : list) { + FinancialPaymentItemRespVO item = new FinancialPaymentItemRespVO(); + item.setId(financialPaymentItemDO.getId()); + item.setNotes(financialPaymentItemDO.getNotes()); + item.setAmount(financialPaymentItemDO.getAmount()); + item.setFinancialPaymentId(financialPaymentItemDO.getFinancialPaymentId()); + item.setCreateTime(financialPaymentItemDO.getCreateTime()); + if (CollectionUtil.isNotEmpty(financialPaymentItemDO.getFileItems())) { + item.setFileItems(new ArrayList()); + } + items.add(item); + } vo.setItems(items); return success(vo); } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemRespVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemRespVO.java index 60b1356c..17d40236 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemRespVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemRespVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.bpm.controller.admin.financialpaymentitem.vo; +import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 财务支付子表 Response VO") @Data @@ -22,8 +24,8 @@ public class FinancialPaymentItemRespVO { @Schema(description = "备注说明") private String notes; - @Schema(description = "附件信息") - private String fileItems; + @Schema(description = "附件信息", requiredMode = Schema.RequiredMode.REQUIRED) + private List fileItems; @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemSaveReqVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemSaveReqVO.java index 0492c0b9..206b9d32 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemSaveReqVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/financialpaymentitem/vo/FinancialPaymentItemSaveReqVO.java @@ -1,5 +1,8 @@ package cn.iocoder.yudao.module.bpm.controller.admin.financialpaymentitem.vo; +import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -23,7 +26,7 @@ public class FinancialPaymentItemSaveReqVO { @Schema(description = "备注说明") private String notes; - @Schema(description = "附件信息") - private String fileItems; + @TableField(typeHandler = JacksonTypeHandler.class) + private List fileItems ; -} \ No newline at end of file +} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/financialpaymentitem/FinancialPaymentItemDO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/financialpaymentitem/FinancialPaymentItemDO.java index b0f10de8..b852e66d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/financialpaymentitem/FinancialPaymentItemDO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/financialpaymentitem/FinancialPaymentItemDO.java @@ -1,12 +1,16 @@ package cn.iocoder.yudao.module.bpm.dal.dataobject.financialpaymentitem; -import lombok.*; -import java.util.*; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import lombok.*; + +import java.math.BigDecimal; +import java.util.List; /** * 财务支付子表 DO @@ -43,6 +47,7 @@ public class FinancialPaymentItemDO extends BaseDO { /** * 附件信息 */ - private String fileItems; + @TableField(typeHandler = JacksonTypeHandler.class) + private List fileItems; -} \ No newline at end of file +} 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 346e3fe9..0972765f 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 @@ -1,8 +1,6 @@ package cn.iocoder.yudao.module.bpm.dal.mysql.financialpayment; -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentPageReqVO; import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -26,4 +24,12 @@ public interface FinancialPaymentMapper extends BaseMapperX * @return */ IPage getFinancialPaymentPage(@Param("vo") FinancialPaymentPageReqVO vo, @Param("page") Page page); + + /** + * 获取详情 + * + * @param id + * @return + */ + FinancialPaymentDO getFinancialPayment(@Param("id") Long id); } 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 963487d1..b90d0f6b 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 @@ -16,20 +16,21 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOACashDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAImprestDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcurePayDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO; +import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO; import cn.iocoder.yudao.module.bpm.dal.mysql.financialpayment.FinancialPaymentMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.financialpaymentitem.FinancialPaymentItemMapper; import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOACashMapper; 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.dal.mysql.task.BpmProcessInstanceExtMapper; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; +import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceStatusEnum; 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; @@ -62,9 +63,9 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { @Resource private SubscribeMessageSendApi subscribeMessageSendApi; @Resource - private RuntimeService runtimeService; - @Resource private AdminUserApi userApi; + @Resource + private BpmProcessInstanceExtMapper processInstanceExtMapper; @Override public Long createFinancialPayment(FinancialPaymentSaveVO vo) { @@ -96,17 +97,30 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { } else if (financialPayment.getType() == 4) { reimbursementMapper.updateById(new BpmOAReimbursementDO().setId(financialPayment.getObjectId()).setResult(BpmProcessInstanceResultEnum.BACK.getResult())); } + BpmProcessInstanceExtDO instanceExtDO = new BpmProcessInstanceExtDO().setProcessInstanceId(financialPayment.getProcessInstanceId()) + .setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()) + .setResult(BpmProcessInstanceResultEnum.BACK.getResult()); + processInstanceExtMapper.updateByProcessInstanceId(instanceExtDO); } this.updateById(financialPayment); + String processDefinitionName = ""; + if (financialPayment.getType() == 1) { + processDefinitionName = "现金支出"; + } else if (financialPayment.getType() == 2) { + processDefinitionName = "备用金"; + }else if (financialPayment.getType() == 3) { + processDefinitionName = "采购付款"; + }else if (financialPayment.getType() == 4) { + processDefinitionName = "报销"; + } 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(), + adminUserRespDTO.getOpenId(), processDefinitionName, time, vo.getStatus() == 1 ? "通过" : "拒绝", financialPaymentItem.getNotes(), financialPayment.getProcessInstanceId(), /** * 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 @@ -135,7 +149,7 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService { @Override public FinancialPaymentDO getFinancialPayment(Long id) { - return financialPaymentMapper.selectById(id); + return financialPaymentMapper.getFinancialPayment(id); } @Override 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 e67e467d..12fd1cc4 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 @@ -62,4 +62,19 @@ order by a.create_time desc +