refactor(bpm): 优化报销和贷款相关功能
- 移除 BpmOAExpensesMapper 中的冗余连接和条件 - 在 BpmOALoanServiceImpl 中添加借支人所属厂区信息 - 更新 BpmOAPaymentMapper 和 BpmOAPaymentPageReqVO,支持按申请人用户编号查询 - 在 BpmOAReimbursementController 中添加付款公司名称 - 更新 BpmOAReimbursementCreateReqVO、BpmOAReimbursementDO 和 BpmOAReimbursementRespVO,支持付款公司 - 优化 BpmProcessInstanceServiceImpl 中的事务处理逻辑
This commit is contained in:
parent
52fc51c738
commit
3aef43868f
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOARei
|
|||||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
||||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
||||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
|
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
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.project.dto.ProjectDTO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -37,6 +38,9 @@ public class BpmOAReimbursementController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProjectApi projectApi;
|
private ProjectApi projectApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeptApi deptApi;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:create')")
|
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:create')")
|
||||||
@Operation(summary = "创建请求申请")
|
@Operation(summary = "创建请求申请")
|
||||||
@ -52,10 +56,16 @@ public class BpmOAReimbursementController {
|
|||||||
|
|
||||||
BpmOAReimbursementDO reimbursement = service.getReimbursement(id);
|
BpmOAReimbursementDO reimbursement = service.getReimbursement(id);
|
||||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
if (respVO != null) {
|
||||||
// 设置项目名称
|
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
// 设置项目名称
|
||||||
respVO.setProjectName(projectDTO.getName());
|
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||||
|
respVO.setProjectName(projectDTO.getName());
|
||||||
|
}
|
||||||
|
if (respVO.getPaymentCompany() != null) {
|
||||||
|
// 设置付款公司名称
|
||||||
|
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success(respVO);
|
return success(respVO);
|
||||||
}
|
}
|
||||||
@ -82,10 +92,16 @@ public class BpmOAReimbursementController {
|
|||||||
|
|
||||||
BpmOAReimbursementDO reimbursement = service.getByProcessInstanceId(processInstanceId);
|
BpmOAReimbursementDO reimbursement = service.getByProcessInstanceId(processInstanceId);
|
||||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
if (respVO != null) {
|
||||||
// 设置项目名称
|
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
// 设置项目名称
|
||||||
respVO.setProjectName(projectDTO.getName());
|
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||||
|
respVO.setProjectName(projectDTO.getName());
|
||||||
|
}
|
||||||
|
if (respVO.getPaymentCompany() != null) {
|
||||||
|
// 设置付款公司名称
|
||||||
|
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success(respVO);
|
return success(respVO);
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,7 @@ public class BpmOAPaymentPageReqVO extends PageParam {
|
|||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private String[] createTime;
|
private String[] createTime;
|
||||||
|
|
||||||
|
@Schema(description = "申请人用户编号")
|
||||||
|
private Long userId;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ public class BpmOAReimbursementCreateReqVO {
|
|||||||
@Schema(description = "开户行信息")
|
@Schema(description = "开户行信息")
|
||||||
private String bankName;
|
private String bankName;
|
||||||
|
|
||||||
|
@Schema(description = "付款公司")
|
||||||
|
private Long paymentCompany;
|
||||||
|
|
||||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "报销项目不能为空")
|
@NotNull(message = "报销项目不能为空")
|
||||||
private List<Reimbursement> reimbursements;
|
private List<Reimbursement> reimbursements;
|
||||||
|
@ -27,6 +27,12 @@ public class BpmOAReimbursementRespVO extends BpmOABaseRespVO {
|
|||||||
@Schema(description = "收款人卡号")
|
@Schema(description = "收款人卡号")
|
||||||
private String bankNo;
|
private String bankNo;
|
||||||
|
|
||||||
|
@Schema(description = "付款公司")
|
||||||
|
private Long paymentCompany;
|
||||||
|
|
||||||
|
@Schema(description = "付款公司名称")
|
||||||
|
private String paymentCompanyName;
|
||||||
|
|
||||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "报销项目不能为空")
|
@NotNull(message = "报销项目不能为空")
|
||||||
private List<ReimbursementDTO> reimbursements;
|
private List<ReimbursementDTO> reimbursements;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@ -64,6 +63,11 @@ public class BpmOAReimbursementDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String bankName;
|
private String bankName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款公司编号
|
||||||
|
*/
|
||||||
|
private Long paymentCompany;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 报销明细数据JSON
|
// * 报销明细数据JSON
|
||||||
// */
|
// */
|
||||||
|
@ -26,6 +26,7 @@ public interface BpmOAPaymentMapper extends BaseMapperX<BpmOAPaymentDO> {
|
|||||||
.eq(BpmOAPaymentDO::getIsTickets, 1)
|
.eq(BpmOAPaymentDO::getIsTickets, 1)
|
||||||
.eqIfPresent(BpmOAPaymentDO::getStatus, pageReqVO.getStatus())
|
.eqIfPresent(BpmOAPaymentDO::getStatus, pageReqVO.getStatus())
|
||||||
.betweenIfPresent(BpmOAPaymentDO::getCreateTime, pageReqVO.getCreateTime())
|
.betweenIfPresent(BpmOAPaymentDO::getCreateTime, pageReqVO.getCreateTime())
|
||||||
|
.eqIfPresent(BpmOAPaymentDO::getUserId, pageReqVO.getUserId())
|
||||||
.eq(pageReqVO.getIsMy(), BpmOAPaymentDO::getUserId, userId)
|
.eq(pageReqVO.getIsMy(), BpmOAPaymentDO::getUserId, userId)
|
||||||
.orderByAsc(BpmOAPaymentDO::getStatus)
|
.orderByAsc(BpmOAPaymentDO::getStatus)
|
||||||
.orderByDesc(BpmOAPaymentDO::getId));
|
.orderByDesc(BpmOAPaymentDO::getId));
|
||||||
|
@ -20,6 +20,8 @@ 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.financialpayment.FinancialPaymentService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||||
|
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.dto.FactoryInfoDTO;
|
||||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||||
@ -77,6 +79,9 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
|||||||
@Resource
|
@Resource
|
||||||
private BankApi bankApi;
|
private BankApi bankApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FactoryInfoApi factoryInfoApi;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -97,8 +102,18 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
|||||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||||
loanMapper.insert(loan);
|
loanMapper.insert(loan);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 发起 BPM 流程
|
// 发起 BPM 流程
|
||||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
|
// 提交是费用借支时
|
||||||
|
if (vo.getLoanType() == 2) {
|
||||||
|
|
||||||
|
// 获取借支人所属厂区信息
|
||||||
|
FactoryInfoDTO factoryInfoDTO = factoryInfoApi.getFactoryInfo(loan.getFactoryId()).getCheckedData();
|
||||||
|
processInstanceVariables.put("factoryType", factoryInfoDTO.getType());
|
||||||
|
}
|
||||||
|
|
||||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(loan.getId())));
|
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(loan.getId())));
|
||||||
|
File diff suppressed because one or more lines are too long
@ -70,12 +70,10 @@
|
|||||||
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
|
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
|
||||||
FROM
|
FROM
|
||||||
bpm_oa_expenses a
|
bpm_oa_expenses a
|
||||||
LEFT JOIN bpm_oa_expenses_item b ON b.expenses_id = a.id
|
|
||||||
LEFT JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_id
|
LEFT JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_id
|
||||||
LEFT JOIN system_bank ub ON ub.id = a.bank_id
|
LEFT JOIN system_bank ub ON ub.id = a.bank_id
|
||||||
WHERE
|
WHERE
|
||||||
a.deleted = 0
|
a.deleted = 0
|
||||||
AND b.deleted = 0
|
|
||||||
AND a.result = 2
|
AND a.result = 2
|
||||||
<if test="pageReqVO.userId != null">
|
<if test="pageReqVO.userId != null">
|
||||||
AND a.user_id = #{pageReqVO.userId}
|
AND a.user_id = #{pageReqVO.userId}
|
||||||
|
Loading…
Reference in New Issue
Block a user