Browse Source

fix: 修复 配送客户查询 预约单和 包件循环查询 慢的问题

pull/7/head
pref_mail@163.com 10 months ago
parent
commit
e33fa03ad1
  1. 10
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java
  2. 102
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml
  3. 63
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java

10
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java

@ -153,6 +153,14 @@ public interface DistributionReservationMapper extends BaseMapper<DistributionRe
*/
List<DistributionReservationStockarticleEntity> selectStockArticleByReservationId(@Param("reservationId") Long id);
/**
* 批量查询预约的订单中间表
* @param reservationIds
* @return
*/
List<DistributionReservationStockarticleEntity> selectStockArticleByReservationIds(@Param("reservationIds") List reservationIds);
/**
* 查询预约单下的订单信息
* @param id
@ -395,4 +403,6 @@ public interface DistributionReservationMapper extends BaseMapper<DistributionRe
* @return
*/
List<DistributionParcelListVO> selectPackageListByReservationIds(@Param("reservationIds") List<Long> reservationIds);
List<DistributionParcelListEntity> selectPackageByReservations(@Param("reservationIds") List<Long> reservationIds, @Param("warehouseId")Long warehouseId);
}

102
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml

@ -1848,4 +1848,106 @@
</foreach>
</where>
</select>
<select id="selectStockArticleByReservationIds"
resultType="com.logpm.distribution.entity.DistributionReservationStockarticleEntity">
SELECT
id,
reservation_id,
stock_article_id,
stock_article_status,
is_zero,
reservation_num
FROM logpm_distribution_reservation_stockarticle
<where>
stock_article_status != '2'
<if test="reservationIds != null">
and reservation_id in
<foreach collection="reservationIds" item="reservationId" open="(" separator="," close=")">
#{reservationId}
</foreach>
</if>
</where>
</select>
<select id="selectPackageByReservations"
resultType="com.logpm.distribution.entity.DistributionParcelListEntity">
SELECT
DISTINCT
ldpl.id,
ldpl.tenant_id,
ldpl.create_user,
ldpl.create_time,
ldpl.update_user,
ldpl.update_time,
ldpl.STATUS,
ldpl.is_deleted,
ldpl.create_dept,
ldpl.reserve1,
ldpl.reserve2,
ldpl.reserve3,
ldpl.reserve4,
ldpl.reserve5,
ldpl.warehouse_id,
ldpl.warehouse,
ldpl.conditions,
ldpl.order_package_code,
ldpl.cargo_title,
ldpl.shelf_title,
lwtg.tray_code AS pallet,
lwug.allocation_title AS goodsAllocation,
ldpl.firsts_code,
ldpl.firsts,
ldpl.second_code,
ldpl.SECOND,
ldpl.third_code,
ldpl.third_product,
ldpl.quantity,
ldpl.train_number,
ldpl.stock_article_id,
ldpl.order_code,
ldpl.service_number,
ldpl.material_id,
ldpl.material_name,
ldpl.material_code,
ldpl.material_unit,
ldpl.brand_id,
ldpl.brand_name,
ldpl.order_package_status,
ldpl.order_package_freeze_status,
ldpl.order_package_grounding_status,
ldpl.order_package_stockup_status,
ldpl.order_package_reservation_status,
ldpl.order_package_loading_status,
ldpl.waybill_number,
ldpl.waybill_id,
ldpl.warehouse_entry_time_end,
ldpl.dealer_name,
ldpl.dealer_code,
ldpl.send_warehouse_id,
ldpl.send_warehouse_name,
ldpl.accept_warehouse_id,
ldpl.accept_warehouse_name,
ldpl.order_package_delivery_status
FROM
logpm_distribution_reservation_package AS ldrp
LEFT JOIN logpm_distribution_parcel_list AS ldpl ON ldpl.order_package_code = ldrp.packet_bar_code
LEFT JOIN logpm_warehouse_tray_goods AS lwtg ON ldpl.id = lwtg.association_id and lwtg.association_type = 3
LEFT JOIN logpm_warehouse_updown_goods AS lwug ON ldpl.id = lwug.association_id and lwug.association_type = 3
<where>
and packet_bar_status != 2
<if test="reservationId !=null ">
and ldrp.reservation_id in
<foreach collection="reservationIds" item="reservationId" open="(" separator="," close=")">
#{reservationId}
</foreach>
</if>
<if test="warehourseId !=null and warehourseId!= ''">
and ldpl.warehouse_id=#{warehourseId}
</if>
</where>
</select>
</mapper>

63
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java

@ -2499,11 +2499,34 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
//查询客户
BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse();
List<DistributionAppReservationVO> customList = distributionDeliveryInfoMapper.selectAppcustomListPage(distributionDeliveryList.getId());
// 查询所有的预约单ID
List<Long> idList = customList.stream()
.map(DistributionAppReservationVO::getId)
.collect(Collectors.toList());
List<DistributionReservationStockarticleEntity> reservationStockarticleEntityLists =distributionReservationMapper.selectStockArticleByReservationIds(idList);
for (DistributionAppReservationVO distributionAppReservationVO : customList) {
List<DistributionReservationStockarticleEntity> reservationStockarticleEntityList = distributionReservationMapper.selectStockArticleByReservationId(distributionAppReservationVO.getId());
List<DistributionReservationStockarticleEntity> reservationStockarticleEntityList = localFindReservationStockarticleEntityLists(reservationStockarticleEntityLists,distributionAppReservationVO.getId());
List<DistributionStockEntity> distributionStockEntities = new ArrayList<>();
List<DistributionLoadscanEntity> loadscanEntityList = new ArrayList<>();
List<WarehouseTrayGoodsEntity> trayList = new ArrayList<>();
List<Long> reaveIds=reservationStockarticleEntityList.stream()
.map(DistributionReservationStockarticleEntity::getReservationId)
.collect(Collectors.toList());
List<DistributionParcelListEntity> allParcelListEntities =distributionReservationMapper.selectPackageByReservations(reaveIds, myCurrentWarehouse.getId());
for (DistributionReservationStockarticleEntity reservationStockarticleEntity : reservationStockarticleEntityList) {
if (reservationStockarticleEntity.getIsZero().equals(IsOrNoConstant.no.getValue())) {
//查询订制品备货数量
@ -2513,7 +2536,11 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
}
//统计托盘数
//查询所有包件
List<DistributionParcelListEntity> parcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(reservationStockarticleEntity.getReservationId(), reservationStockarticleEntity.getStockArticleId(), myCurrentWarehouse.getId());
// List<DistributionParcelListEntity> parcelListEntities = distributionReservationMapper.selectPackageByReservationAndStockArticle(reservationStockarticleEntity.getReservationId(), reservationStockarticleEntity.getStockArticleId(), myCurrentWarehouse.getId());
List<DistributionParcelListEntity> parcelListEntities =localFindAllParcelListEntities(allParcelListEntities,reservationStockarticleEntity.getStockArticleId());
parcelListEntities.forEach(p -> {
WarehouseTrayGoodsEntity warehouseTrayGoodsEntity = new WarehouseTrayGoodsEntity();
warehouseTrayGoodsEntity.setAssociationId(p.getId());
@ -2586,6 +2613,38 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
return customList;
}
private List<DistributionParcelListEntity> localFindAllParcelListEntities(List<DistributionParcelListEntity> allParcelListEntities, Long stockArticleId) {
List<DistributionParcelListEntity> temp = new ArrayList<>();
allParcelListEntities.forEach(t->{
if(t.getStockArticleId().equals(stockArticleId)){
temp.add(t);
}
});
log.info(">>>>>>>>> localFindAllParcelListEntities 寻找的包件集合{}",temp);
return temp;
}
/**
* 找寻预约单ID 相同的数据进行返回
* @param reservationStockarticleEntityLists
* @param id
* @return List
*/
private List<DistributionReservationStockarticleEntity> localFindReservationStockarticleEntityLists(List<DistributionReservationStockarticleEntity> reservationStockarticleEntityLists, Long id) {
List<DistributionReservationStockarticleEntity> temp = new ArrayList<>();
reservationStockarticleEntityLists.forEach(t->{
if(t.getReservationId().equals(id)){
temp.add(t);
}
});
log.info(">>>>> localFindReservationStockarticleEntityLists 寻找匹配的预约订单集合:{} ",temp);
return temp;
}
@Override
public List<DisStockListDetailVO> selectDistributionAppDeliverywrapIn(DistributionAppDeliveryListDTO distributionAppDeliveryListDTO) {
List<DisStockListDetailEntity> detailEntities = baseMapper.selectInventoryListByDeliveryListId(distributionAppDeliveryListDTO.getId());

Loading…
Cancel
Save