Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
SanyCoating
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
蔡楷
SanyCoating
Commits
99e4a099
Commit
99e4a099
authored
Jan 19, 2022
by
黄强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解析json 模板比你且複製,還差變量替換
parent
92620284
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
66 行增加
和
30 行删除
+66
-30
mqttservice/src/main/java/com/jln/system/web/action/mqtt/Base64decrypt.java
+16
-6
mqttservice/src/main/java/com/jln/system/web/action/mqtt/controller/MqttClientController.java
+13
-4
mqttservice/src/main/java/com/jln/system/web/action/mqtt/init/InitHander.java
+9
-5
mqttservice/src/main/java/com/jln/system/web/action/mqtt/server/impl/SendMqttServerImpl.java
+2
-3
mqttservice/src/main/java/com/jln/system/web/action/mqtt/util/FlieUrlUtil.java
+24
-10
system/src/main/java/com/jln/system/Application.java
+2
-2
没有找到文件。
mqttservice/src/main/java/com/jln/system/web/action/mqtt/Base64decrypt.java
查看文件 @
99e4a099
...
...
@@ -49,7 +49,14 @@ public class Base64decrypt {
));
List
<
JSONObject
>
objectList
=
mongoTemplate
.
find
(
query
,
JSONObject
.
class
,
entry
.
getKey
()+
yearMonth
);
//mongdb最新数据时间
Long
time
=
Long
.
valueOf
(
objectList
.
get
(
0
).
toJavaObject
(
Map
.
class
).
get
(
"time"
).
toString
());
Map
<
String
,
Object
>
map1
=
objectList
.
get
(
0
).
toJavaObject
(
Map
.
class
);
Set
<
Map
.
Entry
<
String
,
Object
>>
entries
=
entry
.
getValue
().
entrySet
();
//key 是 数据库字段,value 是iot
//处理上报的字段
Long
time
=
Long
.
valueOf
(
map1
.
get
(
"time"
).
toString
());
//当前时间
long
millis
=
Calendar
.
getInstance
().
getTimeInMillis
();
//如果当前时间-最新上报数据的时间<设置关机范围,那么直接给
...
...
@@ -62,11 +69,14 @@ public class Base64decrypt {
map
=
jsonObject
.
toJavaObject
(
Map
.
class
);
}
}
for
(
Map
.
Entry
<
String
,
Object
>
fields
:
entry
.
getValue
().
entrySet
()){
//
boolean
contains
=
map
.
containsKey
(
fields
.
getKey
());
if
(
contains
){
Object
valeDb
=
map
.
get
(
fields
.
getKey
());
map
.
remove
(
fields
.
getKey
())
;
map
.
put
(
fields
.
getValue
().
toString
(),
valeDb
);
}
}
}
...
...
mqttservice/src/main/java/com/jln/system/web/action/mqtt/controller/MqttClientController.java
查看文件 @
99e4a099
...
...
@@ -5,14 +5,20 @@ import com.jln.common.RedisUtil.RedisUtil;
import
com.jln.common.annotation.IgnoreUserLoginToken
;
import
com.jln.common.entity.Result
;
import
com.jln.system.web.action.mqtt.MqttStartClient
;
import
com.jln.system.web.action.mqtt.init.InitHander
;
import
com.jln.system.web.action.mqtt.mapper.ScadaBiMapper
;
import
com.jln.system.web.action.mqtt.mapper.ScadaTxsbMapper
;
import
com.jln.system.web.action.mqtt.pojo.dto.JsonDataDto
;
import
com.jln.system.web.action.mqtt.pojo.vo.StaticData
;
import
com.jln.system.web.action.mqtt.server.SendMqttServer
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
@RestController
...
...
@@ -31,13 +37,16 @@ public class MqttClientController {
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
SendMqttServer
sendMqttServer
;
@ApiOperation
(
value
=
"mqtt连接发布订阅"
,
notes
=
"mqtt连接发布订阅"
)
@PostMapping
(
"/start
"
)
@PostMapping
(
value
=
"/start"
,
consumes
=
"multipart/*"
,
headers
=
"content-type=multipart/form-data
"
)
@IgnoreUserLoginToken
public
Result
start
()
{
public
Result
start
(
@RequestParam
MultipartFile
file
)
throws
IOException
{
InitHander
initHander
=
new
InitHander
();
List
<
JsonDataDto
>
jsonDataDtoList
=
initHander
.
analysisJsonParm
(
file
);
sendMqttServer
.
sendMqtt
(
jsonDataDtoList
);
/* List<BldzCclmVo> xpjVos = scadaMapper.find("校平机");
HashMap<String, String> xpjMap = new HashMap<>();
...
...
mqttservice/src/main/java/com/jln/system/web/action/mqtt/init/InitHander.java
查看文件 @
99e4a099
...
...
@@ -4,17 +4,20 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.jln.system.web.action.mqtt.pojo.dto.JsonDataDto
;
import
com.jln.system.web.action.mqtt.server.SendMqttServer
;
import
com.jln.system.web.action.mqtt.util.FlieUrlUtil
;
import
com.sun.org.apache.bcel.internal.generic.NEW
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
//
@Component
public
class
InitHander
implements
CommandLineRunner
{
@Autowired
...
...
@@ -23,13 +26,14 @@ public class InitHander implements CommandLineRunner {
@Override
public
void
run
(
String
...
args
){
List
<
JsonDataDto
>
jsonDataDtoList
=
analysisJsonParm
();
sendMqttServer
.
sendMqtt
(
jsonDataDtoList
);
//
List<JsonDataDto> jsonDataDtoList = analysisJsonParm();
//
sendMqttServer.sendMqtt(jsonDataDtoList);
}
public
List
<
JsonDataDto
>
analysisJsonParm
(
)
{
public
List
<
JsonDataDto
>
analysisJsonParm
(
MultipartFile
file
)
throws
IOException
{
String
jsonStr
=
strJson
();
//模拟数据
String
jsonStr
=
FlieUrlUtil
.
readJsonField
(
file
);
//String jsonStr = strJson();//模拟数据
List
<
JsonDataDto
>
jsonDataDtoList
=
new
ArrayList
<>();
...
...
mqttservice/src/main/java/com/jln/system/web/action/mqtt/server/impl/SendMqttServerImpl.java
查看文件 @
99e4a099
...
...
@@ -12,7 +12,6 @@ import com.jln.system.web.action.mqtt.server.SendMqttServer;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.stereotype.Service
;
import
java.io.*
;
...
...
@@ -89,7 +88,7 @@ public class SendMqttServerImpl implements SendMqttServer {
public
void
sendMqtt
(
List
<
JsonDataDto
>
dtoList
)
{
// //解析sk文件
// String skFileValue = readSkFileToList(commonSk);
/*
MqttStartClient mq = new MqttStartClient();
MqttStartClient
mq
=
new
MqttStartClient
();
String
skFileValue
=
mq
.
readSkFileToList
(
commonSk
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
skFileValue
);
Map
<
String
,
String
>
configParams
=
new
HashMap
<>();
...
...
@@ -105,7 +104,7 @@ public class SendMqttServerImpl implements SendMqttServer {
String
topic
=
"$SANY/gateway/pdev/sany/mdc/"
+
jsonObject
.
getString
(
"accessKey"
)
+
"/data"
;
configParams
.
put
(
MqttEnum
.
MQTT_TOPIC
.
getMqttName
(),
topic
);
XBMqttDataUtil xbMqttDataUtil = new XBMqttDataUtil(configParams);
*/
XBMqttDataUtil
xbMqttDataUtil
=
new
XBMqttDataUtil
(
configParams
);
// TODO 动臂斗杆底漆喷涂机器人1
new
Thread
(
new
Runnable
()
{
...
...
mqttservice/src/main/java/com/jln/system/web/action/mqtt/util/FlieUrlUtil.java
查看文件 @
99e4a099
package
com
.
jln
.
system
.
web
.
action
.
mqtt
.
util
;
import
com.jln.system.web.action.mqtt.MqttStartClient
;
import
javafx.application.Application
;
import
org.apache.coyote.Request
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.SpringApplication
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.nio.file.Path
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.*
;
public
class
FlieUrlUtil
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FlieUrlUtil
.
class
);
...
...
@@ -51,4 +43,26 @@ public class FlieUrlUtil {
// System.out.println(path);
}
public
static
String
readJsonField
(
MultipartFile
file
)
throws
IOException
{
long
startTime
=
System
.
currentTimeMillis
();
//获取开始时间
InputStream
filestream
=
file
.
getInputStream
();
// FileInputStream filestream=new FileInputStream(fileAllPath);
/*byte[] b = new byte[3];
filestream.read(b);
String ecode="gbk";
if (b[0] == -17 && b[1] == -69 && b[2] == -65){
ecode="utf-8";
}*/
InputStreamReader
readStream
=
new
InputStreamReader
(
filestream
);
BufferedReader
reader
=
new
BufferedReader
(
readStream
);
String
s
;
StringBuffer
sbStr
=
new
StringBuffer
();
while
((
s
=
reader
.
readLine
())
!=
null
){
sbStr
.
append
(
s
+
"\n"
);
}
reader
.
close
();
return
sbStr
.
toString
();
}
}
system/src/main/java/com/jln/system/Application.java
查看文件 @
99e4a099
...
...
@@ -29,7 +29,7 @@ public class Application {
SpringApplication
.
run
(
Application
.
class
,
args
);
}
@Bean
/*
@Bean
public FilterRegistrationBean httpServletRequestReplacedRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setFilter(new HttpServletRequestReplacedFilter());
...
...
@@ -39,5 +39,5 @@ public class Application {
registration.setOrder(1);
return registration;
}
*/
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论