用车计算逻辑调整

This commit is contained in:
王帅 2025-06-11 13:34:55 +08:00
parent aa37b20015
commit 658264daad
3 changed files with 23 additions and 10 deletions

View File

@ -310,7 +310,7 @@ public class VehicleDemandController extends JeecgController<VehicleDemand, IVeh
} }
/** /**
* 解绑 * 解绑,拆分
* @param ids * @param ids
* @return * @return
*/ */
@ -320,6 +320,10 @@ public class VehicleDemandController extends JeecgController<VehicleDemand, IVeh
List<String> vdNoNews = vehicleDemands.stream() List<String> vdNoNews = vehicleDemands.stream()
.map(VehicleDemand::getVdNo) .map(VehicleDemand::getVdNo)
.collect(Collectors.toList()); .collect(Collectors.toList());
boolean hasEven = vehicleDemands.stream().anyMatch(item -> !TmsConstants.currentStatus_1.equals(item.getCurrentStatus()));
if (hasEven) {
return Result.error("数据中含有不是已合并需求的数据!");
}
LambdaQueryWrapper<VehicleDemandHis> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<VehicleDemandHis> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(VehicleDemandHis::getVdNoNew, vdNoNews); lambdaQueryWrapper.in(VehicleDemandHis::getVdNoNew, vdNoNews);
List<VehicleDemandHis> list = vehicleDemandHisService.list(lambdaQueryWrapper); List<VehicleDemandHis> list = vehicleDemandHisService.list(lambdaQueryWrapper);

View File

@ -47,6 +47,7 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
private final TmsIogisticsPriceMapper iogisticsPriceMapper; private final TmsIogisticsPriceMapper iogisticsPriceMapper;
private final DeliveryDemandMapper deliveryDemandMapper; private final DeliveryDemandMapper deliveryDemandMapper;
/*//用车计算方法,根据价格选择车tms_iogistics_price表
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result<?> carCount(VehicleDemand vehicleDemand) { public Result<?> carCount(VehicleDemand vehicleDemand) {
@ -71,9 +72,9 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
// Integer: 该种车型与车长选择的数量 // Integer: 该种车型与车长选择的数量
Solution solution = findCheapestSolution(iogisticsPriceList, vehicleDemand.getTotalPallets()); Solution solution = findCheapestSolution(iogisticsPriceList, vehicleDemand.getTotalPallets());
// 打印方便查看开发时可以打开 // 打印方便查看开发时可以打开
/*for (Map.Entry<String, Integer> entry : solution.getVehicleCounts().entrySet()) { *//*for (Map.Entry<String, Integer> entry : solution.getVehicleCounts().entrySet()) {
System.out.println(entry.getKey() + " 车: " + entry.getValue() + ""); System.out.println(entry.getKey() + " 车: " + entry.getValue() + "");
}*/ }*//*
// 4.转化集合 // 4.转化集合
List<VehicleDemandCount> vehicleDemandCounts = convertToVehicleDemandCountList(solution.getVehicleCounts(), vehicleDemand); List<VehicleDemandCount> vehicleDemandCounts = convertToVehicleDemandCountList(solution.getVehicleCounts(), vehicleDemand);
// 5.新增 // 5.新增
@ -83,7 +84,7 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
log.info("用车需求计算,用车需求编号:{},方案:{},费用:{}",vehicleDemand.getVdNo(), log.info("用车需求计算,用车需求编号:{},方案:{},费用:{}",vehicleDemand.getVdNo(),
solution.getVehicleCounts(),solution.getTotalCost()); solution.getVehicleCounts(),solution.getTotalCost());
return Result.OK("用车计算成功!"); return Result.OK("用车计算成功!");
} }*/
/** /**
* 查找费用最低的方案 * 查找费用最低的方案
@ -177,7 +178,7 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
* @param * @param
* @param * @param
*/ */
/*private void insertVehicleDemandCount(VehicleDemand vehicleDemand, VehiclePallet vehiclePallet, List<VehicleDemandCount> vehicleDemandCounts) { private void insertVehicleDemandCount(VehicleDemand vehicleDemand, VehiclePallet vehiclePallet, List<VehicleDemandCount> vehicleDemandCounts) {
VehicleDemandCount vehicleDemandCount = new VehicleDemandCount(); VehicleDemandCount vehicleDemandCount = new VehicleDemandCount();
vehicleDemandCount.setVdNo(vehicleDemand.getVdNo()) vehicleDemandCount.setVdNo(vehicleDemand.getVdNo())
.setShipType(vehicleDemand.getShipType()) .setShipType(vehicleDemand.getShipType())
@ -185,12 +186,16 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
.setDeliveryAddress(vehicleDemand.getDeliveryAddress()) .setDeliveryAddress(vehicleDemand.getDeliveryAddress())
.setPickUpHub(vehicleDemand.getPickUpHub()) .setPickUpHub(vehicleDemand.getPickUpHub())
.setCarType(vehiclePallet.getCarType()) .setCarType(vehiclePallet.getCarType())
.setCarLong(vehiclePallet.getCarLong()); .setSystemCarType(vehiclePallet.getCarType())
.setCarLong(vehiclePallet.getCarLong())
.setSystemCarLong(vehiclePallet.getCarLong());
vehicleDemandCounts.add(vehicleDemandCount); vehicleDemandCounts.add(vehicleDemandCount);
}*/ }
/* 原来的用车计算方法 // 用车计算方法,根据托盘数选择大车只考虑托盘数不考虑价格tms_vehicle_pallet表
@Override
@Transactional(rollbackFor = Exception.class)
public Result<?> carCount(VehicleDemand vehicleDemand) { public Result<?> carCount(VehicleDemand vehicleDemand) {
// 1.判断是否进行过用车计算 // 1.判断是否进行过用车计算
LambdaQueryWrapper<VehicleDemandCount> countLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<VehicleDemandCount> countLambdaQueryWrapper = new LambdaQueryWrapper<>();
@ -226,8 +231,11 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
ids.add(smallestVehicle.getId()); ids.add(smallestVehicle.getId());
insertVehicleDemandCount(vehicleDemand, smallestVehicle, vehicleDemandCounts); insertVehicleDemandCount(vehicleDemand, smallestVehicle, vehicleDemandCounts);
} }
// 新增
vehicleDemandCountService.saveBatch(vehicleDemandCounts); vehicleDemandCountService.saveBatch(vehicleDemandCounts);
// 更新发货需求当前状态
deliveryDemandMapper.updateByVdNo(vehicleDemand.getVdNo(), TmsConstants.currentStatus_2);
System.out.println(ids); System.out.println(ids);
return Result.OK("用车计算成功!"); return Result.OK("用车计算成功!");
}*/ }
} }

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.tms.outbound.vehicledemandhis.entity; package org.jeecg.modules.tms.outbound.vehicledemandhis.entity;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
@ -84,7 +85,7 @@ public class VehicleDemandHis implements Serializable {
/**总发货数量*/ /**总发货数量*/
@Excel(name = "总发货数量", width = 15) @Excel(name = "总发货数量", width = 15)
@ApiModelProperty(value = "总发货数量") @ApiModelProperty(value = "总发货数量")
private Integer totalShips; private BigDecimal totalShips;
/**送货区域*/ /**送货区域*/
// @Excel(name = "送货区域", width = 15) // @Excel(name = "送货区域", width = 15)
@ApiModelProperty(value = "送货区域") @ApiModelProperty(value = "送货区域")