Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a3425e6f
由
LN
编写于
2024-12-11 20:18:12 +0800
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge remote-tracking branch 'origin/master'
2 个父辈
a6ea5055
0951b9ed
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
192 行增加
和
1 行删除
src/main/java/com/neotel/smfcore/core/equipment/enums/EquipmentType.java
src/main/java/com/neotel/smfcore/custom/hanwha/controller/HanwhaApiInfoController.java
src/main/java/com/neotel/smfcore/custom/hanwha/controller/HanwhaConfigController.java
src/main/java/com/neotel/smfcore/custom/hanwha/util/HanwhaApiInfoUtil.java
src/main/java/com/neotel/smfcore/custom/hanwha/util/HanwhaCacheUtil.java
src/main/java/com/neotel/smfcore/custom/hanwha/util/bean/HanwhaApiInfo.java
src/main/java/com/neotel/smfcore/custom/hanwha/util/bean/HanwhaCacheConfig.java
src/main/java/com/neotel/smfcore/core/equipment/enums/EquipmentType.java
查看文件 @
a3425e6
...
@@ -52,6 +52,8 @@ public enum EquipmentType {
...
@@ -52,6 +52,8 @@ public enum EquipmentType {
*/
*/
HANWHA
(),
HANWHA
(),
/**
* NEXIM
*/
NEXIM
()
NEXIM
()
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/controller/HanwhaApiInfoController.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
controller
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.custom.hanwha.util.HanwhaApiInfoUtil
;
import
com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@Slf4j
@RestController
@RequestMapping
(
"/hanwhaApiInfo"
)
public
class
HanwhaApiInfoController
{
@Autowired
private
HanwhaApiInfoUtil
hanwhaApiInfoUtil
;
@ApiOperation
(
"获取列表"
)
@RequestMapping
(
"/getApiInfoList"
)
public
ResultBean
getApiInfoList
(){
List
<
HanwhaApiInfo
>
apiInfoList
=
hanwhaApiInfoUtil
.
getApiInfoList
();
return
ResultBean
.
newOkResult
(
apiInfoList
);
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/controller/HanwhaConfigController.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
controller
;
import
com.neotel.smfcore.common.bean.ResultBean
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.custom.hanwha.util.HanwhaCacheUtil
;
import
com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@RestController
@RequestMapping
(
"/hanwhaConfig"
)
public
class
HanwhaConfigController
{
@Autowired
private
HanwhaCacheUtil
hanwhaCacheUtil
;
@ApiOperation
(
"获取ip和端口号"
)
@RequestMapping
(
"/getCacheConfig"
)
public
ResultBean
getCacheConfig
(){
return
ResultBean
.
newOkResult
(
hanwhaCacheUtil
.
getHostAndPortCache
());
}
@ApiOperation
(
"修改ip和端口号"
)
@RequestMapping
(
"/updateCacheConfig"
)
public
ResultBean
updateCacheConfig
(
@RequestBody
HanwhaCacheConfig
cacheConfig
)
{
String
host
=
cacheConfig
.
getHost
();
String
apiPort
=
cacheConfig
.
getApiPort
();
String
webPort
=
cacheConfig
.
getWebPort
();
log
.
info
(
"收到修改ip和端口号,host为[{}],apiPort为[{}],webPort为[{}]"
,
host
,
apiPort
,
webPort
);
if
(
StringUtils
.
isEmpty
(
host
)){
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"host"
});
}
if
(
StringUtils
.
isEmpty
(
webPort
)){
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"webPort"
});
}
if
(
StringUtils
.
isEmpty
(
apiPort
)){
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"apiPort"
});
}
hanwhaCacheUtil
.
updateHostAndPort
(
cacheConfig
);
return
ResultBean
.
newOkResult
(
""
);
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/util/HanwhaApiInfoUtil.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
util
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
public
class
HanwhaApiInfoUtil
{
//api接口信息,默认返回10条
public
static
List
<
HanwhaApiInfo
>
apiInfoList
=
new
CopyOnWriteArrayList
<>();
public
void
updateApiInfoList
(
String
url
,
String
requestParam
,
String
resultReturn
)
{
HanwhaApiInfo
info
=
new
HanwhaApiInfo
();
info
.
setCreateDate
(
new
Date
());
info
.
setUrl
(
url
);
info
.
setRequestParam
(
requestParam
);
info
.
setResultReturn
(
resultReturn
);
apiInfoList
.
add
(
info
);
if
(
apiInfoList
!=
null
&&
apiInfoList
.
size
()
>
10
)
{
apiInfoList
.
remove
(
0
);
}
}
public
List
<
HanwhaApiInfo
>
getApiInfoList
(){
List
<
HanwhaApiInfo
>
resultList
=
new
ArrayList
<>();
if
(
apiInfoList
!=
null
&&
!
apiInfoList
.
isEmpty
()){
resultList
=
apiInfoList
.
stream
().
sorted
(
Comparator
.
comparing
(
HanwhaApiInfo:
:
getCreateDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
return
resultList
;
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/util/HanwhaCacheUtil.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
util
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
public
class
HanwhaCacheUtil
{
@Autowired
private
DataCache
dataCache
;
public
static
final
String
Cache_Hanwha_HostAndPost
=
"Cache_Hanwha_HostAndPost"
;
public
void
updateHostAndPort
(
HanwhaCacheConfig
cacheConfig
)
{
HanwhaCacheConfig
hanwhaCacheConfig
=
dataCache
.
getCache
(
Cache_Hanwha_HostAndPost
);
if
(
hanwhaCacheConfig
==
null
)
{
hanwhaCacheConfig
=
new
HanwhaCacheConfig
();
}
hanwhaCacheConfig
.
setHost
(
cacheConfig
.
getHost
());
hanwhaCacheConfig
.
setWebPort
(
cacheConfig
.
getWebPort
());
hanwhaCacheConfig
.
setApiPort
(
cacheConfig
.
getApiPort
());
hanwhaCacheConfig
.
setSingleOrder
(
cacheConfig
.
isSingleOrder
());
dataCache
.
updateCache
(
Cache_Hanwha_HostAndPost
,
hanwhaCacheConfig
);
}
public
HanwhaCacheConfig
getHostAndPortCache
(){
HanwhaCacheConfig
hostAndPortCache
=
dataCache
.
getCache
(
Cache_Hanwha_HostAndPost
);
if
(
hostAndPortCache
==
null
)
{
hostAndPortCache
=
new
HanwhaCacheConfig
();
}
return
hostAndPortCache
;
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/util/bean/HanwhaApiInfo.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
util
.
bean
;
import
lombok.Data
;
import
java.util.Date
;
@Data
public
class
HanwhaApiInfo
{
private
String
url
;
private
String
requestParam
;
private
String
resultReturn
;
private
Date
createDate
;
}
src/main/java/com/neotel/smfcore/custom/hanwha/util/bean/HanwhaCacheConfig.java
0 → 100644
查看文件 @
a3425e6
package
com
.
neotel
.
smfcore
.
custom
.
hanwha
.
util
.
bean
;
import
lombok.Data
;
@Data
public
class
HanwhaCacheConfig
{
private
String
host
;
private
String
webPort
;
private
String
apiPort
;
private
boolean
singleOrder
=
false
;
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论