diff --git a/intc-modules/intc-gen/src/main/resources/vm/vue/v3/index.vue.vm b/intc-modules/intc-gen/src/main/resources/vm/vue/v3/index.vue.vm deleted file mode 100644 index 9bc3b46..0000000 --- a/intc-modules/intc-gen/src/main/resources/vm/vue/v3/index.vue.vm +++ /dev/null @@ -1,604 +0,0 @@ - - - diff --git a/intc-modules/intc-invest/src/main/java/com/intc/invest/domain/vo/InstallmentHistoryDetailVo.java b/intc-modules/intc-invest/src/main/java/com/intc/invest/domain/vo/InstallmentHistoryDetailVo.java deleted file mode 100644 index b7594e7..0000000 --- a/intc-modules/intc-invest/src/main/java/com/intc/invest/domain/vo/InstallmentHistoryDetailVo.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.intc.invest.domain.vo; - -import com.intc.invest.domain.InstallmentHistoryDetail; -import io.swagger.annotations.ApiModel; -import lombok.Data; -/** - * 分期历史明细Vo对象 installment_history_detail - * - * @author tianyongbao - * @date 2024-03-23 - */ -@ApiModel("分期历史明细Vo对象") -@Data -public class InstallmentHistoryDetailVo extends InstallmentHistoryDetail -{ - private String bankCardLendName; - - private String repaymentAccountName; - -} diff --git a/intc-modules/intc-invest/src/main/java/com/intc/invest/service/impl/StatisticAnalysisImpl.java b/intc-modules/intc-invest/src/main/java/com/intc/invest/service/impl/StatisticAnalysisImpl.java deleted file mode 100644 index c08d005..0000000 --- a/intc-modules/intc-invest/src/main/java/com/intc/invest/service/impl/StatisticAnalysisImpl.java +++ /dev/null @@ -1,3430 +0,0 @@ -package com.intc.invest.service.impl; - -import com.alibaba.fastjson2.JSON; -import com.intc.common.core.utils.DateUtils; -import com.intc.common.core.utils.StringUtils; -import com.intc.common.security.utils.DictUtils; -import com.intc.invest.domain.dto.*; -import com.intc.invest.domain.vo.*; -import com.intc.invest.mapper.*; -import com.intc.invest.service.IStatisticAnalysisService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.stream.Collectors; - -@Service -public class StatisticAnalysisImpl implements IStatisticAnalysisService { - - @Resource - private BankCardLendMapper bankCardLendMapper; - - @Resource - private CreditCardBillMapper creditCardBillMapper; - - @Resource - private FutureStocksBillMapper futureStocksBillMapper; - - @Resource - private FutureStocksMapper futureStocksMapper; - - @Resource - private PosMachineMapper posMachineMapper; - - @Resource - private InstallmentHistoryMapper installmentHistoryMapper; - - @Resource - private InstallmentHistoryDetailMapper installmentHistoryDetailMapper; - - @Resource - private StatisticAnalysisMapper statisticAnalysisMapper; - - @Resource - private CreditReportQueryRecordMapper creditReportQueryRecordMapper; - - @Resource - private AccountsMapper accountsMapper; - - @Resource - private AccountsTransferRecordMapper accountsTransferRecordMapper; - - @Resource - private AccountsDealRecordMapper accountsDealRecordMapper; - - @Override - public Map getPosAccountsInfo() { - //返回数据 - HashMap map = new HashMap<>(); - //Pos机 - PosMachineDto posMachineDto=new PosMachineDto(); - //状态为正常使用 - posMachineDto.setStatus("1"); - map.put("posCount",posMachineMapper.selectPosMachineList(posMachineDto).size()); - - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - AccountsTransferRecordDto dto=new AccountsTransferRecordDto(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //当前日期 - Date queryDate=DateUtils.getNowDate(); - - Calendar calendarStart = Calendar.getInstance(); - calendarStart.add(Calendar.MONTH, 0); - calendarStart.set(Calendar.DAY_OF_MONTH, 1);//1:本月第一天 - //获取数据 - dto.setEndTime(dateFormat.format(queryDate)); - dto.setStartTime(dateFormat.format(calendarStart.getTime())); - dto.setType("1"); - List transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); - - double currentMonthAmount =0; - double currentMonthCommission =0; - int currentMonthCount =0; - double actualAmount =0; - if(transferList.size()>0){ - currentMonthCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); - currentMonthAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); - } - currentMonthCount=transferList.size(); - map.put("currentMonthAmount",decimalFormat.format(currentMonthAmount)); - map.put("currentMonthCommission",decimalFormat.format(currentMonthCommission)); - map.put("currentMonthCount",currentMonthCount); - - calendarStart= Calendar.getInstance(); - calendarStart.set(Calendar.DAY_OF_YEAR, 1);//本年的第一天 - dto.setStartTime(dateFormat.format(calendarStart.getTime())); - transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); - - double currentYearAmount =0; - double currentYearCommission =0; - int currentYearCount =0; - if(transferList.size()>0){ - currentYearCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); - currentYearAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); - } - - currentYearCount=transferList.size(); - map.put("currentYearAmount",decimalFormat.format(currentYearAmount)); - map.put("currentYearCommission",decimalFormat.format(currentYearCommission)); - map.put("currentYearCount",currentYearCount); - dto.setStartTime(""); - transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); - - double accumulateAmount =0; - double accumulateCommission =0; - int accumulateCount =0; - if(transferList.size()>0){ - accumulateCommission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); - accumulateAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); - } - accumulateCount=transferList.size(); - map.put("accumulateAmount",decimalFormat.format(accumulateAmount)); - map.put("accumulateCommission",decimalFormat.format(accumulateCommission)); - map.put("accumulateCount",accumulateCount); - - return map; - } - - @Override - public Map getCreditAccountsInfo() { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - - - //当月信用卡账单 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单"); - CreditCardBillDto creditCardBillDto=new CreditCardBillDto(); - creditCardBillDto.setName(simpleDateFormat.format(DateUtils.getNowDate())); - List creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); - double currentCreditBill = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum(); - map.put("currentCreditBill",decimalFormat.format(currentCreditBill)); - - //信用卡分期当月应还款 - InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); - detailDto.setRepaymentMonth(formatterMonth.format(new Date())); - detailDto.setType("2"); - List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double creditInstallment = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - map.put("creditInstallment",decimalFormat.format(creditInstallment)); - - detailDto.setState("0"); - detailDto.setRepaymentMonth(""); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double unclearedCreditInstallment = 0; - double unclearedCreditInstallmentPrinciple = 0; - double unclearedCreditInstallmentInterest = 0; - if(detailList.size()>0){ - - unclearedCreditInstallmentPrinciple=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); - unclearedCreditInstallmentInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); - unclearedCreditInstallment=unclearedCreditInstallmentPrinciple+unclearedCreditInstallmentInterest; - } - map.put("unclearedCreditInstallment",decimalFormat.format(unclearedCreditInstallment)); - map.put("unclearedCreditInstallmentPrinciple",decimalFormat.format(unclearedCreditInstallmentPrinciple)); - map.put("unclearedCreditInstallmentInterest",decimalFormat.format(unclearedCreditInstallmentInterest)); - - //已结清信用卡分期数据 - InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType("2"); - List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - double clearedCreditInstallmentDebt =0; - double clearedCreditInstallmentPrinciple =0; - double clearedCreditInstallmentInterest =0; - if(installmentHistoryList.size()>0){ - clearedCreditInstallmentPrinciple = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); - clearedCreditInstallmentInterest = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getTotalInterest).sum(); - clearedCreditInstallmentDebt=clearedCreditInstallmentPrinciple+clearedCreditInstallmentInterest; - } - map.put("clearedCreditInstallmentDebt",decimalFormat.format(clearedCreditInstallmentDebt)); - map.put("clearedCreditInstallmentPrinciple",decimalFormat.format(clearedCreditInstallmentPrinciple)); - map.put("clearedCreditInstallmentInterest",decimalFormat.format(clearedCreditInstallmentInterest)); - - int clearedCreditInstallmentCount = installmentHistoryList.size(); - map.put("clearedCreditInstallmentCount",clearedCreditInstallmentCount); - - installmentHistoryDto.setState("0"); - installmentHistoryDto.setType("2"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int unclearedCreditInstallmentCount = installmentHistoryList.size(); - map.put("unclearedCreditInstallmentCount",unclearedCreditInstallmentCount); - - - //信用卡额度 - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - - //状态为正常使用 - bankCardLendDto.setStatus("1"); - bankCardLendDto.setType("2"); - - List bankCardLendVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); - //信用卡 - map.put("creditCount",bankCardLendVoList.size()); - int creditLimit = bankCardLendVoList.stream().mapToInt(BankCardLendVo::getCreditLimit).sum(); - map.put("creditLimit",creditLimit); - AccountsDto dto=new AccountsDto(); - //正常使用 - dto.setStatus("1"); - //信用卡 - dto.setType("2"); - List accountsList=accountsMapper.selectAccountsList(dto); - double creditAvailableLimit =0; - double creditBalance =0; - if(accountsList.size()>0){ - creditAvailableLimit=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - creditBalance=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum()*(-1); - } - map.put("creditAvailableLimit",decimalFormat.format(creditAvailableLimit)); - map.put("creditBalance",decimalFormat.format(creditBalance)); - //使用率 - double creditBillRate; - if (creditLimit != 0) { - creditBillRate= ((creditBalance) * 100) /creditLimit; - }else { - creditBillRate= 0; - } - map.put("creditBillRate", decimalFormat.format(creditBillRate)); - - //上月信用卡账单 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtils.getNowDate()); - calendar.add(Calendar.MONTH, -1); - creditCardBillDto.setName(simpleDateFormat.format(calendar.getTime())); - creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); - double lastMonthUsedLimit = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum(); - map.put("lastMonthUsedLimit",decimalFormat.format(lastMonthUsedLimit)); - - - //使用率 - double lastMonthUsedRate; - if (creditLimit != 0) { - lastMonthUsedRate= ((lastMonthUsedLimit) * 100) /creditLimit; - }else { - lastMonthUsedRate= 0; - } - map.put("lastMonthUsedRate", decimalFormat.format(lastMonthUsedRate)); - - - - //近6个月月信用卡账单 - creditCardBillDto.setName(""); - Calendar startMonth = Calendar.getInstance(); - startMonth.setTime(DateUtils.getNowDate()); - startMonth.add(Calendar.MONTH, -6); - creditCardBillDto.setStartMonth(formatterMonth.format(startMonth.getTime())); - Calendar endMonth = Calendar.getInstance(); - endMonth.setTime(DateUtils.getNowDate()); - endMonth.add(Calendar.MONTH, -1); - creditCardBillDto.setEndMonth(formatterMonth.format(endMonth.getTime())); - creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); - double lastSixMonthUsedLimit = creditCardBillList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum(); - map.put("lastSixMonthUsedLimit",decimalFormat.format(lastSixMonthUsedLimit/6)); - //近6个月月信用卡使用率 - double lastSixMonthUsedRate; - if (creditLimit != 0) { - lastSixMonthUsedRate= lastSixMonthUsedLimit*100/(6*creditLimit); - }else { - lastSixMonthUsedRate= 0; - } - map.put("lastSixMonthUsedRate", decimalFormat.format(lastSixMonthUsedRate)); - - - return map; - } - - - @Override - public Map getDebitAccountsInfo() { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - AccountsDto dto=new AccountsDto(); - //状态正常,不隐藏 - dto.setStatus("1"); - //储蓄卡 - dto.setType("1"); - - //I类储蓄卡 - dto.setDebitType("1"); - List accountsList=accountsMapper.selectAccountsList(dto); - double debitIBalance =0; - Integer debitICount =0; - if(accountsList.size()>0){ - debitIBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - //I类储蓄卡数量 - debitICount=accountsList.size(); - map.put("debitICount",debitICount); - //I类储蓄卡余额 - map.put("debitIBalance",decimalFormat.format(debitIBalance)); - //II类储蓄卡 - dto.setDebitType("2"); - accountsList=accountsMapper.selectAccountsList(dto); - double debitIIBalance =0; - Integer debitIICount =0; - if(accountsList.size()>0){ - debitIIBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - //II类储蓄卡余额 - map.put("debitIIBalance",decimalFormat.format(debitIIBalance)); - //II类储蓄卡数量 - debitIICount=accountsList.size(); - map.put("debitICount",debitICount); - map.put("debitIICount",debitIICount); - //储蓄卡数量 - map.put("debitCount",debitICount+debitIICount); - //储蓄卡余额=I类储蓄卡余额+II类储蓄卡余额 - map.put("debitBalance",decimalFormat.format(debitIBalance+debitIIBalance)); - //网络账户余额 - dto.setDebitType("3"); - accountsList=accountsMapper.selectAccountsList(dto); - double debitOnlineBalance =0; - if(accountsList.size()>0){ - debitOnlineBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("debitOnlineBalance",decimalFormat.format(debitOnlineBalance)); - map.put("debitOnlineCount",accountsList.size()); - //储值卡余额 - dto.setDebitType("4"); - accountsList=accountsMapper.selectAccountsList(dto); - double storedValueCardBalance =0; - if(accountsList.size()>0){ - storedValueCardBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - //储值卡总数 - map.put("storedValueCardCount",accountsList.size()); - //储值卡余额 - map.put("storedValueCardBalance",decimalFormat.format(storedValueCardBalance)); - //住房公积金余额 - dto.setDebitType("5"); - accountsList=accountsMapper.selectAccountsList(dto); - double housingFundBalance =0; - if(accountsList.size()>0){ - housingFundBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("housingFundBalance",decimalFormat.format(housingFundBalance)); - - //职工医保余额 - dto.setDebitType("6"); - accountsList=accountsMapper.selectAccountsList(dto); - double medicalBalance =0; - if(accountsList.size()>0){ - medicalBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("medicalBalance",decimalFormat.format(medicalBalance)); - - //个人养老金余额 - dto.setDebitType("7"); - accountsList=accountsMapper.selectAccountsList(dto); - double personalPensionBalance =0; - if(accountsList.size()>0){ - personalPensionBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("personalPensionBalance",decimalFormat.format(personalPensionBalance)); - - //其他余额 - dto.setDebitType("8"); - accountsList=accountsMapper.selectAccountsList(dto); - double otherDebitBalance =0; - if(accountsList.size()>0){ - otherDebitBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("otherDebitBalance",decimalFormat.format(otherDebitBalance)); - map.put("otherDebitCount",accountsList.size()); - //储蓄账户总余额 - map.put("debitTotalBalance",decimalFormat.format(debitIBalance+debitIIBalance+debitOnlineBalance+housingFundBalance+storedValueCardBalance+medicalBalance+personalPensionBalance+otherDebitBalance)); - - - return map; - } - - @Override - public Map getInvestAccountsInfo() { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - //期货收益 - FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto(); - futureStocksBillDto.setType("1"); - List futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - double futuresIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("futuresIncome",decimalFormat.format(futuresIncome)); - //股票收益 - futureStocksBillDto.setType("2"); - futureStocksBillList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - double stocksIncome = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("stocksIncome",decimalFormat.format(stocksIncome)); - AccountsDto dto=new AccountsDto(); - dto.setState("1"); - //投资账户余额 - dto.setType("5"); - List accountsList=accountsMapper.selectAccountsList(dto); - double investBalance =0; - if(accountsList.size()>0){ - investBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("investBalance",decimalFormat.format(investBalance)); - //总收益 - map.put("totalIncome",decimalFormat.format(futuresIncome+stocksIncome)); - - FutureStocksDto futureStocksDto=new FutureStocksDto(); - //状态为正常使用 - futureStocksDto.setStatus("1"); - futureStocksDto.setType("1"); - //期货 - map.put("futuresCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); - //股票 - futureStocksDto.setType("2"); - map.put("stocksCount",futureStocksMapper.selectFutureStocksList(futureStocksDto).size()); - AccountsDealRecordDto dealDto=new AccountsDealRecordDto(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //当前日期 - Date queryDate=DateUtils.getNowDate(); - - Calendar calendarStart = Calendar.getInstance(); - calendarStart.add(Calendar.MONTH, 0); - calendarStart.set(Calendar.DAY_OF_MONTH, 1);//1:本月第一天 - //获取数据 - dealDto.setEndTime(dateFormat.format(queryDate)); - dealDto.setStartTime(dateFormat.format(calendarStart.getTime())); - dealDto.setType("5"); - dealDto.setDealCategory("2"); - List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(dealDto); - double income =0; - double expenses =0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - - if(vo.getDealType().equals("1")){ - income+=vo.getAmount(); - } - //支出 - if(vo.getDealType().equals("2")){ - expenses+=vo.getAmount(); - } - } - //交易金额 - map.put("currentMonthInvest",decimalFormat.format(income-expenses)); - //收入 - map.put("currentMonthIncome",decimalFormat.format(income)); - - //支出 - map.put("currentMonthExpenses",decimalFormat.format(expenses)); - - return map; - } - - @Override - public Map getLendAccountsInfo() { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - //状态为正常使用 - bankCardLendDto.setStatus("1"); - bankCardLendDto.setType("3"); - bankCardLendDto.setLendType("1"); - //网贷 - map.put("onlineLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - //人情 - bankCardLendDto.setLendType("2"); - map.put("peopleLendCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //未结清网贷数据 - InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); - InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); - detailDto.setType("3"); - detailDto.setState("0"); - List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double unClearedOnlineDebt = 0; - double unClearedOnlineDebtPrinciple = 0; - double unClearedOnlineDebtInterest = 0; - if(detailList.size()>0){ - unClearedOnlineDebtPrinciple=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); - unClearedOnlineDebtInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); - unClearedOnlineDebt=unClearedOnlineDebtPrinciple+unClearedOnlineDebtInterest; - } - map.put("unClearedOnlineDebt",decimalFormat.format(unClearedOnlineDebt)); - map.put("unClearedOnlineDebtPrinciple",decimalFormat.format(unClearedOnlineDebtPrinciple)); - map.put("unClearedOnlineDebtInterest",decimalFormat.format(unClearedOnlineDebtInterest)); - - //信用卡分期账单 - detailDto.setType("2"); - detailDto.setState("0"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double creditInstallmentHistory =0; - if(detailList.size()>0){ - creditInstallmentHistory = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("creditInstallmentHistory",decimalFormat.format(creditInstallmentHistory)); - - - AccountsDto dto=new AccountsDto(); - //状态正常,不隐藏 - dto.setStatus("1"); - //借贷 - dto.setType("3"); - dto.setLendType("2"); - List accountsList=accountsMapper.selectAccountsList(dto); - double peopleLendHistory =0; - if(accountsList.size()>0){ - peopleLendHistory=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum()*(-1); - } - map.put("peopleLendHistory",decimalFormat.format(peopleLendHistory)); -// //人情 -// installmentHistoryDto.setType("4"); -// installmentHistoryDto.setState("0"); -// List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - - //未结清账户数 - installmentHistoryDto.setState("0"); - installmentHistoryDto.setType("3"); - List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int unclearedOnlineDebtCount = installmentHistoryList.size(); - map.put("unclearedOnlineDebtCount",unclearedOnlineDebtCount); - - //已结清账户数 - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType("3"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int clearedOnlineDebtCount = installmentHistoryList.size(); - map.put("clearedOnlineDebtCount",clearedOnlineDebtCount); - - //已结清网贷数据 - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType("3"); - installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - double clearedOnlineDebt =0; - double clearedOnlineDebtPrinciple =0; - double clearedOnlineDebtInterest =0; - if(installmentHistoryList.size()>0){ - clearedOnlineDebtPrinciple = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); - clearedOnlineDebtInterest = installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getTotalInterest).sum(); - clearedOnlineDebt=clearedOnlineDebtPrinciple+clearedOnlineDebtInterest; - } - map.put("clearedOnlineDebt",decimalFormat.format(clearedOnlineDebt)); - map.put("clearedOnlineDebtPrinciple",decimalFormat.format(clearedOnlineDebtPrinciple)); - map.put("clearedOnlineDebtInterest",decimalFormat.format(clearedOnlineDebtInterest)); - //网贷当月应还款 - - detailDto.setRepaymentMonth(formatterMonth.format(new Date())); - detailDto.setState(""); - detailDto.setType("3"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double dueOnlineDebt =0; - if(detailList.size()>0){ - dueOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("dueOnlineDebt",decimalFormat.format(dueOnlineDebt)); - - //网贷当月已还款 - detailDto.setState("1"); - detailDto.setRepaymentMonth(formatterMonth.format(new Date())); - detailDto.setType("3"); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double repaidOnlineDebt =0; - if(detailList.size()>0){ - repaidOnlineDebt = detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("repaidOnlineDebt",decimalFormat.format(repaidOnlineDebt)); - - //网贷剩余还款 - map.put("leftOnlineDebt",decimalFormat.format(dueOnlineDebt-repaidOnlineDebt)); - - return map; - } - - @Override - public CreditReportAnalysisVO getCreditReportInfo() { - - CreditReportQueryRecordDto dto =new CreditReportQueryRecordDto(); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - Date queryDate=DateUtils.getNowDate(); - if(dto.getQueryDateStart()!=null){ - try { - queryDate=formatter.parse(dto.getQueryDateStart()); - dto.setQueryDateEnd(dto.getQueryDateStart()); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - CreditReportAnalysisVO analysisVO=new CreditReportAnalysisVO(); - dto.setQueryType("1"); - - Calendar calendarStart = Calendar.getInstance(); - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -1); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastOneMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -2); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastTwoMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -3); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastThreeMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -6); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastSixMonths(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -12); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastOneYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -24); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - analysisVO.setLastTwoYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - - dto.setQueryDateStart(""); - analysisVO.setLastAllYears(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -6); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - dto.setType("5"); - dto.setQueryType("2"); - analysisVO.setLastSixMonthQueryCount(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -6); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - dto.setType("4"); - analysisVO.setLastSixMonthsAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -24); - dto.setQueryDateStart(formatter.format(calendarStart.getTime())); - dto.setType("4"); - analysisVO.setLastTwoYearsAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - - dto.setQueryDateStart(""); - dto.setType("4"); - analysisVO.setTotalAfterLoan(creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()+""); - return analysisVO; - } - - @Override - public Map getCreditAnalysis(AnalysisDto analysisDto) { -//返回数据 - HashMap map = new HashMap<>(); - - List creditCardBillVoList=new ArrayList<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-1)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-6)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - //根据日期,获取按日获取的数据,按月按年分组列表,单独处理 - CreditCardBillDto creditCardBillDto=new CreditCardBillDto(); - creditCardBillDto.setStartMonth(analysisDto.getStartTime().substring(0,7)); - creditCardBillDto.setEndMonth(analysisDto.getEndTime().substring(0,7)); - creditCardBillDto.setCreditCardId(analysisDto.getId()); - creditCardBillVoList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); - //修改名称加卡号 - for (CreditCardBillVo creditCardBill : creditCardBillVoList) { - if(creditCardBill.getBankName()!=null){ - creditCardBill.setBankNameCode(creditCardBill.getBankName()+"("+ StringUtils.getLastNumberChars(4,creditCardBill.getBankCode()+")")); - } - } - //信用卡额度 - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - bankCardLendDto.setType("2"); - bankCardLendDto.setStatus("1"); - bankCardLendDto.setCreditCardId(analysisDto.getId()); - List bankCardLendVoList=statisticAnalysisMapper.selectBankCardLendList(bankCardLendDto); - int creditLimit = bankCardLendVoList.stream().mapToInt(BankCardLendVo::getCreditLimit).sum(); - map.put("creditLimit",creditLimit); - //信用卡 - map.put("creditCardCount",bankCardLendMapper.selectBankCardLendList(bankCardLendDto).size()); - - AccountsDto dto=new AccountsDto(); - //正常使用 - dto.setStatus("1"); - //信用卡 - dto.setType("2"); - dto.setAccountId(analysisDto.getId()); - List accountsList=accountsMapper.selectAccountsList(dto); - double creditAvailableLimit =0; - double creditBalance =0; - if(accountsList.size()>0){ - creditAvailableLimit=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - creditBalance=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum()*(-1); - } - map.put("creditAvailableLimit",decimalFormat.format(creditAvailableLimit)); - map.put("creditBalance",decimalFormat.format(creditBalance)); - - - //实际账单 - double actualCreditBill = creditCardBillVoList.stream().mapToDouble(CreditCardBillVo::getBillAmount).sum(); - map.put("actualCreditBill", decimalFormat.format(actualCreditBill)); - - - List creditAnalysisList=new ArrayList<>(); - - if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (CreditCardBillVo creditCardBillVo:creditCardBillVoList - ) { - String monthString=dateFormat.format(creditCardBillVo.getBillDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - - for (String staticsTime :staticsTimeList - ) { - String details=""; - double actualCreditBillMonth=0; - for (CreditCardBillVo creditCardBillVo:creditCardBillVoList - ) { - String monthString=dateFormat.format(creditCardBillVo.getBillDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth+=creditCardBillVo.getBillAmount(); - details+=creditCardBillVo.getBankNameCode()+"账单"+creditCardBillVo.getBillAmount()+";
"; - } - } - CreditCardBillVo analysisVo=new CreditCardBillVo(); - analysisVo.setBillAmount(Double.parseDouble(decimalFormat.format(actualCreditBillMonth))); - analysisVo.setName(staticsTime); - analysisVo.setRemark(details); - creditAnalysisList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (CreditCardBillVo creditCardBillVo:creditCardBillVoList - ) { - String yearString=dateFormat.format(creditCardBillVo.getBillDate()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (CreditCardBillVo creditCardBillVo:creditCardBillVoList - ) { - String yearString=dateFormat.format(creditCardBillVo.getBillDate()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=creditCardBillVo.getBillAmount(); - } - } - CreditCardBillVo analysisVo=new CreditCardBillVo(); - analysisVo.setBillAmount(Double.parseDouble(decimalFormat.format(actualCreditBillYear))); - analysisVo.setName(staticsTime); - creditAnalysisList.add(analysisVo); - - } - - } - //平均账单 - int timesCount=creditAnalysisList.size(); - double averageCreditBill=0; - if(timesCount!=0){ - averageCreditBill= actualCreditBill /timesCount; - } - //使用率 - double creditBillRate; - if (creditLimit != 0) { - creditBillRate= ((creditBalance) * 100) /creditLimit; - }else { - creditBillRate= 0; - } - map.put("creditBillRate", decimalFormat.format(creditBillRate)); - map.put("averageCreditBill", decimalFormat.format(averageCreditBill)); - ArrayList> creditBillList = new ArrayList<>(); - ArrayList> tableCreditBillList = new ArrayList<>(); - for (CreditCardBillVo creditCardBillVo:creditAnalysisList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", creditCardBillVo.getName()); - datamap.put("detail", creditCardBillVo.getRemark()); - datamap.put("value", decimalFormat.format(creditCardBillVo.getBillAmount())); - tableCreditBillList.add(datamap); - } - Collections.reverse(creditAnalysisList); - for (CreditCardBillVo creditCardBillVo:creditAnalysisList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", creditCardBillVo.getName()); - datamap.put("value", decimalFormat.format(creditCardBillVo.getBillAmount())); - creditBillList.add(datamap); - } - //列表 - map.put("creditBillList",creditBillList); - map.put("tableCreditBillList",tableCreditBillList); - - return map; - } - - @Override - public Map getFuturesStocksAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-1)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - //获取数据 - List futureStocksBillVoList=new ArrayList<>(); - FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto(); - futureStocksBillDto.setStartMonth(analysisDto.getStartTime().substring(0,7)); - futureStocksBillDto.setEndMonth(analysisDto.getEndTime().substring(0,7)); - futureStocksBillDto.setFutureStocksId(analysisDto.getId()); - if(analysisDto.getDataType()==null){ - futureStocksBillDto.setType("1"); - futureStocksBillVoList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - //期货累计收益 - double accumulateFutures = futureStocksBillVoList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("accumulateFutures", decimalFormat.format(accumulateFutures)); - - futureStocksBillDto.setType("2"); - futureStocksBillVoList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - //股票累计收益 - double accumulateStocks = futureStocksBillVoList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("accumulateStocks", decimalFormat.format(accumulateStocks)); - } - - futureStocksBillDto.setType(analysisDto.getDataType()); - futureStocksBillVoList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); - //修改名称加卡号 - for (FutureStocksBillVo futureStocksBill : futureStocksBillVoList) { - if(futureStocksBill.getFutureStocksCode()!=null){ - futureStocksBill.setFutureStocksNameCode(futureStocksBill.getFutureStocksName()+"("+ futureStocksBill.getFutureStocksCode()+")"); - }else { - futureStocksBill.setFutureStocksNameCode(futureStocksBill.getFutureStocksName()); - } - } - //累计收益 - double accumulateIncome = futureStocksBillVoList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).sum(); - map.put("accumulateIncome", decimalFormat.format(accumulateIncome)); - - List futureStocksBillList=new ArrayList<>(); - - if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillVoList - ) { - - String monthString=dateFormat.format(futureStocksBillVo.getBillDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - - } - } - for (String staticsTime :staticsTimeList - ) { - String details=""; - double actualCreditBillMonth=0; - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillVoList - ) { - String monthString=dateFormat.format(futureStocksBillVo.getBillDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth+=futureStocksBillVo.getBillAmount(); - details+=futureStocksBillVo.getFutureStocksNameCode()+"收益"+futureStocksBillVo.getBillAmount()+";
"; - } - } - FutureStocksBillVo analysisVo=new FutureStocksBillVo(); - analysisVo.setBillAmount(Double.parseDouble(decimalFormat.format(actualCreditBillMonth))); - analysisVo.setName(staticsTime); - analysisVo.setRemark(details); - futureStocksBillList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillVoList - ) { - String yearString=dateFormat.format(futureStocksBillVo.getBillDate()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillVoList - ) { - String yearString=dateFormat.format(futureStocksBillVo.getBillDate()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=futureStocksBillVo.getBillAmount(); - } - } - FutureStocksBillVo analysisVo=new FutureStocksBillVo(); - analysisVo.setBillAmount(Double.parseDouble(decimalFormat.format(actualCreditBillYear))); - analysisVo.setName(staticsTime); - futureStocksBillList.add(analysisVo); - - } - - } - //平均收益 - int timesCount=futureStocksBillList.size(); - double averageIncome=0; - if(timesCount!=0){ - averageIncome= accumulateIncome /timesCount; - } - map.put("averageIncome", decimalFormat.format(averageIncome)); - // 最大值,最小值 - double maxRevenue=0; - double maxLoss=0; - if(futureStocksBillList.size()>0){ - maxRevenue = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).max().getAsDouble(); - maxLoss = futureStocksBillList.stream().mapToDouble(FutureStocksBillVo::getBillAmount).min().getAsDouble(); - } - map.put("maxRevenue", decimalFormat.format(maxRevenue)); - map.put("maxLoss", decimalFormat.format(maxLoss)); - - ArrayList> futuresStocksList = new ArrayList<>(); - ArrayList> tableFuturesStocksList = new ArrayList<>(); - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", futureStocksBillVo.getName()); - datamap.put("detail", futureStocksBillVo.getRemark()); - datamap.put("value", decimalFormat.format(futureStocksBillVo.getBillAmount())); - tableFuturesStocksList.add(datamap); - } - Collections.reverse(futureStocksBillList); - for (FutureStocksBillVo futureStocksBillVo:futureStocksBillList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", futureStocksBillVo.getName()); - datamap.put("value", decimalFormat.format(futureStocksBillVo.getBillAmount())); - futuresStocksList.add(datamap); - } - //列表 - map.put("futuresStocksList",futuresStocksList); - map.put("tableFuturesStocksList",tableFuturesStocksList); - - return map; - } - - @Override - public Map getInstallmentHistoryAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-1)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - //未结清网贷数据 - InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); - InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); - detailDto.setType(analysisDto.getDataType()); - detailDto.setState("0"); - detailDto.setBankCardLendId(analysisDto.getId()); - List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - //未结清本息 - double unClearedDetail = 0; - if(detailList.size()>0){ - unClearedDetail=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("unClearedDetail",decimalFormat.format(unClearedDetail)); - - //未结清本金 - double unClearedPrincipal = 0; - if(detailList.size()>0){ - unClearedPrincipal=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); - } - map.put("unClearedPrincipal",decimalFormat.format(unClearedPrincipal)); - - //未结清利息 - double unClearedInterest = 0; - if(detailList.size()>0){ - unClearedInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); - } - map.put("unClearedInterest",decimalFormat.format(unClearedInterest)); - - //未结清账户数 - installmentHistoryDto.setState("0"); - installmentHistoryDto.setType(analysisDto.getDataType()); - installmentHistoryDto.setBankCardLendId(analysisDto.getId()); - List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - int unclearedDetailCount = installmentHistoryList.size(); - map.put("unclearedDetailCount",unclearedDetailCount); - - //网贷当月应还款 - detailDto.setStartDate(analysisDto.getStartTime()); - detailDto.setEndDate(analysisDto.getEndTime()); - detailDto.setState(""); - detailDto.setType(analysisDto.getDataType()); - - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double dueDetail =0; - if(detailList.size()>0){ - dueDetail=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("dueDetail",decimalFormat.format(dueDetail)); - - double dueInterest =0; - if(detailList.size()>0){ - dueInterest=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getInterest).sum(); - } - map.put("dueInterest",decimalFormat.format(dueInterest)); - - double duePrincipal =0; - if(detailList.size()>0){ - duePrincipal=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getPrincipal).sum(); - } - map.put("duePrincipal",decimalFormat.format(duePrincipal)); - - //网贷当月已还款 - detailDto.setState("1"); - detailDto.setType(analysisDto.getDataType()); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - double repaidDetail =0; - if(detailList.size()>0){ - repaidDetail=detailList.stream().mapToDouble(InstallmentHistoryDetailVo::getCurrentAmount).sum(); - } - map.put("repaidDetail",decimalFormat.format(repaidDetail)); - - //网贷剩余还款 - map.put("leftDetail",decimalFormat.format(dueDetail-repaidDetail)); - - - //获取数据,未还款 - detailDto.setStartDate(analysisDto.getStartTime()); - detailDto.setEndDate(analysisDto.getEndTime()); - detailDto.setState("0"); - detailDto.setType(analysisDto.getDataType()); - detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - - - List installmentHistoryDetailList =new ArrayList<>(); - if("1".equals(analysisDto.getType())){ - //日列表 - List staticsTimeList=new ArrayList<>(); - for (InstallmentHistoryDetailVo vo:detailList - ) { - String dayString=dateFormat.format(vo.getRepaymentDate()); - - if(!staticsTimeList.contains(dayString)){ - staticsTimeList.add(dayString); - } - } - - for (String staticsTime :staticsTimeList - ) { - List> detailItems = new ArrayList<>(); - double actualCreditBillDay=0; - for (InstallmentHistoryDetailVo vo:detailList - ) { - String dayString=dateFormat.format(vo.getRepaymentDate()); - - if(staticsTime.equals(dayString)){ - actualCreditBillDay+=vo.getCurrentAmount(); - - // 创建明细项 - Map detailItem = new HashMap<>(); - detailItem.put("id", vo.getId()); - detailItem.put("bankCardLendName", vo.getBankCardLendName()); - detailItem.put("repaymentDate", dateFormat.format(vo.getRepaymentDate())); - detailItem.put("currentAmount", vo.getCurrentAmount()); - detailItem.put("principal", vo.getPrincipal()); - detailItem.put("interest", vo.getInterest()); - detailItems.add(detailItem); - } - } - InstallmentHistoryDetailVo analysisVo=new InstallmentHistoryDetailVo(); - analysisVo.setCurrentAmount(actualCreditBillDay); - analysisVo.setRemark(staticsTime); - // 将明细列表转为JSON字符串存储 - analysisVo.setBankCardLendName(JSON.toJSONString(detailItems)); - installmentHistoryDetailList.add(analysisVo); - } - - //年查询 - } - else - if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (InstallmentHistoryDetailVo vo:detailList - ) { - String monthString=dateFormat.format(vo.getRepaymentDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillMonth=0; - for (InstallmentHistoryDetailVo vo:detailList - ) { - String monthString=dateFormat.format(vo.getRepaymentDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth+=vo.getCurrentAmount(); - } - } - InstallmentHistoryDetailVo analysisVo=new InstallmentHistoryDetailVo(); - analysisVo.setCurrentAmount(Double.parseDouble(decimalFormat.format(actualCreditBillMonth))); - analysisVo.setRemark(staticsTime); - installmentHistoryDetailList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (InstallmentHistoryDetailVo vo:detailList - ) { - String yearString=dateFormat.format(vo.getRepaymentDate()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (InstallmentHistoryDetailVo vo:detailList - ) { - String yearString=dateFormat.format(vo.getRepaymentDate()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=vo.getCurrentAmount(); - } - } - InstallmentHistoryDetailVo analysisVo=new InstallmentHistoryDetailVo(); - analysisVo.setCurrentAmount(Double.parseDouble(decimalFormat.format(actualCreditBillYear))); - analysisVo.setRemark(staticsTime); - installmentHistoryDetailList.add(analysisVo); - - } - - } - - ArrayList> historyDetailList = new ArrayList<>(); - ArrayList> tableHistoryDetailList = new ArrayList<>(); - for (InstallmentHistoryDetailVo vo:installmentHistoryDetailList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getCurrentAmount())); - // 解析明细JSON字符串 - if (StringUtils.isNotEmpty(vo.getBankCardLendName())) { - try { - Object detailListObj = JSON.parse(vo.getBankCardLendName()); - datamap.put("detailList", detailListObj); - } catch (Exception e) { - // 如果解析失败,保持原来的字符串格式 - datamap.put("detail", vo.getBankCardLendName()); - } - } - tableHistoryDetailList.add(datamap); - } - Collections.reverse(installmentHistoryDetailList); - for (InstallmentHistoryDetailVo vo:installmentHistoryDetailList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getCurrentAmount())); - historyDetailList.add(datamap); - } - //列表 - map.put("historyDetailList",historyDetailList); - map.put("tableHistoryDetailList",tableHistoryDetailList); - - return map; - } - - - @Override - public Map getCreditRecordAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - - } - } - CreditReportQueryRecordDto dto=new CreditReportQueryRecordDto(); - dto.setQueryDateStart(analysisDto.getEndTime()); - Date queryDate=DateUtils.getNowDate(); - if(dto.getQueryDateStart()!=null){ - try { - queryDate=dateFormat.parse(dto.getQueryDateStart()); - dto.setQueryDateEnd(dto.getQueryDateStart()); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - dto.setQueryType("1"); - - Calendar calendarStart = Calendar.getInstance(); - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -1); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastOneMonths",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -2); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastTwoMonths",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -3); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastThreeMonths",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -6); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastSixMonths",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -12); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastOneYears",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -24); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - map.put("lastTwoYears",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -6); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - dto.setType("5"); - dto.setQueryType("2"); - map.put("lastSixMonthPersonalCount",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - - dto.setQueryDateStart(""); - dto.setType("5"); - dto.setQueryType("2"); - map.put("totalPersonalCount",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - calendarStart.setTime(queryDate); - calendarStart.add(Calendar.MONTH, -24); - dto.setQueryDateStart(dateFormat.format(calendarStart.getTime())); - dto.setType("4"); - map.put("lastTwoYearsAfterLoan",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - - dto.setQueryDateStart(""); - dto.setType("4"); - map.put("totalAfterLoan",creditReportQueryRecordMapper.selectCreditReportQueryRecordList(dto).size()); - - CreditReportQueryRecordDto detailDto=new CreditReportQueryRecordDto(); - //获取数据 - detailDto.setQueryDateEnd(analysisDto.getEndTime()); - detailDto.setQueryDateStart(analysisDto.getStartTime()); - detailDto.setQueryType("1"); - List detailList=creditReportQueryRecordMapper.selectCreditReportQueryRecordList(detailDto); - - List queryRecordList =new ArrayList<>(); - - if("1".equals(analysisDto.getType())){ - //日列表 - List staticsTimeList=new ArrayList<>(); - for (CreditReportQueryRecordVo vo:detailList - ) { - String dayString=dateFormat.format(vo.getQueryDate()); - - if(!staticsTimeList.contains(dayString)){ - staticsTimeList.add(dayString); - } - } - - for (String staticsTime :staticsTimeList - ) { - String details=""; - int actualCreditBillDay=0; - for (CreditReportQueryRecordVo vo:detailList - ) { - String dayString=dateFormat.format(vo.getQueryDate()); - - if(staticsTime.equals(dayString)){ - actualCreditBillDay+=vo.getQueryCount(); - details+=vo.getQueryInstitution()+"查询"+vo.getQueryCount()+"次;
"; - } - } - CreditReportQueryRecordVo analysisVo=new CreditReportQueryRecordVo(); - analysisVo.setQueryCount(actualCreditBillDay); - analysisVo.setRemark(staticsTime); - analysisVo.setQueryInstitution(details); - queryRecordList.add(analysisVo); - } - - //年查询 - } - else if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (CreditReportQueryRecordVo vo:detailList - ) { - String monthString=dateFormat.format(vo.getQueryDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - - for (String staticsTime :staticsTimeList - ) { - int actualCreditBillMonth=0; - for (CreditReportQueryRecordVo vo:detailList - ) { - String monthString=dateFormat.format(vo.getQueryDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth+=vo.getQueryCount(); - } - } - CreditReportQueryRecordVo analysisVo=new CreditReportQueryRecordVo(); - analysisVo.setQueryCount(actualCreditBillMonth); - analysisVo.setRemark(staticsTime); - queryRecordList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (CreditReportQueryRecordVo vo:detailList - ) { - String yearString=dateFormat.format(vo.getQueryDate()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - int actualCreditBillYear=0; - for (CreditReportQueryRecordVo vo:detailList - ) { - String yearString=dateFormat.format(vo.getQueryDate()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=vo.getQueryCount(); - } - } - CreditReportQueryRecordVo analysisVo=new CreditReportQueryRecordVo(); - analysisVo.setQueryCount(actualCreditBillYear); - analysisVo.setRemark(staticsTime); - queryRecordList.add(analysisVo); - - } - - } - - ArrayList> creditRecordsList = new ArrayList<>(); - ArrayList> creditTableRecordsList = new ArrayList<>(); - for (CreditReportQueryRecordVo vo:queryRecordList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", vo.getQueryCount()); - datamap.put("detail", vo.getQueryInstitution()); - creditTableRecordsList.add(datamap); - } - Collections.reverse(queryRecordList); - for (CreditReportQueryRecordVo vo:queryRecordList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", vo.getQueryCount()); - creditRecordsList.add(datamap); - } - //列表 - map.put("creditRecordsList",creditRecordsList); - map.put("tableCreditRecordsList",creditTableRecordsList); - - return map; - } - - - @Override - public Map getInstallmentSettledAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-1)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-59)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-10)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - //已结清网贷数据 - InstallmentHistoryDto installmentHistoryDto=new InstallmentHistoryDto(); - installmentHistoryDto.setStartMonth(analysisDto.getStartTime().substring(0,7)); - installmentHistoryDto.setEndMonth(analysisDto.getEndTime().substring(0,7)); - installmentHistoryDto.setState("1"); - installmentHistoryDto.setType(analysisDto.getDataType()); - installmentHistoryDto.setBankCardLendId(analysisDto.getId()); - List installmentHistoryList=installmentHistoryMapper.selectInstallmentHistoryList(installmentHistoryDto); - for (InstallmentHistoryVo installmentHistory : installmentHistoryList) { - if(installmentHistory.getBankCode()!=null){ - installmentHistory.setBankNameCode(installmentHistory.getBankName()+"("+ StringUtils.getLastNumberChars(4,installmentHistory.getBankCode()+")")); - }else { - installmentHistory.setBankNameCode(installmentHistory.getBankName()); - } - } - double clearedPrincipal = 0; - double totalInterest = 0; - if(installmentHistoryList.size()>0){ - clearedPrincipal=installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getInstallmentAmount).sum(); - totalInterest=installmentHistoryList.stream().mapToDouble(InstallmentHistoryVo::getTotalInterest).sum(); - } - map.put("clearedPrincipal",decimalFormat.format(clearedPrincipal)); - map.put("totalInterest",decimalFormat.format(totalInterest)); - - map.put("clearedTotal",decimalFormat.format(totalInterest+clearedPrincipal)); - int clearedCount = installmentHistoryList.size(); - map.put("clearedCount",clearedCount); - - - List installmentHistoryVoList =new ArrayList<>(); - - if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (InstallmentHistoryVo vo:installmentHistoryList - ) { - String monthString=dateFormat.format(vo.getInstallmentDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - for (String staticsTime :staticsTimeList - ) { - String details=""; - double actualCreditBillMonth=0; - for (InstallmentHistoryVo vo:installmentHistoryList - ) { - String monthString=dateFormat.format(vo.getInstallmentDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - double total=vo.getInstallmentAmount()+vo.getTotalInterest(); - BigDecimal bigInstallmentAmount=new BigDecimal(decimalFormat.format( vo.getInstallmentAmount())); - BigDecimal bigTotalInterest=new BigDecimal(decimalFormat.format( vo.getTotalInterest())); - BigDecimal bigDecimal=new BigDecimal(decimalFormat.format( total)); - actualCreditBillMonth+=bigDecimal.doubleValue(); - //2是信用卡,3是网贷 - if(vo.getType().equals("2")){ - details+=vo.getBankNameCode()+"于"+dateFormat.format(vo.getInstallmentDate())+"分期"+bigInstallmentAmount.doubleValue()+",利息"+bigTotalInterest.doubleValue()+",分期本息合计"+bigDecimal.doubleValue()+",结清日期"+dateFormat.format(vo.getCloseDate())+";
"; - } - if(vo.getType().equals("3")){ - details+=vo.getBankNameCode()+"于"+dateFormat.format(vo.getInstallmentDate())+"借款"+bigInstallmentAmount.doubleValue()+",利息"+bigTotalInterest.doubleValue()+",借款本息合计"+bigDecimal.doubleValue()+",结清日期"+dateFormat.format(vo.getCloseDate())+";
"; - } - - } - } - InstallmentHistoryVo analysisVo=new InstallmentHistoryVo(); - analysisVo.setInstallmentAmount(Double.parseDouble(decimalFormat.format(actualCreditBillMonth))); - analysisVo.setRemark(staticsTime); - analysisVo.setName(details); - installmentHistoryVoList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (InstallmentHistoryVo vo:installmentHistoryList - ) { - String yearString=dateFormat.format(vo.getInstallmentDate()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (InstallmentHistoryVo vo:installmentHistoryList - ) { - String yearString=dateFormat.format(vo.getInstallmentDate()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=vo.getInstallmentAmount()+vo.getTotalInterest(); - } - } - InstallmentHistoryVo analysisVo=new InstallmentHistoryVo(); - analysisVo.setInstallmentAmount(Double.parseDouble(decimalFormat.format(actualCreditBillYear))); - analysisVo.setRemark(staticsTime); - installmentHistoryVoList.add(analysisVo); - - } - - } - - ArrayList> historyList = new ArrayList<>(); - ArrayList> tableHistoryList = new ArrayList<>(); - for (InstallmentHistoryVo vo:installmentHistoryVoList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("detail", vo.getName()); - datamap.put("value", decimalFormat.format(vo.getInstallmentAmount())); - tableHistoryList.add(datamap); - } - Collections.reverse(installmentHistoryVoList); - for (InstallmentHistoryVo vo:installmentHistoryVoList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getInstallmentAmount())); - historyList.add(datamap); - } - //列表 - map.put("historyList",historyList); - map.put("tableHistoryList",tableHistoryList); - - return map; - } - - @Override - public Map getAccountsAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - AccountsDto dto=new AccountsDto(); - //正常使用 - dto.setStatus("1"); - //储蓄卡 - dto.setType("1"); - //只计算储蓄卡账户的余额 - dto.setRepayFlag(""); - double debitAllBalance =0; - List accountsList=accountsMapper.selectAccountsList(dto); - if(accountsList.size()>0){ - debitAllBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("debitAllBalance",decimalFormat.format(debitAllBalance)); - - //只计算储蓄卡账户的余额 - dto.setRepayFlag("1"); - accountsList=accountsMapper.selectAccountsList(dto); - List IaccountsList=accountsList.stream().filter(x -> x.getDebitType().equals("1")).collect(Collectors.toList()); - List IIaccountsList=accountsList.stream().filter(x -> x.getDebitType().equals("2")).collect(Collectors.toList()); - double debitBalance =0; - double idebitBalance =0; - double iidebitBalance =0; - if(accountsList.size()>0){ - debitBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - if(IaccountsList.size()>0){ - idebitBalance=IaccountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - if(IIaccountsList.size()>0){ - iidebitBalance=IIaccountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("debitBalance",decimalFormat.format(debitBalance)); - map.put("idebitBalance",decimalFormat.format(idebitBalance)); - map.put("iidebitBalance",decimalFormat.format(iidebitBalance)); - - - map.put("debitBalance",decimalFormat.format(debitBalance)); - //信用卡 - dto.setType("2"); - dto.setRepayFlag(""); - accountsList=accountsMapper.selectAccountsList(dto); - double creditAvailableLimit =0; - double creditBalance =0; - if(accountsList.size()>0){ - creditAvailableLimit=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - creditBalance=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum(); - } - map.put("creditAvailableLimit",decimalFormat.format(creditAvailableLimit)); - map.put("creditBalance",decimalFormat.format(creditBalance)); - - //投资账户 - dto.setType("5"); - accountsList=accountsMapper.selectAccountsList(dto); - List stocksList=accountsList.stream().filter(x -> x.getInvestType().equals("2")).collect(Collectors.toList()); - List futuresList=accountsList.stream().filter(x -> x.getInvestType().equals("1")).collect(Collectors.toList()); - double investBalance =0; - double stocksBalance =0; - double futuresBalance =0; - if(accountsList.size()>0){ - investBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - if(stocksList.size()>0){ - stocksBalance=stocksList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - if(futuresList.size()>0){ - futuresBalance=futuresList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("investBalance",decimalFormat.format(investBalance)); - map.put("stocksBalance",decimalFormat.format(stocksBalance)); - map.put("futuresBalance",decimalFormat.format(futuresBalance)); - - //借贷账户 - dto.setType("3"); - accountsList=accountsMapper.selectAccountsList(dto); - double lendAccountBalance =0; - if(accountsList.size()>0){ - lendAccountBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum(); - } - map.put("lendAccountBalance",decimalFormat.format(lendAccountBalance)); - - dto.setType(analysisDto.getDataType()); - - accountsList=accountsMapper.selectAccountsList(dto); - - //修改名称加卡号 - for (AccountsVo accounts : accountsList) { - String typeName=""; - switch (accounts.getType()){ - case "1" : - typeName="储蓄账户-"; - break; - case "2" : - typeName="信用卡账户-"; - break; - case "3" : - typeName="借贷账户-"; - break; - case "5" : - typeName="投资账户-"; - break; - case "6" : - typeName="POS机账户-"; - break; - } - if(accounts.getCode()!=null){ - accounts.setNameCode(typeName+accounts.getName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")); - }else { - accounts.setNameCode(accounts.getName()); - } - } - ArrayList> accountsBalancesList = new ArrayList<>(); - - for (AccountsVo vo:accountsList - ) { - Map datamap = new HashMap<>(); - datamap.put("account", vo.getNameCode()); - datamap.put("availableLimit", vo.getAvailableLimit()); - accountsBalancesList.add(datamap); - } - //列表 - map.put("accountsBalancesList",accountsBalancesList); - - List creditList=statisticAnalysisMapper.selectCreditCardList(new BankCardLendDto()); - ArrayList> creditBalancesList = new ArrayList<>(); - for (AccountsVo vo:creditList - ) { - Map datamap = new HashMap<>(); - datamap.put("account", vo.getName()); - datamap.put("availableLimit", vo.getAvailableLimit()); - creditBalancesList.add(datamap); - } - //信用卡列表 - map.put("creditBalancesList",creditBalancesList); - - - return map; - } - - @Override - public Map getPosAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.###"); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - - } - } - AccountsTransferRecordDto dto=new AccountsTransferRecordDto(); - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - dto.setType("1"); - dto.setPosId(analysisDto.getId()); - List transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(dto); - - double amount =0; - double commission =0; - int count =0; - double actualAmount =0; - if(transferList.size()>0){ - commission=transferList.stream().mapToDouble(AccountsTransferRecordVo::getCommission).sum(); - actualAmount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getActualAmount).sum(); - amount=transferList.stream().mapToDouble(AccountsTransferRecordVo::getAmount).sum(); - } - count=transferList.size(); - map.put("amount",decimalFormat.format(amount)); - map.put("commission",decimalFormat.format(commission)); - map.put("actualAmount",decimalFormat.format(actualAmount)); - map.put("count",count); - List queryList =new ArrayList<>(); - - if("1".equals(analysisDto.getType())){ - //日列表 - List staticsTimeList=new ArrayList<>(); - for (AccountsTransferRecordVo vo:transferList - ) { - String dayString=dateFormat.format(vo.getCreateTime()); - - if(!staticsTimeList.contains(dayString)){ - staticsTimeList.add(dayString); - } - } - - for (String staticsTime :staticsTimeList - ) { - String details=""; - double actualCreditBillDay=0; - - for (AccountsTransferRecordVo vo:transferList - ) { - String dayString=dateFormat.format(vo.getCreateTime()); - if(staticsTime.equals(dayString)){ - actualCreditBillDay+=vo.getAmount(); - details+=vo.getOutAccountName()+"于"+dateFormatSecond.format(vo.getCreateTime())+"在商户【"+vo.getMerchantName()+"】通过POS机【"+vo.getPosName()+"】刷卡消费"+vo.getAmount()+",其中手续费为"+vo.getCommission()+",入账储蓄卡"+vo.getInAccountName()+vo.getActualAmount()+";
"; - } - } - AccountsTransferRecordVo analysisVo=new AccountsTransferRecordVo(); - analysisVo.setAmount(actualCreditBillDay); - analysisVo.setRemark(staticsTime); - analysisVo.setName(details); - queryList.add(analysisVo); - } - - //年查询 - } - else if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (AccountsTransferRecordVo vo:transferList - ) { - String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillMonth=0; - for (AccountsTransferRecordVo vo:transferList - ) { - String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth+=vo.getAmount(); - } - } - AccountsTransferRecordVo analysisVo=new AccountsTransferRecordVo(); - analysisVo.setAmount(actualCreditBillMonth); - analysisVo.setRemark(staticsTime); - queryList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (AccountsTransferRecordVo vo:transferList - ) { - String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (AccountsTransferRecordVo vo:transferList - ) { - String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4); - if(staticsTime.equals(yearString)){ - actualCreditBillYear+=vo.getAmount(); - } - } - AccountsTransferRecordVo analysisVo=new AccountsTransferRecordVo(); - analysisVo.setAmount(actualCreditBillYear); - analysisVo.setRemark(staticsTime); - queryList.add(analysisVo); - - } - - } - - ArrayList> posList = new ArrayList<>(); - ArrayList> tablePosList = new ArrayList<>(); - for (AccountsTransferRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - datamap.put("detail", vo.getName()); - tablePosList.add(datamap); - } - Collections.reverse(queryList); - for (AccountsTransferRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - posList.add(datamap); - } - //列表 - map.put("posList",posList); - map.put("tablePosList",tablePosList); - - return map; - } - - - @Override - public Map getAccountsDealAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.###"); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - - } - } - AccountsDealRecordDto dto=new AccountsDealRecordDto(); - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - dto.setType(analysisDto.getDataType()); - dto.setAccountId(analysisDto.getId()); - dto.setDealType(analysisDto.getDealType()); - dto.setDealCategory(analysisDto.getDealCategory()); - List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(dto); - - double income =0; - double expenses =0; - double posExpenses =0; - double realExpenses =0; - double posIncome=0; - int incomeCount =0; - int posIncomeCount =0; - int expensesCount =0; - int posExpensesCount =0; - int realExpensesCount =0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - - if(vo.getDealType().equals("1")){ - - if(analysisDto.getDataType().equals("5")){ - if(vo.getDealCategory().equals("2")){ - income+=vo.getAmount(); - incomeCount++; - if(vo.getDealCategory().equals("5")){ - posIncome+=vo.getAmount(); - posIncomeCount++; - } - } - } else { - income+=vo.getAmount(); - incomeCount++; - if(vo.getDealCategory().equals("5")){ - posIncome+=vo.getAmount(); - posIncomeCount++; - } - } - } - //支出 - if(vo.getDealType().equals("2")){ - - - if(analysisDto.getDataType().equals("5")){ - if(vo.getDealCategory().equals("2")){ - expenses+=vo.getAmount(); - expensesCount++; - if(vo.getDealCategory().equals("5")){ - posExpenses+=vo.getAmount(); - posExpensesCount++; - } - if(vo.getDealCategory().equals("1")){ - realExpenses+=vo.getAmount(); - realExpensesCount++; - } - } - } else { - expenses+=vo.getAmount(); - expensesCount++; - if(vo.getDealCategory().equals("5")){ - posExpenses+=vo.getAmount(); - posExpensesCount++; - } - if(vo.getDealCategory().equals("1")){ - realExpenses+=vo.getAmount(); - realExpensesCount++; - } - } - } - } - //交易金额 - map.put("amount",decimalFormat.format(income-expenses)); - //收入 - map.put("income",decimalFormat.format(income)); - //pos收入 - map.put("posIncome",decimalFormat.format(posIncome-posExpenses)); - //非pos收入 - map.put("notPosIncome",decimalFormat.format(income-posIncome-posExpenses)); - //支出 - map.put("expenses",decimalFormat.format(expenses)); - //pos支出 - map.put("posExpenses",decimalFormat.format(posExpenses)); - //真实消费 - map.put("realExpenses",decimalFormat.format(realExpenses)); - //收入笔数 - map.put("incomeCount",incomeCount); - //pos收入笔数 - map.put("posIncomeCount",posIncomeCount); - //非pos收入笔数 - map.put("notPosIncomeCount",incomeCount-posIncomeCount); - //支出笔数 - map.put("expensesCount",expensesCount); - //pos支出笔数 - map.put("posExpensesCount",posExpensesCount); - //日常支出消费笔数 - map.put("realExpensesCount",realExpensesCount); - //其他支出笔数 - map.put("otherExpensesCount",expensesCount-posExpensesCount-realExpensesCount); - List queryList =new ArrayList<>(); - - if("1".equals(analysisDto.getType())){ - //日列表 - 优化版本:使用Map避免嵌套循环,预先格式化日期 - Map amountMap = new LinkedHashMap<>(); - Map detailsMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDealRecordVoList) { - // 预先格式化日期,避免重复格式化 - String dayString=dateFormat.format(vo.getCreateTime()); - String timeString=dateFormatSecond.format(vo.getCreateTime()); - - // 获取字典标签(仅在需要时) - if (null != vo.getDealCategory() && !analysisDto.getDataType().equals("5")) { - vo.setDealCategoryName(DictUtils.getDictLabel("deal_category", vo.getDealCategory().toString())); - } - - // 初始化Map - amountMap.putIfAbsent(dayString, 0.0); - detailsMap.putIfAbsent(dayString, new StringBuilder()); - - String remark=""; - if(vo.getRemark()!=null&&StringUtils.isNotEmpty(vo.getRemark())){ - remark=",备注:"+vo.getRemark(); - } - - if(vo.getDealType().equals("1")){ - if(analysisDto.getDataType().equals("5")){ - if(vo.getDealCategory().equals("2")){ - amountMap.put(dayString, amountMap.get(dayString) + vo.getAmount()); - detailsMap.get(dayString).append(vo.getAccountName()).append("于").append(timeString) - .append("交易盈利").append(vo.getAmount()).append(remark).append(";
"); - } - } else { - amountMap.put(dayString, amountMap.get(dayString) + vo.getAmount()); - detailsMap.get(dayString).append(vo.getAccountName()).append("于").append(timeString) - .append("因交易类别【").append(vo.getDealCategoryName()).append("】收入") - .append(vo.getAmount()).append(remark).append(";
"); - } - } - if(vo.getDealType().equals("2")){ - if(analysisDto.getDataType().equals("5")){ - if(vo.getDealCategory().equals("2")){ - amountMap.put(dayString, amountMap.get(dayString) - vo.getAmount()); - detailsMap.get(dayString).append(vo.getAccountName()).append("于").append(timeString) - .append("交易亏损").append(vo.getAmount()).append(remark).append(";
"); - } - } else { - amountMap.put(dayString, amountMap.get(dayString) - vo.getAmount()); - detailsMap.get(dayString).append(vo.getAccountName()).append("于").append(timeString) - .append("因交易类别【").append(vo.getDealCategoryName()).append("】支出") - .append(vo.getAmount()).append(remark).append(";
"); - } - } - } - - // 转换为结果列表 - for (Map.Entry entry : amountMap.entrySet()) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(entry.getValue()); - analysisVo.setRemark(entry.getKey()); - analysisVo.setName(detailsMap.get(entry.getKey()).toString()); - queryList.add(analysisVo); - } - - } - else if("2".equals(analysisDto.getType())){ - //月列表 - 优化版本:使用Map避免嵌套循环 - Map monthAmountMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDealRecordVoList) { - // 预先格式化并截取月份,避免重复操作 - String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7); - - monthAmountMap.putIfAbsent(monthString, 0.0); - - if(vo.getDealType().equals("1")){ - monthAmountMap.put(monthString, monthAmountMap.get(monthString) + vo.getAmount()); - } - if(vo.getDealType().equals("2")){ - monthAmountMap.put(monthString, monthAmountMap.get(monthString) - vo.getAmount()); - } - } - - // 转换为结果列表 - for (Map.Entry entry : monthAmountMap.entrySet()) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(entry.getValue()); - analysisVo.setRemark(entry.getKey()); - queryList.add(analysisVo); - } - - }else if("3".equals(analysisDto.getType())){ - //年列表 - 优化版本:使用Map避免嵌套循环 - Map yearAmountMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDealRecordVoList) { - // 预先格式化并截取年份,避免重复操作 - String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4); - - yearAmountMap.putIfAbsent(yearString, 0.0); - - if(vo.getDealType().equals("1")){ - yearAmountMap.put(yearString, yearAmountMap.get(yearString) + vo.getAmount()); - } - if(vo.getDealType().equals("2")){ - yearAmountMap.put(yearString, yearAmountMap.get(yearString) - vo.getAmount()); - } - } - - // 转换为结果列表 - for (Map.Entry entry : yearAmountMap.entrySet()) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(entry.getValue()); - analysisVo.setRemark(entry.getKey()); - queryList.add(analysisVo); - } - - } - - ArrayList> acccountsList = new ArrayList<>(); - ArrayList> tableAccountsList = new ArrayList<>(); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - datamap.put("detail", vo.getName()); - tableAccountsList.add(datamap); - } - Collections.reverse(queryList); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - acccountsList.add(datamap); - } - //列表 - map.put("acccountsList",acccountsList); - map.put("tableAccountsList",tableAccountsList); - - return map; - } - - @Override - public Map getAccountsOutInAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.###"); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - - } - } - AccountsDealRecordDto dto=new AccountsDealRecordDto(); - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - dto.setDealCategory(analysisDto.getDealCategory()); - List accountsDealRecordVoList=statisticAnalysisMapper.selectAccountsOutInList(dto); - //修改名称加卡号 - for (AccountsDealRecordVo accounts : accountsDealRecordVoList) { - - if(accounts.getCode()!=null){ - accounts.setNameCode(accounts.getAccountName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")); - }else { - accounts.setNameCode(accounts.getAccountName()); - } - } - //收支差额 - double balance =0; - //支出总额 - double totalOutcome =0; - //投资亏损 - double investOutcome =0; - //刷卡手续费 13 - double posExpenses =0; - //信用卡分期利息 14 - double creditInterest =0; - //网贷利息 15 - double onLineInterest=0; - //日常支出 1 - double dailyExpenses=0; - //投资盈利 2 - double investIncome=0; - //工资收入 11 - double salaryIncome=0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - if(vo.getDealType().equals("1")){ - if(vo.getDealCategory().equals("11")){ - salaryIncome+=vo.getAmount(); - } - if(vo.getDealCategory().equals("2")){ - investIncome+=vo.getAmount(); - } - } - //支出 - if(vo.getDealType().equals("2")){ - //非投资支出 - if(!vo.getDealCategory().equals("2")){ - totalOutcome+=vo.getAmount(); - } - if(vo.getDealCategory().equals("1")){ - dailyExpenses+=vo.getAmount(); - } - if(vo.getDealCategory().equals("2")){ - investOutcome+=vo.getAmount(); - } - if(vo.getDealCategory().equals("13")){ - posExpenses+=vo.getAmount(); - } - if(vo.getDealCategory().equals("14")){ - creditInterest+=vo.getAmount(); - } - if(vo.getDealCategory().equals("15")){ - onLineInterest+=vo.getAmount(); - } - } - } - //收支差额 - map.put("balance",decimalFormat.format(investIncome+salaryIncome-totalOutcome-investOutcome)); - //非投资收益支出总额 - map.put("totalOutcome",decimalFormat.format(totalOutcome)); - //投资亏损 - map.put("investOutcome",decimalFormat.format(investOutcome)); - //刷卡手续费 13 - map.put("posExpenses",decimalFormat.format(posExpenses)); - //信用卡分期利息 14 - map.put("creditInterest",decimalFormat.format(creditInterest)); - //网贷利息 15 - map.put("onLineInterest",decimalFormat.format(onLineInterest)); - //日常支出 1 - map.put("dailyExpenses",decimalFormat.format(dailyExpenses)); - //投资收益 2 - map.put("investIncome",decimalFormat.format(investIncome)); - //工资收入 11 - map.put("salaryIncome",decimalFormat.format(salaryIncome)); - //非日常支出 1 - map.put("notDailyExpenses",decimalFormat.format(onLineInterest+creditInterest+posExpenses)); - - List queryList =new ArrayList<>(); - - if("1".equals(analysisDto.getType())){ - //日列表 - List staticsTimeList=new ArrayList<>(); - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - if (null != vo.getDealCategory()) { - vo.setDealCategoryName(DictUtils.getDictLabel("deal_category", vo.getDealCategory().toString())); - } - String dayString=dateFormat.format(vo.getCreateTime()); - - if(!staticsTimeList.contains(dayString)){ - staticsTimeList.add(dayString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillDay=0; - String details=""; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - String dayString=dateFormat.format(vo.getCreateTime()); - - if(staticsTime.equals(dayString)){ - String remark=""; - if(vo.getRemark()!=null&&StringUtils.isNotEmpty(vo.getRemark())){ - remark+=",备注:"+vo.getRemark(); - } - if(vo.getDealType().equals("1")){ - actualCreditBillDay+=vo.getAmount(); - details+=vo.getNameCode()+"于"+dateFormatSecond.format(vo.getCreateTime())+"因交易类别【"+vo.getDealCategoryName()+"】收入"+vo.getAmount()+remark+";
"; - } - if(vo.getDealType().equals("2")){ - actualCreditBillDay-=vo.getAmount(); - details+=vo.getNameCode()+"于"+dateFormatSecond.format(vo.getCreateTime())+"因交易类别【"+vo.getDealCategoryName()+"】支出"+vo.getAmount()+remark+";
"; - } - } - } - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(actualCreditBillDay); - analysisVo.setRemark(staticsTime); - analysisVo.setName(details); - queryList.add(analysisVo); - } - - //年查询 - } - else if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillMonth=0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - String monthString=dateFormat.format(vo.getCreateTime()).substring(0,7); - - if(staticsTime.equals(monthString)){ - if(vo.getDealType().equals("1")){ - actualCreditBillMonth+=vo.getAmount(); - } - if(vo.getDealType().equals("2")){ - actualCreditBillMonth-=vo.getAmount(); - } - } - } - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(actualCreditBillMonth); - analysisVo.setRemark(staticsTime); - queryList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - List staticsTimeList=new ArrayList<>(); - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4); - - if(!staticsTimeList.contains(yearString)){ - staticsTimeList.add(yearString); - } - } - - for (String staticsTime :staticsTimeList - ) { - double actualCreditBillYear=0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - String yearString=dateFormat.format(vo.getCreateTime()).substring(0,4); - if(staticsTime.equals(yearString)){ - if(vo.getDealType().equals("1")){ - actualCreditBillYear+=vo.getAmount(); - } - if(vo.getDealType().equals("2")){ - actualCreditBillYear-=vo.getAmount(); - } - } - } - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(actualCreditBillYear); - analysisVo.setRemark(staticsTime); - queryList.add(analysisVo); - - } - - } - - ArrayList> acccountsList = new ArrayList<>(); - ArrayList> tableAccountsList = new ArrayList<>(); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - datamap.put("detail", vo.getName()); - tableAccountsList.add(datamap); - } - Collections.reverse(queryList); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - acccountsList.add(datamap); - } - //列表 - map.put("acccountsList",acccountsList); - map.put("tableAccountsList",tableAccountsList); - - return map; - } - - @Override - public Map getDailyExpensesAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.###"); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-24)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - if(analysisDto.getEndTime().equals(formatterMonth.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-5)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); - if(analysisDto.getEndTime().equals(sdfYear.format(new Date()))){ - SimpleDateFormat sdf = new SimpleDateFormat("MM-dd"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-"+sdf.format(new Date())); - }else { - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - - } - } - AccountsDealRecordDto dto=new AccountsDealRecordDto(); - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - dto.setAccountId(analysisDto.getId()); - dto.setChildCategory(analysisDto.getChildCategory()); - List accountsDealRecordVoList=statisticAnalysisMapper.selectDailyExpensesList(dto); - List accountsDateList=statisticAnalysisMapper.selectDailyExpensesDateList(dto); - - List queryList =new ArrayList<>(); - if("1".equals(analysisDto.getType())){ - for (AccountsDealRecordVo vo:accountsDateList - ) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(vo.getAmount()); - analysisVo.setRemark(vo.getDateStr()); - queryList.add(analysisVo); - } - - //年查询 - } - else if("2".equals(analysisDto.getType())){ - //月列表 - 优化版本:使用Map避免嵌套循环 - Map monthAmountMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDateList) { - String monthString=vo.getDateStr().substring(0,7); - monthAmountMap.put(monthString, monthAmountMap.getOrDefault(monthString, 0.0) + vo.getAmount()); - } - - for (Map.Entry entry : monthAmountMap.entrySet()) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(entry.getValue()); - analysisVo.setRemark(entry.getKey()); - queryList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - //年列表 - 优化版本:使用Map避免嵌套循环 - Map yearAmountMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDateList) { - String yearString=vo.getDateStr().substring(0,4); - yearAmountMap.put(yearString, yearAmountMap.getOrDefault(yearString, 0.0) + vo.getAmount()); - } - - for (Map.Entry entry : yearAmountMap.entrySet()) { - AccountsDealRecordVo analysisVo=new AccountsDealRecordVo(); - analysisVo.setAmount(entry.getValue()); - analysisVo.setRemark(entry.getKey()); - queryList.add(analysisVo); - } - - } - - ArrayList> acccountsDateList = new ArrayList<>(); - ArrayList> tableAccountsList = new ArrayList<>(); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - tableAccountsList.add(datamap); - } - Collections.reverse(queryList); - for (AccountsDealRecordVo vo:queryList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getRemark()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - acccountsDateList.add(datamap); - } - //列表 - map.put("acccountsDateList",acccountsDateList); - map.put("tableAccountsDateList",tableAccountsList); - - //日常支出 1 - double dailyExpenses=0; - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ){ - if (null != vo.getChildCategory()) { - vo.setName(DictUtils.getDictLabel("daily_expenses", vo.getChildCategory().toString())); - }else{ - vo.setName("未分类"); - } - dailyExpenses+=vo.getAmount(); - } - //日常支出总额 - map.put("dailyExpenses",decimalFormat.format(dailyExpenses)); - if(accountsDealRecordVoList.size()>0){ - map.put("top1Name",accountsDealRecordVoList.get(0).getName()); - map.put("top1",accountsDealRecordVoList.get(0).getAmount()); - } - if(accountsDealRecordVoList.size()>1){ - map.put("top2Name",accountsDealRecordVoList.get(1).getName()); - map.put("top2",accountsDealRecordVoList.get(1).getAmount()); - } - if(accountsDealRecordVoList.size()>2){ - map.put("top3Name",accountsDealRecordVoList.get(2).getName()); - map.put("top3",accountsDealRecordVoList.get(2).getAmount()); - } - if(accountsDealRecordVoList.size()>3){ - map.put("top4Name",accountsDealRecordVoList.get(3).getName()); - map.put("top4",accountsDealRecordVoList.get(3).getAmount()); - } - if(accountsDealRecordVoList.size()>4){ - map.put("top5Name",accountsDealRecordVoList.get(4).getName()); - map.put("top5",accountsDealRecordVoList.get(4).getAmount()); - } - if(accountsDealRecordVoList.size()>5){ - map.put("top6Name",accountsDealRecordVoList.get(5).getName()); - map.put("top6",accountsDealRecordVoList.get(5).getAmount()); - } - if(accountsDealRecordVoList.size()>6){ - map.put("top7Name",accountsDealRecordVoList.get(6).getName()); - map.put("top7",accountsDealRecordVoList.get(6).getAmount()); - } - if(accountsDealRecordVoList.size()>7){ - map.put("top8Name",accountsDealRecordVoList.get(7).getName()); - map.put("top8",accountsDealRecordVoList.get(7).getAmount()); - } - if(accountsDealRecordVoList.size()>8){ - map.put("top9Name",accountsDealRecordVoList.get(8).getName()); - map.put("top9",accountsDealRecordVoList.get(8).getAmount()); - } - if(accountsDealRecordVoList.size()>9){ - map.put("top10Name",accountsDealRecordVoList.get(9).getName()); - map.put("top10",accountsDealRecordVoList.get(9).getAmount()); - } - - if(accountsDealRecordVoList.size()>10){ - map.put("top11Name",accountsDealRecordVoList.get(10).getName()); - map.put("top11",accountsDealRecordVoList.get(10).getAmount()); - } - if(accountsDealRecordVoList.size()>11){ - map.put("top12Name",accountsDealRecordVoList.get(11).getName()); - map.put("top12",accountsDealRecordVoList.get(11).getAmount()); - } - if(accountsDealRecordVoList.size()>12){ - map.put("top13Name",accountsDealRecordVoList.get(12).getName()); - map.put("top13",accountsDealRecordVoList.get(12).getAmount()); - } - if(accountsDealRecordVoList.size()>13){ - map.put("top14Name",accountsDealRecordVoList.get(13).getName()); - map.put("top14",accountsDealRecordVoList.get(13).getAmount()); - } - if(accountsDealRecordVoList.size()>14){ - map.put("top15Name",accountsDealRecordVoList.get(14).getName()); - map.put("top15",accountsDealRecordVoList.get(14).getAmount()); - } - if(accountsDealRecordVoList.size()>15){ - map.put("top16Name",accountsDealRecordVoList.get(15).getName()); - map.put("top16",accountsDealRecordVoList.get(15).getAmount()); - } - ArrayList> acccountsList = new ArrayList<>(); - for (AccountsDealRecordVo vo:accountsDealRecordVoList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", vo.getName()); - datamap.put("value", decimalFormat.format(vo.getAmount())); - acccountsList.add(datamap); - } - //列表 - map.put("accountsList",acccountsList); - - return map; - } - - - @Override - public List getAccountCalendarInfo (AnalysisDto analysisDto) { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 设置日期格式 - List list =new ArrayList<>(); - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - bankCardLendDto.setType("2"); - bankCardLendDto.setStatus("1"); - DecimalFormat decimalFormat = new DecimalFormat("#.###"); - List bankCardVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); - for (BankCardLendVo bankCard : bankCardVoList) { - String nameCode=bankCard.getName()+"("+ StringUtils.getLastNumberChars(4,bankCard.getCode()+")"); - - String payDateStr = analysisDto.getStartTime().split("-")[0] + "-" +analysisDto.getStartTime().split("-")[1] + "-" + String.format("%02d", bankCard.getPayDate()); - AccountCalendarVo payDate = new AccountCalendarVo(); - payDate.setStart(payDateStr); - payDate.setTitle(nameCode+ "还款日"); - payDate.setType(2); - payDate.setAccountId(bankCard.getId()); - list.add(payDate); - //周视图,月份不相同,下个月的也加入数据 - if(!analysisDto.getStartTime().split("-")[1].equals(analysisDto.getEndTime().split("-")[1])&&analysisDto.getType().equals("2")){ - String nextPayDateStr = analysisDto.getStartTime().split("-")[0] + "-" +analysisDto.getEndTime().split("-")[1] + "-" + String.format("%02d", bankCard.getPayDate()); - AccountCalendarVo nextPayDate = new AccountCalendarVo(); - nextPayDate.setStart(nextPayDateStr); - nextPayDate.setTitle(nameCode+ "还款日"); - nextPayDate.setType(2); - nextPayDate.setAccountId(bankCard.getId()); - list.add(nextPayDate); - } - } - CreditCardBillDto creditCardBillDto =new CreditCardBillDto(); - creditCardBillDto.setStartMonth(analysisDto.getStartTime().split("-")[0] + "-" + analysisDto.getStartTime().split("-")[1]); - creditCardBillDto.setEndMonth(analysisDto.getEndTime().split("-")[0] + "-" + analysisDto.getEndTime().split("-")[1]); - List creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto); - //修改名称加卡号 - for (CreditCardBillVo creditCardBill : creditCardBillList) { - String nameCode=creditCardBill.getBankName()+"("+ StringUtils.getLastNumberChars(4,creditCardBill.getBankCode()+")"); - if(creditCardBill.getBankName()!=null){ - String billDateStr = sdf.format(creditCardBill.getBillDate()); - AccountCalendarVo billDate = new AccountCalendarVo(); - billDate.setStart(billDateStr); - billDate.setTitle(nameCode+ "账单:"+creditCardBill.getBillAmount()); - billDate.setType(1); - billDate.setAccountId(creditCardBill.getCreditCardId()); - billDate.setBillDatePeriod(creditCardBill.getBillDatePeriod()); - list.add(billDate); - } - } - - InstallmentHistoryDetailDto detailDto=new InstallmentHistoryDetailDto(); - detailDto.setStartDate(analysisDto.getStartTime()); - detailDto.setEndDate(analysisDto.getEndTime()); - detailDto.setType("3"); - List detailList=installmentHistoryDetailMapper.selectInstallmentHistoryDetailList(detailDto); - for (InstallmentHistoryDetailVo detail : detailList) { - - if(detail.getBankCardLendName()!=null){ - String billDateStr = sdf.format(detail.getRepaymentDate()); - AccountCalendarVo historyDetail = new AccountCalendarVo(); - historyDetail.setStart(billDateStr); - if(detail.getPostingState().equals("0")){ - historyDetail.setTitle(detail.getBankCardLendName()+ "贷款待还:"+detail.getCurrentAmount()); - historyDetail.setType(3); - } - else { - historyDetail.setTitle(detail.getBankCardLendName()+ "贷款已还:"+detail.getPrincipal()); - historyDetail.setType(4); - } - historyDetail.setAccountId(detail.getBankCardLendId()); - list.add(historyDetail); - } - } - //日常支出统计 - AccountsDealRecordDto dto=new AccountsDealRecordDto(); - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - List dailyExpensesList=statisticAnalysisMapper.selectDailyExpensesByDate(dto); - list.addAll(dailyExpensesList); - - - //工资收入统计 - //获取数据 - dto.setEndTime(analysisDto.getEndTime()); - dto.setStartTime(analysisDto.getStartTime()); - List salaryList=statisticAnalysisMapper.selectSalaryByDate(dto); - list.addAll(salaryList); - - - AccountsDealRecordDto dealDto=new AccountsDealRecordDto(); - //获取数据 - dealDto.setEndTime(analysisDto.getEndTime()); - dealDto.setStartTime(analysisDto.getStartTime()); - dealDto.setType("5"); - dealDto.setDealCategory("2"); - List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(dealDto); - //日列表 - 优化版本:使用Map避免嵌套循环 - Map investAmountMap = new LinkedHashMap<>(); - - for (AccountsDealRecordVo vo:accountsDealRecordVoList) { - String dayString=sdf.format(vo.getCreateTime()); - - investAmountMap.putIfAbsent(dayString, 0.0); - - if(vo.getDealType().equals("1")){ - if(vo.getDealCategory().equals("2")){ - investAmountMap.put(dayString, investAmountMap.get(dayString) + vo.getAmount()); - } - } - if(vo.getDealType().equals("2")){ - if(vo.getDealCategory().equals("2")){ - investAmountMap.put(dayString, investAmountMap.get(dayString) - vo.getAmount()); - } - } - } - - for (Map.Entry entry : investAmountMap.entrySet()) { - AccountCalendarVo billDate = new AccountCalendarVo(); - billDate.setStart(entry.getKey()); - billDate.setTitle("投资收益:"+decimalFormat.format(entry.getValue())); - billDate.setType(6); - billDate.setColor("purple"); - list.add(billDate); - } - - AccountsTransferRecordDto posDto=new AccountsTransferRecordDto(); - //获取数据 - posDto.setEndTime(analysisDto.getEndTime()); - posDto.setStartTime(analysisDto.getStartTime()); - posDto.setType("1"); - List transferList=accountsTransferRecordMapper.selectAccountsTransferRecordList(posDto); - //日列表 - 优化版本:使用Map避免嵌套循环 - Map posAmountMap = new LinkedHashMap<>(); - - for (AccountsTransferRecordVo vo:transferList) { - String dayString=sdf.format(vo.getCreateTime()); - posAmountMap.put(dayString, posAmountMap.getOrDefault(dayString, 0.0) + vo.getAmount()); - } - - for (Map.Entry entry : posAmountMap.entrySet()) { - AccountCalendarVo billDate = new AccountCalendarVo(); - billDate.setStart(entry.getKey()); - billDate.setTitle("POS机刷卡:"+decimalFormat.format(entry.getValue())); - billDate.setType(7); - list.add(billDate); - } - - //统一设置事件背景色和字体颜色 - // 1信用卡账单,2信用卡还款日,3贷款待还,4贷款已还,5日常支出,6投资收益,7POS机刷卡,8工资收入 - for (AccountCalendarVo calendar:list - ) { - int type=calendar.getType(); - switch(type){ - case 1: - calendar.setColor("Khaki"); - calendar.setTextColor("DeepPink"); - break; - case 2: - calendar.setColor("LightCoral"); - calendar.setTextColor("SpringGreen"); - break; - case 3: - calendar.setColor("LightPink"); - calendar.setTextColor("Magenta"); - break; - case 4: - calendar.setColor("LightGreen"); - calendar.setTextColor("RoyalBlue"); - break; - case 5: - calendar.setColor("LemonChiffon"); - calendar.setTextColor("MediumBlue"); - break; - case 6: - calendar.setColor("LightBlue"); - calendar.setTextColor("Crimson"); - break; - case 7: - calendar.setColor("LavenderBlush"); - calendar.setTextColor("Black"); - break; - case 8: - calendar.setColor("Ivory"); - calendar.setTextColor("Tomato"); - break; - default: - calendar.setColor("White"); - calendar.setTextColor("DarkViolet"); - break; - } - - } - return list; - } - - @Override - public Map getDebitCardAnalysis(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - AccountsDto dto=new AccountsDto(); - - List debitCardList=statisticAnalysisMapper.selectDebitCardPosList(dto); - double todayCount =0; - double todayAmount =0; - - double sevenDayCount =0; - double sevenDayAmount =0; - - double oneMonthCount =0; - double oneMonthAmount =0; - - double threeMonthCount =0; - double threeMonthAmount =0; - - double sixMonthCount =0; - double sixMonthAmount =0; - - double oneYearCount =0; - double oneYearAmount =0; - - double twoYearCount =0; - double twoYearAmount =0; - - double fiveYearCount =0; - double fiveYearAmount =0; - - double totalCount =0; - double totalAmount =0; - - if(debitCardList.size()>0){ - todayCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTodayCount).sum(); - todayAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTodayAmount).sum(); - - sevenDayCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSevenDayCount).sum(); - sevenDayAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSevenDayAmount).sum(); - - oneMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneMonthCount).sum(); - oneMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneMonthAmount).sum(); - - threeMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getThreeMonthCount).sum(); - threeMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getThreeMonthAmount).sum(); - - sixMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSixMonthCount).sum(); - sixMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSixMonthAmount).sum(); - - oneYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneYearCount).sum(); - oneYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneYearAmount).sum(); - - twoYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTwoYearCount).sum(); - twoYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTwoYearAmount).sum(); - - fiveYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getFiveYearCount).sum(); - fiveYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getFiveYearAmount).sum(); - - totalCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTotalCount).sum(); - totalAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTotalAmount).sum(); - - } - map.put("todayCount",todayCount); - map.put("todayAmount",decimalFormat.format(todayAmount)); - - map.put("sevenDayCount",sevenDayCount); - map.put("sevenDayAmount",decimalFormat.format(sevenDayAmount)); - - - map.put("oneMonthCount",oneMonthCount); - map.put("oneMonthAmount",decimalFormat.format(oneMonthAmount)); - - - map.put("threeMonthCount",threeMonthCount); - map.put("threeMonthAmount",decimalFormat.format(threeMonthAmount)); - - map.put("sixMonthCount",sixMonthCount); - map.put("sixMonthAmount",decimalFormat.format(sixMonthAmount)); - - map.put("oneYearCount",oneYearCount); - map.put("oneYearAmount",decimalFormat.format(oneYearAmount)); - - map.put("twoYearCount",twoYearCount); - map.put("twoYearAmount",decimalFormat.format(twoYearAmount)); - - map.put("fiveYearCount",fiveYearCount); - map.put("fiveYearAmount",decimalFormat.format(fiveYearAmount)); - - map.put("totalCount",totalCount); - map.put("totalAmount",decimalFormat.format(totalAmount)); - - //修改名称加卡号 - for (AccountsDebitPosVo accounts : debitCardList) { - - if(accounts.getCode()!=null){ - accounts.setNameCode(accounts.getName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")); - }else { - accounts.setNameCode(accounts.getName()); - } - } - ArrayList> accountsOneYearList = new ArrayList<>(); - - for (AccountsDebitPosVo vo:debitCardList - ) { - Map datamap = new HashMap<>(); - datamap.put("debitCard", vo.getNameCode()); - datamap.put("amount", vo.getSixMonthAmount()); - accountsOneYearList.add(datamap); - } - //列表 - map.put("debitCardList",accountsOneYearList); - - //表格列表 - map.put("debitCardTableList",debitCardList); - - - return map; - } - - - @Override - public Map getPosStatics(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - AccountsDto dto=new AccountsDto(); - - List debitCardList=statisticAnalysisMapper.selectPosStaticList(dto); - double todayCount =0; - double todayAmount =0; - - double sevenDayCount =0; - double sevenDayAmount =0; - - double oneMonthCount =0; - double oneMonthAmount =0; - - double threeMonthCount =0; - double threeMonthAmount =0; - - double sixMonthCount =0; - double sixMonthAmount =0; - - double oneYearCount =0; - double oneYearAmount =0; - - double twoYearCount =0; - double twoYearAmount =0; - - double fiveYearCount =0; - double fiveYearAmount =0; - - double totalCount =0; - double totalAmount =0; - - if(debitCardList.size()>0){ - todayCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTodayCount).sum(); - todayAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTodayAmount).sum(); - - sevenDayCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSevenDayCount).sum(); - sevenDayAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSevenDayAmount).sum(); - - oneMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneMonthCount).sum(); - oneMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneMonthAmount).sum(); - - threeMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getThreeMonthCount).sum(); - threeMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getThreeMonthAmount).sum(); - - sixMonthCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSixMonthCount).sum(); - sixMonthAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getSixMonthAmount).sum(); - - oneYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneYearCount).sum(); - oneYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getOneYearAmount).sum(); - - twoYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTwoYearCount).sum(); - twoYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTwoYearAmount).sum(); - - fiveYearCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getFiveYearCount).sum(); - fiveYearAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getFiveYearAmount).sum(); - - totalCount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTotalCount).sum(); - totalAmount=debitCardList.stream().mapToDouble(AccountsDebitPosVo::getTotalAmount).sum(); - - } - map.put("todayCount",todayCount); - map.put("todayAmount",decimalFormat.format(todayAmount)); - - map.put("sevenDayCount",sevenDayCount); - map.put("sevenDayAmount",decimalFormat.format(sevenDayAmount)); - - - map.put("oneMonthCount",oneMonthCount); - map.put("oneMonthAmount",decimalFormat.format(oneMonthAmount)); - - - map.put("threeMonthCount",threeMonthCount); - map.put("threeMonthAmount",decimalFormat.format(threeMonthAmount)); - - map.put("sixMonthCount",sixMonthCount); - map.put("sixMonthAmount",decimalFormat.format(sixMonthAmount)); - - map.put("oneYearCount",oneYearCount); - map.put("oneYearAmount",decimalFormat.format(oneYearAmount)); - - map.put("twoYearCount",twoYearCount); - map.put("twoYearAmount",decimalFormat.format(twoYearAmount)); - - map.put("fiveYearCount",fiveYearCount); - map.put("fiveYearAmount",decimalFormat.format(fiveYearAmount)); - - map.put("totalCount",totalCount); - map.put("totalAmount",decimalFormat.format(totalAmount)); - - //修改名称加卡号 - for (AccountsDebitPosVo accounts : debitCardList) { - accounts.setNameCode(accounts.getName()+"-"+ accounts.getMerchantName()); - } - ArrayList> accountsOneYearList = new ArrayList<>(); - - for (AccountsDebitPosVo vo:debitCardList - ) { - Map datamap = new HashMap<>(); - datamap.put("pos", vo.getNameCode()); - datamap.put("amount", vo.getSixMonthAmount()); - accountsOneYearList.add(datamap); - } - //列表 - map.put("posList",accountsOneYearList); - - //表格列表 - map.put("posTableList",debitCardList); - - - return map; - } - - /** - * 查询记账账户列表 - * - * @param accountsDto 记账账户 - * @return 记账账户 - */ - @Override - public List selectAccountsList(AccountsDto accountsDto) - { - List accountsList=statisticAnalysisMapper.selectAccountsList(accountsDto); - //修改名称加卡号 - for (AccountsVo accounts : accountsList) { - String typeName=""; - switch (accounts.getType()){ - case "1" : - typeName="储蓄账户-"; - break; - case "2" : - typeName="信用卡账户-"; - break; - case "3" : - typeName="借贷账户-"; - break; - case "5" : - typeName="投资账户-"; - break; - case "6" : - typeName="POS机账户-"; - break; - } - if(accounts.getCode()!=null){ - accounts.setNameCodeAvailableLimit(accounts.getName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")+"-可用额度("+accounts.getAvailableLimit()+")"); - accounts.setTypeNameCodeAvailableLimit(typeName+accounts.getName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")+"-可用额度("+accounts.getAvailableLimit()+")"); - accounts.setNameCode(accounts.getName()+"("+ StringUtils.getLastNumberChars(4,accounts.getCode()+")")); - }else { - accounts.setNameCodeAvailableLimit(accounts.getName()); - accounts.setTypeNameCodeAvailableLimit(typeName+accounts.getName()); - accounts.setNameCode(accounts.getName()); - } - if(!"null".equals(String.valueOf(accounts.getBillDate()))) { - accounts.setBillDateName(accounts.getBillDate()+"号"); - } - if(!"null".equals(String.valueOf(accounts.getPayDate()))) { - accounts.setPayDateName(accounts.getPayDate()+"号"); - } - String daysBetween="无交易记录"; - if(accounts.getRecentDealTime()!=null){ - daysBetween = DateUtils.timeDistance(new Date(),accounts.getRecentDealTime()); - } - accounts.setDuration(daysBetween); - } - return accountsList; - } - - - @Override - public Map selectOpenCardList(AnalysisDto analysisDto) { - //返回数据 - HashMap map = new HashMap<>(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - //月查询 - if(analysisDto.getType().equals("2")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),0)); - String startTime=dateFormat.format(DateUtils.addMonths(DateUtils.getNowDate(),-2400)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-31"); - } - - //年查询 - }else if(analysisDto.getType().equals("3")){ - if(StringUtils.isEmpty(analysisDto.getStartTime())&&StringUtils.isEmpty(analysisDto.getEndTime())){ - String endTime=dateFormat.format(DateUtils.getNowDate()); - String startTime=dateFormat.format(DateUtils.addYears(DateUtils.getNowDate(),-500)); - analysisDto.setStartTime(startTime); - analysisDto.setEndTime(endTime); - }else { - analysisDto.setStartTime(analysisDto.getStartTime()+"-01-01"); - analysisDto.setEndTime(analysisDto.getEndTime()+"-12-31"); - } - } - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - - //获取数据 - List bankCardLendVoList=new ArrayList<>(); - BankCardLendDto bankCardLendDto=new BankCardLendDto(); - bankCardLendDto.setStartMonth(analysisDto.getStartTime().substring(0,7)); - bankCardLendDto.setEndMonth(analysisDto.getEndTime().substring(0,7)); - //只统计一类卡和二类卡 - bankCardLendDto.setStaticFlag("1"); - bankCardLendVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); - //修改名称加卡号 - for (BankCardLendVo vo : bankCardLendVoList) { - if(vo.getCode()!=null){ - vo.setNameCode(vo.getName()+"("+ vo.getCode()+")"); - }else { - vo.setNameCode(vo.getName()); - } - } - List debietList=new ArrayList<>(); - if("2".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (BankCardLendVo vo:bankCardLendVoList - ) { - - String monthString=dateFormat.format(vo.getActivationDate()).substring(0,7); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - - } - } - for (String staticsTime :staticsTimeList - ) { - String details=""; - int actualCreditBillMonth=0; - for (BankCardLendVo vo:bankCardLendVoList - ) { - String monthString=dateFormat.format(vo.getActivationDate()).substring(0,7); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth++; - details+=vo.getNameCode()+"于"+dateFormat.format(vo.getActivationDate())+"在 "+vo.getOpeningBank()+" 开户;
"; - } - } - BankCardLendVo analysisVo=new BankCardLendVo(); - analysisVo.setName(actualCreditBillMonth+""); - analysisVo.setCode(staticsTime); - analysisVo.setRemark(details); - debietList.add(analysisVo); - } - - //年查询 - }else if("3".equals(analysisDto.getType())){ - //月列表 - List staticsTimeList=new ArrayList<>(); - for (BankCardLendVo vo:bankCardLendVoList - ) { - - String monthString=dateFormat.format(vo.getActivationDate()).substring(0,4); - - if(!staticsTimeList.contains(monthString)){ - staticsTimeList.add(monthString); - - } - } - for (String staticsTime :staticsTimeList - ) { - String details=""; - int actualCreditBillMonth=0; - for (BankCardLendVo vo:bankCardLendVoList - ) { - String monthString=dateFormat.format(vo.getActivationDate()).substring(0,4); - - if(staticsTime.equals(monthString)){ - actualCreditBillMonth++; - details+=vo.getNameCode()+"于"+dateFormat.format(vo.getActivationDate())+"在 "+vo.getOpeningBank()+" 开户;
"; - } - } - BankCardLendVo analysisVo=new BankCardLendVo(); - analysisVo.setName(actualCreditBillMonth+""); - analysisVo.setCode(staticsTime); - analysisVo.setRemark(details); - debietList.add(analysisVo); - } - - } - - - ArrayList> debitList = new ArrayList<>(); - ArrayList> tableDebitList = new ArrayList<>(); - for (BankCardLendVo bankCardLendVo:debietList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", bankCardLendVo.getCode()); - datamap.put("detail", bankCardLendVo.getRemark()); - datamap.put("value", bankCardLendVo.getName()); - tableDebitList.add(datamap); - } - Collections.reverse(debietList); - for (BankCardLendVo bankCardLendVo:debietList - ) { - Map datamap = new HashMap<>(); - datamap.put("time", bankCardLendVo.getCode()); - datamap.put("value", bankCardLendVo.getName()); - debitList.add(datamap); - } - List accountsList=statisticAnalysisMapper.selectOpenCardList(new AccountsDto()); - //列表 - map.put("accountsList",accountsList); - map.put("debitList",debitList); - map.put("tableDebitList",tableDebitList); - - return map; - } - - @Override - public List getBankCardStatistics() { - return statisticAnalysisMapper.selectBankCardStatistics(new AccountsDto()); - } -} diff --git a/intc-modules/intc-invest/src/main/resources/mapper/invest/InstallmentHistoryDetailMapper.xml b/intc-modules/intc-invest/src/main/resources/mapper/invest/InstallmentHistoryDetailMapper.xml deleted file mode 100644 index 1faa222..0000000 --- a/intc-modules/intc-invest/src/main/resources/mapper/invest/InstallmentHistoryDetailMapper.xml +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - select - a.id, - a.installment_history_id, - a.bank_card_lend_id, - a.current_amount, - a.repayment_date, - a.principal, - a.interest, - a.posting_state, - a.create_by, - a.create_time, - a.update_by, - a.update_time, - a.del_flag, - a.remark, - a.type, - a.periods, - a.repayment_account_id, - CONCAT(bcl."name", - '(', - right(bcl.code, - 4), - ')') as bank_card_lend_name, - CONCAT(debit."name", - '(', - right(debit.code, - 4), - ')') as repayment_account_name - from - installment_history_detail a - left join bank_card_lend bcl on - bcl.id = a.bank_card_lend_id - left join installment_history ih on ih.id=a.installment_history_id - left join bank_card_lend debit on - debit.id = a.repayment_account_id - - - - - - - - insert into installment_history_detail - - id, - installment_history_id, - bank_card_lend_id, - current_amount, - repayment_date, - principal, - interest, - posting_state, - create_by, - create_time, - update_by, - update_time, - del_flag, - remark, - type, - periods, - repayment_account_id, - - - #{id}, - #{installmentHistoryId}, - #{bankCardLendId}, - #{currentAmount}, - #{repaymentDate}, - #{principal}, - #{interest}, - #{postingState}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{delFlag}, - #{remark}, - #{type}, - #{periods}, - #{repaymentAccountId}, - - - - - update installment_history_detail - - installment_history_id = #{installmentHistoryId}, - bank_card_lend_id = #{bankCardLendId}, - current_amount = #{currentAmount}, - repayment_date = #{repaymentDate}, - principal = #{principal}, - interest = #{interest}, - posting_state = #{postingState}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - del_flag = #{delFlag}, - remark = #{remark}, - type = #{type}, - periods = #{periods}, - repayment_account_id = #{repaymentAccountId}, - - where id = #{id} - - - - delete from installment_history_detail where id = #{id} - - - - delete from installment_history_detail where id in - - #{id} - - - - update installment_history_detail set del_flag='1' where id = #{id} - - - - update installment_history_detail set del_flag='1' where id in - - #{id} - - -