Compare commits
No commits in common. "6ab26976d630cf4bc27d70d951f7262a73b24ffd" and "bbd9e52302ade6bb40869593fd0322818808f5be" have entirely different histories.
6ab26976d6
...
bbd9e52302
|
@ -17,11 +17,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -20,14 +20,4 @@ public class ServiceNameConstants {
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "couplet-file";
|
public static final String FILE_SERVICE = "couplet-file";
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param null:
|
|
||||||
* @return null
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 车辆管理模块
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
public static final String VEHICLE_SERVICE = "couplet-vehicle";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>couplet-common-vehicle</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
|
||||||
<!-- MuYu Common Core-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,89 +0,0 @@
|
||||||
package com.couplet.common.system.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/3/26
|
|
||||||
* @Description: 车辆信息表
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName("couplet_vehicle")
|
|
||||||
public class Vehicle{
|
|
||||||
/*
|
|
||||||
*车辆id
|
|
||||||
* */
|
|
||||||
@TableId(type = IdType.AUTO, value = "vehicle_id")
|
|
||||||
private Long vehicleId;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*车辆类型
|
|
||||||
* */
|
|
||||||
@TableField(value = "vehicle_type")
|
|
||||||
private Long vehicleType;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 车辆类型名称
|
|
||||||
* */
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String vehicleTypeName;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*电机厂商
|
|
||||||
* */
|
|
||||||
@TableField(value = "motor_manufacturer")
|
|
||||||
private String motorManufacturer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*电池厂商
|
|
||||||
* */
|
|
||||||
@TableField(value = "battery_manufacturer")
|
|
||||||
private String batteryManufacturer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*电机编号
|
|
||||||
* */
|
|
||||||
@TableField(value = "motor_number")
|
|
||||||
private String motorNumber;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*电池编号
|
|
||||||
* */
|
|
||||||
@TableField(value = "battery_number")
|
|
||||||
private String batteryNumber;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*vin码
|
|
||||||
* */
|
|
||||||
@TableField(value = "vin")
|
|
||||||
private String vin;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*0离线 1在线
|
|
||||||
* */
|
|
||||||
@TableField(value = "vehicle_state")
|
|
||||||
private Integer vehicleState;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*0未删除 1删除
|
|
||||||
* */
|
|
||||||
@TableField(value = "isdelete")
|
|
||||||
private Integer isdelete;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package com.couplet.common.system.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/3/30
|
|
||||||
* @Description: 车辆和标志中间表
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName("couplet_vehicle_and_logo")
|
|
||||||
public class VehicleAndLogo {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 车辆、标志中间表id
|
|
||||||
* */
|
|
||||||
@TableId(type = IdType.AUTO, value = "vehicle_logo_middle_id")
|
|
||||||
private Long vehicleLogoMiddleId;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 车辆id
|
|
||||||
* */
|
|
||||||
@TableField("vehicle_id")
|
|
||||||
private Long vehicleId;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 标志id
|
|
||||||
* */
|
|
||||||
@TableField("logo_id")
|
|
||||||
private Long logoId;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.couplet.common.system.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fufanrui
|
|
||||||
* @version 1.0
|
|
||||||
* @description: TODO
|
|
||||||
* @date 2024/4/2 11:22
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@ToString
|
|
||||||
public class VehicleMiddle{
|
|
||||||
|
|
||||||
private Long middleId;
|
|
||||||
private Long userId;
|
|
||||||
private Long vehicleId;
|
|
||||||
private Long delFlag;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.couplet.common.system.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/3/31
|
|
||||||
* @Description: 车辆类型
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName("couplet_vehicle_type")
|
|
||||||
public class VehicleType {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 车辆类型id
|
|
||||||
* */
|
|
||||||
@TableId(type = IdType.AUTO, value = "vehicle_type_id")
|
|
||||||
private Long vehicleTypeId;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 车辆类型名称
|
|
||||||
* */
|
|
||||||
@TableField(value = "vehicle_type_name")
|
|
||||||
private String vehicleTypeName;
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package com.couplet.common.system.remote;
|
|
||||||
|
|
||||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.common.system.domain.Vehicle;
|
|
||||||
import com.couplet.common.system.domain.VehicleMiddle;
|
|
||||||
import com.couplet.common.system.remote.factory.RemoteVehicleFallbackFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@FeignClient(contextId = "remoteVehicleService" ,
|
|
||||||
value = ServiceNameConstants.VEHICLE_SERVICE,
|
|
||||||
fallbackFactory = RemoteVehicleFallbackFactory.class,
|
|
||||||
path = "/vehicle"
|
|
||||||
)
|
|
||||||
public interface RemoteVehicleService {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param null:
|
|
||||||
* @return null
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 根据员工id查询员工下有哪些车
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@PostMapping("UserUnderTheVehicle/{userId}")
|
|
||||||
public Result<List<Vehicle>> UserUnderTheVehicleList(@PathVariable(value = "userId") Long userId);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param middleId:
|
|
||||||
* @return Result<Integer>
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 删除员工管理的车辆
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{middleId}")
|
|
||||||
public Result<Integer> deleteVehicle(@PathVariable(value = "middleId") Long middleId);
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("vehicleAll")
|
|
||||||
public Result<List<Vehicle>> VehicleManageList();
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package com.couplet.common.system.remote.factory;
|
|
||||||
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.common.system.domain.Vehicle;
|
|
||||||
import com.couplet.common.system.domain.VehicleMiddle;
|
|
||||||
import com.couplet.common.system.remote.RemoteVehicleService;
|
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fufanrui
|
|
||||||
* @version 1.0
|
|
||||||
* @description: TODO
|
|
||||||
* @date 2024/4/2 14:46
|
|
||||||
*/
|
|
||||||
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RemoteVehicleService create(Throwable cause) {
|
|
||||||
return new RemoteVehicleService() {
|
|
||||||
@Override
|
|
||||||
public Result<List<Vehicle>> UserUnderTheVehicleList(Long userId) {
|
|
||||||
return Result.error("调用失败...."+cause.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Integer> deleteVehicle(Long middleId) {
|
|
||||||
return Result.error("调用失败...."+cause.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Integer> addVehicle(VehicleMiddle vehicleMiddle) {
|
|
||||||
return Result.error("调用失败....."+cause.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<Vehicle>> VehicleManageList() {
|
|
||||||
return Result.error("调用失败....."+cause.getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
com.couplet.common.system.remote.factory.RemoteVehicleFallbackFactory
|
|
|
@ -19,7 +19,6 @@
|
||||||
<module>couplet-common-datasource</module>
|
<module>couplet-common-datasource</module>
|
||||||
<module>couplet-common-system</module>
|
<module>couplet-common-system</module>
|
||||||
<module>couplet-trouble-log</module>
|
<module>couplet-trouble-log</module>
|
||||||
<module>couplet-common-vehicle</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>couplet-common</artifactId>
|
<artifactId>couplet-common</artifactId>
|
||||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -82,17 +82,6 @@
|
||||||
<artifactId>couplet-common-swagger</artifactId>
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-modules-vehicle</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-vehicle</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
package com.couplet.server.controller;
|
|
||||||
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.common.system.domain.Vehicle;
|
|
||||||
import com.couplet.common.system.domain.VehicleMiddle;
|
|
||||||
import com.couplet.server.service.VehicleManageService;
|
|
||||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fufanrui
|
|
||||||
* @version 1.0
|
|
||||||
* @description: 车辆管理控制层
|
|
||||||
* @date 2024/4/2 9:05
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/VehicleManage")
|
|
||||||
public class VehicleManageController {
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private VehicleManageService vehicleManageService;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param :
|
|
||||||
* @return Result<List<Vehicle>>
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description Y管理车辆列表
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@PostMapping("/VehicleManageList")
|
|
||||||
public Result<List<Vehicle>> VehicleManageList(){
|
|
||||||
List<Vehicle> vehicles = vehicleManageService.VehicleManageList();
|
|
||||||
Result<List<Vehicle>> success = Result.success(vehicles);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* @param middleId:
|
|
||||||
* @return Result<Integer>
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 删除员工管理的车辆
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
|
|
||||||
@DeleteMapping("/{middleId}")
|
|
||||||
public Result deleteVehicle(@PathVariable(value = "middleId") Long middleId){
|
|
||||||
return vehicleManageService.deleteVehicle(middleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param middle:
|
|
||||||
* @return Result
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 添加车辆
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@PostMapping
|
|
||||||
public Result addVehicle(@RequestBody VehicleMiddle middle){
|
|
||||||
return vehicleManageService.addVehicle(middle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("vehicleAll")
|
|
||||||
public Result<List<Vehicle>> vehicleAll(){
|
|
||||||
List<Vehicle> vehicles = vehicleManageService.vehicleAll();
|
|
||||||
return Result.success(vehicles);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.couplet.server.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.common.system.domain.Vehicle;
|
|
||||||
import com.couplet.common.system.domain.VehicleMiddle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface VehicleManageService {
|
|
||||||
List<Vehicle> VehicleManageList();
|
|
||||||
|
|
||||||
|
|
||||||
Result deleteVehicle(Long middleId);
|
|
||||||
|
|
||||||
Result addVehicle(VehicleMiddle middle);
|
|
||||||
|
|
||||||
List<Vehicle> vehicleAll();
|
|
||||||
|
|
||||||
}
|
|
|
@ -91,14 +91,6 @@ public class EmployeeServiceImpl implements EmployeeService{
|
||||||
return remoteEmployeeService.changeStatus(user);
|
return remoteEmployeeService.changeStatus(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param user:
|
|
||||||
* @return List<SysUser>
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 员工管理列表
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysUser> userList(SysUser user) {
|
public List<SysUser> userList(SysUser user) {
|
||||||
String username = SecurityUtils.getUsername();
|
String username = SecurityUtils.getUsername();
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.couplet.server.service.impl;
|
|
||||||
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.common.security.utils.SecurityUtils;
|
|
||||||
import com.couplet.common.system.domain.Vehicle;
|
|
||||||
import com.couplet.common.system.domain.VehicleMiddle;
|
|
||||||
import com.couplet.common.system.remote.RemoteVehicleService;
|
|
||||||
import com.couplet.server.service.VehicleManageService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fufanrui
|
|
||||||
* @version 1.0
|
|
||||||
* @description: 车辆管理服务实现类
|
|
||||||
* @date 2024/4/2 9:05
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class VehicleManageServiceImpl implements VehicleManageService{
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RemoteVehicleService remoteVehicleService;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @description: 车辆管理列表
|
|
||||||
* @param: []
|
|
||||||
* @return: com.couplet.common.core.domain.Result<java.util.List<com.couplet.common.system.domain.Vehicle>>
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Vehicle> VehicleManageList() {
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
Result<List<Vehicle>> listResult = remoteVehicleService.UserUnderTheVehicleList(userId);
|
|
||||||
List<Vehicle> list = listResult.getData();
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param middleId:
|
|
||||||
* @return Result
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 删除员工管理车辆
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Result deleteVehicle(Long middleId) {
|
|
||||||
Result<Integer> integerResult = remoteVehicleService.deleteVehicle(middleId);
|
|
||||||
Integer resultData = integerResult.getData();
|
|
||||||
|
|
||||||
return resultData==1?Result.success():Result.error("删除失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @param middle:
|
|
||||||
* @return Result
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 添加车辆
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Result addVehicle(VehicleMiddle middle) {
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
middle.setUserId(userId);
|
|
||||||
Result<Integer> integerResult = remoteVehicleService.addVehicle(middle);
|
|
||||||
Integer resultData = integerResult.getData();
|
|
||||||
return resultData==1?Result.success():Result.error("添加失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Vehicle> vehicleAll() {
|
|
||||||
Result<List<Vehicle>> listResult = remoteVehicleService.VehicleManageList();
|
|
||||||
return listResult.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -17,11 +17,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -17,11 +17,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -91,12 +91,6 @@
|
||||||
<version>1.2.5</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 注入车辆服务,调用接口-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-modules-vehicle</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
//@EnableFeignClients
|
|
||||||
public class OnlineApplication {
|
public class OnlineApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(OnlineApplication.class);
|
SpringApplication.run(OnlineApplication.class);
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
package com.couplet.online.utils;
|
package com.couplet.online.utils;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.couplet.common.redis.service.RedisService;
|
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
|
||||||
import com.couplet.vehicle.remote.RemoteVehicleService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ProjectName: five-groups-couplet
|
* @ProjectName: five-groups-couplet
|
||||||
|
@ -60,14 +54,6 @@ public class MqttMonitor {
|
||||||
@Value("${mqtt.server.qos}")
|
@Value("${mqtt.server.qos}")
|
||||||
private Integer qos;
|
private Integer qos;
|
||||||
|
|
||||||
//远程调用
|
|
||||||
@Autowired
|
|
||||||
private RemoteVehicleService remoteVehicleService;
|
|
||||||
|
|
||||||
//redis
|
|
||||||
@Autowired
|
|
||||||
private RedisService redis;
|
|
||||||
|
|
||||||
|
|
||||||
//随项目启动而执行这个方法
|
//随项目启动而执行这个方法
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
|
@ -95,21 +81,7 @@ public class MqttMonitor {
|
||||||
client.setCallback(new MqttCallback() {
|
client.setCallback(new MqttCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void connectionLost(Throwable throwable) {
|
public void connectionLost(Throwable throwable) {
|
||||||
// 处理连接断开的情况
|
|
||||||
// 在这里执行重连操作
|
|
||||||
log.error("连接丢失:{}", throwable.getMessage());
|
log.error("连接丢失:{}", throwable.getMessage());
|
||||||
while (!client.isConnected()) {
|
|
||||||
try {
|
|
||||||
//等待五秒后重新连接
|
|
||||||
Thread.sleep(5000);
|
|
||||||
//重新连接
|
|
||||||
client.reconnect();
|
|
||||||
log.info("重连中...");
|
|
||||||
} catch (InterruptedException | MqttException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,42 +93,14 @@ public class MqttMonitor {
|
||||||
//接收到的原始报文
|
//接收到的原始报文
|
||||||
String message = new String(mqttMessage.getPayload());
|
String message = new String(mqttMessage.getPayload());
|
||||||
|
|
||||||
// log.info("接收消息原始内容:{}", message);
|
log.info("接收消息原始内容:{}", message);
|
||||||
|
|
||||||
//解析后的字符串
|
//去除空格 得到16进制字符串
|
||||||
String parseMsg = ParseMessageUtil.parseMsg(message);
|
String replaced = message.replaceAll(" ", "");
|
||||||
|
log.info("接收消息剪切后内容:{}", replaced);
|
||||||
//拿到前17位(车辆vin码)
|
|
||||||
String start17 = parseMsg.substring(0, 17);
|
|
||||||
|
|
||||||
|
|
||||||
log.info("当前车辆的vin码为:" + start17);
|
|
||||||
|
|
||||||
//判断缓存中是否有这个vin
|
|
||||||
if (redis.hasKey("不存在的车辆VIN:" + start17)) {
|
|
||||||
|
|
||||||
//可使用RabbitMQ发送消息
|
|
||||||
log.error("vin码为" + start17 + "的车辆不属于本系统!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//调取接口,通过vin查询车辆
|
|
||||||
List<Vehicle> vehicles = remoteVehicleService.findByVIN(start17).getData();
|
|
||||||
|
|
||||||
//如果不存在这个车
|
|
||||||
if (vehicles.isEmpty()) {
|
|
||||||
//将不属于自己系统的车辆存入缓存,便于提前进行拒绝提示
|
|
||||||
redis.setCacheObject("不存在的车辆VIN:" + start17, start17);
|
|
||||||
log.error("未找到vin码为" + start17 + "的车辆信息");
|
|
||||||
} else {
|
|
||||||
//如果存在这个车
|
|
||||||
Vehicle vehicle = vehicles.get(0);
|
|
||||||
System.out.println("***********" + vehicle + "***********");
|
|
||||||
//存入redis
|
|
||||||
redis.setCacheObject("存在的车辆VIN:" + start17, JSON.toJSONString(vehicle));
|
|
||||||
|
|
||||||
log.info("vin码为" + start17 + "的车辆属于本系统,允许上线!");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
package com.couplet.online.utils;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/4/2
|
|
||||||
* @Description: 初步解析报文工具类
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class ParseMessageUtil {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @Date: 2024/4/2 14:58
|
|
||||||
* @Description: 将16进制字符串转换为ASCII字符串
|
|
||||||
* @Param: [hexString]
|
|
||||||
* @Return: java.lang.String
|
|
||||||
**/
|
|
||||||
public static String hexToString(String hexString) {
|
|
||||||
StringBuffer asciiString = new StringBuffer();
|
|
||||||
|
|
||||||
for (int i = 0; i < hexString.length(); i += 2) {
|
|
||||||
String hex = hexString.substring(i, i + 2);
|
|
||||||
int decimal = Integer.parseInt(hex, 16);
|
|
||||||
asciiString.append((char) decimal);
|
|
||||||
}
|
|
||||||
return asciiString.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseMsg(String msg) {
|
|
||||||
//去头去尾
|
|
||||||
String substring = msg.substring(2, msg.length() - 2);
|
|
||||||
// log.info("去头去尾的报文:" + substring);
|
|
||||||
|
|
||||||
//去空格
|
|
||||||
String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
|
|
||||||
|
|
||||||
//转换为ASCII字符串
|
|
||||||
String asciiString = hexToString(hexStringWithoutSpaces);
|
|
||||||
|
|
||||||
// log.info("解析后报文:" + asciiString);
|
|
||||||
|
|
||||||
return asciiString;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,10 +35,9 @@ logging:
|
||||||
mqtt:
|
mqtt:
|
||||||
server:
|
server:
|
||||||
broker: tcp://115.159.47.13:1883
|
broker: tcp://115.159.47.13:1883
|
||||||
# broker: mqtt://115.159.47.13:1883
|
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
clientId: fluxmq
|
clientId: lyh
|
||||||
qos: 0
|
qos: 0
|
||||||
topic: test
|
topic: test
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,6 @@
|
||||||
<version>1.4.1</version>
|
<version>1.4.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.couplet.common.log.annotation.Log;
|
||||||
import com.couplet.common.log.enums.BusinessType;
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
|
||||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||||
|
@ -61,7 +60,7 @@ public class VehicleController extends BaseController {
|
||||||
@RequiresPermissions("couplet:vehicle:deleteById")
|
@RequiresPermissions("couplet:vehicle:deleteById")
|
||||||
@GetMapping("/deleteById/{vehicleId}")
|
@GetMapping("/deleteById/{vehicleId}")
|
||||||
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
||||||
public Result<String> deleteById(@PathVariable Long vehicleId) {
|
public Result deleteById(@PathVariable Long vehicleId) {
|
||||||
String result = vehicleService.deleteById(vehicleId);
|
String result = vehicleService.deleteById(vehicleId);
|
||||||
|
|
||||||
return Result.success(result);
|
return Result.success(result);
|
||||||
|
@ -78,7 +77,7 @@ public class VehicleController extends BaseController {
|
||||||
@RequiresPermissions("couplet:vehicle:editById")
|
@RequiresPermissions("couplet:vehicle:editById")
|
||||||
@PostMapping("/editById")
|
@PostMapping("/editById")
|
||||||
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
||||||
public Result<String> editById(@RequestBody VehicleEditParams editParams) {
|
public Result editById(@RequestBody VehicleEditParams editParams) {
|
||||||
|
|
||||||
String result = vehicleService.editById(editParams);
|
String result = vehicleService.editById(editParams);
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ public class VehicleController extends BaseController {
|
||||||
@RequiresPermissions("couplet:vehicle:insert")
|
@RequiresPermissions("couplet:vehicle:insert")
|
||||||
@PostMapping("/insert")
|
@PostMapping("/insert")
|
||||||
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||||
public Result<String> insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||||
System.out.println(insertParams);
|
System.out.println(insertParams);
|
||||||
String result = vehicleService.insert(insertParams);
|
String result = vehicleService.insert(insertParams);
|
||||||
|
|
||||||
|
@ -112,26 +111,11 @@ public class VehicleController extends BaseController {
|
||||||
**/
|
**/
|
||||||
@RequiresPermissions("couplet:vehicle:list")
|
@RequiresPermissions("couplet:vehicle:list")
|
||||||
@GetMapping("/getBindLogoById/{vehicleId}")
|
@GetMapping("/getBindLogoById/{vehicleId}")
|
||||||
public Result<List<Long>> getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||||
|
|
||||||
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
||||||
|
|
||||||
|
|
||||||
return Result.success(bindLogoById);
|
return Result.success(bindLogoById);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @Date: 2024/4/2 15:35
|
|
||||||
* @Description: 通过vin码查询车辆
|
|
||||||
* @Param: [vin]
|
|
||||||
* @Return: com.couplet.common.core.domain.Result<java.util.List<com.couplet.vehicle.domain.Vehicle>>
|
|
||||||
**/
|
|
||||||
@GetMapping("/findByVIN/{vin}")
|
|
||||||
public Result<List<Vehicle>> findByVIN(@PathVariable("vin") String vin) {
|
|
||||||
List<Vehicle> list = vehicleService.findByVIN(vin);
|
|
||||||
|
|
||||||
return Result.success(list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ import lombok.experimental.SuperBuilder;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@TableName("couplet_vehicle")
|
@TableName("couplet_vehicle")
|
||||||
public class Vehicle{
|
public class Vehicle {
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*车辆id
|
*车辆id
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.couplet.vehicle.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fufanrui
|
|
||||||
* @version 1.0
|
|
||||||
* @description: TODO
|
|
||||||
* @date 2024/4/2 11:22
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@ToString
|
|
||||||
public class VehicleMiddle{
|
|
||||||
|
|
||||||
private Long middleId;
|
|
||||||
private Long userId;
|
|
||||||
private Long vehicleId;
|
|
||||||
private Long delFlag;
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,12 +2,9 @@ package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ProjectName: five-groups-couplet
|
* @ProjectName: five-groups-couplet
|
||||||
* @Author: LiuYunHu
|
* @Author: LiuYunHu
|
||||||
|
@ -17,11 +14,4 @@ import java.util.List;
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
@Component
|
||||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
|
||||||
|
|
||||||
Integer deleteVehicle(Long middleId);
|
|
||||||
|
|
||||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
|
||||||
|
|
||||||
List<Vehicle> vehicleAll();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.couplet.vehicle.mapper;
|
package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
import com.couplet.vehicle.domain.VehicleType;
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.couplet.vehicle.remote;
|
|
||||||
|
|
||||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
|
||||||
import com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆服务
|
|
||||||
*
|
|
||||||
* @author couplet
|
|
||||||
*/
|
|
||||||
@FeignClient(contextId = "remoteVehicleService",value = ServiceNameConstants.VEHICLE_SERVICE, fallbackFactory = RemoteVehicleFallbackFactory.class, path = "/vehicle")
|
|
||||||
@Component
|
|
||||||
public interface RemoteVehicleService {
|
|
||||||
|
|
||||||
@GetMapping("/findByVIN/{vin}")
|
|
||||||
public Result<List<Vehicle>> findByVIN(@PathVariable("vin") String vin);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.couplet.vehicle.remote.factory;
|
|
||||||
|
|
||||||
import com.couplet.common.core.domain.Result;
|
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
|
||||||
import com.couplet.vehicle.remote.RemoteVehicleService;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆服务降级处理
|
|
||||||
*
|
|
||||||
* @author couplet
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteVehicleFallbackFactory.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RemoteVehicleService create(Throwable throwable) {
|
|
||||||
log.error("车辆服务调用失败:{}", throwable.getMessage());
|
|
||||||
return new RemoteVehicleService() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<Vehicle>> findByVIN(String vin) {
|
|
||||||
return Result.error("车辆服务调用失败:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ package com.couplet.vehicle.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
|
||||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||||
|
@ -26,15 +25,4 @@ public interface VehicleService extends IService<Vehicle> {
|
||||||
String insert(VehicleInsertParams insertParams);
|
String insert(VehicleInsertParams insertParams);
|
||||||
|
|
||||||
List<Long> getBindLogoById(Long vehicleId);
|
List<Long> getBindLogoById(Long vehicleId);
|
||||||
|
|
||||||
List<Vehicle> findByVIN(String vin);
|
|
||||||
|
|
||||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
|
||||||
|
|
||||||
Integer deleteVehicle(Long middleId);
|
|
||||||
|
|
||||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
|
||||||
|
|
||||||
List<Vehicle> vehicleAll();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.couplet.common.core.domain.Result;
|
import com.couplet.common.core.domain.Result;
|
||||||
import com.couplet.common.core.utils.StringUtils;
|
import com.couplet.common.core.utils.StringUtils;
|
||||||
import com.couplet.common.core.utils.uuid.UUID;
|
|
||||||
import com.couplet.common.security.utils.SecurityUtils;
|
|
||||||
import com.couplet.vehicle.domain.Vehicle;
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
|
||||||
import com.couplet.vehicle.domain.VehicleType;
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
|
@ -17,6 +14,7 @@ import com.couplet.vehicle.mapper.VehicleMapper;
|
||||||
import com.couplet.vehicle.service.VehicleAndLogoService;
|
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||||
import com.couplet.vehicle.service.VehicleService;
|
import com.couplet.vehicle.service.VehicleService;
|
||||||
import com.couplet.vehicle.service.VehicleTypeService;
|
import com.couplet.vehicle.service.VehicleTypeService;
|
||||||
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -189,14 +187,6 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//UUID生成17位随机字符串
|
|
||||||
UUID uuid = UUID.randomUUID();
|
|
||||||
String string = uuid.toString();
|
|
||||||
String s = string.replaceAll("-", "");
|
|
||||||
String vin = s.substring(0, 17);
|
|
||||||
// System.out.println(vin+" "+vin.length());
|
|
||||||
|
|
||||||
/*
|
|
||||||
//雪花算法生成随机数
|
//雪花算法生成随机数
|
||||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
long randomId = idGenerator.nextId();
|
long randomId = idGenerator.nextId();
|
||||||
|
@ -206,8 +196,6 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//切割,只留后17位
|
//切割,只留后17位
|
||||||
vin = vin.substring(vin.length() - 17);
|
vin = vin.substring(vin.length() - 17);
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//创建入参对象
|
//创建入参对象
|
||||||
Vehicle vehicle = new Vehicle();
|
Vehicle vehicle = new Vehicle();
|
||||||
|
@ -255,46 +243,4 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
return logoIds;
|
return logoIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @param userId:
|
|
||||||
* @return List<Vehicle>
|
|
||||||
* @author 付凡芮
|
|
||||||
* @description 根据登入人id查询管理车辆
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Vehicle> UserUnderTheVehicleList(Long userId) {
|
|
||||||
return vehicleMapper.UserUnderTheVehicleList(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer deleteVehicle(Long middleId) {
|
|
||||||
return vehicleMapper.deleteVehicle(middleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
|
||||||
|
|
||||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Vehicle> vehicleAll() {
|
|
||||||
return vehicleMapper.vehicleAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Vehicle> findByVIN(String vin) {
|
|
||||||
|
|
||||||
//创建查询条件包装器
|
|
||||||
LambdaQueryWrapper<Vehicle> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(vin)) {
|
|
||||||
queryWrapper.eq(Vehicle::getVin, vin);
|
|
||||||
}
|
|
||||||
|
|
||||||
//执行查询
|
|
||||||
return this.list(queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory
|
|
|
@ -29,4 +29,4 @@ spring:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.couplet.vehicle.mapper: DEBUG
|
com.couplet.system.mapper: DEBUG
|
||||||
|
|
|
@ -5,59 +5,4 @@
|
||||||
<mapper namespace="com.couplet.vehicle.mapper.VehicleMapper">
|
<mapper namespace="com.couplet.vehicle.mapper.VehicleMapper">
|
||||||
|
|
||||||
|
|
||||||
<sql id="selectMiddleUserOrVehicle">
|
|
||||||
SELECT
|
|
||||||
m.middle_id,
|
|
||||||
m.user_id,
|
|
||||||
m.vehicle_id,
|
|
||||||
m.del_flag,
|
|
||||||
v.vehicle_type,
|
|
||||||
v.motor_manufacturer,
|
|
||||||
v.battery_manufacturer,
|
|
||||||
v.motor_number,
|
|
||||||
v.battery_number,
|
|
||||||
v.vin,
|
|
||||||
v.vehicle_state,
|
|
||||||
t.vehicle_type_name
|
|
||||||
FROM
|
|
||||||
`couplet_middle` m
|
|
||||||
LEFT JOIN couplet_vehicle v ON m.vehicle_id = v.vehicle_id
|
|
||||||
LEFT JOIN couplet_vehicle_type t ON v.vehicle_id = t.vehicle_type_id
|
|
||||||
WHERE m.del_flag = 0
|
|
||||||
</sql>
|
|
||||||
<sql id="selectVehicle">
|
|
||||||
select
|
|
||||||
v.vehicle_id,
|
|
||||||
v.motor_manufacturer,
|
|
||||||
v.battery_manufacturer,
|
|
||||||
v.motor_number,
|
|
||||||
v.battery_number,
|
|
||||||
v.vin,
|
|
||||||
v.vehicle_state,
|
|
||||||
t.vehicle_type_name
|
|
||||||
from couplet_vehicle v
|
|
||||||
left join couplet_vehicle_type t on v.vehicle_type = t.vehicle_type_id
|
|
||||||
where v.isdelete = 0
|
|
||||||
</sql>
|
|
||||||
<insert id="addVehicle">
|
|
||||||
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
|
||||||
<foreach collection="vehicleId" item="vehicleId" separator=",">
|
|
||||||
(#{userId}, #{vehicleId}, 0)
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
<delete id="deleteVehicle">
|
|
||||||
update couplet_middle
|
|
||||||
set del_flag = '2'
|
|
||||||
where middle_id = #{middleId}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<select id="UserUnderTheVehicleList" resultType="com.couplet.vehicle.domain.Vehicle">
|
|
||||||
<include refid="selectMiddleUserOrVehicle"/>
|
|
||||||
<if test="userId!=null">
|
|
||||||
AND m.user_id = #{userId}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
<select id="vehicleAll" resultType="com.couplet.vehicle.domain.Vehicle">
|
|
||||||
<include refid="selectVehicle"/>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import com.couplet.common.core.utils.uuid.UUID;
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ProjectName: five-groups-couplet
|
* @ProjectName: five-groups-couplet
|
||||||
|
@ -11,32 +11,23 @@ public class IdTest {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
//
|
|
||||||
// long l = idGenerator.nextId();
|
long l = idGenerator.nextId();
|
||||||
// String s = "VIN" + l;
|
String s = "VIN" + l;
|
||||||
// System.out.println(l);
|
System.out.println(l);
|
||||||
// System.out.println(s);
|
System.out.println(s);
|
||||||
// System.out.println("剪切前长度:" + s.length());
|
System.out.println("剪切前长度:" + s.length());
|
||||||
//
|
|
||||||
//
|
|
||||||
// String last17 = s.substring(s.length() - 17);
|
|
||||||
// System.out.println("剪切后:"+last17+" 长度:"+last17.length());
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// System.out.println("----------------------");
|
|
||||||
//
|
|
||||||
// String s1 = "1224069209961664512";
|
|
||||||
// String substring = s1.substring(s1.length() - 17);
|
|
||||||
// System.out.println(substring);
|
|
||||||
for (int i = 0; i < 22; i++) {
|
|
||||||
UUID uuid = UUID.randomUUID();
|
|
||||||
String string = uuid.toString();
|
|
||||||
String s = string.replaceAll("-", "");
|
|
||||||
String substring = s.substring(0, 17);
|
|
||||||
System.out.println(substring);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
String last17 = s.substring(s.length() - 17);
|
||||||
|
System.out.println("剪切后:"+last17+" 长度:"+last17.length());
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("----------------------");
|
||||||
|
|
||||||
|
String s1 = "1224069209961664512";
|
||||||
|
String substring = s1.substring(s1.length() - 17);
|
||||||
|
System.out.println(substring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class SysDeptController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*根据deptId获取企业名称
|
*
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
||||||
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId){
|
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId){
|
||||||
|
|
|
@ -16,11 +16,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 172469
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -279,13 +279,6 @@
|
||||||
<version>${couplet.version}</version>
|
<version>${couplet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 车辆上线模块-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-modules-online</artifactId>
|
|
||||||
<version>${couplet.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue