Browse Source

feat(all): 修改报表逻辑

dist.1.2.0^2
zhaoqiaobo 7 months ago
parent
commit
542a68ec51
  1. 4
      blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportDeliverMapeer.java
  2. 16
      blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportDeliverMapper.xml
  3. 6
      blade-service/logpm-report/src/main/java/com/logpm/report/reader/DeliveryDetailReader.java
  4. 2
      blade-service/logpm-report/src/main/java/com/logpm/report/service/IAsyncService.java
  5. 58
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/AsyncServiceImpl.java

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

@ -68,4 +68,8 @@ public interface ReportDeliverMapeer extends BaseMapper {
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(@Param("idBatch") List<Long> idBatch);
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(@Param("idBatch") List<Long> idBatch);
Long getDetailsPageCount(@Param("ew") Wrapper query);
List<ReportDetailVO> getDetailsPageExport(@Param("ew") Wrapper queryWrapper, @Param("current") Integer current, @Param("size") Integer size);
}

16
blade-service/logpm-report/src/main/java/com/logpm/report/mapper/ReportDeliverMapper.xml

@ -303,7 +303,7 @@
) t
${ew.customSqlSegment}
</select>
<select id="getDetailsPage" resultType="com.logpm.report.vo.ReportDetailVO">
<sql id="detailsPageSql">
select id,
train_number,
reservation_code,
@ -496,6 +496,9 @@
FROM logpm_distribution_reservation obj
WHERE obj.id = t.id)
order by t.id desc
</sql>
<select id="getDetailsPage" resultType="com.logpm.report.vo.ReportDetailVO">
<include refid="detailsPageSql"/>
</select>
<sql id="detailsZeroPage">
select
@ -828,4 +831,15 @@
group by t.delivery_id
order by null
</select>
<select id="getDetailsPageCount" resultType="java.lang.Long">
select count(*) from (
<include refid="detailsPageSql"></include>
) t
</select>
<select id="getDetailsPageExport" resultType="com.logpm.report.vo.ReportDetailVO">
<include refid="detailsPageSql"></include>
limit #{current},#{size}
</select>
</mapper>

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

@ -31,14 +31,14 @@ public class DeliveryDetailReader implements ExportReader {
@Override
public Long getCount(Wrapper query) {
Page page = new Page(1, 1);
reportDeliverMapeer.getDetailsPage(page, query);
Long detailsPageCount = reportDeliverMapeer.getDetailsPageCount(query);
Long detailsZeroPageCount = reportDeliverMapeer.getDetailsZeroPageCount(query);
return page.getTotal() + detailsZeroPageCount;
return detailsPageCount + detailsZeroPageCount;
}
@Override
public List<T> findList(Page page, Wrapper query) {
return asyncService.getdetailPages(page, query, Convert.toInt(page.getCurrent()), Convert.toInt(page.getSize()));
return asyncService.getdetailPagesExport(page, query, Convert.toInt(page.getCurrent()), Convert.toInt(page.getSize()));
}
}

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

@ -21,4 +21,6 @@ public interface IAsyncService {
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(List<Long> idBatch);
List<ReportDetailVO> getdetailPages(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size);
List<ReportDetailVO> getdetailPagesExport(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size);
}

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

@ -52,7 +52,7 @@ public class AsyncServiceImpl implements IAsyncService {
}, asyncExecutor);
future.thenAccept(list -> {
if(CollUtil.isNotEmpty(list)){
if (CollUtil.isNotEmpty(list)) {
// 获取组装的数据列表
List<Object> detailVo = pageMap.get(finalI);
// 将查询数据添加到本地缓存
@ -92,11 +92,11 @@ public class AsyncServiceImpl implements IAsyncService {
countDownLatch.countDown();
}
@Override
@Override
// @LogpmAsync("asyncExecutor")
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnInvnByIds(idBatch);
}
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnInvnByIds(idBatch);
}
@Override
// @LogpmAsync("asyncExecutor")
@ -105,8 +105,8 @@ public class AsyncServiceImpl implements IAsyncService {
return reportDeliverMapeer.getDeliveryTrainLoadSacnByIds(idBatch);
}
@Override
public List<ReportDetailVO> getdetailPages(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size) {
@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();
@ -123,7 +123,7 @@ public class AsyncServiceImpl implements IAsyncService {
int zeroSize = zeroTotal % size;
long limitA = 0;
long limitB = 0;
if(zeroSize == 0){
if (zeroSize == 0) {
zeroSize = size;
}
if (!NumberUtil.equals(zeroCurrent, 1)) {
@ -132,12 +132,50 @@ public class AsyncServiceImpl implements IAsyncService {
}
limitB = zeroSize;
List<ReportDetailVO> zeroPage = reportDeliverMapeer.getDetailsZeroPage(limitA, limitB, queryWrapper);
if(CollUtil.isEmpty(detailsPage)){
if (CollUtil.isEmpty(detailsPage)) {
detailsPage = new ArrayList<>();
}
detailsPage.addAll(zeroPage);
}
page.setTotal(allTotal);
return detailsPage;
}
}
@Override
public List<ReportDetailVO> getdetailPagesExport(IPage<ReportDetailVO> page, Wrapper queryWrapper, Integer current, Integer size) {
List<ReportDetailVO> detailsPage = reportDeliverMapeer.getDetailsPageExport(queryWrapper, (current - 1) * size, size);
// 包件总数
long total = detailsPage.size();
// 零件总数
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;
}
}

Loading…
Cancel
Save