|
|
@@ -1,27 +1,27 @@ |
|
|
|
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.hutool.core.bean.BeanUtil; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.qtzl.alterSales.dao.entity.second.AflBydDashboard; |
|
|
|
import com.qtzl.alterSales.dao.entity.second.AflBydDashboardDetail; |
|
|
|
import com.qtzl.alterSales.dao.repo.jpa.second.AflBydDashboardDetailRepo; |
|
|
|
import com.qtzl.alterSales.dao.repo.jpa.second.AflBydDashboardRepo; |
|
|
|
import com.qtzl.alterSales.manager.abstracts.AbstractAfterSalesManager; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.UcServiceError; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.BydDashBoardDetailPageRequest; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.BydDashBoardDetailPageResponse; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.BydDashBoardPageRequest; |
|
|
|
import com.qtzl.alterSales.manager.model.protocol.sales.BydDashBoardPageResponse; |
|
|
|
import com.qtzl.alterSales.manager.service.AfterSalesCmd; |
|
|
|
import com.qtzl.alterSales.manager.vo.BydDashBoardDetailVo; |
|
|
|
import com.qtzl.alterSales.manager.vo.BydDashBoardVo; |
|
|
|
import com.txffp.api.core.manager.comm.annotation.ApiHandler; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
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; |
|
|
|
|
|
|
@@ -34,12 +34,14 @@ import java.util.stream.Collectors; |
|
|
|
**/ |
|
|
|
@Service |
|
|
|
@ApiHandler |
|
|
|
public class BydDashBoardDetailPageHandler extends AbstractAfterSalesManager<BydDashBoardDetailPageRequest>{ |
|
|
|
public class BydDashBoardDetailPageHandler extends AbstractAfterSalesManager<BydDashBoardDetailPageRequest> { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AflBydDashboardDetailRepo aflBydDashboardDetailRepo; |
|
|
|
@Resource |
|
|
|
private AflBydDashboardRepo aflBydDashboardRepo; |
|
|
|
|
|
|
|
public BydDashBoardDetailPageHandler(){ |
|
|
|
public BydDashBoardDetailPageHandler() { |
|
|
|
super(AfterSalesCmd.BYDDASHBOARDDETAILPAGE, BydDashBoardDetailPageRequest.class); |
|
|
|
} |
|
|
|
|
|
|
@@ -47,10 +49,8 @@ public class BydDashBoardDetailPageHandler extends AbstractAfterSalesManager<Byd |
|
|
|
public String handleInternal(String filename, BydDashBoardDetailPageRequest request) throws ServiceHandleException { |
|
|
|
try { |
|
|
|
logger.info("比亚迪看板数据批次明细-分页查询,请求参数:{}", request.toJson(true)); |
|
|
|
/*Pagination pagination = select(request); |
|
|
|
return toResponse(page, request).toJson();*/ |
|
|
|
// TODO |
|
|
|
return null; |
|
|
|
Page<AflBydDashboardDetail> page = select(request); |
|
|
|
return toResponse(page, request).toJson(); |
|
|
|
} catch (Exception e) { |
|
|
|
if (e instanceof ServiceHandleException) { |
|
|
|
throw e; |
|
|
@@ -75,10 +75,41 @@ public class BydDashBoardDetailPageHandler extends AbstractAfterSalesManager<Byd |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
private Page<AflBydDashboardDetail> select(BydDashBoardDetailPageRequest request) throws ServiceHandleException { |
|
|
|
if (request.getPageSize() > 100) { |
|
|
|
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException("请求每页数量过大 " + request.getPageSize()); |
|
|
|
} |
|
|
|
return aflBydDashboardDetailRepo.findAll(((root, query, cb) -> { |
|
|
|
List<Predicate> list = Lists.newArrayList(); |
|
|
|
if (!StringUtils.isEmpty(request.getDashboardId())) { |
|
|
|
list.add(cb.equal(root.<String>get("dashboardId"), request.getDashboardId())); |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(request.getPlateNum())) { |
|
|
|
list.add(cb.equal(root.<String>get("plateNum"), request.getPlateNum())); |
|
|
|
} |
|
|
|
if (null != request.getPlateColor()) { |
|
|
|
list.add(cb.equal(root.<Integer>get("plateColor"), request.getPlateColor())); |
|
|
|
} |
|
|
|
if (!StringUtils.isEmpty(request.getVin())) { |
|
|
|
list.add(cb.equal(root.<String>get("vin"), request.getVin())); |
|
|
|
} |
|
|
|
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 BydDashBoardDetailVo toVo(AflBydDashboardDetail dashboardDetail) { |
|
|
|
BydDashBoardDetailVo boardDetailVo = new BydDashBoardDetailVo(); |
|
|
|
BeanUtil.copyProperties(dashboardDetail, boardDetailVo); |
|
|
|
final AflBydDashboard dashboard = aflBydDashboardRepo.findById(dashboardDetail.getDashboardId()).orElse(null); |
|
|
|
if (null != dashboard) { |
|
|
|
// |
|
|
|
boardDetailVo.setBatchNo(dashboard.getBatchNo()); |
|
|
|
boardDetailVo.setPushState(dashboard.getPushState()); |
|
|
|
boardDetailVo.setPushDate(dashboard.getPushDate()); |
|
|
|
} |
|
|
|
return boardDetailVo; |
|
|
|
} |
|
|
|
} |