fix: 投资账单定时任务。
This commit is contained in:
@@ -54,4 +54,8 @@ public class FutureStocksBillDto extends BaseEntity implements Serializable
|
||||
@ApiModelProperty(value="开始月份")
|
||||
private String startMonth;
|
||||
|
||||
/** 账单月份 */
|
||||
private String billMonth;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ package com.ruoyi.job.service;
|
||||
public interface IInvestJobService
|
||||
{
|
||||
/**
|
||||
* 生成模拟数据
|
||||
* 更新信用卡未出账单
|
||||
*
|
||||
* @author tianyongbao
|
||||
* @date 2023-12-11
|
||||
@@ -18,13 +18,21 @@ public interface IInvestJobService
|
||||
public void generateUnpaidCreditBill();
|
||||
|
||||
/**
|
||||
* 生成能耗模拟数据
|
||||
* 更新信用卡分期数据
|
||||
*
|
||||
* @author tianyongbao
|
||||
* @date 2023-12-12
|
||||
*/
|
||||
public void updateUnpaidInstallmentData();
|
||||
|
||||
/**
|
||||
* 更新投资账户未出账单
|
||||
*
|
||||
* @author tianyongbao
|
||||
* @date 2023-12-11
|
||||
*/
|
||||
public void generateFutureStocksBill();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,8 @@ import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.IdWorker;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import com.ruoyi.invest.domain.AccountsDealRecord;
|
||||
import com.ruoyi.invest.domain.CreditCardBill;
|
||||
import com.ruoyi.invest.domain.InstallmentHistory;
|
||||
import com.ruoyi.invest.domain.InstallmentHistoryDetail;
|
||||
import com.ruoyi.invest.domain.dto.AccountsDealRecordDto;
|
||||
import com.ruoyi.invest.domain.dto.BankCardLendDto;
|
||||
import com.ruoyi.invest.domain.dto.CreditCardBillDto;
|
||||
import com.ruoyi.invest.domain.dto.InstallmentHistoryDetailDto;
|
||||
import com.ruoyi.invest.domain.*;
|
||||
import com.ruoyi.invest.domain.dto.*;
|
||||
import com.ruoyi.invest.domain.vo.*;
|
||||
import com.ruoyi.invest.mapper.*;
|
||||
import com.ruoyi.job.service.IInvestJobService;
|
||||
@@ -49,6 +43,12 @@ public class InvestJobImpl implements IInvestJobService
|
||||
@Resource
|
||||
private InstallmentHistoryMapper installmentHistoryMapper;
|
||||
|
||||
@Resource
|
||||
private FutureStocksBillMapper futureStocksBillMapper;
|
||||
|
||||
@Resource
|
||||
private FutureStocksMapper futureStocksMapper;
|
||||
|
||||
/**
|
||||
* 生成数据
|
||||
*
|
||||
@@ -305,4 +305,107 @@ public class InvestJobImpl implements IInvestJobService
|
||||
return accountsDealRecordMapper.insertAccountsDealRecord(accountsDealRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成数据
|
||||
*
|
||||
* @author tianyongbao
|
||||
* @date 2023-12-11
|
||||
*/
|
||||
@Override
|
||||
public void generateFutureStocksBill() {
|
||||
//未出账单生成,定时任务,每1个小时同步计算一次,作为未出账单,根据投资账户基础信息,遍历投资账户记录信息表和交易记录表即可
|
||||
FutureStocksDto futureStocksDto=new FutureStocksDto();
|
||||
// futureStocksDto.setStatus("1");
|
||||
List<FutureStocksVo> list =futureStocksMapper.selectFutureStocksList(futureStocksDto);
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int month = currentDate.getMonthValue();
|
||||
int year = currentDate.getYear();
|
||||
int dayOfMonth = currentDate.getDayOfMonth();
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
SimpleDateFormat formatterTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy");
|
||||
SimpleDateFormat monthFormatter = new SimpleDateFormat("yyyy-MM");
|
||||
Date billDate= new Date();
|
||||
//遍历数据,获取信用卡账单日及数据
|
||||
for (FutureStocksVo futureStocksVo : list) {
|
||||
//如果不是正常使用的账户,不需要生成账单信息
|
||||
if(!futureStocksVo.getStatus().equals("1")){
|
||||
continue;
|
||||
}
|
||||
|
||||
Calendar calendarStart = Calendar.getInstance();
|
||||
calendarStart.setTime(billDate);
|
||||
calendarStart.set(Calendar.DAY_OF_MONTH, 1); // 设置为当月的第一天
|
||||
|
||||
Date startDate = calendarStart.getTime();
|
||||
String periodStart = formatter.format(startDate);
|
||||
|
||||
Calendar calendarEnd = Calendar.getInstance();
|
||||
calendarEnd.setTime(billDate);
|
||||
int lastDay = calendarEnd.getActualMaximum(Calendar.DAY_OF_MONTH); // 当月的最后一天
|
||||
calendarEnd.set(Calendar.DAY_OF_MONTH, lastDay);
|
||||
Date endDate = calendarEnd.getTime();
|
||||
String periodEnd= formatter.format(endDate);
|
||||
|
||||
double billAmount=0;
|
||||
AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto();
|
||||
accountsDealRecordDto.setAccountId(futureStocksVo.getId());
|
||||
try {
|
||||
accountsDealRecordDto.setStartDateTime(formatterTime.parse(periodStart+" 00:00:00"));
|
||||
accountsDealRecordDto.setEndDateTime(formatterTime.parse(periodEnd+" 23:59:59"));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
accountsDealRecordDto.setDealCategory("2");
|
||||
|
||||
//获取所有交易记录
|
||||
List<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto);
|
||||
//收入转为负数
|
||||
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||
) {
|
||||
if(vo.getDealType().equals("1")){
|
||||
vo.setAmount(vo.getAmount()*(-1));
|
||||
}
|
||||
}
|
||||
//如果存在交易记录,进行账单汇总,否则不进行
|
||||
if(accountsDealRecordVoList.size()>0){
|
||||
billAmount=accountsDealRecordVoList.stream().mapToDouble(AccountsDealRecordVo::getAmount).sum();
|
||||
FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto();
|
||||
futureStocksBillDto.setFutureStocksId(futureStocksVo.getId());
|
||||
String billMonth=year+"-"+String.format("%02d", month);
|
||||
futureStocksBillDto.setBillMonth(billMonth);
|
||||
List<FutureStocksBillVo> futureStocksBillVoList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto);
|
||||
if(futureStocksBillVoList.size()>0){
|
||||
FutureStocksBillVo futureStocksBillVo=futureStocksBillVoList.get(0);
|
||||
FutureStocksBill futureStocksBill=new FutureStocksBill();
|
||||
futureStocksBill.setUpdateBy(SecurityUtils.getUsername());
|
||||
futureStocksBill.setUpdateTime(DateUtils.getNowDate());
|
||||
futureStocksBill.setId(futureStocksVo.getId());
|
||||
futureStocksBill.setBillAmount(billAmount);
|
||||
//更新账单
|
||||
futureStocksBillMapper.updateFutureStocksBill(futureStocksBill);
|
||||
}else {
|
||||
//进行插入操作
|
||||
FutureStocksBill futureStocksBill=new FutureStocksBill();
|
||||
futureStocksBill.setBillDate(endDate);
|
||||
futureStocksBill.setName(simpleDateFormat.format(endDate));
|
||||
futureStocksBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
||||
futureStocksBill.setCreateBy(futureStocksVo.getCreateBy());
|
||||
futureStocksBill.setCreateTime(DateUtils.getNowDate());
|
||||
futureStocksBill.setId(IdWorker.getId());
|
||||
futureStocksBill.setFutureStocksId(futureStocksVo.getId());
|
||||
futureStocksBill.setBillAmount(billAmount);
|
||||
futureStocksBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
||||
futureStocksBill.setBillYear(yearFormatter.format(futureStocksBill.getBillDate()));
|
||||
futureStocksBill.setBillMonth(monthFormatter.format(futureStocksBill.getBillDate()));
|
||||
//插入未出账单
|
||||
futureStocksBillMapper.insertFutureStocksBill(futureStocksBill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="billDatePeriod != null and billDatePeriod != ''"> and a.bill_date_period = #{billDatePeriod}</if>
|
||||
<if test="billAmount != null and billAmount != ''"> and a.bill_amount = #{billAmount}</if>
|
||||
<if test="type != null and type != ''"> and a.type = #{type}</if>
|
||||
<if test="billMonth != null "> and a.bill_month = #{billMonth}</if>
|
||||
<if test="startMonth!=null and startMonth !=''">
|
||||
and to_char(a.bill_date, 'yyyy-MM')>=#{startMonth}
|
||||
</if>
|
||||
|
||||
@@ -31,4 +31,12 @@ public class InvestJobTask
|
||||
}
|
||||
|
||||
|
||||
/**未出信用卡分期账单入账数据*/
|
||||
public void generateFutureStocksBill(){
|
||||
System.out.println("================================开始生成未出投资账单数据("+ DateUtils.getTime() +")=================================");
|
||||
remoteInvestService.generateFutureStocksBill();
|
||||
System.out.println("================================结束生成未出投资账单据("+ DateUtils.getTime() +")=================================");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,5 +30,11 @@ public class InvestProdJobTask
|
||||
System.out.println("================================结束更新未出信用卡分期账单入账拟数据("+ DateUtils.getTime() +")=================================");
|
||||
}
|
||||
|
||||
/**生成未出投资账单数据*/
|
||||
public void generateFutureStocksBill(){
|
||||
System.out.println("================================开始生成未出账单数据("+ DateUtils.getTime() +")=================================");
|
||||
remoteInvestProdService.generateFutureStocksBill();
|
||||
System.out.println("================================结束生成未出账单据("+ DateUtils.getTime() +")=================================");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user