From 2359a7bd49ba9c24ec31c01c87afb08471ba2597 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Thu, 4 Jul 2024 16:09:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9A=E6=97=B6=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?job=E6=9C=8D=E5=8A=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/invest/RemoteInvestProdService.java | 35 +++++++++++++++++ .../RemoteInvestProdFallbackFactory.java | 39 +++++++++++++++++++ .../core/constant/ServiceNameConstants.java | 5 +++ .../com/ruoyi/job/task/InvestProdJobTask.java | 34 ++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java create mode 100644 ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestProdFallbackFactory.java create mode 100644 ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java diff --git a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java new file mode 100644 index 0000000..f341991 --- /dev/null +++ b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java @@ -0,0 +1,35 @@ +package com.ruoyi.api.invest; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 基础服务 + * + * @author YaphetS + */ +@FeignClient(contextId = "remoteInvestProdService", value = ServiceNameConstants.INTC_INVEST_PROD, fallbackFactory = com.ruoyi.api.invest.factory.RemoteInvestProdFallbackFactory.class) +public interface RemoteInvestProdService +{ + /** + * 生成未出信用卡账单数据 + * + * @return 结果 + */ + @RequestMapping(value = "/job/generateUnpaidCreditBill",method = RequestMethod.POST) + public R generateUnpaidCreditBillTask(); + + /** + * 更新未出信用卡分期账单入账数据 + * + * @return 结果 + */ + @RequestMapping(value = "/job/updateUnpaidInstallmentData",method = RequestMethod.POST) + public R updateUnpaidInstallmentDataTask(); + + + +} diff --git a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestProdFallbackFactory.java b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestProdFallbackFactory.java new file mode 100644 index 0000000..27b356f --- /dev/null +++ b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestProdFallbackFactory.java @@ -0,0 +1,39 @@ +package com.ruoyi.api.invest.factory; + +import com.ruoyi.api.invest.RemoteInvestProdService; +import com.ruoyi.common.core.domain.R; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 用户服务降级处理 + * + * @author ruoyi + */ +@Component +public class RemoteInvestProdFallbackFactory implements FallbackFactory +{ + private static final Logger log = LoggerFactory.getLogger(RemoteInvestProdFallbackFactory.class); + + @Override + public RemoteInvestProdService create(Throwable throwable) + { + log.error("投资服务调用失败:{}", throwable.getMessage()); + return new RemoteInvestProdService() + { + + @Override + public R generateUnpaidCreditBillTask() { + return R.fail("投资服务调用生成未出信用卡账单数据失败"); + } + + @Override + public R updateUnpaidInstallmentDataTask() { + return R.fail("投资服务调用更新未出信用卡分期账单入账数据失败"); + } + + }; + } +} diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java index 072ce13..5ef62fe 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ServiceNameConstants.java @@ -60,4 +60,9 @@ public class ServiceNameConstants * INTC_INVEST的serviceId */ public static final String INTC_INVEST ="intc-invest"; + + /** + * INTC_INVEST_PROD的serviceId + */ + public static final String INTC_INVEST_PROD ="intc-invest-prod"; } diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java new file mode 100644 index 0000000..6c4779d --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java @@ -0,0 +1,34 @@ +package com.ruoyi.job.task; + +import com.ruoyi.api.invest.RemoteInvestProdService; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 照明平台定时任务 + * + * @author ruoyi + */ +@Component("investProdJobTask") +public class InvestProdJobTask +{ + @Autowired + private RemoteInvestProdService remoteInvestProdService; + + /**生成未出信用卡账单数据*/ + public void generateUnpaidCreditBillTask(){ + System.out.println("================================开始生成未出账单数据("+ DateUtils.getTime() +")================================="); + remoteInvestProdService.generateUnpaidCreditBillTask(); + System.out.println("================================结束生成未出账单据("+ DateUtils.getTime() +")================================="); + } + + /**未出信用卡分期账单入账数据*/ + public void updateUnpaidInstallmentDataTask(){ + System.out.println("================================开始更新未出信用卡分期账单入账数据("+ DateUtils.getTime() +")================================="); + remoteInvestProdService.updateUnpaidInstallmentDataTask(); + System.out.println("================================结束更新未出信用卡分期账单入账拟数据("+ DateUtils.getTime() +")================================="); + } + + +}