Browse Source

1.干线-车辆配载详情逻辑优化

master
zhenghaoyu 7 months ago
parent
commit
7fa9ee35c4
  1. 15
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadScanAbnormalVO.java
  2. 2
      blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadWaybillInfoVO.java
  3. 1
      blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java
  4. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java
  5. 15
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml
  6. 4
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml
  7. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java
  8. 10
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml
  9. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java
  10. 7
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml
  11. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java
  12. 2
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCostShareRecordService.java
  13. 3
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java
  14. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java
  15. 107
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java
  16. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java
  17. 5
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillOrderServiceImpl.java

15
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadScanAbnormalVO.java

@ -0,0 +1,15 @@
package com.logpm.trunkline.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class CarsLoadScanAbnormalVO implements Serializable {
private String waybillNo;
private String orderCode;
private Integer loadingNum;
private Integer unloadNum;
}

2
blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/vo/CarsLoadWaybillInfoVO.java

@ -22,7 +22,7 @@ public class CarsLoadWaybillInfoVO implements Serializable {
private Integer waybillNum;
private String openPrice;
private String goodsName;
private String waybillType;
private Integer waybillType;
private Long waybillId;
private String remark;
private BigDecimal totalFreight;

1
blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java

@ -662,6 +662,7 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService {
}
}else{
distributionStockArticleEntity.setTotalNumber(total);
distributionStockArticleEntity.setGenre(1);
distributionStockArticleClient.saveOrUpdate(distributionStockArticleEntity);
}

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.java

@ -150,4 +150,6 @@ public interface TrunklineCarsLoadScanMapper extends BaseMapper<TrunklineCarsLoa
List<TrunklineCarsLoadScanVO> findListHasSignOrderIdByIds(@Param("carsLoadScanIds") List<Long> loadScanIds);
List<Long> findCarsLoadScanIdsByWaybillIds(@Param("waybillIds") List<Long> waybillIds);
List<CarsLoadScanAbnormalVO> findAbnormalData(@Param("loadId") Long loadId);
}

15
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsLoadScanMapper.xml

@ -798,4 +798,19 @@
group by ltcls.id
</select>
<select id="findAbnormalData" resultType="com.logpm.trunkline.vo.CarsLoadScanAbnormalVO">
select IFNULL(ltcls.waybill_no,'--') waybillNo,
ltcls.order_code orderCode,
IFNULL(sum(ltcls.num),0) loadingNum,
IFNULL(sum(ltcls.unload_num),0) unloadNum
from logpm_trunkline_cars_load_scan ltcls
left join logpm_trunkline_cars_order ltco on ltco.waybill_id = ltcls.waybill_id and ltco.order_code = ltcls.order_code
where ltcls.load_id = #{loadId}
and ltco.id is null
GROUP BY IFNULL(ltcls.waybill_no,'--'),
ltcls.order_code
order by IFNULL(ltcls.waybill_no,'--') desc, ltcls.order_code desc
</select>
</mapper>

4
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCarsOrderMapper.xml

@ -139,8 +139,8 @@
IFNULL(ltco.unload_num,0) unloadNum,
IFNULL(lww.total_freight/lww.total_count*ltwo.total_number,0) orderFreight,
IFNULL(lww.total_freight/lww.total_count*t.unloadNum,0) unloadIncome,
m.costPiece,
m.costZhang,
IFNULL(m.costPiece,0) costPiece,
IFNULL(m.costZhang,0) costZhang,
sum(ltwo.total_number) orderNum
from (select ltcls.waybill_no waybillNo,
ltcls.order_code orderCode,

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.java

@ -22,4 +22,6 @@ public interface TrunklineCostShareRecordMapper extends BaseMapper<TrunklineCost
TrunklineCostShareRecordEntity sumTotalCost(@Param("waybillNo") String waybillNo);
TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNo(@Param("loadId") Long loadId, @Param("waybillNo") String waybillNo);
TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(@Param("loadId") Long loadId, @Param("waybillNo") String waybillNo, @Param("orderCode") String orderCode);
}

10
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineCostShareRecordMapper.xml

@ -47,4 +47,14 @@
and load_id = #{loadId}
</select>
<select id="findTotalUnloadNumByLoadAndWaybillNoAndOrderCode" resultType="com.logpm.trunkline.entity.TrunklineCostShareRecordEntity">
select IFNULL(sum(cost_piece),0) costPiece,
IFNULL(sum(cost_zhang),0) costZhang,
IFNULL(sum(num),0) num
from logpm_trunkline_cost_share_record
where waybill_no = #{waybillNo}
and load_id = #{loadId}
and order_code = #{orderCode}
</select>
</mapper>

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.java

@ -22,4 +22,6 @@ public interface TrunklineWaybillOrderMapper extends BaseMapper<TrunklineWaybill
Integer findTotalNumByWaybillNoAndOrderCode(@Param("waybillId") Long waybillId, @Param("orderCode") String orderCode);
List<Long> findAdvanceIdsByWaybillIds(@Param("waybillIds") List<Long> waybillIds);
Integer findTotalNumByWaybillAndOrderCode(@Param("waybillNo") String waybillNo, @Param("orderCode") String orderCode);
}

7
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineWaybillOrderMapper.xml

@ -36,6 +36,13 @@
and ltwo.order_code = #{orderCode}
</select>
<select id="findTotalNumByWaybillAndOrderCode" resultType="int">
select IFNULL(sum(ltwo.total_number),0)
from logpm_trunkline_waybill_order ltwo
where ltwo.waybill_no = #{waybillNo}
and ltwo.order_code = #{orderCode}
</select>
<select id="findAdvanceIdsByWaybillIds" resultType="Long">
select ltwo.advance_id
from logpm_trunkline_waybill_order ltwo

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadScanService.java

@ -145,4 +145,6 @@ public interface ITrunklineCarsLoadScanService extends BaseService<TrunklineCars
List<TrunklineCarsLoadScanVO> findListHasSignOrderIdByIds(List<Long> loadScanIds);
List<Long> findCarsLoadScanIdsByWaybillIds(List<Long> waybillIds);
List<CarsLoadScanAbnormalVO> findAbnormalData(Long loadId);
}

2
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCostShareRecordService.java

@ -17,4 +17,6 @@ public interface ITrunklineCostShareRecordService extends BaseService<TrunklineC
TrunklineCostShareRecordEntity sumTotalCost(String waybillNo);
TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNo(Long loadId, String waybillNo);
TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(Long loadId, String waybillNo, String orderCode);
}

3
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineWaybillOrderService.java

@ -2,7 +2,6 @@ package com.logpm.trunkline.service;
import com.logpm.trunkline.entity.TrunklineAdvanceEntity;
import com.logpm.trunkline.entity.TrunklineWaybillOrderEntity;
import com.logpm.trunkline.vo.TrunklineBillladingVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
@ -20,6 +19,8 @@ public interface ITrunklineWaybillOrderService extends BaseService<TrunklineWayb
Integer findTotalNumByWaybillNoAndOrderCode(Long waybillId, String orderCode);
Integer findTotalNumByWaybillAndOrderCode(String waybillNo, String orderCode);
List<Long> findAdvanceIdsByWaybillIds(List<Long> waybillIds);
}

5
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadScanServiceImpl.java

@ -352,4 +352,9 @@ public class TrunklineCarsLoadScanServiceImpl extends BaseServiceImpl<TrunklineC
return baseMapper.findCarsLoadScanIdsByWaybillIds(waybillIds);
}
@Override
public List<CarsLoadScanAbnormalVO> findAbnormalData(Long loadId) {
return baseMapper.findAbnormalData(loadId);
}
}

107
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -68,7 +68,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@ -2908,16 +2910,117 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
List<CarsLoadOrderInfoVO> carsLoadOrderInfoList = trunklineCarsOrderService.findCarsLoadOrderInfoList(loadId, waybillNo);
List<CarsLoadOrderInfoVO> carsLoadOrderInfoListPlan = trunklineCarsOrderService.findCarsLoadOrderInfoListPlan(loadId, waybillNo);
// List<CarsLoadOrderInfoVO> carsLoadOrderInfoListPlan = trunklineCarsOrderService.findCarsLoadOrderInfoListPlan(loadId, waybillNo);
carsLoadOrderInfoList.forEach(carsLoadOrderInfoVO -> {
carsLoadOrderInfoVO.setUnloadIncome(carsLoadOrderInfoVO.getUnloadIncome().setScale(2, BigDecimal.ROUND_HALF_UP));
carsLoadOrderInfoVO.setOrderFreight(carsLoadOrderInfoVO.getOrderFreight().setScale(2, BigDecimal.ROUND_HALF_UP));
});
carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoList);
carsLoadWaybillInfoVO.setCarsLoadOrderInfoListPlan(carsLoadOrderInfoListPlan);
// carsLoadWaybillInfoVO.setCarsLoadOrderInfoListPlan(carsLoadOrderInfoListPlan);
TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo);
carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece());
carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang());
carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum());
}
//查询异常的数据
List<CarsLoadScanAbnormalVO> carsLoadScanAbnormalList = trunklineCarsLoadScanService.findAbnormalData(loadId);
if(!carsLoadScanAbnormalList.isEmpty()){
//把carsLoadScanAbnormalList过滤waybillNo等于--的数据后把waybillNo放入一个Set
Set<String> waybillNoSet = carsLoadScanAbnormalList.stream().filter(carsLoadScanAbnormalVO -> !"--".equals(carsLoadScanAbnormalVO.getWaybillNo()))
.map(CarsLoadScanAbnormalVO::getWaybillNo)
.collect(Collectors.toSet());
List<WarehouseWaybillEntity> waybillEntityList = warehouseWaybillClient.findWaybillBilllByWaybillNos(new ArrayList<>(waybillNoSet));
//把waybillEntityList转化成以waybillNo为key的map
Map<String, WarehouseWaybillEntity> waybillEntityMap = waybillEntityList.stream().collect(Collectors.toMap(WarehouseWaybillEntity::getWaybillNo, Function.identity()));
//把carsLoadScanAbnormalList通过waybillNo分组
Map<String, List<CarsLoadScanAbnormalVO>> carsLoadScanAbnormalMap = carsLoadScanAbnormalList.stream().collect(Collectors.groupingBy(CarsLoadScanAbnormalVO::getWaybillNo));
carsLoadScanAbnormalMap.keySet().forEach(waybillNo -> {
List<CarsLoadScanAbnormalVO> carsLoadScanAbnormalVOS = carsLoadScanAbnormalMap.get(waybillNo);
WarehouseWaybillEntity warehouseWaybillEntity = waybillEntityMap.get(waybillNo);
BigDecimal freightPrice = BigDecimal.ZERO;
CarsLoadWaybillInfoVO carsLoadWaybillInfoVO = new CarsLoadWaybillInfoVO();
carsLoadWaybillInfoVO.setWaybillNo(waybillNo);
if(!"--".equals(waybillNo)){
if(!Objects.isNull(warehouseWaybillEntity)){
carsLoadWaybillInfoVO.setCreateTime(warehouseWaybillEntity.getCreateTime());
carsLoadWaybillInfoVO.setDestination(warehouseWaybillEntity.getDestination());
carsLoadWaybillInfoVO.setDestinationWarehouseName(warehouseWaybillEntity.getDestinationWarehouseName());
carsLoadWaybillInfoVO.setShipper(warehouseWaybillEntity.getShipper());
carsLoadWaybillInfoVO.setShipperName(warehouseWaybillEntity.getShipperName());
carsLoadWaybillInfoVO.setConsignee(warehouseWaybillEntity.getConsignee());
carsLoadWaybillInfoVO.setConsigneeName(warehouseWaybillEntity.getConsigneeName());
carsLoadWaybillInfoVO.setWaybillNum(warehouseWaybillEntity.getTotalCount());
carsLoadWaybillInfoVO.setWaybillType(warehouseWaybillEntity.getWaybillType());
carsLoadWaybillInfoVO.setWaybillId(warehouseWaybillEntity.getId());
carsLoadWaybillInfoVO.setRemark(warehouseWaybillEntity.getRemark());
BigDecimal totalFreight = warehouseWaybillEntity.getTotalFreight();
BigDecimal deliveryFee = warehouseWaybillEntity.getDeliveryFee();
BigDecimal pickupFee = warehouseWaybillEntity.getPickupFee();
BigDecimal warehouseManagementFee = warehouseWaybillEntity.getWarehouseManagementFee();
BigDecimal storageFee = warehouseWaybillEntity.getStorageFee();
BigDecimal handlingFee = warehouseWaybillEntity.getHandlingFee();
BigDecimal otherFee = warehouseWaybillEntity.getOtherFee();
BigDecimal insuranceFee = warehouseWaybillEntity.getInsuranceFee();
carsLoadWaybillInfoVO.setTotalFreight(totalFreight);
carsLoadWaybillInfoVO.setDeliveryFee(deliveryFee);
carsLoadWaybillInfoVO.setPickupFee(pickupFee);
carsLoadWaybillInfoVO.setWarehouseManagementFee(warehouseManagementFee);
carsLoadWaybillInfoVO.setStorageFee(storageFee);
carsLoadWaybillInfoVO.setHandlingFee(handlingFee);
carsLoadWaybillInfoVO.setOtherFee(otherFee);
carsLoadWaybillInfoVO.setInsuranceFee(insuranceFee);
carsLoadWaybillInfoVO.setTotalFee(totalFreight.add(deliveryFee).add(pickupFee).add(warehouseManagementFee).add(storageFee).add(handlingFee).add(otherFee).add(insuranceFee));
TrunklineCostShareRecordEntity costShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNo(loadId, waybillNo);
carsLoadWaybillInfoVO.setCostPiece(costShareRecordEntity.getCostPiece());
carsLoadWaybillInfoVO.setCostZhang(costShareRecordEntity.getCostZhang());
carsLoadWaybillInfoVO.setCostNum(costShareRecordEntity.getNum());
freightPrice = totalFreight.divide(BigDecimal.valueOf(warehouseWaybillEntity.getTotalCount()),4, RoundingMode.HALF_UP);
}
}
List<CarsLoadOrderInfoVO> carsLoadOrderInfoList = new ArrayList<>();
BigDecimal finalFreightPrice = freightPrice;
carsLoadScanAbnormalVOS.forEach(carsLoadScanAbnormalVO -> {
CarsLoadOrderInfoVO carsLoadOrderInfoVO = new CarsLoadOrderInfoVO();
carsLoadOrderInfoVO.setOrderCode(carsLoadScanAbnormalVO.getOrderCode());
carsLoadOrderInfoVO.setLoadingNum(carsLoadScanAbnormalVO.getLoadingNum());
carsLoadOrderInfoVO.setUnloadNum(carsLoadScanAbnormalVO.getUnloadNum());
BigDecimal unloadIncome = finalFreightPrice.multiply(BigDecimal.valueOf(carsLoadScanAbnormalVO.getUnloadNum()));
carsLoadOrderInfoVO.setUnloadIncome(unloadIncome.setScale(2));
carsLoadOrderInfoVO.setPlanNum(0);
String orderCode = carsLoadScanAbnormalVO.getOrderCode();
if("--".equals(waybillNo) || "--".equals(orderCode)){
carsLoadOrderInfoVO.setOrderNum(0);
carsLoadOrderInfoVO.setOrderFreight(BigDecimal.ZERO.setScale(2));
}else{
Integer num = trunklineWaybillOrderService.findTotalNumByWaybillAndOrderCode(waybillNo, orderCode);
carsLoadOrderInfoVO.setOrderNum(num);
carsLoadOrderInfoVO.setOrderFreight(finalFreightPrice.multiply(BigDecimal.valueOf(num)).setScale(2));
}
TrunklineCostShareRecordEntity orderCostShareRecordEntity = trunklineCostShareRecordService.findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(loadId,waybillNo,orderCode);
carsLoadOrderInfoVO.setCostZhang(orderCostShareRecordEntity.getCostZhang());
carsLoadOrderInfoVO.setCostPiece(orderCostShareRecordEntity.getCostPiece());
// carsLoadOrderInfoVO.setWeight(BigDecimal.ZERO);
// carsLoadOrderInfoVO.setVolume(BigDecimal.ZERO);
carsLoadOrderInfoList.add(carsLoadOrderInfoVO);
});
carsLoadWaybillInfoVO.setCarsLoadOrderInfoList(carsLoadOrderInfoList);
carsLoadWaybillInfoList.add(carsLoadWaybillInfoVO);
});
}
//对元素中的waybillNo进行倒序排序
carsLoadWaybillInfoList.sort(Comparator.comparing(CarsLoadWaybillInfoVO::getWaybillNo).reversed());
trunklineCarsLoadVO.setCarsLoadWaybillInfoList(carsLoadWaybillInfoList);
return R.data(trunklineCarsLoadVO);

5
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCostShareRecordServiceImpl.java

@ -43,4 +43,9 @@ public class TrunklineCostShareRecordServiceImpl extends BaseServiceImpl<Trunkli
public TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNo(Long loadId, String waybillNo) {
return baseMapper.findTotalUnloadNumByLoadAndWaybillNo(loadId,waybillNo);
}
@Override
public TrunklineCostShareRecordEntity findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(Long loadId, String waybillNo, String orderCode) {
return baseMapper.findTotalUnloadNumByLoadAndWaybillNoAndOrderCode(loadId,waybillNo,orderCode);
}
}

5
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineWaybillOrderServiceImpl.java

@ -40,6 +40,11 @@ public class TrunklineWaybillOrderServiceImpl extends BaseServiceImpl<TrunklineW
return baseMapper.findTotalNumByWaybillNoAndOrderCode(waybillId,orderCode);
}
@Override
public Integer findTotalNumByWaybillAndOrderCode(String waybillNo, String orderCode) {
return baseMapper.findTotalNumByWaybillAndOrderCode(waybillNo,orderCode);
}
@Override
public List<Long> findAdvanceIdsByWaybillIds(List<Long> waybillIds) {
return baseMapper.findAdvanceIdsByWaybillIds(waybillIds);

Loading…
Cancel
Save