|
|
@@ -1,5 +1,6 @@
|
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -7,6 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.common.enums.NumberConstant;
|
|
|
+import com.sckw.core.common.enums.StringConstant;
|
|
|
+import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.model.page.PageHelperUtil;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
@@ -16,18 +19,20 @@ 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.mongo.model.SckwWaybillOrder;
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
+import com.sckw.order.api.model.AddressInfoDetail;
|
|
|
+import com.sckw.order.api.model.OrderDetailRes;
|
|
|
+import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
+import com.sckw.product.api.model.KwpGoods;
|
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.transport.common.enums.CarWaybillEnum;
|
|
|
import com.sckw.transport.common.enums.LogisticsOrderEnum;
|
|
|
import com.sckw.transport.dao.*;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrder;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrderTrack;
|
|
|
-import com.sckw.transport.model.KwtWaybillOrder;
|
|
|
-import com.sckw.transport.model.KwtWaybillOrderTrack;
|
|
|
+import com.sckw.transport.model.*;
|
|
|
import com.sckw.transport.model.dto.CarListDTO;
|
|
|
-import com.sckw.transport.model.dto.OrderDTO;
|
|
|
import com.sckw.transport.model.dto.OrderTakingDTO;
|
|
|
import com.sckw.transport.model.dto.SendCarDTO;
|
|
|
import com.sckw.transport.model.param.AcceptCarriageOrderQuery;
|
|
|
@@ -35,11 +40,13 @@ import com.sckw.transport.model.param.LogisticsConsignmentParam;
|
|
|
import com.sckw.transport.model.vo.AcceptCarriageOrderVO;
|
|
|
import com.sckw.transport.model.vo.CarWaybillVO;
|
|
|
import com.sckw.transport.model.vo.ConsignmentVO;
|
|
|
+import com.sckw.transport.model.vo.WaybillDetailVO;
|
|
|
import jakarta.annotation.Resource;
|
|
|
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;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
@@ -58,8 +65,13 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class AcceptCarriageOrderService {
|
|
|
|
|
|
- @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false, timeout = 8000)
|
|
|
RemoteSystemService remoteSystemService;
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false, timeout = 8000)
|
|
|
+ TradeOrderInfoService tradeOrderInfoService;
|
|
|
+
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false, timeout = 8000)
|
|
|
+ GoodsInfoService goodsInfoService;
|
|
|
|
|
|
@Resource
|
|
|
private StreamBridge streamBridge;
|
|
|
@@ -79,6 +91,27 @@ public class AcceptCarriageOrderService {
|
|
|
@Autowired
|
|
|
private KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderGoodsMapper kwtLogisticsOrderGoodsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderContractMapper kwtLogisticsOrderContractMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderMapper kwtLogisticsOrderMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwtLogisticsOrderCirculateMapper logisticsOrderCirculateMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MongoTemplate mongoTemplate;
|
|
|
+
|
|
|
public HttpResult list(AcceptCarriageOrderQuery query) {
|
|
|
List<AcceptCarriageOrderVO> list = new ArrayList<>();
|
|
|
AcceptCarriageOrderVO acceptCarriageOrderVo = new AcceptCarriageOrderVO();
|
|
|
@@ -100,20 +133,386 @@ public class AcceptCarriageOrderService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public HttpResult subcontractConsignment(LogisticsConsignmentParam query) {
|
|
|
+ /**
|
|
|
+ * 承运订单分包托运
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResult subcontractConsignment(LogisticsConsignmentParam bo) {
|
|
|
+ OrderDetailRes tradeOrder = tradeOrderInfoService.getOrderDetailById(Long.parseLong(bo.getTOrderId()));
|
|
|
+ if (tradeOrder == null) {
|
|
|
+ log.error("订单id查找失败:{}", bo.getTOrderId());
|
|
|
+ throw new RuntimeException("单据错误,数据不存在");
|
|
|
+ }
|
|
|
+ KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
+ if (!bo.getIsFullDose()) {
|
|
|
+ Long amount = bo.getAmount();
|
|
|
+ Long carryingCapacity = bo.getCarryingCapacity();
|
|
|
+ if (carryingCapacity > amount) {
|
|
|
+ log.error("运订单分包托运-可分配量分配错误:{}", bo.getTOrderId());
|
|
|
+ throw new RuntimeException("可分配量分配错误");
|
|
|
+ }
|
|
|
+ if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
+ throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
+ }
|
|
|
+ order.setAmount(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ } else {
|
|
|
+ order.setAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
+ order.setSubcontractAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
+ }
|
|
|
+ String lOrderNo = com.sckw.transport.utils.StringUtils.getLOrderNo();
|
|
|
+ Long orderId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ /**分包托运需要判断处于哪一级分包托运
|
|
|
+ * 需要记录当前分包数据-分包上游数据
|
|
|
+ * */
|
|
|
+ /**
|
|
|
+ * 判断是否已存在分包【当前分包只允许加上主单一共三级】*/
|
|
|
+ Long count = logisticsOrderMapper.selectCount(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .in(KwtLogisticsOrder::getPids, bo.getLOrderId()));
|
|
|
+ if (count >= NumberConstant.TWO) {
|
|
|
+ throw new RuntimeException("分包次数已达上限!");
|
|
|
+ }
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, bo.getLOrderId()));
|
|
|
+ String pids = logisticsOrder.getPids();
|
|
|
+ if (StringUtils.isNotBlank(pids)) {
|
|
|
+ pids = pids + StringConstant.SEMICOLON + orderId;
|
|
|
+ } else {
|
|
|
+ pids = bo.getLOrderId() + StringConstant.SEMICOLON + orderId;
|
|
|
+ }
|
|
|
+ insertSubcontractLogisticsGoods(bo, lOrderNo, orderId);
|
|
|
+ insertSubcontractLogisticsOrder(bo, lOrderNo, order, tradeOrder, orderId, pids);
|
|
|
+ insertSubcontractLogisticsOrderContract(bo, orderId);
|
|
|
+ insertSubcontractLogisticsOrderUnit(bo, orderId);
|
|
|
+ insertSubcontractLogisticsOrderAddress(bo, orderId);
|
|
|
+ insertLogisticsOrderTrack(bo, orderId);
|
|
|
+ //修改上级分配量以及可分配量委托量等
|
|
|
+ logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(new BigDecimal(bo.getCarryingCapacity())));
|
|
|
+ subcontractSendMongoDB(lOrderNo, orderId, bo, tradeOrder);
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ /**
|
|
|
+ * 推送数据到MongoDB
|
|
|
+ *
|
|
|
+ * @param lOrderNo 物流订单编号
|
|
|
+ * @param orderId 物流订单id
|
|
|
+ * @param bo 页面传输实体
|
|
|
+ * @param tradeOrder 贸易订单信息
|
|
|
+ */
|
|
|
+ private void subcontractSendMongoDB(String lOrderNo, Long orderId, LogisticsConsignmentParam bo, OrderDetailRes tradeOrder) {
|
|
|
+ SckwLogisticsOrder logisticsOrder = new SckwLogisticsOrder();
|
|
|
+ logisticsOrder.setLOrderId(orderId);
|
|
|
+ logisticsOrder.setLOrderNo(lOrderNo);
|
|
|
+ logisticsOrder.setLOrderPid(Long.parseLong(bo.getLOrderId()));
|
|
|
+ logisticsOrder.setTOrderId(tradeOrder.getId());
|
|
|
+ logisticsOrder.setTOrderNo("D" + com.sckw.transport.utils.StringUtils.getWaybillNoUtil());
|
|
|
+ logisticsOrder.setSettlementCycle(bo.getSettlementCycle());
|
|
|
+ logisticsOrder.setPrice(new BigDecimal(bo.getPrice()));
|
|
|
+ logisticsOrder.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getPriceType()) == null ?
|
|
|
+ null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getPriceType()).getValue()));
|
|
|
+ if (!bo.getIsFullDose()) {
|
|
|
+ if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
+ throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
+ }
|
|
|
+ logisticsOrder.setAmount(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ logisticsOrder.setUnit(bo.getCarryingCapacityUnit());
|
|
|
+ logisticsOrder.setCarryingCapacity(bo.getCarryingCapacity());
|
|
|
+ } else {
|
|
|
+ logisticsOrder.setAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
+ logisticsOrder.setSubcontractAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
+ logisticsOrder.setCarryingCapacity(0L);
|
|
|
+ }
|
|
|
+ logisticsOrder.setLoss(bo.getLoss() == null ? null : new BigDecimal(bo.getLoss()));
|
|
|
+ logisticsOrder.setLossUnit(bo.getLossUnit());
|
|
|
+ logisticsOrder.setGoodsPrice(bo.getGoodsPrice() == null ? null : new BigDecimal(bo.getGoodsPrice()));
|
|
|
+ BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
|
|
|
+ logisticsOrder.setSubcontractAmount(decimal);
|
|
|
+ logisticsOrder.setEntrustAmount(decimal);
|
|
|
+ logisticsOrder.setUnloadAmount(decimal);
|
|
|
+ logisticsOrder.setLoadAmount(decimal);
|
|
|
+ logisticsOrder.setIgnoreAmount(decimal);
|
|
|
+ logisticsOrder.setDeficitPrice(decimal);
|
|
|
+ logisticsOrder.setPayment(Long.parseLong(bo.getPayment()));
|
|
|
+ logisticsOrder.setTaxRate(bo.getTaxRate() == null ? null : new BigDecimal(bo.getTaxRate()));
|
|
|
+ logisticsOrder.setRemark(bo.getRemark());
|
|
|
+ logisticsOrder.setEntId(LoginUserHolder.getEntId());
|
|
|
+ logisticsOrder.setFirmName(remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId()).getFirmName());
|
|
|
+ logisticsOrder.setGoodsId(Integer.parseInt(bo.getGoodsId()));
|
|
|
+ KwpGoods goods = goodsInfoService.getGoodsById(Long.parseLong(bo.getGoodsId()));
|
|
|
+ logisticsOrder.setGoodsType(goods == null ? null : goods.getGoodsType());
|
|
|
+ logisticsOrder.setGoodsSpec(goods == null ? null : goods.getSpec());
|
|
|
+ logisticsOrder.setContractId(Integer.parseInt(bo.getContractId()));
|
|
|
+ logisticsOrder.setContractNo(bo.getContractNo());
|
|
|
+ logisticsOrder.setContractName(bo.getContractName());
|
|
|
+ logisticsOrder.setContractSigningWay(bo.getPayment());
|
|
|
+ logisticsOrder.setCheckEntId(Long.parseLong(bo.getCheckCompanyId()));
|
|
|
+ logisticsOrder.setCheckFirmName(bo.getCheckCompany());
|
|
|
+ logisticsOrder.setCheckContacts(bo.getCheckContacts());
|
|
|
+ logisticsOrder.setCheckPhone(bo.getCheckContactPhone());
|
|
|
+ logisticsOrder.setCarrierEntId(Long.parseLong(bo.getConsignCompanyId()));
|
|
|
+ logisticsOrder.setCarrierFirmName(bo.getConsignCompany());
|
|
|
+ logisticsOrder.setCarrierContacts(bo.getConsignContacts());
|
|
|
+ List<AddressInfoDetail> addressInfo = tradeOrder.getAddressInfo();
|
|
|
+ for (AddressInfoDetail detail : addressInfo) {
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(detail.getAddressType())) {
|
|
|
+ logisticsOrder.setLoadType(Long.parseLong(detail.getType()));
|
|
|
+ logisticsOrder.setLoadCityCode(detail.getCityCode());
|
|
|
+ logisticsOrder.setLoadCityName(detail.getCityName());
|
|
|
+ logisticsOrder.setLoadDetailAddress(detail.getDetailAddress());
|
|
|
+ logisticsOrder.setLoadLat(detail.getLat());
|
|
|
+ logisticsOrder.setLoadPhone(detail.getPhone());
|
|
|
+ logisticsOrder.setLoadLng(detail.getLng());
|
|
|
+ logisticsOrder.setLoadContacts(detail.getContacts());
|
|
|
+ }
|
|
|
+ if (String.valueOf(NumberConstant.TWO).equals(detail.getAddressType())) {
|
|
|
+ logisticsOrder.setUnloadType(Long.parseLong(detail.getType()));
|
|
|
+ logisticsOrder.setUnloadPhone(detail.getPhone());
|
|
|
+ logisticsOrder.setUnloadCityCode(detail.getCityCode());
|
|
|
+ logisticsOrder.setUnloadCityName(detail.getCityName());
|
|
|
+ logisticsOrder.setUnloadDetailAddress(detail.getDetailAddress());
|
|
|
+ logisticsOrder.setUnloadLat(detail.getLat());
|
|
|
+ logisticsOrder.setUnloadLng(detail.getLng());
|
|
|
+ logisticsOrder.setUnloadContacts(detail.getContacts());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //TODO 生成时并无时间
|
|
|
+// logisticsOrder.setLoadTime();
|
|
|
+// logisticsOrder.setunLoadTime();
|
|
|
+ logisticsOrder.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ logisticsOrder.setCreateByName(LoginUserHolder.getUserName());
|
|
|
+ logisticsOrder.setCreateTime(new Date());
|
|
|
+ logisticsOrder.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ logisticsOrder.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ logisticsOrder.setUpdateTime(new Date());
|
|
|
+ logisticsOrder.setGoodsPriceUnit(bo.getGoodsPriceUnit());
|
|
|
+ logisticsOrder.setContractName(bo.getContractName());
|
|
|
+ logisticsOrder.setBillingMode(bo.getBillingMode());
|
|
|
+ //rabbitMq业务汇总数据发送/消费对象
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ //业务汇总类型
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
+ //操作对象(1新增/2修改)
|
|
|
+ busSum.setMethod(1);
|
|
|
+ //业务汇总数据对象
|
|
|
+ busSum.setObject(logisticsOrder);
|
|
|
+ streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
|
|
|
}
|
|
|
|
|
|
- public List export(AcceptCarriageOrderQuery query) {
|
|
|
- return null;
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-单据状态
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param orderId
|
|
|
+ */
|
|
|
+ private void insertLogisticsOrderTrack(LogisticsConsignmentParam bo, Long orderId) {
|
|
|
+ KwtLogisticsOrderTrack entity = new KwtLogisticsOrderTrack();
|
|
|
+ entity.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ entity.setLOrderId(orderId);
|
|
|
+ entity.setStatus(LogisticsOrderEnum.PENDING_ORDER.getCode());
|
|
|
+ entity.setCreateTime(new Date());
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ entity.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ entity.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ entity.setRemark(bo.getRemark());
|
|
|
+ logisticsOrderTrackMapper.insert(entity);
|
|
|
}
|
|
|
|
|
|
- public List acceptOrder(OrderDTO orderDTO) {
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-装卸货地址信息
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param orderId
|
|
|
+ */
|
|
|
+ private void insertSubcontractLogisticsOrderAddress(LogisticsConsignmentParam bo, Long orderId) {
|
|
|
+ KwtLogisticsOrderAddress loadOrderAddress = new KwtLogisticsOrderAddress();
|
|
|
+ KwtLogisticsOrderAddress unloadOrderAddress = new KwtLogisticsOrderAddress();
|
|
|
+ OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.parseLong(bo.getTOrderId()));
|
|
|
+ if (ObjectUtils.isEmpty(orderDetailRes)) {
|
|
|
+ log.info("dubbp 查询数据 error :orderId:{}", bo.getTOrderId());
|
|
|
+ throw new RuntimeException("dubbp 查询销售订单数据查找失败!");
|
|
|
+ }
|
|
|
+ List<AddressInfoDetail> addressInfo = orderDetailRes.getAddressInfo();
|
|
|
+ if (CollectionUtils.isNotEmpty(addressInfo)) {
|
|
|
+ for (AddressInfoDetail detail : addressInfo) {
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(detail.getAddressType())) {
|
|
|
+ loadOrderAddress.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ loadOrderAddress.setAddressType(NumberConstant.ONE);
|
|
|
+ loadOrderAddress.setDetailAddress(detail.getDetailAddress());
|
|
|
+ loadOrderAddress.setContacts(detail.getContacts());
|
|
|
+ loadOrderAddress.setLOrderId(orderId);
|
|
|
+ loadOrderAddress.setLat(detail.getLat());
|
|
|
+ loadOrderAddress.setFence(detail.getFence());
|
|
|
+ loadOrderAddress.setCityName(detail.getCityName());
|
|
|
+ loadOrderAddress.setEntryType(NumberConstant.FOUR);
|
|
|
+ loadOrderAddress.setCreateTime(new Date());
|
|
|
+ loadOrderAddress.setPhone(detail.getPhone());
|
|
|
+ loadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ loadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ loadOrderAddress.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
+ if (String.valueOf(NumberConstant.TWO).equals(detail.getAddressType())) {
|
|
|
+ unloadOrderAddress.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ unloadOrderAddress.setAddressType(NumberConstant.TWO);
|
|
|
+ unloadOrderAddress.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ unloadOrderAddress.setContacts(detail.getContacts());
|
|
|
+ unloadOrderAddress.setLOrderId(orderId);
|
|
|
+ unloadOrderAddress.setLat(detail.getLat());
|
|
|
+ unloadOrderAddress.setFence(detail.getFence());
|
|
|
+ unloadOrderAddress.setCityName(detail.getCityName());
|
|
|
+ unloadOrderAddress.setEntryType(NumberConstant.FOUR);
|
|
|
+ unloadOrderAddress.setPhone(detail.getPhone());
|
|
|
+ unloadOrderAddress.setDetailAddress(detail.getDetailAddress());
|
|
|
+ unloadOrderAddress.setCreateTime(new Date());
|
|
|
+ unloadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ unloadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ unloadOrderAddress.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
|
+ logisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-单位信息
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param orderId
|
|
|
+ */
|
|
|
+ private void insertSubcontractLogisticsOrderUnit(LogisticsConsignmentParam bo, Long orderId) {
|
|
|
+ KwtLogisticsOrderUnit checkUnit = new KwtLogisticsOrderUnit()
|
|
|
+ .setLOrderId(orderId)
|
|
|
+ .setId(new IdWorker(NumberConstant.ONE).nextId())
|
|
|
+ .setUnitType(NumberConstant.ONE)
|
|
|
+ .setFirmName(bo.getCheckCompany())
|
|
|
+ .setRemark(bo.getRemark())
|
|
|
+ .setEntId(Long.parseLong(bo.getCheckCompanyId()))
|
|
|
+ .setContacts(bo.getCheckContacts())
|
|
|
+ .setPhone(bo.getCheckContactPhone())
|
|
|
+ .setCreateBy(LoginUserHolder.getUserId())
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
+ .setUpdateTime(new Date());
|
|
|
+ logisticsOrderUnitMapper.insert(checkUnit);
|
|
|
+
|
|
|
+ KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit()
|
|
|
+ .setLOrderId(orderId)
|
|
|
+ .setId(new IdWorker(NumberConstant.ONE).nextId())
|
|
|
+ .setUnitType(NumberConstant.TWO)
|
|
|
+ .setFirmName(bo.getConsignCompany())
|
|
|
+ .setRemark(bo.getRemark())
|
|
|
+ .setEntId(Long.parseLong(bo.getConsignCompanyId()))
|
|
|
+ .setContacts(bo.getConsignContacts())
|
|
|
+ .setPhone(bo.getConsignContactPhone())
|
|
|
+ .setCreateBy(LoginUserHolder.getUserId())
|
|
|
+ .setCreateTime(new Date())
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
+ .setUpdateTime(new Date());
|
|
|
+ logisticsOrderUnitMapper.insert(consignUnit);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-合同信息
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param orderId
|
|
|
+ */
|
|
|
+ private void insertSubcontractLogisticsOrderContract(LogisticsConsignmentParam bo, Long orderId) {
|
|
|
+ KwtLogisticsOrderContract kwtLogisticsOrderContract = new KwtLogisticsOrderContract();
|
|
|
+ kwtLogisticsOrderContract.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ kwtLogisticsOrderContract.setLOrderId(orderId);
|
|
|
+ kwtLogisticsOrderContract.setContractId(Long.parseLong(bo.getContractId()));
|
|
|
+ kwtLogisticsOrderContract.setRemark(bo.getRemark());
|
|
|
+ kwtLogisticsOrderContract.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ kwtLogisticsOrderContract.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ kwtLogisticsOrderContract.setCreateTime(new Date());
|
|
|
+ kwtLogisticsOrderContract.setUpdateTime(new Date());
|
|
|
+ kwtLogisticsOrderContractMapper.insert(kwtLogisticsOrderContract);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-主体
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param lOrderNo
|
|
|
+ * @param order
|
|
|
+ * @param tradeOrder
|
|
|
+ * @param orderId
|
|
|
+ * @param pids
|
|
|
+ */
|
|
|
+ private void insertSubcontractLogisticsOrder(LogisticsConsignmentParam bo, String lOrderNo,
|
|
|
+ KwtLogisticsOrder order, OrderDetailRes tradeOrder,
|
|
|
+ Long orderId, String pids) {
|
|
|
+ order.setId(orderId);
|
|
|
+ order.setEntId(LoginUserHolder.getEntId());
|
|
|
+ order.setTOrderId(Long.parseLong(bo.getTOrderId()));
|
|
|
+ order.setTOrderNo(bo.getTOrderNo());
|
|
|
+ order.setLOrderNo(lOrderNo);
|
|
|
+ //分包时,存放分包上级id
|
|
|
+ order.setPid(Long.parseLong(bo.getLOrderId()));
|
|
|
+ //存放所有的分包的父级id
|
|
|
+ order.setPids(pids);
|
|
|
+ order.setSettlementCycle(bo.getSettlementCycle());
|
|
|
+ order.setPrice(new BigDecimal(bo.getPrice()));
|
|
|
+ order.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getPriceType()) == null ?
|
|
|
+ null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getPriceType()).getValue()));
|
|
|
+ order.setAmount(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ order.setBillingMode(bo.getBillingMode());
|
|
|
+ order.setLoss(new BigDecimal(bo.getLoss()));
|
|
|
+ order.setLossUnit(bo.getLossUnit());
|
|
|
+ order.setLossUnit(remoteSystemService.queryDictByTypeAndValue(DictEnum.UNIT_TYPE_0.getType(), bo.getLossUnit()) == null ?
|
|
|
+ null : remoteSystemService.queryDictByTypeAndValue(DictEnum.UNIT_TYPE_0.getType(), bo.getLossUnit()).getValue());
|
|
|
+ order.setGoodsPrice(new BigDecimal(bo.getGoodsPrice()));
|
|
|
+ order.setGoodsPriceUnit(remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getGoodsPriceUnit()) == null ?
|
|
|
+ null : remoteSystemService.queryDictByTypeAndValue(DictEnum.PRICE_TYPE_0.getType(), bo.getGoodsPriceUnit()).getValue());
|
|
|
+ order.setGoodsPriceUnit(bo.getGoodsPriceUnit());
|
|
|
+ order.setStartTime(bo.getShipmentsDateTime());
|
|
|
+ order.setEntTime(bo.getReceiveGoodsDateTime());
|
|
|
+ order.setRemark(bo.getRemark());
|
|
|
+ order.setPayment(Long.parseLong(tradeOrder.getTrading()));
|
|
|
+ order.setTaxRate(new BigDecimal(bo.getTaxRate()));
|
|
|
+ order.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setCreateTime(new Date());
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
+ order.setStatus(LogisticsOrderEnum.PENDING_ORDER.getCode());
|
|
|
+ BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
|
|
|
+ order.setEntrustAmount(decimal);
|
|
|
+ order.setSubcontractAmount(decimal);
|
|
|
+ order.setLoadAmount(decimal);
|
|
|
+ order.setUnloadAmount(decimal);
|
|
|
+ order.setIgnoreAmount(decimal);
|
|
|
+ order.setDeficitPrice(decimal);
|
|
|
+ order.setDeficitAmount(decimal);
|
|
|
+ kwtLogisticsOrderMapper.insert(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分包托运-承运订单-商品信息
|
|
|
+ *
|
|
|
+ * @param bo
|
|
|
+ * @param lOrderNo
|
|
|
+ * @param orderId
|
|
|
+ */
|
|
|
+ private void insertSubcontractLogisticsGoods(LogisticsConsignmentParam bo, String lOrderNo, Long orderId) {
|
|
|
+ KwtLogisticsOrderGoods kwtLogisticsOrderGoods = new KwtLogisticsOrderGoods();
|
|
|
+ kwtLogisticsOrderGoods.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ kwtLogisticsOrderGoods.setGoodsId(Long.parseLong(bo.getGoodsId()));
|
|
|
+ kwtLogisticsOrderGoods.setGoodsName(bo.getGoodsName());
|
|
|
+ kwtLogisticsOrderGoods.setSkuId(StringUtils.isBlank(bo.getSkuId()) ? null : Long.parseLong(bo.getSkuId()));
|
|
|
+ kwtLogisticsOrderGoods.setLOrderId(orderId);
|
|
|
+ kwtLogisticsOrderGoods.setLOrderNo(lOrderNo);
|
|
|
+ kwtLogisticsOrderGoods.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ kwtLogisticsOrderGoods.setUpdateTime(new Date());
|
|
|
+ kwtLogisticsOrderGoods.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ kwtLogisticsOrderGoods.setCreateTime(new Date());
|
|
|
+ kwtLogisticsOrderGoodsMapper.insert(kwtLogisticsOrderGoods);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 是否接单
|
|
|
*
|
|
|
@@ -172,7 +571,7 @@ public class AcceptCarriageOrderService {
|
|
|
return result;
|
|
|
}
|
|
|
List<SckwWaybillOrder> list = new ArrayList<>();
|
|
|
- if (String.valueOf(NumberConstant.ZERO).equals(sendCarDTO.getType())) {
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(sendCarDTO.getType())) {
|
|
|
for (CarListDTO car : sendCarDTO.getCarList()) {
|
|
|
if (ObjectUtils.isEmpty(car.getCount())) {
|
|
|
throw new RuntimeException("趟次派车时,趟次次数不能为空");
|
|
|
@@ -189,20 +588,28 @@ public class AcceptCarriageOrderService {
|
|
|
// insertWaybillOrderTrack(wOrderId);
|
|
|
}
|
|
|
}
|
|
|
- } else if (String.valueOf(NumberConstant.ONE).equals(sendCarDTO.getType())) {
|
|
|
+ } else if (String.valueOf(NumberConstant.TWO).equals(sendCarDTO.getType())) {
|
|
|
for (CarListDTO car : sendCarDTO.getCarList()) {
|
|
|
if (ObjectUtils.isEmpty(sendCarDTO.getWaitingVolume())) {
|
|
|
throw new RuntimeException("循环派车时,剩余可运量不能为空");
|
|
|
}
|
|
|
for (int i = 0; i < car.getCount(); i++) {
|
|
|
- Long wOrderId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
- String wOrderNo = com.sckw.transport.utils.StringUtils.getWaybillNoUtil() + i;
|
|
|
- KwtWaybillOrder waybillOrder = new KwtWaybillOrder();
|
|
|
- String type = String.valueOf(NumberConstant.ONE);
|
|
|
- waybillOrder.setType(type);
|
|
|
- waybillOrder.setEntrustAmount(new BigDecimal(sendCarDTO.getWaitingVolume()));
|
|
|
- insertWaybillOrder(waybillOrder, wOrderId, wOrderNo, logisticsOrder, car, sendCarDTO, list, type);
|
|
|
-// insertWaybillOrderTrack(wOrderId);
|
|
|
+ KwtLogisticsOrderCirculate circulate = new KwtLogisticsOrderCirculate();
|
|
|
+ circulate.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ circulate.setEntId(logisticsOrder.getEntId());
|
|
|
+ circulate.setLOrderId(Long.parseLong(sendCarDTO.getLOrderId()));
|
|
|
+ circulate.setTruckNo(car.getTruckNo());
|
|
|
+ circulate.setDriverId(Long.parseLong(car.getDriverId()));
|
|
|
+ circulate.setActualAmount(new BigDecimal(car.getLoadAmount()));
|
|
|
+ circulate.setEntrustAmount(new BigDecimal(sendCarDTO.getWaitingVolume()));
|
|
|
+ circulate.setEntrustDate(new Date());
|
|
|
+ circulate.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ circulate.setCreateTime(new Date());
|
|
|
+ circulate.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ circulate.setUpdateTime(new Date());
|
|
|
+ circulate.setType(String.valueOf(NumberConstant.ONE));
|
|
|
+ logisticsOrderCirculateMapper.insert(circulate);
|
|
|
+ sendMongoDbData(list, logisticsOrder, car, sendCarDTO, String.valueOf(NumberConstant.ONE));
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -226,6 +633,46 @@ public class AcceptCarriageOrderService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void sendMongoDbData(List<SckwWaybillOrder> list, KwtLogisticsOrder logisticsOrder
|
|
|
+ , CarListDTO carListDTO, SendCarDTO sendCarDTO, String type) {
|
|
|
+ //放入mongodb实体
|
|
|
+ SckwWaybillOrder waybillCarDTO = new SckwWaybillOrder();
|
|
|
+ waybillCarDTO.set_id(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ waybillCarDTO.setStatus(CarWaybillEnum.PENDING_ORDER.getCode().toString());
|
|
|
+ waybillCarDTO.setType(type);
|
|
|
+ waybillCarDTO.setLOrderId(StringUtils.isBlank(sendCarDTO.getLOrderId()) ? null : Long.parseLong(sendCarDTO.getLOrderId()));
|
|
|
+ waybillCarDTO.setLOrderNo(sendCarDTO.getLOrderNo());
|
|
|
+ waybillCarDTO.setTOrderId(logisticsOrder.getTOrderId());
|
|
|
+ waybillCarDTO.setTOrderNo(logisticsOrder.getTOrderNo());
|
|
|
+ waybillCarDTO.setEntId(logisticsOrder.getEntId());
|
|
|
+ waybillCarDTO.setFirmName(remoteSystemService.queryEntCacheById(logisticsOrder.getEntId()).getFirmName());
|
|
|
+ waybillCarDTO.setTruckNo(carListDTO.getTruckNo());
|
|
|
+ //todo 司机dubbo查询
|
|
|
+// waybillCarDTO.setTruckType();
|
|
|
+// waybillCarDTO.setTruckEnergyType();
|
|
|
+// waybillCarDTO.setTruckColor()
|
|
|
+// waybillCarDTO.setTruckTrailerNo();
|
|
|
+// waybillCarDTO.setTruckFleetName();
|
|
|
+ waybillCarDTO.setDriverId(StringUtils.isBlank(carListDTO.getDriverId()) ? null : Long.parseLong(carListDTO.getDriverId()));
|
|
|
+// waybillCarDTO.setDriverPhone();
|
|
|
+// waybillCarDTO.setDriverIdcard();
|
|
|
+ waybillCarDTO.setDriverName(carListDTO.getDriverName());
|
|
|
+ waybillCarDTO.setStartTime(sendCarDTO.getLoadDateTime());
|
|
|
+ waybillCarDTO.setEndTime(sendCarDTO.getUnloadDateTime());
|
|
|
+ waybillCarDTO.setFleetId(carListDTO.getFleetId());
|
|
|
+ waybillCarDTO.setFleetName(carListDTO.getFleetName());
|
|
|
+ waybillCarDTO.setGoodsName(sendCarDTO.getGoodsName());
|
|
|
+ waybillCarDTO.setGoodsId(StringUtils.isBlank(sendCarDTO.getGoodsId()) ? null : Integer.valueOf(sendCarDTO.getGoodsId()));
|
|
|
+ waybillCarDTO.setLoadingCity(sendCarDTO.getLoadCity());
|
|
|
+ waybillCarDTO.setLoadTime(sendCarDTO.getLoadDateTime());
|
|
|
+ waybillCarDTO.setLoadingAddress(sendCarDTO.getLoadAddress());
|
|
|
+ waybillCarDTO.setUnloadingCity(sendCarDTO.getUnloadCity());
|
|
|
+ waybillCarDTO.setUnloadTime(sendCarDTO.getUnloadDateTime());
|
|
|
+ waybillCarDTO.setUnloadingAddress(sendCarDTO.getUnloadAddress());
|
|
|
+ waybillCarDTO.setDelFlag(Integer.valueOf(NumberConstant.ZERO));
|
|
|
+ list.add(waybillCarDTO);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存车辆运单状态信息
|
|
|
*
|
|
|
@@ -281,6 +728,7 @@ public class AcceptCarriageOrderService {
|
|
|
waybillOrder.setCreateTime(createTime);
|
|
|
waybillOrder.setUpdateTime(new Date());
|
|
|
waybillOrder.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ waybillOrder.setStatus(CarWaybillEnum.PENDING_ORDER.getCode());
|
|
|
waybillOrderMapper.insert(waybillOrder);
|
|
|
|
|
|
//状态表保存
|
|
|
@@ -334,4 +782,31 @@ public class AcceptCarriageOrderService {
|
|
|
waybillCarDTO.setDelFlag(Integer.valueOf(NumberConstant.ZERO));
|
|
|
list.add(waybillCarDTO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运订单-获取运单详情
|
|
|
+ * @param wOrderId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public HttpResult getWaybillData(String wOrderId) {
|
|
|
+ SckwWaybillOrder sckwWaybillOrder = mongoTemplate.findById(Long.parseLong(wOrderId), SckwWaybillOrder.class);
|
|
|
+ WaybillDetailVO vo = new WaybillDetailVO();
|
|
|
+ if (!ObjectUtils.isEmpty(sckwWaybillOrder)) {
|
|
|
+ vo.setFleetName(sckwWaybillOrder.getFleetName());
|
|
|
+ vo.setTruckNo(sckwWaybillOrder.getTruckNo());
|
|
|
+ vo.setDriverName(sckwWaybillOrder.getDriverName());
|
|
|
+ vo.setSendCarWeigh(sckwWaybillOrder.getEntrustAmount());
|
|
|
+ vo.setLoadAmount(sckwWaybillOrder.getLoadAmount());
|
|
|
+ vo.setStowageDateTime(sckwWaybillOrder.getLoadTime());
|
|
|
+ vo.setWaybillType(sckwWaybillOrder.getType());
|
|
|
+ vo.setUnloadAmount(sckwWaybillOrder.getUnloadAmount());
|
|
|
+ vo.setUnloadDateTime(sckwWaybillOrder.getUnloadTime());
|
|
|
+ vo.setAppointor(sckwWaybillOrder.getCreateByName());
|
|
|
+ vo.setLoss(sckwWaybillOrder.getLoss());
|
|
|
+ vo.setGoodsPrice(sckwWaybillOrder.getGoodsPrice());
|
|
|
+ vo.setStartTime(sckwWaybillOrder.getStartTime());
|
|
|
+ vo.setEndTime(sckwWaybillOrder.getEndTime());
|
|
|
+ }
|
|
|
+ return HttpResult.ok(vo);
|
|
|
+ }
|
|
|
}
|