Commit 58259cdf authored by 张庆's avatar 张庆

新增挡板规则

parent 13b4d91f
package com.jqtx.windows.component.model;
import lombok.Data;
@Data
public class FaModel {
private String loanReqNo;
private String term;
private String dateDue;
private String totalAmt;
private String prinAmt;
private String intAmt;
private String ointAmt;
}
package com.jqtx.windows.job;
import cn.hutool.core.date.DateUtil;
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.SftpConfig;
import com.jqtx.windows.common.config.snow.SnowSequenceHelper;
import com.jqtx.windows.component.*;
import com.jqtx.windows.component.enums.LoanStatusEnum;
import com.jqtx.windows.component.impl.BackedBurdenComponentImpl;
import com.jqtx.windows.component.model.*;
import com.jqtx.windows.infrastructure.feign.enums.DebtInfoStatusEnum;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
public class SyncFaJob {
@Autowired
private OssUtils ossUtils;
@Autowired
private LoanPlanComponent loanPlanComponent;
@Autowired
private SftpConfig sftpConfig;
@XxlJob("SyncFaJob")
public void run() {
String param = XxlJobHelper.getJobParam();
Sftp sftp = new Sftp(sftpConfig.getSshHost(), sftpConfig.getSshPort(), sftpConfig.getSshUser(), sftpConfig.getSshPass(), CharsetUtil.CHARSET_UTF_8);
try {
String date = "";
if (StringUtils.isNotEmpty(param)) {
date = param;
} else {
Calendar cal = Calendar.getInstance();
//获取前面的时间用-负号
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, -1);
Date time = cal.getTime();
date = DateUtil.format(time, "yyyyMMdd");
}
if (sftp.isDir("/download/overdue/" + date)) {
sftp.cd("/download/overdue/" + date + "/capital");
sftp.get("overdue_capital" + date + ".txt", "overdue_capital" + date + ".txt");
ossUtils.ossUpload("ZN/overdue/" + date + ".txt", FileUtil.file("overdue_capital" + date + ".txt"));
String stringObject = getStringObject("ZN/overdue/" + date + ".txt");
log.info("oss逾期数据:{}", stringObject);
//存储并去平账
List<FaModel> getlist = getlist(stringObject);
for (FaModel faModel : getlist) {
//查询plan
LoanPlanModel planModel = loanPlanComponent.getPlanNoByLoan(faModel.getLoanReqNo(), faModel.getTerm());
planModel.setPlanFa(new BigDecimal(faModel.getOintAmt()));
loanPlanComponent.updateByLoanPlanModel(planModel);
}
FileUtil.del("/assurance_sftp.txt");
} else {
log.info("浙农逾期文件不存在:{}", date);
}
} catch (Exception e) {
log.info("浙农逾期错误:{}", e.getMessage());
} finally {
//关闭sftp连接
sftp.close();
}
}
public String getStringObject(String uri) {
byte[] bytes = new byte[0];
try {
bytes = ossUtils.ossDownLoad(uri);
} catch (IOException e) {
e.printStackTrace();
}
return new String(bytes);
}
/**
* 组装还融担的全部model
*
* @param jsonResult
* @return
*/
private List<FaModel> getlist(String jsonResult) {
ArrayList<FaModel> list = new ArrayList<>();
String[] split = jsonResult.split("\n");
if (split == null) {
return list;
}
for (String modelstr : split) {
String[] split1 = modelstr.split("\\|");
FaModel model = new FaModel();
model.setLoanReqNo(split1[0]);
model.setTerm(split1[1]);
model.setDateDue(split1[2]);
model.setTotalAmt(split1[3]);
model.setPrinAmt(split1[4]);
model.setIntAmt(split1[5]);
model.setOintAmt(split1[6]);
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