|
@@ -6,8 +6,10 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
|
import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
|
|
import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
|
|
|
|
|
+import com.sckw.core.common.enums.StringConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
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.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
@@ -34,6 +36,7 @@ import com.sckw.order.api.model.*;
|
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
import com.sckw.product.api.model.KwpGoods;
|
|
import com.sckw.product.api.model.KwpGoods;
|
|
|
import com.sckw.redis.config.RedisLockUtil;
|
|
import com.sckw.redis.config.RedisLockUtil;
|
|
|
|
|
+import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.stream.enums.MessageEnum;
|
|
import com.sckw.stream.enums.MessageEnum;
|
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
@@ -41,10 +44,7 @@ import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import com.sckw.transport.common.config.MessageUrlConfig;
|
|
import com.sckw.transport.common.config.MessageUrlConfig;
|
|
|
import com.sckw.transport.dao.*;
|
|
import com.sckw.transport.dao.*;
|
|
|
import com.sckw.transport.model.*;
|
|
import com.sckw.transport.model.*;
|
|
|
-import com.sckw.transport.model.dto.AddressInfoDto;
|
|
|
|
|
-import com.sckw.transport.model.dto.ContractDto;
|
|
|
|
|
-import com.sckw.transport.model.dto.LineFreightDto;
|
|
|
|
|
-import com.sckw.transport.model.dto.LogisticsConsignmentDto;
|
|
|
|
|
|
|
+import com.sckw.transport.model.dto.*;
|
|
|
import com.sckw.transport.model.param.AddLogisticsOrderParam;
|
|
import com.sckw.transport.model.param.AddLogisticsOrderParam;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -57,6 +57,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -139,7 +140,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
public KwtLogisticsOrderGoodsMapper goodsMapper;
|
|
public KwtLogisticsOrderGoodsMapper goodsMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 采购订单/销售订单-物流托运-4.2
|
|
|
|
|
|
|
+ * 采购订单/销售订单-物流托运-v4.2
|
|
|
*
|
|
*
|
|
|
* @param dto
|
|
* @param dto
|
|
|
*/
|
|
*/
|
|
@@ -457,6 +458,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
loadOrderAddress.setCityCode(detail.getCityCode());
|
|
loadOrderAddress.setCityCode(detail.getCityCode());
|
|
|
loadOrderAddress.setLng(detail.getLng());
|
|
loadOrderAddress.setLng(detail.getLng());
|
|
|
loadOrderAddress.setSort(addressInfoDto.getSort());
|
|
loadOrderAddress.setSort(addressInfoDto.getSort());
|
|
|
|
|
+ loadOrderAddress.setTAddressId(Long.parseLong(addressInfoDto.getAddressId()));
|
|
|
logisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
logisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
|
|
|
|
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
@@ -500,6 +502,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
unloadOrderAddress.setCityCode(detail.getCityCode());
|
|
unloadOrderAddress.setCityCode(detail.getCityCode());
|
|
|
unloadOrderAddress.setLng(detail.getLng());
|
|
unloadOrderAddress.setLng(detail.getLng());
|
|
|
unloadOrderAddress.setSort(addressInfoDto.getSort());
|
|
unloadOrderAddress.setSort(addressInfoDto.getSort());
|
|
|
|
|
+ unloadOrderAddress.setTAddressId(Long.parseLong(addressInfoDto.getAddressId()));
|
|
|
logisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
logisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
|
|
|
|
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
@@ -1083,8 +1086,8 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
List<AddressInfoDto> addressInfo = orderDTO.getAddressInfo();
|
|
List<AddressInfoDto> addressInfo = orderDTO.getAddressInfo();
|
|
|
List<String> addressIds = addressInfo.stream().map(AddressInfoDto::getAddressId).collect(Collectors.toList());
|
|
List<String> addressIds = addressInfo.stream().map(AddressInfoDto::getAddressId).collect(Collectors.toList());
|
|
|
Map<Long, EntAddressResDto> addressDetailMap = manageService.queryAddressListByAddressIdList(addressIds);
|
|
Map<Long, EntAddressResDto> addressDetailMap = manageService.queryAddressListByAddressIdList(addressIds);
|
|
|
- if (addressDetailMap.isEmpty()){
|
|
|
|
|
- log.info("no address :{}",JSONObject.toJSONString(addressIds));
|
|
|
|
|
|
|
+ if (addressDetailMap.isEmpty()) {
|
|
|
|
|
+ log.info("no address :{}", JSONObject.toJSONString(addressIds));
|
|
|
throw new BusinessException("地址信息异常");
|
|
throw new BusinessException("地址信息异常");
|
|
|
}
|
|
}
|
|
|
Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
|
|
Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
|
|
@@ -1359,4 +1362,606 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 物流订单-分包托运
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param logisticsOrderSubcontractDto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public HttpResult logisticsOrderSubcontract(LogisticsOrderSubcontractDto bo) {
|
|
|
|
|
+ HttpResult httpResult = ValidUtil.serviceValid(bo);
|
|
|
|
|
+ String key = String.format(RedisConstant.LOGISTICS_ORDER_SUBCONTRACT_KEY, bo.getLOrderId());
|
|
|
|
|
+ if (redisLockUtil.tryLock(key)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!String.valueOf(HttpStatus.SUCCESS_CODE).equals(String.valueOf(httpResult.getCode()))) {
|
|
|
|
|
+ httpResult.setMsg(httpResult.getMsg());
|
|
|
|
|
+ httpResult.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
|
|
+ return httpResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectById(bo.getLOrderId());
|
|
|
|
|
+ if (logisticsOrder == null) {
|
|
|
|
|
+ log.error("订单id查找失败:{},订单编号:{}", bo.getLOrderId(), bo.getLOrderNo());
|
|
|
|
|
+ throw new BusinessException("单据错误,数据不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ //todo 校验当前登录角色是否具有4P物流角色
|
|
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
|
|
+ if (entCacheResDto == null) {
|
|
|
|
|
+ log.info("承运订单-分包托运 用户id:{}", LoginUserHolder.getUserId());
|
|
|
|
|
+ throw new BusinessException("企业信息查询异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!entCacheResDto.getEntTypes().contains(String.valueOf(NumberConstant.THREE))) {
|
|
|
|
|
+ throw new BusinessException("当前用户企业不具有分包功能权限!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (bo.getCarryingCapacity().compareTo(NumberConstant.ZERO_TWO) == 0) {
|
|
|
|
|
+ throw new BusinessException("分配承运量必须填写大于0.00");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal subtract = logisticsOrder.getAmount().subtract((logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount()));
|
|
|
|
|
+ if (bo.getCarryingCapacity().compareTo(subtract) > 0) {
|
|
|
|
|
+ throw new BusinessException("分配承运量必须可待分配量");
|
|
|
|
|
+ }
|
|
|
|
|
+ KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
|
|
+ if (!bo.getIsFullDose()) {
|
|
|
|
|
+ BigDecimal amount = bo.getAmount();
|
|
|
|
|
+ BigDecimal carryingCapacity = bo.getCarryingCapacity();
|
|
|
|
|
+ if (amount.compareTo(carryingCapacity) < 0) {
|
|
|
|
|
+ log.error("运订单分包托运-可分配量分配错误:{}", bo.getLOrderId());
|
|
|
|
|
+ throw new RuntimeException("可分配量分配错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
|
|
+ throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ order.setAmount(bo.getCarryingCapacity());
|
|
|
|
|
+ order.setUnit(bo.getCarryingCapacityUnit());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ order.setAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
|
|
+ order.setSubcontractAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
|
|
+ order.setUnit(bo.getCarryingCapacityUnit());
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getSubcontractAmount();
|
|
|
|
|
+ BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
|
|
|
|
|
+ BigDecimal waitDistributionAmount = logisticsOrder.getAmount().subtract(subcontractAmount).subtract(entrustAmount);
|
|
|
|
|
+ if (waitDistributionAmount.compareTo(NumberConstant.ZERO_TWO) == 0) {
|
|
|
|
|
+ throw new RuntimeException("剩余可分配量为0,不可进行分包操作!");
|
|
|
|
|
+ }
|
|
|
|
|
+ int level = logisticsLevel(logisticsOrder);
|
|
|
|
|
+ long number = logisticsOrderMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
|
|
+ .eq(KwtLogisticsOrder::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .apply(logisticsOrder.getId() != null, "FIND_IN_SET ('" + bo.getLOrderId() + "', pids)").ne(KwtLogisticsOrder::getId, bo.getLOrderId()))
|
|
|
|
|
+ .stream().count();
|
|
|
|
|
+ String pidOrderNo = logisticsOrder.getLOrderNo();
|
|
|
|
|
+ String substring = pidOrderNo.substring(0, 11);
|
|
|
|
|
+ String lOrderNo = substring + logisticsOrder.getType() + String.valueOf(level) + String.valueOf(number + 1);
|
|
|
|
|
+ Long orderId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
|
|
+ //分包托运需要判断处于哪一级分包托运,需要记录当前分包数据-分包上游数据
|
|
|
|
|
+ //判断是否已存在分包【当前分包只允许加上主单一共四级】
|
|
|
|
|
+ if (level >= 4) {
|
|
|
|
|
+ throw new RuntimeException("分包次数已达上限!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String pids = logisticsOrder.getPids();
|
|
|
|
|
+ if (StringUtils.isNotBlank(pids)) {
|
|
|
|
|
+ pids = pids + StringConstant.COMMA + orderId;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ pids = bo.getLOrderId() + StringConstant.COMMA + orderId;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**判断生成物流订单应生成哪一种单据状态*/
|
|
|
|
|
+ List<Long> contractList = new ArrayList<>();
|
|
|
|
|
+ contractList.add(Long.parseLong(bo.getContractId()));
|
|
|
|
|
+ Map<Long, ContractCommonInfoResDto> longContractCommonInfoResDtoMap = contractService.queryContractBaseInfo(contractList);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(longContractCommonInfoResDtoMap)) {
|
|
|
|
|
+ throw new RuntimeException("并未有对应合同,应先签约合同");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (longContractCommonInfoResDtoMap.get(Long.parseLong(bo.getContractId())) == null) {
|
|
|
|
|
+ throw new RuntimeException("并未有对应合同,应先签约合同");
|
|
|
|
|
+ }
|
|
|
|
|
+ ContractCommonInfoResDto infoResDto = longContractCommonInfoResDtoMap.get(Long.parseLong(bo.getContractId()));
|
|
|
|
|
+ /**状态判断
|
|
|
|
|
+ * 是否是已签约合同
|
|
|
|
|
+ * */
|
|
|
|
|
+ // 0 已签约 1待签约
|
|
|
|
|
+ Integer status = infoResDto.getStatus();
|
|
|
|
|
+ Integer orderStatus = LogisticsOrderEnum.PENDING_ORDER.getCode();
|
|
|
|
|
+ if (NumberConstant.ONE == status) {
|
|
|
|
|
+ orderStatus = LogisticsOrderEnum.TO_BE_PLANNED.getCode();
|
|
|
|
|
+ } else if (NumberConstant.ZERO == status) {
|
|
|
|
|
+ orderStatus = LogisticsOrderEnum.PENDING_ORDER.getCode();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.info("分包托运-物流订单id:{}," +
|
|
|
|
|
+ "物流订单编号:{},合同id:{},合同信息:{}",
|
|
|
|
|
+ bo.getLOrderId(), bo.getLOrderNo(),
|
|
|
|
|
+ bo.getContractId(), JSONObject.toJSONString(infoResDto));
|
|
|
|
|
+ throw new RuntimeException("分包托运合同异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ //主体信息保存
|
|
|
|
|
+ logisticsOrderGoodsService.insertSubcontractLogisticsGoods(logisticsOrder, lOrderNo, orderId);
|
|
|
|
|
+ insertSubcontractLogisticsOrder(bo, lOrderNo, order, orderId, pids, orderStatus, logisticsOrder);
|
|
|
|
|
+ insertSubcontractLogisticsOrderContract(bo, orderId, infoResDto);
|
|
|
|
|
+ insertSubcontractLogisticsOrderUnit(bo, orderId);
|
|
|
|
|
+ insertSubcontractLogisticsOrderAddressAndAmount(bo, orderId, logisticsOrder);
|
|
|
|
|
+ insertLogisticsOrderTrack(bo, orderId, orderStatus);
|
|
|
|
|
+ if (bo.getBillingMode().equals("4")) {
|
|
|
|
|
+ insertLogisticsOrderLineFreight(bo, orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改上级分配量以及可分配量委托量等
|
|
|
|
|
+ logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
|
|
|
|
|
+ logisticsOrderMapper.updateById(logisticsOrder);
|
|
|
|
|
+
|
|
|
|
|
+ List<AddressInfoDto> addressInfo = bo.getAddressInfo();
|
|
|
|
|
+ addressInfo.forEach(addressInfoDto -> {
|
|
|
|
|
+ String addressId = addressInfoDto.getAddressId();
|
|
|
|
|
+ KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectById(addressId);
|
|
|
|
|
+ if (orderAmount != null) {
|
|
|
|
|
+ orderAmount.setSubcontractAmount(orderAmount.getSubcontractAmount().add(addressInfoDto.getAmount()));
|
|
|
|
|
+ logisticsOrderAmountMapper.updateById(orderAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**数据发送至消息列表*/
|
|
|
|
|
+ String type = bo.getType();
|
|
|
|
|
+ if ("1".equals(type)){
|
|
|
|
|
+ /**托运订单*/
|
|
|
|
|
+ }else if ("2".equals(type)){
|
|
|
|
|
+ /**承运订单*/
|
|
|
|
|
+ EntCacheResDto consignentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getAcceptCompanyId()));
|
|
|
|
|
+ EntCacheResDto checkentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getConsignCompanyId()));
|
|
|
|
|
+ //托运单位
|
|
|
|
|
+ KwtLogisticsOrderUnit checkUnit = new KwtLogisticsOrderUnit();
|
|
|
|
|
+ checkUnit.setUnitType(1);
|
|
|
|
|
+ checkUnit.setFirmName(bo.getConsignCompany());
|
|
|
|
|
+ checkUnit.setEntId(Long.parseLong(bo.getConsignCompanyId()));
|
|
|
|
|
+ checkUnit.setTopEntId(consignentMap == null ? null : consignentMap.getId());
|
|
|
|
|
+ checkUnit.setContactsId(Long.parseLong(bo.getConsignContactsId()));
|
|
|
|
|
+ //承运单位
|
|
|
|
|
+ KwtLogisticsOrderUnit carriageUnit = new KwtLogisticsOrderUnit();
|
|
|
|
|
+ carriageUnit.setUnitType(2);
|
|
|
|
|
+ carriageUnit.setFirmName(bo.getAcceptCompany());
|
|
|
|
|
+ carriageUnit.setEntId(Long.parseLong(bo.getAcceptCompanyId()));
|
|
|
|
|
+ carriageUnit.setContactsId(Long.parseLong(bo.getAcceptContactsId()));
|
|
|
|
|
+ carriageUnit.setFirmName(bo.getAcceptCompany());
|
|
|
|
|
+ carriageUnit.setTopEntId(checkentMap == null ? null : checkentMap.getId());
|
|
|
|
|
+
|
|
|
|
|
+// commonService.initIatingLogisticsConsignment(checkUnit, carriageUnit, logisticsOrder.getLOrderNo(), logisticsOrder.getCreateBy(), logisticsOrder.getEntId());
|
|
|
|
|
+ commonService.newSendLogisticsOrderToMessage(carriageUnit, checkUnit, logisticsOrder.getLOrderNo(), logisticsOrder.getCreateBy(), logisticsOrder.getEntId(),
|
|
|
|
|
+ messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl(),
|
|
|
|
|
+ messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl(),
|
|
|
|
|
+ MessageEnum.INITIATING_LOGISTICS_CONSIGNMENT, MessageEnum.NEW_CARRIAGE_ORDER,
|
|
|
|
|
+ "1");
|
|
|
|
|
+ }
|
|
|
|
|
+ //修改父级mongodb数据
|
|
|
|
|
+ //更新mongodb
|
|
|
|
|
+ SckwLogisticsOrder lOrder = new SckwLogisticsOrder();
|
|
|
|
|
+ lOrder.set_id(order.getId());
|
|
|
|
|
+ lOrder.setLOrderId(order.getId());
|
|
|
|
|
+ lOrder.setEntrustAmount(order.getEntrustAmount());
|
|
|
|
|
+ lOrder.setStatus(String.valueOf(order.getStatus()));
|
|
|
|
|
+ lOrder.setUpdateTime(order.getUpdateTime());
|
|
|
|
|
+ lOrder.setUpdateBy(order.getUpdateBy());
|
|
|
|
|
+ lOrder.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
|
|
+ lOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
|
|
|
|
|
+// lOrder.setIgnoreAmount(logisticsOrder.getIgnoreAmount().subtract(bo.getCarryingCapacity()));
|
|
|
|
|
+ //rabbitMq业务汇总数据发送/消费对象
|
|
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
|
|
+ //业务汇总类型
|
|
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
|
|
+ //操作对象(1新增/2修改/3替换数据)
|
|
|
|
|
+ busSum.setMethod(2);
|
|
|
|
|
+ //业务汇总数据对象
|
|
|
|
|
+ busSum.setObject(lOrder);
|
|
|
|
|
+ streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
|
|
+ //新增当前分包mongodb数据
|
|
|
|
|
+ subcontractSendMongoDB(lOrderNo, orderId, bo, logisticsOrder, orderStatus);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ redisLockUtil.unlock(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.error("当前数据正在处理,请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void subcontractSendMongoDB(String lOrderNo, Long orderId, LogisticsOrderSubcontractDto bo, KwtLogisticsOrder kwtLogisticsOrder, Integer orderStatus) {
|
|
|
|
|
+ SckwLogisticsOrder logisticsOrder = new SckwLogisticsOrder();
|
|
|
|
|
+ logisticsOrder.setStatus(String.valueOf(orderStatus));
|
|
|
|
|
+ logisticsOrder.setLOrderId(orderId);
|
|
|
|
|
+ logisticsOrder.setLOrderNo(lOrderNo);
|
|
|
|
|
+ logisticsOrder.setLOrderPid(Long.parseLong(bo.getLOrderId()));
|
|
|
|
|
+ logisticsOrder.setSettlementCycle(bo.getSettlementCycle());
|
|
|
|
|
+ logisticsOrder.setPrice(bo.getPrice());
|
|
|
|
|
+ logisticsOrder.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()) == null ?
|
|
|
|
|
+ null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()).getValue()));
|
|
|
|
|
+ if (!bo.getIsFullDose()) {
|
|
|
|
|
+ if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
|
|
+ throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ logisticsOrder.setAmount(bo.getCarryingCapacity());
|
|
|
|
|
+ logisticsOrder.setUnit(bo.getCarryingCapacityUnit());
|
|
|
|
|
+ logisticsOrder.setCarryingCapacity(bo.getCarryingCapacity());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ logisticsOrder.setAmount(NumberConstant.ZERO_TWO);
|
|
|
|
|
+ logisticsOrder.setSubcontractAmount(NumberConstant.ZERO_TWO);
|
|
|
|
|
+ logisticsOrder.setCarryingCapacity(NumberConstant.ZERO_TWO);
|
|
|
|
|
+ }
|
|
|
|
|
+ logisticsOrder.setLoss(bo.getLoss() == null ? null : bo.getLoss());
|
|
|
|
|
+ logisticsOrder.setLossUnit(bo.getLossUnit());
|
|
|
|
|
+ logisticsOrder.setGoodsPrice(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());
|
|
|
|
|
+ if (bo.getGoodsId() != null) {
|
|
|
|
|
+ logisticsOrder.setGoodsId(Long.parseLong(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.setGoodsName(bo.getGoodsName());
|
|
|
|
|
+ logisticsOrder.setContractId(bo.getContractId());
|
|
|
|
|
+ logisticsOrder.setContractNo(bo.getContractNo());
|
|
|
|
|
+ logisticsOrder.setContractName(bo.getContractName());
|
|
|
|
|
+ logisticsOrder.setContractSigningWay(bo.getPayment());
|
|
|
|
|
+ logisticsOrder.setCheckEntId(Long.parseLong(bo.getConsignCompanyId()));
|
|
|
|
|
+ logisticsOrder.setCheckFirmName(bo.getConsignCompany());
|
|
|
|
|
+ logisticsOrder.setCheckContacts(bo.getConsignContacts());
|
|
|
|
|
+ logisticsOrder.setCheckPhone(bo.getConsignContactPhone());
|
|
|
|
|
+ logisticsOrder.setCarrierEntId(Long.parseLong(bo.getAcceptContactsId()));
|
|
|
|
|
+ logisticsOrder.setCarrierFirmName(bo.getAcceptCompany());
|
|
|
|
|
+ logisticsOrder.setCarrierContacts(bo.getAcceptContacts());
|
|
|
|
|
+ //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));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void insertLogisticsOrderLineFreight(LogisticsOrderSubcontractDto dto, Long orderId) {
|
|
|
|
|
+ List<LineFreightDto> lineFreightList = dto.getLineFreightList();
|
|
|
|
|
+ List<Long> lineFreightId = lineFreightList.stream().map(t -> t.getLineFreightId()).distinct().collect(Collectors.toList());
|
|
|
|
|
+ Map<Long, LineFreightAddressRes> resMap = manageService.findLineFreightAddress(lineFreightId);
|
|
|
|
|
+ if (resMap != null) {
|
|
|
|
|
+ lineFreightId.stream().forEach(id -> {
|
|
|
|
|
+ if (resMap.get(id) != null) {
|
|
|
|
|
+ LineFreightAddressRes res = resMap.get(id);
|
|
|
|
|
+ KwtLogisticsOrderLineFreightRate lineFreightRate = new KwtLogisticsOrderLineFreightRate();
|
|
|
|
|
+ lineFreightRate.setLOrderId(orderId);
|
|
|
|
|
+ lineFreightRate.setName(res.getName());
|
|
|
|
|
+ lineFreightRate.setLoadName(res.getLoadName());
|
|
|
|
|
+ lineFreightRate.setLoadCityCode(res.getLoadCityCode());
|
|
|
|
|
+ lineFreightRate.setLoadCityName(res.getLoadCityName());
|
|
|
|
|
+ lineFreightRate.setLoadDetailAddress(res.getLoadDetailAddress());
|
|
|
|
|
+ lineFreightRate.setLoadLat(res.getLoadLat());
|
|
|
|
|
+ lineFreightRate.setLoadLng(res.getLoadLng());
|
|
|
|
|
+ lineFreightRate.setUnloadName(res.getUnloadName());
|
|
|
|
|
+ lineFreightRate.setUnloadCityCode(res.getUnloadCityCode());
|
|
|
|
|
+ lineFreightRate.setUnloadCityName(res.getUnloadCityName());
|
|
|
|
|
+ lineFreightRate.setUnloadDetailAddress(res.getUnloadDetailAddress());
|
|
|
|
|
+ lineFreightRate.setUnloadLat(res.getUnloadLat());
|
|
|
|
|
+ lineFreightRate.setUnloadLng(res.getUnloadLng());
|
|
|
|
|
+ lineFreightRate.setTransportMileage(res.getTransportMileage());
|
|
|
|
|
+ lineFreightRate.setTransportPrice(res.getTransportPrice());
|
|
|
|
|
+ BigDecimal defultBigDecimal = new BigDecimal("0.00");
|
|
|
|
|
+ lineFreightRate.setSettlementAmount(defultBigDecimal);
|
|
|
|
|
+ lineFreightRate.setId(new IdWorker(NumberConstant.FOUR).nextId());
|
|
|
|
|
+ lineFreightRate.setRemark(res.getRemark());
|
|
|
|
|
+ lineFreightRate.setStatus(res.getStatus());
|
|
|
|
|
+ lineFreightRate.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ lineFreightRate.setCreateTime(new Date());
|
|
|
|
|
+ lineFreightRate.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ lineFreightRate.setUpdateTime(new Date());
|
|
|
|
|
+ lineFreightRate.setDelFlag(0);
|
|
|
|
|
+ logisticsOrderLineFreightRateMapper.insert(lineFreightRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void insertLogisticsOrderTrack(LogisticsOrderSubcontractDto bo, Long orderId, Integer orderStatus) {
|
|
|
|
|
+ KwtLogisticsOrderTrack entity = new KwtLogisticsOrderTrack();
|
|
|
|
|
+ entity.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
|
|
+ entity.setLOrderId(orderId);
|
|
|
|
|
+ entity.setStatus(orderStatus);
|
|
|
|
|
+ entity.setCreateTime(new Date());
|
|
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
|
|
+ entity.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ entity.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ entity.setRemark(bo.getRemark());
|
|
|
|
|
+ logisticsOrderTrackMapper.insert(entity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void insertSubcontractLogisticsOrderAddressAndAmount(LogisticsOrderSubcontractDto bo, Long orderId, KwtLogisticsOrder logisticsOrder) {
|
|
|
|
|
+ List<AddressInfoDto> addressInfo = bo.getAddressInfo();
|
|
|
|
|
+ Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
|
|
|
|
|
+
|
|
|
|
|
+ /**处理装货*/
|
|
|
|
|
+ List<AddressInfoDto> loadAddress = addressMap.get(NumberConstant.ONE);
|
|
|
|
|
+ List<String> loadAddressIds = loadAddress.stream().map(AddressInfoDto::getAddressId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ List<KwtLogisticsOrderAddress> orderLoadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
|
|
+ .eq(KwtLogisticsOrderAddress::getLOrderId, logisticsOrder.getId())
|
|
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE)
|
|
|
|
|
+ .in(KwtLogisticsOrderAddress::getId, loadAddressIds)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Long, KwtLogisticsOrderAddress> parentLoadOrderMap = new HashMap<Long, KwtLogisticsOrderAddress>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(orderLoadAddress)) {
|
|
|
|
|
+ parentLoadOrderMap = orderLoadAddress.stream().collect(Collectors.toMap(KwtLogisticsOrderAddress::getId, Function.identity()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(loadAddress)) {
|
|
|
|
|
+ for (AddressInfoDto address : loadAddress) {
|
|
|
|
|
+ if (address.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (parentLoadOrderMap.get(address.getAddressId()) != null) {
|
|
|
|
|
+ KwtLogisticsOrderAddress loadAddressData = parentLoadOrderMap.get(address.getAddressId());
|
|
|
|
|
+ KwtLogisticsOrderAddress loadOrderAddress = new KwtLogisticsOrderAddress();
|
|
|
|
|
+ long addressId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
|
|
+ loadOrderAddress.setId(addressId);
|
|
|
|
|
+ loadOrderAddress.setAddressType(NumberConstant.ONE);
|
|
|
|
|
+ loadOrderAddress.setTAddressId(loadAddressData.getTAddressId() == null ? null : loadAddressData.getTAddressId());
|
|
|
|
|
+ loadOrderAddress.setPAddressId(loadAddressData.getId());
|
|
|
|
|
+ loadOrderAddress.setDetailAddress(loadAddressData.getDetailAddress());
|
|
|
|
|
+ loadOrderAddress.setContacts(loadAddressData.getContacts());
|
|
|
|
|
+ loadOrderAddress.setLOrderId(orderId);
|
|
|
|
|
+ loadOrderAddress.setLat(loadAddressData.getLat());
|
|
|
|
|
+ loadOrderAddress.setFence(loadAddressData.getFence());
|
|
|
|
|
+ loadOrderAddress.setCityName(loadAddressData.getCityName());
|
|
|
|
|
+ loadOrderAddress.setEntryType(NumberConstant.FOUR);
|
|
|
|
|
+ loadOrderAddress.setCreateTime(new Date());
|
|
|
|
|
+ loadOrderAddress.setPhone(loadAddressData.getPhone());
|
|
|
|
|
+ loadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ loadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ loadOrderAddress.setUpdateTime(new Date());
|
|
|
|
|
+ loadOrderAddress.setName(loadAddressData.getName());
|
|
|
|
|
+ loadOrderAddress.setType(loadAddressData.getType());
|
|
|
|
|
+ loadOrderAddress.setCityCode(loadAddressData.getCityCode());
|
|
|
|
|
+ loadOrderAddress.setLng(loadAddressData.getLng());
|
|
|
|
|
+ loadOrderAddress.setRemark(loadAddressData.getRemark());
|
|
|
|
|
+ loadOrderAddress.setStatus(loadAddressData.getStatus());
|
|
|
|
|
+ logisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
|
|
|
+
|
|
|
|
|
+ KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
|
|
+ BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
|
|
+ orderAmount.setLOrderId(orderId);
|
|
|
|
|
+ orderAmount.setLAddressId(addressId);
|
|
|
|
|
+ orderAmount.setAmount(address.getAmount());
|
|
|
|
|
+ orderAmount.setSubcontractAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setEntrustAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setLoadAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setUnloadAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setIgnoreAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setId(new IdWorker(NumberConstant.THREE).nextId());
|
|
|
|
|
+ orderAmount.setStatus(0);
|
|
|
|
|
+ orderAmount.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ orderAmount.setCreateTime(new Date());
|
|
|
|
|
+ orderAmount.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ orderAmount.setUpdateTime(new Date());
|
|
|
|
|
+ orderAmount.setDelFlag(0);
|
|
|
|
|
+ logisticsOrderAmountMapper.insert(orderAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ /**处理卸货*/
|
|
|
|
|
+ List<AddressInfoDto> unloadAddress = addressMap.get(NumberConstant.TWO);
|
|
|
|
|
+ List<String> unloadAddressIds = unloadAddress.stream().map(AddressInfoDto::getAddressId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ List<KwtLogisticsOrderAddress> orderUnLoadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
|
|
+ .eq(KwtLogisticsOrderAddress::getLOrderId, logisticsOrder.getId())
|
|
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO)
|
|
|
|
|
+ .in(KwtLogisticsOrderAddress::getId, unloadAddressIds)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Long, KwtLogisticsOrderAddress> parentUnloadOrderMap = new HashMap<Long, KwtLogisticsOrderAddress>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(orderUnLoadAddress)) {
|
|
|
|
|
+ parentUnloadOrderMap = orderUnLoadAddress.stream().collect(Collectors.toMap(KwtLogisticsOrderAddress::getId, Function.identity()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(unloadAddress)) {
|
|
|
|
|
+ for (AddressInfoDto address : unloadAddress) {
|
|
|
|
|
+ if (address.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (parentLoadOrderMap.get(address.getAddressId()) != null) {
|
|
|
|
|
+ KwtLogisticsOrderAddress loadAddressData = parentLoadOrderMap.get(address.getAddressId());
|
|
|
|
|
+ KwtLogisticsOrderAddress unloadOrderAddress = new KwtLogisticsOrderAddress();
|
|
|
|
|
+ long addressId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
|
|
+ unloadOrderAddress.setId(addressId);
|
|
|
|
|
+ unloadOrderAddress.setAddressType(NumberConstant.TWO);
|
|
|
|
|
+ unloadOrderAddress.setTAddressId(loadAddressData.getTAddressId() == null ? null : loadAddressData.getTAddressId());
|
|
|
|
|
+ unloadOrderAddress.setPAddressId(loadAddressData.getId());
|
|
|
|
|
+ unloadOrderAddress.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
|
|
+ unloadOrderAddress.setContacts(loadAddressData.getContacts());
|
|
|
|
|
+ unloadOrderAddress.setLOrderId(orderId);
|
|
|
|
|
+ unloadOrderAddress.setLat(loadAddressData.getLat());
|
|
|
|
|
+ unloadOrderAddress.setFence(loadAddressData.getFence());
|
|
|
|
|
+ unloadOrderAddress.setCityName(loadAddressData.getCityName());
|
|
|
|
|
+ unloadOrderAddress.setEntryType(NumberConstant.FOUR);
|
|
|
|
|
+ unloadOrderAddress.setPhone(loadAddressData.getPhone());
|
|
|
|
|
+ unloadOrderAddress.setDetailAddress(loadAddressData.getDetailAddress());
|
|
|
|
|
+ unloadOrderAddress.setCreateTime(new Date());
|
|
|
|
|
+ unloadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ unloadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ unloadOrderAddress.setUpdateTime(new Date());
|
|
|
|
|
+ unloadOrderAddress.setName(loadAddressData.getName());
|
|
|
|
|
+ unloadOrderAddress.setType(loadAddressData.getType());
|
|
|
|
|
+ unloadOrderAddress.setCityCode(loadAddressData.getCityCode());
|
|
|
|
|
+ unloadOrderAddress.setLng(loadAddressData.getLng());
|
|
|
|
|
+ unloadOrderAddress.setRemark(loadAddressData.getRemark());
|
|
|
|
|
+ unloadOrderAddress.setStatus(loadAddressData.getStatus());
|
|
|
|
|
+ logisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
|
|
|
+
|
|
|
|
|
+ KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
|
|
+ BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
|
|
+ orderAmount.setLOrderId(orderId);
|
|
|
|
|
+ orderAmount.setLAddressId(addressId);
|
|
|
|
|
+ orderAmount.setAmount(address.getAmount());
|
|
|
|
|
+ orderAmount.setSubcontractAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setEntrustAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setLoadAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setUnloadAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setIgnoreAmount(defaultBigDecimal);
|
|
|
|
|
+ orderAmount.setId(new IdWorker(NumberConstant.THREE).nextId());
|
|
|
|
|
+ orderAmount.setStatus(0);
|
|
|
|
|
+ orderAmount.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ orderAmount.setCreateTime(new Date());
|
|
|
|
|
+ orderAmount.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ orderAmount.setUpdateTime(new Date());
|
|
|
|
|
+ orderAmount.setDelFlag(0);
|
|
|
|
|
+ logisticsOrderAmountMapper.insert(orderAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void insertSubcontractLogisticsOrderUnit(LogisticsOrderSubcontractDto bo, Long orderId) {
|
|
|
|
|
+ EntCacheResDto consignentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getAcceptCompanyId()));
|
|
|
|
|
+ EntCacheResDto checkentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getConsignCompanyId()));
|
|
|
|
|
+ KwtLogisticsOrderUnit checkUnit = new KwtLogisticsOrderUnit()
|
|
|
|
|
+ .setLOrderId(orderId)
|
|
|
|
|
+ .setId(new IdWorker(NumberConstant.ONE).nextId())
|
|
|
|
|
+ .setUnitType(NumberConstant.ONE)
|
|
|
|
|
+ .setFirmName(bo.getConsignCompany())
|
|
|
|
|
+ .setRemark(bo.getRemark())
|
|
|
|
|
+ .setTopEntId(checkentMap == null ? null : checkentMap.getId())
|
|
|
|
|
+ .setEntId(Long.parseLong(bo.getConsignCompanyId()))
|
|
|
|
|
+ .setContacts(bo.getConsignContacts())
|
|
|
|
|
+ .setPhone(bo.getConsignContactPhone())
|
|
|
|
|
+ .setCreateBy(LoginUserHolder.getUserId())
|
|
|
|
|
+ .setCreateTime(new Date())
|
|
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
|
|
+ .setUpdateTime(new Date())
|
|
|
|
|
+ .setContactsId(Long.parseLong(bo.getConsignContactsId()));
|
|
|
|
|
+ logisticsOrderUnitMapper.insert(checkUnit);
|
|
|
|
|
+
|
|
|
|
|
+ KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit()
|
|
|
|
|
+ .setLOrderId(orderId)
|
|
|
|
|
+ .setId(new IdWorker(NumberConstant.ONE).nextId())
|
|
|
|
|
+ .setUnitType(NumberConstant.TWO)
|
|
|
|
|
+ .setFirmName(bo.getAcceptCompany())
|
|
|
|
|
+ .setRemark(bo.getRemark())
|
|
|
|
|
+ .setTopEntId(consignentMap == null ? null : consignentMap.getId())
|
|
|
|
|
+ .setEntId(Long.parseLong(bo.getAcceptCompanyId()))
|
|
|
|
|
+ .setContacts(bo.getAcceptContacts())
|
|
|
|
|
+ .setPhone(bo.getAcceptContactPhone())
|
|
|
|
|
+ .setCreateBy(LoginUserHolder.getUserId())
|
|
|
|
|
+ .setCreateTime(new Date())
|
|
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
|
|
+ .setUpdateTime(new Date())
|
|
|
|
|
+ .setContactsId(Long.parseLong(bo.getAcceptContactsId()));
|
|
|
|
|
+ logisticsOrderUnitMapper.insert(consignUnit);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void insertSubcontractLogisticsOrderContract(LogisticsOrderSubcontractDto bo, Long orderId, ContractCommonInfoResDto infoResDto) {
|
|
|
|
|
+ KwtLogisticsOrderContract kwtLogisticsOrderContract = new KwtLogisticsOrderContract();
|
|
|
|
|
+ kwtLogisticsOrderContract.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
|
|
+ kwtLogisticsOrderContract.setLOrderId(orderId);
|
|
|
|
|
+ kwtLogisticsOrderContract.setContractId(Long.parseLong(bo.getContractId()));
|
|
|
|
|
+ kwtLogisticsOrderContract.setContractName(bo.getContractName() == null ? infoResDto.getContactName() : bo.getContractName());
|
|
|
|
|
+ kwtLogisticsOrderContract.setContractNo(bo.getContractNo() == null ? infoResDto.getContractCode() : bo.getContractNo());
|
|
|
|
|
+ kwtLogisticsOrderContract.setSigningWay(infoResDto.getSigningWay() != null ? String.valueOf(infoResDto.getSigningWay()) : null);
|
|
|
|
|
+ kwtLogisticsOrderContract.setRemark(bo.getRemark());
|
|
|
|
|
+ kwtLogisticsOrderContract.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ kwtLogisticsOrderContract.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ kwtLogisticsOrderContract.setCreateTime(new Date());
|
|
|
|
|
+ kwtLogisticsOrderContract.setUpdateTime(new Date());
|
|
|
|
|
+ logisticsOrderContractMapper.insert(kwtLogisticsOrderContract);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分包托运-订单-主体
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bo 页面填写分包数据
|
|
|
|
|
+ * @param lOrderNo 当前分包物流订单编号
|
|
|
|
|
+ * @param order 当前物流订单数据
|
|
|
|
|
+ * @param orderId 当前订单主键id
|
|
|
|
|
+ * @param pids 组装的pids
|
|
|
|
|
+ * @param orderStatus 当前单据状态
|
|
|
|
|
+ * @param logisticsOrder 父级物流订单
|
|
|
|
|
+ */
|
|
|
|
|
+ private void insertSubcontractLogisticsOrder(LogisticsOrderSubcontractDto bo, String lOrderNo,
|
|
|
|
|
+ KwtLogisticsOrder order,
|
|
|
|
|
+ Long orderId, String pids, Integer orderStatus, KwtLogisticsOrder logisticsOrder) {
|
|
|
|
|
+ order.setId(orderId);
|
|
|
|
|
+ order.setEntId(LoginUserHolder.getEntId());
|
|
|
|
|
+ order.setType(logisticsOrder.getType());
|
|
|
|
|
+ order.setTOrderId(logisticsOrder.getTOrderId());
|
|
|
|
|
+ order.setTOrderNo(logisticsOrder.getTOrderNo());
|
|
|
|
|
+ order.setLOrderNo(lOrderNo);
|
|
|
|
|
+ //分包时,存放分包上级id
|
|
|
|
|
+ order.setPid(Long.parseLong(bo.getLOrderId()));
|
|
|
|
|
+ //存放所有的分包的父级id
|
|
|
|
|
+ order.setPids(pids);
|
|
|
|
|
+ order.setSettlementCycle(bo.getSettlementCycle());
|
|
|
|
|
+ order.setPrice(bo.getPrice());
|
|
|
|
|
+ order.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()) == null ?
|
|
|
|
|
+ null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()).getValue()));
|
|
|
|
|
+ order.setAmount(bo.getCarryingCapacity());
|
|
|
|
|
+ order.setBillingMode(bo.getBillingMode());
|
|
|
|
|
+ order.setLoss(bo.getLoss());
|
|
|
|
|
+ order.setLossUnit(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.UNIT_TYPE.getType(), bo.getLossUnit()) == null ?
|
|
|
|
|
+ null : remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.UNIT_TYPE.getType(), bo.getLossUnit()).getValue());
|
|
|
|
|
+ order.setGoodsPrice(bo.getGoodsPrice() == null ? null : bo.getGoodsPrice());
|
|
|
|
|
+ order.setGoodsPriceUnit(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getGoodsPriceUnit()) == null ?
|
|
|
|
|
+ null : remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getGoodsPriceUnit()).getValue());
|
|
|
|
|
+ order.setStartTime(bo.getStartTime() == null ? null : DateUtil.localDateToLocalDateTimeStart(bo.getStartTime()));
|
|
|
|
|
+ order.setEndTime(bo.getEndTime() == null ? null : DateUtil.localDateToLocalDateTimeEnd(bo.getEndTime()));
|
|
|
|
|
+ order.setRemark(bo.getRemark());
|
|
|
|
|
+ order.setPayment(Long.parseLong(bo.getPayment()));
|
|
|
|
|
+ order.setTaxRate(new BigDecimal(bo.getTaxRate()));
|
|
|
|
|
+ order.setCreateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ order.setCreateTime(new Date());
|
|
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
|
|
+ order.setStatus(orderStatus);
|
|
|
|
|
+ /**补充默认值*/
|
|
|
|
|
+ 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);
|
|
|
|
|
+ order.setTotalUnloadAmount(decimal);
|
|
|
|
|
+ order.setTotalLoadAmount(decimal);
|
|
|
|
|
+ order.setBindStatus(String.valueOf(NumberConstant.ZERO));
|
|
|
|
|
+ logisticsOrderMapper.insert(order);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param logisticsOrder 承运订单
|
|
|
|
|
+ * @description 当前承运订单所属分包层级
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/7/24
|
|
|
|
|
+ **/
|
|
|
|
|
+ public int logisticsLevel(KwtLogisticsOrder logisticsOrder) {
|
|
|
|
|
+ String pids = logisticsOrder.getPids();
|
|
|
|
|
+ String[] idArrays = StringUtils.isBlank(pids) ? new String[0] : pids.split(Global.COMMA);
|
|
|
|
|
+ return idArrays.length <= 1 ? Global.NUMERICAL_ONE : idArrays.length;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|