|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alibaba.nacos.shaded.io.grpc.StatusException;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -33,6 +32,7 @@ import com.sckw.core.web.response.result.PageDataResult;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.excel.utils.ValidUtil;
|
|
import com.sckw.excel.utils.ValidUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
|
|
+import com.sckw.fleet.api.model.vo.RFleetVo;
|
|
|
import com.sckw.fleet.api.model.vo.RTruckVo;
|
|
import com.sckw.fleet.api.model.vo.RTruckVo;
|
|
|
import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
import com.sckw.mongo.enums.BusinessTypeEnum;
|
|
|
import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
import com.sckw.mongo.model.SckwLogisticsOrder;
|
|
@@ -164,6 +164,7 @@ public class KwtLogisticsConsignmentService {
|
|
|
private final KwtLogisticsOrderContractRepository logisticsOrderContractRepository;
|
|
private final KwtLogisticsOrderContractRepository logisticsOrderContractRepository;
|
|
|
private final KwtWaybillOrderSubtaskRepository logisticsOrderSubtaskRepository;
|
|
private final KwtWaybillOrderSubtaskRepository logisticsOrderSubtaskRepository;
|
|
|
private final KwtWaybillOrderRepository waybillOrderRepository;
|
|
private final KwtWaybillOrderRepository waybillOrderRepository;
|
|
|
|
|
+ private final KwtLogisticsOrderCirculateRepository logisticsOrderCirculateRepository;
|
|
|
/**
|
|
/**
|
|
|
* 采购订单-物流托运生成托运订单
|
|
* 采购订单-物流托运生成托运订单
|
|
|
*
|
|
*
|
|
@@ -2325,21 +2326,34 @@ public class KwtLogisticsConsignmentService {
|
|
|
@NotNull
|
|
@NotNull
|
|
|
private Set<Long> getLogOrderIds(QueryLogisticsOrderReq req, Set<Long> entList) {
|
|
private Set<Long> getLogOrderIds(QueryLogisticsOrderReq req, Set<Long> entList) {
|
|
|
Set<Long> logOrderIds = Sets.newHashSet();
|
|
Set<Long> logOrderIds = Sets.newHashSet();
|
|
|
- List<KwtLogisticsOrderGoods> logisticsOrderGoodsList=
|
|
|
|
|
- logisticsOrderGoodsRepository.queryByGoodsName(req.getGoodsName());
|
|
|
|
|
- if(org.springframework.util.CollectionUtils.isEmpty(logisticsOrderGoodsList)){
|
|
|
|
|
- //获取物流订单
|
|
|
|
|
- Set<Long> logOrderFormGoodsIds =
|
|
|
|
|
- logisticsOrderGoodsList.stream().map(KwtLogisticsOrderGoods::getLOrderId).collect(Collectors.toSet());
|
|
|
|
|
- logOrderIds.addAll(logOrderFormGoodsIds);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<KwtLogisticsOrderUnit> logOrderUnits =logisticsOrderUnitRepository.queryByEntIds(entList);
|
|
|
|
|
- if(org.springframework.util.CollectionUtils.isEmpty(logOrderUnits)){
|
|
|
|
|
- //获取物流订单
|
|
|
|
|
- Set<Long> logOrderFormUnitIds =
|
|
|
|
|
- logOrderUnits.stream().map(KwtLogisticsOrderUnit::getLOrderId).collect(Collectors.toSet());
|
|
|
|
|
- logOrderIds.addAll(logOrderFormUnitIds);
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(req.getContractId())){
|
|
|
|
|
+ List<KwtLogisticsOrderContract> kwtLogisticsOrderContracts = logisticsOrderContractRepository.queryByContractId(Long.parseLong(req.getContractId()));
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(kwtLogisticsOrderContracts)){
|
|
|
|
|
+ logOrderIds.addAll(kwtLogisticsOrderContracts.stream()
|
|
|
|
|
+ .map(KwtLogisticsOrderContract::getLOrderId)
|
|
|
|
|
+ .collect(Collectors.toSet()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotBlank(req.getGoodsName())){
|
|
|
|
|
+ List<KwtLogisticsOrderGoods> logisticsOrderGoodsList=
|
|
|
|
|
+ logisticsOrderGoodsRepository.queryByGoodsName(req.getGoodsName());
|
|
|
|
|
+ if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(logisticsOrderGoodsList)){
|
|
|
|
|
+ //获取物流订单
|
|
|
|
|
+ Set<Long> logOrderFormGoodsIds =
|
|
|
|
|
+ logisticsOrderGoodsList.stream().map(KwtLogisticsOrderGoods::getLOrderId).collect(Collectors.toSet());
|
|
|
|
|
+ logOrderIds.addAll(logOrderFormGoodsIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(entList)){
|
|
|
|
|
+ List<KwtLogisticsOrderUnit> logOrderUnits =logisticsOrderUnitRepository.queryByEntIds(entList);
|
|
|
|
|
+ if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(logOrderUnits)){
|
|
|
|
|
+ //获取物流订单
|
|
|
|
|
+ Set<Long> logOrderFormUnitIds =
|
|
|
|
|
+ logOrderUnits.stream().map(KwtLogisticsOrderUnit::getLOrderId).collect(Collectors.toSet());
|
|
|
|
|
+ logOrderIds.addAll(logOrderFormUnitIds);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return logOrderIds;
|
|
return logOrderIds;
|
|
|
}
|
|
}
|
|
@@ -2348,15 +2362,16 @@ public class KwtLogisticsConsignmentService {
|
|
|
private Set<Long> getAllEnt(QueryLogisticsOrderReq req) {
|
|
private Set<Long> getAllEnt(QueryLogisticsOrderReq req) {
|
|
|
Set<Long> allEnt = Sets.newHashSet();
|
|
Set<Long> allEnt = Sets.newHashSet();
|
|
|
//根据企业类型查询企业
|
|
//根据企业类型查询企业
|
|
|
- if(StringUtils.isNotBlank(req.getEntId())){
|
|
|
|
|
- allEnt.add(Long.parseLong(req.getEntId()));
|
|
|
|
|
- EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(Long.parseLong(req.getEntId()));
|
|
|
|
|
- if (Objects.nonNull(entCacheResDto)) {
|
|
|
|
|
- EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntTreeById(entCacheResDto.getId());
|
|
|
|
|
- List<EntCacheResDto> child = entCacheResDto1.getChild();
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(child)) {
|
|
|
|
|
- allEnt.addAll(child.stream().filter(x->x.getEntTypes().contains(req.getEntType())).map(EntCacheResDto::getId).toList());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(req.getEntId())){
|
|
|
|
|
+ return allEnt;
|
|
|
|
|
+ }
|
|
|
|
|
+ allEnt.add(Long.parseLong(req.getEntId()));
|
|
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntTreeById(Long.parseLong(req.getEntId()));
|
|
|
|
|
+ if (Objects.nonNull(entCacheResDto)) {
|
|
|
|
|
+ EntCacheResDto entCacheResDto1 = remoteSystemService.queryEntTreeById(entCacheResDto.getId());
|
|
|
|
|
+ List<EntCacheResDto> child = entCacheResDto1.getChild();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(child)) {
|
|
|
|
|
+ allEnt.addAll(child.stream().filter(x->x.getEntTypes().contains(req.getEntType())).map(EntCacheResDto::getId).toList());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return allEnt;
|
|
return allEnt;
|
|
@@ -2649,4 +2664,100 @@ public class KwtLogisticsConsignmentService {
|
|
|
logisticsOrderDispatchResp.setCloseOrderDesc(CarStatusEnum.getName(truckVo.getStatus()));
|
|
logisticsOrderDispatchResp.setCloseOrderDesc(CarStatusEnum.getName(truckVo.getStatus()));
|
|
|
return logisticsOrderDispatchResp;
|
|
return logisticsOrderDispatchResp;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public PageDataResult<CapacityVo> pageCapacity(CapacityReq req) {
|
|
|
|
|
+ log.info("查询车辆列表请求:{}", JSON.toJSONString( req));
|
|
|
|
|
+ Long logOrderId = Long.parseLong(req.getLogOrderId());
|
|
|
|
|
+ Long entId = Long.parseLong(req.getEntId());
|
|
|
|
|
+ IPage<KwtLogisticsOrderCirculate> page = logisticsOrderCirculateRepository.queryByPage(req.getPageNum(),
|
|
|
|
|
+ req.getPageSize(), req.getTruckNo(),Long.parseLong(req.getEntId()));
|
|
|
|
|
+ List<KwtLogisticsOrderCirculate> records = page.getRecords();
|
|
|
|
|
+
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty( records)){
|
|
|
|
|
+ return PageDataResult.empty(req.getPageNum(), req.getPageSize());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Set<Long> truckIds = records.stream()
|
|
|
|
|
+ .map(KwtLogisticsOrderCirculate::getTruckId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+ List<RTruckVo> truckByTruckIds = remoteFleetService.findTruckByTruckIds(truckIds);
|
|
|
|
|
+ Map<Long, RTruckVo> truckIdAndTruckMap = Maps.newHashMap();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(truckByTruckIds)){
|
|
|
|
|
+ truckIdAndTruckMap = truckByTruckIds.stream()
|
|
|
|
|
+ .collect(Collectors.toMap(RTruckVo::getId, Function.identity(),(k1, k2)->k1));
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询子运单信息
|
|
|
|
|
+ List<KwtWaybillOrderSubtask> waybillOrderSubtasks = logisticsOrderSubtaskRepository.queryByLogId(logOrderId);
|
|
|
|
|
+ Set<Long> billOrderIds = Sets.newHashSet();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(waybillOrderSubtasks)){
|
|
|
|
|
+ //获取主运单id
|
|
|
|
|
+ billOrderIds = waybillOrderSubtasks.stream()
|
|
|
|
|
+ .map(KwtWaybillOrderSubtask::getWOrderId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询运单信息
|
|
|
|
|
+ Map<Long, List<KwtWaybillOrder>> billOrderIdAndWaybillOrderMap = Maps.newHashMap();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(billOrderIds)){
|
|
|
|
|
+ List<KwtWaybillOrder> waybillOrders = waybillOrderRepository.queryByBillOrderIdsAndEntId(billOrderIds,
|
|
|
|
|
+ entId);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(waybillOrders)){
|
|
|
|
|
+ billOrderIdAndWaybillOrderMap = waybillOrders.stream().filter(x->Objects.equals(x.getStatus(),
|
|
|
|
|
+ CarWaybillEnum.APPROVAL_PASS.getCode()))
|
|
|
|
|
+ .collect(Collectors.groupingBy(KwtWaybillOrder::getTruckId));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, RTruckVo> finalTruckIdAndTruckMap = truckIdAndTruckMap;
|
|
|
|
|
+ Map<Long, List<KwtWaybillOrder>> finalBillOrderIdAndWaybillOrderMap = billOrderIdAndWaybillOrderMap;
|
|
|
|
|
+ List<CapacityVo> capacityVos = records.stream()
|
|
|
|
|
+ .map(t -> getCapacityVo(t, finalTruckIdAndTruckMap, finalBillOrderIdAndWaybillOrderMap))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ return PageDataResult.of(page, capacityVos);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @NotNull
|
|
|
|
|
+ private static CapacityVo getCapacityVo(KwtLogisticsOrderCirculate t, Map<Long, RTruckVo> finalTruckIdAndTruckMap, Map<Long, List<KwtWaybillOrder>> finalBillOrderIdAndWaybillOrderMap) {
|
|
|
|
|
+ CapacityVo capacityVo = new CapacityVo();
|
|
|
|
|
+ capacityVo.setTruckId(String.valueOf(t.getTruckId()));
|
|
|
|
|
+ capacityVo.setTruckNo(t.getTruckNo());
|
|
|
|
|
+ RTruckVo truckVo = finalTruckIdAndTruckMap.getOrDefault(t.getTruckId(), new RTruckVo());
|
|
|
|
|
+ capacityVo.setCarAxis(truckVo.getCarAxis());
|
|
|
|
|
+ List<KwtWaybillOrder> waybillOrders = finalBillOrderIdAndWaybillOrderMap.get(t.getTruckId());
|
|
|
|
|
+ capacityVo.setFinishWaybillCount(String.valueOf(waybillOrders.size()));
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(waybillOrders)){
|
|
|
|
|
+ BigDecimal loadAmount = waybillOrders.stream()
|
|
|
|
|
+ .filter(x -> Objects.nonNull(x.getLoadAmount()))
|
|
|
|
|
+ .map(KwtWaybillOrder::getLoadAmount)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ BigDecimal unloadAmount = waybillOrders.stream()
|
|
|
|
|
+ .filter(x -> Objects.nonNull(x.getUnloadAmount()))
|
|
|
|
|
+ .map(KwtWaybillOrder::getUnloadAmount)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ capacityVo.setLoadAmount(loadAmount.setScale(2,RoundingMode.HALF_UP).toPlainString());
|
|
|
|
|
+ capacityVo.setUnloadAmount(unloadAmount.setScale(2,RoundingMode.HALF_UP).toPlainString());
|
|
|
|
|
+ capacityVo.setStatus(String.valueOf(waybillOrders.get(0).getStatus()));
|
|
|
|
|
+ capacityVo.setStatusDesc(CarWaybillEnum.getName(waybillOrders.get(0).getStatus()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ capacityVo.setDispatchStatus(String.valueOf(t.getStatus()));
|
|
|
|
|
+ capacityVo.setDispatchStatusDesc(Objects.equals(t.getStatus(),0) ? "启用" : "关闭");
|
|
|
|
|
+ return capacityVo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public Boolean closeCapacity(@Valid DeleteCapacityReq req) {
|
|
|
|
|
+ log.info("关闭启用已派运力请求参数:{}", JSON.toJSONString(req));
|
|
|
|
|
+ KwtLogisticsOrderCirculate logisticsOrderCirculate =
|
|
|
|
|
+ logisticsOrderCirculateRepository.findOneByLogOrderIdAndTruckId(Long.parseLong(req.getLogisticsOrderId()),
|
|
|
|
|
+ Long.parseLong(req.getTruckId()));
|
|
|
|
|
+ if (Objects.isNull(logisticsOrderCirculate)) {
|
|
|
|
|
+ throw new BusinessException("未找到该运力信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ KwtLogisticsOrderCirculate updateCirCulate = new KwtLogisticsOrderCirculate();
|
|
|
|
|
+ updateCirCulate.setId(logisticsOrderCirculate.getId());
|
|
|
|
|
+ updateCirCulate.setStatus(Integer.parseInt(req.getStatus()));
|
|
|
|
|
+ return logisticsOrderCirculateRepository.updateCirculate(updateCirCulate);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|