|
@@ -1,10 +1,16 @@
|
|
|
package com.usky.agbox.service.job;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.usky.agbox.domain.PatrolInspectionAgbox;
|
|
|
+import com.usky.agbox.service.PatrolInspectionAgboxService;
|
|
|
import com.usky.agbox.service.util.HttpClientUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
public class patrolAgbox {
|
|
@@ -14,15 +20,29 @@ public class patrolAgbox {
|
|
|
@Value("${agBox.url}")
|
|
|
private String URL;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PatrolInspectionAgboxService patrolInspectionAgboxService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取推送配置信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<PatrolInspectionAgbox> getAgBox() {
|
|
|
+ LambdaQueryWrapper<PatrolInspectionAgbox> lambdaQuery = Wrappers.lambdaQuery();
|
|
|
+ List<PatrolInspectionAgbox> list = patrolInspectionAgboxService.list(lambdaQuery);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取事件编码信息
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getEventCode() {
|
|
|
+ List<PatrolInspectionAgbox> list = this.getAgBox();
|
|
|
HashMap map = new HashMap();
|
|
|
- map.put("key", KEY);
|
|
|
+ map.put("key", list.get(0).getAgboxKey());
|
|
|
map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getPatrolEventCode\"}");
|
|
|
- String resultString = HttpClientUtils.doPost(URL,map);
|
|
|
+ String resultString = HttpClientUtils.doPost(list.get(0).getAgboxUrl(),map);
|
|
|
JSONObject resultVO = JSONObject.parseObject(resultString);
|
|
|
return resultVO;
|
|
|
}
|
|
@@ -32,10 +52,11 @@ public class patrolAgbox {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getDeviceList() {
|
|
|
+ List<PatrolInspectionAgbox> list = this.getAgBox();
|
|
|
HashMap map = new HashMap();
|
|
|
- map.put("key", KEY);
|
|
|
+ map.put("key", list.get(0).getAgboxKey());
|
|
|
map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getDeviceList\"}");
|
|
|
- String resultString = HttpClientUtils.doPost(URL,map);
|
|
|
+ String resultString = HttpClientUtils.doPost(list.get(0).getAgboxUrl(),map);
|
|
|
JSONObject resultVO = JSONObject.parseObject(resultString);
|
|
|
return resultVO;
|
|
|
}
|
|
@@ -45,13 +66,14 @@ public class patrolAgbox {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject addEvent(String requestBody) {
|
|
|
+ List<PatrolInspectionAgbox> list = this.getAgBox();
|
|
|
JSONObject eventVO = JSONObject.parseObject(requestBody);
|
|
|
HashMap map = new HashMap();
|
|
|
- map.put("key", KEY);
|
|
|
+ map.put("key", list.get(0).getAgboxKey());
|
|
|
map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"addEvent\",\"params\":{\"deviceId\":\""+eventVO.get("deviceId").toString()+"\"," +
|
|
|
"\"triggerTime\":\""+eventVO.get("triggerTime").toString()+"\",\"eventCode\":"+eventVO.get("eventCode")+",\"name" +
|
|
|
"\":\""+eventVO.get("name").toString()+"\",\"certifiedNo\":\""+eventVO.get("certifiedNo").toString()+"\"}}");
|
|
|
- String resultString = HttpClientUtils.doPost(URL,map);
|
|
|
+ String resultString = HttpClientUtils.doPost(list.get(0).getAgboxUrl(),map);
|
|
|
JSONObject resultVO = JSONObject.parseObject(resultString);
|
|
|
return resultVO;
|
|
|
}
|
|
@@ -61,12 +83,13 @@ public class patrolAgbox {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject updateHeart(String requestBody) {
|
|
|
+ List<PatrolInspectionAgbox> list = this.getAgBox();
|
|
|
JSONObject eventVO = JSONObject.parseObject(requestBody);
|
|
|
HashMap map = new HashMap();
|
|
|
- map.put("key", KEY);
|
|
|
+ map.put("key", list.get(0).getAgboxKey());
|
|
|
map.put("json",
|
|
|
"{\"jsonrpc\":\"2.0\",\"method\":\"updateHeart\",\"params\":{\"deviceId\":\""+eventVO.get("deviceId").toString()+"\"}}");
|
|
|
- String resultString = HttpClientUtils.doPost(URL,map);
|
|
|
+ String resultString = HttpClientUtils.doPost(list.get(0).getAgboxUrl(),map);
|
|
|
JSONObject resultVO = JSONObject.parseObject(resultString);
|
|
|
return resultVO;
|
|
|
}
|
|
@@ -76,11 +99,12 @@ public class patrolAgbox {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getEvent(String requestBody) {
|
|
|
+ List<PatrolInspectionAgbox> list = this.getAgBox();
|
|
|
JSONObject eventVO = JSONObject.parseObject(requestBody);
|
|
|
HashMap map = new HashMap();
|
|
|
- map.put("key", KEY);
|
|
|
+ map.put("key", list.get(0).getAgboxKey());
|
|
|
map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getEvent\",\"params\":{\"eventId\":\""+eventVO.get("eventId").toString()+"\"}}");
|
|
|
- String resultString = HttpClientUtils.doPost(URL,map);
|
|
|
+ String resultString = HttpClientUtils.doPost(list.get(0).getAgboxUrl(),map);
|
|
|
JSONObject resultVO = JSONObject.parseObject(resultString);
|
|
|
return resultVO;
|
|
|
}
|