|
|
@@ -0,0 +1,109 @@
|
|
|
+package com.sckw.transport.service.app;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.sckw.fleet.api.RemoteFleetService;
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
+import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.transport.handler.*;
|
|
|
+import com.sckw.transport.model.param.SalesWaybillOrderQueryParam;
|
|
|
+import com.sckw.transport.model.param.SalesWaybillOrderResp;
|
|
|
+import com.sckw.transport.model.param.WaybillOrderReq;
|
|
|
+import com.sckw.transport.model.vo.StatisticsWaybillResp;
|
|
|
+import com.sckw.transport.repository.*;
|
|
|
+import com.sckw.transport.service.KwtWaybillOrderV1Service;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zk
|
|
|
+ * @desc 司机app接单Service
|
|
|
+ * @date 2023/7/19 0019
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class SalesWaybillOrderService {
|
|
|
+
|
|
|
+ private final KwtLogisticsOrderRepository logisticsOrderRepository;
|
|
|
+ private final KwtLogisticsOrderCirculateRepository logisticsOrderCirculateRepository;
|
|
|
+ private final KwtLogisticsOrderGoodsRepository logisticsOrderGoodsRepository;
|
|
|
+ private final KwtLogisticsOrderAddressRepository logisticsOrderAddressRepository;
|
|
|
+ private final KwtLogisticsOrderUnitRepository logisticsOrderUnitRepository;
|
|
|
+
|
|
|
+ private final KwtWaybillOrderSubtaskRepository waybillOrderSubtaskRepository;
|
|
|
+ private final KwtWaybillOrderRepository waybillOrderRepository;
|
|
|
+ private final KwtWaybillOrderAddressRepository waybillOrderAddressRepository;
|
|
|
+ private final KwtWaybillOrderTicketRepository waybillOrderTicketRepository;
|
|
|
+ private final KwtWaybillOrderNodeRepository waybillOrderNodeRepository;
|
|
|
+
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ RemoteSystemService remoteSystemService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 80000)
|
|
|
+ TradeOrderInfoService tradeOrderInfoService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ RemoteFleetService remoteFleetService;
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ GoodsInfoService goodsInfoService;
|
|
|
+
|
|
|
+ private final TakingOrderHandler takingOrderHandler;
|
|
|
+ private final CancelHandler cancelHandler;
|
|
|
+ private final ComeIntoHandler comeIntoHandler;
|
|
|
+ private final LoadingHandler loadingHandler;
|
|
|
+ private final LeaveMockHandler leaveMockHandler;
|
|
|
+ private final LeaveHandler leaveHandler;
|
|
|
+ private final EmptyLoadLeaveHandler emptyLoadLeaveHandler;
|
|
|
+ private final ReplenishHandler replenishHandler;
|
|
|
+ private final LiftRodReleaseHandler liftRodReleaseHandler;
|
|
|
+
|
|
|
+ private final UnloadingHandler unloadingHandler;
|
|
|
+
|
|
|
+ private final KwtWaybillOrderV1Service waybillOrderV1Service;
|
|
|
+
|
|
|
+ // 注入RedisTemplate用于分布式锁
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate<String, String> redisTemplate;
|
|
|
+
|
|
|
+ // 分布式锁相关常量
|
|
|
+ private static final String TAKING_ORDER_LOCK_PREFIX = "transport:taking_order:lock:";
|
|
|
+ // 锁超时时间30秒
|
|
|
+ private static final long LOCK_EXPIRE_SECONDS = 30;
|
|
|
+ // 锁等待时间500毫秒
|
|
|
+ private static final long LOCK_WAIT_MILLIS = 500;
|
|
|
+ // 锁重试间隔100毫秒
|
|
|
+ private static final long LOCK_RETRY_INTERVAL = 100;
|
|
|
+
|
|
|
+ //载重任务量浮动吨数
|
|
|
+ private static final BigDecimal TWO_TONS = new BigDecimal("2");
|
|
|
+ //载重任务量计算比例
|
|
|
+ private static final BigDecimal EIGHTY_PERCENT = new BigDecimal("0.8");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询销售数据
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public SalesWaybillOrderResp querySalesStatistics(SalesWaybillOrderQueryParam param) {
|
|
|
+ log.info("查询销售数据:{}", JSON.toJSONString(param));
|
|
|
+ SalesWaybillOrderResp salesResp = new SalesWaybillOrderResp();
|
|
|
+ // 查询执行中订单(物流订单)
|
|
|
+ WaybillOrderReq req = new WaybillOrderReq();
|
|
|
+ req.setEntId(String.valueOf(param.getEntId()));
|
|
|
+
|
|
|
+ StatisticsWaybillResp statisticsWaybillResp = waybillOrderV1Service.statisticsWaybillOrder(req);
|
|
|
+
|
|
|
+
|
|
|
+ log.info("查询销售数据成功,结果:{}", JSON.toJSONString(salesResp));
|
|
|
+
|
|
|
+ return salesResp;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|