diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index dfac7337f..48d76d01e 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.4:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.33.0.99:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd-user-center/src/main/java/com/mhd/user/application/service/UserDriverApplicationService.java b/mhd-user-center/src/main/java/com/mhd/user/application/service/UserDriverApplicationService.java index c156a6dc8..8cba1f1d9 100644 --- a/mhd-user-center/src/main/java/com/mhd/user/application/service/UserDriverApplicationService.java +++ b/mhd-user-center/src/main/java/com/mhd/user/application/service/UserDriverApplicationService.java @@ -416,6 +416,17 @@ public class UserDriverApplicationService { VehiclePo vehicleData = vehicle.getData(); log.info("查到到车辆信息:{}",vehicleData); + // 如果车辆存在且当前用户与该车辆的绑定关系已存在,则跳过绑定,避免重复创建绑定记录 + if (vehicleData != null && vehicleData.getVehicleId() != null) { + DriverVehicleBind existingBind = driverVehicleBindDomainService.getBindInfoListByVehicle( + vehicleData.getVehicleId(), driver.getUserId()); + if (ObjectUtil.isNotNull(existingBind)) { + log.info("用户[{}]与车辆[{}]的绑定关系已存在,跳过绑定操作", + driver.getUserId(), driver.getVehicleLicensePlateNumber()); + return; + } + } + DriverVehicleBind driverVehicleBind = driverVehicleBindDomainService.isVehicleBinding(driver.getVehicleLicensePlateNumber()); Boolean isBound=false; if(ObjectUtil.isNotNull(driverVehicleBind)&&!driverVehicleBind.getDriverBindId().equals(driver.getUserId())){ diff --git a/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserDriverDomainService.java b/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserDriverDomainService.java index a694442e4..317649710 100644 --- a/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserDriverDomainService.java +++ b/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserDriverDomainService.java @@ -326,6 +326,9 @@ public class UserDriverDomainService { public UserDriverPo getDriverDataByUserId(Long userId) { UserDriverPo userDriverPo=userDriverRepositoryInterface.getDriverDataByUserId(userId); + if (userDriverPo == null) { + return null; + } R> vehicleR=transportFeign.getVehiclePosByUserId(userDriverPo.getUserId()); if (R.SUCCESS == vehicleR.getCode() && vehicleR.getData() != null && !vehicleR.getData().isEmpty()) { userDriverPo.setVehicleList(vehicleR.getData()); diff --git a/mhd_transport/src/main/java/com/linke/transport/application/service/vehicle/VehicleApplicationService.java b/mhd_transport/src/main/java/com/linke/transport/application/service/vehicle/VehicleApplicationService.java index 516b30a87..b3e4d2147 100644 --- a/mhd_transport/src/main/java/com/linke/transport/application/service/vehicle/VehicleApplicationService.java +++ b/mhd_transport/src/main/java/com/linke/transport/application/service/vehicle/VehicleApplicationService.java @@ -573,12 +573,15 @@ public class VehicleApplicationService { if (! "200".equals(String.valueOf(userInfoResult.get("code")))) { throw new ServiceException("用户信息获取失败: " + userInfoResult.get("msg")); } - UserDriverPo userPo = JSONUtil.toBean(JSONUtil.toJsonStr(userInfoResult.get("data")), - UserDriverPo.class); - vehicle.setUserName(userPo.getUserName()); - vehicle.setUserPhone(userPo.getUserPhone()); + // 司机数据可能不存在(用户尚未在用户中台完成注册),此时使用车辆表单携带的用户信息 + if (ObjectUtil.isNotNull(userInfoResult.get("data"))) { + UserDriverPo userPo = JSONUtil.toBean(JSONUtil.toJsonStr(userInfoResult.get("data")), + UserDriverPo.class); + vehicle.setUserName(userPo.getUserName()); + vehicle.setUserPhone(userPo.getUserPhone()); + } - List roleCodeList; + List roleCodeList = new ArrayList<>(); AjaxResult roleListAjaxResult = userServiceFeign.getRoleListByUserId(vehicle.getUserId()); if ("200".equals(String.valueOf(roleListAjaxResult.get("code"))) && ObjectUtil.isNotNull( roleListAjaxResult.get("data"))) { @@ -586,8 +589,6 @@ public class VehicleApplicationService { RolePO.class); if (CollUtil.isNotEmpty(rolePOS)) { roleCodeList = rolePOS.stream().map(RolePO :: getRoleCode).collect(Collectors.toList()); - } else { - throw new ServiceException("账号未授权角色信息!"); } } else { throw new ServiceException("获取用户角色列表失败: " + roleListAjaxResult.get("msg")); @@ -865,12 +866,14 @@ public class VehicleApplicationService { if (! "200".equals(String.valueOf(userInfoResult.get("code")))) { throw new ServiceException("用户信息获取失败: " + userInfoResult.get("msg")); } - UserDriverPo userPo = JSONUtil.toBean(JSONUtil.toJsonStr(userInfoResult.get("data")), - UserDriverPo.class); - vehicle.setUserName(userPo.getUserName()); - vehicle.setUserPhone(userPo.getUserPhone()); + if (ObjectUtil.isNotNull(userInfoResult.get("data"))) { + UserDriverPo userPo = JSONUtil.toBean(JSONUtil.toJsonStr(userInfoResult.get("data")), + UserDriverPo.class); + vehicle.setUserName(userPo.getUserName()); + vehicle.setUserPhone(userPo.getUserPhone()); + } - List roleCodeList; + List roleCodeList = new ArrayList<>(); AjaxResult roleListAjaxResult = userServiceFeign.getRoleListByUserId(vehicle.getUserId()); if ("200".equals(String.valueOf(roleListAjaxResult.get("code"))) && ObjectUtil.isNotNull( roleListAjaxResult.get("data"))) { @@ -878,8 +881,6 @@ public class VehicleApplicationService { RolePO.class); if (CollUtil.isNotEmpty(rolePOS)) { roleCodeList = rolePOS.stream().map(RolePO :: getRoleCode).collect(Collectors.toList()); - } else { - throw new ServiceException("账号未授权角色信息!"); } } else { throw new ServiceException("获取用户角色列表失败: " + roleListAjaxResult.get("msg")); @@ -1935,10 +1936,13 @@ public class VehicleApplicationService { if (! "200".equals(String.valueOf(info.get("code")))) { throw new ServiceException("用户信息获取失败"); } - UserDriverPo userPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), - UserDriverPo.class); - vehicle.setUserName(userPo.getUserName()); - vehicle.setUserPhone(userPo.getUserPhone()); + // 司机数据可能不存在(用户尚未在用户中台完成注册),此时使用车辆表单携带的用户信息 + if (ObjectUtil.isNotNull(info.get("data"))) { + UserDriverPo userPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), + UserDriverPo.class); + vehicle.setUserName(userPo.getUserName()); + vehicle.setUserPhone(userPo.getUserPhone()); + } List roleCodeList = new ArrayList<>(); AjaxResult roleListAjaxResult = userServiceFeign.getRoleListByUserId(vehicle.getUserId()); if ("200".equals(String.valueOf(roleListAjaxResult.get("code"))) && ObjectUtil.isNotNull( @@ -1948,8 +1952,6 @@ public class VehicleApplicationService { if (rolePOS != null && ! rolePOS.isEmpty()) { roleCodeList.addAll( rolePOS.stream().map(RolePO :: getRoleCode).collect(Collectors.toList())); - } else { - throw new ServiceException("账号未授权角色信息!"); } } if (! roleCodeList.contains(RoleEnum.DRIVER.getCode())) {