Parcourir la source

优化统计合并52010188999到 5201018893

shuiqilin
zhangxin il y a 1 an
Parent
révision
3c4eb9b4ec

+ 4
- 4
src/main/java/com/qtzl/alterSales/dao/entity/second/AflPaccountRefundCount.java Voir le fichier

@@ -16,7 +16,7 @@ import javax.persistence.Table;
public class AflPaccountRefundCount extends AbstractUpdateTimeEntity {

/** 记账日期 */
private String accountDate ;
private Integer accountDate ;
/** 渠道编号 */
private String agentId ;
/** 总条数 */
@@ -31,7 +31,7 @@ public class AflPaccountRefundCount extends AbstractUpdateTimeEntity {
public AflPaccountRefundCount() {
}

public AflPaccountRefundCount(String accountDate, String agentId, Long numberTotal, Long moneyTotal, Long collectMoney) {
public AflPaccountRefundCount(Integer accountDate, String agentId, Long numberTotal, Long moneyTotal, Long collectMoney) {
this.accountDate = accountDate;
this.agentId = agentId;
this.numberTotal = numberTotal;
@@ -43,11 +43,11 @@ public class AflPaccountRefundCount extends AbstractUpdateTimeEntity {

/** 记账日期 */
@Column(name ="ACCOUNT_DATE")
public String getAccountDate(){
public Integer getAccountDate(){
return this.accountDate;
}
/** 记账日期 */
public void setAccountDate(String accountDate){
public void setAccountDate(Integer accountDate){
this.accountDate=accountDate;
}
/** 渠道编号 */

+ 2
- 2
src/main/java/com/qtzl/alterSales/dao/repo/jpa/primary/FssPaccountPayRepo.java Voir le fichier

@@ -60,7 +60,7 @@ public interface FssPaccountPayRepo extends

@Query(value = "select " +
" DATE_FORMAT(insert_time, '%Y-%m-%d') as accountDate,agent_id as agentId , COUNT(1) as numberTotal ,SUM(receipt_Amt) as moneyTotal ,SUM(CASE WHEN `status` = 1 THEN receipt_Amt ELSE 0 END) as collectMoney ,0 as refundMoney " +
" from fss_paccount_pay where insert_time = ?1 GROUP BY DATE_FORMAT(insert_time, '%Y-%m-%d'),agent_id ",nativeQuery = true )
List<Map<String,Object>> findCountTotal(String yesterday);
" from fss_paccount_pay where insert_time >= ?1 and insert_time<=?2 GROUP BY DATE_FORMAT(insert_time, '%Y-%m-%d'),agent_id ",nativeQuery = true )
List<Map<String,Object>> findCountTotal(String yesterdayStare,String yesterdayEnd);

}

+ 1
- 1
src/main/java/com/qtzl/alterSales/dao/repo/jpa/second/AflPaccountRefundCountRepo.java Voir le fichier

@@ -21,5 +21,5 @@ public interface AflPaccountRefundCountRepo extends


@Query(" from AflPaccountRefundCount where agentId = ?1 and accountDate=?2")
AflPaccountRefundCount finByDateAndAgentId(String agentId, String accountDate);
AflPaccountRefundCount finByDateAndAgentId(String agentId, Integer accountDate);
}

+ 32
- 6
src/main/java/com/qtzl/alterSales/manager/model/protocol/sales/AflPaccountRefundCountFindPageRequest.java Voir le fichier

@@ -12,17 +12,21 @@ import org.apache.commons.lang3.StringUtils;
public class AflPaccountRefundCountFindPageRequest extends JpaPageableDataRequest<AflPaccountRefundCountVo> {

/** 记账日期 */
private String accountDate ;
private Integer accountDate ;
/** 渠道编号 */
private String agentId ;
/** 渠道名称 */
private String agentName ;

/** 记账日期开始时间 */
private Integer accountDateStart;
/** 记账日期结束时间 */
private Integer accountDateEnd;

@Override
public HqlBuilder toSelectHql() {
HqlBuilder builder = new HqlBuilder("SELECT new com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo(aprc.id, aprc.accountDate, " +
"aprc.agentId, qa.name, aprc.numberTotal," +
" aprc.agentId, qa.name, aprc.numberTotal," +
" aprc.moneyTotal, aprc.collectMoney,aprc.refundMoney) from AflPaccountRefundCount aprc " +
" left join QtlAgency qa on aprc.agentId = qa.agencyId ");
appendParam(builder);
@@ -39,20 +43,26 @@ public class AflPaccountRefundCountFindPageRequest extends JpaPageableDataReques


private void appendParam(HqlBuilder builder) {
if (!StringUtils.isEmpty(accountDate)){
builder.append(" AND aprc.accountDate = :accountDate", accountDate);
if (accountDate!=null){
builder.append(" AND aprc.accountDate =to_char(:accountDate,'yyyy-mm-dd') ", accountDate);
}
if (!StringUtils.isEmpty(agentName)){
builder.append(" AND qa.name LIKE :agentName",like(agentName));
}
if (accountDateStart!=null){
builder.append(" AND aprc.accountDate >= :accountDateStart",accountDateStart);
}
if (accountDateEnd!=null){
builder.append(" AND aprc.accountDate <= :accountDateEnd",accountDateEnd);
}

}

public String getAccountDate() {
public Integer getAccountDate() {
return accountDate;
}

public void setAccountDate(String accountDate) {
public void setAccountDate(Integer accountDate) {
this.accountDate = accountDate;
}

@@ -71,4 +81,20 @@ public class AflPaccountRefundCountFindPageRequest extends JpaPageableDataReques
public void setAgentName(String agentName) {
this.agentName = agentName;
}

public Integer getAccountDateStart() {
return accountDateStart;
}

public void setAccountDateStart(Integer accountDateStart) {
this.accountDateStart = accountDateStart;
}

public Integer getAccountDateEnd() {
return accountDateEnd;
}

public void setAccountDateEnd(Integer accountDateEnd) {
this.accountDateEnd = accountDateEnd;
}
}

+ 24
- 3
src/main/java/com/qtzl/alterSales/manager/model/protocol/sales/AflPaccountRefundCountFindPageViewRequest.java Voir le fichier

@@ -5,17 +5,22 @@ import com.qtzl.alterSales.manager.model.protocol.AbstractAfterSalesPageRequest;
public class AflPaccountRefundCountFindPageViewRequest extends AbstractAfterSalesPageRequest<AflPaccountRefundCountFindPageViewResponse> {

/** 记账日期 */
private String accountDate ;
private Integer accountDate ;
/** 渠道编号 */
private String agentId ;
/** 渠道名称 */
private String agentName ;

public String getAccountDate() {
/** 记账日期开始时间 */
private Integer accountDateStart;
/** 记账日期结束时间 */
private Integer accountDateEnd;

public Integer getAccountDate() {
return accountDate;
}

public void setAccountDate(String accountDate) {
public void setAccountDate(Integer accountDate) {
this.accountDate = accountDate;
}

@@ -34,4 +39,20 @@ public class AflPaccountRefundCountFindPageViewRequest extends AbstractAfterSale
public void setAgentName(String agentName) {
this.agentName = agentName;
}

public Integer getAccountDateStart() {
return accountDateStart;
}

public void setAccountDateStart(Integer accountDateStart) {
this.accountDateStart = accountDateStart;
}

public Integer getAccountDateEnd() {
return accountDateEnd;
}

public void setAccountDateEnd(Integer accountDateEnd) {
this.accountDateEnd = accountDateEnd;
}
}

+ 5
- 5
src/main/java/com/qtzl/alterSales/manager/quartz/FssPaccountPayCountTask.java Voir le fichier

@@ -2,7 +2,6 @@ package com.qtzl.alterSales.manager.quartz;


import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import com.qtzl.alterSales.manager.service.AflPaccountRefundCountService;
import com.qtzl.alterSales.manager.service.FssPaccountPayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,17 +21,18 @@ public class FssPaccountPayCountTask {

@Resource
private FssPaccountPayService fssPaccountPayService;
@Resource
AflPaccountRefundCountService aflPaccountRefundCountService;
/**
* 定时统计部中心流水数据
* 定时统计部中心流水数据前一天流水
*/
// @Scheduled(cron = "* */1 * * * ?")
@Scheduled(cron = "0 0 5 ? * *")
public void count(){
log.info("执行定时统计部中心原始流水表");
try {
fssPaccountPayService.count();
// for (int i = 1; i < 7; i++) {
// fssPaccountPayService.count(i);
// }
fssPaccountPayService.count(1);
} catch (ServiceHandleException e) {
e.printStackTrace();
}

+ 1
- 0
src/main/java/com/qtzl/alterSales/manager/service/AflBlackInfoServiceImpl.java Voir le fichier

@@ -97,6 +97,7 @@ public class AflBlackInfoServiceImpl implements AflBlackInfoService{
if (request.getOpType()!=null) {
list.add(cb.equal(root.<BlacklistOpType>get("opType"), request.getOpType()));
}

if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeEnd()));
}

+ 20
- 4
src/main/java/com/qtzl/alterSales/manager/service/AflPaccountRefundCountServiceImpl.java Voir le fichier

@@ -106,7 +106,7 @@ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCount
}
String format =null;
try {
format = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(fssPaccountPay.getInserttime());
format = DateTimeFormatter.ofPattern("yyyyMMdd").format(fssPaccountPay.getInserttime());
} catch (Exception e) {
log.error("查询到流水信息插入时间转换有误,payId ={}",payId);
return;
@@ -115,15 +115,31 @@ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCount
log.error("查询到流水信息时间日期为空,payId ={}",payId);
return;
}
AflPaccountRefundCount aflPaccountRefundCount =aflPaccountRefundCountRepo.finByDateAndAgentId(fssPaccountPay.getAgentId(),format);

AflPaccountRefundCount aflPaccountRefundCount = null;
try {
if ("52010188999".equals(fssPaccountPay.getAgentId())){
fssPaccountPay.setAgentId("52010188930");
}
aflPaccountRefundCount = aflPaccountRefundCountRepo.finByDateAndAgentId(fssPaccountPay.getAgentId(),Integer.parseInt(format));
} catch (NumberFormatException e) {
log.error("格式转换有误,AgentId ={},accountDate={}",fssPaccountPay.getAgentId(),format);
}
if (aflPaccountRefundCount==null){
log.error("未查询到部中心原始流水统计信息,AgentId ={},accountDate={}",fssPaccountPay.getAgentId(),format);
return;
}
Long collectMoney = aflPaccountRefundCount.getCollectMoney();
Long collectMoney =0l;
if (aflPaccountRefundCount.getCollectMoney()!=null){
collectMoney = aflPaccountRefundCount.getCollectMoney();
}
// Long collectMoney = aflPaccountRefundCount.getCollectMoney();
log.info("查询到流水统计信息已收取金额为,collectMoney ={}",collectMoney);
log.info("查询到流水信息扣款金额为,receiptAmt ={}",fssPaccountPay.getReceiptAmt());
Long newCollectMoney = collectMoney + fssPaccountPay.getReceiptAmt();
Long newCollectMoney=collectMoney;
if (fssPaccountPay.getReceiptAmt()!=null){
newCollectMoney = collectMoney + fssPaccountPay.getReceiptAmt();
}
log.info("查询到流水统计信息最新已收取金额为,newCollectMoney ={}",newCollectMoney);
aflPaccountRefundCount.setCollectMoney(newCollectMoney);
aflPaccountRefundCount.setUpdateTime(LocalDateTime.now());

+ 1
- 1
src/main/java/com/qtzl/alterSales/manager/service/FssPaccountPayService.java Voir le fichier

@@ -30,6 +30,6 @@ public interface FssPaccountPayService {
*/
List<VehicleAgreementNumBillsVo> findByPayId(List<String> payIds);

void count() throws ServiceHandleException;
void count(int day) throws ServiceHandleException;

}

+ 52
- 14
src/main/java/com/qtzl/alterSales/manager/service/FssPaccountPayServiceImpl.java Voir le fichier

@@ -83,31 +83,69 @@ public class FssPaccountPayServiceImpl implements FssPaccountPayService {
}

@Override
public void count() throws ServiceHandleException {
public void count(int day) throws ServiceHandleException {
// 获取当前日期前一天的日期
LocalDate localDate = LocalDate.now().minusDays(1);//1代表提前多少天
LocalDate localDate = LocalDate.now().minusDays(day);//1代表提前多少天
String yesterday = localDate.toString();
Integer i= aflPaccountRefundCountRepo.findByToDay(yesterday);
Integer i= aflPaccountRefundCountRepo.findByToDay(yesterday.replaceAll("-",""));
if (i!=null&&i>0){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+1天记录已存在");
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+"+day+"天记录已存在");
}

List<Map<String, Object>> countTotal = paccountPayRepo.findCountTotal(yesterday+" 00:00:00");
List<AflPaccountRefundCount> list = new ArrayList<AflPaccountRefundCount>();
List<Map<String, Object>> countTotal = paccountPayRepo.findCountTotal(yesterday+" 00:00:00",yesterday+" 23:59:59");
List<AflPaccountRefundCountVo> list = new ArrayList<AflPaccountRefundCountVo>();
for (Map<String, Object> stringObjectMap : countTotal) {
AflPaccountRefundCount aflPaccountRefundCount = new AflPaccountRefundCount();
AflPaccountRefundCountVo aflPaccountRefundCountVo = JSON.parseObject(JSON.toJSONString(stringObjectMap), AflPaccountRefundCountVo.class);
System.out.println(aflPaccountRefundCountVo.toString());
BeanUtils.copyProperties(aflPaccountRefundCountVo,aflPaccountRefundCount);
list.add(aflPaccountRefundCount);
list.add(aflPaccountRefundCountVo);
}
if (list==null||list.size()<1){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+1天记录无数据");
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+"+day+"天记录无数据");
}
log.info("本次处理数据:{}", JSON.toJSON(list));
for (AflPaccountRefundCount aflPaccountRefundCount : list) {
Long refundMoney = fssPaccountRefundRepo.findByCountRefundMoney(aflPaccountRefundCount.getAgentId(),aflPaccountRefundCount.getAccountDate());
AflPaccountRefundCount bydAflPaccountRefundCount = null;
for (AflPaccountRefundCountVo aflPaccountRefundCountVo : list) {
AflPaccountRefundCount aflPaccountRefundCount = new AflPaccountRefundCount();
Long refundMoney = fssPaccountRefundRepo.findByCountRefundMoney(aflPaccountRefundCountVo.getAgentId(),aflPaccountRefundCountVo.getAccountDate());
BeanUtils.copyProperties(aflPaccountRefundCountVo,aflPaccountRefundCount);
aflPaccountRefundCount.setRefundMoney(refundMoney);
if (!StringUtils.isEmpty(aflPaccountRefundCountVo.getAccountDate())){
String accountDate=aflPaccountRefundCountVo.getAccountDate().replaceAll("-","");
Integer newAccountDate = Integer.parseInt(accountDate);
aflPaccountRefundCount.setAccountDate(newAccountDate);
}
if ("52010188999".equals(aflPaccountRefundCount.getAgentId())&&aflPaccountRefundCount.getAccountDate()!=null){
bydAflPaccountRefundCount=aflPaccountRefundCount;
AflPaccountRefundCount bydNewAflPaccountRefundCount= aflPaccountRefundCountRepo.finByDateAndAgentId("52010188930",aflPaccountRefundCount.getAccountDate());
if (bydNewAflPaccountRefundCount!=null){
if (bydAflPaccountRefundCount.getMoneyTotal()!=null){
bydNewAflPaccountRefundCount.setMoneyTotal(bydNewAflPaccountRefundCount.getMoneyTotal()+bydAflPaccountRefundCount.getMoneyTotal());
}
if (bydAflPaccountRefundCount.getRefundMoney()!=null){
bydNewAflPaccountRefundCount.setRefundMoney(bydNewAflPaccountRefundCount.getRefundMoney()+bydAflPaccountRefundCount.getRefundMoney());
}
if (bydAflPaccountRefundCount.getCollectMoney()!=null){
bydNewAflPaccountRefundCount.setCollectMoney(bydNewAflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney());
}
if (bydAflPaccountRefundCount.getNumberTotal()!=null){
bydNewAflPaccountRefundCount.setNumberTotal(bydNewAflPaccountRefundCount.getNumberTotal()+bydAflPaccountRefundCount.getNumberTotal());
}
aflPaccountRefundCountRepo.save(bydNewAflPaccountRefundCount);
}
continue;
}
if ("52010188930".equals(aflPaccountRefundCount.getAgentId())&&bydAflPaccountRefundCount!=null){
if (bydAflPaccountRefundCount.getMoneyTotal()!=null){
aflPaccountRefundCount.setMoneyTotal(aflPaccountRefundCount.getMoneyTotal()+bydAflPaccountRefundCount.getMoneyTotal());
}
if (bydAflPaccountRefundCount.getRefundMoney()!=null){
aflPaccountRefundCount.setRefundMoney(aflPaccountRefundCount.getRefundMoney()+bydAflPaccountRefundCount.getRefundMoney());
}
if (bydAflPaccountRefundCount.getCollectMoney()!=null){
aflPaccountRefundCount.setCollectMoney(aflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney());
}
if (bydAflPaccountRefundCount.getNumberTotal()!=null){
aflPaccountRefundCount.setCollectMoney(aflPaccountRefundCount.getCollectMoney()+bydAflPaccountRefundCount.getCollectMoney());
}
}
aflPaccountRefundCount.setId(UUID.randomUUID().toString().replace("-", ""));
aflPaccountRefundCount.setUpdateTime(LocalDateTime.now());
aflPaccountRefundCount.setInsertTime(LocalDateTime.now());

Chargement…
Annuler
Enregistrer