|
|
@ -1,11 +1,43 @@ |
|
|
|
package com.daqing.financial.guarantee.service.impl; |
|
|
|
package com.daqing.financial.guarantee.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.daqing.financial.guarantee.feign.HrmsFeignService; |
|
|
|
import com.daqing.financial.guarantee.mapper.AlCollectionMapper; |
|
|
|
import com.daqing.financial.guarantee.mapper.AlCollectionMapper; |
|
|
|
|
|
|
|
import com.daqing.financial.guarantee.mapper.AlRepaymentEntryMapper; |
|
|
|
|
|
|
|
import com.daqing.financial.guarantee.model.request.AlCollectionListRequest; |
|
|
|
|
|
|
|
import com.daqing.financial.guarantee.model.request.AlCollectionRequest; |
|
|
|
|
|
|
|
import com.daqing.financial.guarantee.model.response.*; |
|
|
|
import com.daqing.financial.guarantee.service.IAlCollectionService; |
|
|
|
import com.daqing.financial.guarantee.service.IAlCollectionService; |
|
|
|
|
|
|
|
import com.daqing.framework.domain.crms.response.CrmsCode; |
|
|
|
import com.daqing.framework.domain.guarantee.AlCollection; |
|
|
|
import com.daqing.framework.domain.guarantee.AlCollection; |
|
|
|
|
|
|
|
import com.daqing.framework.domain.guarantee.AlRepaymentEntry; |
|
|
|
|
|
|
|
import com.daqing.framework.domain.guarantee.po.AlCollectionListPO; |
|
|
|
|
|
|
|
import com.daqing.framework.domain.guarantee.po.AlCollectionPO; |
|
|
|
|
|
|
|
import com.daqing.framework.domain.hrms.ext.EmployeeVO; |
|
|
|
|
|
|
|
import com.daqing.framework.exception.ExceptionCast; |
|
|
|
|
|
|
|
import com.daqing.framework.model.response.CommonCode; |
|
|
|
|
|
|
|
import com.daqing.framework.model.response.ResponseResult; |
|
|
|
|
|
|
|
import com.daqing.framework.util.RedisUtil; |
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
import com.daqing.framework.utils.PageUtils; |
|
|
|
|
|
|
|
import com.daqing.framework.utils.excel.ExcelUtil; |
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
@ -18,17 +50,323 @@ import org.springframework.stereotype.Service; |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class AlCollectionServiceImpl extends ServiceImpl<AlCollectionMapper, AlCollection> implements IAlCollectionService { |
|
|
|
public class AlCollectionServiceImpl extends ServiceImpl<AlCollectionMapper, AlCollection> implements IAlCollectionService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private AlRepaymentEntryMapper alRepaymentEntryMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private HrmsFeignService hrmsFeignService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 催收管理列表 |
|
|
|
* 催收管理列表 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param codeOrName 客户编号或者名称 |
|
|
|
* @param codeOrName 客户编号或者名称 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PageUtils list(Integer page, Integer size, String codeOrName) { |
|
|
|
public PageUtils list(Integer page, Integer size, String codeOrName, Integer status) { |
|
|
|
if (page == null || size == null) { |
|
|
|
if (page == null || page < 0 || size == null || size < 0) { |
|
|
|
page = 1; |
|
|
|
page = 1; |
|
|
|
size = 10; |
|
|
|
size = 10; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
// 曾经逾期过的记录
|
|
|
|
|
|
|
|
IPage<AlCollectionPO> alCollectionList = this.getBaseMapper().list(new Page(page, size), codeOrName, status); |
|
|
|
|
|
|
|
// 复制分页信息
|
|
|
|
|
|
|
|
IPage<AlCollectionResponse> response = new Page<>(); |
|
|
|
|
|
|
|
BeanUtils.copyProperties(alCollectionList, response); |
|
|
|
|
|
|
|
// 返回数据集合
|
|
|
|
|
|
|
|
List<AlCollectionResponse> alCollectionResponsesList = new ArrayList<>(); |
|
|
|
|
|
|
|
// 还款记录信息
|
|
|
|
|
|
|
|
List<AlRepaymentEntry> alRepaymentList = alRepaymentEntryMapper.listAlRepayment(); |
|
|
|
|
|
|
|
// 拼装信息
|
|
|
|
|
|
|
|
List<AlCollectionPO> records = alCollectionList.getRecords(); |
|
|
|
|
|
|
|
for (AlCollectionPO record : records) { |
|
|
|
|
|
|
|
AlCollectionResponse alCollectionResponse = new AlCollectionResponse(); |
|
|
|
|
|
|
|
// 逾期次数
|
|
|
|
|
|
|
|
Integer overduePeriods = 0; |
|
|
|
|
|
|
|
// 逾期额度
|
|
|
|
|
|
|
|
BigDecimal overdueAmount = new BigDecimal(0.00); |
|
|
|
|
|
|
|
// 逾期利息
|
|
|
|
|
|
|
|
BigDecimal overdueInterest = new BigDecimal(0.00); |
|
|
|
|
|
|
|
for (AlRepaymentEntry repayment : alRepaymentList) { |
|
|
|
|
|
|
|
if (record.getId().equals(repayment.getInsuranceId())) { |
|
|
|
|
|
|
|
overdueAmount = overdueAmount.add(repayment.getCurrentRepayment()); |
|
|
|
|
|
|
|
overdueInterest = overdueInterest.add(repayment.getInterest()); |
|
|
|
|
|
|
|
overduePeriods++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(record, alCollectionResponse); |
|
|
|
|
|
|
|
alCollectionResponse.setOverdueAmount(overdueAmount); |
|
|
|
|
|
|
|
alCollectionResponse.setOverdueInterest(overdueInterest); |
|
|
|
|
|
|
|
alCollectionResponse.setOverduePeriods(overduePeriods); |
|
|
|
|
|
|
|
alCollectionResponsesList.add(alCollectionResponse); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
response.setRecords(alCollectionResponsesList); |
|
|
|
|
|
|
|
return new PageUtils(response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 催收 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Boolean collection(AlCollectionRequest alCollectionRequest) { |
|
|
|
|
|
|
|
if (alCollectionRequest.getInsuranceId() == null) { |
|
|
|
|
|
|
|
ExceptionCast.cast(CommonCode.INVALID_PARAM); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
AlCollection alCollection = new AlCollection(); |
|
|
|
|
|
|
|
BeanUtils.copyProperties(alCollectionRequest, alCollection); |
|
|
|
|
|
|
|
// 当前记录逾期额度、逾期利息、其他费用、逾期次数
|
|
|
|
|
|
|
|
Map<String, Object> map = this.getOverdueConditionByInsuranceId(alCollectionRequest.getInsuranceId()); |
|
|
|
|
|
|
|
alCollection.setOverdueAmount((BigDecimal) map.get("overdueAmount")); |
|
|
|
|
|
|
|
alCollection.setOverdueInterest((BigDecimal) map.get("overdueInterest")); |
|
|
|
|
|
|
|
alCollection.setOtherExpenses((BigDecimal) map.get("otherExpenses")); |
|
|
|
|
|
|
|
alCollection.setOverduePeriods((Integer) map.get("overduePeriods")); |
|
|
|
|
|
|
|
// 当前催收用户
|
|
|
|
|
|
|
|
alCollection.setCollectionUser(Integer.parseInt(this.getUserId())); |
|
|
|
|
|
|
|
// alCollection.setCollectionUser(2);
|
|
|
|
|
|
|
|
return this.getBaseMapper().collection(alCollection); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 催收详情 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param insuranceId 保后id |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public OverdueDetailResponse overdueDetail(Integer insuranceId) { |
|
|
|
|
|
|
|
if (insuranceId == null) { |
|
|
|
|
|
|
|
ExceptionCast.cast(CommonCode.INVALID_PARAM); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
OverdueDetailResponse overdueDetailResponse = this.getBaseMapper().getOverdueDetailByInsuranceId(insuranceId); |
|
|
|
|
|
|
|
// 逾期金额、逾期利息、其他费用、逾期次数
|
|
|
|
|
|
|
|
Map<String, Object> map = this.getOverdueConditionByInsuranceId(insuranceId); |
|
|
|
|
|
|
|
overdueDetailResponse.setOverdueAmount((BigDecimal) map.get("overdueAmount")); |
|
|
|
|
|
|
|
overdueDetailResponse.setOverdueInterest((BigDecimal) map.get("overdueInterest")); |
|
|
|
|
|
|
|
overdueDetailResponse.setOtherExpenses((BigDecimal) map.get("otherExpenses")); |
|
|
|
|
|
|
|
overdueDetailResponse.setOverduePeriods((Integer) map.get("overduePeriods")); |
|
|
|
|
|
|
|
// 还款记录
|
|
|
|
|
|
|
|
IPage<AlRepaymentEntryListRes> iPage = alRepaymentEntryMapper.pageByCondition(new Page(), null, null, insuranceId); |
|
|
|
|
|
|
|
overdueDetailResponse.setAlRepaymentEntryList(iPage.getRecords()); |
|
|
|
|
|
|
|
return overdueDetailResponse; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 催收列表 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public PageUtils collectionList(AlCollectionListRequest alCollectionListRequest) { |
|
|
|
|
|
|
|
if (alCollectionListRequest.getInsuranceId() == null) { |
|
|
|
|
|
|
|
ExceptionCast.cast(CommonCode.INVALID_PARAM); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 分页参数
|
|
|
|
|
|
|
|
if (alCollectionListRequest.getPage() == null |
|
|
|
|
|
|
|
|| alCollectionListRequest.getPage() < 0 |
|
|
|
|
|
|
|
|| alCollectionListRequest.getSize() == null |
|
|
|
|
|
|
|
|| alCollectionListRequest.getSize() < 0) { |
|
|
|
|
|
|
|
alCollectionListRequest.setPage(1); |
|
|
|
|
|
|
|
alCollectionListRequest.setSize(10); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 催收列表基本信息
|
|
|
|
|
|
|
|
IPage<AlCollectionListPO> alCollectionListPO = this.getBaseMapper().collectionList(new Page(alCollectionListRequest.getPage(), alCollectionListRequest.getSize()), |
|
|
|
|
|
|
|
alCollectionListRequest); |
|
|
|
|
|
|
|
// 创建返回分页类
|
|
|
|
|
|
|
|
Page<AlCollectionListResponse> iPage = new Page<>(); |
|
|
|
|
|
|
|
// 获取所有的用户id并远程转换成名称
|
|
|
|
|
|
|
|
if (alCollectionListPO.getRecords() != null && alCollectionListPO.getRecords().size() != 0) { |
|
|
|
|
|
|
|
Integer[] userIds = new Integer[alCollectionListPO.getRecords().size()]; |
|
|
|
|
|
|
|
for (int i = 0; i < userIds.length; i++) { |
|
|
|
|
|
|
|
userIds[i] = alCollectionListPO.getRecords().get(i).getCollectionUser(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ResponseResult<List<EmployeeVO>> result = hrmsFeignService.listEmpNameByUserId(userIds); |
|
|
|
|
|
|
|
// 复制分页信息、拼装信息并返回
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(alCollectionListPO, iPage); |
|
|
|
|
|
|
|
if (result.getData() != null && result.getData().size() != 0) { |
|
|
|
|
|
|
|
List<AlCollectionListResponse> response = this.jointName(alCollectionListPO.getRecords(), result.getData()); |
|
|
|
|
|
|
|
iPage.setRecords(response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new PageUtils(iPage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查看时的催收详情 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public MoreOverdueDetailResponse moreOverdueDetail(Integer id) { |
|
|
|
|
|
|
|
if (id == null) { |
|
|
|
|
|
|
|
ExceptionCast.cast(CommonCode.INVALID_PARAM); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 催收时间、类型、反馈、附件等
|
|
|
|
|
|
|
|
MoreOverdueDetailResponse moreOverdueDetailResponse = this.getBaseMapper().moreOverdueDetail(id); |
|
|
|
|
|
|
|
OverdueDetailResponse overdueDetailResponse = overdueDetail(this.getBaseMapper().getInsuranceIdById(id)); |
|
|
|
|
|
|
|
// 客户编号、姓名、类型、逾期、还款记录等
|
|
|
|
|
|
|
|
moreOverdueDetailResponse.setCode(overdueDetailResponse.getCode()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setName(overdueDetailResponse.getName()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setType(overdueDetailResponse.getType()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setOverdueAmount(overdueDetailResponse.getOverdueAmount()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setOverdueInterest(overdueDetailResponse.getOverdueInterest()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setOtherExpenses(overdueDetailResponse.getOtherExpenses()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setOverduePeriods(overdueDetailResponse.getOverduePeriods()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setNumberOfCollection(overdueDetailResponse.getNumberOfCollection()); |
|
|
|
|
|
|
|
moreOverdueDetailResponse.setAlRepaymentEntryList(overdueDetailResponse.getAlRepaymentEntryList()); |
|
|
|
|
|
|
|
return moreOverdueDetailResponse; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 催收管理列表导出 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param insuranceIds 保后id集合 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void listExportExcel(List<Integer> insuranceIds, HttpServletResponse response) throws IOException { |
|
|
|
|
|
|
|
IPage<AlCollectionPO> alCollectionList = this.getBaseMapper().list(new Page(), null, null); |
|
|
|
|
|
|
|
// 返回数据集合
|
|
|
|
|
|
|
|
List<AlCollectionResponse> alCollectionResponsesList = new ArrayList<>(); |
|
|
|
|
|
|
|
// 还款记录信息
|
|
|
|
|
|
|
|
List<AlRepaymentEntry> alRepaymentList = alRepaymentEntryMapper.listAlRepayment(); |
|
|
|
|
|
|
|
// 拼装信息
|
|
|
|
|
|
|
|
List<AlCollectionPO> records = alCollectionList.getRecords(); |
|
|
|
|
|
|
|
for (AlCollectionPO record : records) { |
|
|
|
|
|
|
|
AlCollectionResponse alCollectionResponse = new AlCollectionResponse(); |
|
|
|
|
|
|
|
// 逾期次数
|
|
|
|
|
|
|
|
Integer overduePeriods = 0; |
|
|
|
|
|
|
|
// 逾期额度
|
|
|
|
|
|
|
|
BigDecimal overdueAmount = new BigDecimal(0.00); |
|
|
|
|
|
|
|
// 逾期利息
|
|
|
|
|
|
|
|
BigDecimal overdueInterest = new BigDecimal(0.00); |
|
|
|
|
|
|
|
for (AlRepaymentEntry repayment : alRepaymentList) { |
|
|
|
|
|
|
|
if (record.getId().equals(repayment.getInsuranceId())) { |
|
|
|
|
|
|
|
overdueAmount = overdueAmount.add(repayment.getCurrentRepayment()); |
|
|
|
|
|
|
|
overdueInterest = overdueInterest.add(repayment.getInterest()); |
|
|
|
|
|
|
|
overduePeriods++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(record, alCollectionResponse); |
|
|
|
|
|
|
|
alCollectionResponse.setOverdueAmount(overdueAmount); |
|
|
|
|
|
|
|
alCollectionResponse.setOverdueInterest(overdueInterest); |
|
|
|
|
|
|
|
alCollectionResponse.setOverduePeriods(overduePeriods); |
|
|
|
|
|
|
|
alCollectionResponsesList.add(alCollectionResponse); |
|
|
|
|
|
|
|
Iterator<AlCollectionResponse> iterator = alCollectionResponsesList.iterator(); |
|
|
|
|
|
|
|
// 迭代器遍历,删除不需要的数据
|
|
|
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
|
|
boolean flag = false; |
|
|
|
|
|
|
|
// Iterator类的next( )方法在同一循环中不能出现两次,会导致最后一次的游标指向空值
|
|
|
|
|
|
|
|
AlCollectionResponse next = iterator.next(); |
|
|
|
|
|
|
|
for (Integer insuranceId : insuranceIds) { |
|
|
|
|
|
|
|
if (null != next.getId() && next.getId().equals(insuranceId)) { |
|
|
|
|
|
|
|
flag = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!flag) { |
|
|
|
|
|
|
|
iterator.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
|
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyExcel没有关系
|
|
|
|
|
|
|
|
String fileName = URLEncoder.encode("催收管理列表数据一览表", "UTF-8").replaceAll("\\+", "%20"); |
|
|
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(0, "template").head(AlCollectionResponse.class).build(); |
|
|
|
|
|
|
|
excelWriter.write(alCollectionResponsesList, writeSheet); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
if (excelWriter != null) { |
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 催收列表导出 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param ids 催收id集合 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void collectionListExportExcel(List<Integer> ids, HttpServletResponse response) throws IOException { |
|
|
|
|
|
|
|
// 导出的数据集合
|
|
|
|
|
|
|
|
List<AlCollectionListResponse> list = new ArrayList<>(); |
|
|
|
|
|
|
|
// 根据id查询出数据
|
|
|
|
|
|
|
|
List<AlCollectionListPO> alCollectionListPOS = this.getBaseMapper().collectionListExcel(ids); |
|
|
|
|
|
|
|
if (alCollectionListPOS != null && alCollectionListPOS.size() != 0) { |
|
|
|
|
|
|
|
Integer[] userIds = new Integer[alCollectionListPOS.size()]; |
|
|
|
|
|
|
|
for (int i = 0; i < userIds.length; i++) { |
|
|
|
|
|
|
|
userIds[i] = alCollectionListPOS.get(i).getCollectionUser(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 根据用户id查询用户姓名
|
|
|
|
|
|
|
|
ResponseResult<List<EmployeeVO>> result = hrmsFeignService.listEmpNameByUserId(userIds); |
|
|
|
|
|
|
|
if (result.getData() != null && result.getData().size() != 0) { |
|
|
|
|
|
|
|
// 转换用户id为姓名
|
|
|
|
|
|
|
|
list = this.jointName(alCollectionListPOS, result.getData()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
|
|
|
|
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
|
|
|
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyExcel没有关系
|
|
|
|
|
|
|
|
String fileName = URLEncoder.encode("催收列表数据一览表", "UTF-8").replaceAll("\\+", "%20"); |
|
|
|
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet(0, "template").head(AlCollectionListResponse.class).build(); |
|
|
|
|
|
|
|
excelWriter.write(list, writeSheet); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
if (excelWriter != null) { |
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> getOverdueConditionByInsuranceId(Integer insuranceId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<AlRepaymentEntry> alRepaymentList = alRepaymentEntryMapper.listAlRepaymentByInsuranceId(insuranceId); |
|
|
|
|
|
|
|
// 逾期金额
|
|
|
|
|
|
|
|
BigDecimal overdueAmount = new BigDecimal(0.00); |
|
|
|
|
|
|
|
// 逾期利息
|
|
|
|
|
|
|
|
BigDecimal overdueInterest = new BigDecimal(0.00); |
|
|
|
|
|
|
|
// 其他费用
|
|
|
|
|
|
|
|
BigDecimal otherExpenses = new BigDecimal(0.00); |
|
|
|
|
|
|
|
for (AlRepaymentEntry alRepayment : alRepaymentList) { |
|
|
|
|
|
|
|
overdueAmount = overdueAmount.add(alRepayment.getCurrentRepayment()); |
|
|
|
|
|
|
|
overdueInterest = overdueInterest.add(alRepayment.getInterest()); |
|
|
|
|
|
|
|
otherExpenses = otherExpenses.add(alRepayment.getOtherExpenses()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("overduePeriods", alRepaymentList.size()); |
|
|
|
|
|
|
|
map.put("overdueAmount", overdueAmount); |
|
|
|
|
|
|
|
map.put("overdueInterest", overdueInterest); |
|
|
|
|
|
|
|
map.put("otherExpenses", otherExpenses); |
|
|
|
|
|
|
|
return map; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取当前登录用户信息 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String getUserId() { |
|
|
|
|
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
|
|
|
|
|
|
|
String token = request.getHeader("token"); |
|
|
|
|
|
|
|
String userId = RedisUtil.get("dq:token:" + token); |
|
|
|
|
|
|
|
if (userId == null || userId.length() == 0) { |
|
|
|
|
|
|
|
ExceptionCast.cast(CommonCode.GET_LOGIN_USER_FAIL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return userId; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 将催收人id转换成催收人姓名并返回 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<AlCollectionListResponse> jointName(List<AlCollectionListPO> alCollectionListPO, List<EmployeeVO> employeeVO) { |
|
|
|
|
|
|
|
List<AlCollectionListResponse> response = new ArrayList<>(); |
|
|
|
|
|
|
|
for (AlCollectionListPO collectionListPO : alCollectionListPO) { |
|
|
|
|
|
|
|
AlCollectionListResponse alCollectionListResponse = new AlCollectionListResponse(); |
|
|
|
|
|
|
|
for (EmployeeVO employee : employeeVO) { |
|
|
|
|
|
|
|
if (Objects.equals(collectionListPO.getCollectionUser().longValue(), employee.getId())) { |
|
|
|
|
|
|
|
alCollectionListResponse.setCollectionUserName(employee.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(collectionListPO, alCollectionListResponse); |
|
|
|
|
|
|
|
response.add(alCollectionListResponse); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|