Browse Source

Merge branch 'dev' into pre-production

master
zhaoqiaobo 7 months ago
parent
commit
3c34e4a43e
  1. 9
      blade-service/logpm-report/src/main/java/com/logpm/report/reader/DeliveryDetailReader.java
  2. 4
      blade-service/logpm-report/src/main/java/com/logpm/report/service/IAsyncService.java
  3. 41
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/AsyncServiceImpl.java
  4. 12
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDeliverServiceImpl.java

9
blade-service/logpm-report/src/main/java/com/logpm/report/reader/DeliveryDetailReader.java

@ -1,9 +1,11 @@
package com.logpm.report.reader;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.report.mapper.ReportDeliverMapeer;
import com.logpm.report.service.ExportReader;
import com.logpm.report.service.IAsyncService;
import io.prometheus.client.CollectorRegistry;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,6 +25,8 @@ public class DeliveryDetailReader implements ExportReader {
private ReportDeliverMapeer reportDeliverMapeer;
@Autowired
private CollectorRegistry collectorRegistry;
@Autowired
private IAsyncService asyncService;
@Override
public Long getCount(Wrapper query) {
@ -34,10 +38,7 @@ public class DeliveryDetailReader implements ExportReader {
@Override
public List<T> findList(Page page, Wrapper query) {
List detailsPage = reportDeliverMapeer.getDetailsPage(page, query);
List detailsZeroPage = reportDeliverMapeer.getDetailsZeroPage(page.getCurrent(), page.getSize(), query);
detailsPage.addAll(detailsZeroPage);
return detailsPage;
return asyncService.getdetailPages(page, query, Convert.toInt(page.getCurrent()), Convert.toInt(page.getTotal()));
}
}

4
blade-service/logpm-report/src/main/java/com/logpm/report/service/IAsyncService.java

@ -1,7 +1,9 @@
package com.logpm.report.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.vo.ReportDetailVO;
import java.util.List;
import java.util.Map;
@ -17,4 +19,6 @@ public interface IAsyncService {
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch);
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(List<Long> idBatch);
List<ReportDetailVO> getdetailPages(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size);
}

41
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/AsyncServiceImpl.java

@ -2,12 +2,16 @@ package com.logpm.report.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.mapper.ReportDeliverMapeer;
import com.logpm.report.service.ExportReader;
import com.logpm.report.service.IAsyncService;
import com.logpm.report.vo.ReportDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springblade.common.annotations.LogpmAsync;
@ -15,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@ -96,4 +101,40 @@ public class AsyncServiceImpl implements IAsyncService {
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnByIds(idBatch);
}
@Override
public List<ReportDetailVO> getdetailPages(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size) {
List<ReportDetailVO> detailsPage = reportDeliverMapeer.getDetailsPage(page, queryWrapper);
// 包件总数
long total = page.getTotal();
// 零件总数
Long detailsZeroPageCount = reportDeliverMapeer.getDetailsZeroPageCount(queryWrapper);
long allTotal = total + detailsZeroPageCount;
// 包件没数据查零担
int pageSize = current * size;
if (total < pageSize) {
// 剩余需要查询的数量
int zeroTotal = Convert.toInt(pageSize - total);
double div = NumberUtil.div(zeroTotal, size.doubleValue());
long zeroCurrent = (int) Math.ceil(div);
int zeroSize = zeroTotal % size;
long limitA = 0;
long limitB = 0;
if(zeroSize == 0){
zeroSize = size;
}
if (!NumberUtil.equals(zeroCurrent, 1)) {
limitA = zeroSize + (zeroCurrent - 2) * size;
zeroSize = size;
}
limitB = zeroSize;
List<ReportDetailVO> zeroPage = reportDeliverMapeer.getDetailsZeroPage(limitA, limitB, queryWrapper);
if(CollUtil.isEmpty(detailsPage)){
detailsPage = new ArrayList<>();
}
detailsPage.addAll(zeroPage);
}
page.setTotal(allTotal);
return detailsPage;
}
}

12
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDeliverServiceImpl.java

@ -19,6 +19,7 @@ import com.logpm.report.reader.DeliveryCustomerReader;
import com.logpm.report.reader.DeliveryDetailReader;
import com.logpm.report.reader.DeliveryTrainReader;
import com.logpm.report.reader.StockOrderReader;
import com.logpm.report.service.IAsyncService;
import com.logpm.report.service.ReportDataService;
import com.logpm.report.service.ReportDeliverService;
import com.logpm.report.util.QueryUtil;
@ -57,6 +58,7 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
private final IBasicdataWarehouseClient warehouseClient;
private final ReportDataService reportDataService;
private final ReportExcelUtil reportExcelUtil;
private final IAsyncService anAsyncService;
@Override
public IPage<ReportDevilerVO> deliveryTrainPage(ReportDevilerVO vo, ReportDevilerQuery query) {
@ -168,6 +170,11 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
detailsCustomQuery(query, queryWrapper);
// 仓库权限
ReportUtil.buildReportWarehouseAuth(vo.getWarehouseName(), query.getWarehouseNameRange(), queryWrapper, warehouseClient);
List<ReportDetailVO> detailsPage = anAsyncService.getdetailPages(page, queryWrapper, current, size);
return page.setRecords(detailsPage);
}
private List<ReportDetailVO> getdetailPages(IPage<ReportDetailVO> page, QueryWrapper<ReportDetailVO> queryWrapper, Integer current, Integer size) {
List<ReportDetailVO> detailsPage = reportDeliverMapeer.getDetailsPage(page, queryWrapper);
// 包件总数
long total = page.getTotal();
@ -182,8 +189,6 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
double div = NumberUtil.div(zeroTotal, size.doubleValue());
long zeroCurrent = (int) Math.ceil(div);
int zeroSize = zeroTotal % size;
IPage<ReportDetailVO> page1 = Condition.getPage(query);
page1.setCurrent(zeroCurrent);
long limitA = 0;
long limitB = 0;
if(zeroSize == 0){
@ -194,7 +199,6 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
zeroSize = size;
}
limitB = zeroSize;
page1.setSize(zeroSize);
List<ReportDetailVO> zeroPage = reportDeliverMapeer.getDetailsZeroPage(limitA, limitB, queryWrapper);
if(CollUtil.isEmpty(detailsPage)){
detailsPage = new ArrayList<>();
@ -202,7 +206,7 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
detailsPage.addAll(zeroPage);
}
page.setTotal(allTotal);
return page.setRecords(detailsPage);
return detailsPage;
}
private void detailsCustomQuery(DevilerDetailsQuery query, QueryWrapper<ReportDetailVO> queryWrapper) {

Loading…
Cancel
Save