瀏覽代碼

Merge branch 'zhangxin' into lihao

shuiqilin
lihao 1 年之前
父節點
當前提交
18c538d047

+ 3
- 0
src/main/java/com/qtzl/alterSales/dao/repo/jpa/primary/AflAgencyMchRelRepo.java 查看文件

import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel; import com.qtzl.alterSales.dao.entity.primary.AflAgencyMchRel;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;


/*** /***
* <p> * <p>
JpaRepository<AflAgencyMchRel, String>, JpaRepository<AflAgencyMchRel, String>,
JpaSpecificationExecutor<AflAgencyMchRel> { JpaSpecificationExecutor<AflAgencyMchRel> {


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

+ 71
- 14
src/main/java/com/qtzl/alterSales/manager/handler/AflPaccountRefundCountFindPageHandler.java 查看文件

package com.qtzl.alterSales.manager.handler; package com.qtzl.alterSales.manager.handler;


import cn.com.taiji.common.manager.net.http.ServiceHandleException; 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.dao.repo.jpa.second.AflPaccountRefundCountRepo;
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager; import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; 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.AflPaccountRefundCountFindPageViewRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewResponse; import com.qtzl.alterSales.manager.model.protocol.sales.AflPaccountRefundCountFindPageViewResponse;
import com.qtzl.alterSales.manager.service.AfterSalesCmd; import com.qtzl.alterSales.manager.service.AfterSalesCmd;
import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo; import com.qtzl.alterSales.manager.vo.AflPaccountRefundCountVo;
import com.txffp.api.core.manager.comm.annotation.ApiHandler; 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 org.springframework.stereotype.Service;


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


/** /**
* 查询部中心原始流水统计分页 * 查询部中心原始流水统计分页
@Resource @Resource
AflPaccountRefundCountRepo aflPaccountRefundCountRepo; AflPaccountRefundCountRepo aflPaccountRefundCountRepo;


@Resource
AflAgencyMchRelRepo aflAgencyMchRelRepo;

public AflPaccountRefundCountFindPageHandler() { public AflPaccountRefundCountFindPageHandler() {
super(AfterSalesCmd.FINDPAGEPACCOUNTREFUNDCOUNT, AflPaccountRefundCountFindPageViewRequest.class); super(AfterSalesCmd.FINDPAGEPACCOUNTREFUNDCOUNT, AflPaccountRefundCountFindPageViewRequest.class);
} }
@Override @Override
public String handleInternal(String filename, AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException { public String handleInternal(String filename, AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
try { try {
Pagination page =select(request);
return toResponse(page).toJson();
Page<AflPaccountRefundCount> page = select(request);
return toResponse(page,request).toJson();
} catch (Exception e) { } catch (Exception e) {
if (e instanceof ServiceHandleException) { if (e instanceof ServiceHandleException) {
throw e; throw e;
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("查询部中心原始流水统计失败"); 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(); 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; 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; return response;
} }


private Pagination select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
private Page<AflPaccountRefundCount> select(AflPaccountRefundCountFindPageViewRequest request) throws ServiceHandleException {
if (request.getPageSize() > 100) { if (request.getPageSize() > 100) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize()); 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 查看文件

package com.qtzl.alterSales.manager.service; package com.qtzl.alterSales.manager.service;


import cn.com.taiji.common.manager.net.http.ServiceHandleException; 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.primary.FssPaccountPay;
import com.qtzl.alterSales.dao.entity.second.AflPaccountRefundCount; 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.primary.FssPaccountPayRepo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo; import com.qtzl.alterSales.dao.repo.jpa.second.AflPaccountRefundCountRepo;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; 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.AflPaccountRefundCountFindPageViewRequest;
import com.qtzl.alterSales.manager.service.third.ConstantConfig; import com.qtzl.alterSales.manager.service.third.ConstantConfig;
import com.qtzl.alterSales.manager.service.third.FmsService; import com.qtzl.alterSales.manager.service.third.FmsService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


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


@Service @Service
public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCountService{ public class AflPaccountRefundCountServiceImpl implements AflPaccountRefundCountService{
@Resource @Resource
AflPaccountRefundCountRepo aflPaccountRefundCountRepo; AflPaccountRefundCountRepo aflPaccountRefundCountRepo;
@Resource @Resource
AflAgencyMchRelRepo aflAgencyMchRelRepo;
@Resource
FssPaccountPayRepo fssPaccountPayRepo; FssPaccountPayRepo fssPaccountPayRepo;
@Resource @Resource
FmsService fmsService; FmsService fmsService;
public String export(AflPaccountRefundCountFindPageViewRequest request, Logger logger) throws ServiceHandleException { public String export(AflPaccountRefundCountFindPageViewRequest request, Logger logger) throws ServiceHandleException {
String pathFile =null; String pathFile =null;
try { 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) { if (aflPaccountRefundCountVos==null||aflPaccountRefundCountVos.size()==0) {
pathFile = ExcelUtils.export(null, "部中心请款流水统计",constantConfig.getFilePath() ,null, AflPaccountRefundCountVo.class); pathFile = ExcelUtils.export(null, "部中心请款流水统计",constantConfig.getFilePath() ,null, AflPaccountRefundCountVo.class);
} else { } else {
aflPaccountRefundCount.setUpdateTime(LocalDateTime.now()); aflPaccountRefundCount.setUpdateTime(LocalDateTime.now());
aflPaccountRefundCountRepo.save(aflPaccountRefundCount); 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 查看文件

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

Loading…
取消
儲存