|
@@ -1,5 +1,8 @@
|
|
|
package com.persagy.ibms.data.sdk.service.rest;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -11,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import com.persagy.ibms.data.sdk.util.RepositoryBase;
|
|
|
import com.persagy.ibms.data.sdk.util.ToolUtil;
|
|
|
import com.persagy.ibms.data.sdk.websocket.AlarmWebSocketClient;
|
|
|
import com.persagy.ibms.data.sdk.websocket.IOTWebSocketClient;
|
|
@@ -89,8 +93,19 @@ public class RestApi {
|
|
|
public String post(@RequestBody String param, HttpServletRequest request) {
|
|
|
String ip = RestUtil.getIp(request);
|
|
|
log.info("ip:" + ip + " || post: " + param);
|
|
|
- String result = RestUtil.post(param);
|
|
|
- return result;
|
|
|
+ RepositoryBase.ip2param2time.putIfAbsent(ip, new ConcurrentHashMap<String, Date>());
|
|
|
+ ConcurrentHashMap<String, Date> param2time = RepositoryBase.ip2param2time.get(ip);
|
|
|
+ if (!param2time.containsKey(param)) {
|
|
|
+ param2time.put(param, new Date());
|
|
|
+ try {
|
|
|
+ String result = RestUtil.post(param);
|
|
|
+ return result;
|
|
|
+ } finally {
|
|
|
+ param2time.remove(param);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@PostMapping(path = { "/post_filter_and_page", "/zkt-sdk/post_filter_and_page" }, produces = "application/json;charset=UTF-8")
|
|
@@ -130,7 +145,7 @@ public class RestApi {
|
|
|
}
|
|
|
|
|
|
@PostMapping(path = { "/getEquipStaticInfo", "/zkt-sdk/getEquipStaticInfo" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String getEquipStaticInfo(@RequestBody String param){
|
|
|
+ public String getEquipStaticInfo(@RequestBody String param) {
|
|
|
String result = RestUtil.getEquipStaticInfo(param).toJSONString();
|
|
|
return result;
|
|
|
}
|