|
|
@@ -9,13 +9,16 @@ import com.sckw.core.common.enums.NumberConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.enums.CarWaybillEnum;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
+import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
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.mongo.model.TableTops;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
import com.sckw.order.api.model.OrderDetailRes;
|
|
|
@@ -25,7 +28,9 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import com.sckw.transport.dao.*;
|
|
|
import com.sckw.transport.model.*;
|
|
|
+import com.sckw.transport.model.param.LogisticsOrderQuery;
|
|
|
import com.sckw.transport.model.param.ManagementLogisticsOrderQuery;
|
|
|
+import com.sckw.transport.model.vo.CarWaybillVO;
|
|
|
import com.sckw.transport.model.vo.ManagementLogsiticsOrderVO;
|
|
|
import com.sckw.transport.model.vo.OrderDetailVO;
|
|
|
import com.sckw.transport.model.vo.execlVo.ManagementLogisticsOrderExcelVo;
|
|
|
@@ -82,6 +87,12 @@ public class ManagementLogisticsOrderService {
|
|
|
@Autowired
|
|
|
public KwtWaybillOrderMapper waybillOrderMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public KwtWaybillOrderTrackMapper waybillOrderTrackMapper;
|
|
|
+
|
|
|
/**
|
|
|
* @param query
|
|
|
* @return
|
|
|
@@ -156,39 +167,28 @@ public class ManagementLogisticsOrderService {
|
|
|
vo.setStatusLabel(LogisticsOrderEnum.getName(vo.getStatus()));
|
|
|
vo.setLoadAddress(vo.getLoadCityName() + vo.getLoadAddress());
|
|
|
vo.setUnloadAddress(vo.getUnloadCityName() + vo.getUnloadAddress());
|
|
|
- if (vo.getTOrderId() != null) {
|
|
|
- OrderDetailRes orderDetailRes = tradeOrderInfoService.getOrderDetailById(Long.valueOf(vo.getTOrderId()));
|
|
|
- if (orderDetailRes != null) {
|
|
|
- List<UnitInfoDetailRes> unitInfo = orderDetailRes.getUnitInfo();
|
|
|
- for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
- if (String.valueOf(NumberConstant.ONE).equals(detailRes.getUnitType())) {
|
|
|
- vo.setShipmentsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
- vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
- } else {
|
|
|
- vo.setReceiveGoodsUnitEntId(String.valueOf(detailRes.getEntId()));
|
|
|
- vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
vo.setWaitDistributionAmount(vo.getCarryingCapacity().subtract(vo.getSubcontractAmount()).subtract(vo.getEntrustAmount()));
|
|
|
String tOrderId = vo.getTOrderId();
|
|
|
if (StringUtils.isNotBlank(tOrderId)) {
|
|
|
- OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
|
|
|
- if (orderDetailById != null) {
|
|
|
- List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
|
|
|
- if (CollectionUtils.isNotEmpty(unitInfo)) {
|
|
|
- for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
- if ("1".equals(detailRes.getUnitType())) {
|
|
|
- vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
- vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
- }
|
|
|
- if ("2".equals(detailRes.getUnitType())) {
|
|
|
- vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
- vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
+ try {
|
|
|
+ OrderDetailRes orderDetailById = tradeOrderInfoService.getOrderDetailById(Long.parseLong(tOrderId));
|
|
|
+ if (orderDetailById != null) {
|
|
|
+ List<UnitInfoDetailRes> unitInfo = orderDetailById.getUnitInfo();
|
|
|
+ if (CollectionUtils.isNotEmpty(unitInfo)) {
|
|
|
+ for (UnitInfoDetailRes detailRes : unitInfo) {
|
|
|
+ if ("1".equals(detailRes.getUnitType())) {
|
|
|
+ vo.setReceiveGoodsUnit(detailRes.getFirmName());
|
|
|
+ vo.setReceiveGoodsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
+ }
|
|
|
+ if ("2".equals(detailRes.getUnitType())) {
|
|
|
+ vo.setShipmentsUnit(detailRes.getFirmName());
|
|
|
+ vo.setShipmentsUnitEntId(detailRes.getEntId() == null ? null : detailRes.getEntId().toString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ System.out.println("查询贸易订单失败!" + tOrderId + ";" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -537,4 +537,98 @@ public class ManagementLogisticsOrderService {
|
|
|
httpResult.setData(orderDetailVO);
|
|
|
return httpResult;
|
|
|
}
|
|
|
+
|
|
|
+ public HttpResult getCarWaybillByOrder(LogisticsOrderQuery orderDto) {
|
|
|
+ List<Long> list = StringUtils.splitStrToList(orderDto.getIds(), Long.class);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+ List<CarWaybillVO> returnList = new ArrayList<>();
|
|
|
+ list = list.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
|
|
|
+ for (Long id : list) {
|
|
|
+ KwtLogisticsOrder order = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(StringUtils.isNotBlank(id), KwtLogisticsOrder::getId, id)
|
|
|
+ );
|
|
|
+ if (ObjectUtils.isEmpty(order)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<KwtWaybillOrder> kwtWaybillOrders = waybillOrderMapper.selectList(new LambdaQueryWrapper<KwtWaybillOrder>()
|
|
|
+ .eq(StringUtils.isNotBlank(order.getId()), KwtWaybillOrder::getLOrderId, order.getId())
|
|
|
+ .orderByDesc(KwtWaybillOrder::getCreateTime));
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(kwtWaybillOrders)) {
|
|
|
+ for (KwtWaybillOrder kwtWaybillOrder : kwtWaybillOrders) {
|
|
|
+ CarWaybillVO carWaybillVo = new CarWaybillVO();
|
|
|
+ KwtWaybillOrderTicket loadTicket = waybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
|
|
|
+ .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
|
|
|
+ .eq(KwtWaybillOrderTicket::getType, NumberConstant.ONE));
|
|
|
+ KwtWaybillOrderTicket unloadTicket = waybillOrderTicketMapper.selectOne(new LambdaQueryWrapper<KwtWaybillOrderTicket>()
|
|
|
+ .eq(StringUtils.isNotBlank(kwtWaybillOrder.getId()), KwtWaybillOrderTicket::getWOrderId, kwtWaybillOrder.getId())
|
|
|
+ .eq(KwtWaybillOrderTicket::getType, NumberConstant.TWO));
|
|
|
+ //合理损耗
|
|
|
+ BigDecimal loss = order.getLoss() == null ? new BigDecimal("0.00") : order.getLoss();
|
|
|
+ /**亏吨量/吨->装货量-卸货量
|
|
|
+ * 合理损耗值=装货量*合理损耗
|
|
|
+ 扣亏量/吨->亏吨量-合理损耗值
|
|
|
+ */
|
|
|
+ BigDecimal loadAmount = kwtWaybillOrder.getLoadAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getLoadAmount();
|
|
|
+ //已委托量
|
|
|
+ BigDecimal entrustAmount = kwtWaybillOrder.getEntrustAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getEntrustAmount();
|
|
|
+ //合理损耗值
|
|
|
+ BigDecimal multiply = loadAmount.multiply(loss.divide(BigDecimal.valueOf(1000L)));
|
|
|
+ //亏吨量
|
|
|
+ BigDecimal defectiveWeigh = kwtWaybillOrder.getDeficitAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getDeficitAmount();
|
|
|
+ //扣亏量/吨
|
|
|
+ BigDecimal deduct = defectiveWeigh.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : defectiveWeigh.subtract(multiply);
|
|
|
+ carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
|
|
|
+ carWaybillVo.setWOrderNo(order.getLOrderNo());
|
|
|
+ carWaybillVo.setTruckNo(kwtWaybillOrder.getTruckNo());
|
|
|
+ carWaybillVo.setStatus(String.valueOf(kwtWaybillOrder.getStatus()));
|
|
|
+ carWaybillVo.setStatusLabel(CarWaybillEnum.getName(kwtWaybillOrder.getStatus()));
|
|
|
+ carWaybillVo.setWaybillType(kwtWaybillOrder.getType());
|
|
|
+ carWaybillVo.setDriverName(kwtWaybillOrder.getDriverName());
|
|
|
+ //todo 取mongo
|
|
|
+// SckwWaybillOrder sckwWaybillOrder = mongoTemplate.findById(kwtWaybillOrder.getId(), SckwWaybillOrder.class);
|
|
|
+ /** 2023-07-24 原值为承运车队-去除后更换展示为承运公司*/
|
|
|
+// carWaybillVo.setConsignMotorcade(sckwWaybillOrder == null ? null : sckwWaybillOrder.getCarrierFirmName());
|
|
|
+ //派车量
|
|
|
+ carWaybillVo.setSendCarWeigh(kwtWaybillOrder.getEntrustAmount() == null ? null : String.valueOf(kwtWaybillOrder.getEntrustAmount()));
|
|
|
+ carWaybillVo.setSendCarDate(DateUtil.getDateTime(kwtWaybillOrder.getCreateTime()));
|
|
|
+ if (loadTicket != null) {
|
|
|
+ carWaybillVo.setLoadAmount(loadTicket.getAmount() == null ? null : String.valueOf(loadTicket.getAmount()));
|
|
|
+ carWaybillVo.setLoadDateTime(loadTicket.getOperateTime() == null ? null : DateUtil.getDateTime(loadTicket.getOperateTime()));
|
|
|
+ } else {
|
|
|
+ carWaybillVo.setLoadAmount(null);
|
|
|
+ carWaybillVo.setLoadDateTime(null);
|
|
|
+ }
|
|
|
+ if (unloadTicket != null) {
|
|
|
+ carWaybillVo.setUnloadAmount(unloadTicket.getAmount() == null ? null : String.valueOf(unloadTicket.getAmount()));
|
|
|
+ carWaybillVo.setUnloadDateTime(unloadTicket.getOperateTime() == null ? null : DateUtil.getDateTime(unloadTicket.getOperateTime()));
|
|
|
+ } else {
|
|
|
+ carWaybillVo.setUnloadAmount(null);
|
|
|
+ carWaybillVo.setUnloadDateTime(null);
|
|
|
+ }
|
|
|
+ /**亏吨量/吨->装货量-卸货量
|
|
|
+ 扣亏量/吨->亏吨量-合理损耗*/
|
|
|
+ carWaybillVo.setDefectiveWeigh(kwtWaybillOrder.getDeficitAmount() == null ? null : String.valueOf(kwtWaybillOrder.getDeficitAmount()));
|
|
|
+ carWaybillVo.setDeduct(deduct);
|
|
|
+ carWaybillVo.setCreateTime(kwtWaybillOrder.getCreateTime());
|
|
|
+// carWaybillVo.setAppointor(remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()) == null ?
|
|
|
+// String.valueOf(kwtWaybillOrder.getCreateBy()) : remoteSystemService.queryUserCacheById(kwtWaybillOrder.getCreateBy()).getName());
|
|
|
+ carWaybillVo.setLOrderNo(order.getLOrderNo());
|
|
|
+ carWaybillVo.setLOrderId(String.valueOf(order.getId()));
|
|
|
+ carWaybillVo.setLoss(loss);
|
|
|
+ SysDictResDto sysDictResDto = remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.TAX_RATE_TYPE.getType(), order.getLossUnit());
|
|
|
+ carWaybillVo.setLossLabel(sysDictResDto == null ? null : sysDictResDto.getLabel());
|
|
|
+ returnList.add(carWaybillVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CarWaybillVO> collect = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(returnList)) {
|
|
|
+ collect = returnList.stream().skip((orderDto.getPage() - 1) * orderDto.getPageSize()).limit(orderDto.getPageSize()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ PageResult result = PageResult.build(orderDto.getPage(), orderDto.getPageSize(), returnList.stream().count(), collect);
|
|
|
+ return HttpResult.ok(result);
|
|
|
+ }
|
|
|
}
|