Compare commits
5 Commits
998c81680f
...
ae788be25b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae788be25b | ||
![]() |
797ef39bdb | ||
![]() |
b6c81caf6e | ||
![]() |
22c080f77a | ||
![]() |
5a3e98301b |
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
## ide
|
||||
**/.idea
|
||||
*.iml
|
||||
rebel.xml
|
||||
|
||||
## backend
|
||||
**/target
|
||||
**/logs
|
||||
*/logs
|
||||
|
||||
## front
|
||||
**/*.lock
|
Binary file not shown.
@ -147,7 +147,8 @@ spring:
|
||||
#redis 配置
|
||||
redis:
|
||||
database: 0
|
||||
host: 123.57.206.181
|
||||
# host: 123.57.206.181
|
||||
host: localhost
|
||||
port: 6379
|
||||
password: ''
|
||||
#mybatis plus 设置
|
||||
|
@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 9001
|
||||
tomcat:
|
||||
max-swallow-size: -1
|
||||
error:
|
||||
@ -110,7 +110,7 @@ spring:
|
||||
# 初始化大小,最小,最大
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
maxActive: 1000
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
@ -130,10 +130,14 @@ spring:
|
||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://114.215.188.164:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# username: root
|
||||
# password: 123456
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:oracle:thin:@123.57.206.181:1521/ORCLPDB1
|
||||
username: SDKTMS
|
||||
password: SDKTMS
|
||||
driver-class-name: oracle.jdbc.OracleDriver
|
||||
# 多数据源配置
|
||||
#multi-datasource1:
|
||||
#url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
@ -143,7 +147,7 @@ spring:
|
||||
#redis 配置
|
||||
redis:
|
||||
database: 0
|
||||
host: 127.0.0.1
|
||||
host: 123.57.206.181
|
||||
port: 6379
|
||||
password: ''
|
||||
#mybatis plus 设置
|
||||
@ -172,33 +176,32 @@ jeecg:
|
||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||
# 签名拦截接口
|
||||
signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys
|
||||
#local\minio\alioss
|
||||
uploadType: alioss
|
||||
#local、minio、alioss
|
||||
uploadType: local
|
||||
# 前端访问地址
|
||||
domainUrl:
|
||||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/jeecg-boot/upload
|
||||
upload: /opt/upFiles
|
||||
#webapp文件路径
|
||||
webapp: /opt/jeecg-boot/webapp
|
||||
webapp: /opt/webapp
|
||||
shiro:
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储和大鱼短信秘钥配置
|
||||
oss:
|
||||
accessKey: ??
|
||||
secretKey: ??
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
bucketName: jeecgdev
|
||||
staticDomain: https://static.jeecg.com
|
||||
# ElasticSearch 设置
|
||||
# ElasticSearch 6设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
cluster-nodes: 127.0.0.1:9200
|
||||
check-enabled: true
|
||||
check-enabled: false
|
||||
# 在线预览文件服务器地址配置
|
||||
file-view-domain: http://fileview.jeecg.com
|
||||
file-view-domain: 127.0.0.1:8012
|
||||
# minio文件上传
|
||||
minio:
|
||||
minio_url: http://minio.jeecg.com
|
||||
@ -207,7 +210,7 @@ jeecg:
|
||||
bucketName: otatest
|
||||
#大屏报表参数设置
|
||||
jmreport:
|
||||
mode: prod
|
||||
mode: dev
|
||||
#数据字典是否进行saas数据隔离,自己看自己的字典
|
||||
saas: false
|
||||
#是否需要校验token
|
||||
@ -245,7 +248,7 @@ knife4j:
|
||||
#开启生产环境屏蔽
|
||||
production: false
|
||||
basic:
|
||||
enable: true
|
||||
enable: false
|
||||
username: jeecg
|
||||
password: jeecg1314
|
||||
#第三方登录
|
||||
@ -295,4 +298,4 @@ third-app:
|
||||
client-id: ??
|
||||
# appSecret
|
||||
client-secret: ??
|
||||
agent-id: ??
|
||||
agent-id: ??
|
||||
|
@ -4,10 +4,8 @@ import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@ -86,7 +84,7 @@ public class TmsIogisticsPrice implements Serializable {
|
||||
/**车长*/
|
||||
@Excel(name = "车长", width = 15)
|
||||
@ApiModelProperty(value = "车长")
|
||||
private java.lang.Integer carLong;
|
||||
private java.lang.Double carLong;
|
||||
/**装卸吨位*/
|
||||
@Excel(name = "装卸吨位", width = 15)
|
||||
@ApiModelProperty(value = "装卸吨位")
|
||||
@ -125,4 +123,7 @@ public class TmsIogisticsPrice implements Serializable {
|
||||
@Excel(name = "时效", width = 15)
|
||||
@ApiModelProperty(value = "时效")
|
||||
private java.lang.String validity;
|
||||
/**托数*/
|
||||
@TableField(exist = false)
|
||||
private java.lang.Integer maxPallets;
|
||||
}
|
||||
|
@ -14,4 +14,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface TmsIogisticsPriceMapper extends BaseMapper<TmsIogisticsPrice> {
|
||||
|
||||
/**
|
||||
* 查询物流价格信息
|
||||
* @param pickUpHub 起始城市
|
||||
* @param deliveryAddress 目标城市
|
||||
* @return
|
||||
*/
|
||||
List<TmsIogisticsPrice> getIogisticsPrice(@Param("pickUpHub") String pickUpHub,
|
||||
@Param("deliveryAddress") String deliveryAddress);
|
||||
}
|
||||
|
@ -2,4 +2,11 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.tms.basicdata.iogisticsprice.mapper.TmsIogisticsPriceMapper">
|
||||
|
||||
<select id="getIogisticsPrice" resultType="org.jeecg.modules.tms.basicdata.iogisticsprice.entity.TmsIogisticsPrice">
|
||||
select a.*, b.max_pallets from tms_iogistics_price a left join tms_vehicle_pallet b
|
||||
on a.car_type = b.car_type
|
||||
and a.car_long = b.car_long
|
||||
where a.start_city = #{pickUpHub}
|
||||
and a.target_city = #{deliveryAddress}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -83,6 +83,8 @@ public class LogisticsRouteController extends JeecgController<LogisticsRoute, IL
|
||||
//@RequiresPermissions("org.jeecg.modules.tms:tms_logistics_route:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody LogisticsRoute logisticsRoute) {
|
||||
logisticsRoute.setRoute(logisticsRoute.getStartCity() + "--->" +
|
||||
logisticsRoute.getTargetCity());
|
||||
logisticsRouteService.save(logisticsRoute);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
@ -98,6 +100,8 @@ public class LogisticsRouteController extends JeecgController<LogisticsRoute, IL
|
||||
//@RequiresPermissions("org.jeecg.modules.tms:tms_logistics_route:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody LogisticsRoute logisticsRoute) {
|
||||
logisticsRoute.setRoute(logisticsRoute.getStartCity() + "--->" +
|
||||
logisticsRoute.getTargetCity());
|
||||
logisticsRouteService.updateById(logisticsRoute);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
@ -174,4 +178,28 @@ public class LogisticsRouteController extends JeecgController<LogisticsRoute, IL
|
||||
return super.importExcel(request, response, LogisticsRoute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询城市
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getCity")
|
||||
public Result<?> getCity() {
|
||||
List<LogisticsRoute> list = logisticsRouteService.list();
|
||||
List<String> strings = list.stream().map(s -> s.getStartCity() + "&-" + s.getTargetCity())
|
||||
.distinct().collect(Collectors.toList());
|
||||
return Result.OK(strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询区域城市
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getAreaCity")
|
||||
public Result<?> getAreaCity() {
|
||||
List<LogisticsRoute> list = logisticsRouteService.list();
|
||||
List<String> strings = list.stream().map(s -> s.getStartArea() + "&-" + s.getStartCity() + "&-" +
|
||||
s.getTargetArea() + "&-" + s.getTargetCity() + "&-" + s.getRoute() + "&-" + s.getKilometers())
|
||||
.distinct().collect(Collectors.toList());
|
||||
return Result.OK(strings);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.tms.basicdata.logisticsroute.entity.LogisticsRoute;
|
||||
import org.jeecg.modules.tms.basicdata.vehicleoperator.entity.TmsVehicleOperator;
|
||||
import org.jeecg.modules.tms.basicdata.vehicleoperator.service.ITmsVehicleOperatorService;
|
||||
|
||||
@ -174,4 +175,15 @@ public class TmsVehicleOperatorController extends JeecgController<TmsVehicleOper
|
||||
return super.importExcel(request, response, TmsVehicleOperator.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询供应商编码名称
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getSupplierCodeName")
|
||||
public Result<?> getSupplierCodeName() {
|
||||
List<TmsVehicleOperator> list = tmsVehicleOperatorService.list();
|
||||
List<String> strings = list.stream().map(s -> s.getSupplierCode() + "&-" + s.getSupplierName())
|
||||
.distinct().collect(Collectors.toList());
|
||||
return Result.OK(strings);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.tms.basicdata.logisticsroute.entity.LogisticsRoute;
|
||||
import org.jeecg.modules.tms.basicdata.vehiclepallet.entity.VehiclePallet;
|
||||
import org.jeecg.modules.tms.basicdata.vehiclepallet.service.IVehiclePalletService;
|
||||
|
||||
@ -174,9 +175,25 @@ public class VehiclePalletController extends JeecgController<VehiclePallet, IVeh
|
||||
return super.importExcel(request, response, VehiclePallet.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询车型
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getCarType")
|
||||
public Result<?> getCarType() {
|
||||
List<String> cars = vehiclePalletService.getCarType();
|
||||
return Result.ok(cars);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆线呢车型车长
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getCarTypeLong")
|
||||
public Result<?> getCarTypeLong() {
|
||||
List<VehiclePallet> list = vehiclePalletService.list();
|
||||
List<String> strings = list.stream().map(s -> s.getCarType() + "&-" + s.getCarLong())
|
||||
.distinct().collect(Collectors.toList());
|
||||
return Result.OK(strings);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class VehiclePallet implements Serializable {
|
||||
/**车长*/
|
||||
@Excel(name = "车长", width = 15)
|
||||
@ApiModelProperty(value = "车长")
|
||||
private java.lang.Integer carLong;
|
||||
private java.lang.Double carLong;
|
||||
/**托数*/
|
||||
@Excel(name = "托数", width = 15)
|
||||
@ApiModelProperty(value = "托数")
|
||||
|
@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.tms.basicdata.logisticsroute.entity.LogisticsRoute;
|
||||
import org.jeecg.modules.tms.basicdata.vehicleproduct.entity.TmsVehicleProduct;
|
||||
import org.jeecg.modules.tms.basicdata.vehicleproduct.service.ITmsVehicleProductService;
|
||||
|
||||
@ -174,4 +175,11 @@ public class TmsVehicleProductController extends JeecgController<TmsVehicleProdu
|
||||
return super.importExcel(request, response, TmsVehicleProduct.class);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getPnSpecList")
|
||||
public Result<?> getPnSpecList() {
|
||||
List<TmsVehicleProduct> list = tmsVehicleProductService.list();
|
||||
List<String> strings = list.stream().map(s -> s.getPn() + "&-" + s.getSpec())
|
||||
.distinct().collect(Collectors.toList());
|
||||
return Result.OK(strings);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.tms.carinout.vehicleinout.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@ -176,6 +177,11 @@ public class VehicleInOutController extends JeecgController<VehicleInOut, IVehic
|
||||
|
||||
@PostMapping(value = "/handleConfirm")
|
||||
public Result<String> handleConfirm(@RequestBody VehicleInOut vehicleInOut) {
|
||||
if ("3".equals(vehicleInOut.getCurrentStatus())) {
|
||||
vehicleInOut.setAtaTime(new Date());
|
||||
} else if ("4".equals(vehicleInOut.getCurrentStatus())) {
|
||||
vehicleInOut.setAtdTime(new Date());
|
||||
}
|
||||
vehicleInOutService.updateById(vehicleInOut);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class VehicleInOut implements Serializable {
|
||||
@Excel(name = "司机电话", width = 15)
|
||||
@ApiModelProperty(value = "司机电话")
|
||||
private java.lang.String driverTel;
|
||||
/**当前状态*/
|
||||
/**当前状态 创建-0,对接人确认-1,预约入厂-2,审核入库-3,审核出厂-4*/
|
||||
@Excel(name = "当前状态", width = 15, dicCode = "currentStatus")
|
||||
@Dict(dicCode = "currentStatus")
|
||||
@ApiModelProperty(value = "当前状态")
|
||||
|
@ -201,9 +201,24 @@ public class DeliveryDemandController extends JeecgController<DeliveryDemand, ID
|
||||
return deliveryDemandService.handleMerge(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据料号、规格、发货数量计算托盘数
|
||||
* @param deliveryDemand
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getPalletsNum")
|
||||
public Result<?> getPalletsNum(@RequestBody DeliveryDemand deliveryDemand) {
|
||||
return deliveryDemandService.getPalletsNum(deliveryDemand);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用车需求编号查询用车需求物料明细
|
||||
* @param vdNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getByVdNo")
|
||||
public Result<?> getByVdNo(@RequestParam(name="vdNo",required=true) String vdNo) {
|
||||
List<DeliveryDemand> vdNos = deliveryDemandService.query().eq("vd_no", vdNo).list();
|
||||
return Result.OK(vdNos);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package org.jeecg.modules.tms.outbound.vehicledemand.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
* @Author admin
|
||||
* @Date 2025/4/23 9:12
|
||||
*/
|
||||
@Data
|
||||
public class Solution {
|
||||
/**方案*/
|
||||
Map<String, Integer> vehicleCounts;
|
||||
/**成本*/
|
||||
BigDecimal totalCost;
|
||||
}
|
@ -3,9 +3,13 @@ package org.jeecg.modules.tms.outbound.vehicledemand.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.tms.basicdata.iogisticsprice.entity.TmsIogisticsPrice;
|
||||
import org.jeecg.modules.tms.basicdata.iogisticsprice.mapper.TmsIogisticsPriceMapper;
|
||||
import org.jeecg.modules.tms.basicdata.vehiclepallet.entity.VehiclePallet;
|
||||
import org.jeecg.modules.tms.basicdata.vehiclepallet.mapper.VehiclePalletMapper;
|
||||
import org.jeecg.modules.tms.outbound.vehicledemand.entity.Solution;
|
||||
import org.jeecg.modules.tms.outbound.vehicledemand.entity.VehicleDemand;
|
||||
import org.jeecg.modules.tms.outbound.vehicledemand.mapper.VehicleDemandMapper;
|
||||
import org.jeecg.modules.tms.outbound.vehicledemand.service.IVehicleDemandService;
|
||||
@ -15,8 +19,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 用车需求
|
||||
@ -24,14 +28,149 @@ import java.util.List;
|
||||
* @Date: 2025-04-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, VehicleDemand> implements IVehicleDemandService {
|
||||
|
||||
private final VehiclePalletMapper vehiclePalletMapper;
|
||||
private final IVehicleDemandCountService vehicleDemandCountService;
|
||||
private final TmsIogisticsPriceMapper iogisticsPriceMapper;
|
||||
|
||||
@Override
|
||||
public Result<?> carCount(VehicleDemand vehicleDemand) {
|
||||
// 1.判断是否进行过用车计算
|
||||
LambdaQueryWrapper<VehicleDemandCount> countLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
countLambdaQueryWrapper.eq(VehicleDemandCount::getVdNo, vehicleDemand.getVdNo());
|
||||
List<VehicleDemandCount> list = vehicleDemandCountService.list(countLambdaQueryWrapper);
|
||||
// 1.1.进行过
|
||||
if (list != null && list.size() > 0) {
|
||||
return Result.error("已经进行过用车计算了!");
|
||||
}
|
||||
// 2.查询物流价格信息(从起始城市到目标城市各种车型的价格)
|
||||
List<TmsIogisticsPrice> iogisticsPriceList = iogisticsPriceMapper.getIogisticsPrice(
|
||||
vehicleDemand.getPickUpHub(),
|
||||
vehicleDemand.getDeliveryAddress());
|
||||
if (iogisticsPriceList == null || iogisticsPriceList.size() <= 0) {
|
||||
return Result.error("没有符合的物流价格基础信息,请维护!");
|
||||
}
|
||||
// 3.查找费用最低的方案
|
||||
// Map<String, Integer> vehicleCounts;
|
||||
// String: 由车型与车长组成,以逗号分隔
|
||||
// Integer: 该种车型与车长选择的数量
|
||||
Solution solution = findCheapestSolution(iogisticsPriceList, vehicleDemand.getTotalPallets());
|
||||
// 打印,方便查看,开发时可以打开
|
||||
/*for (Map.Entry<String, Integer> entry : solution.getVehicleCounts().entrySet()) {
|
||||
System.out.println(entry.getKey() + " 车: " + entry.getValue() + " 辆");
|
||||
}*/
|
||||
// 4.转化集合
|
||||
List<VehicleDemandCount> vehicleDemandCounts = convertToVehicleDemandCountList(solution.getVehicleCounts(), vehicleDemand);
|
||||
// 5.新增
|
||||
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
||||
log.info("用车需求计算,用车需求编号:{},方案:{},费用:{}",vehicleDemand.getVdNo(),
|
||||
solution.getVehicleCounts(),solution.getTotalCost());
|
||||
return Result.OK("用车计算成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找费用最低的方案
|
||||
*/
|
||||
private Solution findCheapestSolution(List<TmsIogisticsPrice> iogisticsPriceList, Integer totalPallets) {
|
||||
// dp[i] 表示运送 i 托盘时的最小成本
|
||||
BigDecimal[] dp = new BigDecimal[totalPallets + 1];
|
||||
Arrays.fill(dp, BigDecimal.valueOf(Integer.MAX_VALUE));
|
||||
dp[0] = BigDecimal.ZERO;
|
||||
|
||||
// 记录每种状态下的车辆选择
|
||||
Map<Integer, Map<String, Integer>> choices = new HashMap<>();
|
||||
for (int i = 0; i <= totalPallets; i++) {
|
||||
choices.put(i, new HashMap<>());
|
||||
}
|
||||
|
||||
// 动态规划填表
|
||||
for (int i = 0; i <= totalPallets; i++) {
|
||||
if (dp[i].compareTo(BigDecimal.valueOf(Integer.MAX_VALUE)) == 0) continue; // 如果当前状态不可达,跳过
|
||||
|
||||
for (TmsIogisticsPrice iogisticsPrice : iogisticsPriceList) {
|
||||
int next = i + iogisticsPrice.getMaxPallets();
|
||||
if (next > totalPallets) next = totalPallets; // 不超过总托盘数
|
||||
|
||||
BigDecimal newCost = dp[i].add(iogisticsPrice.getTandardPrice());
|
||||
if (newCost.compareTo(dp[next]) < 0 ) { // 如果新成本更低,则更新
|
||||
dp[next] = newCost;
|
||||
|
||||
// 更新车辆选择
|
||||
Map<String, Integer> newChoices = new HashMap<>(choices.get(i));
|
||||
newChoices.put(iogisticsPrice.getCarType() + "," +iogisticsPrice.getCarLong(), newChoices.getOrDefault(iogisticsPrice.getCarType() + "," +iogisticsPrice.getCarLong(), 0) + 1);
|
||||
choices.put(next, newChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
// choices.get(totalPallets):选择的方案, dp[totalPallets]费用
|
||||
Solution solution = new Solution();
|
||||
solution.setVehicleCounts(choices.get(totalPallets));
|
||||
solution.setTotalCost(dp[totalPallets]);
|
||||
return solution;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化集合
|
||||
* @param vehicleCounts
|
||||
* @return
|
||||
*/
|
||||
private List<VehicleDemandCount> convertToVehicleDemandCountList(Map<String, Integer> vehicleCounts,
|
||||
VehicleDemand vehicleDemand) {
|
||||
List<VehicleDemandCount> resultList = new ArrayList<>();
|
||||
|
||||
// 遍历 solution.getVehicleCounts()
|
||||
for (Map.Entry<String, Integer> entry : vehicleCounts.entrySet()) {
|
||||
String key = entry.getKey(); // 键格式为 "车类型,车长度"
|
||||
int count = entry.getValue(); // 车辆数量
|
||||
|
||||
// 解析车类型和车长度
|
||||
String[] parts = key.split(",");
|
||||
/*if (parts.length != 2) {
|
||||
throw new IllegalArgumentException("键格式错误: " + key);
|
||||
}*/
|
||||
String carType = parts[0]; // 车类型
|
||||
double carLong = Double.parseDouble(parts[1]); // 车长度
|
||||
|
||||
// 根据车辆数量生成多条记录
|
||||
for (int i = 0; i < count; i++) {
|
||||
VehicleDemandCount vehicleDemandCount = new VehicleDemandCount();
|
||||
vehicleDemandCount.setCarType(carType)
|
||||
.setCarLong(carLong)
|
||||
.setVdNo(vehicleDemand.getVdNo())
|
||||
.setShipType(vehicleDemand.getShipType())
|
||||
.setDeliveryAddress(vehicleDemand.getDeliveryAddress())
|
||||
.setPickUpHub(vehicleDemand.getPickUpHub());
|
||||
resultList.add(vehicleDemandCount);
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼凑一个用车需求计算的集合
|
||||
* @param vehicleDemand
|
||||
* @param vehiclePallet
|
||||
* @param vehicleDemandCounts
|
||||
*/
|
||||
/*private void insertVehicleDemandCount(VehicleDemand vehicleDemand, VehiclePallet vehiclePallet, List<VehicleDemandCount> vehicleDemandCounts) {
|
||||
VehicleDemandCount vehicleDemandCount = new VehicleDemandCount();
|
||||
vehicleDemandCount.setVdNo(vehicleDemand.getVdNo())
|
||||
.setShipType(vehicleDemand.getShipType())
|
||||
.setDeliveryArea(vehicleDemand.getDeliveryArea())
|
||||
.setDeliveryAddress(vehicleDemand.getDeliveryAddress())
|
||||
.setPickUpHub(vehicleDemand.getPickUpHub())
|
||||
.setCarType(vehiclePallet.getCarType())
|
||||
.setCarLong(vehiclePallet.getCarLong());
|
||||
vehicleDemandCounts.add(vehicleDemandCount);
|
||||
}*/
|
||||
|
||||
|
||||
/* 原来的用车计算方法
|
||||
public Result<?> carCount(VehicleDemand vehicleDemand) {
|
||||
// 1.判断是否进行过用车计算
|
||||
LambdaQueryWrapper<VehicleDemandCount> countLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@ -70,23 +209,5 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
||||
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
||||
System.out.println(ids);
|
||||
return Result.OK("用车计算成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼凑一个用车需求计算的集合
|
||||
* @param vehicleDemand
|
||||
* @param vehiclePallet
|
||||
* @param vehicleDemandCounts
|
||||
*/
|
||||
private void insertVehicleDemandCount(VehicleDemand vehicleDemand, VehiclePallet vehiclePallet, List<VehicleDemandCount> vehicleDemandCounts) {
|
||||
VehicleDemandCount vehicleDemandCount = new VehicleDemandCount();
|
||||
vehicleDemandCount.setVdNo(vehicleDemand.getVdNo())
|
||||
.setShipType(vehicleDemand.getShipType())
|
||||
.setDeliveryArea(vehicleDemand.getDeliveryArea())
|
||||
.setDeliveryAddress(vehicleDemand.getDeliveryAddress())
|
||||
.setPickUpHub(vehicleDemand.getPickUpHub())
|
||||
.setCarType(vehiclePallet.getCarType())
|
||||
.setCarLong(vehiclePallet.getCarLong());
|
||||
vehicleDemandCounts.add(vehicleDemandCount);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
@ -174,4 +176,17 @@ public class VehicleDemandCountController extends JeecgController<VehicleDemandC
|
||||
return super.importExcel(request, response, VehicleDemandCount.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用车需求编号查询用车需求计算
|
||||
* @param vdNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getByVdNo")
|
||||
public Result<?> getByVdNo(@RequestParam(name="vdNo",required=true) String vdNo) {
|
||||
List<VehicleDemandCount> vdNos = vehicleDemandCountService.query().eq("vd_no", vdNo).list();
|
||||
IPage<VehicleDemandCount> page = new Page<>(1, vdNos.size());
|
||||
page.setRecords(vdNos);
|
||||
page.setTotal(vdNos.size());
|
||||
return Result.OK(page);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class VehicleDemandCount implements Serializable {
|
||||
/**车长*/
|
||||
@Excel(name = "车长", width = 15)
|
||||
@ApiModelProperty(value = "车长")
|
||||
private java.lang.Integer carLong;
|
||||
private java.lang.Double carLong;
|
||||
/**送货区域*/
|
||||
@Excel(name = "送货区域", width = 15)
|
||||
@ApiModelProperty(value = "送货区域")
|
||||
|
@ -33,7 +33,7 @@
|
||||
<ojdbc6.version>11.2.0.3</ojdbc6.version>
|
||||
<ojdbc8.version>19.3.0.0</ojdbc8.version>
|
||||
<sqljdbc4.version>4.0</sqljdbc4.version>
|
||||
<mysql-connector-java.version>8.0.27</mysql-connector-java.version>
|
||||
<mysql-connector-java.version>8.0.28</mysql-connector-java.version>
|
||||
<hutool.version>5.8.25</hutool.version>
|
||||
|
||||
<!-- 持久层 -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user