|
@@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
+import com.persagy.ibms.core.util.FastJsonUtil;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -20,109 +21,116 @@ import io.swagger.annotations.ApiModelProperty;
|
|
|
@RestController
|
|
|
public class RestApi {
|
|
|
|
|
|
- @PostMapping(path = { "/query", "/zkt-sdk/query" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String query(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.query(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/general_query", "/zkt-sdk/general_query" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String general_query(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.general_query(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/post", "/zkt-sdk/post" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String post(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String ip = RestUtil.getIp(request);
|
|
|
- RepositoryContainer.RepositoryProject.ip2param2time.putIfAbsent(ip, new ConcurrentHashMap<String, Date>());
|
|
|
- ConcurrentHashMap<String, Date> param2time = RepositoryContainer.RepositoryProject.ip2param2time.get(ip);
|
|
|
- Date exist = param2time.putIfAbsent(param, new Date());
|
|
|
- if (exist == null) {
|
|
|
- try {
|
|
|
- Object resultObject = RestUtil.post(param);
|
|
|
- String result = JSONObject.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
- return result;
|
|
|
- } finally {
|
|
|
- param2time.remove(param);
|
|
|
- }
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/post_batch", "/zkt-sdk/post_batch" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String post_batch(@RequestBody String param, HttpServletRequest request) {
|
|
|
- JSONArray resultObject = RestUtil.post_batch(JSON.parseArray(param));
|
|
|
- String result = JSONArray.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/wrapper_post", "/zkt-sdk/wrapper_post" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String wrapper_post(@RequestBody String param, HttpServletRequest request) {
|
|
|
- JSONObject paramObject = JSON.parseObject(param);
|
|
|
- String path = paramObject.get("path").toString();
|
|
|
- Object Content = RestUtil.post(path);
|
|
|
- JSONObject resultObject = new JSONObject();
|
|
|
- resultObject.put("Content", Content);
|
|
|
- String result = JSONObject.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/post_filter_and_page", "/zkt-sdk/post_filter_and_page" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String post_filter_and_page(@RequestBody String param, HttpServletRequest request) {
|
|
|
- JSONObject paramObject = JSON.parseObject(param);
|
|
|
- JSONObject result = RestUtil.post_filter_and_page(paramObject);
|
|
|
- return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/control", "/zkt-sdk/control" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String control(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.control(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/get_control_value", "/zkt-sdk/get_control_value" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String get_control_value(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.get_control_value(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/light_time_table", "/zkt-sdk/light_time_table" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String light_time_table(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = LightingUtil.light_time_table(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/subsystem_connect_status", "/zkt-sdk/subsystem_connect_status" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String subsystem_connect_status(HttpServletRequest request) {
|
|
|
- String result = RestUtil.subsystem_connect_status();
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/getEquipStaticInfo", "/zkt-sdk/getEquipStaticInfo" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String getEquipStaticInfo(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.getEquipStaticInfo(param).toJSONString();
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(path = { "/getEquipStaticInfoById", "/zkt-sdk/getEquipStaticInfoById" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String getEquipStaticInfoById(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.getEquipStaticInfoById(param).toJSONString();
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据参数获取图形URL路径
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @param request
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiModelProperty("获取图形URL路径")
|
|
|
- @PostMapping(path = { "/getUrl" }, produces = "application/json;charset=UTF-8")
|
|
|
- public String getUrl(@RequestBody String param, HttpServletRequest request) {
|
|
|
- String result = RestUtil.getAdmUrl(param);
|
|
|
- return result;
|
|
|
- }
|
|
|
+ @PostMapping(path = {"/query", "/zkt-sdk/query"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String query(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.query(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/general_query", "/zkt-sdk/general_query"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String general_query(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.general_query(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/post", "/zkt-sdk/post"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String post(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String ip = RestUtil.getIp(request);
|
|
|
+ RepositoryContainer.RepositoryProject.ip2param2time.putIfAbsent(ip, new ConcurrentHashMap<String, Date>());
|
|
|
+ ConcurrentHashMap<String, Date> param2time = RepositoryContainer.RepositoryProject.ip2param2time.get(ip);
|
|
|
+ Date exist = param2time.putIfAbsent(param, new Date());
|
|
|
+ if (exist == null) {
|
|
|
+ try {
|
|
|
+ Object resultObject = RestUtil.post(param);
|
|
|
+ String result = JSONObject.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
+ return result;
|
|
|
+ } finally {
|
|
|
+ param2time.remove(param);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/post_batch", "/zkt-sdk/post_batch"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String post_batch(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ JSONArray resultObject = RestUtil.post_batch(JSON.parseArray(param));
|
|
|
+ String result = JSONArray.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/wrapper_post", "/zkt-sdk/wrapper_post"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String wrapper_post(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ JSONObject paramObject = JSON.parseObject(param);
|
|
|
+ String path = paramObject.get("path").toString();
|
|
|
+ Object Content = RestUtil.post(path);
|
|
|
+ JSONObject resultObject = new JSONObject();
|
|
|
+ resultObject.put("Content", Content);
|
|
|
+ String result = JSONObject.toJSONString(resultObject, SerializerFeature.WriteMapNullValue);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/post_filter_and_page", "/zkt-sdk/post_filter_and_page"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String post_filter_and_page(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ JSONObject paramObject = JSON.parseObject(param);
|
|
|
+ JSONObject result = RestUtil.post_filter_and_page(paramObject);
|
|
|
+ return JSONObject.toJSONString(result, SerializerFeature.WriteMapNullValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/control", "/zkt-sdk/control"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String control(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.control(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/get_control_value", "/zkt-sdk/get_control_value"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String get_control_value(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.get_control_value(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/light_time_table", "/zkt-sdk/light_time_table"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String light_time_table(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = LightingUtil.light_time_table(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/subsystem_connect_status", "/zkt-sdk/subsystem_connect_status"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String subsystem_connect_status(HttpServletRequest request) {
|
|
|
+ String result = RestUtil.subsystem_connect_status();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/getEquipStaticInfo", "/zkt-sdk/getEquipStaticInfo"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String getEquipStaticInfo(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.getEquipStaticInfo(param).toJSONString();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(path = {"/getEquipStaticInfoById", "/zkt-sdk/getEquipStaticInfoById"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String getEquipStaticInfoById(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.getEquipStaticInfoById(param).toJSONString();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据参数获取图形URL路径
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiModelProperty("获取图形URL路径")
|
|
|
+ @PostMapping(path = {"/getUrl"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String getUrl(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.getAdmUrl(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取最近摄像头
|
|
|
+ @PostMapping(path = {"/getNearestCamera", "/zkt-sdk/getNearestCamera"}, produces = "application/json;charset=UTF-8")
|
|
|
+ public String getNearestCamera(@RequestBody String param, HttpServletRequest request) {
|
|
|
+ String result = RestUtil.getNearestCamera(param);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|