Commit 22213142 authored by LSL's avatar LSL

浙农定时

parent 0b008f7c
......@@ -19,6 +19,7 @@ public class SnowSequenceHelper {
public final static String PRE_CREDIT_NO = "16750";
public final static String CREDIT_NO = "16760";
public final static String ACTION_NO = "0000";
public final static String REFUND_NO = "6403";
public final static String CREDIT_ACTION_NO = "1111";
private static SnowFlake instance = null;
......
......@@ -2,7 +2,9 @@ package com.jqtx.windows.component;
import com.jqtx.windows.component.model.RedeemModel;
import java.util.List;
public interface RedeemComponent {
void insert(RedeemModel model);
void insert(List<RedeemModel> model);
}
package com.jqtx.windows.component.impl;
import cn.hutool.extra.cglib.CglibUtil;
import com.jqtx.windows.component.BackedBurdenComponent;
import com.jqtx.windows.component.RedeemComponent;
import com.jqtx.windows.component.model.BurdenModel;
import com.jqtx.windows.component.model.RedeemModel;
import com.jqtx.windows.repository.entity.WindowsBurden;
import com.jqtx.windows.repository.entity.WindowsRedeem;
import com.jqtx.windows.repository.mapper.WindowsBurdenMapper;
import com.jqtx.windows.repository.mapper.WindowsRedeemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class RedeemComponentImpl implements RedeemComponent {
......@@ -19,8 +17,8 @@ public class RedeemComponentImpl implements RedeemComponent {
private WindowsRedeemMapper windowsRedeemMapper;
@Override
public void insert(RedeemModel model) {
windowsRedeemMapper.insert(CglibUtil.copy(model, WindowsRedeem.class));
public void insert(List<RedeemModel> models) {
models.stream().map(e -> windowsRedeemMapper.insert(CglibUtil.copy(e, WindowsRedeem.class)));
}
}
......@@ -5,15 +5,20 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.extra.ssh.Sftp;
import com.jqtx.infrastructure.oss.starter.config.OssUtils;
import com.jqtx.windows.common.config.snow.SnowSequenceHelper;
import com.jqtx.windows.component.impl.BackedBurdenComponentImpl;
import com.jqtx.windows.component.impl.LoanPlanComponentImpl;
import com.jqtx.windows.component.model.BurdenModel;
import com.jqtx.windows.component.model.LoanPlanModel;
import com.jqtx.windows.component.model.RepayModel;
import com.jqtx.windows.web.request.BackedRequest;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -41,7 +46,7 @@ public class BackedBurdenJob {
FileUtil.del("/sftp.txt");
String stringObject = ossUtils.getStringObject("ZN/assurance_/" + "assurance_" + date + ".txt");
log.info("date:{}", stringObject);
//存储并去平账
List<BurdenModel> getlist = getlist(stringObject);
for (BurdenModel model : getlist) {
backedBurdenComponent.insert(model);
......@@ -50,6 +55,11 @@ public class BackedBurdenJob {
}
/**
* 组装还融担的全部model
* @param jsonResult
* @return
*/
private List<BurdenModel> getlist(String jsonResult) {
ArrayList<BurdenModel> list = new ArrayList<>();
String[] split = jsonResult.split("\n");
......@@ -71,9 +81,51 @@ public class BackedBurdenJob {
return list;
}
/**
* 获取planNo
* @param loanNo
* @param planIndex
* @return
*/
private String getPlanNo(String loanNo,String planIndex){
LoanPlanModel planModel = loanPlanComponent.getPlanNoByLoan(loanNo, planIndex);
return planModel.getPlanNo();
}
/**
* 还融担
* @param model
*/
private void backedBurden(BurdenModel model){
//生成 windows_repay 信息
RepayModel repayModel = creditRepay(model);
//生成 windows_backed_detail 信息
//修改 windows_plan backAmt 信息
//修改 windows_plan 还款状态
//修改 windows_loan 还款状态
}
/**
* 生成 windows_repay
* @param model
* @return
*/
public RepayModel creditRepay(BurdenModel model) {
RepayModel windowsRepay = new RepayModel();
windowsRepay.setLoanNo(model.getLoanNo());
String refundNo = SnowSequenceHelper.nextSequence(SnowSequenceHelper.REFUND_NO);
windowsRepay.setBackedNo(refundNo);
windowsRepay.setBackedAmt(new BigDecimal(model.getPepayBurden()));
windowsRepay.setIsSettle(0);
windowsRepay.setBackedType("BURDEN");
windowsRepay.setRepayResult("SUCCESS");
windowsRepay.setRepayStatus("FINISHED");
windowsRepay.setCreator("浙农");
windowsRepay.setGmtCreated(LocalDateTime.now());
windowsRepay.setGmtModified(LocalDateTime.now());
return windowsRepay;
}
}
......@@ -5,13 +5,16 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.extra.ssh.Sftp;
import com.jqtx.infrastructure.oss.starter.config.OssUtils;
import com.jqtx.windows.component.RedeemComponent;
import com.jqtx.windows.component.model.RedeemModel;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
......@@ -19,16 +22,50 @@ public class RedeemJob {
@Autowired
private OssUtils ossUtils;
@Autowired
private RedeemComponent redeemComponent;
@XxlJob("redeemJob")
public void run() {
Sftp sftp = new Sftp("115.238.89.106", 9901, "xiaohua_fr", "R7MADMx1lwMN5k4v", CharsetUtil.CHARSET_UTF_8);
String date = DateUtil.format(new Date(), "yyyyMMdd");
sftp.cd("/download/compensatory/"+date);
sftp.get("compensatory_"+date+".txt","/compensatory_sftp.txt");
ossUtils.ossUpload("ZN/compensatory/"+"compensatory_"+date+".txt", FileUtil.file("/compensatory_sftp.txt"));
sftp.cd("/download/compensatory/" + date);
sftp.get("compensatory_" + date + ".txt", "/compensatory_sftp.txt");
ossUtils.ossUpload("ZN/compensatory/" + "compensatory_" + date + ".txt", FileUtil.file("/compensatory_sftp.txt"));
FileUtil.del("/sftp.txt");
String stringObject = ossUtils.getStringObject("ZN/compensatory/" + "compensatory_" + date + ".txt");
log.info("date:{}", stringObject);
redeemComponent.insert(getlist(stringObject));
}
/**
* 封装model
* @param jsonResult
* @return
*/
private List<RedeemModel> getlist(String jsonResult) {
ArrayList<RedeemModel> list = new ArrayList<>();
String[] split = jsonResult.split("\n");
if (split == null) {
return list;
}
for (String modelstr : split) {
String[] split1 = modelstr.split("\\|");
RedeemModel model = new RedeemModel();
model.setLoanNo(split1[0]);
model.setRedeemType(split1[1]);
model.setPlanIndex(split1[2]);
model.setRaiseTime(split1[3]);
model.setBackedTime(split1[4]);
model.setHoldDay(split1[5]);
model.setRedeemBen(split1[6]);
model.setRedeemXi(split1[7]);
model.setRedeemFa(split1[8]);
model.setRedeemAmount(split1[9]);
list.add(model);
}
return list;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment