Browse Source

Merge branch 'zhangxin' into lihao

shuiqilin
lihao 1 year ago
parent
commit
18c538d047

+ 3
- 0
src/main/java/com/qtzl/alterSales/dao/repo/jpa/primary/AflAgencyMchRelRepo.java View File

@@ -3,6 +3,7 @@ package com.qtzl.alterSales.dao.repo.jpa.primary;
import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/***
* <p>
@@ -13,4 +14,6 @@ public interface AflAgencyMchRelRepo extends
JpaRepository<AflAgencyMchRel, String>,
JpaSpecificationExecutor<AflAgencyMchRel> {

@Query(" from AflAgencyMchRel where agencyId =?1 ")
AflAgencyMchRel findByAgencyId(String agentId);
}

+ 71
- 14
src/main/java/com/qtzl/alterSales/manager/handler/AflPaccountRefundCountFindPageHandler.java View File

@@ -1,21 +1,29 @@
package com.qtzl.alterSales.manager.handler;

import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.common.model.dao.Pagination;
import cn.com.taiji.common.pub.BeanTools;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.collect.Lists;
import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel;
import com.qtzl.alterSales.dao.entity.second.AflPaccountRefundCount;
import com.qtzl.alterSales.dao.repo.jpa.primary.AflAgencyMchRelRepo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo;
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewResponse;
import com.qtzl.alterSales.manager.service.AfterSalesCmd;
import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo;
import com.txffp.api.core.manager.comm.annotation.ApiHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import java.util.List;
import java.util.stream.Collectors;

/**
* 查询部中心原始流水统计分页
@@ -27,6 +35,9 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan
@Resource
AflPaccountRefundCountRepo aflPaccountRefundCountRepo;

@Resource
AflAgencyMchRelRepo aflAgencyMchRelRepo;

public AflPaccountRefundCountFindPageHandler() {
super(AfterSalesCmd.FINDPAGEPACCOUNTREFUNDCOUNT, AflPaccountRefundCountFindPageViewRequest.class);
}
@@ -34,8 +45,8 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan
@Override
public String handleInternal(String filename, AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
try {
Pagination page =select(request);
return toResponse(page).toJson();
Page<AflPaccountRefundCount> page = select(request);
return toResponse(page,request).toJson();
} catch (Exception e) {
if (e instanceof ServiceHandleException) {
throw e;
@@ -44,22 +55,68 @@ public class AflPaccountRefundCountFindPageHandler extends AbstractAfterSalesMan
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("查询部中心原始流水统计失败");
}
}
private AflPaccountRefundCountFindPageViewResponse toResponse(Pagination pagination) {
// private AflPaccountRefundCountFindPageViewResponse toResponse(Pagination pagination) {
// final AflPaccountRefundCountFindPageViewResponse response = new AflPaccountRefundCountFindPageViewResponse();
// BeanTools.copyProperties(pagination, response);
// if (isEmpty(pagination.getResult())) {
// return response;
// }
// response.setData(pagination.getResult(AflPaccountRefundCountVo.class));
// return response;
// }

// private Pagination select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
// if (request.getPageSize() > 100) {
// throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize());
// }
// AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest();
// BeanUtil.copyProperties(request, queryRequest);
// return aflPaccountRefundCountRepo.page(queryRequest);
// }

private AflPaccountRefundCountFindPageViewResponse toResponse(Page<AflPaccountRefundCount> page, AflPaccountRefundCountFindPageViewRequest request) {
final AflPaccountRefundCountFindPageViewResponse response = new AflPaccountRefundCountFindPageViewResponse();
BeanTools.copyProperties(pagination, response);
if (isEmpty(pagination.getResult())) {
response.setCurrentPage(request.getPageNo());
response.setPageSize(request.getPageSize());
response.setPageCount(page.getTotalPages());
response.setTotalCount(page.getTotalElements());
if (isEmpty(page.getContent())) {
response.setData(Lists.newArrayList());
return response;
}
response.setData(pagination.getResult(AflPaccountRefundCountVo.class));
List<AflPaccountRefundCountVo> formVoList = page.getContent().stream().map(this::toVo).collect(Collectors.toList());
response.setData(formVoList);
return response;
}

private Pagination select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
private Page<AflPaccountRefundCount> select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
if (request.getPageSize() > 100) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize());
}
AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest();
BeanUtil.copyProperties(request, queryRequest);
return aflPaccountRefundCountRepo.page(queryRequest);
return aflPaccountRefundCountRepo.findAll(((root, query, cb) -> {
List<Predicate> list = Lists.newArrayList();
if (!StringUtils.isEmpty(request.getAgentId())) {
list.add(cb.equal(root.<Integer>get("agentId"), request.getAgentId()));
}
if (request.getAccountDateEnd()!=null) {
list.add(cb.le(root.<Integer>get("accountDate"), request.getAccountDateEnd()));
}
if (request.getAccountDateStart()!=null) {
list.add(cb.ge(root.<Integer>get("accountDate"), request.getAccountDateStart()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}), PageRequest.of(request.getPageNo() - 1, request.getPageSize(),
Sort.by(Sort.Direction.DESC, "accountDate")));
}

private AflPaccountRefundCountVo toVo(AflPaccountRefundCount aflPaccountRefundCount) {
AflPaccountRefundCountVo aflPaccountRefundCountVo = new AflPaccountRefundCountVo();
BeanUtils.copyProperties(aflPaccountRefundCount,aflPaccountRefundCountVo);
AflAgencyMchRel aflAgencyMchRel = aflAgencyMchRelRepo.findByAgencyId(aflPaccountRefundCountVo.getAgentId());
if (aflAgencyMchRel!=null){
aflPaccountRefundCountVo.setAgentName(aflAgencyMchRel.getAgencyName());
}
return aflPaccountRefundCountVo;
}
}

+ 42
- 5
src/main/java/com/qtzl/alterSales/manager/service/AflPaccountRefundCountServiceImpl.java View File

@@ -1,13 +1,14 @@
package com.qtzl.alterSales.manager.service;

import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.collect.Lists;
import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel;
import com.qtzl.alterSales.dao.entity.primary.FssPaccountPay;
import com.qtzl.alterSales.dao.entity.second.AflPaccountRefundCount;
import com.qtzl.alterSales.dao.repo.jpa.primary.AflAgencyMchRelRepo;
import com.qtzl.alterSales.dao.repo.jpa.primary.FssPaccountPayRepo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewRequest;
import com.qtzl.alterSales.manager.service.third.ConstantConfig;
import com.qtzl.alterSales.manager.service.third.FmsService;
@@ -16,13 +17,17 @@ import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import java.io.File;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCountService{
@@ -32,6 +37,8 @@ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCount
@Resource
AflPaccountRefundCountRepo aflPaccountRefundCountRepo;
@Resource
AflAgencyMchRelRepo aflAgencyMchRelRepo;
@Resource
FssPaccountPayRepo fssPaccountPayRepo;
@Resource
FmsService fmsService;
@@ -41,9 +48,11 @@ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCount
public String export(AflPaccountRefundCountFindPageViewRequest request, Logger logger) throws ServiceHandleException {
String pathFile =null;
try {
AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest();
BeanUtil.copyProperties(request, queryRequest);
List<AflPaccountRefundCountVo> aflPaccountRefundCountVos = aflPaccountRefundCountRepo.list(queryRequest);
// AflPaccountRefundCountFindPageRequest queryRequest = new AflPaccountRefundCountFindPageRequest();
// BeanUtil.copyProperties(request, queryRequest);
// List<AflPaccountRefundCountVo> aflPaccountRefundCountVos = aflPaccountRefundCountRepo.list(queryRequest);
List<AflPaccountRefundCount> select = select(request);
List<AflPaccountRefundCountVo> aflPaccountRefundCountVos = select.stream().map(this::toVo).collect(Collectors.toList());
if (aflPaccountRefundCountVos==null||aflPaccountRefundCountVos.size()==0) {
pathFile = ExcelUtils.export(null, "部中心请款流水统计",constantConfig.getFilePath() ,null, AflPaccountRefundCountVo.class);
} else {
@@ -146,4 +155,32 @@ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCount
aflPaccountRefundCount.setUpdateTime(LocalDateTime.now());
aflPaccountRefundCountRepo.save(aflPaccountRefundCount);
}


private List<AflPaccountRefundCount> select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
return aflPaccountRefundCountRepo.findAll(((root, query, cb) -> {
List<Predicate> list = Lists.newArrayList();
if (!StringUtils.isEmpty(request.getAgentId())) {
list.add(cb.equal(root.<Integer>get("agentId"), request.getAgentId()));
}
if (request.getAccountDateEnd()!=null) {
list.add(cb.le(root.<Integer>get("accountDate"), request.getAccountDateEnd()));
}
if (request.getAccountDateStart()!=null) {
list.add(cb.ge(root.<Integer>get("accountDate"), request.getAccountDateStart()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}), Sort.by(Sort.Direction.DESC, "accountDate"));
}

private AflPaccountRefundCountVo toVo(AflPaccountRefundCount aflPaccountRefundCount) {
AflPaccountRefundCountVo aflPaccountRefundCountVo = new AflPaccountRefundCountVo();
BeanUtils.copyProperties(aflPaccountRefundCount,aflPaccountRefundCountVo);
AflAgencyMchRel aflAgencyMchRel = aflAgencyMchRelRepo.findByAgencyId(aflPaccountRefundCountVo.getAgentId());
if (aflAgencyMchRel!=null){
aflPaccountRefundCountVo.setAgentName(aflAgencyMchRel.getAgencyName());
}
return aflPaccountRefundCountVo;
}
}

+ 1
- 0
src/main/java/com/qtzl/alterSales/manager/service/FssPaccountPayServiceImpl.java View File

@@ -87,6 +87,7 @@ public class FssPaccountPayServiceImpl implements FssPaccountPayService {
// 获取当前日期前一天的日期
LocalDate localDate = LocalDate.now().minusDays(day);//1代表提前多少天
String yesterday = localDate.toString();
System.out.println("当前导入记录日期="+yesterday);
Integer i= aflPaccountRefundCountRepo.findByToDay(yesterday.replaceAll("-",""));
if (i!=null&&i>0){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("当前n+"+day+"天记录已存在");

Loading…
Cancel
Save