Compare commits
17 Commits
73c2c159e8
...
6ab26976d6
Author | SHA1 | Date |
---|---|---|
|
6ab26976d6 | |
|
de572170ec | |
|
bbd9e52302 | |
|
c7443b81d7 | |
|
ffa06bc02e | |
|
4b80034baf | |
|
3947f9414e | |
|
99dc4e832f | |
|
00369a6052 | |
|
a9977b44a9 | |
|
b644752443 | |
|
aaa5d4f868 | |
|
72b634fcc1 | |
|
8d54e991dc | |
|
831ba2668c | |
|
f9ec95317c | |
|
fa79d7a83b |
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -20,4 +20,14 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "couplet-file";
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 车辆管理模块
|
||||
* @date
|
||||
*/
|
||||
public static final String VEHICLE_SERVICE = "couplet-vehicle";
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ public interface RemoteDeptService {
|
|||
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
||||
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId);
|
||||
|
||||
|
||||
/*
|
||||
* @param dept:
|
||||
* @return Result
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package com.couplet.common.system.remote;
|
||||
|
||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.system.domain.SysUser;
|
||||
import com.couplet.common.system.remote.factory.RemoteEmployeeFallbackFactory;
|
||||
import lombok.extern.java.Log;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 远程调用用户服务
|
||||
* @date
|
||||
*/
|
||||
@FeignClient(contextId = "remoteEmployeeService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||
fallbackFactory = RemoteEmployeeFallbackFactory.class,
|
||||
path = "/user")
|
||||
public interface RemoteEmployeeService {
|
||||
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result<TableDataInfo<SysUser>>
|
||||
* @author 付凡芮
|
||||
* @description 调用用户列表
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Result<TableDataInfo<SysUser>> list (SysUser user);
|
||||
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加用户管理
|
||||
* @date
|
||||
*/
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改用户
|
||||
* @date
|
||||
*/
|
||||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody SysUser user);
|
||||
|
||||
|
||||
/*
|
||||
* @param userIds:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除用户
|
||||
* @date
|
||||
*/
|
||||
@DeleteMapping("/{userIds}")
|
||||
public Result remove (@PathVariable(value = "userIds") Long[] userIds);
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description X修改用户状态
|
||||
* @date
|
||||
*/
|
||||
@PutMapping("/changeStatus")
|
||||
public Result changeStatus (@RequestBody SysUser user);
|
||||
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result<List<SysUser>>
|
||||
* @author 付凡芮
|
||||
* @description 根据deptId获取企业下有那些员工
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("userList/{deptId}")
|
||||
public Result<List<SysUser>> userList(@PathVariable(value = "deptId") Long deptId);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @description: 企业服务降级处理
|
||||
* @date 2024/3/27 15:29
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -30,7 +30,6 @@ public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptServ
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
*
|
||||
|
@ -41,6 +40,7 @@ public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptServ
|
|||
public Result<List<SysDept>> getSysDeptByDeptId(Long deptId) {
|
||||
return Result.error("调用失败...."+cause.getMessage());
|
||||
}
|
||||
|
||||
/*
|
||||
* @param cause:
|
||||
* @return RemoteDeptService
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.couplet.common.system.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.system.domain.SysUser;
|
||||
import com.couplet.common.system.remote.RemoteEmployeeService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 员工服务降级处理
|
||||
* @date 2024/3/31 19:43
|
||||
*/
|
||||
public class RemoteEmployeeFallbackFactory implements FallbackFactory<RemoteEmployeeService> {
|
||||
@Override
|
||||
public RemoteEmployeeService create(Throwable cause) {
|
||||
return new RemoteEmployeeService() {
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result<TableDataInfo<SysUser>>
|
||||
* @author 付凡芮
|
||||
* @description 员工列表
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result<TableDataInfo<SysUser>> list(SysUser user) {
|
||||
return Result.error("调用失败"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result add(SysUser user) {
|
||||
return Result.error("调用失败"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result edit(SysUser user) {
|
||||
return Result.error("调用失败"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result remove(Long[] userIds) {
|
||||
return Result.error("调用失败"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result changeStatus(SysUser user) {
|
||||
return Result.error("调用失败"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<SysUser>> userList(Long deptId) {
|
||||
return Result.error("调用失败...."+cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -2,3 +2,4 @@ com.couplet.common.system.remote.factory.RemoteUserFallbackFactory
|
|||
com.couplet.common.system.remote.factory.RemoteLogFallbackFactory
|
||||
com.couplet.common.system.remote.factory.RemoteFileFallbackFactory
|
||||
com.couplet.common.system.remote.factory.RemoteDeptFallbackFactory
|
||||
com.couplet.common.system.remote.factory.RemoteEmployeeFallbackFactory
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-analyze-incident</artifactId>
|
||||
<artifactId>couplet-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-incident-remote</artifactId>
|
||||
<artifactId>couplet-common-vehicle</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -17,9 +17,10 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- MuYu Common Core-->
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-incident-remote</artifactId>
|
||||
<artifactId>couplet-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
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;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
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;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
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;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
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();
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.couplet.common.system.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -19,6 +19,7 @@
|
|||
<module>couplet-common-datasource</module>
|
||||
<module>couplet-common-system</module>
|
||||
<module>couplet-trouble-log</module>
|
||||
<module>couplet-common-vehicle</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>couplet-common</artifactId>
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -1,20 +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-analyze-incident</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-incident-server</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>
|
||||
|
||||
</project>
|
|
@ -1,19 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.controller;
|
||||
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* 事件控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/incident")
|
||||
public class IncidentController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 事件系统接口
|
||||
*/
|
||||
public interface IncidentService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.service.impl;
|
||||
|
||||
import com.couplet.analyze.incident.server.service.IncidentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 故障事件
|
||||
*/
|
||||
@Service("breakdown")
|
||||
public class BreakdownServiceImpl implements IncidentService {
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.service.impl;
|
||||
|
||||
import com.couplet.analyze.incident.server.service.IncidentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 电子围栏事件服务实现类
|
||||
*/
|
||||
@Service("electronic-fence")
|
||||
public class ElectronicFenceServiceImpl implements IncidentService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.service.impl;
|
||||
|
||||
import com.couplet.analyze.incident.server.service.IncidentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 实时数据事件
|
||||
*/
|
||||
@Service("real-time-data")
|
||||
public class RealTimeDataServiceImpl implements IncidentService {
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.couplet.analyze.incident.server.service.impl;
|
||||
|
||||
import com.couplet.analyze.incident.server.service.IncidentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 事件存储服务
|
||||
*/
|
||||
@Service("stored-event")
|
||||
public class StoredEventServiceImpl implements IncidentService {
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9999
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-incident
|
||||
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
level:
|
||||
com.couplet.trouble.mapper: DEBUG
|
|
@ -1,25 +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-analyze</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-analyze-incident</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>couplet-incident-remote</module>
|
||||
<module>couplet-incident-server</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -86,18 +86,6 @@
|
|||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RabbitMQ依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Kafka依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.couplet.analyze.msg;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
|
@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||
* @description
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||
public class CoupletMsgApplication {
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.couplet.analyze.msg.contents;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: kafka常量类
|
||||
* @Date 2023/8/25 18:47
|
||||
* @author DongXiaoDong
|
||||
* @description: Mqtt常量类
|
||||
* @Date 2024/4/1 18:47
|
||||
*/
|
||||
public class MsgContent {
|
||||
|
||||
public static final String BROKER_URL = "tcp://111.229.33.194:1883";
|
||||
public static final String BROKER_URL = "tcp://8.130.181.16:1883";
|
||||
|
||||
public static final String CLIENT_ID = "mqttx_32dcaf76";
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Date;
|
|||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/2 15:26
|
||||
* @description
|
||||
* @description 报文信息实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -260,4 +260,8 @@ public class CoupletMsgData {
|
|||
* CHG(充电机)状态 1:正常 0:故障
|
||||
*/
|
||||
private int chgStatus;
|
||||
|
||||
public CoupletMsgData(String s) {
|
||||
this.vin = s;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.couplet.analyze.msg.mapper;
|
||||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description:
|
||||
*/
|
||||
@Mapper
|
||||
public interface IncidentMapper {
|
||||
/**
|
||||
* 新增存储事件
|
||||
* @param coupletMsgData
|
||||
*/
|
||||
public void reportMapper(CoupletMsgData coupletMsgData);
|
||||
}
|
|
@ -1,26 +1,408 @@
|
|||
package com.couplet.analyze.msg.model;
|
||||
|
||||
import com.couplet.analyze.msg.service.CoupletMsgService;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.couplet.analyze.msg.contents.MsgContent.BROKER_URL;
|
||||
import static com.couplet.analyze.msg.contents.MsgContent.CLIENT_ID;
|
||||
import static io.lettuce.core.pubsub.PubSubOutput.Type.message;
|
||||
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/2 15:41
|
||||
* @description
|
||||
* @description 解析报文数据
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ModelMessage {
|
||||
|
||||
// @Autowired
|
||||
// private CoupletMsgService coupletMsgService;
|
||||
|
||||
// @Autowired
|
||||
// public ModelMessage(CoupletMsgService coupletMsgService){
|
||||
// this.coupletMsgService = coupletMsgService;
|
||||
// }
|
||||
static ArrayList<String> strings = new ArrayList<>() {
|
||||
{
|
||||
add("breakdown");
|
||||
add("electronic-fence");
|
||||
add("real-time-data");
|
||||
add("stored-event");
|
||||
}
|
||||
};
|
||||
|
||||
@Value("${mq.queueName}")
|
||||
public String queueName;
|
||||
|
||||
//交换机
|
||||
@Value("${mq.exchangeName}")
|
||||
public String exchangeName;
|
||||
|
||||
//路由键
|
||||
@Value("${mq.routingKey}")
|
||||
public String routingKey;
|
||||
|
||||
@Scheduled(cron = "0/5 * * * * ?")
|
||||
public void startMsg() {
|
||||
// try {
|
||||
// new MqttClient()
|
||||
// }
|
||||
try {
|
||||
MqttClient mqttClient = new MqttClient(BROKER_URL, CLIENT_ID);
|
||||
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
|
||||
options.setCleanSession(true);
|
||||
mqttClient.connect(options);
|
||||
|
||||
mqttClient.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
log.error("Mqtt[{}-{}]连接断开:[{}]", CLIENT_ID, BROKER_URL, throwable.getMessage(), throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
|
||||
//打印接收到的消息和主题
|
||||
log.info("主题='{}':消息内容={}", topic, new String(mqttMessage.getPayload()));
|
||||
String str = hexToString(new String(mqttMessage.getPayload()));
|
||||
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
||||
|
||||
for (CoupletMsgData msgData : coupletMsgDataList) {
|
||||
log.info("解析到车辆数据:{}", msgData);
|
||||
//发送日志到MQ
|
||||
for (String string : strings) {
|
||||
IncidentService incidentService = SpringUtils.getBean(string);
|
||||
incidentService.incident(msgData);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||
log.info("消息已投递成功:{}",token);
|
||||
}
|
||||
});
|
||||
mqttClient.subscribe("test",0);
|
||||
|
||||
Thread.sleep(1000*60*10);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将16进制字符串转换为ASCII字符串
|
||||
* @param s 16进制字符串
|
||||
* @return ASCII字符串
|
||||
*/
|
||||
public static String hexToString(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
return null;
|
||||
}
|
||||
s = s.replace(" ", "");
|
||||
byte[] baKeyword = new byte[s.length() / 2];
|
||||
for (int i = 0; i < baKeyword.length; i++) {
|
||||
try {
|
||||
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static List<CoupletMsgData> sendMsg(String str) {
|
||||
List<CoupletMsgData> coupletMsgDataList = new ArrayList<>();
|
||||
CoupletMsgData coupletMsgData = new CoupletMsgData();
|
||||
|
||||
coupletMsgData.setVin(str.substring(1,18));
|
||||
|
||||
log.info("vin=="+coupletMsgData.getVin());
|
||||
|
||||
//时间
|
||||
String tim =str.substring(18,31);
|
||||
long timestamp = Long.parseLong(tim);
|
||||
|
||||
Date date = new Date(timestamp);
|
||||
coupletMsgData.setCreateTime(date);
|
||||
|
||||
//经度
|
||||
String lt = str.substring(31,42);
|
||||
// 如果末尾是零,则舍去
|
||||
int endIndex = lt.length() - 1;
|
||||
while (lt.charAt(endIndex) == '0'){
|
||||
endIndex--;
|
||||
}
|
||||
|
||||
String longitude = lt.substring(0, endIndex + 1);
|
||||
coupletMsgData.setLongitude(longitude);
|
||||
|
||||
//维度
|
||||
String latitudeIndex =str.substring(42,52);
|
||||
int endIndexT = latitudeIndex.length() - 1;
|
||||
while (latitudeIndex.charAt(endIndexT) == '0'){
|
||||
endIndexT--;
|
||||
}
|
||||
|
||||
String latitude = latitudeIndex.substring(0, endIndexT + 1);
|
||||
coupletMsgData.setLatitude(latitude);
|
||||
|
||||
//速度speed
|
||||
String speed =str.substring(52,58);
|
||||
coupletMsgData.setSpeed(speed);
|
||||
|
||||
//里程
|
||||
BigDecimal mileage= new BigDecimal(str.substring(58,69));
|
||||
mileage=mileage.stripTrailingZeros();
|
||||
coupletMsgData.setMileage(mileage);
|
||||
|
||||
//总电压
|
||||
String voltage =str.substring(69,75);
|
||||
while (voltage.endsWith("0")) {
|
||||
voltage = voltage.substring(0, voltage.length() - 1); // 去除末尾的零
|
||||
}
|
||||
coupletMsgData.setVoltage(voltage);
|
||||
|
||||
//总电流
|
||||
String current =str.substring(75,80);
|
||||
while (current.endsWith("0")){
|
||||
current=current.substring(0,current.length()-1);
|
||||
}
|
||||
coupletMsgData.setCurrent(current);
|
||||
|
||||
//绝缘电阻 resistance
|
||||
String res =str.substring(80,89);
|
||||
String resistance = res.substring(0, 5);
|
||||
coupletMsgData.setResistance(resistance);
|
||||
|
||||
//档位
|
||||
String gear =str.substring(89,90);
|
||||
coupletMsgData.setGear(gear);
|
||||
|
||||
//accelerationPedal 加速踏板行程值
|
||||
String accelerationPedal =str.substring(90,91);
|
||||
coupletMsgData.setAccelerationPedal(accelerationPedal);
|
||||
|
||||
//brakePedal 制动踏板行程值
|
||||
String brakePedal =str.substring(92,93);
|
||||
coupletMsgData.setBrakePedal(brakePedal);
|
||||
|
||||
//fuelConsumptionRate 燃料消耗率
|
||||
String fuelConsumptionRate =str.substring(94,99);
|
||||
coupletMsgData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||
|
||||
//motorControllerTemperature 电机控制器温度
|
||||
String motorControllerTemperature =str.substring(99,105);
|
||||
while (motorControllerTemperature.endsWith("0")){
|
||||
motorControllerTemperature=motorControllerTemperature.substring(0,motorControllerTemperature.length()-1);
|
||||
}
|
||||
coupletMsgData.setMotorControllerTemperature(motorControllerTemperature);
|
||||
|
||||
//motorSpeed 电机转速
|
||||
String motorSpeed =str.substring(105,110);
|
||||
coupletMsgData.setMotorSpeed(motorSpeed);
|
||||
|
||||
//motorTorque 电机转矩
|
||||
String motorTorque =str.substring(110,114);
|
||||
while (motorTorque.endsWith("0")){
|
||||
motorTorque=motorTorque.substring(0,motorTorque.length()-1);
|
||||
}
|
||||
coupletMsgData.setMotorTorque(motorTorque);
|
||||
|
||||
//motorTemperature 电机温度
|
||||
String motorTemperature =str.substring(114,120);
|
||||
while (motorTemperature.endsWith("0")){
|
||||
motorTemperature=motorTemperature.substring(0,motorTemperature.length()-1);
|
||||
}
|
||||
coupletMsgData.setMotorTemperature(motorTemperature);
|
||||
|
||||
//motorVoltage 电机电压
|
||||
String motorVoltage =str.substring(120,125);
|
||||
while (motorVoltage.endsWith("0")){
|
||||
motorVoltage=motorVoltage.substring(0,motorVoltage.length()-1);
|
||||
}
|
||||
coupletMsgData.setMotorVoltage(motorVoltage);
|
||||
|
||||
//motorCurrent 电机电流
|
||||
String motorCurrent =str.substring(125,133);
|
||||
while (motorCurrent.endsWith("0")){
|
||||
motorCurrent=motorCurrent.substring(0,motorCurrent.length()-1);
|
||||
}
|
||||
coupletMsgData.setMotorCurrent(motorCurrent);
|
||||
|
||||
//remainingBattery 动力电池剩余电量SOC
|
||||
BigDecimal remainingBattery = new BigDecimal(str.substring(133,138));
|
||||
coupletMsgData.setRemainingBattery(remainingBattery);
|
||||
|
||||
//maximumFeedbackPower 当前状态允许的最大反馈功率
|
||||
String maximumFeedbackPower =str.substring(139,144);
|
||||
while (maximumFeedbackPower.endsWith("0")){
|
||||
maximumFeedbackPower=maximumFeedbackPower.substring(0,maximumFeedbackPower.length()-1);
|
||||
}
|
||||
coupletMsgData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||
|
||||
//maximumDischargePower 当前状态允许最大放电功率
|
||||
String maximumDischargePower =str.substring(145,151);
|
||||
while (maximumDischargePower.endsWith("0")){
|
||||
maximumDischargePower=maximumDischargePower.substring(0,maximumDischargePower.length()-1);
|
||||
}
|
||||
coupletMsgData.setMaximumDischargePower(maximumDischargePower);
|
||||
|
||||
//selfCheckCounter BMS自检计数器
|
||||
String selfCheckCounter =str.substring(151,153);
|
||||
String selfCheckCounterReplace = selfCheckCounter.replace("0", "");
|
||||
coupletMsgData.setSelfCheckCounter(selfCheckCounterReplace);
|
||||
|
||||
//totalBatteryCurrent 动力电池充放电电流
|
||||
String totalBatteryCurrent =str.substring(153,158);
|
||||
while (totalBatteryCurrent.endsWith("0")){
|
||||
totalBatteryCurrent=totalBatteryCurrent.substring(0,totalBatteryCurrent.length()-1);
|
||||
}
|
||||
coupletMsgData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||
|
||||
//totalBatteryVoltage 动力电池负载端总电压V3
|
||||
String totalBatteryVoltage =str.substring(158,164);
|
||||
while (totalBatteryVoltage.endsWith("0")){
|
||||
totalBatteryVoltage=totalBatteryVoltage.substring(0,totalBatteryVoltage.length()-1);
|
||||
}
|
||||
coupletMsgData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||
|
||||
//singleBatteryMaxVoltage 单次最大电压
|
||||
String singleBatteryMaxVoltage =str.substring(164,168);
|
||||
while (singleBatteryMaxVoltage.endsWith("0")){
|
||||
singleBatteryMaxVoltage=singleBatteryMaxVoltage.substring(0,singleBatteryMaxVoltage.length()-1);
|
||||
}
|
||||
coupletMsgData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||
|
||||
//singleBatteryMinVoltage 单体电池最低电压
|
||||
String singleBatteryMinVoltage =str.substring(168,172);
|
||||
while (singleBatteryMinVoltage.endsWith("0")){
|
||||
singleBatteryMinVoltage=singleBatteryMinVoltage.substring(0,singleBatteryMinVoltage.length()-1);
|
||||
}
|
||||
|
||||
coupletMsgData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||
|
||||
//singleBatteryMaxTemperature 单体电池最高温度
|
||||
String singleBatteryMaxTemperature =str.substring(172,178);
|
||||
while (singleBatteryMaxTemperature.endsWith("0")){
|
||||
singleBatteryMaxTemperature=singleBatteryMaxTemperature.substring(0,singleBatteryMaxTemperature.length()-1);
|
||||
}
|
||||
coupletMsgData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||
|
||||
//singleBatteryMinTemperature 单体电池最低温度
|
||||
String singleBatteryMinTemperature =str.substring(178,184);
|
||||
while (singleBatteryMinTemperature.endsWith("0")){
|
||||
singleBatteryMinTemperature=singleBatteryMinTemperature.substring(0,singleBatteryMinTemperature.length()-1);
|
||||
}
|
||||
coupletMsgData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||
|
||||
//availableBatteryCapacity 可用电池容量
|
||||
String availableBatteryCapacity =str.substring(184,190);
|
||||
while (availableBatteryCapacity.endsWith("0")){
|
||||
availableBatteryCapacity=availableBatteryCapacity.substring(0,availableBatteryCapacity.length()-1);
|
||||
}
|
||||
coupletMsgData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||
|
||||
//vehicleStatus 车辆状态
|
||||
int vehicleStatus = Integer.parseInt(str.substring(190,191));
|
||||
coupletMsgData.setVehicleStatus(vehicleStatus);
|
||||
|
||||
//chargingStatus 充电状态
|
||||
int chargingStatus = Integer.parseInt(str.substring(191,192));
|
||||
coupletMsgData.setChargingStatus(chargingStatus);
|
||||
|
||||
//operatingStatus 运行状态
|
||||
int operatingStatus = Integer.parseInt(str.substring(192,193));
|
||||
coupletMsgData.setOperatingStatus(operatingStatus);
|
||||
|
||||
//socStatus SOC
|
||||
int socStatus = Integer.parseInt(str.substring(193,194));
|
||||
coupletMsgData.setSocStatus(socStatus);
|
||||
|
||||
//chargingEnergyStorageStatus 可充电储能装置工作状态
|
||||
int chargingEnergyStorageStatus = Integer.parseInt(str.substring(194,195));
|
||||
coupletMsgData.setChargingEnergyStorageStatus(chargingEnergyStorageStatus);
|
||||
|
||||
//driveMotorStatus 驱动电机状态
|
||||
int driveMotorStatus = Integer.parseInt(str.substring(195,196));
|
||||
coupletMsgData.setDriveMotorStatus(driveMotorStatus);
|
||||
|
||||
//positionStatus 定位是否有效
|
||||
int positionStatus = Integer.parseInt(str.substring(196,197));
|
||||
coupletMsgData.setPositionStatus(positionStatus);
|
||||
|
||||
//easStatus EAS(汽车防盗系统)状态
|
||||
int easStatus = Integer.parseInt(str.substring(197,198));
|
||||
coupletMsgData.setEasStatus(easStatus);
|
||||
|
||||
//ptcStatus PTC(电动加热器)状态
|
||||
int ptcStatus = Integer.parseInt(str.substring(198,199));
|
||||
coupletMsgData.setPtcStatus(ptcStatus);
|
||||
|
||||
//epsStatus
|
||||
int epsStatus = Integer.parseInt(str.substring(199,200));
|
||||
coupletMsgData.setEpsStatus(epsStatus);
|
||||
|
||||
//absStatus EPS(电动助力系统)状态
|
||||
int absStatus = Integer.parseInt(str.substring(200,201));
|
||||
coupletMsgData.setAbsStatus(absStatus);
|
||||
|
||||
//mcuStatus MCU(电机/逆变器)状态
|
||||
int mcuStatus = Integer.parseInt(str.substring(201,202));
|
||||
coupletMsgData.setMcuStatus(mcuStatus);
|
||||
|
||||
//heatingStatus 动力电池加热状态
|
||||
int heatingStatus = Integer.parseInt(str.substring(202,203));
|
||||
coupletMsgData.setHeatingStatus(heatingStatus);
|
||||
|
||||
//batteryStatus 动力电池当前状态
|
||||
int batteryStatus = Integer.parseInt(str.substring(203,204));
|
||||
coupletMsgData.setBatteryStatus(batteryStatus);
|
||||
|
||||
//batteryInsulationStatus 动力电池保温状态
|
||||
int batteryInsulationStatus = Integer.parseInt(str.substring(204,205));
|
||||
coupletMsgData.setBatteryInsulationStatus(batteryInsulationStatus);
|
||||
|
||||
//dcdcStatus DCDC(电力交换系统)状态
|
||||
int dcdcStatus = Integer.parseInt(str.substring(205,206));
|
||||
coupletMsgData.setDcdcStatus(dcdcStatus);
|
||||
|
||||
//chgStatus CHG(充电机)状态
|
||||
int chgStatus = Integer.parseInt(str.substring(206,207));
|
||||
coupletMsgData.setChgStatus(chgStatus);
|
||||
|
||||
coupletMsgDataList.add(coupletMsgData);
|
||||
|
||||
return coupletMsgDataList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package com.couplet.analyze.msg.service;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/2 16:44
|
||||
* @description
|
||||
*/
|
||||
public interface CoupletMsgService {
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.couplet.analyze.msg.service;
|
||||
|
||||
import com.couplet.analyze.msg.contents.MsgContent;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 事件系统接口
|
||||
*/
|
||||
public interface IncidentService {
|
||||
|
||||
/**
|
||||
* 事件分析
|
||||
*
|
||||
* @param coupletMsgData
|
||||
*/
|
||||
void incident(CoupletMsgData coupletMsgData);
|
||||
|
||||
/**
|
||||
* 获取事件名称
|
||||
* @return 事件名称
|
||||
*/
|
||||
String getName();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
//package com.couplet.analyze.msg.service.impl;
|
||||
//
|
||||
//import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
//import com.couplet.analyze.msg.service.IncidentService;
|
||||
//import com.couplet.common.log.annotation.Log;
|
||||
//import lombok.extern.log4j.Log4j2;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * @Author: LiJiaYao
|
||||
// * @Date: 2024/4/2
|
||||
// * @Description: 故障事件
|
||||
// */
|
||||
//@Service("breakdown")
|
||||
//@Log4j2
|
||||
//public class BreakdownServiceImpl implements IncidentService {
|
||||
// /**
|
||||
// * 故障事件
|
||||
// *
|
||||
// * @param coupletMsgData
|
||||
// */
|
||||
// @Override
|
||||
// public void incident(CoupletMsgData coupletMsgData) {
|
||||
//
|
||||
// log.info("故障事件开始.....");
|
||||
// log.info("故障事件结束.....");
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return 获取事件名称
|
||||
// */
|
||||
// @Override
|
||||
// public String getName() {
|
||||
// return "breakdown";
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,33 @@
|
|||
//package com.couplet.analyze.msg.service.impl;
|
||||
//
|
||||
//import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
//import com.couplet.analyze.msg.service.IncidentService;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * @Author: LiJiaYao
|
||||
// * @Date: 2024/4/2
|
||||
// * @Description: 电子围栏事件服务实现类
|
||||
// */
|
||||
//@Service("electronic-fence")
|
||||
//public class ElectronicFenceServiceImpl implements IncidentService {
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 电子围栏事件
|
||||
// *
|
||||
// * @param coupletMsgData
|
||||
// */
|
||||
// @Override
|
||||
// public void incident(CoupletMsgData coupletMsgData) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return 电子围栏service 名称
|
||||
// */
|
||||
// @Override
|
||||
// public String getName() {
|
||||
// return "electronic-fence";
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,33 @@
|
|||
//package com.couplet.analyze.msg.service.impl;
|
||||
//
|
||||
//import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
//import com.couplet.analyze.msg.service.IncidentService;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * @Author: LiJiaYao
|
||||
// * @Date: 2024/4/2
|
||||
// * @Description: 实时数据事件
|
||||
// */
|
||||
//@Service("real-time-data")
|
||||
//public class RealTimeDataServiceImpl implements IncidentService {
|
||||
//
|
||||
// /**
|
||||
// * 实时数据事件
|
||||
// *
|
||||
// * @param coupletMsgData
|
||||
// */
|
||||
// @Override
|
||||
// public void incident(CoupletMsgData coupletMsgData) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 实时数据事件
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public String getName() {
|
||||
// return "real-time-data";
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,41 @@
|
|||
package com.couplet.analyze.msg.service.impl;
|
||||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description: 事件存储服务
|
||||
*/
|
||||
@Service("stored-event")
|
||||
@Log4j2
|
||||
public class StoredEventServiceImpl implements IncidentService {
|
||||
@Autowired
|
||||
private IncidentMapper incidentMapper;
|
||||
/**
|
||||
* 事件存储服务
|
||||
*
|
||||
* @param coupletMsgData
|
||||
*/
|
||||
@Override
|
||||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
log.info("开始存储......");
|
||||
incidentMapper.reportMapper(coupletMsgData);
|
||||
log.info("结束存储......");
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件存储服务
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stored-event";
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.couplet.analyze.msg.config.RabbitMQConfig
|
|
@ -0,0 +1,56 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9223
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-msg
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
rabbitmq:
|
||||
host: 39.103.133.57
|
||||
port: 5672
|
||||
username: guest
|
||||
password: guest
|
||||
virtual-host: /
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||
publisher-returns: true #确认消息已发送到队列(Queue)
|
||||
listener:
|
||||
simple:
|
||||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
#acknowledge-mode: manual # 设置消费端手动ack确认
|
||||
retry:
|
||||
enabled: true # 是否支持重试
|
||||
template:
|
||||
# 只要消息抵达Queue,就会异步发送优先回调return firm
|
||||
mandatory: true
|
||||
logging:
|
||||
level:
|
||||
com.couplet.analyze.msg.mapper: DEBUG
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
# RabbitMQ配置
|
||||
mq:
|
||||
queueName: queue
|
||||
exchangeName: exchange
|
||||
routingKey: routingKey
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.couplet.analyze.msg.mapper.IncidentMapper">
|
||||
|
||||
|
||||
<insert id="reportMapper">
|
||||
INSERT INTO `vehicle-resolver`.`resolver_report_data`
|
||||
(`vin`, `create_time`, `longitude`, `latitude`,
|
||||
`speed`, `mileage`, `voltage`, `current`, `resistance`, `gear`,
|
||||
`acceleration_pedal`, `fuel_consumption_rate`,
|
||||
`motor_controller_temperature`, `motor_speed`,
|
||||
`motor_torque`, `motor_temperature`, `motor_voltage`,
|
||||
`motor_current`, `remaining_battery`, `maximum_feedback_power`,
|
||||
`maximum_discharge_power`, `self_check_counter`,
|
||||
`total_battery_current`, `total_battery_voltage`,
|
||||
`single_battery_max_voltage`, `single_battery_min_voltage`,
|
||||
`single_battery_max_temperature`, `single_battery_min_temperature`,
|
||||
`available_battery_capacity`, `vehicle_status`, `charging_status`,
|
||||
`operatingStatus`, `soc_status`, `charging_energy_storage_status`,
|
||||
`drive_motor_status`, `position_status`, `eas_status`, `ptc_status`,
|
||||
`eps_status`, `abs_status`, `mcu_status`, `heating_status`, `battery_status`,
|
||||
`battery_insulation_status`, `dcdc_status`, `chg_status`, `brake_pedal`)
|
||||
VALUES (#{vin},
|
||||
#{createTime},
|
||||
#{longitude},
|
||||
#{latitude},
|
||||
#{speed},
|
||||
#{mileage},
|
||||
#{voltage},
|
||||
#{current},
|
||||
#{resistance},
|
||||
#{gear},
|
||||
#{accelerationPedal},
|
||||
#{fuelConsumptionRate},
|
||||
#{motorControllerTemperature},
|
||||
#{motorSpeed},
|
||||
#{motorTorque},
|
||||
#{motorTemperature},
|
||||
#{motorVoltage},
|
||||
#{motorCurrent},
|
||||
#{remainingBattery},
|
||||
#{maximumFeedbackPower},
|
||||
#{maximumDischargePower},
|
||||
#{selfCheckCounter},
|
||||
#{totalBatteryCurrent},
|
||||
#{totalBatteryVoltage},
|
||||
#{singleBatteryMaxVoltage},
|
||||
#{singleBatteryMinVoltage},
|
||||
#{singleBatteryMaxTemperature},
|
||||
#{singleBatteryMinTemperature},
|
||||
#{availableBatteryCapacity},
|
||||
#{vehicleStatus},
|
||||
#{chargingStatus},
|
||||
#{operatingStatus},
|
||||
#{socStatus},
|
||||
#{chargingEnergyStorageStatus},
|
||||
#{driveMotorStatus},
|
||||
#{positionStatus},
|
||||
#{easStatus},
|
||||
#{ptcStatus},
|
||||
#{epsStatus},
|
||||
#{absStatus},
|
||||
#{mcuStatus},
|
||||
#{heatingStatus},
|
||||
#{batteryStatus},
|
||||
#{batteryInsulationStatus},
|
||||
#{dcdcStatus},
|
||||
#{chgStatus},
|
||||
#{brakePedal}
|
||||
);
|
||||
</insert>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,92 @@
|
|||
package com.couplet.msg;
|
||||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
* @Description:
|
||||
*/
|
||||
public class dome {
|
||||
private static final List<String> msgList = new ArrayList<>(){{
|
||||
add("7E 56 49 4e 31 32 33 34 35 36 37 38 39 44 49 4a 45 34 31 37 31 31 37 36 34 31 30 34 35 30 36 31 31 36 2e 36 36 34 33 38 30 30 33 39 2e 35 33 31 39 39 30 30 37 32 2e 30 30 30 33 31 2e 33 37 36 30 30 30 30 30 32 32 30 30 30 30 32 32 30 30 30 38 35 32 30 30 30 30 30 30 44 30 30 38 30 39 2e 36 30 30 39 34 30 30 30 30 35 38 39 30 36 36 37 39 30 39 33 30 30 30 30 32 30 33 30 30 32 30 33 30 30 30 30 30 34 34 32 38 32 2e 35 35 30 30 30 30 31 34 30 30 30 30 38 30 37 30 30 30 30 37 34 34 30 30 30 33 30 30 30 34 30 30 30 39 35 30 30 30 30 35 38 30 30 30 30 35 34 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 24 7E");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 事件列表
|
||||
*/
|
||||
static List<String> list=new ArrayList<>(){
|
||||
{
|
||||
add("breakdown");
|
||||
add("electronic-fence");
|
||||
add("real-time-data");
|
||||
add("stored-event");
|
||||
}
|
||||
};
|
||||
|
||||
static IncidentService incidentService;
|
||||
public static void main(String[] args) {
|
||||
// 去头去尾
|
||||
for (String string : msgList) {
|
||||
String substring = string.substring(2, string.length() - 2);
|
||||
System.out.println("去头去尾字符串:"+ substring);
|
||||
|
||||
String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
|
||||
String asciiString = hexToString(hexStringWithoutSpaces);
|
||||
System.out.println("16进制解析后的数据:"+asciiString);
|
||||
// //截取前17位
|
||||
String substring1 = asciiString.substring(0, 17);
|
||||
System.out.println("VIN:"+substring1);
|
||||
String substring2 = asciiString.substring(17, 30);
|
||||
System.out.println("时间戳:"+substring2);
|
||||
String substring3 = asciiString.substring(30, 40);
|
||||
System.out.println("经度:" +substring3);
|
||||
String substring4 = asciiString.substring(41, 50);
|
||||
System.out.println("纬度:"+ substring4);
|
||||
String substring5 = asciiString.substring(51, 56);
|
||||
System.out.println("车速:"+ substring5);
|
||||
String substring6 = asciiString.substring(57, 67);
|
||||
System.out.println("总里程:"+ substring6);
|
||||
String substring7 = asciiString.substring(68, 73);
|
||||
System.out.println("总电压:"+ substring7);
|
||||
String pattern = "(.{17})(.{10})(.{9})(.{8})(.{2})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher matcher = compile.matcher(asciiString);
|
||||
if (matcher.find()) {
|
||||
for (int i = 1; i < matcher.groupCount(); i++) {
|
||||
System.out.println("Group "+ i + ":" + matcher.group(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoupletMsgData coupletMsgData = new CoupletMsgData();
|
||||
List<CoupletMsgData> objects = msgList.stream().map(CoupletMsgData::new).toList();
|
||||
|
||||
for (CoupletMsgData object : objects) {
|
||||
//测试所有的事件
|
||||
for (String s : list) {
|
||||
IncidentService bean = SpringUtils.getBean(s);
|
||||
|
||||
incidentService.incident(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static String hexToString(String hexString) {
|
||||
StringBuilder asciiString = new StringBuilder();
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -12,9 +12,7 @@
|
|||
<artifactId>couplet-analyze</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>couplet-analyze-incident</module>
|
||||
<module>couplet-analyze-msg</module>
|
||||
<module>couplet-analyze-incident/couplet-incident-server</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -52,9 +52,9 @@ public class FenceController extends BaseController {
|
|||
@RequiresPermissions("couplet:fence:fenceAdd")
|
||||
@Log(title = "电子围栏新增",businessType = BusinessType.INSERT)
|
||||
public Result<?> fenceInsert(HttpServletRequest request, @RequestBody FenceRequest fenceRequest){
|
||||
if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
||||
return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
||||
}
|
||||
// if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
||||
// return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
||||
// }
|
||||
fenceService.fenceInsert(request,fenceRequest);
|
||||
return Result.success("新增成功");
|
||||
}
|
||||
|
|
|
@ -28,7 +28,11 @@ public class FenAndLogoServiceImpl extends ServiceImpl<FenAndLogoMapper, Fence>
|
|||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 业务实现:添加中间表
|
||||
* @param fenceId
|
||||
* @param logoIds
|
||||
*/
|
||||
@Override
|
||||
public void addBach(Integer fenceId, String[] logoIds) {
|
||||
fenAndLogoMapper.addBach(fenceId,logoIds);
|
||||
|
|
|
@ -52,14 +52,22 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务实现:添加围栏
|
||||
* @param request
|
||||
* @param fenceRequest
|
||||
*/
|
||||
@Override
|
||||
public void fenceInsert(HttpServletRequest request,FenceRequest fenceRequest) {
|
||||
|
||||
//先添加围栏
|
||||
int a= fenceMapper.insertFence(fenceRequest);
|
||||
String[] logoIds = fenceRequest.getLogoIds();
|
||||
String[] parts = new String[0];
|
||||
for (String logoId : logoIds) {
|
||||
//把前台传入的字符串分割成数组
|
||||
parts = logoId.split(",");
|
||||
//再添加围栏和标识中间表
|
||||
fenAndLogoService.addBach(fenceRequest.getFenceId(),parts);
|
||||
|
||||
}
|
||||
|
|
|
@ -82,6 +82,17 @@
|
|||
<artifactId>couplet-common-swagger</artifactId>
|
||||
</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>
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package com.couplet.server.controller;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import com.couplet.common.system.domain.SysUser;
|
||||
import com.couplet.server.service.EmployeeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.couplet.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 员工管理控制器
|
||||
* @date 2024/3/31 19:41
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("employee")
|
||||
public class EmployeeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeservice;
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result<List<SysUser>>
|
||||
* @author 付凡芮
|
||||
* @description 员工列表
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:user:list")
|
||||
@PostMapping("employeeList")
|
||||
public Result<TableDataInfo<SysUser>> userList (SysUser user){
|
||||
startPage();
|
||||
List<SysUser> list = employeeservice.userList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加员工
|
||||
* @date
|
||||
*/
|
||||
@PostMapping
|
||||
@RequiresPermissions("system:user:add")
|
||||
public Result insert (@RequestBody SysUser user) {
|
||||
return employeeservice.insert(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改员工
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping
|
||||
public Result edit (@RequestBody SysUser user) {
|
||||
return employeeservice.deit(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param userIds:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除员工
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:user:remove")
|
||||
@DeleteMapping("/{userIds}")
|
||||
public Result remove (@PathVariable(value = "userIds") Long[] userIds) {
|
||||
return employeeservice.remove(userIds);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改员工状态
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@PutMapping("/changeStatus")
|
||||
public Result changeStatus(@RequestBody SysUser user){
|
||||
return employeeservice.changeStatus(user);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ public class ManageController {
|
|||
* @description 登入后获取到企业下的所有部门
|
||||
* @date
|
||||
*/
|
||||
@GetMapping("manageList")
|
||||
@PostMapping("manageList")
|
||||
@RequiresPermissions("system:dept:list")
|
||||
public Result<List<SysDept>> manageList() {
|
||||
List<SysDept> sysDepts = manageServer.selectDeptList();
|
||||
|
@ -51,6 +51,13 @@ public class ManageController {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param sysDept:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改企业部门信息
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:dept:edit")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
|
@ -58,6 +65,13 @@ public class ManageController {
|
|||
return manageServer.manageEdit(sysDept);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除部门信息
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:dept:remove")
|
||||
@Log(title = "部门管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deptId}")
|
||||
|
@ -71,6 +85,13 @@ public class ManageController {
|
|||
// return manageServer.getSysDeptByDeptId(deptId);
|
||||
// }
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 根据deptId获取信息
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:dept:query")
|
||||
@GetMapping(value = "/{deptId}")
|
||||
public Result getInfo(@PathVariable Long deptId) {
|
||||
|
@ -79,15 +100,16 @@ public class ManageController {
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 获取企业列表
|
||||
* @date
|
||||
*/
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@GetMapping("/list/exclude/{deptId}")
|
||||
public Result excludeChild(@PathVariable(value = "deptId") Long deptId) {
|
||||
return manageServer.excludeChild(deptId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.couplet.server.service;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.system.domain.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EmployeeService {
|
||||
TableDataInfo<SysUser> employeeList(SysUser user);
|
||||
|
||||
Result insert(SysUser user);
|
||||
|
||||
Result deit(SysUser user);
|
||||
|
||||
Result remove(Long[] userIds);
|
||||
|
||||
Result changeStatus(SysUser user);
|
||||
|
||||
List<SysUser> userList(SysUser user);
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
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();
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.couplet.server.service.impl;
|
||||
|
||||
import com.couplet.common.core.constant.SecurityConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.common.system.domain.LoginUser;
|
||||
import com.couplet.common.system.domain.SysUser;
|
||||
import com.couplet.common.system.remote.RemoteEmployeeService;
|
||||
import com.couplet.common.system.remote.RemoteUserService;
|
||||
import com.couplet.server.service.EmployeeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 员工管理服务实现类
|
||||
* @date 2024/3/31 19:42
|
||||
*/
|
||||
@Service
|
||||
public class EmployeeServiceImpl implements EmployeeService{
|
||||
|
||||
|
||||
@Autowired
|
||||
private RemoteEmployeeService remoteEmployeeService;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 员工列表
|
||||
* @date
|
||||
*/
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysUser> employeeList(SysUser user) {
|
||||
Result<TableDataInfo<SysUser>> list = remoteEmployeeService.list(user);
|
||||
TableDataInfo<SysUser> employeeList = list.getData();
|
||||
return employeeList;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加员工
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result insert(SysUser user) {
|
||||
return remoteEmployeeService.add(user);
|
||||
}
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改员工信息
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result deit(SysUser user) {
|
||||
return remoteEmployeeService.edit(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param userIds:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除员工信息
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result remove(Long[] userIds) {
|
||||
return remoteEmployeeService.remove(userIds);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改员工状态
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result changeStatus(SysUser user) {
|
||||
return remoteEmployeeService.changeStatus(user);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return List<SysUser>
|
||||
* @author 付凡芮
|
||||
* @description 员工管理列表
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> userList(SysUser user) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
Result<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.FROM_SOURCE);
|
||||
LoginUser data = userInfo.getData();
|
||||
SysUser sysUser = data.getSysUser();
|
||||
Long deptId = sysUser.getDeptId();
|
||||
Result<List<SysUser>> listResult = remoteEmployeeService.userList(deptId);
|
||||
List<SysUser> userList = listResult.getData();
|
||||
return userList;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,42 +29,78 @@ public class ManageServiceImpl implements ManageServer{
|
|||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/*
|
||||
* @param :
|
||||
* @return List<SysDept>
|
||||
* @author 付凡芮
|
||||
* @description 企业管理列表
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public List<SysDept> selectDeptList() {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
Result<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.FROM_SOURCE);
|
||||
LoginUser user = userInfo.getData();
|
||||
Long deptId = user.getDeptId();
|
||||
Long deptId = loginUser.getSysUser().getDeptId();
|
||||
Result<List<SysDept>> sysDeptByDeptId = remoteDeptService.getSysDeptByDeptId(deptId);
|
||||
List<SysDept> dept = sysDeptByDeptId.getData();
|
||||
return dept;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param sysDept:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加企业部门
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result insertDept(SysDept sysDept) {
|
||||
|
||||
return remoteDeptService.add(sysDept);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param sysDept:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 修改企业部门信息
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result manageEdit(SysDept sysDept) {
|
||||
return remoteDeptService.edit(sysDept);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除企业部门信息
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result manageRemove(Long deptId) {
|
||||
return remoteDeptService.remove(deptId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 获取企业信息
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result getInfo(Long deptId) {
|
||||
return remoteDeptService.getInfo(deptId);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param deptId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 获取企业部门
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result excludeChild(Long deptId) {
|
||||
return remoteDeptService.excludeChild(deptId);
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
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,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -91,6 +91,12 @@
|
|||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注入车辆服务,调用接口-->
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-vehicle</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
//@EnableFeignClients
|
||||
public class OnlineApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OnlineApplication.class);
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
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 org.eclipse.paho.client.mqttv3.*;
|
||||
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.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
|
@ -54,6 +60,14 @@ public class MqttMonitor {
|
|||
@Value("${mqtt.server.qos}")
|
||||
private Integer qos;
|
||||
|
||||
//远程调用
|
||||
@Autowired
|
||||
private RemoteVehicleService remoteVehicleService;
|
||||
|
||||
//redis
|
||||
@Autowired
|
||||
private RedisService redis;
|
||||
|
||||
|
||||
//随项目启动而执行这个方法
|
||||
@PostConstruct
|
||||
|
@ -81,7 +95,21 @@ public class MqttMonitor {
|
|||
client.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
// 处理连接断开的情况
|
||||
// 在这里执行重连操作
|
||||
log.error("连接丢失:{}", throwable.getMessage());
|
||||
while (!client.isConnected()) {
|
||||
try {
|
||||
//等待五秒后重新连接
|
||||
Thread.sleep(5000);
|
||||
//重新连接
|
||||
client.reconnect();
|
||||
log.info("重连中...");
|
||||
} catch (InterruptedException | MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,14 +121,42 @@ public class MqttMonitor {
|
|||
//接收到的原始报文
|
||||
String message = new String(mqttMessage.getPayload());
|
||||
|
||||
log.info("接收消息原始内容:{}", message);
|
||||
// log.info("接收消息原始内容:{}", message);
|
||||
|
||||
//去除空格 得到16进制字符串
|
||||
String replaced = message.replaceAll(" ", "");
|
||||
log.info("接收消息剪切后内容:{}", replaced);
|
||||
//解析后的字符串
|
||||
String parseMsg = ParseMessageUtil.parseMsg(message);
|
||||
|
||||
//拿到前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 + "的车辆属于本系统,允许上线!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9616
|
||||
port: 9617
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
@ -35,9 +35,10 @@ logging:
|
|||
mqtt:
|
||||
server:
|
||||
broker: tcp://115.159.47.13:1883
|
||||
# broker: mqtt://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientId: lyh
|
||||
clientId: fluxmq
|
||||
qos: 0
|
||||
topic: test
|
||||
|
||||
|
|
|
@ -91,6 +91,11 @@
|
|||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.couplet.common.log.annotation.Log;
|
|||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
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.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
|
@ -60,7 +61,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:deleteById")
|
||||
@GetMapping("/deleteById/{vehicleId}")
|
||||
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
||||
public Result deleteById(@PathVariable Long vehicleId) {
|
||||
public Result<String> deleteById(@PathVariable Long vehicleId) {
|
||||
String result = vehicleService.deleteById(vehicleId);
|
||||
|
||||
return Result.success(result);
|
||||
|
@ -77,7 +78,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:editById")
|
||||
@PostMapping("/editById")
|
||||
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
||||
public Result editById(@RequestBody VehicleEditParams editParams) {
|
||||
public Result<String> editById(@RequestBody VehicleEditParams editParams) {
|
||||
|
||||
String result = vehicleService.editById(editParams);
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:insert")
|
||||
@PostMapping("/insert")
|
||||
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||
public Result<String> insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||
System.out.println(insertParams);
|
||||
String result = vehicleService.insert(insertParams);
|
||||
|
||||
|
@ -111,11 +112,26 @@ public class VehicleController extends BaseController {
|
|||
**/
|
||||
@RequiresPermissions("couplet:vehicle:list")
|
||||
@GetMapping("/getBindLogoById/{vehicleId}")
|
||||
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||
public Result<List<Long>> getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||
|
||||
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
||||
|
||||
|
||||
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
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle")
|
||||
public class Vehicle {
|
||||
public class Vehicle{
|
||||
|
||||
|
||||
/*
|
||||
*车辆id
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
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,7 +7,6 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,9 +2,12 @@ package com.couplet.vehicle.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
|
@ -14,4 +17,11 @@ import org.springframework.stereotype.Component;
|
|||
@Mapper
|
||||
@Component
|
||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
||||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.couplet.vehicle.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
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);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
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,6 +2,7 @@ package com.couplet.vehicle.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
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.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
|
@ -25,4 +26,15 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
String insert(VehicleInsertParams insertParams);
|
||||
|
||||
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,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
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.VehicleMiddle;
|
||||
import com.couplet.vehicle.domain.VehicleType;
|
||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
|
@ -14,7 +17,6 @@ import com.couplet.vehicle.mapper.VehicleMapper;
|
|||
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||
import com.couplet.vehicle.service.VehicleService;
|
||||
import com.couplet.vehicle.service.VehicleTypeService;
|
||||
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -187,6 +189,14 @@ 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);
|
||||
long randomId = idGenerator.nextId();
|
||||
|
@ -196,6 +206,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
//切割,只留后17位
|
||||
vin = vin.substring(vin.length() - 17);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//创建入参对象
|
||||
Vehicle vehicle = new Vehicle();
|
||||
|
@ -243,4 +255,46 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -29,4 +29,4 @@ spring:
|
|||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
level:
|
||||
com.couplet.system.mapper: DEBUG
|
||||
com.couplet.vehicle.mapper: DEBUG
|
||||
|
|
|
@ -5,4 +5,59 @@
|
|||
<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>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||
import com.couplet.common.core.utils.uuid.UUID;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
|
@ -11,23 +11,32 @@ public class IdTest {
|
|||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
|
||||
long l = idGenerator.nextId();
|
||||
String s = "VIN" + l;
|
||||
System.out.println(l);
|
||||
System.out.println(s);
|
||||
System.out.println("剪切前长度:" + s.length());
|
||||
// SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
//
|
||||
// long l = idGenerator.nextId();
|
||||
// String s = "VIN" + l;
|
||||
// System.out.println(l);
|
||||
// System.out.println(s);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,31 @@
|
|||
package com.couplet.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.couplet.common.core.constant.SecurityConstants;
|
||||
import com.couplet.common.core.constant.UserConstants;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.page.PageDomain;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.core.web.page.TableSupport;
|
||||
import com.couplet.common.log.annotation.Log;
|
||||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.common.system.domain.LoginUser;
|
||||
import com.couplet.common.system.domain.SysDept;
|
||||
import com.couplet.common.system.remote.RemoteUserService;
|
||||
import com.couplet.system.service.SysDeptService;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.math3.analysis.solvers.BrentSolver;
|
||||
import org.apache.commons.math3.analysis.solvers.SecantSolver;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 部门信息
|
||||
|
@ -26,7 +37,8 @@ public class SysDeptController extends BaseController {
|
|||
|
||||
@Autowired
|
||||
private SysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
/**
|
||||
* 获取部门列表
|
||||
*/
|
||||
|
@ -110,14 +122,13 @@ public class SysDeptController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*根据deptId获取企业名称
|
||||
*/
|
||||
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
||||
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId){
|
||||
List<SysDept> sysDept = deptService.getSysDeptByDeptId(deptId);
|
||||
Result<List<SysDept>> success = Result.success(sysDept);
|
||||
List<SysDept> sysDepts = deptService.getSysDeptByDeptId(deptId);
|
||||
Result<List<SysDept>> success = Result.success(sysDepts);
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SysUserController extends BaseController {
|
|||
* 获取用户列表
|
||||
*/
|
||||
@RequiresPermissions("system:user:list")
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
public Result<TableDataInfo<SysUser>> list (SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
|
@ -107,7 +107,7 @@ public class SysUserController extends BaseController {
|
|||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(sysUser);
|
||||
// 查询企业信息
|
||||
Long deptId = deptService.selectDeptIdByLeader(sysUser.getUserName());
|
||||
Long deptId = deptService.selectDeptIdByLeader(sysUser.getDept().getLeader());
|
||||
LoginUser sysUserVo = new LoginUser();
|
||||
sysUserVo.setSysUser(sysUser);
|
||||
sysUserVo.setRoles(roles);
|
||||
|
@ -291,4 +291,19 @@ public class SysUserController extends BaseController {
|
|||
public Result deptTree (SysDept dept) {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 根据deptId获取企业下的员工
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("userList/{deptId}")
|
||||
public Result<List<SysUser>> userList(@PathVariable(value = "deptId") Long deptId){
|
||||
List<SysUser> userList = userService.userList(deptId);
|
||||
Result<List<SysUser>> success = Result.success(userList);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
|
||||
SysDept selectDeptIdByLeader(String userName);
|
||||
List<SysDept> selectDeptIdByLeader(String userName);
|
||||
|
||||
List<SysDept> getSysDeptByDeptId(Long deptId);
|
||||
|
||||
|
|
|
@ -139,4 +139,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
List<SysUser> userList(Long deptId);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.system.domain.SysDept;
|
||||
import com.couplet.system.domain.vo.TreeSelect;
|
||||
|
||||
|
@ -138,15 +139,17 @@ public interface SysDeptService extends IService<SysDept> {
|
|||
|
||||
/**
|
||||
* 通过负责人查询企业ID
|
||||
* @param userName 负责人
|
||||
* @param leader 负责人
|
||||
* @return 企业ID
|
||||
*/
|
||||
Long selectDeptIdByLeader (String userName);
|
||||
|
||||
Long selectDeptIdByLeader(String leader);
|
||||
/**
|
||||
* 根据企业ID获取企业下部门
|
||||
* @param deptId 企业ID
|
||||
* @return 企业信息,内含有部门
|
||||
*/
|
||||
List<SysDept> getSysDeptByDeptId(Long deptId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -225,4 +225,6 @@ public interface SysUserService extends IService<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
List<SysUser> userList(Long deptId);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.couplet.common.core.exception.ServiceException;
|
|||
import com.couplet.common.core.text.Convert;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.web.page.TableDataInfo;
|
||||
import com.couplet.common.datascope.annotation.DataScope;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.common.system.domain.SysDept;
|
||||
|
@ -284,16 +285,16 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
/**
|
||||
* 通过负责人查询企业ID
|
||||
*
|
||||
* @param userName 负责人
|
||||
* @param leader 负责人
|
||||
*
|
||||
* @return 企业ID
|
||||
*/
|
||||
@Override
|
||||
public Long selectDeptIdByLeader (String userName) {
|
||||
public Long selectDeptIdByLeader (String leader) {
|
||||
|
||||
SysDept sysDept = deptMapper.selectDeptIdByLeader(userName);
|
||||
|
||||
return sysDept == null ? null : sysDept.getDeptId();
|
||||
List<SysDept> sysDept = deptMapper.selectDeptIdByLeader(leader);
|
||||
Long deptId = sysDept.get(0).getDeptId();
|
||||
return sysDept == null ? null : deptId;
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,9 +309,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
|
||||
@Override
|
||||
public List<SysDept> getSysDeptByDeptId(Long deptId) {
|
||||
|
||||
return deptMapper.getSysDeptByDeptId(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
|
|
|
@ -502,4 +502,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> userList(Long deptId) {
|
||||
|
||||
return userMapper.userList(deptId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -109,10 +109,13 @@
|
|||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
<select id="selectDeptIdByLeader" resultType="com.couplet.common.system.domain.SysDept">
|
||||
SELECT * FROM sys_dept d LEFT JOIN sys_user u on d.dept_id = u.dept_id WHERE u.user_name = #{userName}
|
||||
SELECT * FROM sys_dept d WHERE d.leader = #{leader}
|
||||
</select>
|
||||
|
||||
<select id="getSysDeptByDeptId" resultType="com.couplet.common.system.domain.SysDept">
|
||||
SELECT * FROM sys_dept WHERE parent_id = #{deptId}
|
||||
SELECT d.*
|
||||
FROM sys_dept AS d
|
||||
WHERE CONCAT(',', d.ancestors, ',') LIKE CONCAT('%,', #{deptId}, ',%') AND d.dept_id != #{deptId} AND d.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertDept" parameterType="com.couplet.common.system.domain.SysDept">
|
||||
|
|
|
@ -183,6 +183,10 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="userList" resultType="com.couplet.common.system.domain.SysUser">
|
||||
<include refid="selectUserVo"/>
|
||||
WHERE u.dept_id = #{deptId} AND u.del_flag=0
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="com.couplet.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue