Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
T
topology
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
姜立玮
topology
Commits
e33b846a
提交
e33b846a
authored
4 年前
作者:
jianglw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改部分功能
上级
36bb9350
变更
51
隐藏空白字符变更
内嵌
并排
正在显示
51 个修改的文件
包含
1373 行增加
和
120 行删除
+1373
-120
RuoYiApplication.java
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
+2
-0
ImagesController.java
...a/com/ruoyi/web/controller/topology/ImagesController.java
+65
-0
IndexController.java
...va/com/ruoyi/web/controller/topology/IndexController.java
+4
-2
ParamsController.java
...a/com/ruoyi/web/controller/topology/ParamsController.java
+14
-19
application-druid1.yml
ruoyi-admin/src/main/resources/application-druid1.yml
+78
-0
application.yml
ruoyi-admin/src/main/resources/application.yml
+5
-2
pom.xml
ruoyi-common/pom.xml
+22
-0
Constants.java
...on/src/main/java/com/ruoyi/common/constant/Constants.java
+5
-1
Image.java
...ain/java/com/ruoyi/common/core/domain/topology/Image.java
+27
-0
AssembleData.java
...n/java/com/ruoyi/common/topology/change/AssembleData.java
+1
-0
ChangeSub.java
...main/java/com/ruoyi/common/topology/change/ChangeSub.java
+1
-0
Handle.java
...rc/main/java/com/ruoyi/common/topology/change/Handle.java
+1
-0
PointAndData.java
...n/java/com/ruoyi/common/topology/change/PointAndData.java
+34
-15
DataParam.java
.../java/com/ruoyi/common/topology/handletype/DataParam.java
+58
-38
DefaultParam.java
...va/com/ruoyi/common/topology/handletype/DefaultParam.java
+8
-2
DoParam.java
...in/java/com/ruoyi/common/topology/handletype/DoParam.java
+13
-6
NodeLineParamsInt.java
...m/ruoyi/common/topology/handletype/NodeLineParamsInt.java
+10
-1
Mutual.java
...rc/main/java/com/ruoyi/common/topology/mutual/Mutual.java
+73
-0
JexlUtils.java
...ommon/src/main/java/com/ruoyi/common/utils/JexlUtils.java
+24
-0
MimeTypeUtils.java
.../main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
+2
-2
MyAuthenticationProvider.java
.../com/ruoyi/framework/config/MyAuthenticationProvider.java
+61
-0
MyBatisConfig.java
...c/main/java/com/ruoyi/framework/config/MyBatisConfig.java
+1
-1
MybatisPlusConfig.java
...in/java/com/ruoyi/framework/config/MybatisPlusConfig.java
+63
-0
ResourcesConfig.java
...main/java/com/ruoyi/framework/config/ResourcesConfig.java
+12
-1
SqlFilterArgumentResolver.java
.../framework/config/resolver/SqlFilterArgumentResolver.java
+97
-0
DynamicDataSourceAutoConfiguration.java
...mework/datasource/DynamicDataSourceAutoConfiguration.java
+53
-0
EnableDynamicDataSource.java
...mework/datasource/annotation/EnableDynamicDataSource.java
+37
-0
DataSourceProperties.java
...oyi/framework/datasource/config/DataSourceProperties.java
+56
-0
JdbcDynamicDataSourceProvider.java
...work/datasource/config/JdbcDynamicDataSourceProvider.java
+88
-0
LastParamDsProcessor.java
...oyi/framework/datasource/config/LastParamDsProcessor.java
+58
-0
DataSourceConstants.java
...oyi/framework/datasource/support/DataSourceConstants.java
+57
-0
PublicInterface.java
...java/com/ruoyi/framework/publicinter/PublicInterface.java
+60
-0
RyTask.java
...mework/src/main/java/com/ruoyi/framework/task/RyTask.java
+27
-14
TopologyTask.java
.../src/main/java/com/ruoyi/framework/task/TopologyTask.java
+2
-2
CollectTopologyType.java
...ruoyi/framework/topology/collect/CollectTopologyType.java
+4
-1
InfluxdbType.java
...va/com/ruoyi/framework/topology/collect/InfluxdbType.java
+24
-0
MysqlType.java
.../java/com/ruoyi/framework/topology/collect/MysqlType.java
+10
-0
OracleType.java
...java/com/ruoyi/framework/topology/collect/OracleType.java
+10
-0
RedisType.java
.../java/com/ruoyi/framework/topology/collect/RedisType.java
+21
-1
ShareServerType.java
...com/ruoyi/framework/topology/collect/ShareServerType.java
+53
-0
CollectTopology.java
...a/com/ruoyi/framework/topology/emnus/CollectTopology.java
+1
-1
WebSocketServer.java
...n/java/com/ruoyi/framework/websocket/WebSocketServer.java
+26
-11
DBMapper.java
...tem/src/main/java/com/ruoyi/topology/mapper/DBMapper.java
+5
-0
ImagesMapper.java
...src/main/java/com/ruoyi/topology/mapper/ImagesMapper.java
+18
-0
ITopologyService.java
...ain/java/com/ruoyi/topology/service/ITopologyService.java
+2
-0
IimagesService.java
.../main/java/com/ruoyi/topology/service/IimagesService.java
+16
-0
ImagesServiceImpl.java
...va/com/ruoyi/topology/service/impl/ImagesServiceImpl.java
+34
-0
MysqlServiceImpl.java
...ava/com/ruoyi/topology/service/impl/MysqlServiceImpl.java
+4
-0
OracleServiceImpl.java
...va/com/ruoyi/topology/service/impl/OracleServiceImpl.java
+4
-0
TopologyService.java
...java/com/ruoyi/topology/service/impl/TopologyService.java
+7
-0
ImagesMapper.xml
...ystem/src/main/resources/mapper/topology/ImagesMapper.xml
+15
-0
没有找到文件。
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
浏览文件 @
e33b846a
package
com
.
ruoyi
;
package
com
.
ruoyi
;
import
com.ruoyi.framework.datasource.annotation.EnableDynamicDataSource
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
...
@@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
...
@@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi
* @author ruoyi
*/
*/
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
@EnableDynamicDataSource
public
class
RuoYiApplication
public
class
RuoYiApplication
{
{
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
...
...
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/topology/ImagesController.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
web
.
controller
.
topology
;
import
com.ruoyi.common.config.RuoYiConfig
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.utils.file.FileUploadUtils
;
import
com.ruoyi.topology.service.IimagesService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/17 8:51
*/
@RestController
@Slf4j
@RequestMapping
(
"/images"
)
public
class
ImagesController
{
@Autowired
private
IimagesService
iimagesService
;
/**
* 上传图片
* @param file
* @return
* @throws IOException
*/
@RequestMapping
(
"/upload"
)
public
AjaxResult
upload
(
@RequestParam
(
"imgFile"
)
MultipartFile
file
)
throws
IOException
{
if
(!
file
.
isEmpty
())
{
String
img
=
FileUploadUtils
.
upload
(
RuoYiConfig
.
getProfile
()+
Constants
.
IMG_PATH
,
file
);
if
(
iimagesService
.
addImages
(
img
)>
0
){
return
AjaxResult
.
success
();
}
}
return
AjaxResult
.
error
(
"图片不存在,请检查文件是否正确"
);
}
/**
* 获取图片
* @return
*/
@RequestMapping
(
"/list"
)
public
AjaxResult
list
(){
return
AjaxResult
.
success
(
iimagesService
.
getImages
());
}
/**
* 删除图片
* @param id
* @return
*/
@DeleteMapping
(
"/delete/{id}"
)
public
AjaxResult
delete
(
@PathVariable
(
"id"
)
Integer
id
){
if
(
iimagesService
.
deleteImages
(
id
)>
0
){
return
AjaxResult
.
success
();
}
return
AjaxResult
.
error
(
"删除图片失败"
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/topology/IndexController.java
浏览文件 @
e33b846a
...
@@ -106,14 +106,16 @@ public class IndexController extends BaseController {
...
@@ -106,14 +106,16 @@ public class IndexController extends BaseController {
stringRedisTemplate
.
opsForValue
().
set
(
Constants
.
TOPOLOGY_DATA
+
id
,
jsonObject
.
toJSONString
()
);
stringRedisTemplate
.
opsForValue
().
set
(
Constants
.
TOPOLOGY_DATA
+
id
,
jsonObject
.
toJSONString
()
);
return
AjaxResult
.
success
();
return
AjaxResult
.
success
();
}
}
@GetMapping
(
"/test"
)
@PostMapping
(
"/test"
)
public
void
test
()
throws
IOException
{
public
void
test
(
@RequestBody
String
data
)
throws
IOException
{
System
.
out
.
println
(
data
);
// JSONObject jsonObject= JSON.parseObject( "{\n" +
// JSONObject jsonObject= JSON.parseObject( "{\n" +
// " tag: 'numA', //tag节点\n" +
// " tag: 'numA', //tag节点\n" +
// " fontColor: 'red', //数据颜色\n" +
// " fontColor: 'red', //数据颜色\n" +
// " text: 'test', //文本内容\n" +
// " text: 'test', //文本内容\n" +
// " }" );
// " }" );
// webSocketServer.sendInfo(jsonObject.toJSONString() ,"1" );
// webSocketServer.sendInfo(jsonObject.toJSONString() ,"1" );
iTopologyService
.
ces
();
System
.
out
.
println
(
"他请求成功了"
);
System
.
out
.
println
(
"他请求成功了"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/topology/ParamsController.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
web
.
controller
.
topology
;
package
com
.
ruoyi
.
web
.
controller
.
topology
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.
common.utils.sign.RsaUtils
;
import
com.ruoyi.
framework.publicinter.PublicInterface
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* 组态公共调用方法
* 组态公共调用方法
...
@@ -19,32 +19,27 @@ import org.springframework.web.bind.annotation.*;
...
@@ -19,32 +19,27 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping
(
"/params"
)
@RequestMapping
(
"/params"
)
@Slf4j
@Slf4j
public
class
ParamsController
{
public
class
ParamsController
{
@Autowired
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
private
PublicInterface
publicInterface
;
/**
/**
*
*
* @param id
* @param id
* @param
t
ag
* @param
setterT
ag
* @param
fun
* @param
setteeTag
* @return
* @return
*/
*/
@GetMapping
(
"/show"
)
@GetMapping
(
"/show"
)
public
AjaxResult
show
(
@RequestParam
(
value
=
"id"
)
String
id
,
public
AjaxResult
show
(
@RequestParam
(
value
=
"id"
)
String
id
,
@RequestParam
(
value
=
"tag"
)
String
tag
,
@RequestParam
(
value
=
"setterTag"
)
String
setterTag
,
@RequestParam
(
value
=
"fun"
)
String
fun
){
@RequestParam
(
value
=
"setteeTag"
)
String
setteeTag
)
{
Integer
ids
;
try
{
try
{
ids
=
Integer
.
parseInt
(
RsaUtils
.
encryptByPrivateKey
(
id
)
);
return
publicInterface
.
publicMethod
(
id
,
setterTag
,
setteeTag
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getLocalizedMessage
());
e
.
printStackTrace
();
e
.
printStackTrace
();
return
AjaxResult
.
error
(
"id解析失败"
);
}
}
String
value
=
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
TOPOLOGY_DATA
+
ids
);
return
AjaxResult
.
error
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
value
);
JSONObject
topologyHandle
=
jsonObject
.
getJSONObject
(
"topologyHandle"
);
Integer
dataAcquisition
=
topologyHandle
.
getInteger
(
"dataAcquisitionMode"
);
return
AjaxResult
.
success
();
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/resources/application-druid1.yml
0 → 100644
浏览文件 @
e33b846a
# 数据源配置
spring
:
autoconfigure
:
#自动化配置 例外处理
exclude
:
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
dynamic
:
datasource
:
# 主库数据源
master
:
url
:
jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
password
:
root
driverClassName
:
com.mysql.cj.jdbc.Driver
# 从库数据源
slave
:
# 从数据源开关/默认关闭
enabled
:
false
url
:
username
:
password
:
driverClassName
:
# 从库数据源
mysql
:
# 从数据源开关/默认关闭
enabled
:
true
url
:
jdbc:mysql://localhost:3306/d5000?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username
:
root
password
:
root
driverClassName
:
com.mysql.cj.jdbc.Driver
oracle
:
# 从数据源开关/默认关闭
enabled
:
true
url
:
jdbc:oracle:thin:@221.180.252.34:1521:xe
username
:
scott
password
:
scott
driverClassName
:
oracle.jdbc.driver.OracleDriver
druid
:
# 初始连接数
initialSize
:
5
# 最小连接池数量
minIdle
:
10
# 最大连接池数量
maxActive
:
20
# 配置获取连接等待超时的时间
maxWait
:
60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis
:
60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis
:
300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis
:
900000
# 配置检测连接是否有效
validationQuery
:
SELECT 1 FROM DUAL
testWhileIdle
:
true
testOnBorrow
:
false
testOnReturn
:
false
webStatFilter
:
enabled
:
true
statViewServlet
:
enabled
:
true
# 设置白名单,不填则允许所有访问
allow
:
url-pattern
:
/druid/*
# 控制台管理用户名和密码
login-username
:
login-password
:
filter
:
stat
:
enabled
:
true
# 慢SQL记录
log-slow-sql
:
true
slow-sql-millis
:
1000
merge-sql
:
true
wall
:
config
:
multi-statement-allow
:
true
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/resources/application.yml
浏览文件 @
e33b846a
...
@@ -35,7 +35,10 @@ logging:
...
@@ -35,7 +35,10 @@ logging:
level
:
level
:
com.ruoyi
:
debug
com.ruoyi
:
debug
org.springframework
:
warn
org.springframework
:
warn
#加密
jasypt
:
encryptor
:
password
:
hrhx
# Spring配置
# Spring配置
spring
:
spring
:
# 资源信息
# 资源信息
...
@@ -100,7 +103,7 @@ token:
...
@@ -100,7 +103,7 @@ token:
expireTime
:
10080
expireTime
:
10080
# MyBatis配置
# MyBatis配置
mybatis
:
mybatis
-plus
:
# 搜索指定包别名
# 搜索指定包别名
typeAliasesPackage
:
com.ruoyi.**.domain
typeAliasesPackage
:
com.ruoyi.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件
# 配置mapper的扫描,找到所有的mapper.xml映射文件
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/pom.xml
浏览文件 @
e33b846a
...
@@ -140,6 +140,28 @@
...
@@ -140,6 +140,28 @@
<artifactId>
influxdb-client-java
</artifactId>
<artifactId>
influxdb-client-java
</artifactId>
<version>
1.8.0
</version>
<version>
1.8.0
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-jexl3
</artifactId>
<version>
3.1
</version>
</dependency>
<!-- mybatis-plus-->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.4.2
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
dynamic-datasource-spring-boot-starter
</artifactId>
<version>
3.3.6
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jasypt/jasypt -->
<dependency>
<groupId>
com.github.ulisesbocchio
</groupId>
<artifactId>
jasypt-spring-boot-starter
</artifactId>
<version>
2.1.0
</version>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repositories>
<repository>
<repository>
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
浏览文件 @
e33b846a
...
@@ -126,6 +126,10 @@ public class Constants
...
@@ -126,6 +126,10 @@ public class Constants
* 资源映射路径 前缀
* 资源映射路径 前缀
*/
*/
public
static
final
String
RESOURCE_PREFIX
=
"/profile"
;
public
static
final
String
RESOURCE_PREFIX
=
"/profile"
;
/**
* 组态数据前缀
*/
public
static
final
String
TOPOLOGY_DATA
=
"topology_data:"
;
public
static
final
String
TOPOLOGY_DATA
=
"topology_data:"
;
public
static
final
String
IMG_PATH
=
"/img"
;
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/topology/Image.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
core
.
domain
.
topology
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/17 10:04
*/
public
class
Image
{
private
Integer
id
;
private
String
url
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/change/AssembleData.java
浏览文件 @
e33b846a
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* 将数据赋值给组态各节点参数
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/6/1 17:38
* @date 2021/6/1 17:38
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/change/ChangeSub.java
浏览文件 @
e33b846a
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 改变参数
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/4/16 10:28
* @date 2021/4/16 10:28
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/change/Handle.java
浏览文件 @
e33b846a
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
...
@@ -3,6 +3,7 @@ package com.ruoyi.common.topology.change;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 赋值处理类
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/4/10 11:09
* @date 2021/4/10 11:09
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/change/PointAndData.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
topology
.
change
;
package
com
.
ruoyi
.
common
.
topology
.
change
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.enums.NodeLineParams
;
import
com.ruoyi.common.enums.NodeLineParams
;
import
com.ruoyi.common.topology.handletype.NodeLineParamsInt
;
import
com.ruoyi.common.topology.handletype.NodeLineParamsInt
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -15,37 +20,51 @@ import java.util.Map;
...
@@ -15,37 +20,51 @@ import java.util.Map;
* @date 2021/4/26 9:41
* @date 2021/4/26 9:41
*/
*/
public
class
PointAndData
{
public
class
PointAndData
{
/**
/**
* 组装数据
* 组装数据
* @param map
* @param map
* @param jsonArray
* @param jsonArray
* @param id
* @return
* @return
*/
*/
public
static
List
<
Map
<
String
,
Object
>>
assemble
(
Map
<
String
,
Object
>
map
,
JSONArray
jsonArray
){
public
static
List
<
Map
<
String
,
Object
>>
assemble
(
Map
<
String
,
Object
>
map
,
JSONArray
jsonArray
,
String
id
){
List
<
ChangeSub
>
list
=
jsonArray
.
toJavaList
(
ChangeSub
.
class
);
List
<
ChangeSub
>
list
=
jsonArray
.
toJavaList
(
ChangeSub
.
class
);
List
<
Map
<
String
,
Object
>>
list1
=
new
LinkedList
<>(
);
List
<
Map
<
String
,
Object
>>
list1
=
new
LinkedList
<>(
);
for
(
ChangeSub
changeSub:
list
){
for
(
ChangeSub
changeSub:
list
){
List
<
Handle
>
handleList
=
changeSub
.
getHandle
();
List
<
Handle
>
handleList
=
changeSub
.
getHandle
();
list1
.
add
(
handle
(
map
,
handleList
,
changeSub
.
getTag
(),
changeSub
.
getEcharts
()
)
);
list1
.
add
(
handle
(
map
,
handleList
,
changeSub
.
getTag
(),
changeSub
.
getEcharts
()
,
id
)
);
}
}
return
list1
;
return
list1
;
}
}
private
static
Map
<
String
,
Object
>
handle
(
Map
<
String
,
Object
>
map
,
List
<
Handle
>
list
,
String
tag
,
String
echarts
){
/**
*
* @param map
* @param list
* @param tag
* @param echarts
* @param id
* @return
*/
private
static
Map
<
String
,
Object
>
handle
(
Map
<
String
,
Object
>
map
,
List
<
Handle
>
list
,
String
tag
,
String
echarts
,
String
id
){
//存储map
Map
<
String
,
Object
>
map1
=
new
HashMap
<>(
);
Map
<
String
,
Object
>
map1
=
new
HashMap
<>(
);
Map
<
String
,
Object
>
map2
=
null
;
List
<
Map
<
String
,
Object
>>
list1
=
null
;
for
(
Handle
handle:
list
){
for
(
Handle
handle:
list
){
NodeLineParamsInt
nodeLineParamsInt
=
NodeLineParams
.
match
(
handle
.
getType
()
);
NodeLineParamsInt
nodeLineParamsInt
=
NodeLineParams
.
match
(
handle
.
getType
()
);
nodeLineParamsInt
.
getDataToParams
(
handle
,
map
,
map1
,
echarts
);
nodeLineParamsInt
.
getDataToParams
(
handle
,
map
,
map1
,
echarts
,
id
);
// if(handle.getType().equals( "do" )){
}
// map2=new HashMap<>( );
if
(
StringUtils
.
isNotBlank
(
echarts
)){
// list1=new LinkedList<>( );
StringRedisTemplate
stringRedisTemplate
=
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
);
// map2.put( handle.getType(),AssembleData.getData( handle,map) );
JSONObject
jsonObject2
=
JSONObject
.
parseObject
(
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
TOPOLOGY_DATA
+
id
));
// list1.add( map2 );
JSONArray
change
=
jsonObject2
.
getJSONObject
(
"topologyHandle"
).
getJSONArray
(
"change"
);
// map1.put( "actions", list1);
for
(
int
i
=
0
;
i
<
change
.
size
();
i
++){
// }else{
if
(
tag
.
equals
(
change
.
getJSONObject
(
i
).
getString
(
"tag"
)
)){
// map1.put( handle.getType(),AssembleData.getData(handle,map) );
change
.
getJSONObject
(
i
).
put
(
"echarts"
,
JSONObject
.
parseObject
(
map1
.
get
(
"data"
).
toString
()
).
get
(
"echarts"
)
);
// }
}
}
jsonObject2
.
getJSONObject
(
"topologyHandle"
).
put
(
"change"
,
change
);
stringRedisTemplate
.
opsForValue
().
set
(
Constants
.
TOPOLOGY_DATA
+
id
,
jsonObject2
.
toJSONString
()
);
}
}
map1
.
put
(
"tag"
,
tag
);
map1
.
put
(
"tag"
,
tag
);
return
map1
;
return
map1
;
...
...
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/handletype/DataParam.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
topology
.
handletype
;
package
com
.
ruoyi
.
common
.
topology
.
handletype
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.EchartsSet
;
import
com.ruoyi.common.topology.change.EchartsSet
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -16,63 +18,81 @@ import java.util.Map;
...
@@ -16,63 +18,81 @@ import java.util.Map;
/**
/**
* 组装echarts数据
* 组装echarts数据
*
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/6/1 17:26
* @date 2021/6/1 17:26
*/
*/
@Slf4j
@Slf4j
public
class
DataParam
implements
NodeLineParamsInt
{
public
class
DataParam
implements
NodeLineParamsInt
{
@Override
@Override
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
)
{
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
,
String
id
)
{
//判断是否为自定义图表
//判断是否为自定义图表
if
(!
handle
.
getCustomChart
()){
if
(!
handle
.
getCustomChart
())
{
map1
.
put
(
handle
.
getType
(),
AssembleData
.
getData
(
handle
,
map
));
map1
.
put
(
handle
.
getType
(),
AssembleData
.
getData
(
handle
,
map
)
);
}
else
{
}
else
{
if
(
StringUtils
.
isNotBlank
(
echarts
)){
if
(
StringUtils
.
isNotBlank
(
echarts
))
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
echarts
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
echarts
);
JSONObject
jsonObject1
=
JSONObject
.
parseObject
(
echarts
).
getJSONObject
(
"option"
);
JSONObject
jsonObject1
=
JSONObject
.
parseObject
(
echarts
).
getJSONObject
(
"option"
);
jsonObject1
.
getJSONObject
(
"title"
).
put
(
"text"
,
handle
.
getTitle
()
);
//组合title
List
<
String
>
list
=
new
LinkedList
<>();
jsonObject1
.
getJSONObject
(
"title"
).
put
(
"text"
,
handle
.
getTitle
()
);
List
<
String
>
xList
=
new
LinkedList
<>();
List
<
String
>
list
=
new
LinkedList
<>();
List
<
Map
<
String
,
Object
>>
seriesList
=
new
LinkedList
<>();
List
<
String
>
xList
=
new
LinkedList
<>();
Map
<
String
,
Object
>
map2
=
null
;
List
<
Map
<
String
,
Object
>>
seriesList
=
new
LinkedList
<>();
for
(
EchartsSet
echartsSet:
handle
.
getEchartsArray
()){
Map
<
String
,
Object
>
map2
=
null
;
if
(
echartsSet
.
getAxis
().
equals
(
"yAxis"
)){
//组合y轴及x轴
map2
=
new
HashMap
<>();
for
(
EchartsSet
echartsSet
:
handle
.
getEchartsArray
())
{
map2
.
put
(
"name"
,
echartsSet
.
getName
()
);
if
(
echartsSet
.
getAxis
().
equals
(
"yAxis"
))
{
map2
.
put
(
"type"
,
echartsSet
.
getSeriesType
());
map2
=
new
HashMap
<>();
map2
.
put
(
"data"
,
map
.
get
(
echartsSet
.
getPoint
()
)+
""
);
map2
.
put
(
"name"
,
echartsSet
.
getName
()
);
map2
.
put
(
"type"
,
echartsSet
.
getSeriesType
()
);
map2
.
put
(
"data"
,
map
.
get
(
echartsSet
.
getPoint
()
)
+
""
);
seriesList
.
add
(
map2
);
seriesList
.
add
(
map2
);
list
.
add
(
echartsSet
.
getName
()
);
list
.
add
(
echartsSet
.
getName
()
);
}
}
if
(
echartsSet
.
getAxis
().
equals
(
"xAxis"
))
{
if
(
echartsSet
.
getAxis
().
equals
(
"xAxis"
))
{
xList
.
add
(
map
.
get
(
echartsSet
.
getPoint
()
)
+
""
);
xList
.
add
(
map
.
get
(
echartsSet
.
getPoint
()
)
+
""
);
}
}
}
}
JSONArray
jsonArray
=
jsonObject1
.
getJSONArray
(
"series"
);
//组合y轴数据series
if
(
jsonArray
.
size
()==
seriesList
.
size
()){
JSONArray
jsonArray
=
jsonObject1
.
getJSONArray
(
"series"
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++){
// if(jsonArray.size()==seriesList.size()){
for
(
Map
<
String
,
Object
>
m:
seriesList
){
for
(
Map
<
String
,
Object
>
m
:
seriesList
)
{
if
(
jsonArray
.
getJSONObject
(
i
).
getString
(
"name"
).
equals
(
m
.
get
(
"name"
)
)){
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
jsonObject2
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
jsonObject2
=
jsonArray
.
getJSONObject
(
i
);
jsonObject2
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
m
)
);
if
(
m
.
get
(
"name"
).
equals
(
jsonArray
.
getJSONObject
(
i
).
getString
(
"name"
)
))
{
}
jsonObject2
.
getJSONArray
(
"data"
).
add
(
m
.
get
(
"data"
)
);
}
else
{
jsonObject2
.
put
(
"name"
,
m
.
get
(
"name"
)
);
List
<
Object
>
list1
=
new
LinkedList
<>();
list1
.
add
(
m
.
get
(
"data"
)
);
jsonObject2
.
put
(
"data"
,
list1
);
}
}
}
}
}
else
{
jsonArray
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
seriesList
)
);
}
}
jsonObject1
.
getJSONObject
(
"xAxis"
).
put
(
"data"
,
xList
);
jsonObject1
.
getJSONObject
(
"legend"
).
put
(
"data"
,
list
);
if
(
jsonObject1
.
containsKey
(
"legend"
))
{
map1
.
put
(
"data"
,
jsonObject
.
toJSONString
());
jsonObject1
.
getJSONObject
(
"legend"
).
put
(
"data"
,
list
);
}
else
{
jsonObject1
.
getJSONObject
(
"xAxis"
).
getJSONArray
(
"data"
).
add
(
xList
.
get
(
0
)
);
log
.
debug
(
"未获取到组态中的图表信息"
);
}
else
{
jsonObject1
.
put
(
"legend"
,
new
JSONObject
()
);
jsonObject1
.
getJSONObject
(
"legend"
).
put
(
"data"
,
list
);
jsonObject1
.
getJSONObject
(
"xAxis"
).
put
(
"data"
,
xList
);
}
jsonObject1
.
put
(
"series"
,
jsonArray
);
jsonObject
.
put
(
"option"
,
jsonObject1
);
JSONObject
newEcharts
=
new
JSONObject
();
newEcharts
.
put
(
"echarts"
,
jsonObject
);
map1
.
put
(
"data"
,
newEcharts
.
toJSONString
()
);
}
else
{
log
.
debug
(
"未获取到组态中的图表信息"
);
}
}
}
}
//echarts 在canvas上刷新使用
//echarts 在canvas上刷新使用
map1
.
put
(
"elementRendered"
,
false
);
map1
.
put
(
"elementRendered"
,
false
);
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/handletype/DefaultParam.java
浏览文件 @
e33b846a
...
@@ -2,6 +2,7 @@ package com.ruoyi.common.topology.handletype;
...
@@ -2,6 +2,7 @@ package com.ruoyi.common.topology.handletype;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.utils.StringUtils
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -13,7 +14,12 @@ import java.util.Map;
...
@@ -13,7 +14,12 @@ import java.util.Map;
public
class
DefaultParam
implements
NodeLineParamsInt
{
public
class
DefaultParam
implements
NodeLineParamsInt
{
@Override
@Override
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
)
{
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
,
String
id
)
{
map1
.
put
(
handle
.
getType
(),
AssembleData
.
getData
(
handle
,
map
)
);
Object
o
=
AssembleData
.
getData
(
handle
,
map
);
if
(
o
!=
null
){
if
(
StringUtils
.
isNotBlank
(
o
.
toString
()
)){
map1
.
put
(
handle
.
getType
(),
o
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/handletype/DoParam.java
浏览文件 @
e33b846a
...
@@ -2,6 +2,7 @@ package com.ruoyi.common.topology.handletype;
...
@@ -2,6 +2,7 @@ package com.ruoyi.common.topology.handletype;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.AssembleData
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.utils.StringUtils
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -9,6 +10,7 @@ import java.util.List;
...
@@ -9,6 +10,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* 组装动画类
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/6/1 17:26
* @date 2021/6/1 17:26
...
@@ -16,11 +18,16 @@ import java.util.Map;
...
@@ -16,11 +18,16 @@ import java.util.Map;
public
class
DoParam
implements
NodeLineParamsInt
{
public
class
DoParam
implements
NodeLineParamsInt
{
@Override
@Override
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
)
{
public
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
,
String
id
)
{
Map
<
String
,
Object
>
map2
=
new
HashMap
<>(
);
Object
o
=
AssembleData
.
getData
(
handle
,
map
);
List
<
Map
<
String
,
Object
>>
list1
=
new
LinkedList
<>(
);
if
(
o
!=
null
){
map2
.
put
(
handle
.
getType
(),
AssembleData
.
getData
(
handle
,
map
)
);
if
(
StringUtils
.
isNotBlank
(
o
.
toString
()
)){
list1
.
add
(
map2
);
Map
<
String
,
Object
>
map2
=
new
HashMap
<>(
);
map1
.
put
(
"actions"
,
list1
);
List
<
Map
<
String
,
Object
>>
list1
=
new
LinkedList
<>(
);
map2
.
put
(
handle
.
getType
(),
o
);
list1
.
add
(
map2
);
map1
.
put
(
"actions"
,
list1
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/handletype/NodeLineParamsInt.java
浏览文件 @
e33b846a
...
@@ -5,10 +5,19 @@ import com.ruoyi.common.topology.change.Handle;
...
@@ -5,10 +5,19 @@ import com.ruoyi.common.topology.change.Handle;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* node line 参数赋值接口
* @author jianglw
* @author jianglw
* @version 1.0
* @version 1.0
* @date 2021/6/1 17:17
* @date 2021/6/1 17:17
*/
*/
public
interface
NodeLineParamsInt
{
public
interface
NodeLineParamsInt
{
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
);
/**
*
* @param handle 处理参数
* @param map 数据
* @param map1 返回值
* @param echarts echarts值
* @param id topology id
*/
void
getDataToParams
(
Handle
handle
,
Map
<
String
,
Object
>
map
,
Map
<
String
,
Object
>
map1
,
String
echarts
,
String
id
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/topology/mutual/Mutual.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
topology
.
mutual
;
/**
* 交互接口参数类
* @author jianglw
* @version 1.0
* @date 2021/6/7 17:28
*/
public
class
Mutual
{
private
String
setter
;
private
String
settee
;
private
Integer
dataAcquisitionMode
;
private
String
condition
;
private
String
point
;
private
String
shareType
;
private
String
assignment
;
public
String
getShareType
()
{
return
shareType
;
}
public
void
setShareType
(
String
shareType
)
{
this
.
shareType
=
shareType
;
}
public
String
getSetter
()
{
return
setter
;
}
public
void
setSetter
(
String
setter
)
{
this
.
setter
=
setter
;
}
public
String
getSettee
()
{
return
settee
;
}
public
void
setSettee
(
String
settee
)
{
this
.
settee
=
settee
;
}
public
Integer
getDataAcquisitionMode
()
{
return
dataAcquisitionMode
;
}
public
void
setDataAcquisitionMode
(
Integer
dataAcquisitionMode
)
{
this
.
dataAcquisitionMode
=
dataAcquisitionMode
;
}
public
String
getCondition
()
{
return
condition
;
}
public
void
setCondition
(
String
condition
)
{
this
.
condition
=
condition
;
}
public
String
getPoint
()
{
return
point
;
}
public
void
setPoint
(
String
point
)
{
this
.
point
=
point
;
}
public
String
getAssignment
()
{
return
assignment
;
}
public
void
setAssignment
(
String
assignment
)
{
this
.
assignment
=
assignment
;
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/utils/JexlUtils.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
utils
;
import
org.apache.commons.jexl3.JexlBuilder
;
import
org.apache.commons.jexl3.JexlExpression
;
import
org.apache.commons.jexl3.MapContext
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/8 10:34
*/
public
class
JexlUtils
{
public
static
Object
math
(
String
exp
){
JexlBuilder
builder
=
new
JexlBuilder
();
JexlExpression
expression
=
builder
.
create
().
createExpression
(
exp
);
Object
evaluate
=
expression
.
evaluate
(
new
MapContext
()
);
System
.
out
.
println
(
"evaluate "
+
evaluate
.
toString
());
return
evaluate
;
}
public
static
void
main
(
String
[]
args
)
{
JexlUtils
.
math
(
"12.56+33.5"
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
浏览文件 @
e33b846a
...
@@ -17,7 +17,7 @@ public class MimeTypeUtils
...
@@ -17,7 +17,7 @@ public class MimeTypeUtils
public
static
final
String
IMAGE_GIF
=
"image/gif"
;
public
static
final
String
IMAGE_GIF
=
"image/gif"
;
public
static
final
String
[]
IMAGE_EXTENSION
=
{
"bmp"
,
"gif"
,
"jpg"
,
"jpeg"
,
"png"
};
public
static
final
String
[]
IMAGE_EXTENSION
=
{
"bmp"
,
"gif"
,
"jpg"
,
"jpeg"
,
"png"
,
"svg"
};
public
static
final
String
[]
FLASH_EXTENSION
=
{
"swf"
,
"flv"
};
public
static
final
String
[]
FLASH_EXTENSION
=
{
"swf"
,
"flv"
};
...
@@ -32,7 +32,7 @@ public class MimeTypeUtils
...
@@ -32,7 +32,7 @@ public class MimeTypeUtils
// 压缩文件
// 压缩文件
"rar"
,
"zip"
,
"gz"
,
"bz2"
,
"rar"
,
"zip"
,
"gz"
,
"bz2"
,
// pdf
// pdf
"pdf"
};
"pdf"
,
"svg"
};
public
static
String
getExtension
(
String
prefix
)
public
static
String
getExtension
(
String
prefix
)
{
{
...
...
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyAuthenticationProvider.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
config
;
import
com.ruoyi.common.exception.user.UserPasswordNotMatchException
;
import
com.ruoyi.framework.web.service.UserDetailsServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.AuthenticationProvider
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.stereotype.Component
;
@Component
public
class
MyAuthenticationProvider
implements
AuthenticationProvider
{
@Autowired
private
UserDetailsServiceImpl
userDetailsService
;
@Autowired
private
BCryptPasswordEncoder
bCryptPasswordEncoder
;
@Override
public
Authentication
authenticate
(
Authentication
authentication
)
throws
AuthenticationException
,
UserPasswordNotMatchException
{
String
name
=
authentication
.
getName
();
String
password
=(
String
)
authentication
.
getCredentials
();
UserDetails
user
=
userDetailsService
.
loadUserByUsername
(
name
);
String
encoderPassword
=
bCryptPasswordEncoder
.
encode
(
password
);
//查找出账号 想用数据库的校验能通过就通过
if
(
bCryptPasswordEncoder
.
matches
(
password
,
user
.
getPassword
())){
return
new
UsernamePasswordAuthenticationToken
(
name
,
encoderPassword
);
}
int
checkLogin
=
checkLogin
(
name
,
password
);
//外部的账号密码验证接口
if
(
checkLogin
==
2
){
return
new
UsernamePasswordAuthenticationToken
(
name
,
password
);
}
else
{
//如果都登录不了,就返回异常输出
throw
new
UserPasswordNotMatchException
();
}
}
@Override
public
boolean
supports
(
Class
<?>
aClass
)
{
return
false
;
}
/**
* 内网 验证账号密码
* @param userName
* @param pwd
* @return 2 op账号密码验证通过,3 验证不通过
*/
public
static
int
checkLogin
(
String
userName
,
String
pwd
)
{
if
(
userName
.
equals
(
pwd
)){
return
2
;
}
return
3
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
浏览文件 @
e33b846a
...
@@ -29,7 +29,7 @@ import com.ruoyi.common.utils.StringUtils;
...
@@ -29,7 +29,7 @@ import com.ruoyi.common.utils.StringUtils;
*
*
* @author ruoyi
* @author ruoyi
*/
*/
@Configuration
//
@Configuration
public
class
MyBatisConfig
public
class
MyBatisConfig
{
{
@Autowired
@Autowired
...
...
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
config
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
;
import
com.ruoyi.framework.config.resolver.SqlFilterArgumentResolver
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/23 11:14
*/
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
@Configuration
(
proxyBeanMethods
=
false
)
public
class
MybatisPlusConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
()
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
// 分页插件
interceptor
.
addInnerInterceptor
(
paginationInnerInterceptor
()
);
// 乐观锁插件
interceptor
.
addInnerInterceptor
(
optimisticLockerInnerInterceptor
()
);
// 阻断插件
interceptor
.
addInnerInterceptor
(
blockAttackInnerInterceptor
()
);
return
interceptor
;
}
/**
* 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
*/
public
PaginationInnerInterceptor
paginationInnerInterceptor
()
{
PaginationInnerInterceptor
paginationInnerInterceptor
=
new
PaginationInnerInterceptor
();
// 设置数据库类型为mysql
paginationInnerInterceptor
.
setDbType
(
DbType
.
MYSQL
);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInnerInterceptor
.
setMaxLimit
(
-
1L
);
return
paginationInnerInterceptor
;
}
/**
* 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html
*/
public
OptimisticLockerInnerInterceptor
optimisticLockerInnerInterceptor
()
{
return
new
OptimisticLockerInnerInterceptor
();
}
/**
* 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html
*/
public
BlockAttackInnerInterceptor
blockAttackInnerInterceptor
()
{
return
new
BlockAttackInnerInterceptor
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
config
;
package
com
.
ruoyi
.
framework
.
config
;
import
com.ruoyi.framework.config.resolver.SqlFilterArgumentResolver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
import
org.springframework.web.filter.CorsFilter
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
...
@@ -13,6 +15,8 @@ import com.ruoyi.common.config.RuoYiConfig;
...
@@ -13,6 +15,8 @@ import com.ruoyi.common.config.RuoYiConfig;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.framework.interceptor.RepeatSubmitInterceptor
;
import
com.ruoyi.framework.interceptor.RepeatSubmitInterceptor
;
import
java.util.List
;
/**
/**
* 通用配置
* 通用配置
*
*
...
@@ -23,7 +27,14 @@ public class ResourcesConfig implements WebMvcConfigurer
...
@@ -23,7 +27,14 @@ public class ResourcesConfig implements WebMvcConfigurer
{
{
@Autowired
@Autowired
private
RepeatSubmitInterceptor
repeatSubmitInterceptor
;
private
RepeatSubmitInterceptor
repeatSubmitInterceptor
;
/**
* SQL 过滤器避免SQL 注入
* @param argumentResolvers
*/
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
argumentResolvers
.
add
(
new
SqlFilterArgumentResolver
());
}
@Override
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
{
...
...
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/config/resolver/SqlFilterArgumentResolver.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
config
.
resolver
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.ruoyi.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.web.bind.support.WebDataBinderFactory
;
import
org.springframework.web.context.request.NativeWebRequest
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.ModelAndViewContainer
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
/**
* @author lengleng
* @date 2019-06-24
* <p>
* 解决Mybatis Plus Order By SQL注入问题
*/
@Slf4j
public
class
SqlFilterArgumentResolver
implements
HandlerMethodArgumentResolver
{
private
final
static
String
[]
KEYWORDS
=
{
"master"
,
"truncate"
,
"insert"
,
"select"
,
"delete"
,
"update"
,
"declare"
,
"alter"
,
"drop"
,
"sleep"
};
/**
* 判断Controller是否包含page 参数
* @param parameter 参数
* @return 是否过滤
*/
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
parameter
.
getParameterType
().
equals
(
Page
.
class
);
}
/**
* @param parameter 入参集合
* @param mavContainer model 和 view
* @param webRequest web相关
* @param binderFactory 入参解析
* @return 检查后新的page对象
* <p>
* page 只支持查询 GET .如需解析POST获取请求报文体处理
*/
@Override
public
Object
resolveArgument
(
MethodParameter
parameter
,
ModelAndViewContainer
mavContainer
,
NativeWebRequest
webRequest
,
WebDataBinderFactory
binderFactory
)
{
HttpServletRequest
request
=
webRequest
.
getNativeRequest
(
HttpServletRequest
.
class
);
String
[]
ascs
=
request
.
getParameterValues
(
"ascs"
);
String
[]
descs
=
request
.
getParameterValues
(
"descs"
);
String
current
=
request
.
getParameter
(
"current"
);
String
size
=
request
.
getParameter
(
"size"
);
Page
<?>
page
=
new
Page
<>();
if
(
StringUtils
.
isNotBlank
(
current
))
{
page
.
setCurrent
(
Long
.
parseLong
(
current
));
}
if
(
StringUtils
.
isNotBlank
(
size
))
{
page
.
setSize
(
Long
.
parseLong
(
size
));
}
List
<
OrderItem
>
orderItemList
=
new
ArrayList
<>();
Optional
.
ofNullable
(
ascs
).
ifPresent
(
s
->
orderItemList
.
addAll
(
Arrays
.
stream
(
s
).
filter
(
sqlInjectPredicate
()).
map
(
OrderItem:
:
asc
).
collect
(
Collectors
.
toList
())));
Optional
.
ofNullable
(
descs
).
ifPresent
(
s
->
orderItemList
.
addAll
(
Arrays
.
stream
(
s
).
filter
(
sqlInjectPredicate
()).
map
(
OrderItem:
:
desc
).
collect
(
Collectors
.
toList
())));
page
.
addOrder
(
orderItemList
);
return
page
;
}
/**
* 判断用户输入里面有没有关键字
* @return Predicate
*/
private
Predicate
<
String
>
sqlInjectPredicate
()
{
return
sql
->
{
for
(
String
keyword
:
KEYWORDS
)
{
if
(
StringUtils
.
containsIgnoreCase
(
sql
,
keyword
))
{
return
false
;
}
}
return
true
;
};
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceAutoConfiguration.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
;
import
com.baomidou.dynamic.datasource.processor.DsProcessor
;
import
com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider
;
import
com.ruoyi.framework.datasource.config.DataSourceProperties
;
import
com.ruoyi.framework.datasource.config.JdbcDynamicDataSourceProvider
;
import
com.ruoyi.framework.datasource.config.LastParamDsProcessor
;
import
org.jasypt.encryption.StringEncryptor
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author lengleng
* @date 2020-02-06
* <p>
* 动态数据源切换配置
*/
//@Configuration(proxyBeanMethods = false)
//@AutoConfigureAfter(DataSourceAutoConfiguration.class)
//@EnableConfigurationProperties(DataSourceProperties.class)
public
class
DynamicDataSourceAutoConfiguration
{
// @Bean
// public DynamicDataSourceProvider dynamicDataSourceProvider(StringEncryptor stringEncryptor,
// DataSourceProperties properties) {
// return new JdbcDynamicDataSourceProvider(stringEncryptor, properties);
// }
@Bean
public
DsProcessor
dsProcessor
()
{
return
new
LastParamDsProcessor
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/annotation/EnableDynamicDataSource.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
.
annotation
;
import
com.ruoyi.framework.datasource.DynamicDataSourceAutoConfiguration
;
import
org.springframework.context.annotation.Import
;
import
java.lang.annotation.*
;
/**
* @author Lucky
* @date 2019-05-18
* <p>
* 开启动态数据源
*/
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Inherited
@Import
(
DynamicDataSourceAutoConfiguration
.
class
)
public
@interface
EnableDynamicDataSource
{
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/config/DataSourceProperties.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
* @author lengleng
* @date 2019-05-14
* <p>
*/
@Data
//@ConfigurationProperties("spring.datasource.dynamic.datasource.master")
public
class
DataSourceProperties
{
/**
* 用户名
*/
private
String
username
;
/**
* 密码
*/
private
String
password
;
/**
* jdbcurl
*/
private
String
url
;
/**
* 驱动类型
*/
private
String
driverClassName
;
/**
* 查询数据源的SQL
*/
private
String
queryDsSql
=
"select * from gen_datasource_conf where del_flag = 0"
;
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/config/JdbcDynamicDataSourceProvider.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
.
config
;
import
com.baomidou.dynamic.datasource.provider.AbstractJdbcDataSourceProvider
;
import
com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.framework.config.properties.DruidProperties
;
import
com.ruoyi.framework.datasource.support.DataSourceConstants
;
import
org.jasypt.encryption.StringEncryptor
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author lengleng
* @date 2020/2/6
* <p>
* 从数据源中获取 配置信息
*/
public
class
JdbcDynamicDataSourceProvider
extends
AbstractJdbcDataSourceProvider
{
private
final
DataSourceProperties
properties
;
private
final
StringEncryptor
stringEncryptor
;
public
JdbcDynamicDataSourceProvider
(
StringEncryptor
stringEncryptor
,
DataSourceProperties
properties
)
{
super
(
properties
.
getDriverClassName
(),
properties
.
getUrl
(),
properties
.
getUsername
(),
properties
.
getPassword
()
);
this
.
stringEncryptor
=
stringEncryptor
;
this
.
properties
=
properties
;
}
/**
* 执行语句获得数据源参数
*
* @param statement 语句
* @return 数据源参数
* @throws SQLException sql异常
*/
@Override
protected
Map
<
String
,
DataSourceProperty
>
executeStmt
(
Statement
statement
)
throws
SQLException
{
ResultSet
rs
=
statement
.
executeQuery
(
properties
.
getQueryDsSql
()
);
DruidProperties
druidProperties
=
SpringUtils
.
getBean
(
DruidProperties
.
class
);
Map
<
String
,
DataSourceProperty
>
map
=
new
HashMap
<>(
8
);
while
(
rs
.
next
())
{
String
name
=
rs
.
getString
(
DataSourceConstants
.
DS_NAME
);
String
username
=
rs
.
getString
(
DataSourceConstants
.
DS_USER_NAME
);
String
password
=
rs
.
getString
(
DataSourceConstants
.
DS_USER_PWD
);
String
url
=
rs
.
getString
(
DataSourceConstants
.
DS_JDBC_URL
);
DataSourceProperty
property
=
new
DataSourceProperty
();
property
.
setDriverClassName
(
DataSourceConstants
.
DS_DRIVER
);
property
.
setUsername
(
username
);
property
.
setLazy
(
true
);
property
.
setPassword
(
stringEncryptor
.
decrypt
(
password
)
);
property
.
setUrl
(
url
);
map
.
put
(
name
,
property
);
}
// 添加默认主数据源
DataSourceProperty
property
=
new
DataSourceProperty
();
property
.
setUsername
(
properties
.
getUsername
()
);
property
.
setPassword
(
properties
.
getPassword
()
);
property
.
setUrl
(
properties
.
getUrl
()
);
property
.
setLazy
(
true
);
property
.
setDriverClassName
(
DataSourceConstants
.
DS_DRIVER
);
map
.
put
(
DataSourceConstants
.
DS_MASTER
,
property
);
return
map
;
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/config/LastParamDsProcessor.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
.
config
;
import
com.baomidou.dynamic.datasource.processor.DsProcessor
;
import
com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder
;
import
org.aopalliance.intercept.MethodInvocation
;
/**
* @author lengleng
* @date 2020/2/6
* <p>
* 参数数据源解析 @DS("#last)
*/
public
class
LastParamDsProcessor
extends
DsProcessor
{
private
static
final
String
LAST_PREFIX
=
"#last"
;
/**
* 抽象匹配条件 匹配才会走当前执行器否则走下一级执行器
* @param key DS注解里的内容
* @return 是否匹配
*/
@Override
public
boolean
matches
(
String
key
)
{
if
(
key
.
startsWith
(
LAST_PREFIX
))
{
return
true
;
}
return
false
;
}
/**
* 抽象最终决定数据源
* @param invocation 方法执行信息
* @param key DS注解里的内容
* @return 数据源名称
*/
@Override
public
String
doDetermineDatasource
(
MethodInvocation
invocation
,
String
key
)
{
Object
[]
arguments
=
invocation
.
getArguments
();
return
String
.
valueOf
(
arguments
[
arguments
.
length
-
1
]);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/support/DataSourceConstants.java
0 → 100644
浏览文件 @
e33b846a
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
ruoyi
.
framework
.
datasource
.
support
;
/**
* @author lengleng
* @date 2019-04-01
* <p>
* 数据源相关常量
*/
public
interface
DataSourceConstants
{
/**
* 数据源名称
*/
String
DS_NAME
=
"name"
;
/**
* 默认驱动
*/
String
DS_DRIVER
=
"com.mysql.cj.jdbc.Driver"
;
/**
* 默认数据源(master)
*/
String
DS_MASTER
=
"master"
;
/**
* jdbcurl
*/
String
DS_JDBC_URL
=
"url"
;
/**
* 用户名
*/
String
DS_USER_NAME
=
"username"
;
/**
* 密码
*/
String
DS_USER_PWD
=
"password"
;
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/publicinter/PublicInterface.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
publicinter
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.sign.RsaUtils
;
import
com.ruoyi.framework.topology.collect.CollectTopologyType
;
import
com.ruoyi.framework.topology.emnus.CollectTopology
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.naming.Name
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/15 14:55
*/
@Component
(
"publicInterface"
)
@Slf4j
public
class
PublicInterface
{
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
public
AjaxResult
publicMethod
(
String
id
,
String
setterTag
,
String
setteeTag
)
throws
Exception
{
Integer
ids
;
try
{
ids
=
Integer
.
parseInt
(
RsaUtils
.
decryptByPrivateKey
(
id
)
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getLocalizedMessage
());
e
.
printStackTrace
();
log
.
error
(
"id解析失败"
);
return
AjaxResult
.
error
(
"id解析失败"
);
}
String
value
=
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
TOPOLOGY_DATA
+
ids
);
if
(
StringUtils
.
isNotBlank
(
value
)){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
value
);
JSONArray
mutualList
=
jsonObject
.
getJSONArray
(
"mutualList"
);
for
(
int
i
=
0
;
i
<
mutualList
.
size
();
i
++){
Mutual
mutual
=
mutualList
.
getObject
(
i
,
Mutual
.
class
);
if
(
mutual
.
getSetter
().
equals
(
setterTag
)&&
mutual
.
getSettee
().
equals
(
setteeTag
)){
CollectTopologyType
collectTopologyType
=
CollectTopology
.
match
(
mutual
.
getDataAcquisitionMode
());
assert
collectTopologyType
!=
null
;
collectTopologyType
.
setData
(
mutual
);
}
}
}
else
{
log
.
error
(
"未获取到组态数据"
);
return
AjaxResult
.
error
(
"未从redis中获取到组态数据"
);
}
return
AjaxResult
.
success
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/task/RyTask.java
浏览文件 @
e33b846a
...
@@ -4,11 +4,8 @@ import com.alibaba.fastjson.JSONArray;
...
@@ -4,11 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.influxdb.client.InfluxDBClient
;
import
com.influxdb.client.InfluxDBClient
;
import
com.influxdb.client.WriteApi
;
import
com.influxdb.client.WriteApi
;
import
com.influxdb.client.domain.FluxResponse
;
import
com.influxdb.client.domain.WritePrecision
;
import
com.influxdb.client.domain.WritePrecision
;
import
com.influxdb.client.write.Point
;
import
com.influxdb.client.write.Point
;
import
com.influxdb.query.FluxRecord
;
import
com.influxdb.query.FluxTable
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -19,7 +16,6 @@ import org.springframework.stereotype.Component;
...
@@ -19,7 +16,6 @@ import org.springframework.stereotype.Component;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormat
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
...
@@ -42,7 +38,7 @@ public class RyTask {
...
@@ -42,7 +38,7 @@ public class RyTask {
Random
random
=
new
Random
();
Random
random
=
new
Random
();
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
".00"
);
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"
0
.00"
);
final
String
str
=
"total_power,start_power,theory,theory_1,available,"
+
final
String
str
=
"total_power,start_power,theory,theory_1,available,"
+
"a_1,a_2,a_3,a_4,a_5,a_6,a_7,Ua,Ub,Uc,Uab,Ubc,Uca,3U0,"
+
"a_1,a_2,a_3,a_4,a_5,a_6,a_7,Ua,Ub,Uc,Uab,Ubc,Uca,3U0,"
+
"p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,"
+
"p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,"
+
...
@@ -56,8 +52,8 @@ public class RyTask {
...
@@ -56,8 +52,8 @@ public class RyTask {
public
void
ryParams
(
String
params
)
{
public
void
ryParams
(
String
params
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
);
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
);
map
.
put
(
"tag1"
,
random
.
nextFloat
()
);
map
.
put
(
"tag1"
,
random
.
nextFloat
());
map
.
put
(
"tag2"
,
random
.
nextFloat
()
);
map
.
put
(
"tag2"
,
random
.
nextFloat
());
Point
point
=
Point
Point
point
=
Point
.
measurement
(
"mem"
)
.
measurement
(
"mem"
)
.
addFields
(
map
)
.
addFields
(
map
)
...
@@ -77,16 +73,33 @@ public class RyTask {
...
@@ -77,16 +73,33 @@ public class RyTask {
// }
// }
// stringRedisTemplate.opsForValue().set( "gf:data", jsonObject.toJSONString() );
// stringRedisTemplate.opsForValue().set( "gf:data", jsonObject.toJSONString() );
// System.out.println( "执行无参方法" );
// System.out.println( "执行无参方法" );
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
TOPOLOGY_DATA
+
"38"
)
);
// JSONObject jsonObject=JSONObject.parseObject( stringRedisTemplate.opsForValue().get( Constants.TOPOLOGY_DATA+"38" ) );
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"pens"
);
// JSONArray jsonArray=jsonObject.getJSONArray( "pens" );
JSONObject
jsonObject2
=
new
JSONObject
();
// JSONObject jsonObject2=new JSONObject();
// for(int i=0;i<jsonArray.size();i++){
// JSONObject jsonObject1=jsonArray.getJSONObject( i );
// if(jsonObject1.getJSONArray( "tags" ).size()>0 ){
// jsonObject2.put( jsonObject1.getJSONArray( "tags" ).getString( 0 ),random.nextBoolean()?"1":"0" );
// }
// }
// System.out.println(jsonObject2.toJSONString());
// stringRedisTemplate.opsForValue().set( "fd:data", jsonObject2.toJSONString() );
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
TOPOLOGY_DATA
+
"107"
)
);
JSONArray
jsonArray
=
jsonObject
.
getJSONObject
(
"topologyHandle"
).
getJSONArray
(
"change"
);
JSONObject
jsonObjects
=
new
JSONObject
();
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++){
JSONObject
jsonObject1
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
jsonObject1
=
jsonArray
.
getJSONObject
(
i
);
if
(
jsonObject1
.
getJSONArray
(
"tags"
).
size
()>
0
){
JSONArray
jsonArray1
=
jsonObject1
.
getJSONArray
(
"handle"
);
jsonObject2
.
put
(
jsonObject1
.
getJSONArray
(
"tags"
).
getString
(
0
),
random
.
nextBoolean
()?
"1"
:
"0"
);
if
(
jsonArray1
.
size
()>
0
){
if
(
jsonArray1
.
getJSONObject
(
0
).
getBoolean
(
"judge"
)){
jsonObjects
.
put
(
jsonObject1
.
getString
(
"tag"
),
random
.
nextBoolean
()?
"true"
:
"false"
);
}
else
{
jsonObjects
.
put
(
jsonObject1
.
getString
(
"tag"
),
decimalFormat
.
format
(
random
.
nextFloat
()*
10
));
}
}
}
}
}
System
.
out
.
println
(
jsonObject
2
.
toJSONString
());
System
.
out
.
println
(
jsonObject
s
.
toJSONString
());
stringRedisTemplate
.
opsForValue
().
set
(
"
fd:data"
,
jsonObject2
.
toJSONString
()
);
stringRedisTemplate
.
opsForValue
().
set
(
"
lei:data"
,
jsonObjects
.
toJSONString
()
);
}
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/task/TopologyTask.java
浏览文件 @
e33b846a
...
@@ -3,7 +3,7 @@ package com.ruoyi.framework.task;
...
@@ -3,7 +3,7 @@ package com.ruoyi.framework.task;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.
common.core
.websocket.WebSocketServer
;
import
com.ruoyi.
framework
.websocket.WebSocketServer
;
import
com.ruoyi.framework.topology.emnus.CollectTopology
;
import
com.ruoyi.framework.topology.emnus.CollectTopology
;
import
com.ruoyi.common.topology.change.PointAndData
;
import
com.ruoyi.common.topology.change.PointAndData
;
import
com.ruoyi.framework.topology.collect.CollectTopologyType
;
import
com.ruoyi.framework.topology.collect.CollectTopologyType
;
...
@@ -60,7 +60,7 @@ public class TopologyTask {
...
@@ -60,7 +60,7 @@ public class TopologyTask {
/**
/**
* 配置数据
* 配置数据
*/
*/
List
<
Map
<
String
,
Object
>>
list
=
PointAndData
.
assemble
(
stringObjectMap
,
topologyHandle
.
getJSONArray
(
"change"
)
);
List
<
Map
<
String
,
Object
>>
list
=
PointAndData
.
assemble
(
stringObjectMap
,
topologyHandle
.
getJSONArray
(
"change"
)
,
data
);
/**
/**
* mqtt与socket
* mqtt与socket
*/
*/
...
...
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/CollectTopologyType.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -10,5 +12,6 @@ import java.util.Map;
...
@@ -10,5 +12,6 @@ import java.util.Map;
* @date 2021/4/9 9:55
* @date 2021/4/9 9:55
*/
*/
public
interface
CollectTopologyType
{
public
interface
CollectTopologyType
{
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
);
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
);
AjaxResult
setData
(
Mutual
mutual
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/InfluxdbType.java
浏览文件 @
e33b846a
...
@@ -2,11 +2,17 @@ package com.ruoyi.framework.topology.collect;
...
@@ -2,11 +2,17 @@ package com.ruoyi.framework.topology.collect;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.influxdb.client.InfluxDBClient
;
import
com.influxdb.client.InfluxDBClient
;
import
com.influxdb.client.WriteApi
;
import
com.influxdb.client.domain.WritePrecision
;
import
com.influxdb.client.write.Point
;
import
com.influxdb.query.FluxRecord
;
import
com.influxdb.query.FluxRecord
;
import
com.influxdb.query.FluxTable
;
import
com.influxdb.query.FluxTable
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
javax.management.Query
;
import
javax.management.Query
;
import
java.time.Instant
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -33,4 +39,22 @@ public class InfluxdbType implements CollectTopologyType {
...
@@ -33,4 +39,22 @@ public class InfluxdbType implements CollectTopologyType {
}
}
return
map1
;
return
map1
;
}
}
@Override
public
AjaxResult
setData
(
Mutual
mutual
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
);
if
(
mutual
.
getAssignment
().
contains
(
"="
)){
map
.
put
(
mutual
.
getPoint
(),
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
);
}
else
{
}
Point
point
=
Point
.
measurement
(
mutual
.
getCondition
())
.
addFields
(
map
)
.
time
(
Instant
.
now
(),
WritePrecision
.
NS
);
try
(
WriteApi
writeApi
=
influxDBClient
.
getWriteApi
())
{
writeApi
.
writePoint
(
point
);
}
return
AjaxResult
.
success
();
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/MysqlType.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.topology.service.impl.MysqlServiceImpl
;
import
com.ruoyi.topology.service.impl.MysqlServiceImpl
;
...
@@ -17,4 +19,12 @@ public class MysqlType implements CollectTopologyType {
...
@@ -17,4 +19,12 @@ public class MysqlType implements CollectTopologyType {
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
return
mysqlService
.
getMysqlData
(
param
);
return
mysqlService
.
getMysqlData
(
param
);
}
}
@Override
public
AjaxResult
setData
(
Mutual
mutual
)
{
if
(
mysqlService
.
setMysqlData
(
mutual
.
getCondition
())>
0
){
return
AjaxResult
.
success
();
}
return
AjaxResult
.
error
(
"修改失败"
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/OracleType.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.topology.service.impl.OracleServiceImpl
;
import
com.ruoyi.topology.service.impl.OracleServiceImpl
;
...
@@ -17,4 +19,12 @@ public class OracleType implements CollectTopologyType {
...
@@ -17,4 +19,12 @@ public class OracleType implements CollectTopologyType {
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
return
oracleService
.
getOracleData
(
param
);
return
oracleService
.
getOracleData
(
param
);
}
}
@Override
public
AjaxResult
setData
(
Mutual
mutual
)
{
if
(
oracleService
.
setOracleData
(
mutual
.
getCondition
()
)>
0
){
return
AjaxResult
.
success
();
}
return
AjaxResult
.
error
(
"修改失败"
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/RedisType.java
浏览文件 @
e33b846a
...
@@ -2,6 +2,10 @@ package com.ruoyi.framework.topology.collect;
...
@@ -2,6 +2,10 @@ package com.ruoyi.framework.topology.collect;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.JexlUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
@@ -14,11 +18,27 @@ import java.util.Map;
...
@@ -14,11 +18,27 @@ import java.util.Map;
*/
*/
public
class
RedisType
implements
CollectTopologyType
{
public
class
RedisType
implements
CollectTopologyType
{
private
StringRedisTemplate
stringRedisTemplate
=
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
);
private
final
StringRedisTemplate
stringRedisTemplate
=
SpringUtils
.
getBean
(
StringRedisTemplate
.
class
);
@Override
@Override
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
public
Map
<
String
,
Object
>
getData
(
String
param
,
JSONArray
jsonArray
)
{
String
data
=
stringRedisTemplate
.
opsForValue
().
get
(
param
);
String
data
=
stringRedisTemplate
.
opsForValue
().
get
(
param
);
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
data
,
Map
.
class
);
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
data
,
Map
.
class
);
return
map
;
return
map
;
}
}
@Override
public
AjaxResult
setData
(
Mutual
mutual
)
{
String
str
=
stringRedisTemplate
.
opsForValue
().
get
(
mutual
.
getCondition
()
);
if
(
StringUtils
.
isNotBlank
(
str
)){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
str
);
if
(
mutual
.
getAssignment
().
contains
(
"="
)){
jsonObject
.
put
(
mutual
.
getPoint
(),
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
);
}
else
{
jsonObject
.
put
(
mutual
.
getPoint
(),
JexlUtils
.
math
(
jsonObject
.
getString
(
mutual
.
getPoint
()
)+
mutual
.
getAssignment
()
));
}
stringRedisTemplate
.
opsForValue
().
set
(
mutual
.
getCondition
(),
jsonObject
.
toJSONString
()
);
return
AjaxResult
.
success
();
}
return
AjaxResult
.
error
(
"设置失败"
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/collect/ShareServerType.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
package
com
.
ruoyi
.
framework
.
topology
.
collect
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.enums.NodeLineParams
;
import
com.ruoyi.common.enums.NodeLineParams
;
import
com.ruoyi.common.topology.change.EchartsSet
;
import
com.ruoyi.common.topology.change.EchartsSet
;
import
com.ruoyi.common.topology.mutual.Mutual
;
import
com.ruoyi.common.utils.JexlUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.topology.emnus.ShareDataType
;
import
com.ruoyi.framework.topology.emnus.ShareDataType
;
import
com.ruoyi.common.topology.change.ChangeSub
;
import
com.ruoyi.common.topology.change.ChangeSub
;
import
com.ruoyi.common.topology.change.Handle
;
import
com.ruoyi.common.topology.change.Handle
;
import
shareconnector.domain.DataType
;
import
shareconnector.netty.ShareServerFactory
;
import
shareconnector.netty.ShareServerFactory
;
import
shareconnector.service.SendAndRequestService
;
import
shareconnector.service.SendAndRequestService
;
...
@@ -26,6 +31,8 @@ public class ShareServerType implements CollectTopologyType {
...
@@ -26,6 +31,8 @@ public class ShareServerType implements CollectTopologyType {
Map
<
String
,
Set
<
Integer
>>
map
=
new
LinkedHashMap
<>(
);
Map
<
String
,
Set
<
Integer
>>
map
=
new
LinkedHashMap
<>(
);
Set
<
Integer
>
set
=
null
;
Set
<
Integer
>
set
=
null
;
for
(
ChangeSub
changeSub:
list
)
{
for
(
ChangeSub
changeSub:
list
)
{
// #00FF00,#FF4500
// true,false
List
<
Handle
>
handleList
=
changeSub
.
getHandle
();
List
<
Handle
>
handleList
=
changeSub
.
getHandle
();
for
(
Handle
handle:
handleList
){
for
(
Handle
handle:
handleList
){
//获取echarts数据
//获取echarts数据
...
@@ -60,4 +67,50 @@ public class ShareServerType implements CollectTopologyType {
...
@@ -60,4 +67,50 @@ public class ShareServerType implements CollectTopologyType {
}
}
return
map1
;
return
map1
;
}
}
@Override
public
AjaxResult
setData
(
Mutual
mutual
)
{
String
[]
params
=
mutual
.
getCondition
().
split
(
":"
);
shareServerFactory
.
setIp
(
params
[
0
]
).
setPort
(
Integer
.
parseInt
(
params
[
1
]
)
);
SendAndRequestService
send
=
SendAndRequestService
.
getInstance
();
if
(
StringUtils
.
isNotBlank
(
mutual
.
getShareType
()
)){
if
(!
mutual
.
getAssignment
().
contains
(
"="
)){
if
(
mutual
.
getShareType
().
equals
(
ShareDataType
.
FLOAT
.
name
())){
Set
<
Integer
>
set
=
new
HashSet
<>();
set
.
add
(
Integer
.
parseInt
(
mutual
.
getPoint
()
)
);
Map
<
Integer
,
Object
>
floatMap
=
send
.
getDatas
(
set
,
DataType
.
FLOAT
);
Map
<
Integer
,
Float
>
map
=
new
LinkedHashMap
<>();
Float
it
=
Float
.
parseFloat
(
JexlUtils
.
math
(
floatMap
.
get
(
Integer
.
parseInt
(
mutual
.
getPoint
()
)
)+
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
).
toString
())
;
map
.
put
(
Integer
.
parseInt
(
mutual
.
getPoint
()
),
it
);
send
.
sendFloatData
(
map
);
}
if
(
mutual
.
getShareType
().
equals
(
ShareDataType
.
INT
.
name
()
)){
Set
<
Integer
>
set
=
new
HashSet
<>();
set
.
add
(
Integer
.
parseInt
(
mutual
.
getPoint
()
)
);
Map
<
Integer
,
Object
>
intMap
=
send
.
getDatas
(
set
,
DataType
.
INTEGER
);
Map
<
Integer
,
Integer
>
map
=
new
LinkedHashMap
<>();
Integer
it
=
Integer
.
parseInt
(
JexlUtils
.
math
(
intMap
.
get
(
Integer
.
parseInt
(
mutual
.
getPoint
()
)
)+
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
).
toString
())
;
map
.
put
(
Integer
.
parseInt
(
mutual
.
getPoint
()
),
Integer
.
parseInt
(
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
)
);
send
.
sendIntegerData
(
map
);
}
}
else
{
if
(
mutual
.
getShareType
().
equals
(
ShareDataType
.
FLOAT
.
name
())){
Map
<
Integer
,
Float
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
Integer
.
parseInt
(
mutual
.
getPoint
()
),
Float
.
parseFloat
(
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
)
);
send
.
sendFloatData
(
map
);
}
if
(
mutual
.
getShareType
().
equals
(
ShareDataType
.
BOOLEAN
.
name
()
)){
Map
<
Integer
,
Boolean
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
Integer
.
parseInt
(
mutual
.
getPoint
()
),
Boolean
.
parseBoolean
(
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
)
);
send
.
sendBooleanData
(
map
);
}
if
(
mutual
.
getShareType
().
equals
(
ShareDataType
.
INT
.
name
()
)){
Map
<
Integer
,
Integer
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
Integer
.
parseInt
(
mutual
.
getPoint
()
),
Integer
.
parseInt
(
mutual
.
getAssignment
().
replaceAll
(
"="
,
""
)
)
);
send
.
sendIntegerData
(
map
);
}
}
}
return
AjaxResult
.
success
();
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-framework/src/main/java/com/ruoyi/framework/topology/emnus/CollectTopology.java
浏览文件 @
e33b846a
...
@@ -35,7 +35,7 @@ public enum CollectTopology {
...
@@ -35,7 +35,7 @@ public enum CollectTopology {
this
.
i
=
i
;
this
.
i
=
i
;
this
.
collectTopologyType
=
collectTopologyType
;
this
.
collectTopologyType
=
collectTopologyType
;
}
}
//匹配
//匹配
public
static
CollectTopologyType
match
(
int
i
)
{
public
static
CollectTopologyType
match
(
int
i
)
{
CollectTopology
[]
values
=
CollectTopology
.
values
();
CollectTopology
[]
values
=
CollectTopology
.
values
();
...
...
This diff is collapsed.
Click to expand it.
ruoyi-
common/src/main/java/com/ruoyi/common/core
/websocket/WebSocketServer.java
→
ruoyi-
framework/src/main/java/com/ruoyi/framework
/websocket/WebSocketServer.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
common
.
core
.
websocket
;
package
com
.
ruoyi
.
framework
.
websocket
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.framework.publicinter.PublicInterface
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -34,6 +37,8 @@ public class WebSocketServer {
...
@@ -34,6 +37,8 @@ public class WebSocketServer {
/**接收topologyId*/
/**接收topologyId*/
private
String
topologyId
=
""
;
private
String
topologyId
=
""
;
private
PublicInterface
publicInterface
=
SpringUtils
.
getBean
(
"publicInterface"
);
/**
/**
* 连接建立成功调用的方法*/
* 连接建立成功调用的方法*/
@OnOpen
@OnOpen
...
@@ -77,7 +82,7 @@ public class WebSocketServer {
...
@@ -77,7 +82,7 @@ public class WebSocketServer {
*
*
* @param message 客户端发送过来的消息*/
* @param message 客户端发送过来的消息*/
@OnMessage
@OnMessage
public
void
onMessage
(
String
message
,
Session
session
)
{
public
void
onMessage
(
String
message
,
Session
session
,
@PathParam
(
"topologyId"
)
String
topologyId
)
{
log
.
info
(
"用户消息:"
+
topologyId
+
",报文:"
+
message
);
log
.
info
(
"用户消息:"
+
topologyId
+
",报文:"
+
message
);
//可以群发消息
//可以群发消息
//消息保存到数据库、redis
//消息保存到数据库、redis
...
@@ -86,17 +91,27 @@ public class WebSocketServer {
...
@@ -86,17 +91,27 @@ public class WebSocketServer {
//解析发送的报文
//解析发送的报文
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
message
);
//追加发送人(防止串改)
//追加发送人(防止串改)
jsonObject
.
put
(
"fromUserId"
,
this
.
topologyId
);
jsonObject
.
put
(
"fromUserId"
,
topologyId
);
String
toUserId
=
jsonObject
.
getString
(
"toUserId"
);
// String toUserId=jsonObject.getString("toUserId");
//传送给对应toUserId用户的websocket
// //传送给对应toUserId用户的websocket
if
(
StringUtils
.
isNotBlank
(
toUserId
)&&
webSocketMap
.
containsKey
(
toUserId
)){
// if(StringUtils.isNotBlank(toUserId)&&webSocketMap.containsKey(toUserId)){
webSocketMap
.
get
(
toUserId
).
sendMessage
(
jsonObject
.
toJSONString
());
// webSocketMap.get(toUserId).sendMessage(jsonObject.toJSONString());
}
else
{
// }else{
log
.
error
(
"请求的userId:"
+
toUserId
+
"不在该服务器上"
);
// log.error("请求的userId:"+toUserId+"不在该服务器上");
//否则不在这个服务器上,发送到mysql或者redis
// //否则不在这个服务器上,发送到mysql或者redis
}
// }
//公共方法解析
AjaxResult
ajaxResult
=
publicInterface
.
publicMethod
(
jsonObject
.
getString
(
"id"
),
jsonObject
.
getString
(
"setterTag"
),
jsonObject
.
getString
(
"setteeTag"
)
);
sendInfo
(
JSON
.
toJSONString
(
ajaxResult
),
topologyId
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
try
{
sendInfo
(
JSON
.
toJSONString
(
AjaxResult
.
error
(
"执行失败"
)
),
topologyId
);
}
catch
(
IOException
ioException
)
{
ioException
.
printStackTrace
();
log
.
error
(
"发送消息失败,客户端:{}"
,
topologyId
);
}
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/mapper/DBMapper.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
topology
.
mapper
;
package
com
.
ruoyi
.
topology
.
mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -13,4 +15,7 @@ import java.util.Map;
...
@@ -13,4 +15,7 @@ import java.util.Map;
public
interface
DBMapper
{
public
interface
DBMapper
{
@Select
(
"${sql}"
)
@Select
(
"${sql}"
)
Map
<
String
,
Object
>
getDBData
(
String
sql
);
Map
<
String
,
Object
>
getDBData
(
String
sql
);
@Update
(
"${sql}"
)
Integer
setDBData
(
String
sql
);
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/mapper/ImagesMapper.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
topology
.
mapper
;
import
com.ruoyi.common.core.domain.topology.Image
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/17 9:41
*/
public
interface
ImagesMapper
{
Integer
addImages
(
@Param
(
"url"
)
String
url
);
Integer
deleteImages
(
@Param
(
"id"
)
Integer
id
);
List
<
Image
>
getImages
();
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/ITopologyService.java
浏览文件 @
e33b846a
...
@@ -22,4 +22,6 @@ public interface ITopologyService {
...
@@ -22,4 +22,6 @@ public interface ITopologyService {
Integer
deleteTopologyById
(
Integer
id
);
Integer
deleteTopologyById
(
Integer
id
);
Map
<
String
,
Object
>
getData
(
String
sql
);
Map
<
String
,
Object
>
getData
(
String
sql
);
void
ces
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/IimagesService.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
topology
.
service
;
import
com.ruoyi.common.core.domain.topology.Image
;
import
java.util.List
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/17 9:29
*/
public
interface
IimagesService
{
Integer
addImages
(
String
url
);
Integer
deleteImages
(
Integer
id
);
List
<
Image
>
getImages
();
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/impl/ImagesServiceImpl.java
0 → 100644
浏览文件 @
e33b846a
package
com
.
ruoyi
.
topology
.
service
.
impl
;
import
com.ruoyi.common.core.domain.topology.Image
;
import
com.ruoyi.topology.mapper.ImagesMapper
;
import
com.ruoyi.topology.service.IimagesService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author jianglw
* @version 1.0
* @date 2021/6/17 9:36
*/
@Service
public
class
ImagesServiceImpl
implements
IimagesService
{
@Autowired
private
ImagesMapper
imagesMapper
;
@Override
public
Integer
addImages
(
String
url
)
{
return
imagesMapper
.
addImages
(
url
);
}
@Override
public
Integer
deleteImages
(
Integer
id
)
{
return
imagesMapper
.
deleteImages
(
id
);
}
@Override
public
List
<
Image
>
getImages
()
{
return
imagesMapper
.
getImages
();
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/impl/MysqlServiceImpl.java
浏览文件 @
e33b846a
...
@@ -25,4 +25,8 @@ public class MysqlServiceImpl implements IMysqlService {
...
@@ -25,4 +25,8 @@ public class MysqlServiceImpl implements IMysqlService {
public
Map
<
String
,
Object
>
getMysqlData
(
String
sql
)
{
public
Map
<
String
,
Object
>
getMysqlData
(
String
sql
)
{
return
dbMapper
.
getDBData
(
sql
);
return
dbMapper
.
getDBData
(
sql
);
}
}
public
Integer
setMysqlData
(
String
condition
)
{
return
dbMapper
.
setDBData
(
condition
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/impl/OracleServiceImpl.java
浏览文件 @
e33b846a
...
@@ -25,4 +25,8 @@ public class OracleServiceImpl implements IOracleService {
...
@@ -25,4 +25,8 @@ public class OracleServiceImpl implements IOracleService {
public
Map
<
String
,
Object
>
getOracleData
(
String
sql
)
{
public
Map
<
String
,
Object
>
getOracleData
(
String
sql
)
{
return
dbMapper
.
getDBData
(
sql
);
return
dbMapper
.
getDBData
(
sql
);
}
}
public
Integer
setOracleData
(
String
condition
)
{
return
dbMapper
.
setDBData
(
condition
);
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/java/com/ruoyi/topology/service/impl/TopologyService.java
浏览文件 @
e33b846a
package
com
.
ruoyi
.
topology
.
service
.
impl
;
package
com
.
ruoyi
.
topology
.
service
.
impl
;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.ruoyi.common.core.domain.topology.TopologyData
;
import
com.ruoyi.common.core.domain.topology.TopologyData
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.topology.mapper.TopologyMapper
;
import
com.ruoyi.topology.mapper.TopologyMapper
;
...
@@ -51,4 +52,10 @@ public class TopologyService implements ITopologyService {
...
@@ -51,4 +52,10 @@ public class TopologyService implements ITopologyService {
public
Map
<
String
,
Object
>
getData
(
String
sql
)
{
public
Map
<
String
,
Object
>
getData
(
String
sql
)
{
return
topologyMapper
.
getData
(
sql
);
return
topologyMapper
.
getData
(
sql
);
}
}
@DS
(
"#last"
)
@Override
public
void
ces
()
{
System
.
out
.
println
(
topologyMapper
.
getData
(
"select * from images"
));
}
}
}
This diff is collapsed.
Click to expand it.
ruoyi-system/src/main/resources/mapper/topology/ImagesMapper.xml
0 → 100644
浏览文件 @
e33b846a
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ruoyi.topology.mapper.ImagesMapper"
>
<insert
id=
"addImages"
>
insert into images (url) values (#{url})
</insert>
<delete
id=
"deleteImages"
>
delete from images where id = #{id}
</delete>
<select
id=
"getImages"
resultType=
"com.ruoyi.common.core.domain.topology.Image"
>
select * from images
</select>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论