|
|
@@ -154,6 +154,101 @@ public class FssPaccountPayServiceImpl implements FssPaccountPayService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 更新统计 |
|
|
|
* @param day |
|
|
|
* @throws ServiceHandleException |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void newCount(int day) throws ServiceHandleException { |
|
|
|
// 获取当前日期前一天的日期 |
|
|
|
//1代表提前多少天 |
|
|
|
LocalDate localDate = LocalDate.now().minusDays(day); |
|
|
|
String yesterday = localDate.toString(); |
|
|
|
log.info("当前导入记录日期="+yesterday); |
|
|
|
List<Map<String, Object>> countTotal = paccountPayRepo.findCountTotal(yesterday+" 00:00:00",yesterday+" 23:59:59"); |
|
|
|
List<AflPaccountRefundCountFindVo> list = new ArrayList<AflPaccountRefundCountFindVo>(); |
|
|
|
for (Map<String, Object> stringObjectMap : countTotal) { |
|
|
|
AflPaccountRefundCountFindVo aflPaccountRefundCountVo = JSON.parseObject(JSON.toJSONString(stringObjectMap), AflPaccountRefundCountFindVo.class); |
|
|
|
list.add(aflPaccountRefundCountVo); |
|
|
|
} |
|
|
|
if (list==null||list.size()<1){ |
|
|
|
log.error("当前n+"+day+"天记录无数据"); |
|
|
|
return; |
|
|
|
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+"+day+"天记录无数据"); |
|
|
|
} |
|
|
|
log.info("本次处理数据:{}", JSON.toJSON(list)); |
|
|
|
AflPaccountRefundCount bydAflPaccountRefundCount = null; |
|
|
|
for (AflPaccountRefundCountFindVo aflPaccountRefundCountVo : list) { |
|
|
|
Integer newAccountDate1 =null; |
|
|
|
if (!StringUtils.isEmpty(aflPaccountRefundCountVo.getAccountDate())){ |
|
|
|
String accountDate=aflPaccountRefundCountVo.getAccountDate().replaceAll("-",""); |
|
|
|
newAccountDate1 = Integer.parseInt(accountDate); |
|
|
|
} |
|
|
|
AflPaccountRefundCount aflPaccountRefundCount= null; |
|
|
|
if("52010188999".equals(aflPaccountRefundCountVo.getAgentId())&&newAccountDate1!=null){ |
|
|
|
aflPaccountRefundCount= aflPaccountRefundCountRepo.finByDateAndAgentId("52010188930",newAccountDate1); |
|
|
|
}else { |
|
|
|
aflPaccountRefundCount= aflPaccountRefundCountRepo.finByDateAndAgentId(aflPaccountRefundCountVo.getAgentId(),newAccountDate1); |
|
|
|
} |
|
|
|
if (aflPaccountRefundCount==null){ |
|
|
|
aflPaccountRefundCount = new AflPaccountRefundCount(); |
|
|
|
} |
|
|
|
Long refundMoney = fssPaccountRefundRepo.findByCountRefundMoney(aflPaccountRefundCountVo.getAgentId(),aflPaccountRefundCountVo.getAccountDate()); |
|
|
|
|
|
|
|
aflPaccountRefundCountVo.setId(aflPaccountRefundCount.getId()); |
|
|
|
BeanUtils.copyProperties(aflPaccountRefundCountVo,aflPaccountRefundCount); |
|
|
|
aflPaccountRefundCount.setRefundMoney(refundMoney); |
|
|
|
if (!StringUtils.isEmpty(aflPaccountRefundCountVo.getAccountDate())){ |
|
|
|
String accountDate=aflPaccountRefundCountVo.getAccountDate().replaceAll("-",""); |
|
|
|
Integer newAccountDate = Integer.parseInt(accountDate); |
|
|
|
aflPaccountRefundCount.setAccountDate(newAccountDate); |
|
|
|
} |
|
|
|
if ("52010188999".equals(aflPaccountRefundCount.getAgentId())&&aflPaccountRefundCount.getAccountDate()!=null){ |
|
|
|
bydAflPaccountRefundCount=aflPaccountRefundCount; |
|
|
|
AflPaccountRefundCount bydNewAflPaccountRefundCount= aflPaccountRefundCountRepo.finByDateAndAgentId("52010188930",aflPaccountRefundCount.getAccountDate()); |
|
|
|
if (bydNewAflPaccountRefundCount!=null){ |
|
|
|
if (bydAflPaccountRefundCount.getMoneyTotal()!=null){ |
|
|
|
bydNewAflPaccountRefundCount.setMoneyTotal(bydNewAflPaccountRefundCount.getMoneyTotal()+bydAflPaccountRefundCount.getMoneyTotal()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getRefundMoney()!=null){ |
|
|
|
bydNewAflPaccountRefundCount.setRefundMoney(bydNewAflPaccountRefundCount.getRefundMoney()+bydAflPaccountRefundCount.getRefundMoney()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getCollectMoney()!=null){ |
|
|
|
bydNewAflPaccountRefundCount.setCollectMoney(bydNewAflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getNumberTotal()!=null){ |
|
|
|
bydNewAflPaccountRefundCount.setNumberTotal(bydNewAflPaccountRefundCount.getNumberTotal()+bydAflPaccountRefundCount.getNumberTotal()); |
|
|
|
} |
|
|
|
aflPaccountRefundCountRepo.save(bydNewAflPaccountRefundCount); |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ("52010188930".equals(aflPaccountRefundCount.getAgentId())&&bydAflPaccountRefundCount!=null){ |
|
|
|
if (bydAflPaccountRefundCount.getMoneyTotal()!=null){ |
|
|
|
aflPaccountRefundCount.setMoneyTotal(aflPaccountRefundCount.getMoneyTotal()+bydAflPaccountRefundCount.getMoneyTotal()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getRefundMoney()!=null){ |
|
|
|
aflPaccountRefundCount.setRefundMoney(aflPaccountRefundCount.getRefundMoney()+bydAflPaccountRefundCount.getRefundMoney()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getCollectMoney()!=null){ |
|
|
|
aflPaccountRefundCount.setCollectMoney(aflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney()); |
|
|
|
} |
|
|
|
if (bydAflPaccountRefundCount.getNumberTotal()!=null){ |
|
|
|
aflPaccountRefundCount.setCollectMoney(aflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(aflPaccountRefundCount.getId())){ |
|
|
|
aflPaccountRefundCount.setId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
aflPaccountRefundCount.setInsertTime(LocalDateTime.now()); |
|
|
|
} |
|
|
|
aflPaccountRefundCount.setUpdateTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
aflPaccountRefundCountRepo.save(aflPaccountRefundCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private List<VehicleAgreementNumBillsVo> toVo(List<FssPaccountPay> payList) { |
|
|
|
if (CollectionUtils.isEmpty(payList)) { |
|
|
|
return Lists.newArrayList(); |