|
|
@ -28,10 +28,16 @@ package com.yxt.anrui.riskcenter.biz.loanbepadsincereapply; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanbepadsincereapply.*; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanbepadsincereveh.LoanBePadsincereVehDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.RepaymentExcelInfo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanCreateScheduleVinsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentschedule.LoanRepaymentScheduleDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentschedule.LoanRepaymentScheduleService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -78,318 +84,343 @@ import java.util.regex.Pattern; |
|
|
|
@Service |
|
|
|
public class LoanBePadsincereApplyService extends MybatisBaseService<LoanBePadsincereApplyMapper, LoanBePadsincereApply> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private LoanRepaymentScheduleService loanRepaymentScheduleService; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private BusSalesOrderFeign busSalesOrderFeign; |
|
|
|
@Autowired |
|
|
|
private LoanRepaymentScheduleService loanRepaymentScheduleService; |
|
|
|
@Autowired |
|
|
|
private LoanRepaymentPlanDetailsService loanRepaymentPlanDetailsService; |
|
|
|
|
|
|
|
public PagerVo<LoanBePadsincereApplyVo> listPageVo(PagerQuery<LoanBePadsincereApplyQuery> pq) { |
|
|
|
LoanBePadsincereApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<LoanBePadsincereApply> qw = new QueryWrapper<>(); |
|
|
|
//========================================数据授权开始
|
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl())) { |
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setMenuSid(query.getMenuSid()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.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("orgPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())){ |
|
|
|
qw.like("useOrgName",query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())){ |
|
|
|
qw.like("createByName",query.getCreateByName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())){ |
|
|
|
qw.like("billNo",query.getBillNo()); |
|
|
|
} |
|
|
|
qw.apply(StringUtils.isNotBlank(query.getCreateStartTime()), "date_format (createTime,'%Y-%m-%d') >= date_format('" + query.getCreateStartTime() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(query.getCreateEndTime()), "date_format (createTime,'%Y-%m-%d') <= date_format('" + query.getCreateEndTime() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<LoanBePadsincereApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<LoanBePadsincereApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(LoanBePadsincereApplyDto dto){ |
|
|
|
public PagerVo<LoanBePadsincereApplyVo> listPageVo(PagerQuery<LoanBePadsincereApplyQuery> pq) { |
|
|
|
LoanBePadsincereApplyQuery query = pq.getParams(); |
|
|
|
QueryWrapper<LoanBePadsincereApply> qw = new QueryWrapper<>(); |
|
|
|
//========================================数据授权开始
|
|
|
|
if (StringUtils.isNotBlank(query.getMenuUrl())) { |
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(query.getOrgPath()); |
|
|
|
privilegeQuery.setMenuUrl(query.getMenuUrl()); |
|
|
|
privilegeQuery.setMenuSid(query.getMenuSid()); |
|
|
|
privilegeQuery.setUserSid(query.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = query.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("orgPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("orgPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("createBySid", query.getUserSid()); |
|
|
|
} else { |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} else { |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = new PagerVo<>(); |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getUseOrgName())) { |
|
|
|
qw.like("useOrgName", query.getUseOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateByName())) { |
|
|
|
qw.like("createByName", query.getCreateByName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBillNo())) { |
|
|
|
qw.like("billNo", query.getBillNo()); |
|
|
|
} |
|
|
|
qw.apply(StringUtils.isNotBlank(query.getCreateStartTime()), "date_format (createTime,'%Y-%m-%d') >= date_format('" + query.getCreateStartTime() + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotBlank(query.getCreateEndTime()), "date_format (createTime,'%Y-%m-%d') <= date_format('" + query.getCreateEndTime() + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
IPage<LoanBePadsincereApply> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<LoanBePadsincereApplyVo> pagging = baseMapper.selectPageVo(page, qw); |
|
|
|
PagerVo<LoanBePadsincereApplyVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public void saveOrUpdateDto(LoanBePadsincereApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
this.insertByDto(dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(LoanBePadsincereApplyDto dto){ |
|
|
|
LoanBePadsincereApply entity = new LoanBePadsincereApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(LoanBePadsincereApplyDto dto){ |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.updateByDto(dto); |
|
|
|
} |
|
|
|
|
|
|
|
public void insertByDto(LoanBePadsincereApplyDto dto) { |
|
|
|
LoanBePadsincereApply entity = new LoanBePadsincereApply(); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public void updateByDto(LoanBePadsincereApplyDto dto) { |
|
|
|
String dtoSid = dto.getSid(); |
|
|
|
if (StringUtils.isBlank(dtoSid)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
LoanBePadsincereApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public LoanBePadsincereApplyDetailsVo fetchDetailsVoBySid(String sid){ |
|
|
|
LoanBePadsincereApply entity = fetchBySid(sid); |
|
|
|
LoanBePadsincereApplyDetailsVo vo = new LoanBePadsincereApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
LoanBePadsincereApply entity = fetchBySid(dtoSid); |
|
|
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
|
|
|
baseMapper.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public LoanBePadsincereApplyDetailsVo fetchDetailsVoBySid(String sid) { |
|
|
|
LoanBePadsincereApply entity = fetchBySid(sid); |
|
|
|
LoanBePadsincereApplyDetailsVo vo = new LoanBePadsincereApplyDetailsVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<List<BePadsincereExcelInfo>> getExcelInfo(MultipartFile file, HttpServletRequest request) throws IOException { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String temp = request.getSession().getServletContext().getRealPath(File.separator) + "temp";// 临时目录
|
|
|
|
File tempFile = new File(temp); |
|
|
|
if (!tempFile.exists()) { |
|
|
|
tempFile.mkdirs(); |
|
|
|
} |
|
|
|
String fileName = file.getOriginalFilename(); |
|
|
|
if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { |
|
|
|
return rb.fail().setMsg("上传文件不正确"); |
|
|
|
} |
|
|
|
public ResultBean<List<LoanBePadsincereVehDetailsVo>> getExcelInfo(MultipartFile file, HttpServletRequest request) throws IOException { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String temp = request.getSession().getServletContext().getRealPath(File.separator) + "temp";// 临时目录
|
|
|
|
File tempFile = new File(temp); |
|
|
|
if (!tempFile.exists()) { |
|
|
|
tempFile.mkdirs(); |
|
|
|
} |
|
|
|
String fileName = file.getOriginalFilename(); |
|
|
|
if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { |
|
|
|
return rb.fail().setMsg("上传文件不正确"); |
|
|
|
} |
|
|
|
|
|
|
|
int[] resultCell = new int[]{0, 1, 2, 3, 4, 5, 6, 7}; |
|
|
|
List<BePadsincereExcelInfo> resultList = new ArrayList<>(); |
|
|
|
boolean isExcel2003 = true; |
|
|
|
if (fileName.matches("^.+\\.(?i)(xlsx)$")) { |
|
|
|
isExcel2003 = false; |
|
|
|
} |
|
|
|
InputStream is = file.getInputStream(); |
|
|
|
Workbook wb = null; |
|
|
|
if (isExcel2003) { |
|
|
|
wb = new HSSFWorkbook(is); |
|
|
|
} else { |
|
|
|
wb = new XSSFWorkbook(is); |
|
|
|
} |
|
|
|
Sheet sheet = wb.getSheetAt(0); |
|
|
|
ReturnExcelInfo importReturn = getSheetVal(sheet, resultCell); |
|
|
|
resultList = importReturn.getInfos(); |
|
|
|
System.out.println("结果是--->" + resultList); |
|
|
|
importReturn.setInfos(resultList); |
|
|
|
if (!resultList.isEmpty()) { |
|
|
|
if (StringUtils.isNotBlank(importReturn.getCheckInfo2())) { |
|
|
|
return rb.success().setData(resultList).setMsg(importReturn.getCheckInfo2()); |
|
|
|
} else { |
|
|
|
return rb.success().setData(resultList).setMsg("成功导入数据,请点击确定按钮"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String checkResult = importReturn.getCheckInfo(); |
|
|
|
return rb.success().setData(resultList).setMsg(checkResult); |
|
|
|
} |
|
|
|
} |
|
|
|
int[] resultCell = new int[]{0, 1, 2, 3, 4, 5, 6, 7}; |
|
|
|
List<BePadsincereExcelInfo> resultList = new ArrayList<>(); |
|
|
|
List<LoanBePadsincereVehDetailsVo> resultList2 = new ArrayList<>(); |
|
|
|
boolean isExcel2003 = true; |
|
|
|
if (fileName.matches("^.+\\.(?i)(xlsx)$")) { |
|
|
|
isExcel2003 = false; |
|
|
|
} |
|
|
|
InputStream is = file.getInputStream(); |
|
|
|
Workbook wb = null; |
|
|
|
if (isExcel2003) { |
|
|
|
wb = new HSSFWorkbook(is); |
|
|
|
} else { |
|
|
|
wb = new XSSFWorkbook(is); |
|
|
|
} |
|
|
|
Sheet sheet = wb.getSheetAt(0); |
|
|
|
ReturnExcelInfo importReturn = getSheetVal(sheet, resultCell); |
|
|
|
resultList = importReturn.getInfos(); |
|
|
|
for (BePadsincereExcelInfo bePadsincereExcelInfo : resultList) { |
|
|
|
List<LoanRepaymentScheduleDetailsVo> loanRepaymentScheduleDetailsVos = loanRepaymentScheduleService.selectByBankContractNo(bePadsincereExcelInfo.getBankContractNo()); |
|
|
|
for (LoanRepaymentScheduleDetailsVo loanRepaymentScheduleDetailsVo : loanRepaymentScheduleDetailsVos) { |
|
|
|
String vinNo = loanRepaymentScheduleDetailsVo.getVinNo(); |
|
|
|
String[] vinNos = vinNo.split(","); |
|
|
|
for (String no : vinNos) { |
|
|
|
LoanBePadsincereVehDetailsVo loanBePadsincereVehDetailsVo = new LoanBePadsincereVehDetailsVo(); |
|
|
|
loanBePadsincereVehDetailsVo.setVinNo(no); |
|
|
|
loanBePadsincereVehDetailsVo.setLoanContractNo(loanRepaymentScheduleDetailsVo.getLoanContractNo()); |
|
|
|
loanBePadsincereVehDetailsVo.setBankName(loanRepaymentScheduleDetailsVo.getBankName()); |
|
|
|
loanBePadsincereVehDetailsVo.setBankContractNo(bePadsincereExcelInfo.getBankContractNo()); |
|
|
|
BusSalesOrder busSalesOrder = busSalesOrderFeign.fetchBySid(loanRepaymentScheduleDetailsVo.getSalesOrderSid()).getData(); |
|
|
|
loanBePadsincereVehDetailsVo.setCustomerName(busSalesOrder.getCustomerName()); |
|
|
|
loanBePadsincereVehDetailsVo.setBorrowerName(loanRepaymentScheduleDetailsVo.getBorrowerName()); |
|
|
|
loanBePadsincereVehDetailsVo.setPeriod(bePadsincereExcelInfo.getPeriod()); |
|
|
|
String sysBeMoney = loanRepaymentPlanDetailsService.selBeMoney(no, bePadsincereExcelInfo.getPeriod(), bePadsincereExcelInfo.getBankContractNo()); |
|
|
|
loanBePadsincereVehDetailsVo.setSysBeMoney(sysBeMoney); |
|
|
|
loanBePadsincereVehDetailsVo.setBankBeMoney(bePadsincereExcelInfo.getBePrincipal()); |
|
|
|
loanBePadsincereVehDetailsVo.setBankBeInter(bePadsincereExcelInfo.getBeDefInter()); |
|
|
|
loanBePadsincereVehDetailsVo.setPaymentAccount(bePadsincereExcelInfo.getPaymentAccount()); |
|
|
|
loanBePadsincereVehDetailsVo.setPaymentNum(bePadsincereExcelInfo.getPaymentNum()); |
|
|
|
loanBePadsincereVehDetailsVo.setBankCollectionAcc(bePadsincereExcelInfo.getBankCollectionAcc()); |
|
|
|
loanBePadsincereVehDetailsVo.setBankCollectionNum(bePadsincereExcelInfo.getBankCollectionNum()); |
|
|
|
resultList2.add(loanBePadsincereVehDetailsVo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(importReturn.getCheckInfo2())) { |
|
|
|
return rb.success().setData(resultList2).setMsg(importReturn.getCheckInfo2()); |
|
|
|
} else { |
|
|
|
return rb.success().setData(resultList2).setMsg("成功导入数据,请点击确定按钮"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private ReturnExcelInfo getSheetVal(Sheet sheet, int[] resultCell) { |
|
|
|
ReturnExcelInfo importReturn = new ReturnExcelInfo(); |
|
|
|
List<BePadsincereExcelInfo> importVoList = new ArrayList<>(); |
|
|
|
int[] resultIndex = new int[resultCell.length]; |
|
|
|
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) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
BePadsincereExcelInfo importVo = new BePadsincereExcelInfo(); |
|
|
|
for (int i = 0; i < row.getPhysicalNumberOfCells(); i++) { |
|
|
|
String trim = new String(); |
|
|
|
try { |
|
|
|
trim = getCellVal(row.getCell(i)).toString().trim(); |
|
|
|
if (StringUtils.isBlank(trim)) { |
|
|
|
NullPointerException nullPointerException = new NullPointerException(); |
|
|
|
} |
|
|
|
String temp = getCellVal(row.getCell(i)).toString().trim(); |
|
|
|
for (int j = 0; j < resultCell.length; j++) { |
|
|
|
if (i == resultCell[j]) { |
|
|
|
switch (i) { |
|
|
|
case 0: |
|
|
|
importVo.setBankContractNo(temp); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
importVo.setPeriod(temp); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
importVo.setBePrincipal(temp); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
importVo.setBeDefInter(temp); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
importVo.setPaymentAccount(temp); |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
importVo.setPaymentNum(temp); |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
importVo.setBankCollectionAcc(temp); |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
importVo.setBankCollectionNum(temp); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
if (StringUtils.isBlank(trim)) { |
|
|
|
String word = new String(); |
|
|
|
switch (i) { |
|
|
|
case 0: |
|
|
|
word = "资方合同编号"; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
word = "期数"; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
word = "逾期本金"; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
word = "逾期罚息"; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
word = "付款账户"; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
word = "付款账号"; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
word = "资方收款账户"; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
word = "资方收款账号"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
importVoList.add(importVo); |
|
|
|
} |
|
|
|
StringBuffer sbBankCNo = new StringBuffer(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (!importVoList.isEmpty()) { |
|
|
|
for (BePadsincereExcelInfo excelInfo : importVoList) { |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankContractNo())){ |
|
|
|
checkWord.add("资方合同编号不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getPeriod())){ |
|
|
|
checkWord.add("期数不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBePrincipal())){ |
|
|
|
checkWord.add("逾期本金不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBeDefInter())){ |
|
|
|
checkWord.add("逾期罚息不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankCollectionAcc())){ |
|
|
|
checkWord.add("资方收款账户不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankCollectionNum())){ |
|
|
|
checkWord.add("资方收款账号不能为空"); |
|
|
|
} |
|
|
|
int i = loanRepaymentScheduleService.selectByBankContractNo(excelInfo.getBankContractNo()); |
|
|
|
if (i == 0){ |
|
|
|
checkWord.add("资方合同号" + excelInfo.getBankContractNo() + "在还款计划表中不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
|
} |
|
|
|
private ReturnExcelInfo getSheetVal(Sheet sheet, int[] resultCell) { |
|
|
|
ReturnExcelInfo importReturn = new ReturnExcelInfo(); |
|
|
|
List<BePadsincereExcelInfo> importVoList = new ArrayList<>(); |
|
|
|
int[] resultIndex = new int[resultCell.length]; |
|
|
|
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) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
BePadsincereExcelInfo importVo = new BePadsincereExcelInfo(); |
|
|
|
for (int i = 0; i < row.getPhysicalNumberOfCells(); i++) { |
|
|
|
String trim = new String(); |
|
|
|
try { |
|
|
|
trim = getCellVal(row.getCell(i)).toString().trim(); |
|
|
|
if (StringUtils.isBlank(trim)) { |
|
|
|
NullPointerException nullPointerException = new NullPointerException(); |
|
|
|
} |
|
|
|
String temp = getCellVal(row.getCell(i)).toString().trim(); |
|
|
|
for (int j = 0; j < resultCell.length; j++) { |
|
|
|
if (i == resultCell[j]) { |
|
|
|
switch (i) { |
|
|
|
case 0: |
|
|
|
importVo.setBankContractNo(temp); |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
importVo.setPeriod(temp); |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
importVo.setBePrincipal(temp); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
importVo.setBeDefInter(temp); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
importVo.setPaymentAccount(temp); |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
importVo.setPaymentNum(temp); |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
importVo.setBankCollectionAcc(temp); |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
importVo.setBankCollectionNum(temp); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
if (StringUtils.isBlank(trim)) { |
|
|
|
String word = new String(); |
|
|
|
switch (i) { |
|
|
|
case 0: |
|
|
|
word = "资方合同编号"; |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
word = "期数"; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
word = "逾期本金"; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
word = "逾期罚息"; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
word = "付款账户"; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
word = "付款账号"; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
word = "资方收款账户"; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
word = "资方收款账号"; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
importVoList.add(importVo); |
|
|
|
} |
|
|
|
StringBuffer sbBankCNo = new StringBuffer(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (!importVoList.isEmpty()) { |
|
|
|
for (BePadsincereExcelInfo excelInfo : importVoList) { |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankContractNo())) { |
|
|
|
checkWord.add("资方合同编号不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getPeriod())) { |
|
|
|
checkWord.add("期数不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBePrincipal())) { |
|
|
|
checkWord.add("逾期本金不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBeDefInter())) { |
|
|
|
checkWord.add("逾期罚息不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankCollectionAcc())) { |
|
|
|
checkWord.add("资方收款账户不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(excelInfo.getBankCollectionNum())) { |
|
|
|
checkWord.add("资方收款账号不能为空"); |
|
|
|
} |
|
|
|
List<LoanRepaymentScheduleDetailsVo> loanRepaymentScheduleDetailsVos = loanRepaymentScheduleService.selectByBankContractNo(excelInfo.getBankContractNo()); |
|
|
|
if (loanRepaymentScheduleDetailsVos == null || loanRepaymentScheduleDetailsVos.size() == 0) { |
|
|
|
checkWord.add("资方合同号" + excelInfo.getBankContractNo() + "在还款计划表中不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
public Object getCellVal(Cell cell) { |
|
|
|
Object obj = null; |
|
|
|
if (cell != null) { |
|
|
|
switch (cell.getCellTypeEnum()) { |
|
|
|
case BOOLEAN: |
|
|
|
obj = cell.getBooleanCellValue(); |
|
|
|
break; |
|
|
|
case ERROR: |
|
|
|
obj = cell.getErrorCellValue(); |
|
|
|
break; |
|
|
|
case NUMERIC: |
|
|
|
obj = cell.getNumericCellValue(); |
|
|
|
break; |
|
|
|
case STRING: |
|
|
|
obj = cell.getStringCellValue(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return obj; |
|
|
|
} |
|
|
|
public Object getCellVal(Cell cell) { |
|
|
|
Object obj = null; |
|
|
|
if (cell != null) { |
|
|
|
switch (cell.getCellTypeEnum()) { |
|
|
|
case BOOLEAN: |
|
|
|
obj = cell.getBooleanCellValue(); |
|
|
|
break; |
|
|
|
case ERROR: |
|
|
|
obj = cell.getErrorCellValue(); |
|
|
|
break; |
|
|
|
case NUMERIC: |
|
|
|
obj = cell.getNumericCellValue(); |
|
|
|
break; |
|
|
|
case STRING: |
|
|
|
obj = cell.getStringCellValue(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return obj; |
|
|
|
} |
|
|
|
} |