Commit f71c1844 authored by 赵啸非's avatar 赵啸非

添加产品升级功能

parent 03013975
......@@ -14,7 +14,7 @@ import javax.annotation.PreDestroy;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
@Service
//@Service
@Slf4j
public class DefaultTbCoreConsumerService extends AbstractConsumerService<TbQueueMsg> implements TbCoreConsumerService {
......
......@@ -32,7 +32,6 @@ public class DefaultTbQueueMsg implements TbQueueMsg {
*/
private String data;
/**
* 消息头信息
*/
......@@ -61,7 +60,10 @@ public class DefaultTbQueueMsg implements TbQueueMsg {
String ret = JSON.toJSONString(queueMsg);
System.out.println("pro:"+ret);
//
// DefaultTbQueueMsg qu = JSON.parseObject(ret, DefaultTbQueueMsg.class);
DefaultTbQueueMsg qu = JSON.parseObject(ret, DefaultTbQueueMsg.class);
System.out.println("header:"+qu.getHeaders().get(MessageHeader.MESSAGETYPE));
System.out.println("data:"+qu.getData());
}
......
......@@ -13,7 +13,7 @@ import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@Component
//@Component
@ConditionalOnExpression("'${queue.type:null}'=='rabbitmq'")
public class RabbitMqTbCoreQueueFactory implements TbCoreQueueFactory {
......
......@@ -13,7 +13,7 @@ import javax.annotation.PostConstruct;
* 初始化消息生产者服务
*/
@CommonsLog
@Service
//@Service
public class TbCoreQueueProducerProvider implements TbQueueProducerProvider {
/**
......@@ -27,7 +27,7 @@ public class TbCoreQueueProducerProvider implements TbQueueProducerProvider {
*/
private TbQueueProducer<TbQueueMsg> queueProducer;
@PostConstruct
//@PostConstruct
public void init() {
log.info("消息队列生产服务开始...");
this.queueProducer = tbQueueProvider.createMsgProducer();
......
......@@ -13,7 +13,7 @@ import javax.annotation.PostConstruct;
@Slf4j
@ConditionalOnExpression("'${queue.type:null}'=='rabbitmq'")
@Component
//@Component
@Data
public class TbRabbitMqSettings {
@Value("${queue.rabbitmq.exchange_name:}")
......
......@@ -2,7 +2,7 @@
NODE_ENV = development
# 地址
VUE_APP_BASE_API =http://plm.testnew.com:8082/m
VUE_APP_BASE_API =http://plm.testnew.com:8084/m
# websocket地址
VUE_APP_WEBSOCKET_API =127.0.0.1:18222/m
......@@ -10,3 +10,6 @@ VUE_APP_WEBSOCKET_API =127.0.0.1:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
# 站点请求地址
VUE_APP_SITETREE_URL = http://127.0.0.1:18222/m/site/siteTree
......@@ -10,3 +10,6 @@ VUE_APP_WEBSOCKET_API =192.168.0.98:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
# 站点请求地址
VUE_APP_SITETREE_URL = http://192.168.0.98:18222/m/site/siteTree
\ No newline at end of file
......@@ -10,3 +10,6 @@ VUE_APP_WEBSOCKET_API =192.168.0.98:18222/m
# 门户登录地址
VUE_APP_PORTAL_URL = http://192.168.0.98:11072
# 站点请求地址
VUE_APP_SITETREE_URL = http://192.168.0.98:18222/m/site/siteTree
\ No newline at end of file
......@@ -51,10 +51,9 @@
"less": "^3.0.4",
"less-loader": "^4.1.0",
"lint-staged": "10.5.3",
"node-sass": "^5.0.0",
"runjs": "4.4.2",
"sass": "1.32.0",
"sass-loader": "^10.1.0",
"sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.5",
"svg-sprite-loader": "5.1.1",
"vue-formatter": "^0.0.8",
......
......@@ -107,7 +107,14 @@ export default {
// this.getwaitedListdata(id);
},
getwaitedListdata() {
this.$get("http://192.168.0.98:11078/base/site/siteTree").then((res) => {
let url=process.env.VUE_APP_SITETREE_URL=='undefined'?'http://192.168.0.98:11078/base/site/siteTree':process.env.VUE_APP_SITETREE_URL
console.log("url:"+url)
console.log("url:"+process.env.VUE_APP_SITETREE_URL)
this.$get(url).then((res) => {
console.log(res.data);
const { siteTree } = res.data;
this.sitelist = siteTree;
......
......@@ -471,6 +471,7 @@ export default {
created() {
// this.siteId = window.sessionStorage.getItem("siteid") || null
this.siteId = session.getSession("siteid") || null;
console.log("cur siteId"+this.siteId)
let today = new Date();
let query = {
year: today.getFullYear(),
......@@ -509,7 +510,9 @@ export default {
this.pushChart.resize();
},
syncDeviceStat() {
this.$post("/device/stat/syncDeviceStat", {})
this.$post("/device/stat/syncDeviceStat", {siteId:this.siteId})
.then((res) => {
if (res.code == 1) {
this.statData = res.data.data[0];
......
......@@ -21,63 +21,6 @@
登陆 &copy; <a href="">信宏翔网络科技有限公司</a> 出品
</div>
<!-- <Map ref="map1" :markersData="originData" @choose="getDetailData" /> -->
<!-- <el-card :body-style="{ padding: '5px' }" style="width: 300px">
<el-row type="flex" class="row-bg" justify="space-around">
<span style="font-size: 18px"><b>高新区政务服务中心</b></span>
<el-button type="text" size="mini" class="button">查看详情</el-button>
</el-row>
<el-divider></el-divider>
<el-row type="flex" justify="space-around">
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">设备总数</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">在线</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">离线</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">停用</span>
</el-col>
<el-col :span="4">
<span style="font-size: 13px"><b>100</b></span
><br />
<span style="font-size: 12px">待激活</span>
</el-col>
</el-row>
<el-divider></el-divider>
<el-descriptions :column="1" size="small">
<el-descriptions-item label="站点编码"
>kooriookami</el-descriptions-item
>
<el-descriptions-item label="站点地址"
>18100000000</el-descriptions-item
>
<el-descriptions-item
label="联系人"
:labelStyle="{ 'text-align': 'right', width: '50px' }"
>苏州市</el-descriptions-item
>
<el-descriptions-item label="联系电话">
<el-tag size="small">学校</el-tag>
</el-descriptions-item>
<el-descriptions-item label="创建时间"
>江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item
>
</el-descriptions>
</el-card> -->
</div>
</template>
......
......@@ -17,7 +17,8 @@ module.exports = {
hot: true,//自动保存
proxy: {
'/m': {
target: 'http://192.168.0.98:11078',
// target: 'http://192.168.0.98:11078',
target: 'http://127.0.0.1:18222',
changeOrigin: true,
secure: false,
cookieDomainRewrite: 'plm.testnew.com',
......
......@@ -23,31 +23,34 @@
<properties>
<profiles.active>develop</profiles.active>
<profiles.server.port>18222</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.queue.type></profiles.queue.type>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://localhost:3306/device-new-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://localhost:3306/device-new-platform?allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>12345678</profiles.datasource.password>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri>
<profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.password></profiles.redis.password>
<profiles.redis.database>7</profiles.redis.database>
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.username>guest</profiles.rabbitmq.username>
<profiles.rabbitmq.password>guest</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/test</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost1>/</profiles.rabbitmq.virtualhost1>
<profiles.rabbitmq.exchange></profiles.rabbitmq.exchange>
<profiles.rabbitmq.exchange>amp.direct</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.log.level>DEBUG</profiles.log.level>
<profiles.log.path>/logs</profiles.log.path>
<profiles.data.path>/data</profiles.data.path>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
</properties>
......@@ -75,7 +78,10 @@
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
<profiles.rabbitmq.virtualhost>/test</profiles.rabbitmq.virtualhost>
<profiles.rabbitmq.virtualhost1>/</profiles.rabbitmq.virtualhost1>
<profiles.rabbitmq.exchange></profiles.rabbitmq.exchange>
<profiles.rabbitmq.exchange>amp.direct</profiles.rabbitmq.exchange>
<profiles.sms.smsSendUrl>http://127.0.0.1:8089/api/index/index</profiles.sms.smsSendUrl>
<profiles.sms.apiId>k6BVS1PEbyzcJAE4</profiles.sms.apiId>
<profiles.sms.type>3</profiles.sms.type>
<profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.log.level>INFO</profiles.log.level>
<profiles.data.path>/data</profiles.data.path>
......
......@@ -19,6 +19,7 @@ public class ManagerApplication extends BaseWebApplication {
public static void main(String[] args) {
SpringApplication.run(ManagerApplication.class, args);
}
......
package com.mortals.xhx.base.framework.config;
import com.mortals.xhx.base.framework.listener.DirectDynamicListener;
import com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler;
import com.mortals.xhx.base.framework.listener.SimpleDynamicListener;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.base.system.message.impl.MessageServiceImpl;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.rabbit.AsyncRabbitTemplate;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
......@@ -15,11 +22,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@Configuration
@Order(1)
public class RabbitConfig {
@Autowired
private SimpleDynamicListener simpleDynamicListener;
@Autowired
private DirectDynamicListener directDynamicListener;
@Autowired
private RabbitLoggingErrorHandler rabbitLoggingErrorHandler;
@Autowired
private MessageProducer messageProducer;
//@Bean("simpleMessageListenerContainer")
public SimpleMessageListenerContainer simpleMessageListenerContainer(CachingConnectionFactory cachingConnectionFactory) {
......@@ -32,8 +47,41 @@ public class RabbitConfig {
return container;
}
@Bean
public DirectMessageListenerContainer messageListenerContainer(ConnectionFactory connectionFactory) {
DirectMessageListenerContainer container = new DirectMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
//后置处理器,接收到的消息都添加头信息
container.setAfterReceivePostProcessors(message -> {
message.getMessageProperties().setContentType("application/json");
return message;
});
//设置异常处理
container.setErrorHandler(rabbitLoggingErrorHandler);
// 并发消费,不使用
// container.setConsumersPerQueue(3);
// container.setMaxConcurrentConsumers(10);
// container.setMessageListener(directDynamicListener);
return container;
}
@Bean(name = "consumerBatchContainerFactory")
@Bean
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setReturnCallback(messageProducer);
rabbitTemplate.setConfirmCallback(messageProducer);
return rabbitTemplate;
}
@Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
return rabbitAdmin;
}
//@Bean(name = "consumerBatchContainerFactory")
public SimpleRabbitListenerContainerFactory consumerBatchContainerFactory(
SimpleRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory) {
// 创建 SimpleRabbitListenerContainerFactory 对象
......@@ -54,7 +102,7 @@ public class RabbitConfig {
}
@Bean
//@Bean
public AsyncRabbitTemplate asyncRabbitTemplate(RabbitTemplate rabbitTemplate) {
AsyncRabbitTemplate asyncRabbitTemplate = new AsyncRabbitTemplate(rabbitTemplate);
asyncRabbitTemplate.setReceiveTimeout(10000);
......
......@@ -8,6 +8,7 @@ import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.PlatformTypeEnum;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
......@@ -54,6 +55,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Value("${token.database:0}")
private Integer portalDb;
@Value("${platform.type:cloud}")
private String platFormType;//版本,默认云服务版本
protected static final Long SECOND = 1l;
protected static final Long SECOND_MINUTE = 60 * SECOND;
......@@ -86,10 +90,15 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String userKey = getTokenKey(uuid);
// Rest<String> rest = userFeign.getToken(userKey);
// String userStr = rest.getData();
cacheService.select(portalDb);
String userStr = cacheService.get(userKey);
String userStr = "";
if (platFormType.equalsIgnoreCase(PlatformTypeEnum.CLOUD.getValue())) {
cacheService.select(portalDb);
userStr = cacheService.get(userKey);
cacheService.select(db);
} else {
userStr = cacheService.get(userKey);
}
cacheService.select(db);
if (StringUtils.isNotEmpty(userStr)) {
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
userEntity.setToken(token);
......
......@@ -3,6 +3,7 @@ package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.UuidUtil;
import com.mortals.xhx.common.code.*;
......@@ -32,7 +33,9 @@ import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 离线通知
......@@ -60,7 +63,6 @@ public class CustomerKeyExpirationListener implements MessageListener {
@Autowired
private ISmsSetFeign smsSetFeign;
@Override
public void onMessage(Message message, byte[] bytes) {
String key = message.toString();
......@@ -81,13 +83,11 @@ public class CustomerKeyExpirationListener implements MessageListener {
}
//保存离线告警消息
DeviceAlarmInfoEntity alarmInfoEntity = new DeviceAlarmInfoEntity();
alarmInfoEntity.initAttrValue();
alarmInfoEntity.setAlarmDevice(deviceEntity.getId());
alarmInfoEntity.setSiteId(deviceEntity.getSiteId());
alarmInfoEntity.setAlarmContent(deviceEntity.getDeviceName() + "已离线!");
alarmInfoEntity.setAlarmContent(String.format("设备告警:%s设备:%s已离线,请注意检查!",productEntity.getProductName(),deviceEntity.getDeviceName()+":"+deviceEntity.getDeviceName() ));
alarmInfoEntity.setAlarmType(AlarmTypeEnum.离线.getValue());
alarmInfoEntity.setAlarmLevel(AlarmLevelEnum.一般.getValue());
alarmInfoEntity.setAlarmStatus(AlarmStatusEnum.未清除.getValue());
......@@ -96,14 +96,11 @@ public class CustomerKeyExpirationListener implements MessageListener {
alarmInfoEntity.setCreateTime(new Date());
alarmInfoEntity.setCreateUserId(1L);
deviceAlarmInfoService.save(alarmInfoEntity);
// TODO: 2022/6/23 告警信息保存与发送
AlarmConfigEntity alarmConfigEntity = alarmConfigService.selectOne(new AlarmConfigQuery().productId(productEntity.getId()));
if (!ObjectUtils.isEmpty(alarmConfigEntity)) {
if (alarmConfigEntity.getAlarmPusW1ay() == AlarmPusW1ayEnum.短信.getValue()) {
// TODO: 2022/7/4 发送短信
Rest<RespData<List<SmsSetPdu>>> respDataRest = smsSetFeign.list(new SmsSetPdu().siteId(deviceEntity.getSiteId()));
if (respDataRest.getCode() == YesNoEnum.YES.getValue()) {
List<SmsSetPdu> data = respDataRest.getData().getData();
......@@ -111,7 +108,7 @@ public class CustomerKeyExpirationListener implements MessageListener {
Integer messageoff = data.get(0).getMessageoff();
if (messageoff == YesNoEnum.YES.getValue()) {
// todo 发送短信
//短信使用模板,如 设备告警:{产品}设备:{设备名称加编码}已离线,请注意检查!
DeviceAlarmInfoEntity deviceAlarmInfoEntity = deviceAlarmInfoService.selectOne(new DeviceAlarmInfoQuery().alarmDevice(deviceEntity.getId()));
if (!ObjectUtils.isEmpty(deviceAlarmInfoEntity)) {
AlarmSmsSendEntity alarmSmsSendEntity = new AlarmSmsSendEntity();
......@@ -120,7 +117,10 @@ public class CustomerKeyExpirationListener implements MessageListener {
alarmSmsSendEntity.setSiteId(deviceAlarmInfoEntity.getSiteId());
alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone());
alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel());
alarmSmsSendEntity.setSendMess(deviceAlarmInfoEntity.getAlarmContent());
Map<String, String> map = new HashMap<>();
map.put("1",productEntity.getProductName());
map.put("2",deviceEntity.getDeviceName()+":"+deviceEntity.getDeviceName());
alarmSmsSendEntity.setSendMess(JSON.toJSONString(map));
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity, null);
}
......
package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.DefaultQueueMsg;
import com.mortals.xhx.common.utils.SendTask;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.queue.DefaultTbQueueMsg;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import static com.mortals.xhx.common.model.MessageHeader.DEVICECODE;
import static com.mortals.xhx.common.model.MessageHeader.MESSAGETYPE;
/**
* 设备上行消息处理
*
* @author: zxfei
* @date: 2022/8/23 0:32
* @description:
**/
@Slf4j
@Service
public class DirectDynamicListener implements MessageListener {
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceService deviceService;
@Autowired
private ProductService productService;
@Autowired
private PlatformService platformService;
@Autowired
private SendTaskThreadPool sendTaskThreadPool;
@Autowired
private ICacheService cacheService;
@Override
public void onMessage(Message message) {
String queue = message.getMessageProperties().getConsumerQueue();
byte[] body = message.getBody();
String data = new String(body);
log.info("接收到:{} ,\n消息内容为:{}", queue, data);
DefaultQueueMsg queueMsg = JSON.parseObject(data, DefaultQueueMsg.class);
//做相应业务,做日志操作
String deviceCode = queueMsg.getHeaders().getData().get(DEVICECODE);
String messageType = queueMsg.getHeaders().getData().get(MESSAGETYPE);
try {
DeviceEntity deviceEntity = deviceService.getExtCache(deviceCode);
if (!ObjectUtils.isEmpty(deviceEntity)) {
cacheService.set(RedisKey.KEY_DEVICE_ONLINE_CACHE + deviceEntity.getDeviceCode(), "", GlobalSysInfo.getParamIntValue(Constant.HEARTBEAT_TIMEOUT, 120));
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) {
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE);
}
}
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(messageType);
deviceLogEntity.setContent(queueMsg.getData());
deviceLogEntity.setLogType(LogTypeEnum.上报事件.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
}
//获取exchange,
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)
&& !ObjectUtils.isEmpty(platformEntity)
&& platformEntity.getSendSwitch() == YesNoEnum.YES.getValue()) {
if (platformEntity.getSendMsgType() == SendMsgTypeEnum.http.getValue() && !ObjectUtils.isEmpty(platformEntity.getSendUrl())) {
SendTask sendTask = new SendTask(platformEntity.getSendUrl(), queueMsg.getData());
sendTaskThreadPool.execute(sendTask);
}
}
}
} catch (Exception e) {
log.error("消费消息异常", e);
}
// log.info("接收到:" + queue + ",消息内容为:" + new String(body));
// //channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
// log.info(queue + "队列消息消费成功");
}
}
package com.mortals.xhx.base.framework.listener;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.ErrorHandler;
@Component
@Slf4j
public class RabbitLoggingErrorHandler implements ErrorHandler {
public RabbitLoggingErrorHandler(SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory) {
rabbitListenerContainerFactory.setErrorHandler(this);
}
@Override
public void handleError(Throwable t) {
log.error("[handleError][发生异常]]", t);
}
}
package com.mortals.xhx.base.login.web;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.CookieService;
import com.mortals.framework.ap.GlobalSysInfo;
......@@ -10,7 +9,6 @@ import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.AESUtil;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
......@@ -24,9 +22,9 @@ import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -43,7 +41,8 @@ import static com.mortals.xhx.common.key.ErrorCode.ERROR_TOKEN_EXPIRED_CONTENT;
@RestController
@Slf4j
@RequestMapping("login")
public class LoginController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> {
@ConditionalOnExpression("'${platform.type:null}'=='cloud'")
public class LoginController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> implements InitializingBean {
@Autowired
private UserService userService;
......@@ -280,4 +279,9 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
}
return null;
}
@Override
public void afterPropertiesSet() throws Exception {
log.info("初始化加载云服务版登录。。。");
}
}
/**
* 文件:AreaDao.java<br/>
* 版本:1.0.0<br/>
* 日期:2019-03-14<br/>
* Copyright &reg; www.sccoopskj.com<br/>
* All right reserved.
*/
package com.mortals.xhx.base.system.area.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.base.system.area.model.AreaEntity;
/**
* Title: 区域信息 <br/>
* Description: AreaDao DAO接口 <br/>
* Copyright: Copyright &reg; www.sccoopskj.com <br/>
* Company: www.sccoopskj.com
*
* @author
* @version 1.0.0
*/
public interface AreaDao extends ICRUDDao<AreaEntity,Long>{
}
\ No newline at end of file
/**
* 文件:AreaEntity.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.area.model;
import java.util.Date;
import com.mortals.framework.model.BaseEntityLong;
/**
* <p>Title: 区域信息</p>
* <p>Description: AreaEntity </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class AreaEntity extends BaseEntityLong{
private static final long serialVersionUID = 1556594630661L;
/** 上级区域ID */
private Long parentId;
/** 区域名称 */
private String name;
/** 区域级别,按所处树的节点层次 */
private Integer level;
/** 区域编码,按全国省市编码 */
private String code;
/** 区域负责人 */
private String contactsPeople;
/** 区域负责人电话 */
private String contactsMobile;
/** 子区域数量,默认0 */
private Integer childSize;
/** 子区域的最大ID,默认0 */
private Integer maxChildId;
/** 状态,0停用,1启用,默认1 */
private Integer status;
/** 描述 */
private String remark;
/** 创建时间 */
private Date createTime;
/** 更新时间 */
private Date updateTime;
/** 创建用户ID */
private Long createUserId;
/** 创建用户名称 */
private String createUserName;
public AreaEntity(){
}
/**
* 获取 上级区域ID
* @return parentId
*/
public Long getParentId(){
return this.parentId;
}
/**
* 设置 上级区域ID
* @param parentId
*/
public void setParentId(Long parentId){
this.parentId = parentId;
}
/**
* 获取 区域名称
* @return name
*/
public String getName(){
return this.name;
}
/**
* 设置 区域名称
* @param name
*/
public void setName(String name){
this.name = name;
}
/**
* 获取 区域级别,按所处树的节点层次
* @return level
*/
public Integer getLevel(){
return this.level;
}
/**
* 设置 区域级别,按所处树的节点层次
* @param level
*/
public void setLevel(Integer level){
this.level = level;
}
/**
* 获取 区域编码,按全国省市编码
* @return code
*/
public String getCode(){
return this.code;
}
/**
* 设置 区域编码,按全国省市编码
* @param code
*/
public void setCode(String code){
this.code = code;
}
/**
* 获取 区域负责人
* @return contactsPeople
*/
public String getContactsPeople(){
return this.contactsPeople;
}
/**
* 设置 区域负责人
* @param contactsPeople
*/
public void setContactsPeople(String contactsPeople){
this.contactsPeople = contactsPeople;
}
/**
* 获取 区域负责人电话
* @return contactsMobile
*/
public String getContactsMobile(){
return this.contactsMobile;
}
/**
* 设置 区域负责人电话
* @param contactsMobile
*/
public void setContactsMobile(String contactsMobile){
this.contactsMobile = contactsMobile;
}
/**
* 获取 子区域数量,默认0
* @return childSize
*/
public Integer getChildSize(){
return this.childSize;
}
/**
* 设置 子区域数量,默认0
* @param childSize
*/
public void setChildSize(Integer childSize){
this.childSize = childSize;
}
/**
* 获取 子区域的最大ID,默认0
* @return maxChildId
*/
public Integer getMaxChildId(){
return this.maxChildId;
}
/**
* 设置 子区域的最大ID,默认0
* @param maxChildId
*/
public void setMaxChildId(Integer maxChildId){
this.maxChildId = maxChildId;
}
/**
* 获取 状态,0停用,1启用,默认1
* @return status
*/
public Integer getStatus(){
return this.status;
}
/**
* 设置 状态,0停用,1启用,默认1
* @param status
*/
public void setStatus(Integer status){
this.status = status;
}
/**
* 获取 描述
* @return remark
*/
public String getRemark(){
return this.remark;
}
/**
* 设置 描述
* @param remark
*/
public void setRemark(String remark){
this.remark = remark;
}
/**
* 获取 创建时间
* @return createTime
*/
public Date getCreateTime(){
return this.createTime;
}
/**
* 设置 创建时间
* @param createTime
*/
public void setCreateTime(Date createTime){
this.createTime = createTime;
}
/**
* 获取 更新时间
* @return updateTime
*/
public Date getUpdateTime(){
return this.updateTime;
}
/**
* 设置 更新时间
* @param updateTime
*/
public void setUpdateTime(Date updateTime){
this.updateTime = updateTime;
}
/**
* 获取 创建用户ID
* @return createUserId
*/
public Long getCreateUserId(){
return this.createUserId;
}
/**
* 设置 创建用户ID
* @param createUserId
*/
public void setCreateUserId(Long createUserId){
this.createUserId = createUserId;
}
/**
* 获取 创建用户名称
* @return createUserName
*/
public String getCreateUserName(){
return this.createUserName;
}
/**
* 设置 创建用户名称
* @param createUserName
*/
public void setCreateUserName(String createUserName){
this.createUserName = createUserName;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj instanceof AreaEntity) {
AreaEntity tmp = (AreaEntity) obj;
if (this.getId().longValue() == tmp.getId().longValue()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append("id:").append(getId())
.append(",parentId:").append(getParentId())
.append(",name:").append(getName())
.append(",level:").append(getLevel())
.append(",code:").append(getCode())
.append(",contactsPeople:").append(getContactsPeople())
.append(",contactsMobile:").append(getContactsMobile())
.append(",childSize:").append(getChildSize())
.append(",maxChildId:").append(getMaxChildId())
.append(",status:").append(getStatus())
.append(",remark:").append(getRemark())
.append(",createTime:").append(getCreateTime())
.append(",updateTime:").append(getUpdateTime())
.append(",createUserId:").append(getCreateUserId())
.append(",createUserName:").append(getCreateUserName());
return sb.toString();
}
public void initAttrValue(){
this.parentId = null;
this.name = null;
this.level = null;
this.code = null;
this.contactsPeople = null;
this.contactsMobile = null;
this.childSize = 0;
this.maxChildId = 0;
this.status = 1;
this.remark = null;
this.createTime = null;
this.updateTime = null;
this.createUserId = null;
this.createUserName = null;
}
}
\ No newline at end of file
/**
* 文件:AreaService.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.area.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.base.system.area.model.AreaEntity;
/**
* <p>Title: 区域信息</p>
* <p>Description: AreaService service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public interface AreaService extends ICRUDService<AreaEntity,Long>{
/**
* 格式化areaId
* @param areaId
* @return
*/
Long formatAreaId(Long areaId);
}
\ No newline at end of file
/**
* 文件:AreaServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.area.service.impl;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.base.system.area.dao.AreaDao;
import com.mortals.xhx.base.system.area.model.AreaEntity;
import com.mortals.xhx.base.system.area.service.AreaService;
/**
* <p>Title: 区域信息</p>
* <p>Description: AreaServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
@Service("areaService")
public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao,AreaEntity,Long> implements AreaService {
/**
* 格式化区域ID
* @param areaId
* @return
*/
@Override
public Long formatAreaId(Long areaId) {
Long id = areaId;
if(id != null){
String area = String.valueOf(id);
if(area.endsWith("00")){
area = area.substring(0, 4);
}
if(area.endsWith("00")){
area = area.substring(0, 2);
}
id = (Long.valueOf(area));
}
return id;
}
}
\ No newline at end of file
/**
* 文件:AreaController.java 版本:1.0.0 日期: Copyright &reg; All right reserved.
*/
package com.mortals.xhx.base.system.area.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.YesNo;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.area.model.AreaEntity;
import com.mortals.xhx.base.system.area.service.AreaService;
import com.mortals.xhx.common.code.AreaLevelEnum;
/**
* <p>
* Title: 区域信息
* </p>
* <p>
* Description: AreaController
* </p>
* <p>
* Copyright: Copyright &reg;
* </p>
* <p>
* Company:
* </p>
* @author
* @version 1.0.0
*/
@RestController
@RequestMapping("area")
public class AreaController extends BaseCRUDJsonMappingController<AreaService, AreaForm, AreaEntity, Long> {
public AreaController() {
super.setFormClass(AreaForm.class);
super.setModuleDesc("区域信息");
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, AreaForm form,
Map<String, Object> model, Context context) {
this.addDict(model, "level", IBaseEnum.getEnumMap(AreaLevelEnum.class));
this.addDict(model, "status", IBaseEnum.getEnumMap(YesNo.class));
super.init(request, response, form, model, context);
}
@Override
protected void doListBefore(HttpServletRequest request, HttpServletResponse response, AreaForm form, Map<String, Object> model, Context context) throws AppException {
if (form.getQuery().getStatus() == null) {
form.getQuery().setStatus(YesNo.YES.getValue());
}
if(StringUtils.isEmpty(form.getQuery().getName())){
form.getQuery().setLevel(AreaLevelEnum.PROVINCE.getValue());
}
}
/**
* 根据parentId查询区域信息
*/
@PostMapping(value="getAreaByParentId")
public String getAreaByParentId(HttpServletRequest request, HttpServletResponse response, AreaForm form) {
JSONObject ret = new JSONObject();
Context context = getContext();
try{
List<JSONObject> list = new ArrayList<>();
PageInfo pageInfo = form.getPageInfo();
Result<AreaEntity> result = service.find(form.getQuery(), form.getPageInfo(), context);
pageInfo = result.getPageInfo();
List<AreaEntity> areaList = result.getList();
for(AreaEntity area : areaList){
JSONObject json = new JSONObject();
json.put("id", area.getId());
json.put("parentId", area.getParentId());
json.put("name", area.getName());
json.put("level", area.getLevel());
json.put("code", area.getCode());
json.put("contactsPeople", area.getContactsPeople());
json.put("contactsMobile", area.getContactsMobile());
json.put("remark", area.getRemark());
list.add(json);
}
JSONObject data = new JSONObject();
data.put(SysConstains.RESULT_KEY, list);
data.put(SysConstains.PAGEINFO_KEY, pageInfo);
init(request, response, form, data, context);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_DATA, data);
}catch(Exception e){
log.error("根据parentId查询区域信息错误", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
return ret.toJSONString();
}
@PostMapping(value = "getAllAreaList")
public String getAllAreaList(HttpServletRequest request, HttpServletResponse response, AreaForm form) {
try{
return super.list(form);
}catch(Exception e){
log.error("查询所有区域信息列表错误",e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
\ No newline at end of file
/**
* 文件:AreaForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.area.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.area.model.AreaEntity;
import com.mortals.xhx.base.system.area.model.AreaQuery;
/**
* <p>Title: 区域信息</p>
* <p>Description: AreaForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class AreaForm extends BaseCRUDFormLong<AreaEntity> {
private AreaEntity entity = new AreaEntity();
private AreaQuery query = new AreaQuery();
public AreaForm(){
}
@Override
public AreaEntity getEntity() {
return entity;
}
public void setEntity(AreaEntity entity) {
this.entity = entity;
}
@Override
public AreaQuery getQuery() {
return query;
}
public void setQuery(AreaQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ public interface MessageService {
/**
* 请求队列
*
* @param info
* @param callback
*/
......@@ -32,22 +33,23 @@ public interface MessageService {
/**
* 删除队列
*/
void delQueue(String queue,TbQueueCallback callback);
void delQueue(String queue, TbQueueCallback callback);
/**
* 获取鉴权token
*
*/
String getBasePlatformToken();
/**
* 获取站点树
*
* @return
*/
String siteTree();
/**
* 发送第三方平台crud消息
*
* @param sendUrl
* @param deviceReq
* @return
......@@ -57,6 +59,7 @@ public interface MessageService {
/**
* 发送第三方平台四二班透传消息
*
* @param sendUrl
* @param content
* @return
......
package com.mortals.xhx.base.system.message;
import com.mortals.xhx.busiz.req.DeviceReq;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.queue.TbQueueCallback;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import com.mortals.xhx.queue.TopicPartitionInfo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
public interface RabbitMessageService extends RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback {
/**
* 发送消息
*
* @author: zxfei
* @date: 2022/9/2 11:31
*/
void sendMsg(String exchange, String routingKey, String message);
/**
* 新增队列并绑定交换机与路由
*
* @param exchange
* @param routingKey
* @param queue
*/
void queueAddAndBinds(String exchange, String routingKey, String queue);
/**
* 删除队列
*
* @param queue
*/
Boolean queueDelete(String queue);
}
\ No newline at end of file
package com.mortals.xhx.base.system.message;
package com.mortals.xhx.base.system.message.impl;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.model.AccessLogPdu;
import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.model.OperateLogPdu;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.xhx.base.system.message.RabbitMessageService;
import com.mortals.xhx.common.key.QueueKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
@Primary
@Slf4j
public class MessageProducer implements IMessageProduceService {
public class MessageProducer implements IMessageProduceService, RabbitMessageService, InitializingBean {
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private RabbitAdmin rabbitAdmin;
public void syncAccessSend(AccessLogPdu accessLogPdu) {
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ACCESS_LOG_QUEUE, JSON.toJSONString(accessLogPdu));
......@@ -33,14 +46,56 @@ public class MessageProducer implements IMessageProduceService {
@Override
public void syncErrorSend(ErrorLogPdu errorLogPdu) {
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.ERROR_LOG_QUEUE, JSON.toJSONString(errorLogPdu));
}
@Override
public void syncOperSend(OperateLogPdu operLogPdu) {
log.info("operLogInfo==>{}",JSON.toJSONString(operLogPdu));
rabbitTemplate.convertAndSend(QueueKey.EXCHANGE, QueueKey.OPERATION_LOG_QUEUE, JSON.toJSONString(operLogPdu));
}
@Override
public void sendMsg(String exchange, String routingKey, String message) {
CorrelationData correlationData = new CorrelationData(IdUtil.fastSimpleUUID());
rabbitTemplate.convertAndSend(exchange, routingKey, message, correlationData);
// rabbitTemplate.send(exchange,routingKey,);
}
@Override
public void queueAddAndBinds(String exchange, String routingKey, String queue) {
Map<String, Object> args = new HashMap<>();
args.put("x-message-ttl", 86400000);
Queue rabbitQueue = new Queue(queue, true, false, false, args);
DirectExchange directExchange = new DirectExchange(exchange);
rabbitAdmin.declareQueue(rabbitQueue);
rabbitAdmin.declareBinding(
BindingBuilder.bind(rabbitQueue)
.to(directExchange)
.with(routingKey)
);
log.debug("队列创建绑定成功,queue:{}", queue);
}
@Override
public Boolean queueDelete(String queue) {
return rabbitAdmin.deleteQueue(queue);
}
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
}
@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
}
@Override
public void afterPropertiesSet() throws Exception {
System.out.println(111);
}
}
......@@ -6,8 +6,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.*;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.HttpUtil;
......@@ -22,6 +23,7 @@ import com.mortals.xhx.common.code.DeviceMethodEnum;
import com.mortals.xhx.common.code.MessageTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.common.utils.SendTask;
......@@ -31,11 +33,22 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.queue.*;
import com.mortals.xhx.queue.provider.TbCoreQueueProducerProvider;
import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -56,7 +69,7 @@ import static com.mortals.xhx.common.key.Constant.PATH_SITETREE;
*/
@Service("messageService")
@Slf4j
public class MessageServiceImpl implements MessageService {
public class MessageServiceImpl implements MessageService{
@Value("${baseplatform.httpUrl:''}")
private String httpUrl;
......@@ -69,8 +82,7 @@ public class MessageServiceImpl implements MessageService {
@Autowired
private SendTaskThreadPool sendTaskThreadPool;
@Autowired
//@Autowired
private TbCoreQueueProducerProvider producerProvider;
@Override
......@@ -79,6 +91,10 @@ public class MessageServiceImpl implements MessageService {
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastSimpleUUID(), message == null ? "" : message, header);
producer.send(info, queueMsg, callback);
//rabbitTemplate.send();
}
@Override
......@@ -180,6 +196,7 @@ public class MessageServiceImpl implements MessageService {
sendTaskThreadPool.execute(sendTask);
}
public static void main(String[] args) {
try {
......@@ -192,13 +209,12 @@ public class MessageServiceImpl implements MessageService {
JSONObject jsonObject = new JSONObject();
jsonObject.put("stacktrace",stacktrace);
jsonObject.put("stacktrace", stacktrace);
System.out.println(JSON.toJSONString(jsonObject));
}
}
}
\ No newline at end of file
package com.mortals.xhx.base.system.site.dao;
import com.mortals.xhx.base.system.site.model.SiteEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @author: zxfei
* @date: 2021/9/1 9:08
*/
@Mapper
@Repository
public interface ISiteCustomDao {
/**
* 查询子站点
*
* @param map 参数
* @return
*/
List<SiteEntity> selectChildrenSiteById(Map<String,String> map);
}
package com.mortals.xhx.base.system.site.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.base.system.site.model.SiteEntity;
import com.mortals.xhx.base.system.site.model.TreeSelect;
import java.util.List;
/**
* <p>Title: 站点信息表</p>
* <p>Description: SiteService service接口 </p>
* <p>Copyright: Copyright &reg; </p>
*
* @version 1.0.0
*/
public interface SiteService extends ICRUDService<SiteEntity, Long> {
/**
* 是否存在站点子节点
*
* @param siteId SiteID
* @return 结果
*/
boolean hasChildBySiteId(Long siteId);
/**
* 查询站点是否存在用户
*
* @param siteId 站点ID
* @return 结果 true 存在 false 不存在
*/
boolean checkSiteExistUser(Long siteId);
/**
* 查询站点管理数据
*
* @param site 站点信息
* @return 站点信息集合
*/
List<SiteEntity> selectSiteList(SiteEntity site);
/**
* 构建前端所需要下拉树结构
*
* @param sites 站点列表
* @return 下拉树结构列表
*/
public List<TreeSelect> buildSiteTreeSelect(List<SiteEntity> sites);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment