|
|
@ -2,14 +2,24 @@ package com.yxt.anrui.riskcenter.biz.loanrepaymenthistory; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportReturn; |
|
|
|
import com.yxt.anrui.base.api.basemodelmodprice.BaseModelModpriceImportVo; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameter; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterQuery; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanparameter.LoanParameterVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetailsDto; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
@ -31,6 +41,8 @@ import java.math.BigDecimal; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -43,6 +55,9 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LoanRepaymentPlanDetailsService loanRepaymentPlanDetailsService; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<String> saveHistory(LoanRepaymentHistoryDto dto) { |
|
|
|
ResultBean<String> rb = ResultBean.fireFail(); |
|
|
@ -62,9 +77,8 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
return baseMapper.selHistoryByPlanSid(planSid); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public ResultBean getExcelInfo(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
public ResultBean<List<RepaymentExcelInfo>> getExcelInfo(MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IOException, ParseException { |
|
|
|
ResultBean<List<RepaymentExcelInfo>> rb = ResultBean.fireFail(); |
|
|
|
String temp = request.getSession().getServletContext().getRealPath(File.separator) + "temp";// 临时目录
|
|
|
|
File tempFile = new File(temp); |
|
|
|
if (!tempFile.exists()) { |
|
|
@ -98,51 +112,24 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
StringBuffer checkBankNo = new StringBuffer(); |
|
|
|
if (!resultList.isEmpty()) { |
|
|
|
int size = resultList.size(); |
|
|
|
importReturn.setCheckInfo(currentTime + " " + "录入成功" + String.valueOf(size) + "条记录。"); |
|
|
|
//保存还款记录
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
for (RepaymentExcelInfo repaymentExcelInfo : resultList) { |
|
|
|
List<LoanRepaymentPlanDetails> planDetails = loanRepaymentPlanDetailsService.selPlanByNoAndPeriod(repaymentExcelInfo.getBankContractNo(), repaymentExcelInfo.getPeriod()); |
|
|
|
if (!planDetails.isEmpty()) { |
|
|
|
for (LoanRepaymentPlanDetails planDetail : planDetails) { |
|
|
|
LoanRepaymentHistory repaymentHistory = new LoanRepaymentHistory(); |
|
|
|
repaymentHistory.setBuckle("未申请"); |
|
|
|
repaymentHistory.setBuckleKey("001"); |
|
|
|
repaymentHistory.setScheduleSid(planDetail.getScheduleSid()); |
|
|
|
repaymentHistory.setPlanDetailSid(planDetail.getSid()); |
|
|
|
repaymentHistory.setActualDate(sdf.parse(repaymentExcelInfo.getRealReturnTime())); |
|
|
|
BigDecimal realMoney = new BigDecimal(repaymentExcelInfo.getRealMoney()); |
|
|
|
BigDecimal divide = realMoney.divide(new BigDecimal(planDetails.size()), 2, BigDecimal.ROUND_HALF_UP); |
|
|
|
repaymentHistory.setActualMoney(divide); |
|
|
|
repaymentHistory.setDataTime(new DateTime()); |
|
|
|
List<LoanRepaymentHistory> histories = baseMapper.selHistoryByPlanSid(planDetail.getSid()); |
|
|
|
BigDecimal returned = new BigDecimal(0); |
|
|
|
if (!histories.isEmpty()) { |
|
|
|
for (LoanRepaymentHistory history : histories) { |
|
|
|
returned = history.getActualMoney().add(returned); |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal decimal = returned.add(divide); |
|
|
|
BigDecimal dueMoney = planDetail.getDueMoney(); |
|
|
|
BigDecimal subtract = dueMoney.subtract(decimal); |
|
|
|
repaymentHistory.setOutstandingMoney(subtract); |
|
|
|
baseMapper.insert(repaymentHistory); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(importReturn.getCheckInfo2())) { |
|
|
|
return rb.success().setData(resultList).setMsg(importReturn.getCheckInfo2()); |
|
|
|
} else { |
|
|
|
return rb.success().setData(resultList).setMsg("成功导入" + size + "条数据,请点击确定按钮"); |
|
|
|
} |
|
|
|
|
|
|
|
return rb.success().setData(importReturn); |
|
|
|
} else { |
|
|
|
String checkResult = importReturn.getCheckInfo(); |
|
|
|
return rb.fail().setMsg(checkResult); |
|
|
|
return rb.success().setData(resultList).setMsg(checkResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ReturnExcelInfo getSheetVal(Sheet sheet, int[] resultCell) { |
|
|
|
ReturnExcelInfo importReturn = new ReturnExcelInfo(); |
|
|
|
List<RepaymentExcelInfo> importVoList = new ArrayList<>(); |
|
|
|
int[] resultIndex = new int[resultCell.length]; |
|
|
|
StringBuffer sb = new StringBuffer(); |
|
|
|
Set<String> checkWord = new HashSet<>(); |
|
|
|
Set<String> checkWord2 = new HashSet<>(); |
|
|
|
for (int r = 1; r <= sheet.getLastRowNum(); r++) { |
|
|
|
Row row = sheet.getRow(r); |
|
|
|
if (row == null) { |
|
|
@ -198,21 +185,96 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
String checkResult = "第" + (r + 1) + "行" + word + "为空"; |
|
|
|
sb.append(checkResult).append(";"); |
|
|
|
// String checkResult = "第" + (r + 1) + "行" + word + "为空";
|
|
|
|
// sb.append(checkResult).append(";");
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
importVoList.add(importVo); |
|
|
|
} |
|
|
|
importReturn.setInfos(importVoList); |
|
|
|
if (StringUtils.isNotBlank(sb.toString())) { |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
importReturn.setCheckInfo(sb.toString()); |
|
|
|
StringBuffer sbBankCNo = new StringBuffer(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (!importVoList.isEmpty()) { |
|
|
|
for (RepaymentExcelInfo excelInfo : importVoList) { |
|
|
|
if (StringUtils.isBlank(excelInfo.getRealReturnTime()) || |
|
|
|
StringUtils.isBlank(excelInfo.getPeriod()) || |
|
|
|
StringUtils.isBlank(excelInfo.getRealMoney()) || |
|
|
|
StringUtils.isBlank(excelInfo.getBankContractNo())) { |
|
|
|
checkWord.add("导入数据不可为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(excelInfo.getRealReturnTime())) { |
|
|
|
try { |
|
|
|
sdf.parse(excelInfo.getRealReturnTime()); |
|
|
|
} catch (ParseException e) { |
|
|
|
checkWord.add("请导入正确的日期格式,如:2023-01-01"); |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(excelInfo.getPeriod())) { |
|
|
|
if (!isNum(excelInfo.getPeriod())) { |
|
|
|
checkWord.add("期数必须为数字格式"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(excelInfo.getRealMoney())) { |
|
|
|
if (!isNum(excelInfo.getRealMoney())) { |
|
|
|
checkWord.add("实还金额必须为数字格式"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(excelInfo.getBankContractNo()) && StringUtils.isNotBlank(excelInfo.getPeriod())) { |
|
|
|
String bankContractNo = excelInfo.getBankContractNo(); |
|
|
|
String period = excelInfo.getPeriod(); |
|
|
|
List<LoanRepaymentPlanDetails> planDetails = loanRepaymentPlanDetailsService.selPlanByNoAndPeriod(bankContractNo, period); |
|
|
|
if (planDetails.isEmpty() || planDetails == null) { |
|
|
|
sbBankCNo.append(bankContractNo).append("、"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(excelInfo.getBankContractNo()) && StringUtils.isNotBlank(excelInfo.getRealReturnTime())) { |
|
|
|
String bankContractNo = excelInfo.getBankContractNo(); |
|
|
|
String realReturnTime = excelInfo.getRealReturnTime(); |
|
|
|
List<LoanRepaymentHistory> histories = baseMapper.selByBankNoAndActDate(bankContractNo, realReturnTime); |
|
|
|
if (!histories.isEmpty() || histories.size() > 0) { |
|
|
|
checkWord2.add("实还日期:" + realReturnTime + "、资方合同编号:" + bankContractNo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String bankCo = ""; |
|
|
|
if (sbBankCNo.length() > 0) { |
|
|
|
sbBankCNo.delete(sbBankCNo.length() - 1, sbBankCNo.length()); |
|
|
|
bankCo = "资方合同号" + sbBankCNo + "不存在"; |
|
|
|
} |
|
|
|
checkWord.add(bankCo); |
|
|
|
StringBuffer sbcheck1 = new StringBuffer(); |
|
|
|
if (!checkWord.isEmpty()) { |
|
|
|
for (String s : checkWord) { |
|
|
|
if (StringUtils.isBlank(s)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
sbcheck1.append(s).append(";"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (sbcheck1.length() > 0) { |
|
|
|
sbcheck1.delete(sbcheck1.length() - 1, sbcheck1.length()); |
|
|
|
importReturn.setCheckInfo(sbcheck1.toString()); |
|
|
|
importReturn.setInfos(new ArrayList<>()); |
|
|
|
return importReturn; |
|
|
|
} |
|
|
|
importReturn.setInfos(importVoList); |
|
|
|
StringBuffer sbcheck2 = new StringBuffer(); |
|
|
|
if (!checkWord2.isEmpty()) { |
|
|
|
for (String s : checkWord2) { |
|
|
|
if (StringUtils.isBlank(s)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
sbcheck2.append(s).append(","); |
|
|
|
} |
|
|
|
} |
|
|
|
if (sbcheck2.length() > 0) { |
|
|
|
sbcheck2.delete(sbcheck2.length() - 1, sbcheck2.length()); |
|
|
|
importReturn.setCheckInfo2("已存在" + sbcheck2.toString() + "的记录,是否继续导入"); |
|
|
|
return importReturn; |
|
|
|
} |
|
|
|
return importReturn; |
|
|
|
} |
|
|
|
|
|
|
@ -239,6 +301,42 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
return obj; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isNum(String s) { |
|
|
|
if (StringUtils.isNotBlank(s)) { |
|
|
|
if (s.contains(".")) { |
|
|
|
return isNumeric(s); |
|
|
|
} else { |
|
|
|
return isNumericFirst(s); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isNumeric(String s) { |
|
|
|
String substring = s.substring(0, s.lastIndexOf(".")); |
|
|
|
String substringLast = s.substring(s.lastIndexOf(".") + 1, s.length()); |
|
|
|
if (substring != null && !"".equals(substring.trim()) || substringLast != null && !"".equals(substringLast.trim())) { |
|
|
|
boolean matches = substring.matches("^[0-9]*$"); |
|
|
|
boolean b = substringLast.matches("^[0-9]*$"); |
|
|
|
if (matches && b) { |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
} else |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isNumericFirst(String str) { |
|
|
|
Pattern pattern = Pattern.compile("[0-9]*"); |
|
|
|
System.out.println(str); |
|
|
|
Matcher isNum = pattern.matcher(str); |
|
|
|
if (!isNum.matches()) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> updateRecord(LoanRepaymentHistoryUpdate dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = dto.getSid(); |
|
|
@ -276,4 +374,241 @@ public class LoanRepaymentHistoryService extends MybatisBaseService<LoanRepaymen |
|
|
|
LoanRepaymentHistoryUpdate vo = baseMapper.updateRecordInfo(sid); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
public PagerVo<LoanRepaymentHistoryVo> monthListPage(PagerQuery<LoanRepaymentHistoryQuery> pq) { |
|
|
|
IPage<LoanRepaymentHistory> page = PagerUtil.queryToPage(pq); |
|
|
|
LoanRepaymentHistoryQuery pagerQuery = pq.getParams(); |
|
|
|
QueryWrapper<LoanRepaymentHistory> qw = new QueryWrapper<>(); |
|
|
|
//=======================
|
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(pagerQuery.getOrgPath()); |
|
|
|
privilegeQuery.setMenuSid(pagerQuery.getMenuSid()); |
|
|
|
privilegeQuery.setMenuUrl(pagerQuery.getMenuUrl()); |
|
|
|
privilegeQuery.setUserSid(pagerQuery.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = pagerQuery.getOrgPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("p.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("p.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("p.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("p.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("p.salesUserSid", pagerQuery.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<LoanRepaymentHistoryVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<LoanRepaymentHistoryVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
//=======================
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) { |
|
|
|
qw.like("p.loanContractNo", pagerQuery.getLoanContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getVinNo())) { |
|
|
|
qw.like("p.vinNo", pagerQuery.getVinNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBankName())) { |
|
|
|
qw.like("p.bankName", pagerQuery.getBankName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBankContractNo())) { |
|
|
|
qw.like("p.bankContractNo", pagerQuery.getBankContractNo()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getCustomer())) { |
|
|
|
qw.like("p.customer", pagerQuery.getCustomer()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBorrowerName())) { |
|
|
|
qw.like("p.borrowerName", pagerQuery.getBorrowerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getPeriod())) { |
|
|
|
qw.like("p.period", pagerQuery.getPeriod()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getReturnWayKey())) { |
|
|
|
qw.eq("h.returnWayKey", pagerQuery.getReturnWayKey()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBuckleKey())) { |
|
|
|
qw.eq("h.buckleKey", pagerQuery.getBuckleKey()); |
|
|
|
} else { |
|
|
|
qw.ne("h.buckleKey", "002"); |
|
|
|
qw.ne("h.buckleKey", "003"); |
|
|
|
} |
|
|
|
String dueStartDate = pagerQuery.getDueStartDate(); |
|
|
|
String dueEndDate = pagerQuery.getDueEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(dueStartDate), "date_format (p.dueDate,'%Y-%m-%d') >= date_format('" + dueStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(dueEndDate), "date_format (p.dueDate,'%Y-%m-%d') <= date_format('" + dueEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
List<String> monthHeadAndLast = getMonthHeadAndLast(new Date()); |
|
|
|
String head = monthHeadAndLast.get(0); |
|
|
|
String last = monthHeadAndLast.get(1); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String actualStartDate = pagerQuery.getActualStartDate(); |
|
|
|
String actualEndDate = pagerQuery.getActualEndDate(); |
|
|
|
try { |
|
|
|
Date headT = sdf.parse(head); |
|
|
|
Date lastT = sdf.parse(last); |
|
|
|
Date ast = null; |
|
|
|
Date aed = null; |
|
|
|
if (StringUtils.isNotBlank(actualStartDate)) { |
|
|
|
ast = sdf.parse(actualStartDate); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(actualEndDate)) { |
|
|
|
aed = sdf.parse(actualEndDate); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(actualStartDate) && StringUtils.isNotBlank(actualEndDate)) { |
|
|
|
if (aed.before(lastT)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(actualEndDate), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + actualEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} else { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + last + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} |
|
|
|
} else if (StringUtils.isBlank(actualEndDate) && StringUtils.isNotBlank(actualStartDate)) { |
|
|
|
if (headT.before(ast)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(actualStartDate), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + actualStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + last + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} else { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + last + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} |
|
|
|
} else if (StringUtils.isNotBlank(actualStartDate) && StringUtils.isNotBlank(actualEndDate)) { |
|
|
|
if (headT.before(ast) && aed.before(lastT)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(actualStartDate), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + actualStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(actualEndDate), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + actualEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} else if (headT.before(ast) && !aed.before(lastT)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(actualStartDate), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + actualStartDate + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + lastT + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} else if (!headT.before(ast) && aed.before(lastT)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(actualEndDate), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + actualEndDate + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} else if (!headT.before(ast) && !aed.before(lastT)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + last + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
String dataStartTime = pagerQuery.getDataStartTime(); |
|
|
|
String dataEndTime = pagerQuery.getDataEndTime(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(dataStartTime), "date_format (h.dataTime,'%Y-%m-%d') >= date_format('" + dataStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(dataEndTime), "date_format (h.dataTime,'%Y-%m-%d') <= date_format('" + dataEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.orderByDesc("h.dataTime"); |
|
|
|
if (StringUtils.isBlank(actualStartDate) && StringUtils.isBlank(actualEndDate)) { |
|
|
|
qw.apply(StringUtils.isNotEmpty(head), "date_format (h.actualDate,'%Y-%m-%d') >= date_format('" + head + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(last), "date_format (h.actualDate,'%Y-%m-%d') <= date_format('" + last + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
} |
|
|
|
IPage<LoanRepaymentHistoryVo> pagging = baseMapper.monthListPage(page, qw); |
|
|
|
PagerVo<LoanRepaymentHistoryVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public List<String> getMonthHeadAndLast(Date date) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String now = sdf.format(date); |
|
|
|
String[] split = now.split("-"); |
|
|
|
String year = split[0]; |
|
|
|
String month = split[1]; |
|
|
|
String headDate = ""; |
|
|
|
String lastDate = ""; |
|
|
|
int y = Integer.parseInt(year); |
|
|
|
if (month.equals("01") || |
|
|
|
month.equals("03") || |
|
|
|
month.equals("05") || |
|
|
|
month.equals("07") || |
|
|
|
month.equals("08") || |
|
|
|
month.equals("10") || |
|
|
|
month.equals("12")) { |
|
|
|
headDate = year + "-" + month + "-01"; |
|
|
|
lastDate = year + "-" + month + "-31"; |
|
|
|
} else if (month.equals("04") || |
|
|
|
month.equals("06") || |
|
|
|
month.equals("09") || |
|
|
|
month.equals("11") |
|
|
|
) { |
|
|
|
headDate = year + "-" + month + "-01"; |
|
|
|
lastDate = year + "-" + month + "-30"; |
|
|
|
} else if (month.equals("02")) { |
|
|
|
headDate = year + "-" + month + "-01"; |
|
|
|
if ((y % 4) == 0) { |
|
|
|
lastDate = year + "-" + month + "-29"; |
|
|
|
} else { |
|
|
|
lastDate = year + "-" + month + "-28"; |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
list.add(headDate); |
|
|
|
list.add(lastDate); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<String> saveRecords(List<RepaymentExcelInfo> dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
//保存还款记录
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (!dto.isEmpty()) { |
|
|
|
for (RepaymentExcelInfo repaymentExcelInfo : dto) { |
|
|
|
List<LoanRepaymentPlanDetails> planDetails = loanRepaymentPlanDetailsService.selPlanByNoAndPeriod(repaymentExcelInfo.getBankContractNo(), repaymentExcelInfo.getPeriod()); |
|
|
|
if (!planDetails.isEmpty()) { |
|
|
|
for (LoanRepaymentPlanDetails planDetail : planDetails) { |
|
|
|
LoanRepaymentHistory repaymentHistory = new LoanRepaymentHistory(); |
|
|
|
repaymentHistory.setBuckle("未申请"); |
|
|
|
repaymentHistory.setBuckleKey("001"); |
|
|
|
repaymentHistory.setScheduleSid(planDetail.getScheduleSid()); |
|
|
|
repaymentHistory.setPlanDetailSid(planDetail.getSid()); |
|
|
|
try { |
|
|
|
repaymentHistory.setActualDate(sdf.parse(repaymentExcelInfo.getRealReturnTime())); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
BigDecimal realMoney = new BigDecimal(repaymentExcelInfo.getRealMoney()); |
|
|
|
BigDecimal divide = realMoney.divide(new BigDecimal(planDetails.size()), 2, BigDecimal.ROUND_HALF_UP); |
|
|
|
repaymentHistory.setActualMoney(divide); |
|
|
|
repaymentHistory.setDataTime(new DateTime()); |
|
|
|
List<LoanRepaymentHistory> histories = baseMapper.selHistoryByPlanSid(planDetail.getSid()); |
|
|
|
BigDecimal returned = new BigDecimal(0); |
|
|
|
if (!histories.isEmpty()) { |
|
|
|
for (LoanRepaymentHistory history : histories) { |
|
|
|
returned = history.getActualMoney().add(returned); |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal decimal = returned.add(divide); |
|
|
|
BigDecimal dueMoney = planDetail.getDueMoney(); |
|
|
|
BigDecimal subtract = dueMoney.subtract(decimal); |
|
|
|
repaymentHistory.setOutstandingMoney(subtract); |
|
|
|
baseMapper.insert(repaymentHistory); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
} |
|
|
|