|
@@ -1,6 +1,5 @@
|
|
|
package com.fjhx.account.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;
|
|
@@ -9,7 +8,6 @@ import com.fjhx.account.entity.account.dto.AccountPaymentDto;
|
|
|
import com.fjhx.account.entity.account.dto.AccountRequestFundsDto;
|
|
|
import com.fjhx.account.entity.account.enums.AccountRequestFundsStatusEnum;
|
|
|
import com.fjhx.account.entity.account.enums.PaymentStatusEnum;
|
|
|
-import com.fjhx.account.entity.account.enums.PaymentTypeEnum;
|
|
|
import com.fjhx.account.entity.account.po.AccountRequestFunds;
|
|
|
import com.fjhx.account.entity.account.po.AccountRequestFundsDetail;
|
|
|
import com.fjhx.account.service.account.AccountPaymentService;
|
|
@@ -35,9 +33,16 @@ import java.util.List;
|
|
|
@DS(SourceConstant.ACCOUNT)
|
|
|
@Component
|
|
|
public class AccountRequestFundsFlow extends FlowDelegate {
|
|
|
+
|
|
|
@Autowired
|
|
|
private AccountPaymentService accountPaymentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AccountRequestFundsService accountRequestFundsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AccountRequestFundsDetailService accountRequestFundsDetailService;
|
|
|
+
|
|
|
@Override
|
|
|
public String getFlowKey() {
|
|
|
return "account_request_funds_flow";
|
|
@@ -53,24 +58,24 @@ public class AccountRequestFundsFlow extends FlowDelegate {
|
|
|
*/
|
|
|
@Override
|
|
|
public Long start(Long flowId, JSONObject submitData) {
|
|
|
-// DynamicDataSourceContextHolder.push(SourceConstant.ACCOUNT);
|
|
|
- AccountRequestFundsService accountRequestFundsService = SpringUtil.getBean(AccountRequestFundsService.class);
|
|
|
- AccountRequestFundsDetailService accountRequestFundsDetailService = SpringUtil.getBean(AccountRequestFundsDetailService.class);
|
|
|
+
|
|
|
+ // 获取提交数据
|
|
|
AccountRequestFundsDto accountRequestFundsDto = submitData.toJavaObject(AccountRequestFundsDto.class);
|
|
|
+
|
|
|
+ // 添加请款表的信息
|
|
|
accountRequestFundsDto.setStatus(AccountRequestFundsStatusEnum.UNDER_REVIEW.getKey());
|
|
|
- //添加请款表的信息
|
|
|
accountRequestFundsService.save(accountRequestFundsDto);
|
|
|
|
|
|
- //获取请款详情表的详细信息
|
|
|
+ // 添加请款详情表的信息
|
|
|
List<AccountRequestFundsDetail> accountRequestFundsDetailList = accountRequestFundsDto.getAccountRequestFundsDetailList();
|
|
|
if (CollectionUtils.isNotEmpty(accountRequestFundsDetailList)) {
|
|
|
- accountRequestFundsDetailList.forEach(accountRequestFundsDetail -> accountRequestFundsDetail
|
|
|
- .setAccountRequestFundsId(accountRequestFundsDto.getId()));
|
|
|
- //添加请款详情表的信息
|
|
|
+ accountRequestFundsDetailList.forEach(item -> item.setAccountRequestFundsId(accountRequestFundsDto.getId()));
|
|
|
accountRequestFundsDetailService.saveBatch(accountRequestFundsDetailList);
|
|
|
}
|
|
|
- //添加附件信息
|
|
|
+
|
|
|
+ // 添加附件信息
|
|
|
ObsFileUtil.saveFile(accountRequestFundsDto.getFileList(), accountRequestFundsDto.getId());
|
|
|
+
|
|
|
return accountRequestFundsDto.getId();
|
|
|
}
|
|
|
|
|
@@ -83,59 +88,63 @@ public class AccountRequestFundsFlow extends FlowDelegate {
|
|
|
*/
|
|
|
@Override
|
|
|
public void end(Long flowId, Long businessId, JSONObject submitData) {
|
|
|
- AccountRequestFundsService accountRequestFundsService = SpringUtil.getBean(AccountRequestFundsService.class);
|
|
|
- //通过业务ID查询申购数据
|
|
|
+ // 通过业务ID查询申购数据
|
|
|
AccountRequestFunds accountRequestFunds = accountRequestFundsService.getById(businessId);
|
|
|
- AccountRequestFundsDto accountRequestFundsDto = submitData.toJavaObject(AccountRequestFundsDto.class);
|
|
|
if (ObjectUtils.isEmpty(accountRequestFunds)) {
|
|
|
throw new ServiceException("请款表的数据不存在");
|
|
|
}
|
|
|
- //修改申购状态为审批通过
|
|
|
+
|
|
|
+ // 修改申购状态为审批通过
|
|
|
accountRequestFunds.setStatus(AccountRequestFundsStatusEnum.PASS.getKey());
|
|
|
- //修改核销状态以及预支单核销状态为已核销
|
|
|
- if ("3".equals(accountRequestFundsDto.getType())) {
|
|
|
+
|
|
|
+ // 修改核销状态以及预支单核销状态为已核销
|
|
|
+ if ("3".equals(accountRequestFunds.getType())) {
|
|
|
accountRequestFunds.setWriteOffStatus(1);
|
|
|
- //修改预支单核销状态
|
|
|
+ // 修改预支单核销状态
|
|
|
AccountRequestFunds advance = accountRequestFundsService.getById(accountRequestFunds.getAdvanceId());
|
|
|
- Assert.notEmpty(advance,"查询不到关联预支单信息");
|
|
|
+ Assert.notEmpty(advance, "查询不到关联预支单信息");
|
|
|
advance.setWriteOffStatus(1);
|
|
|
accountRequestFundsService.updateById(advance);
|
|
|
}
|
|
|
+
|
|
|
accountRequestFundsService.updateById(accountRequestFunds);
|
|
|
- //添加打款的数据
|
|
|
- addPayment(accountRequestFundsDto);
|
|
|
+
|
|
|
+ // 添加打款的数据
|
|
|
+ addPayment(accountRequestFunds);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加打款表的数据
|
|
|
*/
|
|
|
- private void addPayment(AccountRequestFundsDto accountRequestFundsDto) {
|
|
|
+ private void addPayment(AccountRequestFunds accountRequestFunds) {
|
|
|
AccountPaymentDto accountPayment = new AccountPaymentDto();
|
|
|
- accountPayment.setBusinessId(accountRequestFundsDto.getId());
|
|
|
- accountPayment.setType(PaymentTypeEnum.UNDER_REVIEW.getKey());
|
|
|
+
|
|
|
+ accountPayment.setDepartmentId(accountRequestFunds.getDepartmentId());
|
|
|
+ accountPayment.setCorporationId(accountRequestFunds.getCorporationId());
|
|
|
+ accountPayment.setBusinessId(accountRequestFunds.getId());
|
|
|
+ accountPayment.setPaymentTime(accountRequestFunds.getPaymentTime());
|
|
|
+ accountPayment.setCurrency(accountRequestFunds.getCurrency());
|
|
|
accountPayment.setStatus(PaymentStatusEnum.UNDER_REVIEW.getKey());
|
|
|
- accountPayment.setPaymentTime(accountPayment.getPaymentTime());
|
|
|
- accountPayment.setPaymentRemark(accountRequestFundsDto.getPaymentRemarks());
|
|
|
-
|
|
|
- accountPayment.setDepartmentId(accountRequestFundsDto.getDepartmentId());
|
|
|
- accountPayment.setCorporationId(accountRequestFundsDto.getCorporationId());
|
|
|
- accountPayment.setBusinessId(accountPayment.getId());
|
|
|
- accountPayment.setPaymentMethod(accountRequestFundsDto.getPaymentMethod());
|
|
|
- accountPayment.setIncomeAmount(accountRequestFundsDto.getTotal());
|
|
|
- accountPayment.setAmount(accountRequestFundsDto.getTotal());
|
|
|
- accountPayment.setName(accountRequestFundsDto.getName());
|
|
|
- accountPayment.setBusinessManagementId(accountRequestFundsDto.getAccountManagementId());
|
|
|
- accountPayment.setOpeningBank(accountRequestFundsDto.getOpeningBank());
|
|
|
- accountPayment.setCurrency(accountPayment.getCurrency());
|
|
|
- accountPayment.setAccountOpening(accountRequestFundsDto.getAccountOpening());
|
|
|
- accountPayment.setInterbankNumber(accountPayment.getInterbankNumber());
|
|
|
-
|
|
|
- //如果是核销 核销数据审批通过后,根据“核销总额 - 预支总额”生成“待打款”数据
|
|
|
- if ("3".equals(accountRequestFundsDto.getType())) {
|
|
|
- BigDecimal subtract = accountRequestFundsDto.getTotal().subtract(accountRequestFundsDto.getAdvanceAmounts());
|
|
|
+ accountPayment.setType(accountRequestFunds.getType());
|
|
|
+ accountPayment.setPaymentRemark(accountRequestFunds.getPaymentRemarks());
|
|
|
+ accountPayment.setPaymentMethod(accountRequestFunds.getPaymentMethod());
|
|
|
+ accountPayment.setIncomeAmount(accountRequestFunds.getTotal());
|
|
|
+ accountPayment.setName(accountRequestFunds.getName());
|
|
|
+ accountPayment.setBusinessManagementId(accountRequestFunds.getAccountManagementId());
|
|
|
+ accountPayment.setOpeningBank(accountRequestFunds.getOpeningBank());
|
|
|
+ accountPayment.setAccountOpening(accountRequestFunds.getAccountOpening());
|
|
|
+ accountPayment.setInterbankNumber(accountRequestFunds.getInterbankNumber());
|
|
|
+
|
|
|
+ // 如果是核销 核销数据审批通过后,根据“核销总额 - 预支总额”生成“待打款”数据
|
|
|
+ if ("3".equals(accountRequestFunds.getType())) {
|
|
|
+ BigDecimal subtract = accountRequestFunds.getTotal().subtract(accountRequestFunds.getAdvanceAmounts());
|
|
|
accountPayment.setAmount(subtract);
|
|
|
+ } else {
|
|
|
+ accountPayment.setAmount(accountRequestFunds.getTotal());
|
|
|
}
|
|
|
|
|
|
accountPaymentService.save(accountPayment);
|
|
|
}
|
|
|
+
|
|
|
}
|