|
|
@@ -0,0 +1,516 @@
|
|
|
+package com.sckw.transport.service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.constant.NumberConstant;
|
|
|
+import com.sckw.core.model.enums.*;
|
|
|
+import com.sckw.core.model.page.PageResult;
|
|
|
+import com.sckw.core.utils.*;
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.core.web.response.HttpResult;
|
|
|
+import com.sckw.excel.utils.DateUtil;
|
|
|
+import com.sckw.fleet.api.RemoteFleetService;
|
|
|
+import com.sckw.fleet.api.model.vo.RDriverVo;
|
|
|
+import com.sckw.fleet.api.model.vo.RTruckVo;
|
|
|
+import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
|
+import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
|
+import com.sckw.mongo.model.SckwWaybillOrder;
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
+import com.sckw.redis.constant.RedisConstant;
|
|
|
+import com.sckw.redis.utils.RedissonUtils;
|
|
|
+import com.sckw.stream.enums.MessageEnum;
|
|
|
+import com.sckw.stream.model.SckwBusSum;
|
|
|
+import com.sckw.stream.model.SckwMessage;
|
|
|
+import com.sckw.stream.model.UserInfo;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
+import com.sckw.transport.dao.*;
|
|
|
+import com.sckw.transport.model.*;
|
|
|
+import com.sckw.transport.model.dto.*;
|
|
|
+import com.sckw.transport.model.vo.*;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import jakarta.validation.Valid;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
+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.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zk
|
|
|
+ * @desc 车辆运单
|
|
|
+ * @date 2023/7/19 0019
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class KwtWaybillOrderV1Service {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderMapper waybillOrderDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderV1Mapper waybillOrderV1Dao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderMapper logisticsOrderDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderTrackMapper logisticsOrderTrackDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderAddressMapper logisticsOrderAddressDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderAddressMapper waybillOrderAddressDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderTrackMapper waybillOrderTrackDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderTicketMapper waybillOrderTicketDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderSubtaskMapper waybillOrderSubtaskDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderUnitMapper logisticsOrderUnitDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderGoodsMapper logisticsOrderGoodsDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderCirculateMapper logisticsOrderCirculateDao;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderAmountMapper logisticsOrderAmountDao;
|
|
|
+ @Autowired
|
|
|
+ KwtWaybillOrderTicketService waybillOrderTicketService;
|
|
|
+ @Autowired
|
|
|
+ KwtLogisticsOrderGoodsService kwtLogisticsOrderGoodsService;
|
|
|
+ @Autowired
|
|
|
+ KwtCommonService commonService;
|
|
|
+ @Resource
|
|
|
+ private StreamBridge streamBridge;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteFleetService remoteFleetService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private TradeOrderInfoService tradeOrderInfoService;
|
|
|
+ @Value("${message.waybill.refuseSendCar.app}")
|
|
|
+ private String refuseSendCarAppUrl;
|
|
|
+ @Value("${message.waybill.refuseSendCar.pc}")
|
|
|
+ private String refuseSendCarPcUrl;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params 派车参数
|
|
|
+ * @desc 派车-多装多卸
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/19
|
|
|
+ **/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult sendCarV1(SendCarDto2 params) {
|
|
|
+ /*1、校验*/
|
|
|
+ HttpResult result = checkWaybillOrderV1(params);
|
|
|
+ if (result.getCode() != HttpStatus.SUCCESS_CODE) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*2、新增运单相关信息*/
|
|
|
+ List<SendCarEntrustDto> sendCarEntrustAll = ranksSave(params);
|
|
|
+
|
|
|
+ /*3、更新承运订单委派信息*/
|
|
|
+ List<Long> lOrderIds = editLogisticsOrder(sendCarEntrustAll, params.getType());
|
|
|
+
|
|
|
+ /*4、更新承运订单状态(包括上级承运订单)*/
|
|
|
+ editLogisticsOrderStatus(lOrderIds);
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params 派车请求参数
|
|
|
+ * @desc 派车校验
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/4
|
|
|
+ **/
|
|
|
+ public HttpResult checkWaybillOrderV1(SendCarDto2 params) {
|
|
|
+ /*控制校验*/
|
|
|
+ if (CollectionUtils.isEmpty(params.getSends())) {
|
|
|
+ return HttpResult.error("请选择委派信息!");
|
|
|
+ } else {
|
|
|
+ for (SendCarInfoDto sendCar:params.getSends()) {
|
|
|
+ if (CollectionUtils.isEmpty(sendCar.getEntrusts())) {
|
|
|
+ return HttpResult.error("请选择委派信息!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //车辆司机信息
|
|
|
+ List<SendCarInfoDto> sends = params.getSends();
|
|
|
+ //物流订单ID
|
|
|
+ List<Long> lOrderIds = new ArrayList<>();
|
|
|
+ //物流订单装卸货地址委派量统计
|
|
|
+ Map<Long, BigDecimal> truckTotalEntrustAmount = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ for (SendCarInfoDto sendCar:sends) {
|
|
|
+ //运输委托信息
|
|
|
+ List<SendCarEntrustDto> entrusts = sendCar.getEntrusts();
|
|
|
+ /*数据组装*/
|
|
|
+ for (SendCarEntrustDto e : entrusts) {
|
|
|
+ lOrderIds.add(e.getLOrderId());
|
|
|
+ //承运订单该车辆计划运输总量:核定载量 * 趟次
|
|
|
+ BigDecimal entrustAmount = BigDecimal.valueOf(e.getEntrustAmount() * sendCar.getCount());
|
|
|
+ BigDecimal totalEntrustAmount = truckTotalEntrustAmount.get(e.getAddressId()) != null
|
|
|
+ ? truckTotalEntrustAmount.get(e.getAddressId()) : NumberConstant.ZERO_TWO;
|
|
|
+ truckTotalEntrustAmount.put(e.getAddressId(), totalEntrustAmount.add(entrustAmount));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Long> lOrderIdsList = lOrderIds.stream().distinct().toList();
|
|
|
+
|
|
|
+ /*校验物流运单是否可以派车*/
|
|
|
+ for (Long lOrderId:lOrderIdsList) {
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ return HttpResult.error("订单"+lOrderId+"已不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态校验
|
|
|
+ if (!logisticsOrder.getStatus().equals(LogisticsOrderEnum.WAIT_DELIVERY.getCode())
|
|
|
+ && !logisticsOrder.getStatus().equals(LogisticsOrderEnum.IN_TRANSIT.getCode())) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + LogisticsOrderEnum.getName(logisticsOrder.getStatus()) + "不能派车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //剩余可运量校验
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getEntrustAmount();
|
|
|
+ BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getSubcontractAmount();
|
|
|
+ //历史下游司机委派量 + 分包量
|
|
|
+ BigDecimal entrustAmountTotal = entrustAmount.add(subcontractAmount);
|
|
|
+ if (entrustAmountTotal.compareTo(logisticsOrder.getAmount()) > 0) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "剩余可运量已不能派车!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*校验是车辆委托量否超过物流订单剩余量-趟次*/
|
|
|
+ //物流订单地址委托量信息-装货信息
|
|
|
+ KwtLogisticsOrderAddress queryAmount = new KwtLogisticsOrderAddress();
|
|
|
+ queryAmount.setLOrderId(lOrderId);
|
|
|
+ queryAmount.setAddressType(AddressDefaultTypeEnum.SHIPMENT.getCode());
|
|
|
+ List<KwtLogisticsOrderAmount> logisticsOrderAmounts = logisticsOrderAmountDao.findByAddress(queryAmount);
|
|
|
+ for (KwtLogisticsOrderAmount orderAmount:logisticsOrderAmounts) {
|
|
|
+ BigDecimal truckEntrustAmount = truckTotalEntrustAmount.get(orderAmount.getLAddressId());
|
|
|
+ //当前下游司机委派量 + 历史下游司机委派量 + 分包量
|
|
|
+ BigDecimal actualAmount = truckEntrustAmount.add(entrustAmountTotal);
|
|
|
+ if (actualAmount.doubleValue() > orderAmount.getAmount().doubleValue()) {
|
|
|
+ return HttpResult.error("订单" + logisticsOrder.getLOrderNo() + "累计派车量已大于剩余可运量!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return HttpResult.ok(truckTotalEntrustAmount);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params 派车请求参数
|
|
|
+ * @desc 新增运单相关信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/5
|
|
|
+ **/
|
|
|
+ public List<SendCarEntrustDto> ranksSave(SendCarDto2 params) {
|
|
|
+ //车辆司机信息
|
|
|
+ List<SendCarInfoDto> sends = params.getSends();
|
|
|
+ //物流订单对应地址信息(所有)
|
|
|
+ List<SendCarEntrustDto> sendCarEntrustAll = new ArrayList<>();
|
|
|
+ for (SendCarInfoDto sendCar:sends) {
|
|
|
+ //趟次(循环单默认趟次为1)
|
|
|
+ int count = params.getType() == Global.NUMERICAL_ONE ? sendCar.getCount() : Global.NUMERICAL_ONE;
|
|
|
+ for (int i=0; i<count; i++) {
|
|
|
+ //新增运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = sendCarDriver(sendCar, params.getType());
|
|
|
+ //运输委托信息
|
|
|
+ List<SendCarEntrustDto> entrusts = sendCar.getEntrusts();
|
|
|
+ //物流订单对应地址信息
|
|
|
+ Map<Long, List<SendCarEntrustDto>> sendCarEntrusts = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ //数据组装-物流订单归类(合并派车)
|
|
|
+ for (SendCarEntrustDto sendCarEntrust:entrusts) {
|
|
|
+ //物流订单ID
|
|
|
+ Long lOrderId = sendCarEntrust.getLOrderId();
|
|
|
+ //委派信息
|
|
|
+ List<SendCarEntrustDto> entrustDtos = new ArrayList<>(){{add(sendCarEntrust);}};
|
|
|
+ if (sendCarEntrusts.get(lOrderId) == null) {
|
|
|
+ sendCarEntrusts.put(lOrderId, entrustDtos);
|
|
|
+ } else {
|
|
|
+ entrustDtos.addAll(sendCarEntrusts.get(lOrderId));
|
|
|
+ sendCarEntrusts.put(lOrderId, entrustDtos);
|
|
|
+ }
|
|
|
+ sendCarEntrustAll.add(sendCarEntrust);
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据存储
|
|
|
+ for (Long lOrderId:sendCarEntrusts.keySet()) {
|
|
|
+ //物流订单关联委派地址信息
|
|
|
+ List<SendCarEntrustDto> sendCars = sendCarEntrusts.get(lOrderId);
|
|
|
+ //物流订单委派量统计
|
|
|
+ BigDecimal entrustAmount = NumberConstant.ZERO_TWO;
|
|
|
+ //物流订单委派装货时间
|
|
|
+ List<Date> loadTime = new ArrayList<>();
|
|
|
+ //物流订单委派卸货时间
|
|
|
+ List<Date> unloadTime = new ArrayList<>();
|
|
|
+ //数据组装-数据统计
|
|
|
+ for (SendCarEntrustDto sendCarEntrust:sendCars) {
|
|
|
+ //委派量
|
|
|
+ BigDecimal amount = BigDecimal.valueOf(sendCarEntrust.getEntrustAmount());
|
|
|
+ //计划装卸货时间
|
|
|
+ Date planTime = sendCarEntrust.getPlanTime();
|
|
|
+ //装货+卸货
|
|
|
+ if (sendCarEntrust.getAddressType() == AddressDefaultTypeEnum.SHIPMENT.getCode()) {
|
|
|
+ entrustAmount = entrustAmount.add(amount);
|
|
|
+ loadTime.add(planTime);
|
|
|
+ } else {
|
|
|
+ unloadTime.add(planTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增运单子单信息
|
|
|
+ KwtWaybillOrderSubtask subtasks = sendCarSubtask(waybillOrder, lOrderId, entrustAmount, loadTime, unloadTime);
|
|
|
+ for (SendCarEntrustDto sendCarEntrust:sendCars) {
|
|
|
+ //新增地址信息
|
|
|
+ sendCarAddress(subtasks.getId(), sendCarEntrust, waybillOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*车辆运单状态记录*/
|
|
|
+ this.setWaybillOrderTrack(waybillOrder.getId(), waybillOrder.getUpdateTime(), waybillOrder.getStatus(), null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sendCarEntrustAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param sendCarEntrusts 委派参数
|
|
|
+ * @desc 更新承运订单委派信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/5
|
|
|
+ **/
|
|
|
+ public List<Long> editLogisticsOrder(List<SendCarEntrustDto> sendCarEntrusts, int type) {
|
|
|
+ //物流订单ID
|
|
|
+ List<Long> lOrderIds = new ArrayList<>();
|
|
|
+ //物流订单对应委派量(所有)
|
|
|
+ Map<Long, BigDecimal> lEntrustAmount = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ //物流订单地址对应委派量(所有)
|
|
|
+ Map<Long, BigDecimal> aEntrustAmount = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ //数据组装-数据统计
|
|
|
+ for (SendCarEntrustDto sendCarEntrust:sendCarEntrusts) {
|
|
|
+ //委派量
|
|
|
+ BigDecimal amount = BigDecimal.valueOf(sendCarEntrust.getEntrustAmount());
|
|
|
+ //装货+卸货
|
|
|
+ if (sendCarEntrust.getAddressType() == AddressDefaultTypeEnum.SHIPMENT.getCode()) {
|
|
|
+ if (lEntrustAmount.get(sendCarEntrust.getLOrderId()) == null) {
|
|
|
+ lEntrustAmount.put(sendCarEntrust.getLOrderId(), amount);
|
|
|
+ } else {
|
|
|
+ BigDecimal entrustAmount = lEntrustAmount.get(sendCarEntrust.getLOrderId()).add(amount);
|
|
|
+ lEntrustAmount.put(sendCarEntrust.getLOrderId(), entrustAmount);
|
|
|
+ }
|
|
|
+ if (aEntrustAmount.get(sendCarEntrust.getAddressId()) == null) {
|
|
|
+ aEntrustAmount.put(sendCarEntrust.getAddressId(), amount);
|
|
|
+ } else {
|
|
|
+ BigDecimal entrustAmount = aEntrustAmount.get(sendCarEntrust.getAddressId()).add(amount);
|
|
|
+ aEntrustAmount.put(sendCarEntrust.getAddressId(), entrustAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lOrderIds.add(sendCarEntrust.getLOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //循环单不更新物流订单委派量
|
|
|
+ if (type == Global.NUMERICAL_TWO) {
|
|
|
+ return lOrderIds.stream().distinct().toList();
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新承运订单运量kwt_logistics_order_amount委派量
|
|
|
+ for (Long lOrderId:lEntrustAmount.keySet()) {
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrder.getEntrustAmount();
|
|
|
+ logisticsOrder.setEntrustAmount(entrustAmount.add(lEntrustAmount.get(lOrderId)));
|
|
|
+ logisticsOrderDao.updateById(logisticsOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新承运订单kwt_logistics_order委派量
|
|
|
+ for (Long lAddressId:aEntrustAmount.keySet()) {
|
|
|
+ KwtLogisticsOrderAmount logisticsOrderAmount = logisticsOrderAmountDao.findByAddressId(lAddressId);
|
|
|
+ BigDecimal entrustAmount = logisticsOrderAmount.getEntrustAmount() == null ? new BigDecimal(Global.AMOUNT) : logisticsOrderAmount.getEntrustAmount();
|
|
|
+ logisticsOrderAmount.setEntrustAmount(entrustAmount.add(aEntrustAmount.get(lAddressId)));
|
|
|
+ logisticsOrderAmountDao.updateById(logisticsOrderAmount);
|
|
|
+ }
|
|
|
+ return lOrderIds.stream().distinct().toList();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param lOrderIds 物流订单集
|
|
|
+ * @desc 更新承运订单状态信息(包括分包上级物流订单)
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/5
|
|
|
+ **/
|
|
|
+ public void editLogisticsOrderStatus(List<Long> lOrderIds) {
|
|
|
+ for (Long lOrderId:lOrderIds) {
|
|
|
+ //物流订单信息
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
+ //当前承运订单所属分包层级
|
|
|
+ String pids = logisticsOrder.getPids();
|
|
|
+ if (StringUtils.isNotBlank(pids)) {
|
|
|
+ String[] idArray = pids.split(Global.COMMA);
|
|
|
+ for (String id : idArray) {
|
|
|
+ KwtLogisticsOrder order = logisticsOrderDao.selectById(id);
|
|
|
+ //承运订单-待派车
|
|
|
+ if (order.getStatus().equals(LogisticsOrderEnum.WAIT_DELIVERY.getCode())) {
|
|
|
+ //更新当前承运订单状态(待派车->运输中)
|
|
|
+ order.setStatus(LogisticsOrderEnum.IN_TRANSIT.getCode());
|
|
|
+ logisticsOrderDao.updateById(order);
|
|
|
+
|
|
|
+ //承运订单状态记录
|
|
|
+ KwtLogisticsOrderTrack orderTrack = new KwtLogisticsOrderTrack();
|
|
|
+ orderTrack.setLOrderId(order.getId());
|
|
|
+ orderTrack.setStatus(order.getStatus());
|
|
|
+ orderTrack.setRemark(LogisticsOrderEnum.getName(order.getStatus()));
|
|
|
+ logisticsOrderTrackDao.insert(orderTrack);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param sendCar 车辆司机信息
|
|
|
+ * @param type 派车类型(1 趟次、2 循环)
|
|
|
+ * @desc 运单信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/4
|
|
|
+ **/
|
|
|
+ public KwtWaybillOrderV1 sendCarDriver(SendCarInfoDto sendCar, int type) {
|
|
|
+ //车辆运单编号存储
|
|
|
+ //String wOrderNo = getRedisGenerateWaybillOrderNo(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, logisticsOrder.getLOrderNo());
|
|
|
+ //车辆信息
|
|
|
+ RTruckVo truck = remoteFleetService.findTruck(sendCar.getTruckId());
|
|
|
+ //司机信息
|
|
|
+ RDriverVo driver = remoteFleetService.findDriver(sendCar.getDriverId());
|
|
|
+ //运单信息
|
|
|
+ KwtWaybillOrderV1 waybillOrder = new KwtWaybillOrderV1();
|
|
|
+ waybillOrder.setEntId(LoginUserHolder.getEntId());
|
|
|
+ waybillOrder.setWOrderNo("W"+System.currentTimeMillis());
|
|
|
+ waybillOrder.setType(type);
|
|
|
+ waybillOrder.setTruckId(sendCar.getTruckId());
|
|
|
+ waybillOrder.setTruckNo(truck != null ? truck.getTruckNo() : null);
|
|
|
+ waybillOrder.setDriverId(sendCar.getDriverId());
|
|
|
+ waybillOrder.setDriverName(driver != null ? driver.getName() : null);
|
|
|
+ waybillOrder.setDriverPhone(driver != null ? driver.getPhone() : null);
|
|
|
+ waybillOrder.setDriverIdcard(driver != null ? driver.getIdcard() : null);
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.PENDING_ORDER.getCode());
|
|
|
+ waybillOrderV1Dao.insert(waybillOrder);
|
|
|
+ return waybillOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param waybillOrder 运单信息
|
|
|
+ * @param lOrderId 物流运单ID
|
|
|
+ * @param entrustAmount 运输委托信息
|
|
|
+ * @param loadTime 装货时间
|
|
|
+ * @param unloadTime 卸货时间
|
|
|
+ * @desc 车辆运单-子运单信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/4
|
|
|
+ **/
|
|
|
+ public KwtWaybillOrderSubtask sendCarSubtask(KwtWaybillOrderV1 waybillOrder, Long lOrderId, BigDecimal entrustAmount, List<Date> loadTime, List<Date> unloadTime) {
|
|
|
+ loadTime.sort(Comparator.naturalOrder());
|
|
|
+ unloadTime.sort(Comparator.reverseOrder());
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderDao.selectById(lOrderId);
|
|
|
+ KwtWaybillOrderSubtask orderSubtask = new KwtWaybillOrderSubtask();
|
|
|
+ orderSubtask.setEntId(waybillOrder.getEntId());
|
|
|
+ orderSubtask.setLOrderId(lOrderId);
|
|
|
+ orderSubtask.setWOrderId(waybillOrder.getId());
|
|
|
+ orderSubtask.setWOrderNo(waybillOrder.getWOrderNo());
|
|
|
+ orderSubtask.setUnit(logisticsOrder != null ? logisticsOrder.getUnit() : null);
|
|
|
+ orderSubtask.setEntrustAmount(entrustAmount.doubleValue());
|
|
|
+ orderSubtask.setLoadTime(loadTime.get(Global.NUMERICAL_ZERO));
|
|
|
+ orderSubtask.setUnloadTime(unloadTime.get(Global.NUMERICAL_ZERO));
|
|
|
+ orderSubtask.setStatus(waybillOrder.getStatus());
|
|
|
+ waybillOrderSubtaskDao.insert(orderSubtask);
|
|
|
+ return orderSubtask;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param wSubtaskId 运单-子订单ID
|
|
|
+ * @param sendCarEntrust 运输委托信息
|
|
|
+ * @param waybillOrder 运单信息
|
|
|
+ * @desc 运单地址信息
|
|
|
+ * @author zk
|
|
|
+ * @date 2024/3/4
|
|
|
+ **/
|
|
|
+ public KwtWaybillOrderAddress sendCarAddress(Long wSubtaskId, SendCarEntrustDto sendCarEntrust, KwtWaybillOrderV1 waybillOrder) {
|
|
|
+ KwtLogisticsOrderAddress logisticsOrderAddress = logisticsOrderAddressDao.selectById(sendCarEntrust.getAddressId());
|
|
|
+ KwtWaybillOrderAddress orderAddress = new KwtWaybillOrderAddress();
|
|
|
+ BeanUtils.copyProperties(logisticsOrderAddress, orderAddress);
|
|
|
+ orderAddress.setId(null);
|
|
|
+ orderAddress.setWOrderId(waybillOrder.getId());
|
|
|
+ orderAddress.setWSubtaskId(wSubtaskId);
|
|
|
+ orderAddress.setLAddressId(sendCarEntrust.getAddressId());
|
|
|
+ orderAddress.setPlanTime(sendCarEntrust.getPlanTime());
|
|
|
+ orderAddress.setEntrustAmount(BigDecimal.valueOf(sendCarEntrust.getEntrustAmount()));
|
|
|
+ orderAddress.setSort(sendCarEntrust.getSort());
|
|
|
+ orderAddress.setCreateBy(null);
|
|
|
+ orderAddress.setCreateTime(null);
|
|
|
+ orderAddress.setUpdateBy(null);
|
|
|
+ orderAddress.setUpdateTime(null);
|
|
|
+ waybillOrderAddressDao.insert(orderAddress);
|
|
|
+ return orderAddress;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param wOrderId 车辆订单ID
|
|
|
+ * @param status 车辆运单状态
|
|
|
+ * @param remark 备注
|
|
|
+ * @desc 新增运单状态记录
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/7/20
|
|
|
+ **/
|
|
|
+ public void setWaybillOrderTrack(Long wOrderId, Date operateTime, int status, String remark) {
|
|
|
+ KwtWaybillOrderTrack orderTrack = new KwtWaybillOrderTrack();
|
|
|
+ orderTrack.setWOrderId(wOrderId);
|
|
|
+ orderTrack.setOperateTime(operateTime);
|
|
|
+ orderTrack.setStatus(status);
|
|
|
+ orderTrack.setRemark(remark);
|
|
|
+ waybillOrderTrackDao.insert(orderTrack);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param type 字典类型
|
|
|
+ * @param value 字典值
|
|
|
+ * @desc 获取数据字典值
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/8/30
|
|
|
+ **/
|
|
|
+ public String getDictValue(String type, String value) {
|
|
|
+ if (StringUtils.isBlank(type) || StringUtils.isBlank(value)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> dictKey = new ArrayList<>() {{
|
|
|
+ add(type + Global.POUND + value);
|
|
|
+ }};
|
|
|
+ Map<String, SysDictResDto> dicts = remoteSystemService.queryDictMapByTypeValues(String.join(Global.COMMA, dictKey));
|
|
|
+ SysDictResDto dict = dicts == null ? null : dicts.get(DictTypeEnum.APPROVED_DRIVING.getType() + Global.POUND + value);
|
|
|
+ return dict != null ? dict.getLabel() : null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param dictKey 字典值
|
|
|
+ * @desc 获取数据字典
|
|
|
+ * @author zk
|
|
|
+ * @date 2023/9/11
|
|
|
+ **/
|
|
|
+ public Map<String, SysDictResDto> dict(List<String> dictKey) {
|
|
|
+ if (CollectionUtils.isEmpty(dictKey)) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ dictKey = dictKey.stream().distinct().collect(Collectors.toList());
|
|
|
+ return remoteSystemService.queryDictMapByTypeValues(String.join(Global.COMMA, dictKey));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|