|
|
@@ -1,6 +1,8 @@
|
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.sckw.core.common.enums.NumberConstant;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.CarWaybillEnum;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
@@ -35,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
@@ -80,11 +83,11 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param driverId 司机ID
|
|
|
- * @desc 统计司机任务数(待接单/出车/执行/完结)
|
|
|
+ * @desc 统计司机任务数(待接单 / 出车 / 执行 / 完结)
|
|
|
* @author zk
|
|
|
* @date 2023/8/1
|
|
|
**/
|
|
|
- public Map findStatisticsCountByDriver(Long driverId){
|
|
|
+ public Map findStatisticsCountByDriver(Long driverId) {
|
|
|
return waybillOrderDao.findStatisticsCountByDriver(driverId);
|
|
|
}
|
|
|
|
|
|
@@ -94,7 +97,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/1
|
|
|
**/
|
|
|
- public Map findStatisticsSumByDriver(Map params){
|
|
|
+ public Map findStatisticsSumByDriver(Map params) {
|
|
|
return waybillOrderDao.findStatisticsSumByDriver(params);
|
|
|
}
|
|
|
|
|
|
@@ -104,7 +107,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/1
|
|
|
**/
|
|
|
- public List<WaybillOrderDriverVo> findWaybillOrderByDriver(Map params){
|
|
|
+ public List<WaybillOrderDriverVo> findWaybillOrderByDriver(Map params) {
|
|
|
/**参数处理**/
|
|
|
//业务状态busStatus 1待接单/2出车/3执行/4完结
|
|
|
Integer busStatus = Integer.parseInt(StringUtils.objectStr(params.get("busStatus")));
|
|
|
@@ -125,13 +128,13 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**数据组装**/
|
|
|
List<Long> entIds = new ArrayList<>();
|
|
|
- for (WaybillOrderDriverVo waybillOrder:waybillOrders) {
|
|
|
+ for (WaybillOrderDriverVo waybillOrder : waybillOrders) {
|
|
|
entIds.add(waybillOrder.getCarrierEntId());
|
|
|
}
|
|
|
//企业数据集
|
|
|
entIds = entIds.stream().distinct().collect(Collectors.toList());
|
|
|
Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
- for (WaybillOrderDriverVo waybillOrder:waybillOrders) {
|
|
|
+ for (WaybillOrderDriverVo waybillOrder : waybillOrders) {
|
|
|
EntCacheResDto ent = ents == null ? null : ents.get(waybillOrder.getCarrierEntId());
|
|
|
waybillOrder.setCarrierFirmName(ent != null ? ent.getFirmName() : null);
|
|
|
}
|
|
|
@@ -144,7 +147,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/2
|
|
|
**/
|
|
|
- public HttpResult changeWaybillOrder(@RequestParam("wOrderId") Long wOrderId){
|
|
|
+ public HttpResult changeWaybillOrder(@RequestParam("wOrderId") Long wOrderId) {
|
|
|
//车辆运单信息
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(wOrderId);
|
|
|
//循环派车信息
|
|
|
@@ -156,7 +159,7 @@ public class KwtWaybillOrderService {
|
|
|
Map<String, Object> result = new HashMap();
|
|
|
result.put("id", wOrderId);
|
|
|
result.put("wOrderId", wOrderId);
|
|
|
- if (waybillOrder != null){
|
|
|
+ if (waybillOrder != null) {
|
|
|
result.put("wOrderNo", waybillOrder.getWOrderNo());
|
|
|
result.put("status", waybillOrder.getStatus());
|
|
|
result.put("truckNo", waybillOrder.getTruckNo());
|
|
|
@@ -191,7 +194,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/2
|
|
|
**/
|
|
|
- public HttpResult changeDriver(@RequestBody @Valid ChangeDriverDto params){
|
|
|
+ public HttpResult changeDriver(@RequestBody @Valid ChangeDriverDto params) {
|
|
|
/**数据校验**/
|
|
|
SckwWaybillOrder wOrder = new SckwWaybillOrder();
|
|
|
//车辆运单信息
|
|
|
@@ -238,7 +241,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/2
|
|
|
**/
|
|
|
- public HttpResult changeTruck(@RequestBody @Valid ChangeTruckDto params){
|
|
|
+ public HttpResult changeTruck(@RequestBody @Valid ChangeTruckDto params) {
|
|
|
/**数据校验**/
|
|
|
SckwWaybillOrder wOrder = new SckwWaybillOrder();
|
|
|
//车辆运单信息
|
|
|
@@ -284,13 +287,13 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param circulateId 循环派车信息ID
|
|
|
- * @param driver 司机信息
|
|
|
- * @param truck 车辆信息
|
|
|
+ * @param driver 司机信息
|
|
|
+ * @param truck 车辆信息
|
|
|
* @desc 变更循环派车信息
|
|
|
* @author zk
|
|
|
* @date 2023/8/2
|
|
|
**/
|
|
|
- public void changeWaybillOrderCirculate(Long circulateId, ChangeDriverDto driver, ChangeTruckDto truck){
|
|
|
+ public void changeWaybillOrderCirculate(Long circulateId, ChangeDriverDto driver, ChangeTruckDto truck) {
|
|
|
//循环派车信息
|
|
|
KwtLogisticsOrderCirculate circulate = new KwtLogisticsOrderCirculate();
|
|
|
if (driver != null) {
|
|
|
@@ -309,12 +312,12 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param driver 司机信息
|
|
|
- * @param truck 车辆信息
|
|
|
+ * @param truck 车辆信息
|
|
|
* @desc 更新车辆运单信息
|
|
|
* @author zk
|
|
|
* @date 2023/8/2
|
|
|
**/
|
|
|
- public void changeWaybillOrder(ChangeDriverDto driver, ChangeTruckDto truck){
|
|
|
+ public void changeWaybillOrder(ChangeDriverDto driver, ChangeTruckDto truck) {
|
|
|
//车辆运单信息
|
|
|
KwtWaybillOrder waybillOrder = new KwtWaybillOrder();
|
|
|
if (driver != null) {
|
|
|
@@ -349,7 +352,7 @@ public class KwtWaybillOrderService {
|
|
|
return result;
|
|
|
}
|
|
|
//下游司机委派量累加(趟次)
|
|
|
- BigDecimal ranksAmount = (BigDecimal)result.getData();
|
|
|
+ BigDecimal ranksAmount = (BigDecimal) result.getData();
|
|
|
|
|
|
/**数据处理**/
|
|
|
result = setWaybillOrder(params, logisticsOrder);
|
|
|
@@ -369,7 +372,7 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**Mongodb数据存储**/
|
|
|
//1车辆订单
|
|
|
- for (SckwWaybillOrder waybillOrder:sckwWaybillOrders) {
|
|
|
+ for (SckwWaybillOrder waybillOrder : sckwWaybillOrders) {
|
|
|
//rabbitMq业务汇总数据发送/消费对象
|
|
|
SckwBusSum busSum = new SckwBusSum();
|
|
|
//业务汇总类型
|
|
|
@@ -390,7 +393,7 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param params 派车请求参数
|
|
|
+ * @param params 派车请求参数
|
|
|
* @param logisticsOrder 物流订单
|
|
|
* @desc 派车校验
|
|
|
* @author zk
|
|
|
@@ -399,13 +402,13 @@ public class KwtWaybillOrderService {
|
|
|
public HttpResult checkWaybillOrder(List<SendCarDto1> params, KwtLogisticsOrder logisticsOrder) {
|
|
|
/**校验物流运单是否可以派车**/
|
|
|
if (logisticsOrder == null) {
|
|
|
- return HttpResult.error("订单已不存在!" );
|
|
|
+ return HttpResult.error("订单已不存在!");
|
|
|
}
|
|
|
|
|
|
//状态校验
|
|
|
if (logisticsOrder.getStatus() != LogisticsOrderEnum.WAIT_DELIVERY.getCode()
|
|
|
&& logisticsOrder.getStatus() != LogisticsOrderEnum.IN_TRANSIT.getCode()) {
|
|
|
- return HttpResult.error("订单"+LogisticsOrderEnum.getName(logisticsOrder.getStatus())+"不能派车!" );
|
|
|
+ return HttpResult.error("订单" + LogisticsOrderEnum.getName(logisticsOrder.getStatus()) + "不能派车!");
|
|
|
}
|
|
|
|
|
|
//剩余可运量校验
|
|
|
@@ -414,17 +417,17 @@ public class KwtWaybillOrderService {
|
|
|
//历史下游司机委派量 + 分包量
|
|
|
BigDecimal entrustAmountTotal = entrustAmount.add(subcontractAmount);
|
|
|
if (entrustAmountTotal.compareTo(logisticsOrder.getAmount()) > 0) {
|
|
|
- return HttpResult.error("剩余可运量已不能派车!" );
|
|
|
+ return HttpResult.error("剩余可运量已不能派车!");
|
|
|
}
|
|
|
|
|
|
/**校验是车辆委托量否超过物流订单剩余量**/
|
|
|
//下游司机委派量累加(趟次)
|
|
|
BigDecimal ranksAmount = new BigDecimal(Global.AMOUNT);
|
|
|
- for (SendCarDto1 sendCarDto:params) {
|
|
|
+ for (SendCarDto1 sendCarDto : params) {
|
|
|
if (sendCarDto.getType() == Global.NUMERICAL_ONE) {
|
|
|
//趟次派车趟次数量必填
|
|
|
if (sendCarDto.getCount() == null || sendCarDto.getCount() <= 0) {
|
|
|
- return HttpResult.error(sendCarDto.getTruckNo() + "趟次必须等于或大于0!" );
|
|
|
+ return HttpResult.error(sendCarDto.getTruckNo() + "趟次必须等于或大于0!");
|
|
|
}
|
|
|
//承运订单该车辆计划运输总量:核定载量 * 趟次
|
|
|
Double truckEntrustAmount = sendCarDto.getEntrustAmount() * sendCarDto.getCount();
|
|
|
@@ -433,7 +436,7 @@ public class KwtWaybillOrderService {
|
|
|
//当前下游司机委派量 + 历史下游司机委派量 + 分包量
|
|
|
BigDecimal actualAmount = ranksAmount.add(entrustAmountTotal);
|
|
|
if (actualAmount.compareTo(logisticsOrder.getAmount()) > 0) {
|
|
|
- return HttpResult.error("累计派车量已大于剩余可运量!" );
|
|
|
+ return HttpResult.error("累计派车量已大于剩余可运量!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -441,7 +444,7 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param params 派车请求参数
|
|
|
+ * @param params 派车请求参数
|
|
|
* @param logisticsOrder 物流订单
|
|
|
* @desc 派车存储
|
|
|
* @author zk
|
|
|
@@ -462,13 +465,13 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**MySql车辆运单数据处理/存储**/
|
|
|
List<SckwWaybillOrder> sckwWaybillOrders = new ArrayList();
|
|
|
- for (SendCarDto1 sendCarDto:params) {
|
|
|
+ for (SendCarDto1 sendCarDto : params) {
|
|
|
/**KwtWaybillOrder数据组装**/
|
|
|
KwtWaybillOrder waybillOrder = this.setKwtWaybillOrder(sendCarDto);
|
|
|
|
|
|
/**数据存储**/
|
|
|
if (sendCarDto.getType() == Global.NUMERICAL_ONE) {
|
|
|
- for (int i=0; i<sendCarDto.getCount(); i++) {
|
|
|
+ for (int i = 0; i < sendCarDto.getCount(); i++) {
|
|
|
//车辆运单存储
|
|
|
ranksSave(waybillOrder, loadAddress, unloadAddress);
|
|
|
|
|
|
@@ -508,8 +511,8 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param waybillOrder 车辆订单信息
|
|
|
- * @param loadAddress 装货地址信息
|
|
|
+ * @param waybillOrder 车辆订单信息
|
|
|
+ * @param loadAddress 装货地址信息
|
|
|
* @param unloadAddress 卸货地址信息
|
|
|
* @desc 趟次派车数据存储
|
|
|
* @author zk
|
|
|
@@ -558,7 +561,7 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param lOrderId 物流订单ID
|
|
|
+ * @param lOrderId 物流订单ID
|
|
|
* @param addressType 地址类型(1装货地址、2卸货地址)
|
|
|
* @desc 获取物流订单地址信息
|
|
|
* @author zk
|
|
|
@@ -581,8 +584,8 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param wOrderId 车辆订单ID
|
|
|
- * @param status 车辆运单状态
|
|
|
- * @param remark 备注
|
|
|
+ * @param status 车辆运单状态
|
|
|
+ * @param remark 备注
|
|
|
* @desc 新增运单状态记录
|
|
|
* @author zk
|
|
|
* @date 2023/7/20
|
|
|
@@ -626,13 +629,13 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param sendCarDto 派车请求参数
|
|
|
+ * @param sendCarDto 派车请求参数
|
|
|
* @param logisticsOrder 承运订单
|
|
|
- * @param loadAddress 装货地址
|
|
|
- * @param unloadAddress 卸货地址
|
|
|
- * @param checkEnt 托运企业
|
|
|
- * @param carrierEnt 承运企业
|
|
|
- * @param goods 商品信息
|
|
|
+ * @param loadAddress 装货地址
|
|
|
+ * @param unloadAddress 卸货地址
|
|
|
+ * @param checkEnt 托运企业
|
|
|
+ * @param carrierEnt 承运企业
|
|
|
+ * @param goods 商品信息
|
|
|
* @desc mongodb车辆运单对象赋值
|
|
|
* @author zk
|
|
|
* @date 2023/7/20
|
|
|
@@ -760,7 +763,7 @@ public class KwtWaybillOrderService {
|
|
|
//int level = checkLogisticsLevel(logisticsOrder);
|
|
|
String pids = logisticsOrder.getPids();
|
|
|
if (StringUtils.isNotBlank(pids)) {
|
|
|
- String [] idArray = pids.split(Global.COMMA);
|
|
|
+ String[] idArray = pids.split(Global.COMMA);
|
|
|
for (String id : idArray) {
|
|
|
KwtLogisticsOrder order = logisticsOrderDao.selectById(id);
|
|
|
//承运订单-待派车
|
|
|
@@ -794,7 +797,7 @@ public class KwtWaybillOrderService {
|
|
|
**/
|
|
|
public int logisticsLevel(KwtLogisticsOrder logisticsOrder) {
|
|
|
String pids = logisticsOrder.getPids();
|
|
|
- String [] idArrays = StringUtils.isBlank(pids) ? new String[0] : pids.split(Global.COMMA);
|
|
|
+ String[] idArrays = StringUtils.isBlank(pids) ? new String[0] : pids.split(Global.COMMA);
|
|
|
return idArrays.length <= 1 ? Global.NUMERICAL_ONE : (idArrays.length - Global.NUMERICAL_ONE);
|
|
|
}
|
|
|
|
|
|
@@ -805,7 +808,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/24
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult cancelSendCar(List<Long> ids){
|
|
|
+ public HttpResult cancelSendCar(List<Long> ids) {
|
|
|
/**1数据校验**/
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
return HttpResult.error("请选择需要撤回的车辆运单!");
|
|
|
@@ -817,7 +820,7 @@ public class KwtWaybillOrderService {
|
|
|
if (order != null) {
|
|
|
//3待接单的车辆运单才能撤回
|
|
|
if (order.getStatus() != CarWaybillEnum.PENDING_ORDER.getCode()) {
|
|
|
- return HttpResult.error("运单"+order.getWOrderNo()+"当前状态已不能撤回!");
|
|
|
+ return HttpResult.error("运单" + order.getWOrderNo() + "当前状态已不能撤回!");
|
|
|
}
|
|
|
} else {
|
|
|
//循环派车信息
|
|
|
@@ -873,13 +876,13 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param wOrder mongodb中车辆运单信息
|
|
|
- * @param order 车辆运单信息
|
|
|
+ * @param order 车辆运单信息
|
|
|
* @param method 操作对象(1新增/2修改/3替换数据)
|
|
|
* @description 更新mongodb中车辆运单信息
|
|
|
* @author zk
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
- public void editSckwWaybillOrder(SckwWaybillOrder wOrder, KwtWaybillOrder order, int method){
|
|
|
+ public void editSckwWaybillOrder(SckwWaybillOrder wOrder, KwtWaybillOrder order, int method) {
|
|
|
wOrder.setWOrderId(order.getId());
|
|
|
wOrder.setStatus(order.getStatus());
|
|
|
wOrder.setUpdateTime(order.getUpdateTime());
|
|
|
@@ -897,12 +900,12 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param lOrder mongodb中承运订单信息
|
|
|
- * @param order 承运订单
|
|
|
+ * @param order 承运订单
|
|
|
* @description 更新mongodb中承运订单信息
|
|
|
* @author zk
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
- public void editSckwLogisticsOrder(SckwLogisticsOrder lOrder, KwtLogisticsOrder order){
|
|
|
+ public void editSckwLogisticsOrder(SckwLogisticsOrder lOrder, KwtLogisticsOrder order) {
|
|
|
lOrder.set_id(order.getId());
|
|
|
lOrder.setLOrderId(order.getId());
|
|
|
lOrder.setEntrustAmount(order.getEntrustAmount());
|
|
|
@@ -1038,7 +1041,7 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param circulate 循环派车记录
|
|
|
- * @param wOrderId 车辆订单ID
|
|
|
+ * @param wOrderId 车辆订单ID
|
|
|
* @desc 新增循环派车接单后车辆运单待接单记录
|
|
|
* @author zk
|
|
|
* @date 2023/7/26
|
|
|
@@ -1141,7 +1144,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult confirmDeparture(OperateWaybillDto params){
|
|
|
+ public HttpResult confirmDeparture(OperateWaybillDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1177,7 +1180,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult refuseDeparture(OperateWaybillDto params){
|
|
|
+ public HttpResult refuseDeparture(OperateWaybillDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1233,7 +1236,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult arriveLoadLocation(OperateWaybillDto params){
|
|
|
+ public HttpResult arriveLoadLocation(OperateWaybillDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1269,7 +1272,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult loading(WaybillOrderTicketDto params){
|
|
|
+ public HttpResult loading(WaybillOrderTicketDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1298,18 +1301,18 @@ public class KwtWaybillOrderService {
|
|
|
waybillOrderTicketDao.insert(ticket);
|
|
|
|
|
|
/**5跟新司机/车辆数据
|
|
|
- //更新司机信息
|
|
|
- editDriver(waybillOrder.getDriverId());
|
|
|
- //更新车辆信息
|
|
|
- editTruck(waybillOrder.getTruckId());**/
|
|
|
+ //更新司机信息
|
|
|
+ editDriver(waybillOrder.getDriverId());
|
|
|
+ //更新车辆信息
|
|
|
+ editTruck(waybillOrder.getTruckId());**/
|
|
|
|
|
|
/**6更新承运订单entrustAmount
|
|
|
- KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(waybillOrder.getLOrderId());
|
|
|
- //承运订单已装货量=承运订单原装货量+当前车辆运单装货量
|
|
|
- BigDecimal loadAmount = logisticsOrder.getLoadAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getLoadAmount();
|
|
|
- logisticsOrder.setLoadAmount(loadAmount.add(waybillOrder.getLoadAmount()));
|
|
|
- logisticsOrder.setLoadTime(logisticsOrder.getLoadTime() == null ?waybillOrder.getUpdateTime() : logisticsOrder.getLoadTime());
|
|
|
- logisticsOrderDao.updateById(logisticsOrder);**/
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(waybillOrder.getLOrderId());
|
|
|
+ //承运订单已装货量=承运订单原装货量+当前车辆运单装货量
|
|
|
+ BigDecimal loadAmount = logisticsOrder.getLoadAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getLoadAmount();
|
|
|
+ logisticsOrder.setLoadAmount(loadAmount.add(waybillOrder.getLoadAmount()));
|
|
|
+ logisticsOrder.setLoadTime(logisticsOrder.getLoadTime() == null ?waybillOrder.getUpdateTime() : logisticsOrder.getLoadTime());
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);**/
|
|
|
|
|
|
/**7Mongodb数据更新**/
|
|
|
//1车辆运单
|
|
|
@@ -1338,7 +1341,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult arriveUnloadLocation(OperateWaybillDto params){
|
|
|
+ public HttpResult arriveUnloadLocation(OperateWaybillDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1374,7 +1377,7 @@ public class KwtWaybillOrderService {
|
|
|
* @date 2023/7/26
|
|
|
**/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult unloading(WaybillOrderTicketDto params){
|
|
|
+ public HttpResult unloading(WaybillOrderTicketDto params) {
|
|
|
/**1数据校验**/
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(params.getWOrderId());
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1417,24 +1420,24 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**6跟新司机/车辆数据
|
|
|
- //更新司机信息
|
|
|
- editDriver(waybillOrder.getDriverId());
|
|
|
- //更新车辆信息
|
|
|
- editTruck(waybillOrder.getTruckId());**/
|
|
|
+ //更新司机信息
|
|
|
+ editDriver(waybillOrder.getDriverId());
|
|
|
+ //更新车辆信息
|
|
|
+ editTruck(waybillOrder.getTruckId());**/
|
|
|
|
|
|
/**7更新承运订单entrustAmount
|
|
|
- //更新卸货量/卸货时间/亏吨/亏吨扣款
|
|
|
- //承运订单卸货量=承运订单原卸货量+当前车辆运单卸货量
|
|
|
- BigDecimal unloadAmount = logisticsOrder.getUnloadAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getUnloadAmount();
|
|
|
- logisticsOrder.setUnloadAmount(unloadAmount.add(waybillOrder.getUnloadAmount()));
|
|
|
- logisticsOrder.setUnloadTime(waybillOrder.getUpdateTime());
|
|
|
- //承运订单亏吨量=承运订单装货量-承运订单卸货量
|
|
|
- logisticsOrder.setDeficitAmount(logisticsOrder.getLoadAmount().subtract(logisticsOrder.getUnloadAmount()));
|
|
|
- //承运订单亏吨扣款
|
|
|
- deficitPrice = deficitPrice(logisticsOrder.getLoadAmount(), logisticsOrder.getDeficitAmount(),
|
|
|
- logisticsOrder.getLoss(), logisticsOrder.getGoodsPrice());
|
|
|
- logisticsOrder.setDeficitPrice(deficitPrice);
|
|
|
- logisticsOrderDao.updateById(logisticsOrder);**/
|
|
|
+ //更新卸货量/卸货时间/亏吨/亏吨扣款
|
|
|
+ //承运订单卸货量=承运订单原卸货量+当前车辆运单卸货量
|
|
|
+ BigDecimal unloadAmount = logisticsOrder.getUnloadAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getUnloadAmount();
|
|
|
+ logisticsOrder.setUnloadAmount(unloadAmount.add(waybillOrder.getUnloadAmount()));
|
|
|
+ logisticsOrder.setUnloadTime(waybillOrder.getUpdateTime());
|
|
|
+ //承运订单亏吨量=承运订单装货量-承运订单卸货量
|
|
|
+ logisticsOrder.setDeficitAmount(logisticsOrder.getLoadAmount().subtract(logisticsOrder.getUnloadAmount()));
|
|
|
+ //承运订单亏吨扣款
|
|
|
+ deficitPrice = deficitPrice(logisticsOrder.getLoadAmount(), logisticsOrder.getDeficitAmount(),
|
|
|
+ logisticsOrder.getLoss(), logisticsOrder.getGoodsPrice());
|
|
|
+ logisticsOrder.setDeficitPrice(deficitPrice);
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);**/
|
|
|
|
|
|
/**8Mongodb数据更新**/
|
|
|
//1车辆运单
|
|
|
@@ -1461,10 +1464,10 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param loadAmount 装货量
|
|
|
+ * @param loadAmount 装货量
|
|
|
* @param deficitAmount 亏吨量
|
|
|
- * @param loss 合理损耗
|
|
|
- * @param goodsPrice 货值单价
|
|
|
+ * @param loss 合理损耗
|
|
|
+ * @param goodsPrice 货值单价
|
|
|
* @desc 计算亏吨扣款
|
|
|
* @author zk
|
|
|
* @date 2023/7/27
|
|
|
@@ -1484,7 +1487,7 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**
|
|
|
* @param lOrderId 承运订单ID
|
|
|
- * @description 校验当前承运订单是否运输完成(修改状态+统计量)
|
|
|
+ * @description 校验当前承运订单是否运输完成(修改状态 + 统计量)
|
|
|
* @author zk
|
|
|
* @date 2023/7/27
|
|
|
**/
|
|
|
@@ -1502,7 +1505,10 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**1-2校验当前承运订单是否运输完成**/
|
|
|
//车辆运单统计
|
|
|
- WaybillCountVo waybillCount = waybillOrderDao.findWaybillOrderCount( new HashMap(){{put("upperlOrderId", logisticsOrder.getId()); put("passStatus", 1); }});
|
|
|
+ WaybillCountVo waybillCount = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
|
|
|
+ put("upperlOrderId", logisticsOrder.getId());
|
|
|
+ put("passStatus", 1);
|
|
|
+ }});
|
|
|
logisticsOrder.setTotalLoadAmount(waybillCount.getLoadAmount());
|
|
|
logisticsOrder.setTotalUnloadAmount(waybillCount.getUnloadAmount());
|
|
|
BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
|
|
|
@@ -1525,7 +1531,7 @@ public class KwtWaybillOrderService {
|
|
|
/**1-5循环派车失效kwt_logistics_order_circulate**/
|
|
|
//循环派车信息
|
|
|
List<KwtLogisticsOrderCirculate> circulates = logisticsOrderCirculateDao.findCirculateList(logisticsOrder.getId(), null, null, 0);
|
|
|
- for (KwtLogisticsOrderCirculate circulate:circulates) {
|
|
|
+ for (KwtLogisticsOrderCirculate circulate : circulates) {
|
|
|
circulate.setStatus(Global.NUMERICAL_ONE);
|
|
|
logisticsOrderCirculateDao.updateById(circulate);
|
|
|
|
|
|
@@ -1543,9 +1549,14 @@ public class KwtWaybillOrderService {
|
|
|
/**1-6更新贸易订单总量**/
|
|
|
if (logisticsLevel(logisticsOrder) == Global.NUMERICAL_ONE) {
|
|
|
//查询贸易订单总装货量/总卸货量
|
|
|
- WaybillCountVo tradeCount = waybillOrderDao.findWaybillOrderCount( new HashMap(){{put("tOrderId", logisticsOrder.getTOrderId()); put("passStatus", 1); }});
|
|
|
+ WaybillCountVo tradeCount = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
|
|
|
+ put("tOrderId", logisticsOrder.getTOrderId());
|
|
|
+ put("passStatus", 1);
|
|
|
+ }});
|
|
|
//查询贸易订单关联物流运单是否全部完结-totalUnfinished
|
|
|
- WaybillCountVo tradeCount1 = waybillOrderDao.findWaybillOrderCount( new HashMap(){{put("tOrderId", logisticsOrder.getTOrderId()); }});
|
|
|
+ WaybillCountVo tradeCount1 = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
|
|
|
+ put("tOrderId", logisticsOrder.getTOrderId());
|
|
|
+ }});
|
|
|
CompleteLogisticsOrderParam tradeOrder = new CompleteLogisticsOrderParam();
|
|
|
tradeOrder.setTOrderId(logisticsOrder.getTOrderId());
|
|
|
tradeOrder.setActualLoadAmount(tradeCount.getLoadAmount());
|
|
|
@@ -1567,7 +1578,7 @@ public class KwtWaybillOrderService {
|
|
|
//获取所有上级物流订单ID(当前物流订单ID除外)
|
|
|
String pids = logisticsOrder.getPids();
|
|
|
if (StringUtils.isNotBlank(pids)) {
|
|
|
- String [] idArray = pids.split(Global.COMMA);
|
|
|
+ String[] idArray = pids.split(Global.COMMA);
|
|
|
for (String id : idArray) {
|
|
|
Long pid = Long.parseLong(id);
|
|
|
//当前物流订单ID除外
|
|
|
@@ -1591,8 +1602,11 @@ public class KwtWaybillOrderService {
|
|
|
if (subcontractAmount.compareTo(new BigDecimal(Global.AMOUNT)) > 0) {
|
|
|
/**1-1校验下级分包是否全部运输完成**/
|
|
|
List<KwtLogisticsOrder> logisticsOrders = logisticsOrderDao.findLogisticsOrder(
|
|
|
- new HashMap(){{put("upperlOrderId", logisticsOrder.getId()); put("ownOrderId", logisticsOrder.getId());}});
|
|
|
- for (KwtLogisticsOrder logisticsOrder1:logisticsOrders) {
|
|
|
+ new HashMap() {{
|
|
|
+ put("upperlOrderId", logisticsOrder.getId());
|
|
|
+ put("ownOrderId", logisticsOrder.getId());
|
|
|
+ }});
|
|
|
+ for (KwtLogisticsOrder logisticsOrder1 : logisticsOrders) {
|
|
|
if (!LogisticsOrderEnum.transportCompleted(logisticsOrder1.getStatus())) {
|
|
|
//下级分包承运订单运输未完成
|
|
|
subcontractBool = false;
|
|
|
@@ -1673,7 +1687,7 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/8/10
|
|
|
**/
|
|
|
- public HttpResult ticketWaybillOrder(Long wOrderId){
|
|
|
+ public HttpResult ticketWaybillOrder(Long wOrderId) {
|
|
|
//车辆运单信息
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderDao.selectById(wOrderId);
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -1690,7 +1704,10 @@ public class KwtWaybillOrderService {
|
|
|
//商品信息
|
|
|
KwtLogisticsOrderGoods goods = logisticsOrderGoodsDao.findByGoods(waybillOrder.getLOrderId());
|
|
|
//用户数据集
|
|
|
- List<Long> createBys = new ArrayList(){{add(loadTicket.getUpdateBy()); add(unloadTicket.getUpdateBy());}};
|
|
|
+ List<Long> createBys = new ArrayList() {{
|
|
|
+ add(loadTicket.getUpdateBy());
|
|
|
+ add(unloadTicket.getUpdateBy());
|
|
|
+ }};
|
|
|
createBys = createBys.stream().distinct().collect(Collectors.toList());
|
|
|
Map<Long, UserCacheResDto> users = remoteSystemService.queryUserCacheMapByIds(createBys);
|
|
|
UserCacheResDto loadUser = users == null ? null : users.get(loadTicket.getUpdateBy());
|
|
|
@@ -1814,13 +1831,15 @@ public class KwtWaybillOrderService {
|
|
|
**/
|
|
|
public void editDriver(Long driverId) {
|
|
|
//数据统计
|
|
|
- WaybillCountVo countVo = waybillOrderDao.findWaybillOrderCount(new HashMap(){{put("driverId", driverId);}});
|
|
|
+ WaybillCountVo countVo = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
|
|
|
+ put("driverId", driverId);
|
|
|
+ }});
|
|
|
RDriverVo driver = new RDriverVo();
|
|
|
driver.setId(driverId);
|
|
|
driver.setTotalComplete(countVo.getTotalComplete());
|
|
|
driver.setTotalTake(countVo.getTotalTake());
|
|
|
driver.setTotalWeight(countVo.getLoadAmount());
|
|
|
- driver.setBusinessStatus(countVo.getTotalExecute() != null && countVo.getTotalExecute() > 0 ? 1 : 0 );
|
|
|
+ driver.setBusinessStatus(countVo.getTotalExecute() != null && countVo.getTotalExecute() > 0 ? 1 : 0);
|
|
|
remoteFleetService.updateById(driver);
|
|
|
}
|
|
|
|
|
|
@@ -1832,13 +1851,15 @@ public class KwtWaybillOrderService {
|
|
|
**/
|
|
|
public void editTruck(Long truckId) {
|
|
|
//数据统计
|
|
|
- WaybillCountVo countVo = waybillOrderDao.findWaybillOrderCount(new HashMap(){{put("truckId", truckId);}});
|
|
|
+ WaybillCountVo countVo = waybillOrderDao.findWaybillOrderCount(new HashMap() {{
|
|
|
+ put("truckId", truckId);
|
|
|
+ }});
|
|
|
RTruckVo truck = new RTruckVo();
|
|
|
truck.setId(truckId);
|
|
|
truck.setTotalComplete(countVo.getTotalComplete());
|
|
|
truck.setTotalTake(countVo.getTotalTake());
|
|
|
truck.setTotalWeight(countVo.getLoadAmount());
|
|
|
- truck.setBusinessStatus(countVo.getTotalExecute() != null && countVo.getTotalExecute() > 0 ? 1 : 0 );
|
|
|
+ truck.setBusinessStatus(countVo.getTotalExecute() != null && countVo.getTotalExecute() > 0 ? 1 : 0);
|
|
|
remoteFleetService.updateById(truck);
|
|
|
}
|
|
|
|
|
|
@@ -1853,14 +1874,14 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
|
|
|
/** 当前物流订单是全量下游则只能全量可运、否则可委托量或全量
|
|
|
- 校验上游是否全量,并获取全量跟节点物流订单或贸易订单(可委派量)
|
|
|
+ 校验上游是否全量,并获取全量跟节点物流订单或贸易订单(可委派量)
|
|
|
1、派车、循环派车接单需校验贸易订单/物流订单是否委派完成;
|
|
|
2、装货需要统计物流订单总装货量;
|
|
|
3、卸货需要统计物流订单总卸货量,变更上游状态;
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * @param lOrderId 物流订单信息ID
|
|
|
+ * @param lOrderId 物流订单信息ID
|
|
|
* @param entrustAmount 委托量
|
|
|
* @desc 校验委托量是否大于剩余可运量(趟次派车/循环运单接单、委托/全量可运)
|
|
|
* @author zk
|
|
|
@@ -1872,7 +1893,7 @@ public class KwtWaybillOrderService {
|
|
|
/**存在全量可运**/
|
|
|
if (isComplete(logisticsOrder)) {
|
|
|
//获取所有上级物流订单ID(当前物流订单ID除外)
|
|
|
- List<Long> idArray = (List)CollectionUtils.toList(logisticsOrder.getPids(), false);
|
|
|
+ List<Long> idArray = (List) CollectionUtils.toList(logisticsOrder.getPids(), false);
|
|
|
for (Long id : idArray) {
|
|
|
//当前物流订单ID除外
|
|
|
if (id != lOrderId) {
|
|
|
@@ -1925,4 +1946,103 @@ public class KwtWaybillOrderService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运订单-托运订单-订单详情数据统计
|
|
|
+ * @param orderId
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Integer> statisticsByOrderId(String orderId, String type) {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(type)) {
|
|
|
+ map = statisticsConsignByOrderId(orderId);
|
|
|
+ } else if (String.valueOf(NumberConstant.TWO).equals(type)) {
|
|
|
+ map = statisticsCarriageByOrderId(orderId);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("统计类型异常");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运数据统计
|
|
|
+ * @param orderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Integer> statisticsCarriageByOrderId(String orderId) {
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ /**
|
|
|
+ * 【进行】:对应【待接单】、【待出车】、【已出车】、【到达装货地点】、【已装货】、【到达卸货地点】
|
|
|
+ * 【完成】:对应【已卸货】、【已核单】
|
|
|
+ * 【退回】:对应【拒绝接单】、【拒绝出车】、【单趟撤回】
|
|
|
+ * */
|
|
|
+ List<Integer> orderStatusList = new ArrayList<>();
|
|
|
+ orderStatusList.add(CarWaybillEnum.PENDING_ORDER.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
|
|
|
+ Integer proceed = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("proceed", proceed);
|
|
|
+
|
|
|
+ orderStatusList.clear();
|
|
|
+ orderStatusList.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.APPROVAL_PASS.getCode());
|
|
|
+ Integer finish = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("finish", finish);
|
|
|
+
|
|
|
+ orderStatusList.clear();
|
|
|
+ orderStatusList.add(CarWaybillEnum.REJECT_ORDER.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.REVOKED.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
|
|
|
+ Integer cancel = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("cancel", cancel);
|
|
|
+
|
|
|
+ map.put("total", proceed + finish + cancel);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 托运数据统计
|
|
|
+ * @param orderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Integer> statisticsConsignByOrderId(String orderId) {
|
|
|
+
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ /**
|
|
|
+ * 【进行】:对应【待接单】、【待出车】、【已出车】、【到达装货地点】、【已装货】、【到达卸货地点】
|
|
|
+ * 【完成】:对应【已卸货】、【已核单】
|
|
|
+ * 【退回】:对应【拒绝接单】、【拒绝出车】、【单趟撤回】
|
|
|
+ * */
|
|
|
+ List<Integer> orderStatusList = new ArrayList<>();
|
|
|
+ orderStatusList.add(CarWaybillEnum.PENDING_ORDER.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
|
|
|
+ Integer proceed = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("proceed", proceed);
|
|
|
+
|
|
|
+ orderStatusList.clear();
|
|
|
+ orderStatusList.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.APPROVAL_PASS.getCode());
|
|
|
+ Integer finish = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("finish", finish);
|
|
|
+
|
|
|
+ orderStatusList.clear();
|
|
|
+ orderStatusList.add(CarWaybillEnum.REJECT_ORDER.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.REFUSE_TRAFFIC.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.REVOKED.getCode());
|
|
|
+ orderStatusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode());
|
|
|
+ Integer cancel = logisticsOrderDao.selectCountByLorderId(orderId, orderStatusList);
|
|
|
+ map.put("cancel", cancel);
|
|
|
+
|
|
|
+ map.put("total", proceed + finish + cancel);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|