|
|
@@ -1,18 +1,24 @@
|
|
|
package com.sckw.transport.service.dubbo;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.sckw.core.common.enums.NumberConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
|
import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
|
+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.SysDictResDto;
|
|
|
@@ -20,14 +26,11 @@ import com.sckw.transport.api.dubbo.TransportDubboService;
|
|
|
import com.sckw.transport.api.model.dto.AccountCheckingBindDTO;
|
|
|
import com.sckw.transport.api.model.dto.AddressResDTO;
|
|
|
import com.sckw.transport.api.model.dto.LogisticsOrderDTO;
|
|
|
+import com.sckw.transport.api.model.param.ContractSignLogisticsParam;
|
|
|
import com.sckw.transport.api.model.param.LogisticsOrderParam;
|
|
|
import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
|
|
|
-import com.sckw.transport.dao.KwtLogisticsOrderAddressMapper;
|
|
|
-import com.sckw.transport.dao.KwtLogisticsOrderMapper;
|
|
|
-import com.sckw.transport.dao.KwtLogisticsOrderUnitMapper;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrder;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrderAddress;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrderUnit;
|
|
|
+import com.sckw.transport.dao.*;
|
|
|
+import com.sckw.transport.model.*;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
@@ -66,6 +69,12 @@ public class TransportDubboServiceImpl implements TransportDubboService {
|
|
|
@Autowired
|
|
|
private KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 对账管理-ids查询
|
|
|
*
|
|
|
@@ -354,7 +363,7 @@ public class TransportDubboServiceImpl implements TransportDubboService {
|
|
|
Long count = logisticsOrderMapper.selectCount(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
.in(KwtLogisticsOrder::getId, collect)
|
|
|
.in(KwtLogisticsOrder::getStatus, orderStatus)
|
|
|
- .eq(KwtLogisticsOrder::getDelFlag,NumberConstant.ZERO)
|
|
|
+ .eq(KwtLogisticsOrder::getDelFlag, NumberConstant.ZERO)
|
|
|
);
|
|
|
if (count > 0) {
|
|
|
return true;
|
|
|
@@ -384,7 +393,7 @@ public class TransportDubboServiceImpl implements TransportDubboService {
|
|
|
List<KwtLogisticsOrder> orderList = logisticsOrderMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
.in(KwtLogisticsOrder::getId, collect)
|
|
|
.in(KwtLogisticsOrder::getStatus, orderStatus)
|
|
|
- .eq(KwtLogisticsOrder::getDelFlag,NumberConstant.ZERO)
|
|
|
+ .eq(KwtLogisticsOrder::getDelFlag, NumberConstant.ZERO)
|
|
|
);
|
|
|
if (CollectionUtils.isNotEmpty(orderList)) {
|
|
|
List<String> orderNo = orderList.stream().map(KwtLogisticsOrder::getLOrderNo).collect(Collectors.toList());
|
|
|
@@ -392,4 +401,89 @@ public class TransportDubboServiceImpl implements TransportDubboService {
|
|
|
}
|
|
|
return httpResult;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void contractSignLogisticsCompleted(ContractSignLogisticsParam param) {
|
|
|
+ if (Objects.isNull(param.getUpdateBy()) || StringUtils.isBlank(param.getUpdateByName())) {
|
|
|
+ throw new BusinessException("操作人信息不能为空!");
|
|
|
+ }
|
|
|
+ Long contractId = param.getContractId();
|
|
|
+ Long updateBy = param.getUpdateBy();
|
|
|
+
|
|
|
+ String lockKey = String.format(RedisConstant.LOGISTICS_ORDER_CONTRACT_UPDATE_KEY, param.getContractId());
|
|
|
+ if (Boolean.FALSE.equals(RedissonUtils.tryLock(lockKey, 5L, 10L))) {
|
|
|
+ throw new BusinessException("业务繁忙,请稍后再试!");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<KwtLogisticsOrderContract> contracts = logisticsOrderContractMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderContract>()
|
|
|
+ .eq(KwtLogisticsOrderContract::getContractId, contractId)
|
|
|
+ .eq(KwtLogisticsOrderContract::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(contracts)) {
|
|
|
+ log.info("合同:{}无相关联待签约的物流订单", contractId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> orderIds = contracts.stream().map(KwtLogisticsOrderContract::getLOrderId).distinct().collect(Collectors.toList());
|
|
|
+ List<KwtLogisticsOrder> orders = logisticsOrderMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .in(KwtLogisticsOrder::getId, orderIds)
|
|
|
+ .eq(KwtLogisticsOrder::getStatus, LogisticsOrderEnum.TO_BE_PLANNED.getCode())
|
|
|
+ );
|
|
|
+ if (CollectionUtils.isEmpty(orders)) {
|
|
|
+ log.info("合同:{}无相关联待签约的物流订单", contractId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<SckwLogisticsOrder> logisticsOrders = Lists.newArrayList();
|
|
|
+ List<Long> ids = orders.stream().map(KwtLogisticsOrder::getId).toList();
|
|
|
+ /**改变物流订单状态*/
|
|
|
+ for (Long id : ids) {
|
|
|
+ logisticsOrderMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrder>()
|
|
|
+ .set(KwtLogisticsOrder::getUpdateBy, updateBy)
|
|
|
+ .set(KwtLogisticsOrder::getUpdateTime, new Date())
|
|
|
+ .set(KwtLogisticsOrder::getStatus, LogisticsOrderEnum.PENDING_ORDER.getCode())
|
|
|
+ .eq(KwtLogisticsOrder::getId, id)
|
|
|
+ );
|
|
|
+ SckwLogisticsOrder logisticsOrder = new SckwLogisticsOrder();
|
|
|
+ logisticsOrder.set_id(id);
|
|
|
+ logisticsOrder.setLOrderId(id);
|
|
|
+ logisticsOrder.setStatus(LogisticsOrderEnum.PENDING_ORDER.getStatus());
|
|
|
+ logisticsOrder.setUpdateBy(updateBy);
|
|
|
+ logisticsOrder.setUpdateByName(param.getUpdateByName());
|
|
|
+ logisticsOrders.add(logisticsOrder);
|
|
|
+ }
|
|
|
+ /**增加状态表数据*/
|
|
|
+ orders.forEach(e -> {
|
|
|
+ KwtLogisticsOrderTrack orderTrack = logisticsOrderTrackMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderTrack>()
|
|
|
+ .eq(KwtLogisticsOrderTrack::getLOrderId, e.getId())
|
|
|
+ .eq(KwtLogisticsOrderTrack::getStatus, LogisticsOrderEnum.PENDING_ORDER.getCode())
|
|
|
+ );
|
|
|
+ if (orderTrack == null) {
|
|
|
+ KwtLogisticsOrderTrack track = new KwtLogisticsOrderTrack();
|
|
|
+ track.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ track.setLOrderId(e.getId());
|
|
|
+ track.setStatus(LogisticsOrderEnum.PENDING_ORDER.getCode());
|
|
|
+ track.setCreateBy(updateBy);
|
|
|
+ track.setCreateTime(new Date());
|
|
|
+ track.setUpdateBy(updateBy);
|
|
|
+ track.setUpdateTime(new Date());
|
|
|
+ track.setDelFlag(NumberConstant.ZERO);
|
|
|
+ logisticsOrderTrackMapper.insert(track);
|
|
|
+ } else {
|
|
|
+ orderTrack.setUpdateBy(updateBy);
|
|
|
+ orderTrack.setUpdateTime(new Date());
|
|
|
+ logisticsOrderTrackMapper.updateById(orderTrack);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /** mongodb保存*/
|
|
|
+ for (SckwLogisticsOrder logisticsOrder : logisticsOrders) {
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
+ busSum.setMethod(NumberConstant.TWO);
|
|
|
+ busSum.setObject(logisticsOrder);
|
|
|
+ streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ RedissonUtils.unlock(lockKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|