refactor(bpm): 重构报销、现金支出和付款业务的打印数据处理逻辑
- 新增 BpmOAPrintDataRespVO 类统一报销、现金支出和付款业务的打印数据结构 - 新增 BpmProcessInstancePrintDataRespVO 类用于流程实例的打印数据响应 - 重构 BpmOAPaymentController 和 BpmOAPaymentService 接口,将业务逻辑移至服务层 - 优化 BpmProcessInstanceServiceImpl 中的打印数据处理逻辑,支持多种业务类型
This commit is contained in:
parent
a182bef370
commit
1fcb34677e
@ -49,18 +49,12 @@ public class BpmOAPaymentController {
|
||||
@Resource
|
||||
private BpmOAPaymentService paymentService;
|
||||
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建付款申请")
|
||||
public CommonResult<Long> createPayment(@Valid @RequestBody BpmOAPaymentCreateReqVO createReqVO) {
|
||||
@ -74,44 +68,7 @@ public class BpmOAPaymentController {
|
||||
public CommonResult<BpmOAPaymentRespVO> getPayment(@RequestParam("id") Long id) {
|
||||
|
||||
BpmOAPaymentDO payment = paymentService.getPayment(id);
|
||||
BpmOAPaymentRespVO respVO = BeanUtils.toBean(payment, BpmOAPaymentRespVO.class);
|
||||
if (respVO != null) {
|
||||
|
||||
// 获取部门信息Map
|
||||
List<Long> deptIds = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(respVO.getFactoryDetail())) {
|
||||
deptIds.addAll(convertList(respVO.getFactoryDetail(), FactoryDetailVO::getDeptId));
|
||||
}else {
|
||||
deptIds.add(payment.getDeptId());
|
||||
}
|
||||
deptIds.add(payment.getPaymentCompany());
|
||||
Map<Long, DeptRespDTO> dtoMap = deptApi.getDeptMap(new HashSet<>(deptIds));
|
||||
|
||||
// 设置部门名称
|
||||
respVO.setDeptName(dtoMap.get(payment.getDeptId()) != null ? dtoMap.get(payment.getDeptId()).getName() : null);
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(dtoMap.get(payment.getPaymentCompany()).getName());
|
||||
// 设置工厂名称
|
||||
respVO.getFactoryDetail().forEach(item -> {
|
||||
item.setFactoryName(dtoMap.get(item.getDeptId()).getName());
|
||||
});
|
||||
|
||||
if (StringUtils.isNotEmpty(payment.getProjectNo())) {
|
||||
// 获取项目信息
|
||||
ProjectDTO project = projectApi.getProject(payment.getProjectNo()).getCheckedData();
|
||||
// 设置项目名称
|
||||
respVO.setProjectName(project.getName());
|
||||
}
|
||||
|
||||
if (payment.getBankId() != null) {
|
||||
// 获取银行卡信息
|
||||
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
|
||||
// 设置银行卡信息
|
||||
respVO.setBankName(bankResp.getBankName());
|
||||
respVO.setBankNo(bankResp.getBankNo());
|
||||
respVO.setNickname(bankResp.getNickname());
|
||||
}
|
||||
}
|
||||
BpmOAPaymentRespVO respVO = paymentService.convertPayment(payment);
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
@ -122,43 +79,7 @@ public class BpmOAPaymentController {
|
||||
public CommonResult<BpmOAPaymentRespVO> getByProcessInstanceId(@RequestParam("processInstanceId") String processInstanceId) {
|
||||
|
||||
BpmOAPaymentDO payment = paymentService.getByProcessInstanceId(processInstanceId);
|
||||
BpmOAPaymentRespVO respVO = BeanUtils.toBean(payment, BpmOAPaymentRespVO.class);
|
||||
if (respVO != null) {
|
||||
// 获取部门信息Map
|
||||
List<Long> deptIds = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(respVO.getFactoryDetail())) {
|
||||
deptIds.addAll(convertList(respVO.getFactoryDetail(), FactoryDetailVO::getDeptId));
|
||||
}else {
|
||||
deptIds.add(payment.getDeptId());
|
||||
}
|
||||
deptIds.add(payment.getPaymentCompany());
|
||||
Map<Long, DeptRespDTO> dtoMap = deptApi.getDeptMap(new HashSet<>(deptIds));
|
||||
|
||||
// 设置部门名称
|
||||
respVO.setDeptName(dtoMap.get(payment.getDeptId()) != null ? dtoMap.get(payment.getDeptId()).getName() : null);
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(dtoMap.get(payment.getPaymentCompany()).getName());
|
||||
// 设置工厂名称
|
||||
respVO.getFactoryDetail().forEach(item -> {
|
||||
item.setFactoryName(dtoMap.get(item.getDeptId()).getName());
|
||||
});
|
||||
|
||||
if (payment.getProjectNo() != null) {
|
||||
// 获取项目信息
|
||||
ProjectDTO project = projectApi.getProject(payment.getProjectNo()).getCheckedData();
|
||||
// 设置项目名称
|
||||
respVO.setProjectName(project.getName());
|
||||
}
|
||||
|
||||
if (payment.getBankId() != null) {
|
||||
// 获取银行卡信息
|
||||
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
|
||||
// 设置银行卡信息
|
||||
respVO.setBankName(bankResp.getBankName());
|
||||
respVO.setBankNo(bankResp.getBankNo());
|
||||
respVO.setNickname(bankResp.getNickname());
|
||||
}
|
||||
}
|
||||
BpmOAPaymentRespVO respVO = paymentService.convertPayment(payment);
|
||||
|
||||
return success(respVO);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.print;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOABaseRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.cash.BpmOACashRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -14,12 +16,18 @@ import java.util.List;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOAReimbursementPrintDataRespVO extends BpmOABaseRespVO {
|
||||
public class BpmOAPrintDataRespVO extends BpmOABaseRespVO {
|
||||
|
||||
@Schema(description = "报销业务数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "报销业务数据")
|
||||
private BpmOAReimbursementRespVO bpmOAReimbursementRespVO ;
|
||||
|
||||
@Schema(description = "流程审批节点信息【包含人员签名地址】", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "现金支出业务数据")
|
||||
private BpmOACashRespVO bpmOACashRespVO;
|
||||
|
||||
@Schema(description = "付款业务数据")
|
||||
private BpmOAPaymentRespVO bpmOAPaymentRespVO;
|
||||
|
||||
@Schema(description = "流程审批节点信息【包含人员签名地址】")
|
||||
List<BpmTaskRespVO> processTasks ;
|
||||
|
||||
/**
|
@ -15,9 +15,9 @@ public class BpmProcessInstancePrintDataRespVO {
|
||||
@Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "oa_reimbursement")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "报销业务打印数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BpmOAReimbursementPrintDataRespVO bpmOAReimbursementPrintDataRespVO ;
|
||||
@Schema(description = "业务打印数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BpmOAPrintDataRespVO printDataRespVO ;
|
||||
|
||||
@Schema(description = "现金支出业务打印数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BpmOACashPrintDataRespVO bpmOACashPrintDataRespVO;
|
||||
// @Schema(description = "现金支出业务打印数据", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private BpmOACashPrintDataRespVO bpmOACashPrintDataRespVO;
|
||||
}
|
||||
|
@ -77,4 +77,6 @@ public interface BpmOAPaymentService {
|
||||
* @param url utl
|
||||
*/
|
||||
void deleteFiles(Long id, String url);
|
||||
|
||||
BpmOAPaymentRespVO convertPayment(BpmOAPaymentDO payment);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.BpmOAPaymentUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.payment.*;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAPaymentDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
@ -18,19 +16,24 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||
import cn.iocoder.yudao.module.system.api.bank.dto.BankRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_PAYMENT_FILES_NOT_NULL;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.OA_PAYMENT_NOT_EXISTS;
|
||||
|
||||
@ -63,6 +66,15 @@ public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPa
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Override
|
||||
public Long createPayment(Long userId, BpmOAPaymentCreateReqVO createReqVO) {
|
||||
|
||||
@ -204,6 +216,50 @@ public class BpmOAPaymentServiceImpl extends BpmOABaseService implements BpmOAPa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOAPaymentRespVO convertPayment(BpmOAPaymentDO payment) {
|
||||
|
||||
BpmOAPaymentRespVO respVO = BeanUtils.toBean(payment, BpmOAPaymentRespVO.class);
|
||||
if (respVO != null) {
|
||||
|
||||
// 获取部门信息Map
|
||||
List<Long> deptIds = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(respVO.getFactoryDetail())) {
|
||||
deptIds.addAll(convertList(respVO.getFactoryDetail(), FactoryDetailVO::getDeptId));
|
||||
}else {
|
||||
deptIds.add(payment.getDeptId());
|
||||
}
|
||||
deptIds.add(payment.getPaymentCompany());
|
||||
Map<Long, DeptRespDTO> dtoMap = deptApi.getDeptMap(new HashSet<>(deptIds));
|
||||
|
||||
// 设置部门名称
|
||||
respVO.setDeptName(dtoMap.get(payment.getDeptId()) != null ? dtoMap.get(payment.getDeptId()).getName() : null);
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(dtoMap.get(payment.getPaymentCompany()).getName());
|
||||
// 设置工厂名称
|
||||
respVO.getFactoryDetail().forEach(item -> {
|
||||
item.setFactoryName(dtoMap.get(item.getDeptId()).getName());
|
||||
});
|
||||
|
||||
if (StringUtils.isNotEmpty(payment.getProjectNo())) {
|
||||
// 获取项目信息
|
||||
ProjectDTO project = projectApi.getProject(payment.getProjectNo()).getCheckedData();
|
||||
// 设置项目名称
|
||||
respVO.setProjectName(project.getName());
|
||||
}
|
||||
|
||||
if (payment.getBankId() != null) {
|
||||
// 获取银行卡信息
|
||||
BankRespDTO bankResp = bankApi.getBank(payment.getBankId()).getCheckedData();
|
||||
// 设置银行卡信息
|
||||
respVO.setBankName(bankResp.getBankName());
|
||||
respVO.setBankNo(bankResp.getBankNo());
|
||||
respVO.setNickname(bankResp.getNickname());
|
||||
}
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
|
||||
private BpmOAPaymentDO validateLeaveExists(Long id) {
|
||||
BpmOAPaymentDO paymentDO = paymentMapper.selectById(id);
|
||||
if (paymentDO == null) {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user