Merge branch 'server_five' of https://gitea.qinmian.online/five-groups/five-groups-couplet into server_five_dongxiaodong
# Conflicts: # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/consumer/CodeConsumer.java # couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelsKafkaMessage.java # couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.ymlserver_five_liuyunhu
commit
599d89b6e4
|
@ -4,6 +4,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 认证授权中心
|
||||
|
@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
*/
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletAuthApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletAuthApplication.class, args);
|
||||
|
|
|
@ -17,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.couplet.remote;
|
||||
|
||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.remote.factory.RemoteRealTimeFallbackFactory;
|
||||
import com.couplet.remote.factory.RemoteTroubleFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteRealTimeService" ,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteRealTimeFallbackFactory.class
|
||||
)
|
||||
public interface RemoteRealTimeService {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.couplet.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.remote.RemoteRealTimeService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/8
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
public class RemoteRealTimeFallbackFactory implements FallbackFactory<RemoteRealTimeService> {
|
||||
|
||||
@Override
|
||||
public RemoteRealTimeService create(Throwable cause) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.couplet.common.core.utils;
|
||||
|
||||
import com.couplet.common.core.web.page.TableSupport;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.couplet.common.core.utils.sql.SqlUtil;
|
||||
import com.couplet.common.core.web.page.PageDomain;
|
||||
import com.couplet.common.core.web.page.TableSupport;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
|
|
|
@ -1,27 +1,31 @@
|
|||
package com.couplet.analyze.common.contents;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/7
|
||||
* @Description: 事件内容
|
||||
*/
|
||||
public class AnalyzeEventContents {
|
||||
|
||||
public interface AnalyzeEventContents {
|
||||
|
||||
/**
|
||||
* 故障
|
||||
*/
|
||||
String BREAKDOWN = "breakdown";
|
||||
static final String BREAKDOWN = "breakdown";
|
||||
/**
|
||||
* 电子围栏
|
||||
*/
|
||||
String ELECTRONIC_FENCE = "electronic-fence";
|
||||
static final String ELECTRONIC_FENCE = "electronic-fence";
|
||||
/**
|
||||
* 实时数据
|
||||
*/
|
||||
String REAL_TIME_DATA = "real-time-data";
|
||||
static final String REAL_TIME_DATA = "real-time-data";
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*/
|
||||
String STORED_EVENT = "stored-event";
|
||||
static final String STORED_EVENT = "stored-event";
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ public class AnalyzeEventCache {
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> getEventList(String vin){
|
||||
|
||||
public Set<String> getEventList(String vin){
|
||||
return redisService.getCacheSet(encode(vin));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.common.redis.service;
|
||||
|
||||
import com.couplet.common.domain.CoupletVehicleData;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
|
@ -180,30 +181,32 @@ public class RedisService {
|
|||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
} /**
|
||||
}
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @param setValue 缓存的数据
|
||||
*
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final T dataSet) {
|
||||
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final T setValue) {
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
setOperation.add(dataSet);
|
||||
setOperation.add(setValue);
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除set
|
||||
* @param key
|
||||
* @param setValue
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param setValue 缓存的数据
|
||||
*
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> void deleteSet(String key, String setValue) {
|
||||
|
||||
//缓存的键值
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
setOperation.remove(setValue); //缓存的数据
|
||||
BoundSetOperations setOperations = redisTemplate.boundSetOps(key);
|
||||
setOperations.remove(setValue);
|
||||
}
|
||||
/**
|
||||
* 获得缓存的set
|
||||
|
@ -217,6 +220,7 @@ public class RedisService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
|
@ -299,5 +303,14 @@ public class RedisService {
|
|||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) {
|
||||
String key = "vin:"+realTimeDataRequest.getVin();
|
||||
redisTemplate.opsForValue().set(key, realTimeDataRequest);
|
||||
}
|
||||
|
||||
public void stopViewingData(String vin) {
|
||||
|
||||
String key = "vin:"+vin;
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.system.domain.SysDept;
|
|||
import com.couplet.common.system.remote.RemoteDeptService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
* @date 2024/3/27 15:29
|
||||
*/
|
||||
@Slf4j
|
||||
|
||||
@Component
|
||||
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {
|
||||
@Override
|
||||
public RemoteDeptService create(Throwable cause) {
|
||||
|
|
|
@ -5,6 +5,7 @@ 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 org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
* @description: 员工服务降级处理
|
||||
* @date 2024/3/31 19:43
|
||||
*/
|
||||
@Component
|
||||
public class RemoteEmployeeFallbackFactory implements FallbackFactory<RemoteEmployeeService> {
|
||||
@Override
|
||||
public RemoteEmployeeService create(Throwable cause) {
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -98,6 +98,10 @@
|
|||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-business</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RabbitMQ依赖-->
|
||||
<dependency>
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.couplet.analyze.msg.mapper;
|
|||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
@ -20,6 +23,6 @@ public interface IncidentMapper {
|
|||
* 查询是否存在该vin
|
||||
*/
|
||||
// CoupletMsgData queryByIncident(RealTimeDataRequest realTimeDataRequest);
|
||||
CoupletMsgData queryByIncident(String vin);
|
||||
CoupletMsgData queryByIncident(@Param("vin") String vin, @Param("createTime") Date createTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -34,19 +34,12 @@ public class ModelsKafkaMessage {
|
|||
private static final String TOPIC_NAME = "online";
|
||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||
|
||||
static ArrayList<String> strings = new ArrayList<>() {
|
||||
{
|
||||
add("breakdown");
|
||||
add("electronic-fence");
|
||||
add("real-time-data");
|
||||
add("stored-event");
|
||||
}
|
||||
};
|
||||
// @Autowired
|
||||
// private RabbitTemplate rabbitTemplate;
|
||||
@Autowired
|
||||
private AnalyzeEventCache analyzeEventCache;
|
||||
|
||||
/**
|
||||
* 消费者配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Scheduled(fixedDelay = 50)
|
||||
|
@ -64,7 +57,6 @@ public class ModelsKafkaMessage {
|
|||
|
||||
//订阅主题
|
||||
consumer.subscribe(Collections.singletonList(TOPIC_NAME));
|
||||
|
||||
//持续消费消息
|
||||
while (true) {
|
||||
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||
|
@ -74,19 +66,21 @@ public class ModelsKafkaMessage {
|
|||
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
||||
for (CoupletMsgData msgData : coupletMsgDataList) {
|
||||
log.info("解析到车辆数据:{}", msgData);
|
||||
for (String string : strings) {
|
||||
Set<String> eventList = analyzeEventCache.getEventList(msgData.getVin());
|
||||
for (String string : eventList) {
|
||||
IncidentService incidentService = SpringUtils.getBean(string);
|
||||
incidentService.incident(msgData);
|
||||
}
|
||||
//发送消息
|
||||
// 发送消息
|
||||
// rabbitTemplate.convertAndSend("couplet-code-queue",msgData,message -> {
|
||||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// });
|
||||
|
||||
try {
|
||||
sleep(100);
|
||||
} catch (Exception e) {
|
||||
throw new VehicleException("睡眠失败"+e);
|
||||
throw new VehicleException("睡眠失败" + e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
|
||||
String fenceKey="fence";
|
||||
|
||||
// redisService.getCacheSet()
|
||||
ArrayList<Fence> fences = new ArrayList<>();
|
||||
if (redisService.hasKey(fenceKey)) {
|
||||
log.info("电子围栏事件redis存在.......");
|
||||
|
|
|
@ -4,11 +4,17 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
|
|||
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.remote.RemoteRealTimeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
|
@ -25,7 +31,9 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
private IncidentMapper incidentMapper;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteRealTimeService remoteRealTimeService;
|
||||
|
||||
/**
|
||||
* 实时数据事件
|
||||
|
@ -37,7 +45,16 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
|
||||
log.info("实时数据事件开始.....");
|
||||
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())){
|
||||
RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin());
|
||||
|
||||
if (RealTimeJudge.addRealTime(cacheObject)) {
|
||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
||||
CoupletMsgData query = incidentMapper.queryByIncident(coupletMsgData.getVin(), new Date());
|
||||
redisService.setCacheObject("vin:" + cacheObject.getVin(), query);
|
||||
} else {
|
||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
||||
}
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
|
||||
log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
}
|
||||
log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
|
@ -48,6 +65,7 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
|
||||
/**
|
||||
* 实时数据事件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,6 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -24,7 +23,6 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
rabbitmq:
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
</insert>
|
||||
<select id="queryByIncident" resultType="com.couplet.analyze.msg.domain.CoupletMsgData"
|
||||
parameterType="com.couplet.common.domain.request.RealTimeDataRequest">
|
||||
SELECT * FROM couplet_msg_data WHERE vin =#{vin}
|
||||
SELECT * FROM couplet_msg_data WHERE vin=#{vin} and create_time = #{createTime}
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
@ -92,7 +92,15 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>7.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-mq</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -5,7 +5,9 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.couplet.common.domain.request.VehicleListParams;
|
|||
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.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -159,7 +160,7 @@ public class VehicleController extends BaseController {
|
|||
|
||||
@PostMapping
|
||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
||||
return Result.success(vehicleService.addVehicle(vehicleMiddle));
|
||||
return Result.success(vehicleService.addVehicle(SecurityUtils.getUserId(),vehicleMiddle.getVehicleIds()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.couplet.common.security.utils.SecurityUtils;
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -26,8 +27,6 @@ import java.util.Objects;
|
|||
@RequestMapping("detection")
|
||||
public class VehicleDetectionController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private VehicleDetectionService vehicleDetectionService;
|
||||
@Autowired
|
||||
|
@ -50,24 +49,23 @@ public class VehicleDetectionController {
|
|||
|
||||
/*
|
||||
* @param vin:
|
||||
* @return Result<List<Vehicle>>
|
||||
* @return Result<List<Vehicle>>
|
||||
* @author 付凡芮
|
||||
* @description 根据vin查询车辆信息
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/monitorinData/{vin}")
|
||||
public void monitorinData(@PathVariable String vin){
|
||||
String exchangeName = "exchangeName"; // 交换机名称
|
||||
String routingKey = "routingKey"; // 路由键
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
realTimeDataRequest.setVin(vin);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest);
|
||||
vehicleDetectionService.monitorinData(vin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @param :
|
||||
* @return Result<List<CoupletVehicleData>>
|
||||
* @author 付凡芮
|
||||
* @description 查看事实数据列表
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("realData")
|
||||
public Result<List<CoupletVehicleData>> realData(){
|
||||
List<CoupletVehicleData> list = redisService.getList();
|
||||
|
@ -75,4 +73,16 @@ public class VehicleDetectionController {
|
|||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param vin:
|
||||
* @return void
|
||||
* @author 付凡芮
|
||||
* @description 停止传送实时数据
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("stopViewingData/{vin}")
|
||||
public void stopViewingData(@PathVariable String vin){
|
||||
vehicleDetectionService.stopViewingData(vin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,9 +22,12 @@ public interface VehicleMapper extends BaseMapper<Vehicle> {
|
|||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
Integer onOrOutLineByVIN(@Param("vin") String vin, @Param("status") int status);
|
||||
|
||||
|
||||
Integer addVehicle(@Param("userId") Long userId, @Param("vehicleIds") List<Long> vehicleIds);
|
||||
}
|
||||
|
|
|
@ -9,4 +9,8 @@ public interface VehicleDetectionService {
|
|||
|
||||
List<Vehicle> detectionList();
|
||||
|
||||
void monitorinData(String vin);
|
||||
|
||||
|
||||
void stopViewingData(String vin);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,11 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
Integer onOrOutLineByVIN(String s, int i);
|
||||
|
||||
|
||||
Integer addVehicle(Long userId, List<Long> vehicleIds);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,13 @@ import com.couplet.common.domain.request.FenceRequest;
|
|||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.mq.remote.RemoteFenceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -40,12 +43,12 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
* 注入redis模板
|
||||
*/
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
/**
|
||||
* 远程调用队列服务
|
||||
*/
|
||||
// @Autowired
|
||||
// private RemoteFenceService remoteFenceService;
|
||||
@Autowired
|
||||
private RemoteFenceService remoteFenceService;
|
||||
|
||||
@Override
|
||||
public List<Fence> pageQuery(FenceConfig fenceConfig) {
|
||||
|
@ -54,7 +57,6 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeFenceStatus(FenceUpdateRequest fenceUpdateRequest) {
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
|
@ -63,31 +65,50 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
/**
|
||||
* 电子围栏发送改变
|
||||
*/
|
||||
// redisService.setCacheObject("fence:info"+fenceUpdateRequest.getFenceId(),fenceUpdateRequest, 10, TimeUnit.MINUTES);
|
||||
redisTemplate.opsForValue().set("changeFenceStatus", JSON.toJSONString(fenceUpdateRequest), 10, TimeUnit.MINUTES);
|
||||
|
||||
remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fenceInsert(FenceRequest fenceRequest) {
|
||||
|
||||
redisService.setCacheObject("fence:info:"+fenceUpdateRequest.getFenceId(),fenceUpdateRequest);
|
||||
redisService.expire("fence:info:"+fenceUpdateRequest.getFenceId(),10,TimeUnit.MINUTES);
|
||||
// remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务实现:添加围栏
|
||||
*
|
||||
* @param request
|
||||
* @param fenceRequest
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void fenceInsert(FenceRequest fenceRequest) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
fenceRequest.setCrateName(username);
|
||||
//先添加围栏
|
||||
fenceMapper.insertFence(fenceRequest);
|
||||
fenAndLogoService.addBach(fenceRequest.getFenceId(), fenceRequest.getLogoIds());
|
||||
}
|
||||
// @Override
|
||||
// public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) {
|
||||
// String username = SecurityUtils.getUsername();
|
||||
// fenceRequest.setCrateName(username);
|
||||
// //先添加围栏
|
||||
// fenceMapper.insertFence(fenceRequest);
|
||||
// String[] logoIds = fenceRequest.getLogoIds();
|
||||
// String[] parts = new String[0];
|
||||
// for (String logoId : logoIds) {
|
||||
// //把前台传入的字符串分割成数组
|
||||
// parts = logoId.split(",");
|
||||
// //再添加围栏和标识中间表
|
||||
// fenAndLogoService.addBach(fenceRequest.getFenceId(), parts);
|
||||
// }
|
||||
// /**
|
||||
// * 电子围栏发送改变
|
||||
// */
|
||||
// redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void removeByFenceId(Long fenceId) {
|
||||
fenceMapper.removeByFenceId(fenceId);
|
||||
/**
|
||||
* 电子围栏发送改变
|
||||
*/
|
||||
redisTemplate.opsForValue().set("removeByFenceId", JSON.toJSONString(fenceId), 10, TimeUnit.MINUTES);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.couplet.business.server.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.business.server.mapper.VehicleDetectionMapper;
|
||||
import com.couplet.business.server.service.VehicleDetectionService;
|
||||
import com.couplet.business.server.service.VehicleManageService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mysql.cj.xdevapi.JsonString;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import springfox.documentation.spring.web.json.Json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,10 +29,27 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
|||
|
||||
@Autowired
|
||||
private VehicleDetectionMapper vehicleDetectionMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public List<Vehicle> detectionList() {
|
||||
return vehicleDetectionMapper.detectionList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void monitorinData(String vin) {
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setVin(vin);
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
redisService.setVinAndUserId(realTimeDataRequest);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopViewingData(String vin) {
|
||||
redisService.stopViewingData(vin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -303,11 +303,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return vehicleMapper.deleteVehicle(middleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
||||
|
||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> vehicleAll() {
|
||||
|
@ -322,6 +318,11 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return vehicleMapper.onOrOutLineByVIN(vin, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addVehicle(Long userId, List<Long> vehicleIds) {
|
||||
return vehicleMapper.addVehicle(userId,vehicleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> findByVIN(String vin) {
|
||||
|
||||
|
|
|
@ -41,12 +41,11 @@
|
|||
</sql>
|
||||
<insert id="addVehicle">
|
||||
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
||||
<foreach collection="vehicleId" item="vehicleId" separator=",">
|
||||
<foreach collection="vehicleIds" item="vehicleId" separator=",">
|
||||
(#{userId}, #{vehicleId}, 0)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="onOrOutLineByVIN">
|
||||
UPDATE `couplet-cloud`.`couplet_vehicle`
|
||||
SET `vehicle_state` = #{status}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 代码生成
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletGenApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletGenApplication.class, args);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletJobApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletJobApplication.class, args);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.job.controller;
|
||||
|
||||
import com.couplet.common.core.constant.Constants;
|
||||
|
||||
import com.couplet.common.core.exception.job.TaskException;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.utils.poi.ExcelUtil;
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package com.couplet.job.task;
|
||||
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 定时任务调度测试
|
||||
*
|
||||
* @author couplet
|
||||
*/
|
||||
@Component("myTask")
|
||||
public class MyTask {
|
||||
public void ryMultipleParams (String s, Boolean b, Long l, Double d, Integer i) {
|
||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||
}
|
||||
|
||||
public void ryParams (String params) {
|
||||
System.out.println("执行有参方法:" + params);
|
||||
}
|
||||
|
||||
public void ryNoParams () {
|
||||
System.out.println("执行无参方法");
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @ProjectName: Default (Template) Project
|
||||
|
@ -16,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletMqApplatcaion {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
||||
|
|
|
@ -38,7 +38,7 @@ mqtt:
|
|||
# broker: mqtt://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientId: mq
|
||||
clientId: fluxMq
|
||||
qos: 0
|
||||
topic: dxd
|
||||
topic: test
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletSystemApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletSystemApplication.class, args);
|
||||
|
|
|
@ -15,11 +15,9 @@ 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