Browse Source

Merge branch 'zhangxin' into lihao

shuiqilin
lihao 1 year ago
parent
commit
8d3d1e87a4

+ 0
- 1
application.pid View File

@@ -1 +0,0 @@
39724

+ 3
- 3
src/main/java/com/qtzl/alterSales/manager/handler/AflBlackInfoFindPageHandler.java View File

@@ -19,7 +19,7 @@ import org.springframework.stereotype.Service;

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

@@ -84,10 +84,10 @@ public class AflBlackInfoFindPageHandler extends AbstractAfterSalesManager<AflBl
list.add(cb.equal(root.<BlacklistOpType>get("opType"), request.getOpType()));
}
if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
list.add(cb.lessThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeEnd()));
}
if (request.getInsertTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
list.add(cb.greaterThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeStart()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));

+ 76
- 20
src/main/java/com/qtzl/alterSales/manager/handler/AflProductFindPageHandler.java View File

@@ -1,42 +1,50 @@
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.second.AflProductInfo;
import com.qtzl.alterSales.dao.repo.jpa.second.AflProductInfoRepo;
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager;
import com.qtzl.alterSales.manager.model.protocol.UcServiceError;
import com.qtzl.alterSales.manager.model.protocol.sales.AflProductInfoFindPageRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflProductInfoFindPageResponse;
import com.qtzl.alterSales.manager.model.protocol.sales.AflProductInfoFindPageViweRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflProductInfoFindPageViewRequest;
import com.qtzl.alterSales.manager.model.protocol.sales.AflProductInfoFindPageViewResponse;
import com.qtzl.alterSales.manager.service.AfterSalesCmd;
import com.qtzl.alterSales.manager.vo.AflProductInfoFindPageVo;
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.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* 查询产品管理
*/
@Service
@ApiHandler
public class AflProductFindPageHandler extends AbstractAfterSalesManager<AflProductInfoFindPageViweRequest> {
public class AflProductFindPageHandler extends AbstractAfterSalesManager<AflProductInfoFindPageViewRequest> {

@Resource
AflProductInfoRepo aflProductInfoRepo;


public AflProductFindPageHandler() {
super(AfterSalesCmd.FINDPAGEPRODUCTINFO, AflProductInfoFindPageViweRequest.class);
super(AfterSalesCmd.FINDPAGEPRODUCTINFO, AflProductInfoFindPageViewRequest.class);
}

@Override
public String handleInternal(String filename, AflProductInfoFindPageViweRequest request) throws ServiceHandleException {
public String handleInternal(String filename, AflProductInfoFindPageViewRequest request) throws ServiceHandleException {
try {
Pagination page =select(request);
return toResponse(page).toJson();
// Pagination page =select(request);
Page<AflProductInfo> page = select(request);
return toResponse(page,request).toJson();
} catch (Exception e) {
if (e instanceof ServiceHandleException) {
throw e;
@@ -46,23 +54,71 @@ public class AflProductFindPageHandler extends AbstractAfterSalesManager<AflProd
}
}

private AflProductInfoFindPageResponse toResponse(Pagination pagination) {
final AflProductInfoFindPageResponse response = new AflProductInfoFindPageResponse();
BeanTools.copyProperties(pagination, response);
if (isEmpty(pagination.getResult())) {
private AflProductInfoFindPageViewResponse toResponse(Page<AflProductInfo> page, AflProductInfoFindPageViewRequest request) {
final AflProductInfoFindPageViewResponse response = new AflProductInfoFindPageViewResponse();
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(AflProductInfoFindPageVo.class));
List<AflProductInfoFindPageVo> formVoList = page.getContent().stream().map(this::toVo).collect(Collectors.toList());
response.setData(formVoList);
return response;
}

private Pagination select(AflProductInfoFindPageViweRequest request) throws ServiceHandleException {

private Page<AflProductInfo> select(AflProductInfoFindPageViewRequest request) throws ServiceHandleException {
if (request.getPageSize() > 100) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize());
}
AflProductInfoFindPageRequest queryRequest = new AflProductInfoFindPageRequest();
BeanUtil.copyProperties(request, queryRequest);
return aflProductInfoRepo.page(queryRequest);
return aflProductInfoRepo.findAll(((root, query, cb) -> {
List<Predicate> list = Lists.newArrayList();
if (!StringUtils.isEmpty(request.getProductCode())) {
list.add(cb.equal(root.<String>get("productCode"), request.getProductCode()));
}
if (!StringUtils.isEmpty(request.getProductName())) {
list.add(cb.equal(root.get("productName"), request.getProductName()));
}
if (request.getAuditStatus()!=null) {
list.add(cb.equal(root.<Integer>get("auditStatus"), request.getAuditStatus()));
}
if (request.getGroundStatus()!=null) {
list.add(cb.equal(root.<Integer>get("groundStatus"), request.getGroundStatus()));
}
if (request.getGroundTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeEnd()));
}
if (request.getGroundTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("groundTime"), request.getGroundTimeStart()));
}
if (request.getUndercarriageTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeEnd()));
}
if (request.getUndercarriageTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("undercarriageTime"), request.getUndercarriageTimeStart()));
}
if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
}
if (request.getInsertTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
}
//查询为未删除的数据
list.add(cb.equal(root.<Integer>get("isDelete"), 0));
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}), PageRequest.of(request.getPageNo() - 1, request.getPageSize(),
Sort.by(Sort.Direction.DESC, "insertTime")));
}
private AflProductInfoFindPageVo toVo(AflProductInfo aflProductInfo) {
AflProductInfoFindPageVo aflProductInfoFindPageVo = new AflProductInfoFindPageVo();
BeanUtils.copyProperties(aflProductInfo,aflProductInfoFindPageVo);
return aflProductInfoFindPageVo;
}

}



+ 7
- 7
src/main/java/com/qtzl/alterSales/manager/model/protocol/sales/AflBlackInfoFindPageViewRequest.java View File

@@ -3,7 +3,7 @@ package com.qtzl.alterSales.manager.model.protocol.sales;
import com.qtzl.alterSales.manager.enums.BlacklistOpType;
import com.qtzl.alterSales.manager.model.protocol.AbstractAfterSalesPageRequest;

import java.util.Date;
import java.time.LocalDateTime;

public class AflBlackInfoFindPageViewRequest extends AbstractAfterSalesPageRequest<AflBlackInfoFindPageViewResponse> {

@@ -17,9 +17,9 @@ public class AflBlackInfoFindPageViewRequest extends AbstractAfterSalesPageReque
/*** 用户手机号 */
private String mobile;
/** 创建时间开始时间 */
private Date insertTimeStart;
private LocalDateTime insertTimeStart;
/** 创建时间结束时间 */
private Date insertTimeEnd;
private LocalDateTime insertTimeEnd;

public String getAgreementNum() {
return agreementNum;
@@ -55,19 +55,19 @@ public class AflBlackInfoFindPageViewRequest extends AbstractAfterSalesPageReque
this.mobile = mobile;
}

public Date getInsertTimeStart() {
public LocalDateTime getInsertTimeStart() {
return insertTimeStart;
}

public void setInsertTimeStart(Date insertTimeStart) {
public void setInsertTimeStart(LocalDateTime insertTimeStart) {
this.insertTimeStart = insertTimeStart;
}

public Date getInsertTimeEnd() {
public LocalDateTime getInsertTimeEnd() {
return insertTimeEnd;
}

public void setInsertTimeEnd(Date insertTimeEnd) {
public void setInsertTimeEnd(LocalDateTime insertTimeEnd) {
this.insertTimeEnd = insertTimeEnd;
}
}

+ 5
- 6
src/main/java/com/qtzl/alterSales/manager/service/AflBlackInfoServiceImpl.java View File

@@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import java.io.File;
import java.util.Date;
import java.time.LocalDateTime;
import java.util.List;


@@ -43,7 +43,6 @@ public class AflBlackInfoServiceImpl implements AflBlackInfoService{
if (count> 10000l){
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("状态名单管理导出失败,数据大于10000不允许导出");
}

List<AflBlackInfo> aflBlackInfos = select(request);
if (aflBlackInfos==null||aflBlackInfos.size()==0) {
pathFile = ExcelUtils.export(null, "状态名单",constantConfig.getFilePath() ,null, AflBlackInfo.class);
@@ -99,10 +98,10 @@ public class AflBlackInfoServiceImpl implements AflBlackInfoService{
list.add(cb.equal(root.<BlacklistOpType>get("opType"), request.getOpType()));
}
if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
list.add(cb.lessThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeEnd()));
}
if (request.getInsertTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
list.add(cb.greaterThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeStart()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
@@ -124,10 +123,10 @@ public class AflBlackInfoServiceImpl implements AflBlackInfoService{
list.add(cb.equal(root.<BlacklistOpType>get("opType"), request.getOpType()));
}
if (request.getInsertTimeEnd()!=null) {
list.add(cb.lessThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeEnd()));
list.add(cb.lessThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeEnd()));
}
if (request.getInsertTimeStart()!=null) {
list.add(cb.greaterThanOrEqualTo(root.<Date>get("insertTime"), request.getInsertTimeStart()));
list.add(cb.greaterThanOrEqualTo(root.<LocalDateTime>get("insertTime"), request.getInsertTimeStart()));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));

Loading…
Cancel
Save