From aa9144b45d9bcd2973ee6db3d15c56ef0e83d3fc Mon Sep 17 00:00:00 2001 From: lousailong <804521647@qq.com> Date: Wed, 12 Mar 2025 10:42:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=A4=A9=E6=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jqtx/windows/component/LoanComponent.java | 7 +-- .../component/enums/RetryStateEnum.java | 40 +++++++++++++++++ .../component/enums/RetryTypeEnum.java | 38 ++++++++++++++++ .../component/impl/LoanComponentImpl.java | 11 +++++ .../com/jqtx/windows/job/SyncRetryJob.java | 45 ++++++++++++++++--- .../mapper/WindowsPublicMapper.java | 11 +++++ .../mybatis/mapper/WindowsPublicMapper.xml | 35 +++++++++++++++ 7 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/jqtx/windows/component/enums/RetryStateEnum.java create mode 100644 src/main/java/com/jqtx/windows/component/enums/RetryTypeEnum.java create mode 100644 src/main/java/com/jqtx/windows/repository/mapper/WindowsPublicMapper.java create mode 100644 src/main/resources/mybatis/mapper/WindowsPublicMapper.xml diff --git a/src/main/java/com/jqtx/windows/component/LoanComponent.java b/src/main/java/com/jqtx/windows/component/LoanComponent.java index 7c7cffa..0f5b9dc 100644 --- a/src/main/java/com/jqtx/windows/component/LoanComponent.java +++ b/src/main/java/com/jqtx/windows/component/LoanComponent.java @@ -1,9 +1,8 @@ package com.jqtx.windows.component; import com.jqtx.windows.component.model.LoanModel; -import com.jqtx.windows.repository.mapper.WindowsCreditMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; + +import java.util.List; public interface LoanComponent { @@ -16,4 +15,6 @@ public interface LoanComponent { LoanModel getByOrderNo(String orderNo); LoanModel getByOrderNoInit(String orderNo); + + List<String> getNotTsLoanModel(); } diff --git a/src/main/java/com/jqtx/windows/component/enums/RetryStateEnum.java b/src/main/java/com/jqtx/windows/component/enums/RetryStateEnum.java new file mode 100644 index 0000000..0d44612 --- /dev/null +++ b/src/main/java/com/jqtx/windows/component/enums/RetryStateEnum.java @@ -0,0 +1,40 @@ +package com.jqtx.windows.component.enums; + +/** + * @Author: wuwei + * @Date: 2019/12/04 13:40 + * 閲嶈瘯鎺ㄩ€佺被鍨� + */ +public enum RetryStateEnum { + + SUBMITED("SUBMITED", "寰呮帹閫�"), + + PUSH_SUCCESS("SUCCESS", "鎺ㄩ€佹垚鍔�"), + + PUSH_FAIL("FAIL", "鎺ㄩ€佸け璐�"); + + private String message; + + private String code; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + private RetryStateEnum(String code, String message) { + this.message = message; + this.code = code; + } +} diff --git a/src/main/java/com/jqtx/windows/component/enums/RetryTypeEnum.java b/src/main/java/com/jqtx/windows/component/enums/RetryTypeEnum.java new file mode 100644 index 0000000..6d1dc60 --- /dev/null +++ b/src/main/java/com/jqtx/windows/component/enums/RetryTypeEnum.java @@ -0,0 +1,38 @@ +package com.jqtx.windows.component.enums; + +/** + * @Author: wuwei + * @Date: 2019/12/04 13:40 + * 閲嶈瘯鎺ㄩ€佺被鍨� + */ +public enum RetryTypeEnum { + + RETRY_TYPE_BACK_LOAN("RETRY_TYPE_BACK_LOAN", "鍊熸鎺ㄩ€�"), + RETRY_TYPE_BACK_PLAN("RETRY_TYPE_BACK_PLAN", "杩樻璁″垝鎺ㄩ€�") + ; + + private String message; + + private String code; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + private RetryTypeEnum(String code, String message) { + this.message = message; + this.code = code; + } +} diff --git a/src/main/java/com/jqtx/windows/component/impl/LoanComponentImpl.java b/src/main/java/com/jqtx/windows/component/impl/LoanComponentImpl.java index 378707a..f7dec11 100644 --- a/src/main/java/com/jqtx/windows/component/impl/LoanComponentImpl.java +++ b/src/main/java/com/jqtx/windows/component/impl/LoanComponentImpl.java @@ -3,12 +3,15 @@ package com.jqtx.windows.component.impl; import cn.hutool.core.bean.BeanUtil; import com.jqtx.windows.component.LoanComponent; import com.jqtx.windows.component.model.LoanModel; +import com.jqtx.windows.component.model.LoanPlanModel; import com.jqtx.windows.repository.entity.WindowsLoan; import com.jqtx.windows.repository.entity.WindowsLoanExample; import com.jqtx.windows.repository.mapper.WindowsLoanMapper; +import com.jqtx.windows.repository.mapper.WindowsPublicMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; @Service @@ -17,6 +20,9 @@ public class LoanComponentImpl implements LoanComponent { @Autowired private WindowsLoanMapper windowsLoanMapper; + @Autowired + private WindowsPublicMapper windowsPublicMapper; + @Override public LoanModel getByLoanNo(String loanNo) { WindowsLoanExample example = new WindowsLoanExample(); @@ -63,4 +69,9 @@ public class LoanComponentImpl implements LoanComponent { List<WindowsLoan> windowsLoans = windowsLoanMapper.selectByExample(example); return windowsLoans.stream().map(m -> BeanUtil.toBean(m, LoanModel.class)).findFirst().orElse(null); } + + @Override + public List<String> getNotTsLoanModel() { + return windowsPublicMapper.getNotTsLoanModel(); + } } diff --git a/src/main/java/com/jqtx/windows/job/SyncRetryJob.java b/src/main/java/com/jqtx/windows/job/SyncRetryJob.java index dfb7ae2..3f9f2be 100644 --- a/src/main/java/com/jqtx/windows/job/SyncRetryJob.java +++ b/src/main/java/com/jqtx/windows/job/SyncRetryJob.java @@ -1,22 +1,27 @@ package com.jqtx.windows.job; -import com.alibaba.fastjson2.JSON; import com.jqtx.windows.component.LoanPlanComponent; import com.jqtx.windows.component.SyncBuildComponent; import com.jqtx.windows.component.config.Contant; import com.jqtx.windows.component.config.FeignUrlConfig; +import com.jqtx.windows.component.enums.RetryStateEnum; +import com.jqtx.windows.component.enums.RetryTypeEnum; +import com.jqtx.windows.component.impl.LoanComponentImpl; import com.jqtx.windows.component.model.LoanPlanModel; import com.jqtx.windows.component.tsmodel.AddCaseRequest; +import com.jqtx.windows.repository.entity.WindowsRetry; +import com.jqtx.windows.repository.mapper.WindowsRetryMapper; import com.jqtx.windows.service.SyncDataService; import com.jqtx.windows.web.response.JsonResult; import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.text.MessageFormat; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; @@ -37,6 +42,10 @@ public class SyncRetryJob { private LoanPlanComponent loanPlanComponent; @Autowired private SyncBuildComponent syncBuildComponent; + @Autowired + private LoanComponentImpl loanComponent; + @Autowired + private WindowsRetryMapper windowsRetryMapper; @XxlJob(value = "syncRetryJobHandler") private void process() { @@ -47,9 +56,14 @@ public class SyncRetryJob { log.info("浠诲姟寮€濮嬫椂闂�-[{}]", executeStartTime.format(formatter)); log.info("闇€瑕侀噸鏂版帹閫佹浠跺鐞嗗紑濮�..."); Long li1 = System.currentTimeMillis(); - List<LoanPlanModel> list = loanPlanComponent.getByLoan(param); - for (LoanPlanModel planModel : list) { - sendTs(syncBuildComponent.buildAddCaseRequest(planModel.getPlanNo())); + //鏌ヨ + if (StringUtils.isNotBlank(param)) { + sendTs(param); + } else { + List<String> loanModels = loanComponent.getNotTsLoanModel(); + for (String loanNo : loanModels) { + sendTs(loanNo); + } } Long li2 = System.currentTimeMillis(); log.info("浠诲姟缁撴潫鏃堕棿-[{}]锛屾墽琛�-[{}]", executeStartTime.format(formatter), li2 - li1); @@ -59,6 +73,26 @@ public class SyncRetryJob { log.info("闇€瑕侀噸鏂版帹閫佹浠跺鐞嗙粨鏉�..."); } + public void sendTs(String loanNo) { + List<LoanPlanModel> list = loanPlanComponent.getByLoan(loanNo); + for (LoanPlanModel planModel : list) { + Boolean planboolean = sendTs(syncBuildComponent.buildAddCaseRequest(planModel.getPlanNo())); + insertRetry(planModel.getPlanNo(), RetryTypeEnum.RETRY_TYPE_BACK_PLAN.getCode(),planboolean); + } + insertRetry(loanNo, RetryTypeEnum.RETRY_TYPE_BACK_LOAN.getCode(),true); + } + private void insertRetry(String bizCode,String bizType,Boolean bizState){ + WindowsRetry windowsRetry = new WindowsRetry(); + windowsRetry.setBizCode(bizCode); + windowsRetry.setBizType(bizType); + windowsRetry.setBizState(bizState ? RetryStateEnum.PUSH_SUCCESS.getCode() : RetryStateEnum.PUSH_FAIL.getCode()); + windowsRetry.setPushDate(LocalDate.now()); + LocalDateTime localDateTime = LocalDateTime.now(); + windowsRetry.setGmtCreated(localDateTime); + windowsRetry.setGmtModified(localDateTime); + windowsRetryMapper.insert(windowsRetry); + } + public Boolean sendTs(AddCaseRequest addCaseRequest) { String url = feignUrlConfig.getUrl() + Contant.REMIND_URL; String body = com.alibaba.fastjson.JSON.toJSONString(addCaseRequest); @@ -73,5 +107,4 @@ public class SyncRetryJob { } - } diff --git a/src/main/java/com/jqtx/windows/repository/mapper/WindowsPublicMapper.java b/src/main/java/com/jqtx/windows/repository/mapper/WindowsPublicMapper.java new file mode 100644 index 0000000..764fa44 --- /dev/null +++ b/src/main/java/com/jqtx/windows/repository/mapper/WindowsPublicMapper.java @@ -0,0 +1,11 @@ +package com.jqtx.windows.repository.mapper; + +import com.jqtx.windows.repository.entity.WindowsLoan; +import com.jqtx.windows.repository.entity.WindowsLoanExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface WindowsPublicMapper { + List<String> getNotTsLoanModel(); +} diff --git a/src/main/resources/mybatis/mapper/WindowsPublicMapper.xml b/src/main/resources/mybatis/mapper/WindowsPublicMapper.xml new file mode 100644 index 0000000..13b6e24 --- /dev/null +++ b/src/main/resources/mybatis/mapper/WindowsPublicMapper.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.jqtx.windows.repository.mapper.WindowsPublicMapper"> + <resultMap id="LoanModelResultMap" type="com.jqtx.windows.repository.entity.WindowsLoan"> + <id column="id" jdbcType="INTEGER" property="id" /> + <result column="loan_no" jdbcType="VARCHAR" property="loanNo" /> + <result column="order_no" jdbcType="VARCHAR" property="orderNo" /> + <result column="loan_amt" jdbcType="DECIMAL" property="loanAmt" /> + <result column="raise_amt" jdbcType="DECIMAL" property="raiseAmt" /> + <result column="service_amt" jdbcType="DECIMAL" property="serviceAmt" /> + <result column="rate_amt" jdbcType="DECIMAL" property="rateAmt" /> + <result column="burden_amt" jdbcType="DECIMAL" property="burdenAmt" /> + <result column="loan_usage" jdbcType="VARCHAR" property="loanUsage" /> + <result column="raise_date" jdbcType="TIMESTAMP" property="raiseDate" /> + <result column="loan_status" jdbcType="VARCHAR" property="loanStatus" /> + <result column="bank_account" jdbcType="VARCHAR" property="bankAccount" /> + <result column="loan_term" jdbcType="VARCHAR" property="loanTerm" /> + <result column="loan_credit_result" jdbcType="VARCHAR" property="loanCreditResult" /> + <result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" /> + <result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" /> + <result column="memo" jdbcType="VARCHAR" property="memo" /> + </resultMap> + + <select id="getNotTsLoanModel" resultType="java.lang.String"> + SELECT + wl.loan_no + FROM + windows_loan wl + LEFT JOIN + windows_retry wr + ON wl.loan_no = wr.biz_code + WHERE wr.id is NULL AND wl.loan_status = 'BACKING' LIMIT 100 + </select> + +</mapper> -- 2.18.1