fine()添加车辆缓存
parent
c34bec050c
commit
6e4b268730
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-modules-cache 缓存基准
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 抽象缓存层
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common
|
||||
* @Project:cloud-server-8
|
||||
* @name:CacheAbsBacis
|
||||
* @Date:2024/9/30 11:19
|
||||
*/
|
||||
public abstract class CacheAbsBasic<K,V> implements CacheBasic<K,V>{
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void put(K key, V value) {
|
||||
redisService.setCacheObject(encode(key),value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
return redisService.getCacheObject(encode(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(K key) {
|
||||
redisService.deleteObject(encode(key));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存基础
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:CacheBasic
|
||||
* @Date:2024/9/30 11:41
|
||||
*/
|
||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
||||
|
||||
void put(K key,V value);
|
||||
|
||||
V get(K key);
|
||||
|
||||
void remove(K key);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 主键基础
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:PrimaryKeyBasic
|
||||
* @Date:2024/9/30 11:35
|
||||
*/
|
||||
public interface PrimaryKeyBasic <K>{
|
||||
|
||||
/**
|
||||
* key 前缀
|
||||
* @return 前缀
|
||||
*/
|
||||
public String keyPre();
|
||||
/**
|
||||
* 编码
|
||||
* @param key 缓存键
|
||||
* @return 装修键
|
||||
*/
|
||||
public default String encode(K key){
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码key
|
||||
* @param key 编码Key
|
||||
* @return 解码后的Key
|
||||
*/
|
||||
public K decode(String key);
|
||||
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
<module>cloud-common-rabbit</module>
|
||||
<module>cloud-common-saas</module>
|
||||
<module>cloud-common-wechat</module>
|
||||
<module>cloud-common-kafka</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-common</artifactId>
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<artifactId>cloud-Saas-Service</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
<description>
|
||||
cloud-modules-enterprise-cache 缓存模块
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-auth</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 添加车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationAddService extends CacheAbsBasic<String, CarInformationAddReq> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationAddReq:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆基础信息列表缓存
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationFenceRespService extends CacheAbsBasic<String, List<CarInformationResp>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationFenceResp:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页查询车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationRespService extends CacheAbsBasic<String, Page<CarInformationResp>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationResp:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.resp.CarFenceGroupResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询车辆
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationService extends CacheAbsBasic<String, List<CarInformation>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformation:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.req.CarInformationUpdReq;
|
||||
|
||||
/**
|
||||
* 修改车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationUpdService extends CacheAbsBasic<String, CarInformationUpdReq> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationUpdReq:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationRespService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationAddService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationUpdService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationFenceRespService
|
|
@ -15,8 +15,8 @@
|
|||
cloud-modules-enterprise-common 企业业务common
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
cloud-modules-enterprise-server 企业业务服务
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
@ -33,10 +33,10 @@
|
|||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!--apache.kafka<-->
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!--远调端Feign-->
|
||||
<dependency>
|
||||
|
@ -101,9 +101,13 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-kafka</artifactId>
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
|
|
@ -36,10 +36,10 @@ public class CarFenceClazzController {
|
|||
@PostMapping("/selectClazz")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarFenceClazz>> selectConnect(){
|
||||
|
||||
List<CarFenceClazz> connects = carFenceClazzService.list();
|
||||
log.info("查询数据成功");
|
||||
return Result.success(
|
||||
|
||||
connects, "操作成功"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public class CarFenceController {
|
|||
){
|
||||
Page<CarFenceResp> connects = carFenceService.selectCarFence(req);
|
||||
log.info("查询数据:"+ connects);
|
||||
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
@ -58,13 +59,13 @@ public class CarFenceController {
|
|||
@Validated @RequestBody CarFence carFence
|
||||
){
|
||||
Boolean connects = carFenceService.addCarFence(carFence);
|
||||
log.info("shd");
|
||||
|
||||
log.info("shd");
|
||||
return connects?Result.success(
|
||||
null, "操作成功"
|
||||
):Result.success(
|
||||
null, "操作失败"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +95,7 @@ public class CarFenceController {
|
|||
@Validated @RequestBody FenceGroupReq req
|
||||
){
|
||||
Boolean connects = carFenceService.addFenceGroup(req);
|
||||
|
||||
return connects?Result.success(
|
||||
null, "操作成功"
|
||||
):Result.success(
|
||||
|
@ -138,6 +140,7 @@ public class CarFenceController {
|
|||
@PostMapping("/carGroupList")
|
||||
@Operation(summary = "查询车辆围栏组数据",description = "查询车辆围栏组信息")
|
||||
public Result<List<CarFenceGroupsResp>> carGroupList(@RequestBody CarFenceGroupReq req){
|
||||
|
||||
List<CarFenceGroupsResp> connects = carFenceService.carGroupList(req);
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
|
|
|
@ -36,7 +36,9 @@ public class CarFenceTypeController {
|
|||
@PostMapping("/selectType")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarFenceType>> selectConnect(){
|
||||
|
||||
List<CarFenceType> connects = carFenceTypeService.list();
|
||||
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
|
|
@ -4,15 +4,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.CarFenceType;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.req.CarInformationListReq;
|
||||
import com.muyu.domain.req.CarInformationUpdReq;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
import com.muyu.enterprise.cache.car.*;
|
||||
import com.muyu.server.service.CarInformationService;
|
||||
import com.muyu.server.util.ObtainRootLogin;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -30,6 +34,11 @@ import java.util.List;
|
|||
public class CarInformationController {
|
||||
@Resource
|
||||
private CarInformationService carInformationService;
|
||||
private VehicleCacheCarInformationService vehicleCacheCarInformationService;
|
||||
private VehicleCacheCarInformationRespService vehicleCacheCarInformationRespService;
|
||||
private VehicleCacheCarInformationAddService vehicleCacheCarInformationAddService;
|
||||
private VehicleCacheCarInformationUpdService vehicleCacheCarInformationUpdService;
|
||||
private VehicleCacheCarInformationFenceRespService vehicleCacheCarInformationFenceRespService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,10 +47,20 @@ public class CarInformationController {
|
|||
@PostMapping("/selectCarInformation")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarInformation>> selectConnect(){
|
||||
List<CarInformation> carFenceRespPage = vehicleCacheCarInformationService
|
||||
.get(vehicleCacheCarInformationService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage)) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
List<CarInformation> connects = carInformationService.list()
|
||||
.stream()
|
||||
.map(CarInformation::carInformationBuilder)
|
||||
.toList();
|
||||
vehicleCacheCarInformationService.put(
|
||||
vehicleCacheCarInformationService.keyPre()+ObtainRootLogin.obtain()
|
||||
,connects);
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
@ -68,8 +87,19 @@ public class CarInformationController {
|
|||
@PostMapping("/selectCarInformationList")
|
||||
@Operation(summary = "企业车辆管理列表")
|
||||
public Result<Page<CarInformationResp>> selectCarInformationList(@Validated @RequestBody CarInformationListReq carInformationListReq) {
|
||||
|
||||
Page<CarInformationResp> carFenceRespPage = vehicleCacheCarInformationRespService
|
||||
.get(vehicleCacheCarInformationRespService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage.getRecords())) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
Page<CarInformationResp> pageInfo = carInformationService.selectCarInformationList(carInformationListReq);
|
||||
log.info("企业车辆管理列表查询",carInformationListReq,pageInfo);
|
||||
vehicleCacheCarInformationRespService.put(
|
||||
vehicleCacheCarInformationRespService.keyPre()+ObtainRootLogin.obtain()
|
||||
,pageInfo);
|
||||
return Result.success(pageInfo);
|
||||
|
||||
}
|
||||
|
@ -83,6 +113,10 @@ public class CarInformationController {
|
|||
@PostMapping("/addCarInformation")
|
||||
@Operation(summary = "企业车辆添加管理")
|
||||
public Result addCarInformation(@Validated @RequestBody CarInformationAddReq carInformationAddReq){
|
||||
|
||||
vehicleCacheCarInformationAddService.put(
|
||||
vehicleCacheCarInformationAddService
|
||||
.keyPre()+ObtainRootLogin.obtain(), carInformationAddReq);
|
||||
return carInformationService.addCarInformation(carInformationAddReq)
|
||||
?Result.success("添加车辆成功")
|
||||
:Result.error(402,"添加车辆失败");
|
||||
|
@ -114,7 +148,9 @@ public class CarInformationController {
|
|||
public Result updateCarMessage(@Validated @RequestBody CarInformationUpdReq carInformationUpdReq){
|
||||
boolean updatecarInformation = carInformationService.updatecarInformation(carInformationUpdReq);
|
||||
log.info(updatecarInformation);
|
||||
System.out.println("我在这个里:"+updatecarInformation);
|
||||
vehicleCacheCarInformationUpdService.put(
|
||||
vehicleCacheCarInformationUpdService
|
||||
.keyPre()+ObtainRootLogin.obtain(), carInformationUpdReq);
|
||||
if(updatecarInformation)
|
||||
{
|
||||
return Result.success(carInformationUpdReq,"修改成功");
|
||||
|
@ -133,7 +169,17 @@ public class CarInformationController {
|
|||
@GetMapping("/selectCarInformationIdAndLicensePlate")
|
||||
@Operation(summary = "查询企业车辆 carInformationID 和 carInformationLicensePlate")
|
||||
public Result<List<CarInformationResp>> selectCarInformationIdAndLicensePlate(){
|
||||
List<CarInformationResp> carFenceRespPage = vehicleCacheCarInformationFenceRespService
|
||||
.get(vehicleCacheCarInformationFenceRespService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage)) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
List<CarInformationResp> carInformations = carInformationService.selectBycarInformationIDAndLicensePlate();
|
||||
vehicleCacheCarInformationFenceRespService.put(
|
||||
vehicleCacheCarInformationFenceRespService.keyPre()+ObtainRootLogin.obtain()
|
||||
,carInformations);
|
||||
return Result.success(carInformations);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class CarMessageController {
|
|||
@PostMapping("/selectCarMessageList")
|
||||
@Operation(summary = "报文模板展示列表")
|
||||
public Result<List<CarMessage>> selectCarMessageList(){
|
||||
|
||||
List<CarMessage> carMessages = carMessageService.selectCarMessageList();
|
||||
return Result.success(carMessages);
|
||||
}
|
||||
|
@ -42,10 +43,8 @@ public class CarMessageController {
|
|||
@PostMapping("/insertCarMessage")
|
||||
@Operation(summary = "添加报文信息")
|
||||
public Result<Integer> insertCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||
|
||||
int inserted = carMessageService.insertCarMessage(carMessage);
|
||||
if (inserted>0){
|
||||
return Result.success(200,"添加成功");
|
||||
}
|
||||
return Result.error(402,"添加失败");
|
||||
}
|
||||
|
||||
|
@ -57,6 +56,7 @@ public class CarMessageController {
|
|||
@Operation(summary = "删除报文信息")
|
||||
public Result<Integer> delectByCarMessageId(@RequestParam(name = "carMessageId") Integer carMessageId){
|
||||
int deleteByCarMessageId = carMessageService.delectByCarMessageId(carMessageId);
|
||||
|
||||
if (deleteByCarMessageId>0){
|
||||
return Result.success(200,"删除成功");
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ public class CarMessageController {
|
|||
@PostMapping("/updateCarMessage")
|
||||
@Operation(summary = "修改报文信息")
|
||||
public Result<Integer> updateCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||
|
||||
int updateCarMessage = carMessageService.updateCarMessage(carMessage);
|
||||
if(updateCarMessage>0)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆电子围栏添加中间表控制层
|
||||
* @Author:yang
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.server.controller;
|
|||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.CarType;
|
||||
import com.muyu.server.service.CarTypeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -9,6 +10,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆类型控制层
|
||||
* @Author:weiran
|
||||
|
@ -33,6 +36,9 @@ public class CarTypeController {
|
|||
@PostMapping("/list")
|
||||
@Operation(summary = "车辆类型",description = "车辆类型信息")
|
||||
public Result carTypeList(){
|
||||
return Result.success(carTypeService.selectcarType());
|
||||
|
||||
List<CarType> data = carTypeService.selectcarType();
|
||||
|
||||
return Result.success(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ public class FaultCodeController {
|
|||
@PostMapping("/faultcodelist")
|
||||
@Operation(summary = "故障码列表(多)",description = "展示故障码信息")
|
||||
public Result<FaultCodeTotalListResp> selectfaultcodelist(@Validated @RequestBody FaultCodeListReq faultCodeListReq){
|
||||
return Result.success(faultCodeService.selectfaultcodelist(faultCodeListReq));
|
||||
FaultCodeTotalListResp selectfaultcodelist = faultCodeService.selectfaultcodelist(faultCodeListReq);
|
||||
return Result.success(selectfaultcodelist,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import com.muyu.domain.FaultCondition;
|
|||
import com.muyu.domain.req.FaultConditionAddReq;
|
||||
import com.muyu.domain.req.FaultConditionListReq;
|
||||
import com.muyu.domain.req.FaultConditionUpdReq;
|
||||
import com.muyu.domain.resp.FaultConditionTotalListResp;
|
||||
import com.muyu.server.service.FaultConditionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -40,7 +40,9 @@ public class FaultConditionController {
|
|||
@PostMapping("/list")
|
||||
@Operation(summary = "故障规则列表展示",description = "故障规则列表展示")
|
||||
public Result getfaultrulelist(@RequestBody @Validated FaultConditionListReq faultConditionListReq){
|
||||
return Result.success(faultConditionService.getfaultrulelist(faultConditionListReq));
|
||||
|
||||
FaultConditionTotalListResp getfaultrulelist = faultConditionService.getfaultrulelist(faultConditionListReq);
|
||||
return Result.success(getfaultrulelist,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
package com.muyu.server.mqtt;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||
import com.muyu.domain.CarMessage;
|
||||
import com.muyu.server.service.CarMessageService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
@Component
|
||||
public class Demo {
|
||||
@Resource
|
||||
private CarMessageService service;
|
||||
@Resource
|
||||
private KafkaProducer<String, String> kafkaProducer;
|
||||
@PostConstruct
|
||||
public void test() {
|
||||
|
||||
String topic = "vehicle";
|
||||
String content = "Message from MqttPublishSample";
|
||||
int qos = 2;
|
||||
String broker = "tcp://106.15.136.7:1883";
|
||||
String clientId = "JavaSample";
|
||||
|
||||
try {
|
||||
// 第三个参数为空,默认持久化策略
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId);
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setCleanSession(true);
|
||||
System.out.println("Connecting to broker: "+broker);
|
||||
sampleClient.connect(connOpts);
|
||||
sampleClient.subscribe(topic,0);
|
||||
sampleClient.setCallback(new MqttCallback() {
|
||||
// 连接丢失
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
|
||||
}
|
||||
// 连接成功
|
||||
@Override
|
||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||
|
||||
List<CarMessage> list= service.selectCarMessageList(1,2);
|
||||
String str = new String( mqttMessage.getPayload() );
|
||||
System.out.println(str);
|
||||
String[] test = str.split(" ");
|
||||
String[] results = new String[list.size()];
|
||||
List<CompletableFuture<String>> futures = new ArrayList<>();
|
||||
for (CarMessage carmsg : list) {
|
||||
futures.add(CompletableFuture.supplyAsync(() -> {
|
||||
int startIndex = Integer.parseInt(String.valueOf(carmsg.getCarMessageStartIndex())) - 1;
|
||||
int endIndex = Integer.parseInt(String.valueOf(carmsg.getCarMessageEndIndex()));
|
||||
StringBuilder hexBuilder = new StringBuilder();
|
||||
for (int j = startIndex; j < endIndex; j++) {
|
||||
hexBuilder.append(test[j]);
|
||||
}
|
||||
// 创建16进制的对象
|
||||
String hex = hexBuilder.toString();
|
||||
// 转橙字符数组
|
||||
char[] result = new char[hex.length() / 2];
|
||||
for (int x = 0; x < hex.length(); x += 2) {
|
||||
// 先转十进制
|
||||
int high = Character.digit(hex.charAt(x), 16);
|
||||
// 转二进制
|
||||
int low = Character.digit(hex.charAt(x + 1), 16);
|
||||
// 转字符
|
||||
result[x / 2] = (char) ((high << 4) + low);
|
||||
}
|
||||
return new String(result);
|
||||
}));
|
||||
}
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
results[i] = futures.get(i).get();
|
||||
}
|
||||
String jsonString = JSONObject.toJSONString( results );
|
||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<>( KafkaConstants.KafkaTopic, jsonString);
|
||||
kafkaProducer.send(producerRecord);
|
||||
}
|
||||
// 接收信息
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
}
|
||||
});
|
||||
} catch(MqttException me) {
|
||||
System.out.println("reason "+me.getReasonCode());
|
||||
System.out.println("msg "+me.getMessage());
|
||||
System.out.println("loc "+me.getLocalizedMessage());
|
||||
System.out.println("cause "+me.getCause());
|
||||
System.out.println("excep "+me);
|
||||
me.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.server.util;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.domain.CarFenceClazz;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.server.util
|
||||
* @Project:cloud-server-8
|
||||
* @name:ObtainRootLogin
|
||||
* @Date:2024/10/2 16:46
|
||||
*/
|
||||
public class ObtainRootLogin {
|
||||
|
||||
public static String obtain(){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
|
||||
return sysUser.getDatabaseName();
|
||||
};
|
||||
}
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
<modules>
|
||||
<module>cloud-modules-enterprise-common</module>
|
||||
<module>cloud-modules-enterprise-server</module>
|
||||
<module>cloud-modules-enterprise-cache</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
Loading…
Reference in New Issue