Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/dev_20251130' into dev_20251130

xucaiqin 1 mese fa
parent
commit
19822e86ec

+ 10 - 0
sckw-gateway/src/main/resources/bootstrap-test.yml

@@ -17,4 +17,14 @@ spring:
         namespace: @nacos.namespace@
         # 共享配置
         group: sckw-ng-service-platform
+        shared-configs:
+          - data-id: sckw-common.yml
+            group: sckw-ng-common
+            refresh: true
+
+        #可以读多个配置文件 需要在同一个命名空间下面可以是不同的组
+        extension-configs:
+          - dataId: sckw-common.yml
+            group: sckw-ng-service-platform
+            refresh: true
 

+ 2 - 2
sckw-modules-api/sckw-transport-api/src/main/java/com/sckw/transport/api/feign/VehicleTraceClient.java

@@ -19,8 +19,8 @@ import java.util.List;
  */
 @FeignClient(
     name = "iot-platform",
-    url = "${vehicle.trace.api.base-url}",
-    path = "/api/transfer",
+    url = "${vehicle.trace.api.base-url}/api/transfer",
+   // path = "/api/transfer",
     configuration = VehicleTraceFeignConfig.class
 )
 @ConditionalOnProperty(name = "vehicle.trace.api.base-url")

+ 19 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/repository/KwcContractLogisticsRepository.java

@@ -11,6 +11,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
@@ -78,4 +79,22 @@ public class KwcContractLogisticsRepository extends ServiceImpl<KwcContractLogis
                 .like(org.apache.commons.lang3.StringUtils.isNotBlank(contractNo),KwcContractLogistics::getContractNo, contractNo)
                 .like(org.apache.commons.lang3.StringUtils.isNotBlank(contractName),KwcContractLogistics::getName, contractName));
     }
+
+    /**
+     * 查询时间范围内的指定派车方式的物流合同
+     * @param contractIdList
+     * @param startTime
+     * @param endTime
+     * @param dispatchingType
+     * @return
+     */
+    public KwcContractLogistics queryBy(Set<Long> contractIdList, Date startTime, Date endTime, Integer dispatchingType) {
+        return getOne(Wrappers.<KwcContractLogistics>lambdaQuery()
+                .eq(KwcContractLogistics::getDelFlag, 0)
+                .in(KwcContractLogistics::getId, contractIdList)
+                .eq(KwcContractLogistics::getDispatching, dispatchingType)
+                .and(queryWrapper -> queryWrapper.between(KwcContractLogistics::getStartTime, startTime, endTime)
+                        .or().between(KwcContractLogistics::getEndTime, startTime, endTime)
+                        .or(queryWrapper1->queryWrapper1.le(KwcContractLogistics::getStartTime, startTime).ge(KwcContractLogistics::getEndTime, endTime))));
+    }
 }

+ 15 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractLogisticsService.java

@@ -1258,6 +1258,9 @@ public class KwcContractLogisticsService {
             saveContractLogistics.setEndTime(DateUtils.getEndOfDay(baseInfo.getEndTime()));
         }
 
+        //校验物流企业是否存在同时段的自动派车合同
+        checkAutoDispatchingContractExist(baseInfo);
+
         saveContractLogistics.setStatus(ContractStatusEnum.SUBMIT.getCode());
         saveContractLogistics.setCreateBy(LoginUserHolder.getUserId());
         saveContractLogistics.setCreateTime(date);
@@ -1286,6 +1289,18 @@ public class KwcContractLogisticsService {
 
         return Boolean.TRUE;
     }
+
+    public void checkAutoDispatchingContractExist(LogisticListReq.TradeBaseInfo baseInfo) {
+        List<KwcContractLogisticsUnit> units = kwcContractLogisticsUnitRepository.queryByEntIdAndEntType(baseInfo.getPurchaseEntId(), EntTypeEnum.LOGISTICS4.getCode());
+        if (CollectionUtils.isNotEmpty(units)) {
+            Set<Long> contractIdList = units.stream().map(KwcContractLogisticsUnit::getContractId).collect(Collectors.toSet());
+            KwcContractLogistics kwcContractLogistics = kwcContractLogisticsRepository.queryBy(contractIdList,baseInfo.getStartTime(),baseInfo.getEndTime(),Integer.parseInt(DictEnum.DISPATCHING_TYPE_2.getValue()));
+            if (Objects.nonNull(kwcContractLogistics)){
+                throw new BusinessException("当前物流企业在合同时间段内已存在自动派车合同");
+            }
+        }
+    }
+
     private String changeFile(String contractFile) {
         if (StringUtils.isNotBlank(contractFile)) {
             JSONArray jsonArray = JSONArray.parseArray(contractFile);

+ 2 - 2
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -1631,7 +1631,7 @@ public class KwfTruckService {
             // 使用 Feign 调用查询实时位置
             BaseResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
             
-            if (result == null || result.getCode() != HttpStatus.SUCCESS_CODE || result.getData() == null) {
+            if (result == null || result.getCode() != 0 || result.getData() == null) {
                 log.warn("查询实时轨迹返回空数据, 运单号: {}", odrderNo);
                 return null;
             }
@@ -1651,7 +1651,7 @@ public class KwfTruckService {
             // 使用 Feign 调用查询实时位置
             BaseResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
             
-            if (result == null || result.getCode() != HttpStatus.SUCCESS_CODE || result.getData() == null) {
+            if (result == null || result.getCode() != 0 || result.getData() == null) {
                 log.warn("查询实时轨迹返回空数据, 车牌号: {}", truckId);
                 return null;
             }

+ 4 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/GenerateTraceReq.java

@@ -25,7 +25,7 @@ public class GenerateTraceReq implements Serializable {
 
     @Schema(description = "运单号", example = "T88565469682136456969", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotBlank(message = "运单号不能为空")
-    private String wOrderNo;
+    private String wayOrderNo;
 
     @Schema(description = "车牌号", example = "川A888528", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotBlank(message = "车牌号不能为空")
@@ -35,6 +35,9 @@ public class GenerateTraceReq implements Serializable {
     @NotBlank(message = "当前位置不能为空")
     private String currentLocation;
 
+    @Schema(description = "异常位置详细地址")
+    private String exceptionLocation;
+
     @Schema(description = "异常类型(1-车辆偏航,2-急刹车,3-超速,4-异常停车)")
     private Integer exceptionType;
 }

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtWaybillOrderV1Service.java

@@ -2208,7 +2208,7 @@ public class KwtWaybillOrderV1Service {
                     vehicleDataDTO.setWOrderNo(waybillOrder.getWOrderNo());
                     BaseResult<List<com.sckw.transport.api.model.dto.VehicleReturnData>> result = vehicleTraceClient.queryVehicleDataList(vehicleDataDTO1);
                     
-                    if (result != null && result.getCode()!= HttpStatus.SUCCESS_CODE && result.getData() != null) {
+                    if (result != null && result.getCode()== 0 && result.getData() != null) {
                         List<com.sckw.transport.api.model.dto.VehicleReturnData> vehicleReturn = result.getData();
                         List<VehicleRouteData> vehicleReturnData = vehicleReturn.stream().map(x->{
                             VehicleRouteData vehicleRouteData = new VehicleRouteData();

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/VehicleExceptionService.java

@@ -144,7 +144,7 @@ public class VehicleExceptionService {
                 // 默认离线
                 Integer locationStatus = 0;
                 
-                if (result != null && result.getCode() == 200 && result.getData() != null) {
+                if (result != null && result.getCode() == 0 && result.getData() != null) {
                     VehicleReturnData vehicleData = result.getData();
                     
                     // 判断30分钟内有定位数据为在线

+ 15 - 12
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/kwfTruckTraceService.java

@@ -41,6 +41,7 @@ import com.sckw.transport.model.dto.TruckDto;
 import com.sckw.transport.api.feign.VehicleTraceClient;
 import com.sckw.transport.api.model.dto.VehicleDataDTO;
 import com.sckw.transport.api.model.dto.VehicleReturnData;
+import com.sckw.transport.model.enuma.VehicleExceptionTypeEnum;
 import com.sckw.transport.model.param.*;
 import com.sckw.transport.model.dto.GenerateTraceReq;
 import com.sckw.transport.model.vo.CurrentTaskTraceReqVo;
@@ -546,7 +547,7 @@ public class kwfTruckTraceService {
             // 使用 Feign 调用查询实时位置
             BaseResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
 
-            if (result == null || result.getCode() != HttpStatus.SUCCESS_CODE || result.getData() == null) {
+            if (result == null || result.getCode() != 0 || result.getData() == null) {
                 log.warn("查询实时轨迹返回空数据, 车牌号: {}", truckId);
                 return null;
             }
@@ -621,7 +622,7 @@ public class kwfTruckTraceService {
             // 使用 Feign 调用上报车辆轨迹
             BaseResult<Void> result = vehicleTraceClient.saveVehicleData(req);
             
-            if (result == null || result.getCode() != HttpStatus.SUCCESS_CODE) {
+            if (result == null || result.getCode() != 0) {
                 log.error("app上报车辆轨迹失败, 响应: {}", result);
                 throw new BusinessException("app上报车辆轨迹异常");
             }
@@ -722,7 +723,7 @@ public class kwfTruckTraceService {
                 vehicleDataDTO.setCarNo(truckNo);
                 BaseResult<VehicleReturnData> result = vehicleTraceClient.queryRealTimeLocation(vehicleDataDTO);
 
-                if (result == null || result.getCode() != HttpStatus.SUCCESS_CODE || result.getData() == null) {
+                if (result == null || result.getCode() != 0 || result.getData() == null) {
                     // 无定位数据,设置为离线
                     truckLocationStatusMap.put(truckNo, 0);
                     return truckLocationStatusMap;
@@ -1038,7 +1039,7 @@ public class kwfTruckTraceService {
                 
                 VehicleLocationInfo locationInfo = new VehicleLocationInfo();
                 
-                if (result != null && result.getCode() == 200 && result.getData() != null) {
+                if (result != null && result.getCode() == 0 && result.getData() != null) {
                     VehicleReturnData vehicleData = result.getData();
                     
                     // 判断定位状态
@@ -1094,7 +1095,7 @@ public class kwfTruckTraceService {
                 BaseResult<List<com.sckw.transport.api.model.dto.VehicleReturnData>> result = 
                         vehicleTraceClient.queryVehicleDataList(vehicleDataDTO);
                 
-                if (result != null && result.getCode() == HttpStatus.SUCCESS_CODE && result.getData() != null) {
+                if (result != null && result.getCode() == 0 && result.getData() != null) {
                     List<com.sckw.transport.api.model.dto.VehicleReturnData> traceDataList = result.getData();
                     
                     // 统计alarmCode不为null且不为0的记录数量(表示有异常报警)
@@ -1252,12 +1253,12 @@ public class kwfTruckTraceService {
         String longitude = location[0];
         String latitude = location[1];
 
-        KwtWaybillOrder order = kwtWaybillOrderRepository.queryByWayOrderNo(req.getWOrderNo());
+        KwtWaybillOrder order = kwtWaybillOrderRepository.queryByWayOrderNo(req.getWayOrderNo());
         if (Objects.isNull(order)){
             throw new BusinessException("运单不存在");
         }
         //查询子运单
-        KwtWaybillOrder subOrders = kwtWaybillOrderRepository.queryByBillOrderId(order.getLOrderId());
+        KwtWaybillOrderSubtask subOrders = kwtWaybillOrderSubtaskRepository.queryByBillOrderId(order.getId());
         if (Objects.isNull(subOrders)){
             throw new BusinessException("子运单不存在");
         }
@@ -1272,7 +1273,7 @@ public class kwfTruckTraceService {
         try {
             // 调用数据中台保存轨迹数据
             BaseResult<Void> result = vehicleTraceClient.saveVehicleData(vehiclesTrajectoryReq);
-            if (result.getCode() != HttpStatus.SUCCESS_CODE) {
+            if (result.getCode() != 0) {
                 log.error("保存车辆轨迹数据失败:{}", result.getMessage());
                 throw new BusinessException("生成轨迹失败:" + result.getMessage());
             }
@@ -1280,7 +1281,7 @@ public class kwfTruckTraceService {
             // 如果有异常类型,同时保存到本地车辆异常表
             saveException(req, order, longitude, latitude);
 
-            log.info("生成车辆轨迹成功,运单号:{},车牌号:{}", req.getWOrderNo(), req.getTruckNo());
+            log.info("生成车辆轨迹成功,运单号:{},车牌号:{}", req.getWayOrderNo(), req.getTruckNo());
         } catch (Exception e) {
             log.error("生成车辆轨迹异常:", e);
             throw new BusinessException("生成轨迹失败:" + e.getMessage());
@@ -1296,11 +1297,13 @@ public class kwfTruckTraceService {
             vehicleException.setEntId(order.getEntId());
             vehicleException.setTruckId(order.getTruckId());
             vehicleException.setTruckNo(req.getTruckNo());
-            vehicleException.setWOrderNo(req.getWOrderNo());
+            vehicleException.setWOrderNo(req.getWayOrderNo());
             vehicleException.setDriverId(order.getDriverId());
             vehicleException.setDriverName(order.getDriverName());
             vehicleException.setDriverPhone(order.getDriverPhone());
             vehicleException.setExceptionType(req.getExceptionType());
+            vehicleException.setDescription(VehicleExceptionTypeEnum.getName(req.getExceptionType()));
+            vehicleException.setLocation(req.getExceptionLocation());
             vehicleException.setLongitude(longitude);
             vehicleException.setLatitude(latitude);
             vehicleException.setExceptionTime(new Date());
@@ -1318,7 +1321,7 @@ public class kwfTruckTraceService {
     @NotNull
     private static VehiclesTrajectoryReq getVehiclesTrajectoryReq(GenerateTraceReq req, KwtWaybillOrder order, String longitude, String latitude, KwtLogisticsOrder logisticsOrder, RFleetVo fleetByTruckId) {
         VehiclesTrajectoryReq vehiclesTrajectoryReq = new VehiclesTrajectoryReq();
-        vehiclesTrajectoryReq.setTs(req.getDate() + " " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
+        vehiclesTrajectoryReq.setTs(req.getDate());
         vehiclesTrajectoryReq.setMobile(order.getDriverPhone());
         vehiclesTrajectoryReq.setTruckNo(req.getTruckNo());
         vehiclesTrajectoryReq.setLongitude(longitude);
@@ -1334,7 +1337,7 @@ public class kwfTruckTraceService {
         if (req.getExceptionType() != null){
             vehiclesTrajectoryReq.setStatus(String.valueOf(req.getExceptionType()));
         }
-        vehiclesTrajectoryReq.setWOrderNo(req.getWOrderNo());
+        vehiclesTrajectoryReq.setWOrderNo(req.getWayOrderNo());
         vehiclesTrajectoryReq.setLOrderNo(Optional.ofNullable(logisticsOrder).map(KwtLogisticsOrder::getLOrderNo).orElse( ""));
         VehiclesTrajectoryReq.VehicleDataVO vehicleDataVO = new VehiclesTrajectoryReq.VehicleDataVO();
         vehicleDataVO.setCarNo(req.getTruckNo());