年度统计根据实际还款日修改

master v1.1
chen 3 years ago
parent 7ddcc0cdd5
commit da71140823
  1. 2
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/AlCollectionStatisticsService.java
  2. 23
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlCollectionStatisticsServiceImpl.java
  3. 4
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlInsuranceListServiceImpl.java
  4. 53
      dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/AlRepaymentEntryServiceImpl.java
  5. 13
      dq-financial-guarantee/src/main/resources/mapper/guarantee/AlCollectionStatisticsMapper.xml

@ -49,5 +49,5 @@ public interface AlCollectionStatisticsService extends IService<AlCollectionStat
boolean selectGenerateYear(String year); boolean selectGenerateYear(String year);
void updateCompleteStatistics(Integer repaymentId); void updateCompleteStatistics(Integer repaymentId,String year);
} }

@ -137,7 +137,6 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
String year = generateReq.getYear(); String year = generateReq.getYear();
List<Integer> personLiableIds = generateReq.getPersonLiableIds(); List<Integer> personLiableIds = generateReq.getPersonLiableIds();
//有人员id生成数据 //有人员id生成数据
if (personLiableIds.size() > 0){ if (personLiableIds.size() > 0){
List<AlReimbursement> reimbursementList = reimbursementMapper.selectListByYear(year,personLiableIds); List<AlReimbursement> reimbursementList = reimbursementMapper.selectListByYear(year,personLiableIds);
@ -156,7 +155,7 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
// BigDecimal guaranteeAmount = alInsuranceList.getGuaranteeAmount(); // BigDecimal guaranteeAmount = alInsuranceList.getGuaranteeAmount();
//统计业务还款记录清收现金和资产 //统计业务还款记录清收现金和资产
QueryWrapper<AlRepaymentEntry> repaymentEntryWrapper = new QueryWrapper<>(); QueryWrapper<AlRepaymentEntry> repaymentEntryWrapper = new QueryWrapper<>();
repaymentEntryWrapper.eq("insurance_id",insuranceId).orderByAsc("id"); repaymentEntryWrapper.eq("insurance_id",insuranceId).last("and YEAR(actual_repayment_date) = '"+year+"' ");
List<AlRepaymentEntry> repaymentEntryList = repaymentEntryMapper.selectList(repaymentEntryWrapper); List<AlRepaymentEntry> repaymentEntryList = repaymentEntryMapper.selectList(repaymentEntryWrapper);
//清收现金 //清收现金
BigDecimal repaymentCash = new BigDecimal(0); BigDecimal repaymentCash = new BigDecimal(0);
@ -164,8 +163,8 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
BigDecimal repaymentAssets = new BigDecimal(0); BigDecimal repaymentAssets = new BigDecimal(0);
StringBuilder note = new StringBuilder(); StringBuilder note = new StringBuilder();
for (AlRepaymentEntry repaymentEntry: repaymentEntryList){ for (AlRepaymentEntry repaymentEntry: repaymentEntryList){
//无实际还款日不加入年度统计 //无实际还款日不加入年度统计或不在此年度不加入该年度统计
if (repaymentEntry.getActualRepaymentDate()==null){ if (!year.equals(repaymentEntry.getActualRepaymentDate().substring(0,4))){
continue; continue;
} }
if (repaymentEntry.getRepaymentCash()!=null){ if (repaymentEntry.getRepaymentCash()!=null){
@ -186,6 +185,7 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
collectionStatistics.setGroupId(collectionGroupId); collectionStatistics.setGroupId(collectionGroupId);
collectionStatistics.setInsuranceId(insuranceId); collectionStatistics.setInsuranceId(insuranceId);
collectionStatistics.setActualRepaymentDate(year);
collectionStatistics.setPersonLiable(personLiable); collectionStatistics.setPersonLiable(personLiable);
collectionStatistics.setPersonLiableId(personLiableId); collectionStatistics.setPersonLiableId(personLiableId);
collectionStatistics.setJobNumber(jobNumber); collectionStatistics.setJobNumber(jobNumber);
@ -343,7 +343,7 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
* 还款添加或编辑或删除根据还款记录id查询保后业务数据更新年度清收数据 * 还款添加或编辑或删除根据还款记录id查询保后业务数据更新年度清收数据
*/ */
@Override @Override
public void updateCompleteStatistics(Integer insuranceId) { public void updateCompleteStatistics(Integer insuranceId,String year) {
//查询清收代偿信息 //查询清收代偿信息
QueryWrapper<AlReimbursement> wrapper = new QueryWrapper<>(); QueryWrapper<AlReimbursement> wrapper = new QueryWrapper<>();
wrapper.eq("insurance_id",insuranceId); wrapper.eq("insurance_id",insuranceId);
@ -363,17 +363,17 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
String customerName = alInsuranceList.getCustomerName(); String customerName = alInsuranceList.getCustomerName();
//统计该业务下还款记录清收现金和资产 //统计该业务下还款记录清收现金和资产
QueryWrapper<AlRepaymentEntry> repaymentEntryWrapper = new QueryWrapper<>(); QueryWrapper<AlRepaymentEntry> repaymentEntryWrapper = new QueryWrapper<>();
repaymentEntryWrapper.eq("insurance_id",insuranceId).orderByAsc("id"); repaymentEntryWrapper.eq("insurance_id",insuranceId).last("and YEAR(actual_repayment_date) = '"+year+"' ");
List<AlRepaymentEntry> repaymentEntryList = repaymentEntryMapper.selectList(repaymentEntryWrapper); List<AlRepaymentEntry> repaymentEntryList = repaymentEntryMapper.selectList(repaymentEntryWrapper);
//无还款记录则删除该年度业务统计 //无还款记录则删除该年度业务统计
if (ObjectUtil.isNull(repaymentEntryList)){ if (ObjectUtil.isNull(repaymentEntryList)||repaymentEntryList.size()==0){
QueryWrapper<AlCollectionStatistics> deleteWrapper = new QueryWrapper<>(); QueryWrapper<AlCollectionStatistics> deleteWrapper = new QueryWrapper<>();
deleteWrapper.eq("insurance_id",insuranceId).eq("group_id",groupId); deleteWrapper.eq("insurance_id",insuranceId).eq("group_id",groupId).eq("actual_repayment_date",year);
baseMapper.delete(deleteWrapper); baseMapper.delete(deleteWrapper);
}else { }else {
//先清空之前数据 //先清空之前数据
QueryWrapper<AlCollectionStatistics> deleteWrapper = new QueryWrapper<>(); QueryWrapper<AlCollectionStatistics> deleteWrapper = new QueryWrapper<>();
deleteWrapper.eq("insurance_id",insuranceId).eq("group_id",groupId); deleteWrapper.eq("insurance_id",insuranceId).eq("group_id",groupId).eq("actual_repayment_date",year);
baseMapper.delete(deleteWrapper); baseMapper.delete(deleteWrapper);
//清收现金 //清收现金
BigDecimal repaymentCash = new BigDecimal(0); BigDecimal repaymentCash = new BigDecimal(0);
@ -382,8 +382,8 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
StringBuilder note = new StringBuilder(); StringBuilder note = new StringBuilder();
for (AlRepaymentEntry repayment: repaymentEntryList){ for (AlRepaymentEntry repayment: repaymentEntryList){
//无实际还款日不加入年度统计 //无实际还款日不加入年度统计或不在此年度不加入该年度统计
if (repayment.getActualRepaymentDate()==null){ if (!year.equals(repayment.getActualRepaymentDate().substring(0,4))){
continue; continue;
} }
if (repayment.getRepaymentCash()!=null){ if (repayment.getRepaymentCash()!=null){
@ -404,6 +404,7 @@ public class AlCollectionStatisticsServiceImpl extends ServiceImpl<AlCollectionS
//添加年度数据 //添加年度数据
collectionStatistics.setGroupId(groupId); collectionStatistics.setGroupId(groupId);
collectionStatistics.setInsuranceId(insuranceId); collectionStatistics.setInsuranceId(insuranceId);
collectionStatistics.setActualRepaymentDate(year);
collectionStatistics.setPersonLiable(personLiable); collectionStatistics.setPersonLiable(personLiable);
collectionStatistics.setPersonLiableId(personLiableId); collectionStatistics.setPersonLiableId(personLiableId);
collectionStatistics.setJobNumber(jobNumber); collectionStatistics.setJobNumber(jobNumber);

@ -168,10 +168,10 @@ public class AlInsuranceListServiceImpl extends ServiceImpl<AlInsuranceListMappe
deleteWrapper.eq("insurance_id",alInsuranceList.getId()); deleteWrapper.eq("insurance_id",alInsuranceList.getId());
int delete = collectionStatisticsMapper.delete(deleteWrapper); int delete = collectionStatisticsMapper.delete(deleteWrapper);
// System.out.println("删除条数"+delete); // System.out.println("删除条数"+delete);
if (delete>0){ /*if (delete>0){
//根据业务id更新年度统计 //根据业务id更新年度统计
collectionStatisticsService.updateCompleteStatistics(alInsuranceList.getId()); collectionStatisticsService.updateCompleteStatistics(alInsuranceList.getId());
} }*/
} }
} }
//更新清收代偿数据 //更新清收代偿数据

@ -81,8 +81,14 @@ public class AlRepaymentEntryServiceImpl extends ServiceImpl<AlRepaymentEntryMap
updateRepaymentEntry(insuranceId); updateRepaymentEntry(insuranceId);
//更新统计还款记录数据 //更新统计还款记录数据
repaymentStatistics(insuranceId); repaymentStatistics(insuranceId);
//更新年度统计 String actualRepaymentDate = alRepaymentEntry.getActualRepaymentDate();
collectionStatisticsService.updateCompleteStatistics(insuranceId); //添加无实际还款不进行年度统计
if (actualRepaymentDate!=null){
//获取实际还款日年份
String year = actualRepaymentDate.substring(0,4);
//更新年度统计
collectionStatisticsService.updateCompleteStatistics(insuranceId,year);
}
return insert; return insert;
} }
@ -132,15 +138,38 @@ public class AlRepaymentEntryServiceImpl extends ServiceImpl<AlRepaymentEntryMap
@Override @Override
public int updateRepayment(AlRepaymentEntry alRepaymentEntryReq) { public int updateRepayment(AlRepaymentEntry alRepaymentEntryReq) {
String actualRepaymentDate = alRepaymentEntryReq.getActualRepaymentDate();
//查询更新之前的年份
String before = "";
AlRepaymentEntry repaymentEntry = baseMapper.selectById(alRepaymentEntryReq.getId());
before = repaymentEntry.getActualRepaymentDate();
before = before.substring(0,4);
int update = baseMapper.updateById(alRepaymentEntryReq); int update = baseMapper.updateById(alRepaymentEntryReq);
// if (actualRepaymentDate==null){
// //查询更新之前数据
// AlRepaymentEntry repaymentEntry1 = baseMapper.selectById(alRepaymentEntryReq.getId());
// actualRepaymentDate = repaymentEntry1.getActualRepaymentDate();
// }else {
// }
//查询更新之前数据进行更新
collectionStatisticsService.updateCompleteStatistics(alRepaymentEntryReq.getInsuranceId(),before);
//更新代偿信息 //更新代偿信息
updateReimbursementData(alRepaymentEntryReq.getInsuranceId()); updateReimbursementData(alRepaymentEntryReq.getInsuranceId());
//更新业务状态 //更新业务状态
updateRepaymentEntry(alRepaymentEntryReq.getInsuranceId()); updateRepaymentEntry(alRepaymentEntryReq.getInsuranceId());
//更新统计还款记录数据 //更新统计还款记录数据
repaymentStatistics(alRepaymentEntryReq.getInsuranceId()); repaymentStatistics(alRepaymentEntryReq.getInsuranceId());
//更新年度统计
collectionStatisticsService.updateCompleteStatistics(alRepaymentEntryReq.getInsuranceId()); //无实际还款不进行年度统计
if (actualRepaymentDate!=null){
//获取实际还款日年份
String year = actualRepaymentDate.substring(0,4);
//更新年度统计
collectionStatisticsService.updateCompleteStatistics(alRepaymentEntryReq.getInsuranceId(),year);
}
return update; return update;
} }
@ -148,13 +177,25 @@ public class AlRepaymentEntryServiceImpl extends ServiceImpl<AlRepaymentEntryMap
public int delRepayment(List<Integer> ids) { public int delRepayment(List<Integer> ids) {
if (ids.size()>0){ if (ids.size()>0){
AlRepaymentEntry repaymentEntry = baseMapper.selectById(ids.get(0)); AlRepaymentEntry repaymentEntry = baseMapper.selectById(ids.get(0));
//删除前更新年度统计
for (Integer id : ids){
AlRepaymentEntry repaymentEntry1 = baseMapper.selectById(id);
String actualRepaymentDate = repaymentEntry1.getActualRepaymentDate();
//添加无实际还款不进行年度统计
if (actualRepaymentDate!=null){
//获取实际还款日年份
String year = actualRepaymentDate.substring(0,4);
//更新年度统计
collectionStatisticsService.updateCompleteStatistics(repaymentEntry.getInsuranceId(),year);
}
}
int i = baseMapper.deleteBatchIds(ids); int i = baseMapper.deleteBatchIds(ids);
//更新统计还款记录数据 //更新统计还款记录数据
repaymentStatistics(repaymentEntry.getInsuranceId()); repaymentStatistics(repaymentEntry.getInsuranceId());
//更新代偿信息 //更新代偿信息
updateReimbursementData(repaymentEntry.getInsuranceId()); updateReimbursementData(repaymentEntry.getInsuranceId());
//更新年度统计
collectionStatisticsService.updateCompleteStatistics(repaymentEntry.getInsuranceId());
return i; return i;
} }
return 0; return 0;

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.guarantee.mapper.AlCollectionStatisticsMapper"> <mapper namespace="com.daqing.financial.guarantee.mapper.AlCollectionStatisticsMapper">
<delete id="deleteAnnualStatistics"> <delete id="deleteAnnualStatistics">
delete from al_collection_statistics where year(create_time) = #{year} delete from al_collection_statistics where actual_repayment_date = #{year}
</delete> </delete>
<delete id="truncate"> <delete id="truncate">
TRUNCATE al_collection_statistics TRUNCATE al_collection_statistics
@ -122,10 +122,9 @@
</select> </select>
<select id="selectAnnualList" resultType="java.lang.String"> <select id="selectAnnualList" resultType="java.lang.String">
select DISTINCT(year(create_time)) from al_collection_statistics select DISTINCT(actual_repayment_date) from al_collection_statistics
</select> </select>
<select id="selectAnnualStatisticsList" <select id="selectAnnualStatisticsList"
resultType="com.daqing.framework.domain.guarantee.AlCollectionStatistics"> resultType="com.daqing.framework.domain.guarantee.AlCollectionStatistics">
select ac.id,ac.group_id,ac.person_liable,ac.job_number,ac.enterprise,ac.cash,ac.assets, select ac.id,ac.group_id,ac.person_liable,ac.job_number,ac.enterprise,ac.cash,ac.assets,
@ -134,7 +133,7 @@
ac.proportion,ac.description,ag.group_name ac.proportion,ac.description,ag.group_name
from al_collection_statistics ac from al_collection_statistics ac
left join al_collection_group ag on ac.group_id = ag.id left join al_collection_group ag on ac.group_id = ag.id
where year(ac.create_time) = #{slr.year} where ac.actual_repayment_date = #{slr.year}
<if test="slr.groupId != null and slr.groupId != ''"> <if test="slr.groupId != null and slr.groupId != ''">
AND ac.group_id = #{slr.groupId} AND ac.group_id = #{slr.groupId}
</if> </if>
@ -151,7 +150,7 @@
select count(1) select count(1)
from al_collection_statistics ac from al_collection_statistics ac
left join al_collection_group ag on ac.group_id = ag.id left join al_collection_group ag on ac.group_id = ag.id
where year(ac.create_time) = #{slr.year} where ac.actual_repayment_date = #{slr.year}
<if test="slr.groupId != null and slr.groupId != ''"> <if test="slr.groupId != null and slr.groupId != ''">
AND ac.group_id = #{slr.groupId} AND ac.group_id = #{slr.groupId}
</if> </if>
@ -168,11 +167,11 @@
</select> </select>
<select id="selectGenerateYear" resultType="java.lang.Integer"> <select id="selectGenerateYear" resultType="java.lang.Integer">
select count(1) from al_collection_statistics where year(actual_repayment_date) = #{year} select count(1) from al_collection_statistics where actual_repayment_date = #{year}
</select> </select>
<select id="selectYearPerson" resultType="java.lang.Integer"> <select id="selectYearPerson" resultType="java.lang.Integer">
select DISTINCT(person_liable_id) from al_collection_statistics where year(create_time) = #{year} select DISTINCT(person_liable_id) from al_collection_statistics where actual_repayment_date = #{year}
</select> </select>
<select id="selectGroupList" resultType="java.lang.Integer"> <select id="selectGroupList" resultType="java.lang.Integer">

Loading…
Cancel
Save