Commit f217772f by 毛树良

<feat>:增加繁星同步gb1400协议优化

1 parent 1a58ea4e
......@@ -9,6 +9,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
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;
@Slf4j
......@@ -23,17 +27,43 @@ public class Gb1400Controller {
* @param params
* @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)
@ResponseBody
public JSONObject subscribes(@RequestBody String params){
log.info("收到请求[Subscribes.request]:{}", params);
JsonMessage vo = gb1400Service.subscribes(params);
public void subscribes(HttpServletRequest request, HttpServletResponse response) throws IOException {
BufferedReader br = request.getReader();
String str;
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));
JSONObject result = null;
response.setContentType("application/VIID+JSON;charset=utf-8");
if (SystemConstants.APP_CODE_SUCCESS == vo.getCode()) {
return Gb1400ResponseUtil.responseStatusListObject((List<JSONObject>) vo.getData());
result = Gb1400ResponseUtil.responseStatusListObject((List<JSONObject>) vo.getData());
} else {
return Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes");
result = Gb1400ResponseUtil.error(1, vo.getMsg(),"/VIID/Subscribes");
}
response.getWriter().write(result.toJSONString());
}
/**
......
......@@ -102,10 +102,10 @@ public class Gb1400ServiceImpl implements Gb1400Service {
list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "SubscribeID不能为空"));
continue;
}
if (!"50".equals(item.getString("SubscribeDetail"))) {
list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "订阅类别暂不支持"));
continue;
}
// if (!"50".equals(item.getString("SubscribeDetail"))) {
// list.add(Gb1400ResponseUtil.buildResponseStatusObject(item.getString("SubscribeDetail"), "/VIID/Subscribes", 1, "订阅类别暂不支持"));
// continue;
// }
String subscribeId = item.getString("SubscribeID");
// String subscribeDetail = item.getString("SubscribeDetail");
redisTemplate.opsForHash().put(RedisConstants.GB1400_SUBSCRIBES_HASH, subscribeId, item.toJSONString());
......@@ -147,7 +147,25 @@ public class Gb1400ServiceImpl implements Gb1400Service {
}
String notificationsData = JSONObject.toJSONString(subscribeNotificationsObj);
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(){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!