|
@@ -1,6 +1,5 @@
|
|
|
package com.fjhx.purchase.flow;
|
|
|
|
|
|
-import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -18,6 +17,7 @@ import com.fjhx.purchase.entity.pay.po.PayDetail;
|
|
|
import com.fjhx.purchase.service.pay.PayDetailService;
|
|
|
import com.fjhx.purchase.service.pay.PayService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
@@ -25,6 +25,7 @@ import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 采购付款流程
|
|
|
+ *
|
|
|
* @Author:caozj
|
|
|
* @DATE:2023/4/3 17:38
|
|
|
*/
|
|
@@ -32,12 +33,20 @@ import java.util.List;
|
|
|
@Component
|
|
|
public class PayFlow extends FlowDelegate {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PayService payService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AccountPaymentService accountPaymentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PayDetailService payDetailService;
|
|
|
+
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
|
return "pay_flow";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 发起流程
|
|
|
* @param flowId 流程ID
|
|
@@ -46,19 +55,19 @@ public class PayFlow extends FlowDelegate {
|
|
|
*/
|
|
|
@Override
|
|
|
public Long start(Long flowId, JSONObject submitData) {
|
|
|
- PayService payService = SpringUtil.getBean(PayService.class);
|
|
|
- PayDetailService payDetailService = SpringUtil.getBean(PayDetailService.class);
|
|
|
Pay pay = submitData.toJavaObject(Pay.class);
|
|
|
+
|
|
|
pay.setStatus(PayStatusEnum.UNDER_REVIEW.getKey());
|
|
|
payService.save(pay);
|
|
|
+
|
|
|
List<PayDetail> payDetailList = pay.getPayDetailList();
|
|
|
- if(CollectionUtils.isNotEmpty(payDetailList)){
|
|
|
- for(PayDetail s : payDetailList){
|
|
|
- s.setPayId(pay.getId());
|
|
|
- }
|
|
|
+ if (CollectionUtils.isNotEmpty(payDetailList)) {
|
|
|
+ payDetailList.forEach(item -> item.setPayId(pay.getId()));
|
|
|
payDetailService.saveBatch(payDetailList);
|
|
|
}
|
|
|
- ObsFileUtil.saveFile(pay.getFileList(),pay.getId());
|
|
|
+
|
|
|
+ ObsFileUtil.saveFile(pay.getFileList(), pay.getId());
|
|
|
+
|
|
|
return pay.getId();
|
|
|
}
|
|
|
|
|
@@ -70,18 +79,19 @@ public class PayFlow extends FlowDelegate {
|
|
|
*/
|
|
|
@Override
|
|
|
public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
- PayService payService = SpringUtil.getBean(PayService.class);
|
|
|
- AccountPaymentService accountPaymentService = SpringUtil.getBean(AccountPaymentService.class);
|
|
|
- //通过业务ID查询申购数据
|
|
|
+
|
|
|
+ // 通过业务ID查询申购数据
|
|
|
Pay pay = payService.getById(businessId);
|
|
|
- if(ObjectUtils.isEmpty(pay)){
|
|
|
+ if (ObjectUtils.isEmpty(pay)) {
|
|
|
throw new ServiceException("采购付款单不存在");
|
|
|
}
|
|
|
- //修改采购状态为审批通过
|
|
|
+
|
|
|
+ // 修改采购状态为审批通过
|
|
|
pay.setStatus(PayStatusEnum.PASS.getKey());
|
|
|
pay.setApprovedDate(new Date());
|
|
|
payService.updateById(pay);
|
|
|
- //添加一条付款流水
|
|
|
+
|
|
|
+ // 添加一条付款流水
|
|
|
AccountPayment payment = new AccountPayment();
|
|
|
payment.setAccountManagementId(pay.getAccountManagementId());
|
|
|
payment.setBusinessId(pay.getId());
|
|
@@ -99,5 +109,6 @@ public class PayFlow extends FlowDelegate {
|
|
|
payment.setInterbankNumber(pay.getInterbankNumber());
|
|
|
payment.setPaymentMethod(pay.getPayType());
|
|
|
accountPaymentService.save(payment);
|
|
|
+
|
|
|
}
|
|
|
}
|