|
|
@@ -22,6 +22,8 @@ import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
|
import com.sckw.mongo.model.SckwWaybillOrder;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
import com.sckw.order.api.model.CompleteLogisticsOrderParam;
|
|
|
+import com.sckw.redis.constant.RedisConstant;
|
|
|
+import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
@@ -33,6 +35,7 @@ import com.sckw.transport.model.vo.WaybillCountVo;
|
|
|
import com.sckw.transport.model.vo.WaybillOrderDriverVo;
|
|
|
import jakarta.annotation.Resource;
|
|
|
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.cloud.stream.function.StreamBridge;
|
|
|
@@ -40,6 +43,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.*;
|
|
|
@@ -50,6 +54,7 @@ import java.util.stream.Collectors;
|
|
|
* @desc TODO
|
|
|
* @date 2023/7/19 0019
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@SuppressWarnings("all")
|
|
|
public class KwtWaybillOrderService {
|
|
|
@@ -471,7 +476,7 @@ public class KwtWaybillOrderService {
|
|
|
List<SckwWaybillOrder> sckwWaybillOrders = new ArrayList();
|
|
|
for (SendCarDto1 sendCarDto : params) {
|
|
|
/**KwtWaybillOrder数据组装**/
|
|
|
- String wOrderNo = OrderGenerateSeqNoUtils.getWaybillSeqNo(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, logisticsOrder.getLOrderNo());
|
|
|
+ String wOrderNo = getRedisGenerateWaybillOrderNo(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, logisticsOrder.getLOrderNo());
|
|
|
KwtWaybillOrder waybillOrder = this.setKwtWaybillOrder(sendCarDto, wOrderNo);
|
|
|
/**数据存储**/
|
|
|
if (sendCarDto.getType() == Global.NUMERICAL_ONE) {
|
|
|
@@ -514,6 +519,31 @@ public class KwtWaybillOrderService {
|
|
|
return HttpResult.ok(sckwWaybillOrders);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取生成车辆运单单据号最大值处理
|
|
|
+ */
|
|
|
+ public String getRedisGenerateWaybillOrderNo(RedisOrderGenerateEnum redisOrderGenerateEnum, OrderRuleEnum orderRuleEnum, String lOrderNo) {
|
|
|
+ Date date = new Date();
|
|
|
+ String lockKey = String.format(RedisConstant.WAYBILL_NO_GENERATE_KEY, DateUtils.formatDateToYYMMDD(date)) + lOrderNo;
|
|
|
+ String key = OrderGenerateSeqNoUtils.getKeyNotDate(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, lOrderNo);
|
|
|
+ try {
|
|
|
+ if (Boolean.FALSE.equals(RedissonUtils.exists(key))) {
|
|
|
+ if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 5L, 10L))) {
|
|
|
+ throw new BusinessException("业务繁忙,请稍后再试!");
|
|
|
+ }
|
|
|
+ String maxOrderNo = waybillOrderDao.getMaxOrderNo(lOrderNo);
|
|
|
+ if (StringUtils.isNotBlank(maxOrderNo)) {
|
|
|
+ Long maxNum = Long.valueOf(StringUtils.subStrFromIndexToEnd(maxOrderNo, 3));
|
|
|
+ RedissonUtils.setAtomicLong(key, maxNum, DateUtils.getSecondsDay());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return OrderGenerateSeqNoUtils.getWaybillSeqNo(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, lOrderNo);
|
|
|
+ } finally {
|
|
|
+ RedissonUtils.unlock(lockKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param waybillOrder 车辆订单信息
|
|
|
* @param loadAddress 装货地址信息
|
|
|
@@ -644,12 +674,12 @@ public class KwtWaybillOrderService {
|
|
|
* @author zk
|
|
|
* @date 2023/7/20
|
|
|
**/
|
|
|
- public KwtWaybillOrder setKwtWaybillOrder(KwtLogisticsOrderCirculate circulate, OperateSendCarDto params) {
|
|
|
+ public KwtWaybillOrder setKwtWaybillOrder(KwtLogisticsOrderCirculate circulate, OperateSendCarDto params, String wOrderNo) {
|
|
|
KwtWaybillOrder waybillOrder = new KwtWaybillOrder();
|
|
|
waybillOrder.setId(circulate.getId());
|
|
|
waybillOrder.setEntId(LoginUserHolder.getEntId());
|
|
|
waybillOrder.setLOrderId(circulate.getLOrderId());
|
|
|
- waybillOrder.setWOrderNo("xxxxxx");
|
|
|
+ waybillOrder.setWOrderNo(wOrderNo);
|
|
|
waybillOrder.setType(params.getType());
|
|
|
waybillOrder.setStartTime(circulate.getStartTime());
|
|
|
waybillOrder.setEndTime(circulate.getEndTime());
|
|
|
@@ -1132,7 +1162,8 @@ public class KwtWaybillOrderService {
|
|
|
//卸货地址
|
|
|
KwtWaybillOrderAddress unloadAddress = this.getAddress(circulate.getLOrderId(), Global.NUMERICAL_TWO, Global.NUMERICAL_ONE);
|
|
|
//KwtWaybillOrder数据组装
|
|
|
- KwtWaybillOrder waybillOrder = setKwtWaybillOrder(circulate, params);
|
|
|
+ String wOrderNo = getRedisGenerateWaybillOrderNo(RedisOrderGenerateEnum.WAYBILL_ORDER, OrderRuleEnum.WAYBILL_ORDER, logisticsOrder.getLOrderNo());
|
|
|
+ KwtWaybillOrder waybillOrder = setKwtWaybillOrder(circulate, params, wOrderNo);
|
|
|
|
|
|
/**2车辆运单存储**/
|
|
|
ranksSave(waybillOrder, loadAddress, unloadAddress);
|
|
|
@@ -1147,7 +1178,7 @@ public class KwtWaybillOrderService {
|
|
|
|
|
|
/**4更新循环派车数据**/
|
|
|
circulate.setWOrderId(waybillOrder.getId());
|
|
|
- circulate.setTotalTake(circulate.getTotalTake() != null ? circulate.getTotalTake() + Global.NUMERICAL_ONE : Global.NUMERICAL_ZERO);
|
|
|
+ circulate.setTotalTake(circulate.getTotalTake() != null ? circulate.getTotalTake() + Global.NUMERICAL_ONE : Global.NUMERICAL_ONE);
|
|
|
logisticsOrderCirculateDao.updateById(circulate);
|
|
|
|
|
|
/**5Mongodb数据更新**/
|
|
|
@@ -2307,7 +2338,7 @@ public class KwtWaybillOrderService {
|
|
|
*/
|
|
|
public HttpResult getLogisticsAmountByOrderId(String orderId) {
|
|
|
KwtLogisticsOrder kwtLogisticsOrder = logisticsOrderDao.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>().eq(KwtLogisticsOrder::getId, Long.parseLong(orderId)));
|
|
|
- if (kwtLogisticsOrder==null){
|
|
|
+ if (kwtLogisticsOrder == null) {
|
|
|
return HttpResult.error("单据不存在!");
|
|
|
}
|
|
|
BigDecimal amount = kwtLogisticsOrder.getAmount();
|
|
|
@@ -2325,11 +2356,11 @@ public class KwtWaybillOrderService {
|
|
|
statusList.add(CarWaybillEnum.APPROVAL_NO_PASS.getCode().longValue());
|
|
|
//趟次
|
|
|
Map<String, Object> tripMap = waybillOrderDao.selectOrderByOrderId(Long.parseLong(orderId), 1, statusList);
|
|
|
- tripMap.put("waitDistributionAmount",waitDistributionAmount);
|
|
|
+ tripMap.put("waitDistributionAmount", waitDistributionAmount);
|
|
|
map.put("trip", tripMap);
|
|
|
//循环
|
|
|
Map<String, Object> loopMap = waybillOrderDao.selectOrderByOrderId(Long.parseLong(orderId), 2, statusList);
|
|
|
- loopMap.put("waitDistributionAmount",waitDistributionAmount);
|
|
|
+ loopMap.put("waitDistributionAmount", waitDistributionAmount);
|
|
|
map.put("loop", loopMap);
|
|
|
return HttpResult.ok(map);
|
|
|
}
|