fix:定时任务相关功能完善,自测问题修复。
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>ruoyi-api-system</module>
|
<module>ruoyi-api-system</module>
|
||||||
|
<module>ruoyi-api-invest</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>ruoyi-api</artifactId>
|
<artifactId>ruoyi-api</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|||||||
28
ruoyi-api/ruoyi-api-invest/pom.xml
Normal file
28
ruoyi-api/ruoyi-api-invest/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-api</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-api-invest</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
ruoyi-api-invest
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- RuoYi Common Core-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.ruoyi.api.invest;
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础服务
|
||||||
|
*
|
||||||
|
* @author YaphetS
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteInvestService", value = ServiceNameConstants.INTC_INVEST, fallbackFactory = com.ruoyi.api.invest.factory.RemoteInvestFallbackFactory.class)
|
||||||
|
public interface RemoteInvestService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 生成未出信用卡账单数据
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/job/generateUnpaidCreditBill",method = RequestMethod.POST)
|
||||||
|
public R generateUnpaidCreditBillTask();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新未出信用卡分期账单入账数据
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/job/updateUnpaidInstallmentData",method = RequestMethod.POST)
|
||||||
|
public R updateUnpaidInstallmentDataTask();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.ruoyi.api.invest.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.api.invest.RemoteInvestService;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务降级处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteInvestFallbackFactory implements FallbackFactory<RemoteInvestService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(com.ruoyi.api.invest.factory.RemoteInvestFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteInvestService create(Throwable throwable)
|
||||||
|
{
|
||||||
|
log.error("投资服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteInvestService()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R generateUnpaidCreditBillTask() {
|
||||||
|
return R.fail("投资服务调用生成未出信用卡账单数据失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R updateUnpaidInstallmentDataTask() {
|
||||||
|
return R.fail("投资服务调用更新未出信用卡分期账单入账数据失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
com.ruoyi.api.invest.factory.RemoteInvestFallbackFactory
|
||||||
@@ -57,7 +57,7 @@ public class ServiceNameConstants
|
|||||||
public static final String VIDEO_SERVICE ="hny-video";
|
public static final String VIDEO_SERVICE ="hny-video";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMART_LIGHT_SERVICE的serviceId
|
* INTC_INVEST的serviceId
|
||||||
*/
|
*/
|
||||||
public static final String SMART_LIGHT_SERVICE ="hny-smart-light";
|
public static final String INTC_INVEST ="intc-invest";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public class CreditCardBill extends BaseEntity
|
|||||||
/** 删除标志(0代表存在 1代表删除) */
|
/** 删除标志(0代表存在 1代表删除) */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 1代表删除) */
|
||||||
|
private String billState;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@@ -66,6 +69,7 @@ public class CreditCardBill extends BaseEntity
|
|||||||
.append("updateBy", getUpdateBy())
|
.append("updateBy", getUpdateBy())
|
||||||
.append("updateTime", getUpdateTime())
|
.append("updateTime", getUpdateTime())
|
||||||
.append("delFlag", getDelFlag())
|
.append("delFlag", getDelFlag())
|
||||||
|
.append("billState", getBillState())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户交易记录Dto对象 accounts_deal_record
|
* 账户交易记录Dto对象 accounts_deal_record
|
||||||
*
|
*
|
||||||
@@ -27,7 +29,7 @@ public class AccountsDealRecordDto implements Serializable
|
|||||||
|
|
||||||
/** 账户 */
|
/** 账户 */
|
||||||
@ApiModelProperty(value="账户")
|
@ApiModelProperty(value="账户")
|
||||||
private String accountId;
|
private Long accountId;
|
||||||
|
|
||||||
/** 交易类型 */
|
/** 交易类型 */
|
||||||
@ApiModelProperty(value="交易类型")
|
@ApiModelProperty(value="交易类型")
|
||||||
@@ -37,12 +39,21 @@ public class AccountsDealRecordDto implements Serializable
|
|||||||
@ApiModelProperty(value="交易类别")
|
@ApiModelProperty(value="交易类别")
|
||||||
private String dealCategory;
|
private String dealCategory;
|
||||||
|
|
||||||
/** 交易类别 */
|
/** 开始日期 */
|
||||||
@ApiModelProperty(value="开始日期")
|
@ApiModelProperty(value="开始日期")
|
||||||
private String startTime;
|
private String startTime;
|
||||||
|
|
||||||
/** 交易类别 */
|
/** 结束日期 */
|
||||||
@ApiModelProperty(value="结束日期")
|
@ApiModelProperty(value="结束日期")
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
|
/** 开始时间*/
|
||||||
|
@ApiModelProperty(value="开始时间")
|
||||||
|
private Date startDateTime;
|
||||||
|
|
||||||
|
/** 结束时间*/
|
||||||
|
@ApiModelProperty(value="结束时间")
|
||||||
|
private Date endDateTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,24 @@ public class CreditCardBillDto implements Serializable
|
|||||||
@ApiModelProperty(value="信用卡id")
|
@ApiModelProperty(value="信用卡id")
|
||||||
private Long creditCardId;
|
private Long creditCardId;
|
||||||
|
|
||||||
|
/** 开始月份 */
|
||||||
|
@ApiModelProperty(value="开始月份")
|
||||||
|
private String startMonth;
|
||||||
|
|
||||||
|
|
||||||
/** 结束月份 */
|
/** 结束月份 */
|
||||||
@ApiModelProperty(value="结束月份")
|
@ApiModelProperty(value="结束月份")
|
||||||
private String endMonth;
|
private String endMonth;
|
||||||
|
|
||||||
|
|
||||||
/** 开始月份 */
|
/** 账单状态 */
|
||||||
@ApiModelProperty(value="开始月份")
|
@ApiModelProperty(value="账单状态")
|
||||||
private String startMonth;
|
private String billState;
|
||||||
|
|
||||||
|
|
||||||
|
/** 账单日 */
|
||||||
|
@ApiModelProperty(value="账单日")
|
||||||
|
private String billDate;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import com.ruoyi.common.core.utils.StringUtils;
|
|||||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.invest.domain.CreditCardBill;
|
import com.ruoyi.invest.domain.CreditCardBill;
|
||||||
import com.ruoyi.invest.domain.dto.CreditCardBillDto;
|
import com.ruoyi.invest.domain.dto.CreditCardBillDto;
|
||||||
|
import com.ruoyi.invest.domain.vo.BankCardLendVo;
|
||||||
import com.ruoyi.invest.domain.vo.CreditCardBillVo;
|
import com.ruoyi.invest.domain.vo.CreditCardBillVo;
|
||||||
|
import com.ruoyi.invest.mapper.BankCardLendMapper;
|
||||||
import com.ruoyi.invest.mapper.CreditCardBillMapper;
|
import com.ruoyi.invest.mapper.CreditCardBillMapper;
|
||||||
import com.ruoyi.invest.service.ICreditCardBillService;
|
import com.ruoyi.invest.service.ICreditCardBillService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -28,6 +30,8 @@ public class CreditCardBillServiceImpl implements ICreditCardBillService
|
|||||||
{
|
{
|
||||||
@Resource
|
@Resource
|
||||||
private CreditCardBillMapper creditCardBillMapper;
|
private CreditCardBillMapper creditCardBillMapper;
|
||||||
|
@Resource
|
||||||
|
private BankCardLendMapper bankCardLendMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询信用卡账单
|
* 查询信用卡账单
|
||||||
@@ -74,17 +78,25 @@ public class CreditCardBillServiceImpl implements ICreditCardBillService
|
|||||||
creditCardBill.setId(IdWorker.getId());
|
creditCardBill.setId(IdWorker.getId());
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
BankCardLendVo bankCard=bankCardLendMapper.selectBankCardLendById(creditCardBill.getCreditCardId());
|
||||||
|
//0表示当期,1表示下期
|
||||||
|
String isNextBillDate = bankCard.getIsNextBillDate();
|
||||||
if(creditCardBill.getBillDate()!=null){
|
if(creditCardBill.getBillDate()!=null){
|
||||||
creditCardBill.setName(simpleDateFormat.format(creditCardBill.getBillDate()));
|
creditCardBill.setName(simpleDateFormat.format(creditCardBill.getBillDate()));
|
||||||
Calendar calendarStart = Calendar.getInstance();
|
Calendar calendarStart = Calendar.getInstance();
|
||||||
calendarStart.setTime(creditCardBill.getBillDate());
|
calendarStart.setTime(creditCardBill.getBillDate());
|
||||||
calendarStart.add(Calendar.MONTH, -1);
|
calendarStart.add(Calendar.MONTH, -1);
|
||||||
|
if(isNextBillDate.equals("0")){
|
||||||
|
calendarStart.add(Calendar.DATE, 1);
|
||||||
|
}
|
||||||
Date lastMonth = calendarStart.getTime();
|
Date lastMonth = calendarStart.getTime();
|
||||||
String periodStart = formatter.format(lastMonth);
|
String periodStart = formatter.format(lastMonth);
|
||||||
|
|
||||||
Calendar calendarEnd = Calendar.getInstance();
|
Calendar calendarEnd = Calendar.getInstance();
|
||||||
calendarEnd.setTime(creditCardBill.getBillDate());
|
calendarEnd.setTime(creditCardBill.getBillDate());
|
||||||
calendarEnd.add(Calendar.DATE, -1);
|
if(isNextBillDate.equals("1")){
|
||||||
|
calendarEnd.add(Calendar.DATE, -1);
|
||||||
|
}
|
||||||
Date lastDay = calendarEnd.getTime();
|
Date lastDay = calendarEnd.getTime();
|
||||||
String periodEnd= formatter.format(lastDay);
|
String periodEnd= formatter.format(lastDay);
|
||||||
creditCardBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
creditCardBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
||||||
@@ -107,17 +119,25 @@ public class CreditCardBillServiceImpl implements ICreditCardBillService
|
|||||||
creditCardBill.setUpdateTime(DateUtils.getNowDate());
|
creditCardBill.setUpdateTime(DateUtils.getNowDate());
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
BankCardLendVo bankCard=bankCardLendMapper.selectBankCardLendById(creditCardBill.getCreditCardId());
|
||||||
|
//0表示当期,1表示下期
|
||||||
|
String isNextBillDate = bankCard.getIsNextBillDate();
|
||||||
if(creditCardBill.getBillDate()!=null){
|
if(creditCardBill.getBillDate()!=null){
|
||||||
creditCardBill.setName(simpleDateFormat.format(creditCardBill.getBillDate()));
|
creditCardBill.setName(simpleDateFormat.format(creditCardBill.getBillDate()));
|
||||||
Calendar calendarStart = Calendar.getInstance();
|
Calendar calendarStart = Calendar.getInstance();
|
||||||
calendarStart.setTime(creditCardBill.getBillDate());
|
calendarStart.setTime(creditCardBill.getBillDate());
|
||||||
calendarStart.add(Calendar.MONTH, -1);
|
calendarStart.add(Calendar.MONTH, -1);
|
||||||
|
if(isNextBillDate.equals("0")){
|
||||||
|
calendarStart.add(Calendar.DATE, 1);
|
||||||
|
}
|
||||||
Date lastMonth = calendarStart.getTime();
|
Date lastMonth = calendarStart.getTime();
|
||||||
String periodStart = formatter.format(lastMonth);
|
String periodStart = formatter.format(lastMonth);
|
||||||
|
|
||||||
Calendar calendarEnd = Calendar.getInstance();
|
Calendar calendarEnd = Calendar.getInstance();
|
||||||
calendarEnd.setTime(creditCardBill.getBillDate());
|
calendarEnd.setTime(creditCardBill.getBillDate());
|
||||||
calendarEnd.add(Calendar.DATE, -1);
|
if(isNextBillDate.equals("1")){
|
||||||
|
calendarEnd.add(Calendar.DATE, -1);
|
||||||
|
}
|
||||||
Date lastDay = calendarEnd.getTime();
|
Date lastDay = calendarEnd.getTime();
|
||||||
String periodEnd= formatter.format(lastDay);
|
String periodEnd= formatter.format(lastDay);
|
||||||
creditCardBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
creditCardBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
||||||
|
|||||||
@@ -113,6 +113,28 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|||||||
//返回数据
|
//返回数据
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||||
|
|
||||||
|
AccountsDto dto=new AccountsDto();
|
||||||
|
dto.setState("1");
|
||||||
|
//储蓄卡
|
||||||
|
dto.setType("1");
|
||||||
|
List<AccountsVo> accountsList=accountsMapper.selectAccountsList(dto);
|
||||||
|
double debetBalance =0;
|
||||||
|
if(accountsList.size()>0){
|
||||||
|
debetBalance=accountsList.stream().mapToDouble(AccountsVo::getAvailableLimit).sum();
|
||||||
|
}
|
||||||
|
map.put("debetBalance",decimalFormat.format(debetBalance));
|
||||||
|
|
||||||
|
dto.setState("1");
|
||||||
|
//信用卡
|
||||||
|
dto.setType("2");
|
||||||
|
accountsList=accountsMapper.selectAccountsList(dto);
|
||||||
|
double creditBalance =0;
|
||||||
|
if(accountsList.size()>0){
|
||||||
|
creditBalance=accountsList.stream().mapToDouble(AccountsVo::getBalance).sum()*(-1);
|
||||||
|
}
|
||||||
|
map.put("creditBalance",decimalFormat.format(creditBalance));
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM");
|
SimpleDateFormat formatterMonth = new SimpleDateFormat("yyyy-MM");
|
||||||
//未结清网贷数据
|
//未结清网贷数据
|
||||||
@@ -148,7 +170,10 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
|
|||||||
}
|
}
|
||||||
map.put("peopleLendHistory",decimalFormat.format(peopleLendHistory));
|
map.put("peopleLendHistory",decimalFormat.format(peopleLendHistory));
|
||||||
|
|
||||||
map.put("totalDebt",decimalFormat.format(unClearedOnlineDebt+creditInstallmentHistory+peopleLendHistory));
|
//总负债
|
||||||
|
map.put("totalDebt",decimalFormat.format(unClearedOnlineDebt+creditBalance+peopleLendHistory));
|
||||||
|
//净资产
|
||||||
|
map.put("netAsset",decimalFormat.format(debetBalance-unClearedOnlineDebt-creditBalance-peopleLendHistory));
|
||||||
|
|
||||||
//未结清账户数
|
//未结清账户数
|
||||||
installmentHistoryDto.setState("0");
|
installmentHistoryDto.setState("0");
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.ruoyi.job.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.job.service.IInvestJobService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 信息Controller
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
@Api(tags=" 生成数据信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/job")
|
||||||
|
public class InvestJob
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private IInvestJobService investJobService;
|
||||||
|
|
||||||
|
@PostMapping("/generateUnpaidCreditBill")
|
||||||
|
public AjaxResult generateUnpaidCreditBill()
|
||||||
|
{
|
||||||
|
System.out.println("================================开始生成未出账单数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
investJobService.generateUnpaidCreditBill();
|
||||||
|
System.out.println("================================结束生成未出账单据("+ DateUtils.getTime() +")=================================");
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/updateUnpaidInstallmentData")
|
||||||
|
public AjaxResult updateUnpaidInstallmentData()
|
||||||
|
{
|
||||||
|
System.out.println("================================开始更新未出信用卡分期账单入账数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
investJobService.updateUnpaidInstallmentData();
|
||||||
|
System.out.println("================================结束更新未出信用卡分期账单入账拟数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.ruoyi.job.service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成模拟数据
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
public interface IInvestJobService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 生成模拟数据
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
public void generateUnpaidCreditBill();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成能耗模拟数据
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-12
|
||||||
|
*/
|
||||||
|
public void updateUnpaidInstallmentData();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
package com.ruoyi.job.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.core.utils.IdWorker;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.invest.domain.CreditCardBill;
|
||||||
|
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.vo.AccountsDealRecordVo;
|
||||||
|
import com.ruoyi.invest.domain.vo.BankCardLendVo;
|
||||||
|
import com.ruoyi.invest.domain.vo.CreditCardBillVo;
|
||||||
|
import com.ruoyi.invest.mapper.AccountsDealRecordMapper;
|
||||||
|
import com.ruoyi.invest.mapper.AccountsMapper;
|
||||||
|
import com.ruoyi.invest.mapper.BankCardLendMapper;
|
||||||
|
import com.ruoyi.invest.mapper.CreditCardBillMapper;
|
||||||
|
import com.ruoyi.job.service.IInvestJobService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成数据
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InvestJobImpl implements IInvestJobService
|
||||||
|
{
|
||||||
|
@Resource
|
||||||
|
private BankCardLendMapper bankCardLendMapper;
|
||||||
|
@Resource
|
||||||
|
private AccountsMapper accountsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountsDealRecordMapper accountsDealRecordMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CreditCardBillMapper creditCardBillMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成数据
|
||||||
|
*
|
||||||
|
* @author tianyongbao
|
||||||
|
* @date 2023-12-11
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void generateUnpaidCreditBill() {
|
||||||
|
//未出账单生成,定时任务,每3个小时同步计算一次,作为未出账单,根据信用卡基础信息,包括账单日及账单日消费信息,遍历信用卡记录信息表和交易记录表即可
|
||||||
|
BankCardLendDto bankCardLendDto=new BankCardLendDto();
|
||||||
|
bankCardLendDto.setType("2");
|
||||||
|
List<BankCardLendVo> bankCardVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto);
|
||||||
|
// 获取当前日期
|
||||||
|
Date currentDate = new Date();
|
||||||
|
// 创建SimpleDateFormat实例,指定日期格式
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||||
|
// 格式化日期为字符串
|
||||||
|
String formattedDate = sdf.format(currentDate);
|
||||||
|
// 从格式化后的字符串中提取年份和月份
|
||||||
|
String year = formattedDate.substring(0, 4);
|
||||||
|
String month = formattedDate.substring(5);
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date billDate= new Date();
|
||||||
|
//遍历数据,获取信用卡账单日及数据
|
||||||
|
for (BankCardLendVo bankCard : bankCardVoList) {
|
||||||
|
//0表示当期,1表示下期
|
||||||
|
String isNextBillDate = bankCard.getIsNextBillDate();
|
||||||
|
String billDateStr=year+"-"+month+"-"+String.format("%02d", bankCard.getBillDate());
|
||||||
|
try {
|
||||||
|
billDate=formatter.parse(billDateStr);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Calendar calendarStart = Calendar.getInstance();
|
||||||
|
calendarStart.setTime(billDate);
|
||||||
|
calendarStart.add(Calendar.MONTH, -1);
|
||||||
|
if(isNextBillDate.equals("0")){
|
||||||
|
calendarStart.add(Calendar.DATE, 1);
|
||||||
|
}
|
||||||
|
Date startDate = calendarStart.getTime();
|
||||||
|
String periodStart = formatter.format(startDate);
|
||||||
|
|
||||||
|
Calendar calendarEnd = Calendar.getInstance();
|
||||||
|
calendarEnd.setTime(billDate);
|
||||||
|
if(isNextBillDate.equals("1")){
|
||||||
|
calendarEnd.add(Calendar.DATE, -1);
|
||||||
|
}
|
||||||
|
Date endDate = calendarEnd.getTime();
|
||||||
|
String periodEnd= formatter.format(endDate);
|
||||||
|
|
||||||
|
double billAmount=0;
|
||||||
|
AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto();
|
||||||
|
accountsDealRecordDto.setAccountId(bankCard.getId());
|
||||||
|
accountsDealRecordDto.setStartDateTime(startDate);
|
||||||
|
accountsDealRecordDto.setEndDateTime(endDate);
|
||||||
|
//获取所有交易记录
|
||||||
|
List<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto);
|
||||||
|
//支出转为负数
|
||||||
|
for (AccountsDealRecordVo vo:accountsDealRecordVoList
|
||||||
|
) {
|
||||||
|
if(vo.getDealType().equals("2")){
|
||||||
|
vo.setAmount(vo.getAmount()*(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(accountsDealRecordVoList.size()>0){
|
||||||
|
billAmount=accountsDealRecordVoList.stream().mapToDouble(AccountsDealRecordVo::getAmount).sum();
|
||||||
|
}
|
||||||
|
CreditCardBillDto creditCardBillDto=new CreditCardBillDto();
|
||||||
|
creditCardBillDto.setCreditCardId(bankCard.getId());
|
||||||
|
creditCardBillDto.setBillDate(billDateStr);
|
||||||
|
creditCardBillDto.setBillState("0");
|
||||||
|
List<CreditCardBillVo> creditCardBillList=creditCardBillMapper.selectCreditCardBillList(creditCardBillDto);
|
||||||
|
if(creditCardBillList.size()>0){
|
||||||
|
CreditCardBillVo creditCardBillVo=creditCardBillList.get(0);
|
||||||
|
CreditCardBill creditCardBill=new CreditCardBill();
|
||||||
|
creditCardBill.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
creditCardBill.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
creditCardBill.setId(creditCardBillVo.getId());
|
||||||
|
creditCardBill.setBillAmount(billAmount);
|
||||||
|
//更新未出账单
|
||||||
|
creditCardBillMapper.updateCreditCardBill(creditCardBill);
|
||||||
|
}else {
|
||||||
|
|
||||||
|
CreditCardBill creditCardBill=new CreditCardBill();
|
||||||
|
try {
|
||||||
|
creditCardBill.setBillDate(formatter.parse(billDateStr));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
creditCardBill.setName(simpleDateFormat.format(creditCardBill.getBillDate()));
|
||||||
|
creditCardBill.setBillDatePeriod(periodStart+"~"+periodEnd);
|
||||||
|
creditCardBill.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
creditCardBill.setCreateTime(DateUtils.getNowDate());
|
||||||
|
creditCardBill.setId(IdWorker.getId());
|
||||||
|
creditCardBill.setCreditCardId(bankCard.getId());
|
||||||
|
creditCardBill.setBillAmount(billAmount);
|
||||||
|
creditCardBill.setBillState("0");
|
||||||
|
//插入未出账单
|
||||||
|
creditCardBillMapper.insertCreditCardBill(creditCardBill);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUnpaidInstallmentData(){
|
||||||
|
//信用卡分期入账信息自动入账,同时更新信用卡额度相关信息
|
||||||
|
// 获取当前日期
|
||||||
|
Date currentDate = new Date();
|
||||||
|
// 创建SimpleDateFormat实例,指定日期格式
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
// 格式化日期为字符串
|
||||||
|
String formattedDate = sdf.format(currentDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -62,6 +62,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="startTime!=null and startTime !=''">
|
<if test="startTime!=null and startTime !=''">
|
||||||
and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime}
|
and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="endDateTime!=null">
|
||||||
|
and #{endDateTime}>a.create_time
|
||||||
|
</if>
|
||||||
|
<if test="startDateTime!=null">
|
||||||
|
and a.create_time>=#{startDateTime}
|
||||||
|
</if>
|
||||||
|
|
||||||
</where>
|
</where>
|
||||||
order by a.create_time desc
|
order by a.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="billState" column="bill_state" />
|
||||||
<result property="bankName" column="bank_name" />
|
<result property="bankName" column="bank_name" />
|
||||||
<result property="bankCode" column="bank_code" />
|
<result property="bankCode" column="bank_code" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@@ -33,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.update_by,
|
a.update_by,
|
||||||
a.update_time,
|
a.update_time,
|
||||||
a.del_flag,
|
a.del_flag,
|
||||||
|
a.bill_state,
|
||||||
bc."name" as bank_name,
|
bc."name" as bank_name,
|
||||||
bc.code as bank_code
|
bc.code as bank_code
|
||||||
from
|
from
|
||||||
@@ -47,12 +49,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.del_flag='0'
|
a.del_flag='0'
|
||||||
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
|
<if test="name != null and name != ''"> and a.name like '%'|| #{name}||'%'</if>
|
||||||
<if test="creditCardId != null "> and a.credit_card_id = #{creditCardId}</if>
|
<if test="creditCardId != null "> and a.credit_card_id = #{creditCardId}</if>
|
||||||
|
<if test="billState != null and billState != ''"> and a.bill_state = #{billState}</if>
|
||||||
<if test="startMonth!=null and startMonth !=''">
|
<if test="startMonth!=null and startMonth !=''">
|
||||||
and to_char(a.bill_date, 'yyyy-MM')>=#{startMonth}
|
and to_char(a.bill_date, 'yyyy-MM')>=#{startMonth}
|
||||||
</if>
|
</if>
|
||||||
<if test="endMonth!=null and endMonth !=''">
|
<if test="endMonth!=null and endMonth !=''">
|
||||||
and #{endMonth}>=to_char(a.bill_date, 'yyyy-MM')
|
and #{endMonth}>=to_char(a.bill_date, 'yyyy-MM')
|
||||||
</if>
|
</if>
|
||||||
|
<if test="billDate!=null and billDate !=''">
|
||||||
|
and #{billDate}=to_char(a.bill_date, 'yyyy-MM-dd')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
|
||||||
</where>
|
</where>
|
||||||
order by a.bill_date desc
|
order by a.bill_date desc
|
||||||
</select>
|
</select>
|
||||||
@@ -76,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="delFlag != null">del_flag,</if>
|
<if test="delFlag != null">del_flag,</if>
|
||||||
|
<if test="billState != null">bill_state,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">#{id},</if>
|
<if test="id != null">#{id},</if>
|
||||||
@@ -89,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
<if test="delFlag != null">#{delFlag},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
|
<if test="billState != null">#{billState},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -105,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
<if test="billState != null">bill_state = #{billState},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -54,7 +54,12 @@
|
|||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${swagger.fox.version}</version>
|
<version>${swagger.fox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-api-invest</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<!-- Quartz -->
|
<!-- Quartz -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.quartz-scheduler</groupId>
|
<groupId>org.quartz-scheduler</groupId>
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.ruoyi.job.task;
|
||||||
|
|
||||||
|
import com.ruoyi.api.invest.RemoteInvestService;
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 照明平台定时任务
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
@Component("investJobTask")
|
||||||
|
public class InvestJobTask
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RemoteInvestService remoteInvestService;
|
||||||
|
|
||||||
|
/**生成未出信用卡账单数据*/
|
||||||
|
public void generateUnpaidCreditBillTask(){
|
||||||
|
System.out.println("================================开始生成未出账单数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
remoteInvestService.generateUnpaidCreditBillTask();
|
||||||
|
System.out.println("================================结束生成未出账单据("+ DateUtils.getTime() +")=================================");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**未出信用卡分期账单入账数据*/
|
||||||
|
public void updateUnpaidInstallmentDataTask(){
|
||||||
|
System.out.println("================================开始更新未出信用卡分期账单入账数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
remoteInvestService.updateUnpaidInstallmentDataTask();
|
||||||
|
System.out.println("================================结束更新未出信用卡分期账单入账拟数据("+ DateUtils.getTime() +")=================================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user