小车上线
parent
5dd0571824
commit
5b56363dde
|
@ -1,6 +1,6 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9211
|
port: 9212
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
|
|
|
@ -17,6 +17,6 @@ import java.util.List;
|
||||||
public interface RemoteBusinessService {
|
public interface RemoteBusinessService {
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/entinfo/listAll")
|
@GetMapping("entinfo/listAll")
|
||||||
public List<Entinfo> listAll();
|
public List<Entinfo> listAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ public class RemoteBusinessFallbackFactory implements FallbackFactory<RemoteBusi
|
||||||
public RemoteBusinessService create (Throwable throwable) {
|
public RemoteBusinessService create (Throwable throwable) {
|
||||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
return new RemoteBusinessService(){
|
return new RemoteBusinessService(){
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entinfo> listAll() {
|
public List<Entinfo> listAll() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -71,12 +71,6 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-common-datasource</artifactId>
|
<artifactId>muyu-common-datasource</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 企业依赖-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-business</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- muyu Common DataScope -->
|
<!-- muyu Common DataScope -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
|
|
@ -45,20 +45,7 @@ public class ManyDataSource {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteBusinessService remoteBusinessService;
|
private RemoteBusinessService remoteBusinessService;
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// private EntInfoFeign entInfoFeign;
|
|
||||||
|
|
||||||
// @PostConstruct
|
|
||||||
// public void init() {
|
|
||||||
// new Thread(() -> {
|
|
||||||
// try {
|
|
||||||
// Thread.sleep(10000);
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }).start();
|
|
||||||
// }
|
|
||||||
|
|
||||||
//调用注解 添加队列名称
|
//调用注解 添加队列名称
|
||||||
@RabbitListener(queuesToDeclare = {@Queue(name = "muyu-vehicle-exchange")})
|
@RabbitListener(queuesToDeclare = {@Queue(name = "muyu-vehicle-exchange")})
|
||||||
|
@ -111,27 +98,6 @@ public class ManyDataSource {
|
||||||
}};
|
}};
|
||||||
List<Entinfo> list = remoteBusinessService.listAll();
|
List<Entinfo> list = remoteBusinessService.listAll();
|
||||||
databaseNameList.addAll(list);
|
databaseNameList.addAll(list);
|
||||||
|
|
||||||
// List<String> entinfo = redisTemplate.opsForList().range("entinfo", 0, -1);
|
|
||||||
// entinfo.forEach(string -> {
|
|
||||||
// Entinfo entInfo = JSON.parseObject(String.valueOf(string), Entinfo.class);
|
|
||||||
// databaseNameList.add(entInfo);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// List<Entinfo> entinfos = entInfoFeign.listAll();
|
|
||||||
// databaseNameList.addAll(entinfos);
|
|
||||||
|
|
||||||
|
|
||||||
// if(SecurityUtils.getLoginUser() == null){
|
|
||||||
// return databaseNameList;
|
|
||||||
// }else{
|
|
||||||
// Long storeId = SecurityUtils.getLoginUser().getUserid();
|
|
||||||
// SysUser sysUser = remoteUserService.selectByUserId(storeId);
|
|
||||||
// String s = redisService.getCacheObject(String.valueOf(sysUser.getUserType()));
|
|
||||||
// EntInfo entInfo = JSON.parseObject(s, EntInfo.class);
|
|
||||||
// databaseNameList.add(entInfo);
|
|
||||||
// return databaseNameList;
|
|
||||||
// }
|
|
||||||
return databaseNameList;
|
return databaseNameList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆故障码接口 FaultCodeMapper
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:16
|
||||||
|
*/
|
||||||
|
public interface FaultCodeMapper {
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.vehicle.mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障记录接口 FaultRecordMapper
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:17
|
||||||
|
*/
|
||||||
|
public interface FaultRecordMapper {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.muyu.vehicle.rabbitmq.producer;
|
||||||
|
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VehicleProducer
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 15:56
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class VehicleProducer {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
|
//调用注解,添加队列名称
|
||||||
|
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-start")})
|
||||||
|
public void smsConfigStart(String msg, Message message, Channel channel){
|
||||||
|
//获取消息的id
|
||||||
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||||
|
|
||||||
|
if (count==1) {
|
||||||
|
log.info("开始消费:{}", msg);
|
||||||
|
|
||||||
|
//判断车辆属于哪个企业
|
||||||
|
|
||||||
|
//选择数据源,切换数据源
|
||||||
|
|
||||||
|
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
log.info("消费成功!数据源为:{}", message);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("消费失败");
|
||||||
|
|
||||||
|
try {
|
||||||
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
log.info("回退成功");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.info("回退失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-ent")})
|
||||||
|
public void smsConfigEnt(String msg, Message message, Channel channel){
|
||||||
|
|
||||||
|
//获取消息的id
|
||||||
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
try {
|
||||||
|
//提那家消费id到redis set集合中,
|
||||||
|
Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||||
|
|
||||||
|
//成功
|
||||||
|
if (count == 1 ) {
|
||||||
|
log.info("开始消费:{}", msg);
|
||||||
|
|
||||||
|
//确认消费
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
log.info("消费成功");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//删除队列id
|
||||||
|
log.info("消费失败");
|
||||||
|
try {
|
||||||
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
log.info("消费失败");
|
||||||
|
|
||||||
|
}catch (IOException ex){
|
||||||
|
log.info("消费异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆故障码接口 FaultCodeService
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:12
|
||||||
|
*/
|
||||||
|
public interface FaultCodeService {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障记录借口哦 FaultRecordService
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:12
|
||||||
|
*/
|
||||||
|
public interface FaultRecordService {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆故障码业务层处理 FaultCodeServicelmpl
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:13
|
||||||
|
*/
|
||||||
|
public class FaultCodeServicelmpl {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.vehicle.service.impl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障记录业务层处理 FaultRecordServicelmpl
|
||||||
|
*
|
||||||
|
* @author xiaohuang
|
||||||
|
* Date 2024/6/20 17:15
|
||||||
|
*/
|
||||||
|
public class FaultRecordServicelmpl {
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9212
|
port: 9213
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -225,6 +225,7 @@
|
||||||
<module>muyu-iotdb</module>
|
<module>muyu-iotdb</module>
|
||||||
<module>muyu-vehicle</module>
|
<module>muyu-vehicle</module>
|
||||||
<module>muyu-cloud-datasource</module>
|
<module>muyu-cloud-datasource</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue