Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3-integration
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f217772f
authored
May 06, 2022
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<feat>:增加繁星同步gb1400协议优化
1 parent
1a58ea4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
11 deletions
fanxing-docking-gb1400/src/main/java/com/viontech/controller/Gb1400Controller.java
fanxing-docking-gb1400/src/main/java/com/viontech/service/impl/Gb1400ServiceImpl.java
fanxing-docking-gb1400/src/main/java/com/viontech/controller/Gb1400Controller.java
View file @
f217772
...
@@ -9,6 +9,10 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -9,6 +9,10 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
@Slf4j
@Slf4j
...
@@ -23,17 +27,43 @@ public class Gb1400Controller {
...
@@ -23,17 +27,43 @@ public class Gb1400Controller {
* @param params
* @param params
* @return
* @return
*/
*/
// @RequestMapping(value = "/Subscribes" ,method = RequestMethod.POST)
// @ResponseBody
// public JSONObject subscribes(@RequestBody String params){
// log.info("收到请求[Subscribes.request]:{}", params);
// JsonMessage vo = gb1400Service.subscribes(params);
// log.info("响应[Subscribes.request]:{}", JSONObject.toJSONString(vo));
// if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
// return Gb1400ResponseUtil.responseStatusListObject((List<JSONObject>) vo.getData());
// } else {
// return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes");
// }
// }
/**
* 批量订阅
* @return
*/
@RequestMapping
(
value
=
"/Subscribes"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/Subscribes"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
void
subscribes
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
JSONObject
subscribes
(
@RequestBody
String
params
){
BufferedReader
br
=
request
.
getReader
();
log
.
info
(
"收到请求[Subscribes.request]:{}"
,
params
);
String
str
;
JsonMessage
vo
=
gb1400Service
.
subscribes
(
params
);
StringBuilder
params
=
new
StringBuilder
();
while
((
str
=
br
.
readLine
())
!=
null
){
params
.
append
(
str
);
}
log
.
info
(
"收到请求[Subscribes.request]:{}"
,
params
.
toString
());
JsonMessage
vo
=
gb1400Service
.
subscribes
(
params
.
toString
());
log
.
info
(
"响应[Subscribes.request]:{}"
,
JSONObject
.
toJSONString
(
vo
));
log
.
info
(
"响应[Subscribes.request]:{}"
,
JSONObject
.
toJSONString
(
vo
));
JSONObject
result
=
null
;
response
.
setContentType
(
"application/VIID+JSON;charset=utf-8"
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
vo
.
getCode
())
{
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
vo
.
getCode
())
{
re
turn
Gb1400ResponseUtil
.
responseStatusListObject
((
List
<
JSONObject
>)
vo
.
getData
());
re
sult
=
Gb1400ResponseUtil
.
responseStatusListObject
((
List
<
JSONObject
>)
vo
.
getData
());
}
else
{
}
else
{
re
turn
Gb1400ResponseUtil
.
error
(
1
,
vo
.
getMsg
(),
"/VIID/Subscribes"
);
re
sult
=
Gb1400ResponseUtil
.
error
(
1
,
vo
.
getMsg
(),
"/VIID/Subscribes"
);
}
}
response
.
getWriter
().
write
(
result
.
toJSONString
());
}
}
/**
/**
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/service/impl/Gb1400ServiceImpl.java
View file @
f217772
...
@@ -102,10 +102,10 @@ public class Gb1400ServiceImpl implements Gb1400Service {
...
@@ -102,10 +102,10 @@ public class Gb1400ServiceImpl implements Gb1400Service {
list
.
add
(
Gb1400ResponseUtil
.
buildResponseStatusObject
(
item
.
getString
(
"SubscribeDetail"
),
"/VIID/Subscribes"
,
1
,
"SubscribeID不能为空"
));
list
.
add
(
Gb1400ResponseUtil
.
buildResponseStatusObject
(
item
.
getString
(
"SubscribeDetail"
),
"/VIID/Subscribes"
,
1
,
"SubscribeID不能为空"
));
continue
;
continue
;
}
}
if
(!
"50"
.
equals
(
item
.
getString
(
"SubscribeDetail"
)))
{
//
if (!"50".equals(item.getString("SubscribeDetail"))) {
list
.
add
(
Gb1400ResponseUtil
.
buildResponseStatusObject
(
item
.
getString
(
"SubscribeDetail"
),
"/VIID/Subscribes"
,
1
,
"订阅类别暂不支持"
));
//
list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "订阅类别暂不支持"));
continue
;
//
continue;
}
//
}
String
subscribeId
=
item
.
getString
(
"SubscribeID"
);
String
subscribeId
=
item
.
getString
(
"SubscribeID"
);
// String subscribeDetail = item.getString("SubscribeDetail");
// String subscribeDetail = item.getString("SubscribeDetail");
redisTemplate
.
opsForHash
().
put
(
RedisConstants
.
GB1400_SUBSCRIBES_HASH
,
subscribeId
,
item
.
toJSONString
());
redisTemplate
.
opsForHash
().
put
(
RedisConstants
.
GB1400_SUBSCRIBES_HASH
,
subscribeId
,
item
.
toJSONString
());
...
@@ -147,7 +147,25 @@ public class Gb1400ServiceImpl implements Gb1400Service {
...
@@ -147,7 +147,25 @@ public class Gb1400ServiceImpl implements Gb1400Service {
}
}
String
notificationsData
=
JSONObject
.
toJSONString
(
subscribeNotificationsObj
);
String
notificationsData
=
JSONObject
.
toJSONString
(
subscribeNotificationsObj
);
String
sendResult
=
gb1400RestTemplate
.
doPost
(
gb1400Config
.
getUserIdentify
(),
Gb1400UriConstants
.
SUBSCRIBENOTIFICATIONS
,
notificationsData
);
String
sendResult
=
gb1400RestTemplate
.
doPost
(
gb1400Config
.
getUserIdentify
(),
Gb1400UriConstants
.
SUBSCRIBENOTIFICATIONS
,
notificationsData
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
sendResult
);
if
(
StringUtils
.
isBlank
(
sendResult
))
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
sendResult
);
}
JSONObject
resultObj
=
JSONObject
.
parseObject
(
sendResult
);
if
(
resultObj
!=
null
&&
resultObj
.
getJSONObject
(
"ResponseStatusListObject"
)
!=
null
)
{
JSONObject
resultlistObj
=
resultObj
.
getJSONObject
(
"ResponseStatusListObject"
);
if
(
resultlistObj
!=
null
&&
resultlistObj
.
getJSONArray
(
"ResponseStatusObject"
)
!=
null
)
{
JSONArray
arr
=
resultlistObj
.
getJSONArray
(
"ResponseStatusObject"
);
if
(
arr
!=
null
&&
arr
.
size
()
>
0
)
{
JSONObject
item
=
(
JSONObject
)
arr
.
get
(
0
);
if
(
item
!=
null
&&
item
.
getInteger
(
"StatusCode"
)
==
0
)
{
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
sendResult
);
}
else
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
sendResult
);
}
}
}
}
return
JsonMessageUtil
.
getErrorJsonMsg
(
sendResult
);
}
}
private
String
getRedisAuth
(){
private
String
getRedisAuth
(){
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment