瀏覽代碼

苏商还款定时任务优化

liuj 2 周之前
父節點
當前提交
33230694b6

+ 13 - 3
src/main/java/com/sunxung/factoring/job/impl/SmbTaskJob.java

@@ -60,12 +60,22 @@ public class SmbTaskJob {
     }
 
     /**
-     * 苏商还款文件批处理任务(每天凌晨1点执行
+     * 苏商还款申请重新发起任务(每20分钟执行一次
      */
-    @Scheduled(cron = "0 0 1 * * ?")
+    @Scheduled(cron = "0 0/20 * * * ?")
+    public void repayApplyAgainProcess() {
+        log.info("苏商还款申请重新发起定时任务执行开始...");
+        financingPaymentInfoService.repayApplyAgainProcess();
+        log.info("苏商还款申请重新发起定时任务执行结束...");
+    }
+
+    /**
+     * 苏商还款文件批处理任务(每天凌晨4点执行)
+     */
+    @Scheduled(cron = "0 0 4 * * ?")
     public void repaymentFileProcess() {
         log.info("苏商还款文件批处理任务执行开始...");
-        LocalDate localDate = LocalDate.now().minusDays(1L);
+        LocalDate localDate = LocalDate.now();
         financingReconciliationInfoService.repaymentFileProcess(localDate);
         log.info("苏商还款文件批处理任务执行结束...");
     }

+ 21 - 12
src/main/java/com/sunxung/factoring/service/cashflowmanage/impl/CashFlowManageBasicInfoServiceImpl.java

@@ -726,20 +726,26 @@ public class CashFlowManageBasicInfoServiceImpl extends ServiceImpl<CashFlowMana
             }
             cashFlowManageOutInfoService.save(cashFlowManageOutInfo);
 
-            //更新现金流信息表状态
-            this.lambdaUpdate().eq(CashFlowManageBasicInfo::getId, cashFlowManageOutInfo.getCashFlowManageBasicInfoId())
-                    .set(CashFlowManageBasicInfo::getCashStatus, 4).update();
 
             CashFlowManageBasicInfo cashFlowManageBasicInfo = getById(cashFlowManageOutInfo.getCashFlowManageBasicInfoId());
-            if (cashFlowManageBasicInfo != null && CashFlowOutTypeDict.ChildEnum.MANAGEMENT_AMOUNT.getCode().equals(cashFlowManageBasicInfo.getCashType())) {
-                //如果类型为资方融资款时,需要向苏商银行发起提款申请
-                //异步调用
-                CompletableFuture.runAsync(() -> {
-                    LedgerFundGoodsAssign ledgerFundGoodsAssign = ledgerFundGoodsAssignService.getById(cashFlowManageBasicInfo.getLedgerFundGoodsAssignId());
-                    if (ledgerFundGoodsAssign != null) {
-                        ledgerManagementService.repayApplyBySMB(ledgerFundGoodsAssign);
-                    }
-                });
+            if (cashFlowManageBasicInfo != null) {
+                //更新现金流信息表状态(非资方融资款项类型的)
+                if (!CashFlowOutTypeDict.ChildEnum.MANAGEMENT_AMOUNT.getCode().equals(cashFlowManageBasicInfo.getCashType())) {
+                    this.lambdaUpdate().eq(CashFlowManageBasicInfo::getId, cashFlowManageOutInfo.getCashFlowManageBasicInfoId())
+                            .set(CashFlowManageBasicInfo::getCashStatus, 4).update();
+                } else {
+                    //如果类型为资方融资款时,需要向苏商银行发起提款申请
+                    //异步调用
+                    CompletableFuture.runAsync(() -> {
+                        LedgerFundGoodsAssign ledgerFundGoodsAssign = ledgerFundGoodsAssignService.getById(cashFlowManageBasicInfo.getLedgerFundGoodsAssignId());
+                        if (ledgerFundGoodsAssign != null) {
+                            ledgerManagementService.repayApplyBySMB(ledgerFundGoodsAssign);
+                        }
+                        //更新状态
+                        this.lambdaUpdate().eq(CashFlowManageBasicInfo::getId, cashFlowManageOutInfo.getCashFlowManageBasicInfoId())
+                                .set(CashFlowManageBasicInfo::getCashStatus, 4).update();
+                    });
+                }
             }
         }
     }
@@ -766,12 +772,15 @@ public class CashFlowManageBasicInfoServiceImpl extends ServiceImpl<CashFlowMana
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void repayApplyAgain(Long id) {
         CashFlowManageBasicInfo cashFlowManageBasicInfo = this.getById(id);
         if (cashFlowManageBasicInfo != null) {
             LedgerFundGoodsAssign ledgerFundGoodsAssign = ledgerFundGoodsAssignService.getById(cashFlowManageBasicInfo.getLedgerFundGoodsAssignId());
             if (ledgerFundGoodsAssign != null) {
                 ledgerManagementService.repayApplyBySMB(ledgerFundGoodsAssign);
+                //更新状态
+                this.lambdaUpdate().eq(CashFlowManageBasicInfo::getId, id).set(CashFlowManageBasicInfo::getCashStatus, 4).update();
             }
         }
     }

+ 5 - 0
src/main/java/com/sunxung/factoring/service/smb/IFinancingPaymentInfoService.java

@@ -42,4 +42,9 @@ public interface IFinancingPaymentInfoService extends IService<FinancingPaymentI
      * 还款状态查询
      */
     void repayStatusQuery();
+
+    /**
+     * 苏商还款重新发起
+     */
+    void repayApplyAgainProcess();
 }

+ 30 - 1
src/main/java/com/sunxung/factoring/service/smb/impl/FinancingPaymentInfoServiceImpl.java

@@ -12,8 +12,11 @@ import com.sunxung.factoring.component.util.CodeUtil;
 import com.sunxung.factoring.component.util.CollectionUtil;
 import com.sunxung.factoring.component.util.ConstantConversionUtil;
 import com.sunxung.factoring.component.util.ThreadLocalUtil;
+import com.sunxung.factoring.dict.impl.CashFlowOutTypeDict;
 import com.sunxung.factoring.entity.GridPage;
 import com.sunxung.factoring.entity.ResponseJson;
+import com.sunxung.factoring.entity.cashflowmanage.CashFlowManageBasicInfo;
+import com.sunxung.factoring.entity.cashflowmanage.CashFlowManageOutInfo;
 import com.sunxung.factoring.entity.entprise.Enterprise;
 import com.sunxung.factoring.entity.smb.FinancingPaymentInfo;
 import com.sunxung.factoring.entity.smb.SmbRefinancingInfo;
@@ -22,6 +25,8 @@ import com.sunxung.factoring.entity.sys.Permission;
 import com.sunxung.factoring.entity.sys.UserOrgRel;
 import com.sunxung.factoring.entity.sys.UserRoleRel;
 import com.sunxung.factoring.mapper.smb.FinancingPaymentInfoMapper;
+import com.sunxung.factoring.service.cashflowmanage.CashFlowManageBasicInfoService;
+import com.sunxung.factoring.service.cashflowmanage.CashFlowManageOutInfoService;
 import com.sunxung.factoring.service.entprise.IEnterpriseService;
 import com.sunxung.factoring.service.smb.IFinancingPaymentInfoService;
 import com.sunxung.factoring.service.smbApi.api.SMBApiService;
@@ -41,7 +46,6 @@ import org.springframework.web.client.RestTemplate;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 
 /**
  * <p>
@@ -75,6 +79,12 @@ public class FinancingPaymentInfoServiceImpl extends ServiceImpl<FinancingPaymen
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private CashFlowManageBasicInfoService cashFlowManageBasicInfoService;
+
+    @Autowired
+    private CashFlowManageOutInfoService cashFlowManageOutInfoService;
+
     @Override
     public GridPage<FinancingPaymentInfo> findBySearch(FinancingPaymentInfoSearch search) {
         Long currentUserId = ThreadLocalUtil.getUserId();
@@ -190,6 +200,25 @@ public class FinancingPaymentInfoServiceImpl extends ServiceImpl<FinancingPaymen
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void repayApplyAgainProcess() {
+        //获取所有类型为资方融资款 状态为处理中的现金流信息
+        List<CashFlowManageBasicInfo> cashFlowManageBasicInfoList = cashFlowManageBasicInfoService.lambdaQuery()
+                .eq(CashFlowManageBasicInfo::getCashType, CashFlowOutTypeDict.ChildEnum.MANAGEMENT_AMOUNT.getCode())
+                .eq(CashFlowManageBasicInfo::getCashStatus, 3).list();
+        if (CollectionUtil.isNotEmpty(cashFlowManageBasicInfoList)) {
+            for (CashFlowManageBasicInfo cashFlowManageBasicInfo : cashFlowManageBasicInfoList) {
+                //判断是否有出账记录
+                CashFlowManageOutInfo outInfo = cashFlowManageOutInfoService.lambdaQuery().eq(CashFlowManageOutInfo::getCashFlowManageBasicInfoId, cashFlowManageBasicInfo.getId()).one();
+                if (outInfo != null) {
+                    //有出账记录说明OA已审批结束,重新发起还款申请
+                    cashFlowManageBasicInfoService.repayApplyAgain(cashFlowManageBasicInfo.getId());
+                }
+            }
+        }
+    }
+
     /**
      * 修改资方还款信息
      *