Browse Source

1.更新托盘数据,库位数据逻辑优化

dist.1.3.0
zhenghaoyu 10 months ago
parent
commit
ac9e8811c7
  1. 5
      blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java
  2. 20
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java
  3. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java
  4. 10
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml
  5. 3
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java
  6. 11
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
  7. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java
  8. 5
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java
  9. 19
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java
  10. 12
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java
  11. 8
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java
  12. 2
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java
  13. 8
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.xml
  14. 4
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java
  15. 120
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java

5
blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionStockArticleClient.java

@ -183,4 +183,9 @@ public interface IDistributionStockArticleClient {
@PostMapping(value = API_PREFIX + "/addReturnList",consumes = MediaType.APPLICATION_JSON_VALUE)
List<DistributionStockArticleEntity> addReturnList(@RequestBody List<DistributionStockArticleEntity> addStockArticleEntities);
@PostMapping(value = API_PREFIX + "/findOrderTotalNumByOrderCodes",consumes = MediaType.APPLICATION_JSON_VALUE)
Integer findOrderTotalNumByOrderCodes(@RequestBody JSONObject jsonObject);
@PostMapping(value = API_PREFIX + "/findOrderTotalNumByOrderPackageCodes",consumes = MediaType.APPLICATION_JSON_VALUE)
Integer findOrderTotalNumByOrderPackageCodes(@RequestBody JSONObject jsonObject);
}

20
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java

@ -16,6 +16,7 @@
*/
package com.logpm.distribution.feign;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -350,4 +351,23 @@ public class DistributionStockArticleClient implements IDistributionStockArticle
return addStockArticleEntities;
}
@Override
public Integer findOrderTotalNumByOrderCodes(JSONObject jsonObject) {
JSONArray jsonArray = jsonObject.getJSONArray("orderCodes");
List<String> orderCodes = jsonArray.toJavaList(String.class);
Long warehouseId = jsonObject.getLong("warehouseId");
return distributionStockArticleService.findOrderTotalNumByOrderCodes(orderCodes,warehouseId);
}
@Override
public Integer findOrderTotalNumByOrderPackageCodes(JSONObject jsonObject) {
JSONArray jsonArray = jsonObject.getJSONArray("orderPackageCodes");
List<String> orderPackageCodes = jsonArray.toJavaList(String.class);
Long warehouseId = jsonObject.getLong("warehouseId");
return distributionStockArticleService.findOrderTotalNumByOrderPackageCodes(orderPackageCodes,warehouseId);
}
}

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java

@ -279,4 +279,6 @@ public interface DistributionParcelListMapper extends BaseMapper<DistributionPar
List<Map<String, String>> findPackageCodeByCodes(@Param("keySet") Set<String> keySet);
List<DistributionParcelListEntity> findALLNoUpShelfPackageByOrderCodeList(@Param("orderCodeList") List<String> orderCodeList, @Param("warehouseId") Long warehouseId);
List<String> findOrderCodesByOrderPackageCodes(@Param("orderPackageCodes") List<String> orderPackageCodes, @Param("warehouseId") Long warehouseId);
}

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

@ -1783,5 +1783,15 @@
and lwug.id is null
</select>
<select id="findOrderCodesByOrderPackageCodes" resultType="java.lang.String">
select ldpl.order_code
from logpm_distribution_parcel_list ldpl
where ldpl.warehouse_id = #{warehouseId}
and ldpl.order_package_code in
<foreach collection="orderPackageCodes" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by ldpl.order_code
</select>
</mapper>

3
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.java

@ -199,4 +199,7 @@ public interface DistributionStockArticleMapper extends BaseMapper<DistributionS
void updateCustomerAllByOrderCode(@Param("data") cn.hutool.json.JSONObject data);
void updateDistributionStockArticleEntityById(@Param("t") DistributionStockArticleEntity t);
Integer findOrderTotalNumByOrderCodes(@Param("orderCodes") List<String> orderCodes,@Param("warehouseId") Long warehouseId);
}

11
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml

@ -1428,4 +1428,15 @@
</update>
<select id="findOrderTotalNumByOrderCodes" resultType="int">
select IFNULL(sum(total_number),0)
from logpm_distribution_stock_article
where warehouse_id = #{warehouseId}
and order_code in
<foreach collection="orderCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java

@ -244,4 +244,6 @@ public interface IDistributionParcelListService extends BaseService<Distribution
Map<String, Set<String>> findPackageCodeByCodes(Set<String> keySet);
List<DistributionParcelListEntity> findALLNoUpShelfPackageByOrderCodeList(List<String> orderCodeList, Long warehouseId);
List<String> findOrderCodesByOrderPackageCodes(List<String> orderPackageCodes, Long warehouseId);
}

5
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionStockArticleService.java

@ -28,7 +28,6 @@ import com.logpm.distribution.vo.app.queryOrderVO;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -288,4 +287,8 @@ public interface IDistributionStockArticleService extends BaseService<Distributi
* @param orderCode 订单号
*/
void updateCustomerAllByOrderCode(String orderCode);
Integer findOrderTotalNumByOrderCodes(List<String> orderCodes,Long warehouseId);
Integer findOrderTotalNumByOrderPackageCodes(List<String> orderPackageCodes, Long warehouseId);
}

19
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java

@ -43,13 +43,7 @@ import com.logpm.distribution.entity.DistrilbutionBillPackageEntity;
import com.logpm.distribution.excel.DistributionParcelListExcel;
import com.logpm.distribution.mapper.DistributionParcelListMapper;
import com.logpm.distribution.mapper.DistributionStockArticleMapper;
import com.logpm.distribution.service.IDistributionParcelDetailsService;
import com.logpm.distribution.service.IDistributionParcelListService;
import com.logpm.distribution.service.IDistributionParcelNumberService;
import com.logpm.distribution.service.IDistributionReservationZeroPackageService;
import com.logpm.distribution.service.IDistributionStockListInfoService;
import com.logpm.distribution.service.IDistributionStockListService;
import com.logpm.distribution.service.IDistrilbutionBillPackageService;
import com.logpm.distribution.service.*;
import com.logpm.distribution.vo.DistributionParcelListBaseVO;
import com.logpm.distribution.vo.DistributionParcelListNodeVO;
import com.logpm.distribution.vo.DistributionParcelListVO;
@ -82,6 +76,7 @@ import org.springblade.system.feign.IUserClient;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -132,6 +127,9 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
@Autowired
private IDistributionReservationZeroPackageService reservationZeroPackageService;
@Lazy
@Autowired
private IDistributionStockArticleService distributionStockArticleService;
@Autowired
private IDistrilbutionBillPackageService distrilbutionBillPackageService;
@ -786,8 +784,8 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
stockArticleEntity.setConsigneeMobile(waybillEntity.getConsigneeMobile());
stockArticleEntity.setConsigneeAddress(waybillEntity.getConsigneeAddress());
stockArticleEntity.setConsigneeUnit(basicdataClientEntity.getClientName());
distributionStockArticleMapper.updateById(stockArticleEntity);
}
distributionStockArticleService.updateBatchById(stockArticleEntities);
}
return orderCodes;
}
@ -1291,4 +1289,9 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
return baseMapper.findALLNoUpShelfPackageByOrderCodeList(orderCodeList,warehouseId);
}
@Override
public List<String> findOrderCodesByOrderPackageCodes(List<String> orderPackageCodes, Long warehouseId) {
return baseMapper.findOrderCodesByOrderPackageCodes(orderPackageCodes,warehouseId);
}
}

12
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionStockArticleServiceImpl.java

@ -2698,6 +2698,18 @@ public class DistributionStockArticleServiceImpl extends BaseServiceImpl<Distrib
this.baseMapper.updateCustomerAllByOrderCode(JSONUtil.parseObj(data));
}
@Override
public Integer findOrderTotalNumByOrderCodes(List<String> orderCodes,Long warehouseId) {
return baseMapper.findOrderTotalNumByOrderCodes(orderCodes,warehouseId);
}
@Override
public Integer findOrderTotalNumByOrderPackageCodes(List<String> orderPackageCodes, Long warehouseId) {
List<String> orderCodes = distributionParcelListService.findOrderCodesByOrderPackageCodes(orderPackageCodes,warehouseId);
return baseMapper.findOrderTotalNumByOrderCodes(orderCodes,warehouseId);
}
@Override
public R findEditCustomerLog(Long orderId) {

8
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistrilbutionBillLadingServiceImpl.java

@ -3157,10 +3157,10 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
.collect(Collectors.toList()); // 收集到新的List<String>
List<DistributionStockArticleEntity> distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.<DistributionStockArticleEntity>query().lambda()
.in(DistributionStockArticleEntity::getId, ls)
.ne(DistributionStockArticleEntity::getIsZero, "1")
);
List<DistributionStockArticleEntity> distributionStockArticleEntityList = distributionStockArticleService.list(Wrappers.<DistributionStockArticleEntity>query().lambda()
.in(DistributionStockArticleEntity::getId, ls)
.ne(DistributionStockArticleEntity::getIsZero, "1")
);
List<DistributionParcelListEntity> list1 = distributionParcelListService.list(Wrappers.<DistributionParcelListEntity>query().lambda()
.in(DistributionParcelListEntity::getStockArticleId, ls)

2
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.java

@ -43,4 +43,6 @@ public interface WarehouseTrayTypeMapper extends BaseMapper<WarehouseTrayTypeEnt
* @return
*/
TrayTypeDataListVO getZeroOrderByOrderId(@Param("orderId")Long orderId,@Param("warehouseId") Long warehouseId);
void updateAllNumTrayTypeId(@Param("orderTotalNum") Integer orderTotalNum, @Param("orderNum") Integer orderNum, @Param("stockTotalNum") Integer stockTotalNum, @Param("stockNum") Integer stockNum, @Param("trayTypeId") Long trayTypeId);
}

8
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseTrayTypeMapper.xml

@ -114,5 +114,13 @@
and ldsa.warehouse_id = #{warehouseId}
</select>
<update id="updateAllNumTrayTypeId" >
update logpm_warehouse_tray_type
set total_num = #{enterNum},
order_total_num = #{orderTotalNum},
stock_num = #{enterNum},
stock_total_num = #{orderTotalNum}
where id = #{trayTypeId}
</update>
</mapper>

4
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseTrayTypeServiceImpl.java

@ -1155,14 +1155,14 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT
orderTotalNum = orderTotalNum + zeroTatolNumVO.getOrderTotalNum();
orderNum = orderNum + zeroTatolNumVO.getEnterNum();
}
baseMapper.updateNumByTrayTypeId(orderTotalNum,orderNum,trayTypeId);
// baseMapper.updateNumByTrayTypeId(orderTotalNum,orderNum,trayTypeId);
TatolNumVO stockTatolNumVO = warehouseTrayGoodsService.getStockTotalNumAndNum(trayTypeId,warehouseId);
if(!Objects.isNull(stockTatolNumVO)){
stockTotalNum = stockTotalNum + stockTatolNumVO.getOrderTotalNum();
stockNum = stockNum + stockTatolNumVO.getEnterNum();
}
baseMapper.updateStockByTrayTypeId(stockTotalNum,stockNum,trayTypeId);
baseMapper.updateAllNumTrayTypeId(orderTotalNum,orderNum,stockTotalNum,stockNum,trayTypeId);
}

120
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -3111,75 +3112,60 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl<WarehouseUpd
QueryWrapper<WarehouseUpdownGoodsEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("updown_type_id", updownTypeId);
List<WarehouseUpdownGoodsEntity> list = warehouseUpdownGoodsService.list(queryWrapper);
Set<String> set = new TreeSet<>();
Integer totalNum = 0;
Integer orderTotalNum = 0;
Integer stockNum = 0;
Integer stockTotalNum = 0;
for (WarehouseUpdownGoodsEntity updownGoodsEntity : list) {
String associationType = updownGoodsEntity.getAssociationType();
Long associationId = updownGoodsEntity.getAssociationId();
String associationValue = updownGoodsEntity.getAssociationValue();
Long marketId = updownGoodsEntity.getMarketId();
Integer num = updownGoodsEntity.getNum();
String incomingBatch = updownGoodsEntity.getIncomingBatch();
if ("1".equals(associationType)) {
//零担订单数据
String orderCode = associationValue;
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
Integer totalNumber = stockArticleEntity.getTotalNumber();
if (!set.contains(associationValue)) {
set.add(orderCode);
orderTotalNum = orderTotalNum + totalNumber;
}
totalNum = totalNum + num;
} else if ("3".equals(associationType)) {
DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(associationValue, warehouseId);
String orderCode = parcelListEntity.getOrderCode();
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
Integer totalNumber = stockArticleEntity.getTotalNumber();
if (!set.contains(orderCode)) {
set.add(orderCode);
orderTotalNum = orderTotalNum + totalNumber;
}
totalNum = totalNum + num;
} else if ("4".equals(associationType)) {
DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(marketId, associationValue, incomingBatch, warehouseId);
Integer quantityStock = stockListEntity.getQuantityStock();
stockNum = stockNum + num;
stockTotalNum = stockTotalNum + quantityStock;
}
}
baseMapper.updateNumByUpdownTypeId(orderTotalNum, totalNum, stockNum, stockTotalNum, updownTypeId);
AtomicReference<Integer> totalNum = new AtomicReference<>(0);
AtomicReference<Integer> orderTotalNum = new AtomicReference<>(0);
AtomicReference<Integer> stockNum = new AtomicReference<>(0);
AtomicReference<Integer> stockTotalNum = new AtomicReference<>(0);
// DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode);
// if(Objects.isNull(stockArticleEntity)){
// log.warn("##############updateUpdownTypeNumPackage: 订单信息不存在 orderCode={}",orderCode);
// throw new CustomerException(403,"订单信息不存在");
// }
// Integer orderTotalNumber = stockArticleEntity.getTotalNumber();
// //查询该订单在该上架方式下的包件还有几条数据
// List<WarehouseUpdownGoodsEntity> ls = warehouseUpdownGoodsService.findListByUpdownTypeIdAndOrderCode(updownTypeId,orderCode);
// int size = ls.size();
// if("1".equals(addStatus)){
// if(size==0){
// baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,orderTotalNumber,quantity);
// }else{
// baseMapper.updateTotalNum(updownTypeId,quantity);
// }
// }else if("2".equals(addStatus)){
// if(size==0){
// log.warn("##############updateUpdownTypeNumPackage: 数据格式问题 updownTypeId={} orderCode={}",updownTypeId,orderCode);
// throw new CustomerException(403,"数据格式问题");
// }else if(size > 1){
// //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量
// baseMapper.updateTotalNum(updownTypeId,-quantity);
// }else{
// //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量
// baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,-orderTotalNumber,-quantity);
// }
// }
// 使用Java Stream对list按associationType字段进行分组
Map<String, List<WarehouseUpdownGoodsEntity>> groupedByAssociationType = list.stream()
.collect(Collectors.groupingBy(WarehouseUpdownGoodsEntity::getAssociationType));
groupedByAssociationType.keySet().forEach(associationType -> {
List<WarehouseUpdownGoodsEntity> updownGoodsEntities = groupedByAssociationType.get(associationType);
//统计updownGoodsEntities中所有元素的num之和
Integer total = updownGoodsEntities.stream()
.mapToInt(WarehouseUpdownGoodsEntity::getNum)
.sum();
//把updownGoodsEntities中所有元素的associationValue放入一个List<String>中
List<String> associationValues = updownGoodsEntities.stream()
.map(WarehouseUpdownGoodsEntity::getAssociationValue)
.collect(Collectors.toList());
if ("1".equals(associationType)) {
//零担
//获取所有
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderCodes",associationValues);
jsonObject.put("warehouseId",warehouseId);
Integer orderTotal = distributionStockArticleClient.findOrderTotalNumByOrderCodes(jsonObject);
totalNum.set(totalNum.get()+total);
orderTotalNum.set(orderTotalNum.get()+orderTotal);
}else if ("3".equals(associationType)){
//订制品
JSONObject jsonObject = new JSONObject();
jsonObject.put("orderPackageCodes",associationValues);
jsonObject.put("warehouseId",warehouseId);
Integer orderTotal = distributionStockArticleClient.findOrderTotalNumByOrderPackageCodes(jsonObject);
totalNum.set(totalNum.get()+total);
orderTotalNum.set(orderTotalNum.get()+orderTotal);
}else if ("4".equals(associationType)){
//无数据库存品
updownGoodsEntities.forEach(updownGoodsEntity -> {
DistributionStockListEntity stockListEntity = distributionStockListClient.getEntityByMarketIdAndMaterialCodeAndIncomingBatch(updownGoodsEntity.getMarketId(), updownGoodsEntity.getAssociationValue(), updownGoodsEntity.getIncomingBatch(), warehouseId);
Integer quantityStock = stockListEntity.getQuantityStock();
stockTotalNum.set(stockTotalNum.get() + quantityStock);
});
stockNum.set(stockNum.get() + total);
}
});
baseMapper.updateNumByUpdownTypeId(orderTotalNum.get(), totalNum.get(), stockNum.get(), stockTotalNum.get(), updownTypeId);
}
/**

Loading…
Cancel
Save