Commit 8cbed39d by 李小惠

添加设备监控消息队列

parent 68c1dacb
...@@ -237,3 +237,4 @@ Thumbs.db ...@@ -237,3 +237,4 @@ Thumbs.db
/app-log/log_error.log.orig /app-log/log_error.log.orig
/app-log/log_total.log.orig /app-log/log_total.log.orig
/app-log/total/log-total-2024-01-31.0.log.orig /app-log/total/log-total-2024-01-31.0.log.orig
/lxh/
<<<<<<< HEAD
/jyzb-process/target
/jyzb-api/target/
/jyzb-biz/target/
##ignore this file##
/target/
.classpath
.project
/.settings/
##filter databfile、sln file##
*.mdb
*.ldb
*.sln
##class file##
*.com
*.class
*.dll
*.exe
*.o
*.so
# compression file
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.via
*.tmp
*.err
# OS generated files #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
/*/target/*
=======
/jyzb-boot/target
>>>>>>> develop
2024-03-05 08:31:16.263 ERROR 15956 --- [http-nio-10030-exec-8] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token 2024-03-05 11:03:59.185 ERROR 19644 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:37:36.832 ERROR 15956 --- [TTW-6-3] c.j.i.server.handle.BizProtocolHandler : 协议异常(WebSocket(Server)) - 客户端编号: null - 错误信息: 远程主机强迫关闭了一个现有的连接。 - 处理方式:创建监听器[ExceptionEventListener]监听异常事件(ExceptionEvent) 2024-03-05 11:04:07.772 ERROR 19644 --- [main] o.s.b.d.LoggingFailureAnalysisReporter :
java.io.IOException: 远程主机强迫关闭了一个现有的连接。 ***************************
at sun.nio.ch.SocketDispatcher.read0(Native Method) APPLICATION FAILED TO START
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ***************************
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:192) Description:
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258) Parameter 0 of method createQueuesAndBindings in com.junmp.jyzb.config.rabbitMQ.TopicRabbitConfig required a bean of type 'org.springframework.amqp.core.TopicExchange' that could not be found.
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) The following candidates were found but could not be injected:
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) - User-defined bean method 'topicExchange' in 'largeSrceenRabbitConfig'
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) Action:
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) Consider revisiting the entries above or defining a bean of type 'org.springframework.amqp.core.TopicExchange' in your configuration.
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) 2024-03-05 11:06:58.094 ERROR 19796 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
at java.lang.Thread.run(Thread.java:748) 2024-03-05 11:07:24.051 ERROR 19796 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token
2024-03-05 11:08:27.952 ERROR 19796 --- [http-nio-10030-exec-3] c.j.j.b.c.handle.GlobalExceptionHandler : 业务异常,错误信息为:组织机构不存在
2024-03-05 11:08:42.414 ERROR 15160 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 11:09:06.067 ERROR 15160 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token
2024-03-05 11:10:26.963 ERROR 17680 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 11:10:38.766 ERROR 17680 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token
2024-03-05 11:10:45.134 ERROR 17680 --- [AMQP Connection 192.168.3.121:5672] o.s.a.r.c.CachingConnectionFactory : Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'DevMonitorMsg' in vhost '/', class-id=60, method-id=40)
2024-03-05 11:11:54.168 ERROR 17680 --- [AMQP Connection 192.168.3.121:5672] o.s.a.r.c.CachingConnectionFactory : Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'DevMonitorMsg' in vhost '/', class-id=60, method-id=40)
2024-03-05 11:25:54.742 ERROR 17680 --- [hutool-cron-4] c.h.cron.listener.TaskListenerManager :
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may exist in file [F:\vue_project\jyzb_platformV2_localhost\jyzb-biz\target\classes\mapper\InventorySummaryMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: {CALL Insert_into_view_warranty_group()}
### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
2024-03-05 08:38:55.739 ERROR 15956 --- [http-nio-10030-exec-5] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token org.springframework.dao.CannotAcquireLockException:
2024-03-05 08:40:00.308 ERROR 15956 --- [TTW-6-4] c.j.i.server.handle.BizProtocolHandler : 协议异常(WebSocket(Server)) - 客户端编号: null - 错误信息: 远程主机强迫关闭了一个现有的连接。 - 处理方式:创建监听器[ExceptionEventListener]监听异常事件(ExceptionEvent) ### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
### The error may exist in file [F:\vue_project\jyzb_platformV2_localhost\jyzb-biz\target\classes\mapper\InventorySummaryMapper.xml]
java.io.IOException: 远程主机强迫关闭了一个现有的连接。 ### The error may involve defaultParameterMap
at sun.nio.ch.SocketDispatcher.read0(Native Method) ### The error occurred while setting parameters
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ### SQL: {CALL Insert_into_view_warranty_group()}
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ### Cause: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ; Lock wait timeout exceeded; try restarting transaction; nested exception is com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378) at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:267)
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:258) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) at com.sun.proxy.$Proxy142.insert(Unknown Source)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) at com.sun.proxy.$Proxy280.setWarrantyGroupAction(Unknown Source)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at com.junmp.jyzb.service.impl.InventorySummaryServiceImpl.setWarrantyGroupAction(InventorySummaryServiceImpl.java:538)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at com.junmp.jyzb.service.impl.InventorySummaryServiceImpl$$FastClassBySpringCGLIB$$ec214b78.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.junmp.jyzb.service.impl.InventorySummaryServiceImpl$$EnhancerBySpringCGLIB$$710af712.setWarrantyGroupAction(<generated>)
at com.junmp.jyzb.task.WarrantyGroupAction.action(WarrantyGroupAction.java:19)
at com.junmp.v2.job.hutool.HutoolJobExecuteServiceImpl.lambda$startJob$0(HutoolJobExecuteServiceImpl.java:68)
at cn.hutool.cron.task.CronTask.execute(CronTask.java:31)
at cn.hutool.cron.TaskExecutor.run(TaskExecutor.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) at java.lang.Thread.run(Thread.java:748)
Caused by: com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:123)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
at com.mysql.cj.jdbc.CallableStatement.execute(CallableStatement.java:845)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at com.zaxxer.hikari.pool.HikariProxyCallableStatement.execute(HikariProxyCallableStatement.java)
at org.apache.ibatis.executor.statement.CallableStatementHandler.update(CallableStatementHandler.java:50)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at com.sun.proxy.$Proxy352.update(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at com.sun.proxy.$Proxy351.update(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
... 18 common frames omitted
2024-03-05 08:40:57.442 ERROR 20748 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict! 2024-03-05 11:54:37.354 ERROR 13660 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:41:22.246 ERROR 20748 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token 2024-03-05 12:00:55.984 ERROR 14932 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:43:00.029 ERROR 18504 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict! 2024-03-05 12:02:50.339 ERROR 14180 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:43:11.419 ERROR 18504 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token 2024-03-05 12:16:51.546 ERROR 19636 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:43:25.310 ERROR 18504 --- [http-nio-10030-exec-2] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token 2024-03-05 12:25:15.239 ERROR 20620 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:44:35.216 ERROR 18504 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : 绑定异常>>组织机构不能为空 2024-03-05 12:30:58.081 ERROR 5964 --- [main] easy-es : Easy-Es supported elasticsearch and restHighLevelClient jar version is:7.14.0 ,Please resolve the dependency conflict!
2024-03-05 08:44:35.507 ERROR 18504 --- [http-nio-10030-exec-4] c.j.j.b.c.handle.GlobalExceptionHandler : 业务异常,错误信息为:组织机构不存在 2024-03-05 12:33:27.839 ERROR 5964 --- [http-nio-10030-exec-2] c.j.j.b.c.handle.GlobalExceptionHandler : >授权异常>>获取token失败,请检查header和param中是否传递了用户token
2024-03-05 09:04:01.141 ERROR 18504 --- [http-nio-10030-exec-4] com.junmp.v2.log.aop.ApiLogRecordAop : com.junmp.junmpProcess.controller.BpmnController.getProcessDefinitionId(java.util.LinkedHashMap)
2024-03-05 09:04:45.736 ERROR 18504 --- [http-nio-10030-exec-1] c.j.j.b.c.handle.GlobalExceptionHandler : 业务异常,错误信息为:adin 用户不存在
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.junmp.jyzb.config.rabbitMQ; package com.junmp.jyzb.config.rabbitMQ;
import org.springframework.amqp.core.FanoutExchange; import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -12,11 +13,14 @@ public class largeSrceenRabbitConfig { ...@@ -12,11 +13,14 @@ public class largeSrceenRabbitConfig {
private static final String EXCHANGE_NAME = "largeScreen_exchange"; private static final String EXCHANGE_NAME = "largeScreen_exchange";
@Bean @Bean
public FanoutExchange fanoutExchange() { public FanoutExchange fanoutExchange() {
return new FanoutExchange(EXCHANGE_NAME); return new FanoutExchange(EXCHANGE_NAME);
} }
@Bean @Bean
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) { public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory); RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
...@@ -24,4 +28,5 @@ public class largeSrceenRabbitConfig { ...@@ -24,4 +28,5 @@ public class largeSrceenRabbitConfig {
return rabbitAdmin; return rabbitAdmin;
} }
} }
...@@ -303,7 +303,9 @@ public class InventoryController { ...@@ -303,7 +303,9 @@ public class InventoryController {
@PostMapping(path = "/EqsByState",name = "查询状态满足的装备#enable") @PostMapping(path = "/EqsByState",name = "查询状态满足的装备#enable")
@ApiOperation("查询状态满足的装备") @ApiOperation("查询状态满足的装备")
public ApiRes<PageResult<InventoryDto>> EqsByState(@RequestBody InventoryReq req){ public ApiRes<PageResult<InventoryDto>> EqsByState(@RequestBody InventoryReq req){
return ApiRes.success(inventoryService.EqsByState(req)); return ApiRes.success(inventoryService.EqsByState(req));
} }
//将装备根据质保期,维保期上产日期进行分类汇总并且返回 //将装备根据质保期,维保期上产日期进行分类汇总并且返回
......
...@@ -46,6 +46,9 @@ import com.junmp.v2.message.api.bean.req.MessageSendReq; ...@@ -46,6 +46,9 @@ import com.junmp.v2.message.api.bean.req.MessageSendReq;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.IOUtils;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -90,6 +93,12 @@ public class PublicController { ...@@ -90,6 +93,12 @@ public class PublicController {
private MsgRedisCache redisCache; private MsgRedisCache redisCache;
@Resource @Resource
private RabbitTemplate rabbitTemplate;
@Resource
private RabbitAdmin rabbitAdmin;
@Resource
private OutInRecordRedisCache outInRecordRedisCache; private OutInRecordRedisCache outInRecordRedisCache;
private final static String DB_URL_TEMPLATE = "jdbc:mysql://{}:{}/{}?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true"; private final static String DB_URL_TEMPLATE = "jdbc:mysql://{}:{}/{}?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true";
...@@ -155,8 +164,13 @@ public class PublicController { ...@@ -155,8 +164,13 @@ public class PublicController {
} }
@PostMapping("/bbb") @PostMapping("/bbb")
public ApiRes<Date> bbb(){ public ApiRes<Boolean> bbb(){
return ApiRes.success(DateTimeUtil.DateByDays());
// TopicExchange exchange = new TopicExchange("DevMonitorMsg");
// String exchangeName="DevMonitorMsg";
// rabbitAdmin.declareExchange(exchange);
// rabbitTemplate.convertAndSend(exchangeName, "1369509498032811869", "设备下线");
return ApiRes.success(true);
} }
......
...@@ -195,7 +195,7 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake ...@@ -195,7 +195,7 @@ public class StocktakeServiceImpl extends ServiceImpl<StocktakeMapper, Stocktake
one=list.get(0); one=list.get(0);
} }
//设置num的数量 //设置num的数量
if (ObjectUtil.isNull(one)){ if (one != null){
orderNum.setNum(1); orderNum.setNum(1);
orderNumService.save(orderNum); orderNumService.save(orderNum);
return orderNum; return orderNum;
......
...@@ -34,6 +34,9 @@ import lombok.SneakyThrows; ...@@ -34,6 +34,9 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -59,6 +62,12 @@ public class WarehouseWebSocketServer implements WebSocketServerListener { ...@@ -59,6 +62,12 @@ public class WarehouseWebSocketServer implements WebSocketServerListener {
@Resource @Resource
private DeviceRedisCache redisCache; private DeviceRedisCache redisCache;
@Resource
private RabbitTemplate rabbitTemplate;
@Resource
private RabbitAdmin rabbitAdmin;
@Override @Override
public String uri() { public String uri() {
return "/device/ws"; return "/device/ws";
...@@ -89,7 +98,11 @@ public class WarehouseWebSocketServer implements WebSocketServerListener { ...@@ -89,7 +98,11 @@ public class WarehouseWebSocketServer implements WebSocketServerListener {
redisCache.put(orgId, jsonData); redisCache.put(orgId, jsonData);
redisCache.put(channel, orgId); redisCache.put(channel, orgId);
} }
//推送消息到对应组织机构
TopicExchange exchange = new TopicExchange("DevMonitorMsg");
rabbitAdmin.declareExchange(exchange);
String exchangeName="DevMonitorMsg";
rabbitTemplate.convertAndSend(exchangeName, orgId, "设备上线");
protocol.response("true"); protocol.response("true");
} }
catch (Exception e) catch (Exception e)
...@@ -104,7 +117,11 @@ public class WarehouseWebSocketServer implements WebSocketServerListener { ...@@ -104,7 +117,11 @@ public class WarehouseWebSocketServer implements WebSocketServerListener {
String orgId= redisCache.get(channel); String orgId= redisCache.get(channel);
redisCache.remove(channel); redisCache.remove(channel);
redisCache.remove(orgId); redisCache.remove(orgId);
//将消息推到对应组织机构
TopicExchange exchange = new TopicExchange("DevMonitorMsg");
String exchangeName="DevMonitorMsg";
rabbitAdmin.declareExchange(exchange);
rabbitTemplate.convertAndSend(exchangeName, orgId, "设备下线");
WebSocketServerListener.super.onClose(protocol); WebSocketServerListener.super.onClose(protocol);
} }
......
package com.junmp.jyzb.websocket;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.junmp.iot.server.ws.WebSocketServerListener;
import com.junmp.iot.server.ws.impl.DefaultWebSocketServerProtocol;
import com.junmp.junmpProcess.redis.FlowRedisCache;
import com.junmp.jyzb.api.util.WsCabinetReq;
import com.junmp.jyzb.api.util.WsWarehouseReq;
import com.junmp.jyzb.cache.DeviceRedisCache;
import com.junmp.jyzb.cache.OnlineRedisCache;
import com.junmp.jyzb.entity.Cabinet;
import com.junmp.jyzb.entity.CabinetBox;
import com.junmp.jyzb.entity.Temp.OnlineState;
import com.junmp.jyzb.service.CabinetService;
import com.junmp.jyzb.utils.DateTimeUtil;
import com.junmp.v2.ws.api.enums.ClientMsgType;
import com.junmp.v2.ws.api.enums.ServerMsgType;
import com.junmp.v2.ws.api.enums.SysMsgTypeEnum;
import com.junmp.v2.ws.api.message.WsCallbackApi;
import com.junmp.v2.ws.api.session.bean.WsSession;
import com.junmp.v2.ws.bean.WsMsgDto;
import com.junmp.v2.ws.channel.WsSessionContainer;
import com.junmp.v2.ws.message.WsMessageHandle;
import com.junmp.v2.ws.session.WsSessionHandle;
import io.jsonwebtoken.JwtException;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Component
@Slf4j
public class WarehouseWebSocketServer implements WebSocketServerListener {
// private static final Logger log = LoggerFactory.getLogger(com.junmp.v2.ws.server.ScreenWebSocketServer.class);
@Resource
public CabinetService cabinetService;
@Resource
private DeviceRedisCache redisCache;
@Override
public String uri() {
return "/device/ws";
}
@SneakyThrows
@Override
public void onText(DefaultWebSocketServerProtocol protocol) {
try {
String text = protocol.readText();
ObjectMapper objectMapper = new ObjectMapper();
WsWarehouseReq deviceData = objectMapper.readValue(text, WsWarehouseReq.class);
String orgId = deviceData.getOrgId();
deviceData.getOrgId();
if(redisExist!=null)//已有存在数据
{
String jsonData = objectMapper.writeValueAsString(deviceData);
if(redisExist!=null)//已有存在数据
{
String jsonData = objectMapper.writeValueAsString(deviceData);
redisCache.put(orgId, jsonData);
}
else
{
String channel = protocol.requestMessage().getChannelId();
String jsonData = objectMapper.writeValueAsString(deviceData);
redisCache.put(orgId, jsonData);
redisCache.put(channel, orgId);
}
protocol.response("true");
}
catch (Exception e)
{
protocol.response("false");
}
}
@Override
public void onClose(DefaultWebSocketServerProtocol protocol) {
String channel= protocol.requestMessage().getChannelId();
String orgId= redisCache.get(channel);
redisCache.remove(channel);
redisCache.remove(orgId);
WebSocketServerListener.super.onClose(protocol);
}
@Override
public void onBinary(DefaultWebSocketServerProtocol protocol) {
WebSocketServerListener.super.onBinary(protocol);
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论