|
|
@@ -9,17 +9,23 @@ import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
+import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
import com.sckw.core.model.enums.OrderRuleEnum;
|
|
|
import com.sckw.core.model.enums.RedisOrderGenerateEnum;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.OrderGenerateSeqNoUtils;
|
|
|
+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.excel.utils.DateUtil;
|
|
|
+import com.sckw.excel.utils.ValidUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
import com.sckw.manage.api.RemoteManageService;
|
|
|
+import com.sckw.manage.api.model.dto.res.EntAddressResDto;
|
|
|
+import com.sckw.manage.api.model.dto.res.FindEntCooperateResVo;
|
|
|
import com.sckw.manage.api.model.dto.res.LineFreightAddressRes;
|
|
|
import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
|
import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
|
@@ -39,12 +45,15 @@ 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.param.AddLogisticsOrderParam;
|
|
|
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.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
@@ -103,29 +112,32 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
public KwtLogisticsOrderLineFreightRateMapper logisticsOrderLineFreightRateMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderContractMapper kwtLogisticsOrderContractMapper;
|
|
|
+ public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderAddressMapper kwtLogisticsOrderAddressMapper;
|
|
|
+ public KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
|
|
|
|
|
|
@Autowired
|
|
|
public KwtLogisticsOrderAmountMapper logisticsOrderAmountMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderTrackMapper kwtLogisticsOrderTrackMapper;
|
|
|
+ public KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderGoodsMapper kwtLogisticsOrderGoodsMapper;
|
|
|
+ public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderUnitMapper kwtLogisticsOrderUnitMapper;
|
|
|
+ public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public KwtLogisticsOrderMapper kwtLogisticsOrderMapper;
|
|
|
+ public KwtLogisticsOrderMapper logisticsOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
|
public KwtWaybillOrderMapper waybillOrderMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderGoodsMapper goodsMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 采购订单/销售订单-物流托运-4.2
|
|
|
*
|
|
|
@@ -133,7 +145,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
*/
|
|
|
public void logisticsConsignmentSave(LogisticsConsignmentDto dto) {
|
|
|
commonService.getRedisGenerateOrderNo();
|
|
|
- Long count = kwtLogisticsOrderMapper.selectCount(new LambdaQueryWrapper<KwtLogisticsOrder>().eq(KwtLogisticsOrder::getTOrderId, dto.getTOrderId()));
|
|
|
+ Long count = logisticsOrderMapper.selectCount(new LambdaQueryWrapper<KwtLogisticsOrder>().eq(KwtLogisticsOrder::getTOrderId, dto.getTOrderId()));
|
|
|
String lOrderNo = OrderGenerateSeqNoUtils.getSeqNo(RedisOrderGenerateEnum.LOGISTICS_ORDER, OrderRuleEnum.LOGISTICS_ORDER, "1", "0", String.valueOf(count + 1));
|
|
|
OrderDetailRes tradeOrder = tradeOrderInfoService.getOrderDetailById(Long.parseLong(dto.getTOrderId()));
|
|
|
if (tradeOrder == null) {
|
|
|
@@ -229,7 +241,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
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->{
|
|
|
+ lineFreightId.stream().forEach(id -> {
|
|
|
if (resMap.get(id) != null) {
|
|
|
LineFreightAddressRes res = resMap.get(id);
|
|
|
KwtLogisticsOrderLineFreightRate lineFreightRate = new KwtLogisticsOrderLineFreightRate();
|
|
|
@@ -405,7 +417,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
entity.setCreateBy(LoginUserHolder.getUserId());
|
|
|
entity.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
entity.setRemark(dto.getRemark());
|
|
|
- kwtLogisticsOrderTrackMapper.insert(entity);
|
|
|
+ logisticsOrderTrackMapper.insert(entity);
|
|
|
}
|
|
|
|
|
|
private void saveLogisticsOrderAddressAndAmount(LogisticsConsignmentDto dto, Long orderId) {
|
|
|
@@ -445,7 +457,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
loadOrderAddress.setCityCode(detail.getCityCode());
|
|
|
loadOrderAddress.setLng(detail.getLng());
|
|
|
loadOrderAddress.setSort(addressInfoDto.getSort());
|
|
|
- kwtLogisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
|
+ logisticsOrderAddressMapper.insert(loadOrderAddress);
|
|
|
|
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
@@ -488,7 +500,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
unloadOrderAddress.setCityCode(detail.getCityCode());
|
|
|
unloadOrderAddress.setLng(detail.getLng());
|
|
|
unloadOrderAddress.setSort(addressInfoDto.getSort());
|
|
|
- kwtLogisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
|
+ logisticsOrderAddressMapper.insert(unloadOrderAddress);
|
|
|
|
|
|
KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
@@ -660,7 +672,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
.setUpdateBy(LoginUserHolder.getUserId())
|
|
|
.setUpdateTime(new Date())
|
|
|
.setContactsId(Long.parseLong(dto.getCheckContactsId()));
|
|
|
- kwtLogisticsOrderUnitMapper.insert(checkUnit);
|
|
|
+ logisticsOrderUnitMapper.insert(checkUnit);
|
|
|
|
|
|
KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit()
|
|
|
.setLOrderId(orderId)
|
|
|
@@ -677,7 +689,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
.setUpdateBy(LoginUserHolder.getUserId())
|
|
|
.setUpdateTime(new Date())
|
|
|
.setContactsId(Long.parseLong(dto.getConsignContactsId()));
|
|
|
- kwtLogisticsOrderUnitMapper.insert(consignUnit);
|
|
|
+ logisticsOrderUnitMapper.insert(consignUnit);
|
|
|
}
|
|
|
|
|
|
private void saveLogisticsOrderContract(LogisticsConsignmentDto dto, Long orderId) {
|
|
|
@@ -701,7 +713,7 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
kwtLogisticsOrderContract.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
kwtLogisticsOrderContract.setCreateTime(new Date());
|
|
|
kwtLogisticsOrderContract.setUpdateTime(new Date());
|
|
|
- kwtLogisticsOrderContractMapper.insert(kwtLogisticsOrderContract);
|
|
|
+ logisticsOrderContractMapper.insert(kwtLogisticsOrderContract);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -753,6 +765,597 @@ public class KwtLogisticsOrderConsignmentService {
|
|
|
order.setTotalUnloadAmount(decimal);
|
|
|
order.setTotalLoadAmount(decimal);
|
|
|
order.setBindStatus(String.valueOf(NumberConstant.ZERO));
|
|
|
- kwtLogisticsOrderMapper.insert(order);
|
|
|
+ logisticsOrderMapper.insert(order);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物流订单-自建订单-v4.2
|
|
|
+ *
|
|
|
+ * @param addLogisticsOrderParam
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public HttpResult addLogisticsOrder(AddLogisticsOrderParam addOrderDTO) {
|
|
|
+ commonService.getRedisGenerateOrderNo();
|
|
|
+ /**生成订单编号*/
|
|
|
+ String lOrderNo = OrderGenerateSeqNoUtils.getSeqNo(RedisOrderGenerateEnum.LOGISTICS_ORDER, OrderRuleEnum.LOGISTICS_ORDER, "2", "0", "0");
|
|
|
+ HttpResult httpResult = ValidUtil.serviceValid(addOrderDTO);
|
|
|
+ if (!String.valueOf(HttpStatus.SUCCESS_CODE).equals(String.valueOf(httpResult.getCode()))) {
|
|
|
+ return HttpResult.error(httpResult.getMsg());
|
|
|
+ }
|
|
|
+ checkCreateLogisticOrderParam(addOrderDTO);
|
|
|
+ String consignCompanyId = addOrderDTO.getConsignCompanyId();
|
|
|
+ String acceptCompanyId = addOrderDTO.getAcceptCompanyId();
|
|
|
+ List<FindEntCooperateResVo> entCooperate = manageService.findEntCooperate(Long.parseLong(consignCompanyId), Long.parseLong(acceptCompanyId), CooperateTypeEnum.CARRIAGE.getCode());
|
|
|
+// if (CollectionUtils.isEmpty(entCooperate)) {
|
|
|
+// return HttpResult.error("该承运企业与我方企业并无合作关系!");
|
|
|
+// }
|
|
|
+ /**保存新建数据*/
|
|
|
+ Long lOrderId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ /**根据合同计算当前单据状态*/
|
|
|
+ /**判断生成物流订单应生成哪一种单据状态*/
|
|
|
+ List<Long> contractList = new ArrayList<>();
|
|
|
+ contractList.add(Long.parseLong(addOrderDTO.getContractId()));
|
|
|
+ Map<Long, ContractCommonInfoResDto> longContractCommonInfoResDtoMap = contractService.queryContractBaseInfo(contractList);
|
|
|
+ if (CollectionUtils.isEmpty(longContractCommonInfoResDtoMap)) {
|
|
|
+ throw new BusinessException("新建订单-并未有对应合同,应先签约合同");
|
|
|
+ }
|
|
|
+ if (longContractCommonInfoResDtoMap.get(Long.parseLong(addOrderDTO.getContractId())) == null) {
|
|
|
+ throw new BusinessException("新建订单-并未有对应合同,应先签约合同");
|
|
|
+ }
|
|
|
+ ContractCommonInfoResDto infoResDto = longContractCommonInfoResDtoMap.get(Long.parseLong(addOrderDTO.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.WAIT_DELIVERY.getCode();
|
|
|
+ } else {
|
|
|
+ log.info("创建订单异常");
|
|
|
+ throw new BusinessException("自建订单异常");
|
|
|
+ }
|
|
|
+ /**数据保存*/
|
|
|
+ saveCreateLogisticsOrder(addOrderDTO, lOrderId, orderStatus, lOrderNo);
|
|
|
+ saveCreateLogisticsOrderAddressAndAmount(addOrderDTO, lOrderId);
|
|
|
+ saveConsignLogisticsOrderGoods(addOrderDTO, lOrderId, lOrderNo);
|
|
|
+ saveCreateLogisticsOrderContract(addOrderDTO, lOrderId, infoResDto);
|
|
|
+ saveCreateLogisticsOrderTrack(lOrderId, orderStatus);
|
|
|
+ saveCreateLogisticsOrderUnit(addOrderDTO, lOrderId);
|
|
|
+ if ("4".equals(addOrderDTO.getBillingMode())) {
|
|
|
+ saveCreateLogisticsOrderLineFreight(addOrderDTO, lOrderId);
|
|
|
+ }
|
|
|
+ /**保存mongodb*/
|
|
|
+ saveCreateLogisticsOrderToMongoDb(addOrderDTO, orderStatus, lOrderId, lOrderNo, infoResDto);
|
|
|
+ /**消息主体*/
|
|
|
+ String type = addOrderDTO.getType();
|
|
|
+ if (type.equals("1")) {
|
|
|
+ logisticsOrderPush(addOrderDTO, lOrderNo, LoginUserHolder.getUserId(), LoginUserHolder.getEntId());
|
|
|
+ } else if (type.equals("2")) {
|
|
|
+ //托运单位
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(Long.parseLong(addOrderDTO.getConsignCompanyId()));
|
|
|
+ KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit();
|
|
|
+ consignUnit.setUnitType(NumberConstant.ONE);
|
|
|
+ consignUnit.setEntId(Long.parseLong(addOrderDTO.getConsignCompanyId()));
|
|
|
+ consignUnit.setTopEntId(entCacheResDto == null ? null : entCacheResDto.getId());
|
|
|
+ consignUnit.setFirmName(addOrderDTO.getConsignCompany());
|
|
|
+ consignUnit.setContactsId(Long.parseLong(addOrderDTO.getConsignContactsId()));
|
|
|
+ //承运单位
|
|
|
+ EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntCacheById(Long.parseLong(addOrderDTO.getAcceptCompanyId()));
|
|
|
+ KwtLogisticsOrderUnit carriageUnit = new KwtLogisticsOrderUnit();
|
|
|
+ carriageUnit.setUnitType(NumberConstant.TWO);
|
|
|
+ carriageUnit.setEntId(Long.parseLong(addOrderDTO.getAcceptCompanyId()));
|
|
|
+ carriageUnit.setTopEntId(entCacheResDto1 == null ? null : entCacheResDto1.getId());
|
|
|
+ carriageUnit.setFirmName(addOrderDTO.getAcceptCompany());
|
|
|
+ carriageUnit.setContactsId(Long.parseLong(addOrderDTO.getAcceptContactsId()));
|
|
|
+ commonService.newSendLogisticsOrderToMessage(consignUnit, carriageUnit, lOrderNo, LoginUserHolder.getUserId(), LoginUserHolder.getEntId()
|
|
|
+ , messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl()
|
|
|
+ , messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl()
|
|
|
+ , MessageEnum.NEW_LOGISTICS_ORDER, MessageEnum.NEW_CARRIAGE_ORDER
|
|
|
+ , "1"
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveCreateLogisticsOrderLineFreight(AddLogisticsOrderParam addOrderDTO, Long lOrderId) {
|
|
|
+ List<LineFreightDto> lineFreightList = addOrderDTO.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(lOrderId);
|
|
|
+ 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 saveCreateLogisticsOrderToMongoDb(AddLogisticsOrderParam orderDTO, Integer orderStatus, Long lOrderId, String lOrderNo, ContractCommonInfoResDto infoResDto) {
|
|
|
+ SckwLogisticsOrder order = new SckwLogisticsOrder();
|
|
|
+ order.set_id(lOrderId);
|
|
|
+ order.setLOrderId(lOrderId);
|
|
|
+ order.setLOrderNo(lOrderNo);
|
|
|
+ order.setLOrderPid(null);
|
|
|
+ order.setLOrderPids(String.valueOf(lOrderId));
|
|
|
+ order.setType(NumberConstant.TWO);
|
|
|
+ order.setSettlementCycle(orderDTO.getSettlementCycle());
|
|
|
+ order.setPrice(orderDTO.getPrice());
|
|
|
+ order.setPriceType(order.getPriceType());
|
|
|
+ order.setAmount(orderDTO.getAmount());
|
|
|
+ order.setUnit(orderDTO.getAmountUnit());
|
|
|
+ order.setLoss(orderDTO.getLoss());
|
|
|
+ order.setLossUnit(orderDTO.getLossUnit());
|
|
|
+ order.setGoodsPrice(orderDTO.getGoodsPrice() == null ? null : orderDTO.getGoodsPrice());
|
|
|
+ order.setGoodsPriceUnit(orderDTO.getGoodsPriceUnit());
|
|
|
+ BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
|
|
|
+ order.setSubcontractAmount(decimal);
|
|
|
+ order.setEntrustAmount(decimal);
|
|
|
+ order.setUnloadAmount(decimal);
|
|
|
+ order.setLoadAmount(decimal);
|
|
|
+ order.setIgnoreAmount(decimal);
|
|
|
+ order.setDeficitAmount(decimal);
|
|
|
+ order.setDeficitPrice(decimal);
|
|
|
+ order.setPayment(orderDTO.getPayment());
|
|
|
+ order.setTaxRate(orderDTO.getTaxRate());
|
|
|
+ order.setRemark(orderDTO.getRemark());
|
|
|
+ order.setStatus(String.valueOf(orderStatus));
|
|
|
+ order.setEntId(LoginUserHolder.getEntId());
|
|
|
+ order.setFirmName(LoginUserHolder.getEntName());
|
|
|
+// order.setGoodsId(Long.parseLong(orderDTO.getGoodsId()));
|
|
|
+// order.setGoodsCode(goods == null ? null : goods.getCode());
|
|
|
+ order.setGoodsName(orderDTO.getGoodsName());
|
|
|
+// order.setGoodsType(goods == null ? null : goods.getGoodsType());
|
|
|
+//// order.setGoodsIndustry(goods == null ? null : goods.get);
|
|
|
+// order.setGoodsSpec(goods == null ? null : goods.getSpec());
|
|
|
+ order.setContractId(orderDTO.getContractId());
|
|
|
+ order.setContractNo(infoResDto.getContractCode());
|
|
|
+ order.setContractName(infoResDto.getContactName());
|
|
|
+ order.setContractSigningWay(String.valueOf(infoResDto.getSigningWay()));
|
|
|
+ order.setCheckEntId(Long.parseLong(orderDTO.getConsignCompanyId()));
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(Long.parseLong(orderDTO.getConsignCompanyId())));
|
|
|
+ EntCacheResDto ent = entMap.get(Long.parseLong(orderDTO.getConsignCompanyId()));
|
|
|
+ if (Objects.isNull(ent)) {
|
|
|
+ throw new BusinessException("企业:" + orderDTO.getConsignCompany() + "的一级企业信息不存在!");
|
|
|
+ }
|
|
|
+ order.setCheckTopEntId(ent.getId());
|
|
|
+ order.setCheckFirmName(orderDTO.getConsignCompany());
|
|
|
+ order.setCheckContacts(orderDTO.getConsignContacts());
|
|
|
+ order.setCheckPhone(orderDTO.getConsignContactPhone());
|
|
|
+ order.setCarrierEntId(Long.parseLong(orderDTO.getAcceptCompanyId()));
|
|
|
+ Map<Long, EntCacheResDto> entMap1 = remoteSystemService.queryEntTreeByIds(Collections.singletonList(Long.parseLong(orderDTO.getAcceptCompanyId())));
|
|
|
+ EntCacheResDto ent1 = entMap1.get(Long.parseLong(orderDTO.getAcceptCompanyId()));
|
|
|
+ if (Objects.isNull(ent1)) {
|
|
|
+ throw new BusinessException("企业:" + orderDTO.getConsignCompany() + "的一级企业信息不存在!");
|
|
|
+ }
|
|
|
+ order.setCarrierTopEntId(ent1.getId());
|
|
|
+ order.setCarrierFirmName(orderDTO.getAcceptCompany());
|
|
|
+ order.setCarrierContacts(orderDTO.getAcceptContacts());
|
|
|
+ order.setCarrierPhone(orderDTO.getAcceptContactPhone());
|
|
|
+// order.setLoadType();
|
|
|
+// order.setLoadContacts(orderDTO.getLoadContacts());
|
|
|
+// order.setLoadPhone(orderDTO.getLoadPhone());
|
|
|
+// order.setLoadCityCode(orderDTO.getLoadCityCode());
|
|
|
+// order.setLoadCityName(orderDTO.getLoadCityName());
|
|
|
+// order.setLoadDetailAddress(orderDTO.getLoadDetailAddress());
|
|
|
+// order.setLoadLat(orderDTO.getLoadLat());
|
|
|
+// order.setLoadLng(orderDTO.getLoadLng());
|
|
|
+//// order.setUnloadType();
|
|
|
+// order.setUnloadContacts(orderDTO.getUnloadContacts());
|
|
|
+// order.setUnloadPhone(orderDTO.getUnloadPhone());
|
|
|
+// order.setUnloadCityCode(orderDTO.getUnloadCityCode());
|
|
|
+// order.setUnloadCityName(orderDTO.getUnloadCityName());
|
|
|
+// order.setUnloadDetailAddress(orderDTO.getUnloadDetailAddress());
|
|
|
+// order.setUnloadLat(orderDTO.getUnloadLat());
|
|
|
+// order.setUnloadLng(orderDTO.getUnloadLng());
|
|
|
+ order.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setCreateByName(LoginUserHolder.getUserName());
|
|
|
+ order.setCreateTime(new Date());
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
+// order.setWOrderNo(lOrderNo);
|
|
|
+ order.setCarryingCapacity(orderDTO.getAmount());
|
|
|
+ order.setBillingMode(orderDTO.getBillingMode());
|
|
|
+ order.setDelFlag(String.valueOf(NumberConstant.ZERO));
|
|
|
+ order.setStartTime(orderDTO.getStartTime() == null ? null : DateUtil.localDateToLocalDateTimeStart(orderDTO.getStartTime()));
|
|
|
+ order.setEndTime(orderDTO.getEndTime() == null ? null : DateUtil.localDateToLocalDateTimeEnd(orderDTO.getEndTime()));
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
+ busSum.setMethod(NumberConstant.ONE);
|
|
|
+ busSum.setObject(order);
|
|
|
+ streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveCreateLogisticsOrderUnit(AddLogisticsOrderParam orderDTO, Long lOrderId) {
|
|
|
+ //托运
|
|
|
+ KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit();
|
|
|
+ consignUnit.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ consignUnit.setLOrderId(lOrderId);
|
|
|
+ consignUnit.setUnitType(NumberConstant.ONE);
|
|
|
+ consignUnit.setEntId(Long.parseLong(orderDTO.getConsignCompanyId()));
|
|
|
+ List<Long> entIds = new ArrayList<>();
|
|
|
+ entIds.add(Long.parseLong(orderDTO.getConsignCompanyId()));
|
|
|
+ entIds.add(Long.parseLong(orderDTO.getAcceptCompanyId()));
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
|
|
|
+ EntCacheResDto ent = entMap.get(Long.parseLong(orderDTO.getConsignCompanyId()));
|
|
|
+ if (Objects.isNull(ent)) {
|
|
|
+ throw new BusinessException("企业:" + orderDTO.getConsignCompany() + "的一级企业信息不存在!");
|
|
|
+ }
|
|
|
+ consignUnit.setContactsId(Long.parseLong(orderDTO.getConsignContactsId()));
|
|
|
+ consignUnit.setTopEntId(ent.getId());
|
|
|
+ consignUnit.setFirmName(orderDTO.getConsignCompany());
|
|
|
+ consignUnit.setContacts(orderDTO.getConsignContacts());
|
|
|
+ consignUnit.setPhone(orderDTO.getConsignContactPhone());
|
|
|
+// consignUnit.setRemark(orderDTO.getRemark());
|
|
|
+ consignUnit.setStatus(NumberConstant.ZERO);
|
|
|
+ consignUnit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ consignUnit.setCreateTime(new Date());
|
|
|
+ consignUnit.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ consignUnit.setUpdateTime(new Date());
|
|
|
+ //承运
|
|
|
+ KwtLogisticsOrderUnit unit = new KwtLogisticsOrderUnit();
|
|
|
+ unit.setId(new IdWorker(NumberConstant.TWO).nextId());
|
|
|
+ unit.setLOrderId(lOrderId);
|
|
|
+ unit.setUnitType(NumberConstant.TWO);
|
|
|
+ unit.setEntId(Long.parseLong(orderDTO.getAcceptCompanyId()));
|
|
|
+ EntCacheResDto ent1 = entMap.get(Long.parseLong(orderDTO.getAcceptCompanyId()));
|
|
|
+ if (Objects.isNull(ent1)) {
|
|
|
+ throw new BusinessException("企业:" + orderDTO.getAcceptCompany() + "的一级企业信息不存在!");
|
|
|
+ }
|
|
|
+ unit.setContactsId(Long.parseLong(orderDTO.getAcceptContactsId()));
|
|
|
+ unit.setTopEntId(ent1.getId());
|
|
|
+ unit.setFirmName(orderDTO.getAcceptCompany());
|
|
|
+ unit.setContacts(orderDTO.getAcceptContacts());
|
|
|
+ unit.setPhone(orderDTO.getAcceptContactPhone());
|
|
|
+// unit.setRemark(orderDTO.getRemark());
|
|
|
+ unit.setStatus(NumberConstant.ZERO);
|
|
|
+ unit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ unit.setCreateTime(new Date());
|
|
|
+ unit.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ unit.setUpdateTime(new Date());
|
|
|
+ logisticsOrderUnitMapper.insert(consignUnit);
|
|
|
+ logisticsOrderUnitMapper.insert(unit);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveCreateLogisticsOrderTrack(Long lOrderId, Integer orderStatus) {
|
|
|
+ KwtLogisticsOrderTrack track = new KwtLogisticsOrderTrack();
|
|
|
+ track.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ track.setLOrderId(lOrderId);
|
|
|
+ track.setStatus(orderStatus);
|
|
|
+ track.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setCreateTime(new Date());
|
|
|
+ track.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setUpdateTime(new Date());
|
|
|
+ logisticsOrderTrackMapper.insert(track);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveCreateLogisticsOrderContract(AddLogisticsOrderParam orderDTO, Long lOrderId, ContractCommonInfoResDto infoResDto) {
|
|
|
+ KwtLogisticsOrderContract contract = new KwtLogisticsOrderContract();
|
|
|
+ contract.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ contract.setContractId(Long.parseLong(orderDTO.getContractId()));
|
|
|
+ contract.setLOrderId(lOrderId);
|
|
|
+ contract.setContractNo(orderDTO.getContractNo() == null ? infoResDto.getContractCode() : orderDTO.getContractNo());
|
|
|
+ contract.setContractName(orderDTO.getContractName() == null ? infoResDto.getContactName() : orderDTO.getContractName());
|
|
|
+ contract.setSigningWay(orderDTO.getSigningWay() == null ? String.valueOf(infoResDto.getSigningWay()) : orderDTO.getSigningWay());
|
|
|
+ contract.setStatus(NumberConstant.ZERO);
|
|
|
+ contract.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ contract.setCreateTime(new Date());
|
|
|
+ contract.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ contract.setUpdateTime(new Date());
|
|
|
+ logisticsOrderContractMapper.insert(contract);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveCreateLogisticsOrderAddressAndAmount(AddLogisticsOrderParam orderDTO, Long lOrderId) {
|
|
|
+ List<AddressInfoDto> addressInfo = orderDTO.getAddressInfo();
|
|
|
+ List<String> addressIds = addressInfo.stream().map(AddressInfoDto::getAddressId).collect(Collectors.toList());
|
|
|
+ Map<Long, EntAddressResDto> addressDetailMap = manageService.queryAddressListByAddressIdList(addressIds);
|
|
|
+ if (addressDetailMap.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
|
|
|
+ List<AddressInfoDto> loadAddressInfoDtos = addressMap.get(1);
|
|
|
+ loadAddressInfoDtos.forEach(address -> {
|
|
|
+ EntAddressResDto entAddressResDtos = addressDetailMap.get(Long.parseLong(address.getAddressId()));
|
|
|
+ if (entAddressResDtos.getId() != null) {
|
|
|
+ KwtLogisticsOrderAddress loadAddress = new KwtLogisticsOrderAddress();
|
|
|
+ long addressId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ loadAddress.setId(addressId);
|
|
|
+ loadAddress.setLOrderId(lOrderId);
|
|
|
+ loadAddress.setAddressType(NumberConstant.ONE);
|
|
|
+ loadAddress.setName(entAddressResDtos.getName() == null ? null : entAddressResDtos.getName());
|
|
|
+ loadAddress.setContacts(entAddressResDtos.getContacts());
|
|
|
+ loadAddress.setPhone(entAddressResDtos.getPhone());
|
|
|
+ loadAddress.setCityCode(entAddressResDtos.getCityCode());
|
|
|
+ loadAddress.setCityName(entAddressResDtos.getCityName());
|
|
|
+ loadAddress.setDetailAddress(entAddressResDtos.getDetailAddress());
|
|
|
+ loadAddress.setLat(entAddressResDtos.getLat());
|
|
|
+ loadAddress.setLng(entAddressResDtos.getLng());
|
|
|
+ loadAddress.setEntryType(NumberConstant.FOUR);
|
|
|
+ loadAddress.setStatus(NumberConstant.ZERO);
|
|
|
+ loadAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ loadAddress.setSort(address.getSort());
|
|
|
+ Date date = new Date();
|
|
|
+ loadAddress.setCreateTime(date);
|
|
|
+ loadAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ loadAddress.setUpdateTime(date);
|
|
|
+ logisticsOrderAddressMapper.insert(loadAddress);
|
|
|
+
|
|
|
+ KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
+ BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
+ orderAmount.setLOrderId(lOrderId);
|
|
|
+ orderAmount.setAddressId(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> unloadAddressInfoDtos = addressMap.get(2);
|
|
|
+ unloadAddressInfoDtos.forEach(address -> {
|
|
|
+ EntAddressResDto entAddressResDtos = addressDetailMap.get(Long.parseLong(address.getAddressId()));
|
|
|
+ if (entAddressResDtos.getId() != null) {
|
|
|
+ KwtLogisticsOrderAddress unloadAddress = new KwtLogisticsOrderAddress();
|
|
|
+ long addressId = new IdWorker(NumberConstant.ONE).nextId();
|
|
|
+ unloadAddress.setId(addressId);
|
|
|
+ unloadAddress.setLOrderId(lOrderId);
|
|
|
+ unloadAddress.setAddressType(NumberConstant.ONE);
|
|
|
+ unloadAddress.setName(entAddressResDtos.getName() == null ? null : entAddressResDtos.getName());
|
|
|
+ unloadAddress.setContacts(entAddressResDtos.getContacts());
|
|
|
+ unloadAddress.setPhone(entAddressResDtos.getPhone());
|
|
|
+ unloadAddress.setCityCode(entAddressResDtos.getCityCode());
|
|
|
+ unloadAddress.setCityName(entAddressResDtos.getCityName());
|
|
|
+ unloadAddress.setDetailAddress(entAddressResDtos.getDetailAddress());
|
|
|
+ unloadAddress.setLat(entAddressResDtos.getLat());
|
|
|
+ unloadAddress.setLng(entAddressResDtos.getLng());
|
|
|
+ unloadAddress.setEntryType(NumberConstant.FOUR);
|
|
|
+ unloadAddress.setStatus(NumberConstant.ZERO);
|
|
|
+ unloadAddress.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ unloadAddress.setSort(address.getSort());
|
|
|
+ Date date = new Date();
|
|
|
+ unloadAddress.setCreateTime(date);
|
|
|
+ unloadAddress.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ unloadAddress.setUpdateTime(date);
|
|
|
+ logisticsOrderAddressMapper.insert(unloadAddress);
|
|
|
+
|
|
|
+ KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
|
|
|
+ BigDecimal defaultBigDecimal = new BigDecimal("0.00");
|
|
|
+ orderAmount.setLOrderId(lOrderId);
|
|
|
+ orderAmount.setAddressId(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 saveCreateLogisticsOrder(AddLogisticsOrderParam orderDTO, Long lOrderId, Integer orderStatus, String lOrderNo) {
|
|
|
+ KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
+ order.setId(lOrderId);
|
|
|
+ order.setEntId(LoginUserHolder.getEntId());
|
|
|
+ order.setType(String.valueOf(NumberConstant.TWO));
|
|
|
+ order.setLOrderNo(lOrderNo);
|
|
|
+ order.setPids(lOrderId.toString());
|
|
|
+ order.setSettlementCycle(orderDTO.getSettlementCycle());
|
|
|
+ order.setBillingMode(orderDTO.getBillingMode());
|
|
|
+ order.setPrice(orderDTO.getPrice());
|
|
|
+ order.setPriceType(orderDTO.getPriceType());
|
|
|
+ order.setPayment(orderDTO.getPayment());
|
|
|
+ order.setAmount(orderDTO.getAmount());
|
|
|
+ order.setUnit(orderDTO.getAmountUnit());
|
|
|
+ order.setLoss(orderDTO.getLoss() == null ? null : orderDTO.getLoss());
|
|
|
+ order.setLossUnit(orderDTO.getLossUnit());
|
|
|
+ order.setGoodsPrice(orderDTO.getGoodsPrice() == null ? null : orderDTO.getGoodsPrice());
|
|
|
+ order.setGoodsPriceUnit(orderDTO.getGoodsPriceUnit());
|
|
|
+ order.setStartTime(org.apache.commons.lang3.ObjectUtils.isEmpty(orderDTO.getStartTime()) ?
|
|
|
+ null : DateUtil.localDateToLocalDateTimeStart(orderDTO.getStartTime()));
|
|
|
+ order.setEndTime(org.apache.commons.lang3.ObjectUtils.isEmpty(orderDTO.getEndTime()) ?
|
|
|
+ null : DateUtil.localDateToLocalDateTimeEnd(orderDTO.getEndTime()));
|
|
|
+ BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
|
|
|
+ order.setSubcontractAmount(decimal);
|
|
|
+ order.setEntrustAmount(decimal);
|
|
|
+ order.setUnloadAmount(decimal);
|
|
|
+ order.setLoadAmount(decimal);
|
|
|
+ order.setIgnoreAmount(decimal);
|
|
|
+ order.setDeficitAmount(decimal);
|
|
|
+ order.setDeficitPrice(decimal);
|
|
|
+ order.setTaxRate(orderDTO.getTaxRate());
|
|
|
+ order.setRemark(orderDTO.getRemark());
|
|
|
+ order.setStatus(orderStatus);
|
|
|
+ order.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setCreateTime(new Date());
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
+ order.setBindStatus(String.valueOf(NumberConstant.ZERO));
|
|
|
+ order.setTotalUnloadAmount(decimal);
|
|
|
+ order.setTotalLoadAmount(decimal);
|
|
|
+ logisticsOrderMapper.insert(order);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 物流订单-商品信息
|
|
|
+ *
|
|
|
+ * @param bo 页面请求数据
|
|
|
+ * @param orderId 物流订单表编号
|
|
|
+ * @param lOrderNo 物流订单编号
|
|
|
+ */
|
|
|
+ public void saveConsignLogisticsOrderGoods(AddLogisticsOrderParam bo, Long orderId, String lOrderNo) {
|
|
|
+ KwtLogisticsOrderGoods goods = new KwtLogisticsOrderGoods();
|
|
|
+ goods.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+// kwtLogisticsOrderGoods.setGoodsId(bo.getGoodsId());
|
|
|
+ goods.setGoodsName(bo.getGoodsName());
|
|
|
+ goods.setGoodsType(bo.getGoodsType());
|
|
|
+ goods.setSkuId(StringUtils.isBlank(bo.getSkuId()) ? null : bo.getSkuId());
|
|
|
+ goods.setLOrderId(orderId);
|
|
|
+ goods.setLOrderNo(lOrderNo);
|
|
|
+ goods.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ goods.setUpdateTime(new Date());
|
|
|
+ goods.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ goods.setCreateTime(new Date());
|
|
|
+ goodsMapper.insert(goods);
|
|
|
+
|
|
|
+// //辅助单位
|
|
|
+// List<GoodsUnitParam> assistUnit = bo.getAssistUnit();
|
|
|
+// if (CollectionUtils.isNotEmpty(assistUnit)) {
|
|
|
+// assistUnit.forEach(e -> {
|
|
|
+// KwtLogisticsOrderGoodsUnit unit = BeanUtils.copyProperties(e, KwtLogisticsOrderGoodsUnit.class);
|
|
|
+// unit.setGoodsId(kwtLogisticsOrderGoods.getGoodsId());
|
|
|
+// unit.setLOrderId(kwtLogisticsOrderGoods.getLOrderId());
|
|
|
+// unit.setUnit(unit.getFromUnit().equals(bo.getCarryingCapacityUnit()) ? unit.getToUnit() : unit.getFromUnit());
|
|
|
+// goodsUnitMapper.insert(unit);
|
|
|
+// });
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void logisticsOrderPush(AddLogisticsOrderParam addOrderDTO, String lOrderNo, Long createBy, Long entId) {
|
|
|
+ //发起方
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(Long.parseLong(addOrderDTO.getConsignCompanyId()));
|
|
|
+ KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit();
|
|
|
+ consignUnit.setUnitType(NumberConstant.ONE);
|
|
|
+ consignUnit.setEntId(Long.parseLong(addOrderDTO.getConsignCompanyId()));
|
|
|
+ consignUnit.setTopEntId(entCacheResDto == null ? null : entCacheResDto.getId());
|
|
|
+ consignUnit.setFirmName(addOrderDTO.getAcceptCompany());
|
|
|
+ consignUnit.setContactsId(Long.parseLong(addOrderDTO.getConsignContactsId()));
|
|
|
+
|
|
|
+ //接收方
|
|
|
+ EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntCacheById(Long.parseLong(addOrderDTO.getAcceptCompanyId()));
|
|
|
+ KwtLogisticsOrderUnit carriageUnit = new KwtLogisticsOrderUnit();
|
|
|
+ carriageUnit.setUnitType(NumberConstant.TWO);
|
|
|
+ carriageUnit.setEntId(Long.parseLong(addOrderDTO.getAcceptCompanyId()));
|
|
|
+ carriageUnit.setTopEntId(entCacheResDto1 == null ? null : entCacheResDto1.getId());
|
|
|
+ carriageUnit.setFirmName(addOrderDTO.getConsignCompany());
|
|
|
+ carriageUnit.setContactsId(Long.parseLong(addOrderDTO.getAcceptContactsId()));
|
|
|
+
|
|
|
+ sendLogisticsOrderToMessage(consignUnit, carriageUnit, lOrderNo, createBy, entId
|
|
|
+ , messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl(),
|
|
|
+ messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl(),
|
|
|
+ MessageEnum.NEW_LOGISTICS_ORDER, MessageEnum.NEW_CARRIAGE_ORDER, "1"
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起物流托运-[贸易订单物流托运确认/承运订单分包托运确认]
|
|
|
+ *
|
|
|
+ * @param consignUnit 托运单位
|
|
|
+ * @param carriageUnit 承运单位
|
|
|
+ * @param orderNo 单据号
|
|
|
+ * @param createBy 创建人
|
|
|
+ * @param entId 创建数据的企业id
|
|
|
+ * @param pcConsignUrl PC托运地址
|
|
|
+ * @param appConsignUrl app托运地址
|
|
|
+ * @param pcCarriageUrl PC承运地址
|
|
|
+ * @param appCarriageUrl app承运地址
|
|
|
+ * @param type 1代表给托运创建人发 2代表给承运创建人发
|
|
|
+ */
|
|
|
+ public void sendLogisticsOrderToMessage(KwtLogisticsOrderUnit consignUnit, KwtLogisticsOrderUnit carriageUnit,
|
|
|
+ String orderNo, Long createBy, Long entId,
|
|
|
+ String pcConsignUrl, String appConsignUrl,
|
|
|
+ String pcCarriageUrl, String appCarriageUrl,
|
|
|
+ MessageEnum consignMessageEnum,
|
|
|
+ MessageEnum carriageMessageEnum,
|
|
|
+ String type) {
|
|
|
+ boolean flag = createBy.equals(consignUnit.getContactsId()) || createBy.equals(carriageUnit.getContactsId());
|
|
|
+ Map<String, Object> map = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
+ map.put("orderNo", orderNo);
|
|
|
+ if (flag && createBy.equals(consignUnit.getContactsId())) {
|
|
|
+ commonService.sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
|
|
|
+ commonService.sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
|
|
|
+ } else if (flag && createBy.equals(carriageUnit.getContactsId())) {
|
|
|
+ commonService.sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
|
|
|
+ commonService.sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
|
|
|
+ } else {
|
|
|
+ commonService.sendLogisticsConsignMessage(consignUnit, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
|
|
|
+ commonService.sendLogisticsCarriageMessage(carriageUnit, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
|
|
|
+ if ("1".equals(type)) {
|
|
|
+ map.put("companyName", consignUnit.getFirmName());
|
|
|
+ commonService.sendLogisticsCreateByMessage(createBy, entId, map, pcConsignUrl, appConsignUrl, consignMessageEnum);
|
|
|
+ } else {
|
|
|
+ map.put("companyName", carriageUnit.getFirmName());
|
|
|
+ commonService.sendLogisticsCreateByMessage(createBy, entId, map, pcCarriageUrl, appCarriageUrl, carriageMessageEnum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验请求参数
|
|
|
+ *
|
|
|
+ * @param addLogisticsOrderParam
|
|
|
+ */
|
|
|
+ private void checkCreateLogisticOrderParam(AddLogisticsOrderParam addLogisticsOrderParam) {
|
|
|
+
|
|
|
+ if (!ObjectUtils.isEmpty(addLogisticsOrderParam.getTaxRate())) {
|
|
|
+ if (addLogisticsOrderParam.getTaxRate().compareTo(new BigDecimal(NumberConstant.ZERO)) < 0) {
|
|
|
+ throw new BusinessException("税率填写格式错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(addLogisticsOrderParam.getLoss())) {
|
|
|
+ if (addLogisticsOrderParam.getLoss().compareTo(new BigDecimal(NumberConstant.ZERO)) < 0) {
|
|
|
+ throw new BusinessException("合理损耗填写格式错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(addLogisticsOrderParam.getGoodsPrice())) {
|
|
|
+ if (addLogisticsOrderParam.getGoodsPrice().compareTo(new BigDecimal(NumberConstant.ZERO)) < 0) {
|
|
|
+ throw new BusinessException("扣亏货值填写格式错误!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|