feat: 电子围栏报警
parent
e5c4c0b9a4
commit
0569099b02
|
@ -0,0 +1,18 @@
|
|||
package com.couplet.common.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/7
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class FenceAndLogeRequest {
|
||||
|
||||
|
||||
private Long id;
|
||||
private Long[] logoIds;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
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.common.domain.request.FenceAndLogeRequest;
|
||||
import com.couplet.remote.factory.RemoteFenceAndLogFallbackFactory;
|
||||
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 = "remoteFenceAndLogService" ,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteFenceAndLogFallbackFactory.class
|
||||
)
|
||||
public interface RemoteFenceAndLogService {
|
||||
|
||||
@PostMapping("/queryByFenceAndLogoIds")
|
||||
public Result<?> queryByFenceAndLogoIds(@RequestBody FenceAndLogeRequest fenceAndLogeRequest);
|
||||
|
||||
}
|
|
@ -54,5 +54,12 @@ public interface RemoteVehicleService {
|
|||
@GetMapping("onOrOutLineByVIN")
|
||||
public Integer onOrOutLineByVIN(@RequestParam("params") String params);
|
||||
|
||||
/**
|
||||
* 根据车辆id查询绑定的标识
|
||||
* @param vehicleId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/vehicleAndLogo/queryByLogoIds/{vehicleId}")
|
||||
public Result<List<Long>> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.couplet.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
import com.couplet.remote.RemoteFenceAndLogService;
|
||||
import com.couplet.remote.RemoteTroubleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2024/4/2 14:46
|
||||
*/
|
||||
@Component
|
||||
public class RemoteFenceAndLogFallbackFactory implements FallbackFactory<RemoteFenceAndLogService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteFenceAndLogFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteFenceAndLogService create(Throwable cause) {
|
||||
return new RemoteFenceAndLogService() {
|
||||
|
||||
@Override
|
||||
public Result<?> queryByFenceAndLogoIds(FenceAndLogeRequest fenceAndLogeRequest) {
|
||||
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -56,6 +56,11 @@ public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehic
|
|||
log.error("车辆服务调用失败:" + cause.getMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Long>> queryByLogoIds(Long vehicleId) {
|
||||
return Result.error("车辆服务调用失败:"+cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package com.couplet.analyze.msg.consumer;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.common.core.text.Convert;
|
||||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -27,55 +28,57 @@ import java.util.concurrent.TimeUnit;
|
|||
@RabbitListener(queues = "fenceQueue")
|
||||
public class FenceConsumer {
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
private RedisService redisService;
|
||||
|
||||
@RabbitHandler
|
||||
public void fenceConsumer(FenceUpdateRequest fenceUpdateRequest, Channel channel, Message message) throws IOException {
|
||||
|
||||
log.info("消息进入队列,传入的数据是:[{}]", fenceUpdateRequest);
|
||||
log.info("电子围栏消息进入队列,传入的数据是:[{}]", fenceUpdateRequest);
|
||||
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
if (!redisTemplate.hasKey("消息不丢失:" + messageId)) {
|
||||
redisTemplate.opsForValue().set("消息不丢失:" + messageId, "" + deliveryTag, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
if (redisTemplate.hasKey("fence")){
|
||||
redisTemplate.delete("fence");
|
||||
if (!redisService.hasKey("电子围栏消息不丢失:" + messageId)) {
|
||||
redisService.setCacheObject("电子围栏消息不丢失:" + messageId, "" + deliveryTag);
|
||||
}
|
||||
// if (redisService.hasKey("fence")){
|
||||
// redisService.deleteObject("fence");
|
||||
// }
|
||||
|
||||
Long add = redisTemplate.opsForSet().add("消息不重复:" + messageId, messageId);
|
||||
redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||
HashSet<String> objects = new HashSet<>();
|
||||
objects.add(messageId);
|
||||
|
||||
BoundSetOperations<String, String> set = redisService.setCacheSet("电子围栏消息不重复:" + messageId, objects);
|
||||
redisService.expire("电子围栏消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||
try {
|
||||
if (0 < add) {
|
||||
if (set != null) {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
HashSet<FenceUpdateRequest> hashSet = new HashSet<>();
|
||||
hashSet.add(fenceUpdateRequest);
|
||||
hashMap.put(fenceUpdateRequest.getFenceId()+"",fenceUpdateRequest);
|
||||
// redisTemplate.opsForH("fence", JSON.toJSONString(hashMap),10,TimeUnit.MINUTES);
|
||||
// redisTemplate.opsForHash().put("fence", fenceUpdateRequest.getFenceId()+"", JSON.toJSONString(hashMap));
|
||||
redisTemplate.opsForList().rightPush("fence",JSON.toJSONString(hashMap));
|
||||
redisTemplate.expire("fence", 10, TimeUnit.MINUTES);
|
||||
|
||||
String key = Convert.toStr(fenceUpdateRequest.getFenceId());
|
||||
redisService.setCacheObject(key,fenceUpdateRequest);
|
||||
redisService.expire(key, 10, TimeUnit.MINUTES);
|
||||
//判断车辆是否有实时数据,如果没有则删除数据
|
||||
channel.basicAck(deliveryTag, false);
|
||||
} else {
|
||||
log.error("消息不能重复消费:[{}]", fenceUpdateRequest);
|
||||
log.error("电子围栏消息不能重复消费:[{}]", fenceUpdateRequest);
|
||||
channel.basicReject(deliveryTag, false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("消息未进入队列,传入的信息是:【{}】", fenceUpdateRequest);
|
||||
String s = redisTemplate.opsForValue().get("消息不丢失:" + messageId);
|
||||
log.error("电子围栏消息未进入队列,传入的信息是:【{}】", fenceUpdateRequest);
|
||||
String s = redisService.getCacheObject("电子围栏消息不丢失:" + messageId);
|
||||
|
||||
Long o = Long.valueOf(s);
|
||||
if (deliveryTag == o + 2) {
|
||||
log.error("消息已丢失,无法传入的信息是:【{}】", fenceUpdateRequest);
|
||||
log.error("电子围栏消息已丢失,无法传入的信息是:【{}】", fenceUpdateRequest);
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
} else {
|
||||
log.error("消息已丢失,已再次传入的信息是:【{}】", fenceUpdateRequest);
|
||||
log.error("电子围栏消息已丢失,已再次传入的信息是:【{}】", fenceUpdateRequest);
|
||||
channel.basicNack(deliveryTag, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.couplet.analyze.msg.consumer;
|
||||
|
||||
import com.couplet.common.core.text.Convert;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/4
|
||||
* @Description:
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@RabbitListener(queues = "vehicleQueue")
|
||||
public class VehicleConsumer {
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@RabbitHandler
|
||||
public void vehicleConsumer(String vehicleAndLogo, Channel channel, Message message) throws IOException {
|
||||
log.info("车辆消息进入队列,传入的数据是:[{}]", vehicleAndLogo);
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
if (!redisService.hasKey("车辆消息不丢失:" + messageId)) {
|
||||
redisService.setCacheObject("车辆消息不丢失:" + messageId, "" + deliveryTag);
|
||||
}
|
||||
HashSet<String> objects = new HashSet<>();
|
||||
objects.add(messageId);
|
||||
BoundSetOperations<String, String> set = redisService.setCacheSet("车辆信息消息不重复:" + messageId, objects);
|
||||
redisService.expire("车辆信息消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||
try {
|
||||
if (set != null) {
|
||||
// String key = Convert.toStr(id);
|
||||
|
||||
String key = "id";
|
||||
redisService.setCacheObject(key, vehicleAndLogo);
|
||||
redisService.expire(key, 10, TimeUnit.MINUTES);
|
||||
//判断车辆是否有实时数据,如果没有则删除数据
|
||||
channel.basicAck(deliveryTag, false);
|
||||
} else {
|
||||
log.error("车辆消息不能重复消费:[{}]", vehicleAndLogo);
|
||||
channel.basicReject(deliveryTag, false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("车辆消息未进入队列,传入的信息是:【{}】", vehicleAndLogo);
|
||||
String s = redisService.getCacheObject("车辆消息不丢失:" + messageId);
|
||||
Long o = Long.valueOf(s);
|
||||
if (deliveryTag == o + 2) {
|
||||
log.error("车辆消息已丢失,无法传入的信息是:【{}】", vehicleAndLogo);
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
} else {
|
||||
log.error("车辆消息已丢失,已再次传入的信息是:【{}】", vehicleAndLogo);
|
||||
channel.basicNack(deliveryTag, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.couplet.analyze.msg.model;
|
|||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.exception.vehicle.VehicleException;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
|
@ -19,6 +20,7 @@ import java.util.Properties;
|
|||
|
||||
import static com.couplet.analyze.msg.utils.MsgUtils.hexToString;
|
||||
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -74,6 +76,12 @@ public class ModelsKafkaMessage {
|
|||
IncidentService incidentService = SpringUtils.getBean(string);
|
||||
incidentService.incident(msgData);
|
||||
}
|
||||
|
||||
try {
|
||||
sleep(100);
|
||||
} catch (Exception e) {
|
||||
throw new VehicleException("睡眠失败"+e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,16 +6,17 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
|
|||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.analyze.msg.utils.MsgUtils;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.remote.RemoteTroubleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
* 设置redis存储
|
||||
*/
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteTroubleService remoteTroubleService;
|
||||
|
||||
|
@ -73,19 +74,18 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
//获取过期的key
|
||||
String key = "breakdown";
|
||||
log.debug("失效+key is:"+ key);
|
||||
String value = JSON.toJSONString(coupletMsgData);
|
||||
redisTemplate.opsForSet().add(key, value);
|
||||
HashSet<CoupletMsgData> objects = new HashSet<>();
|
||||
objects.add(coupletMsgData);
|
||||
redisService.setCacheSet(key, objects);
|
||||
long expireTime = 30;
|
||||
redisTemplate.expire(key, expireTime, TimeUnit.MINUTES);
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
redisService.expire(key, expireTime, TimeUnit.MINUTES);
|
||||
scheduledRedis();
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
log.info("故障事件结束时间:"+timeMillis);
|
||||
log.info("故障事件检测结束.....");
|
||||
log.info("故障事件结束.....");
|
||||
}
|
||||
long timeMillis = System.currentTimeMillis();
|
||||
log.info("故障事件结束时间:"+timeMillis);
|
||||
log.info("故障事件检测结束.....");
|
||||
log.info("故障事件结束.....");
|
||||
}
|
||||
|
||||
|
@ -100,11 +100,12 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
public void scheduledRedis() {
|
||||
|
||||
// Get all members of the set
|
||||
Set<String> members = redisTemplate.opsForSet().members("breakdown");
|
||||
Set<String> members = redisService.getCacheSet("breakdown");
|
||||
if (members.size()!=0){
|
||||
for (String member : members){
|
||||
CoupletMsgData code = JSON.parseObject(member, CoupletMsgData.class);
|
||||
Set<String> breakdownIds = redisTemplate.opsForSet().members(code.getVin());
|
||||
String vin = code.getVin();
|
||||
Set<String> breakdownIds = redisService.getCacheSet(vin+":"+"breakdown");
|
||||
if (breakdownIds.size()==0){
|
||||
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
||||
troubleCode.setTroubleStartTime(new Date());
|
||||
|
@ -198,10 +199,11 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
|||
troubleCode.setTroublePosition("206");
|
||||
}
|
||||
remoteTroubleService.newFaultData(troubleCode);
|
||||
redisTemplate.opsForSet().add(code.getVin(), code.getVin()+":"+code);
|
||||
HashSet<Object> objects = new HashSet<>();
|
||||
objects.add(code.getVin()+":"+code);
|
||||
redisService.setCacheSet(vin+":"+"breakdown", objects);
|
||||
long expireTime = 30;
|
||||
redisTemplate.expire(code.getVin(), expireTime, TimeUnit.MINUTES);
|
||||
|
||||
redisService.expire(vin+":"+"breakdown", expireTime, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,15 +3,17 @@ package com.couplet.analyze.msg.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.text.Convert;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.remote.RemoteFenceAndLogService;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
@ -23,7 +25,9 @@ import java.util.Map;
|
|||
public class ElectronicFenceServiceImpl implements IncidentService {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteFenceAndLogService remoteFenceAndLogService;
|
||||
|
||||
/**
|
||||
* 电子围栏事件
|
||||
|
@ -34,12 +38,13 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
log.info("电子围栏事件开始.......");
|
||||
|
||||
String fenceKey="fence";
|
||||
|
||||
ArrayList<Fence> fences = new ArrayList<>();
|
||||
if (redisTemplate.hasKey(fenceKey)) {
|
||||
if (redisService.hasKey(fenceKey)) {
|
||||
log.info("电子围栏事件redis存在.......");
|
||||
List<String> fence = redisTemplate.opsForList().range(fenceKey, 0, -1);
|
||||
redisService.getCacheObject();
|
||||
for (String s : fence) {
|
||||
Fence parseObject = JSON.parseObject(s, Fence.class);
|
||||
fences.add(parseObject);
|
||||
|
@ -93,4 +98,25 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
public String getName() {
|
||||
return "electronic-fence";
|
||||
}
|
||||
|
||||
|
||||
public void ifFence() {
|
||||
String key = "id";
|
||||
/**
|
||||
* redisService中的object类型获取到数据
|
||||
*/
|
||||
String cacheObject = redisService.getCacheObject(key);
|
||||
String[] split = cacheObject.split("-");
|
||||
Long id = Convert.toLong(split[0]);
|
||||
Long[] longArray = Convert.toLongArray(split[1]);
|
||||
// for (Long aLong : longArray) {
|
||||
// aLong.wait(",");
|
||||
// }
|
||||
FenceAndLogeRequest fenceAndLogeRequest = new FenceAndLogeRequest();
|
||||
fenceAndLogeRequest.setId(id);
|
||||
fenceAndLogeRequest.setLogoIds(longArray);
|
||||
remoteFenceAndLogService.queryByFenceAndLogoIds(fenceAndLogeRequest);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.couplet.business.server.controller;
|
||||
|
||||
import com.couplet.business.server.service.FenAndLogoService;
|
||||
import com.couplet.business.server.service.VehicleAndLogoService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
import com.couplet.common.log.annotation.Log;
|
||||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/7
|
||||
* @Description: 车辆和标识中间信息
|
||||
*/
|
||||
@RestController
|
||||
@Log4j2
|
||||
@RequestMapping("/fenceAndLogo")
|
||||
public class FenceAndLogoController extends BaseController {
|
||||
|
||||
/**
|
||||
* 调用车辆logo接口
|
||||
*/
|
||||
@Autowired
|
||||
private FenAndLogoService fenAndLogoService;
|
||||
|
||||
/**
|
||||
* 根据车辆id查询绑定的标识
|
||||
* @param aLong
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "查找车辆绑定的电子围栏", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/queryByFenceAndLogoIds")
|
||||
public Result<?> queryByFenceAndLogoIds(@RequestBody FenceAndLogeRequest request){
|
||||
List<Fence> bindLogoById = fenAndLogoService.queryByFenceAndLogoIds(request);
|
||||
return success(bindLogoById);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.couplet.business.server.controller;
|
||||
|
||||
import com.couplet.business.server.service.VehicleAndLogoService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import com.couplet.common.log.annotation.Log;
|
||||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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: LiJiaYao
|
||||
* @Date: 2024/4/7
|
||||
* @Description: 车辆和标识中间信息
|
||||
*/
|
||||
@RestController
|
||||
@Log4j2
|
||||
@RequestMapping("/vehicleAndLogo")
|
||||
public class VehicleAndLogoController extends BaseController {
|
||||
|
||||
/**
|
||||
* 调用车辆logo接口
|
||||
*/
|
||||
@Autowired
|
||||
private VehicleAndLogoService vehicleAndLogoService;
|
||||
|
||||
/**
|
||||
* 根据车辆id查询绑定的标识
|
||||
* @param vehicleId
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "查询车辆id绑定的标识", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/queryByLogoIds/{vehicleId}")
|
||||
public Result<?> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId){
|
||||
List<Long> bindLogoById = vehicleAndLogoService.getBindLogoById(vehicleId);
|
||||
return success(bindLogoById);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,9 +2,12 @@ package com.couplet.business.server.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/3/28
|
||||
|
@ -19,4 +22,10 @@ public interface FenAndLogoMapper extends BaseMapper<Fence> {
|
|||
* @param logoIds
|
||||
*/
|
||||
void addBach(@Param("fenceId") Integer fenceId, @Param("logoIds") String[] logoIds);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aLong
|
||||
*/
|
||||
List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest aLong);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.couplet.business.server.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -16,4 +19,13 @@ public interface FenAndLogoService extends IService<Fence> {
|
|||
* @param logoIds
|
||||
*/
|
||||
void addBach(Integer fenceId, String[] logoIds);
|
||||
|
||||
/**
|
||||
* 根据标识id和车辆id查询电子围栏
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest request);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.business.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.VehicleAndLogo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -18,4 +19,6 @@ public interface VehicleAndLogoService extends IService<VehicleAndLogo> {
|
|||
int deleteByVehicleId(Long vehicleId);
|
||||
|
||||
List<Long> getBindLogoById(Long vehicleId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.couplet.business.server.mapper.FenAndLogoMapper;
|
||||
import com.couplet.business.server.service.FenAndLogoService;
|
||||
import com.couplet.common.domain.Fence;
|
||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/3/28
|
||||
|
@ -38,4 +41,10 @@ public class FenAndLogoServiceImpl extends ServiceImpl<FenAndLogoMapper, Fence>
|
|||
fenAndLogoMapper.addBach(fenceId,logoIds);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest request) {
|
||||
|
||||
return fenAndLogoMapper.queryByFenceAndLogoIds(request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,6 @@ public class VehicleAndLogoServiceImpl extends ServiceImpl<VehicleAndLogoMapper,
|
|||
**/
|
||||
@Override
|
||||
public List<Long> getBindLogoById(Long vehicleId) {
|
||||
|
||||
|
||||
return mapper.getBindLogoById(vehicleId);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,4 +29,18 @@
|
|||
(#{fenceId}, #{item})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="queryByFenceAndLogoIds" resultType="com.couplet.common.domain.Fence">
|
||||
|
||||
SELECT fence_id,
|
||||
fence_name,
|
||||
fence_longitude_latitude,
|
||||
logo_name
|
||||
FROM couplet_fences_and_logo a
|
||||
INNER JOIN couplet_fence_info f on a.fences_id=f.fence_id
|
||||
INNER JOIN couplet_logo_info l on l.logo_id=a.logo_id
|
||||
left JOIN couplet_vehicle_and_logo c on l.logo_id=c.logo_id
|
||||
WHERE l.logo_id=#{logoIds} and c.vehicle_id=#{id}
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</delete>
|
||||
|
||||
<select id="getBindLogoById" resultType="java.lang.Long">
|
||||
SELECT val.logo_id
|
||||
SELECT val.logo_id,val.vehicle_id
|
||||
FROM `couplet_vehicle_and_logo` val
|
||||
WHERE val.vehicle_id = #{vehicleId}
|
||||
</select>
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteVehicleService" ,
|
||||
@FeignClient(contextId = "remoteFenceService" ,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteFenceFallbackFactory.class
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue