|
|
@@ -1,7 +1,19 @@
|
|
|
package com.sckw.transport.service;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.sckw.core.common.enums.NumberConstant;
|
|
|
+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.transport.dao.*;
|
|
|
+import com.sckw.transport.model.*;
|
|
|
+import com.sckw.transport.model.dto.DocumentParamDTO;
|
|
|
+import com.sckw.transport.model.vo.OrderDetailVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
@@ -13,8 +25,33 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class TransportCommonService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public KwoTradeOrderMapper tradeOrderMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderMapper logisticsOrderMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwoTradeOrderAddressMapper tradeOrderAddressMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取托运企业名称
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -24,6 +61,7 @@ public class TransportCommonService {
|
|
|
|
|
|
/**
|
|
|
* 获取车牌号
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -33,6 +71,7 @@ public class TransportCommonService {
|
|
|
|
|
|
/**
|
|
|
* 获取联系人
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -42,6 +81,7 @@ public class TransportCommonService {
|
|
|
|
|
|
/**
|
|
|
* 获取司机
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -49,4 +89,89 @@ public class TransportCommonService {
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
+ public HttpResult getOrderDetail(DocumentParamDTO dto) {
|
|
|
+ HttpResult httpResult = new HttpResult();
|
|
|
+ httpResult.setCode(HttpStatus.SUCCESS_CODE);
|
|
|
+ if (String.valueOf(NumberConstant.FOUR).equals(dto.getDocumentType())) {
|
|
|
+ //托运订单
|
|
|
+ OrderDetailVO orderDetailVO = getOrderData(dto);
|
|
|
+ httpResult.setData(orderDetailVO);
|
|
|
+ } else if (String.valueOf(NumberConstant.THREE).equals(dto.getDocumentType())) {
|
|
|
+ //承运订单
|
|
|
+ OrderDetailVO orderDetailVO = getOrderData(dto);
|
|
|
+ httpResult.setData(orderDetailVO);
|
|
|
+ } else {
|
|
|
+ httpResult.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
+ httpResult.setMsg("单据类型错误");
|
|
|
+ }
|
|
|
+ return httpResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ private OrderDetailVO getOrderData(DocumentParamDTO dto) {
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, dto.getId())
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getDocumentNo()), KwtLogisticsOrder::getLOrderNo, dto.getDocumentNo())
|
|
|
+ .eq(KwtLogisticsOrder::getEntId, LoginUserHolder.getEntId()));
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ log.info("查无单据:{}", JSONObject.toJSONString(dto));
|
|
|
+ throw new RuntimeException("查无单据");
|
|
|
+
|
|
|
+ }
|
|
|
+ KwtLogisticsOrderContract contract = logisticsOrderContractMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderContract>()
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderContract::getLOrderId, dto.getId()));
|
|
|
+ KwtLogisticsOrderUnit unitOne = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderUnit::getLOrderId, dto.getId())
|
|
|
+ .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
|
|
|
+// .eq(KwtLogisticsOrderUnit::getEntId, logisticsOrder.getEntId()));
|
|
|
+ KwtLogisticsOrderUnit unitTwo = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderUnit::getLOrderId, dto.getId())
|
|
|
+ .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
|
|
|
+// .eq(KwtLogisticsOrderUnit::getEntId, logisticsOrder.getEntId()));
|
|
|
+ KwtLogisticsOrderAddress loadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderAddress::getLOrderId, dto.getId())
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
|
|
|
+ KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
|
|
|
+ .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderAddress::getLOrderId, dto.getId())
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
|
|
|
+ KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
|
|
|
+ .eq(StringUtils.isNotBlank(logisticsOrder.getId()), KwtLogisticsOrderGoods::getLOrderId, logisticsOrder.getId()));
|
|
|
+ OrderDetailVO orderDetailVO = new OrderDetailVO();
|
|
|
+ orderDetailVO.setId(String.valueOf(logisticsOrder.getId()));
|
|
|
+ if (contract != null) {
|
|
|
+ orderDetailVO.setContractId(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
|
|
|
+ //todo 接口调用合同服务查询合同信息
|
|
|
+// orderDetailVO.setContractName(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
|
|
|
+// orderDetailVO.setContractNo(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
|
|
|
+ }
|
|
|
+ if (unitOne != null) {
|
|
|
+ orderDetailVO.setConsignCompany(unitOne.getFirmName());
|
|
|
+ orderDetailVO.setConsignContacts(unitOne.getContacts());
|
|
|
+ orderDetailVO.setConsignPhone(unitOne.getPhone());
|
|
|
+ orderDetailVO.setCollectionCompany(unitOne.getFirmName());
|
|
|
+ }
|
|
|
+ if (unitTwo != null) {
|
|
|
+ orderDetailVO.setCarrierCompany(unitTwo.getFirmName());
|
|
|
+ orderDetailVO.setCarrierContacts(unitTwo.getContacts());
|
|
|
+ orderDetailVO.setCarrierPhone(unitTwo.getPhone());
|
|
|
+ }
|
|
|
+ orderDetailVO.setGoodsName(orderGoods == null ? null : orderGoods.getGoodsName());
|
|
|
+ orderDetailVO.setNumber(logisticsOrder.getAmount() == null ? null : String.valueOf(logisticsOrder.getAmount()));
|
|
|
+ orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : String.valueOf(logisticsOrder.getPrice()));
|
|
|
+ orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : String.valueOf(logisticsOrder.getLoss()));
|
|
|
+ orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : String.valueOf(logisticsOrder.getGoodsPrice()));
|
|
|
+ orderDetailVO.setLoadAddress(loadOrderAddress.getName());
|
|
|
+ orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
|
|
|
+ orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
|
|
|
+ orderDetailVO.setUnloadAddress(unloadOrderAddress.getName());
|
|
|
+ orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
|
|
|
+ orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
|
|
|
+ orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
|
|
|
+ orderDetailVO.setBillingMode(logisticsOrder.getBillingMode());
|
|
|
+ orderDetailVO.setScheduleStartTime(logisticsOrder.getStartTime() == null ? null : DateUtil.getDateTime(logisticsOrder.getStartTime()));
|
|
|
+ orderDetailVO.setScheduleEndTime(logisticsOrder.getEntTime() == null ? null : DateUtil.getDateTime(logisticsOrder.getEntTime()));
|
|
|
+ orderDetailVO.setPerformanceAmount(logisticsOrder.getLoadAmount() == null ? null : String.valueOf(logisticsOrder.getLoadAmount()));
|
|
|
+ return orderDetailVO;
|
|
|
+ }
|
|
|
}
|