|
@@ -2,6 +2,7 @@ package com.jpsoft.smart.modules.lapi.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.jpsoft.smart.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.smart.modules.base.entity.DeviceInfo;
|
|
|
import com.jpsoft.smart.modules.base.entity.PersonDeviceRelation;
|
|
@@ -13,8 +14,10 @@ import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.utils.LApiUtil;
|
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.smart.modules.constant.LApiConstant;
|
|
|
+import com.jpsoft.smart.modules.lapi.request.LapiRequest;
|
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
|
import com.jpsoft.smart.modules.lapi.vo.*;
|
|
|
+import io.netty.handler.codec.http.HttpMethod;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -30,8 +33,6 @@ import java.util.*;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class LapiServiceImpl implements ILapiService {
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
private DeviceInfoService deviceInfoService;
|
|
|
|
|
@@ -44,9 +45,13 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
@Autowired
|
|
|
private CompanyInfoService companyInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LapiRequest lapiRequest;
|
|
|
+
|
|
|
@Override
|
|
|
public DeviceInfo findByIpAddressAndPort(String ipAddress, String port) throws Exception {
|
|
|
JSONObject jsonObject = LApiUtil.getRequest(ipAddress + ":" + port + LApiConstant.DEVICEBASICINFO);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
@@ -65,7 +70,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (deviceInfo == null) {
|
|
|
throw new Exception("设备未绑定");
|
|
|
}
|
|
|
- JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.KEEPALIVE);
|
|
|
+// JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.KEEPALIVE);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.KEEPALIVE, HttpMethod.GET,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
return true;
|
|
|
}
|
|
@@ -155,7 +162,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
//获取人员人脸库id
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
|
- JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
|
+// JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDPERSON + faceDbId + "/People",HttpMethod.POST,map);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -268,7 +277,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
//获取人员人脸库id
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
|
- JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
|
+ //JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDPERSON + faceDbId + "/People",HttpMethod.POST,map);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -320,7 +331,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("公司名称为空");
|
|
|
}
|
|
|
String faceDbId = "";
|
|
|
- JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
+
|
|
|
+ //JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.GETFACEDB,HttpMethod.GET,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List listData = response.getJSONArray("LibList");
|
|
@@ -362,7 +376,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("公司名称为空");
|
|
|
}
|
|
|
String faceDbId = "";
|
|
|
- JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
+// JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.GETFACEDB,HttpMethod.GET,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List listData = response.getJSONArray("LibList");
|
|
@@ -411,7 +427,11 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
try {
|
|
|
//获取人员人脸库id
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
- JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId() + "?LastChange=" + new Date().getTime());
|
|
|
+// JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId() + "?LastChange=" + new Date().getTime());
|
|
|
+
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),
|
|
|
+ LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId(),HttpMethod.DELETE,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -459,7 +479,11 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
DeviceInfo deviceInfo = deviceInfoService.get(deviceId);
|
|
|
try {
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
- JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId() + "?LastChange=" + new Date().getTime());
|
|
|
+// JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId() + "?LastChange=" + new Date().getTime());
|
|
|
+
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),
|
|
|
+ LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId(),HttpMethod.DELETE,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -496,7 +520,8 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("设备已删除");
|
|
|
}
|
|
|
|
|
|
- JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REMOTEOPENED);
|
|
|
+// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REMOTEOPENED);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.REMOTEOPENED,HttpMethod.PUT,null);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return true;
|
|
@@ -511,7 +536,8 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (deviceInfo.getDelFlag()) {
|
|
|
throw new Exception("设备已删除");
|
|
|
}
|
|
|
- JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REBOOT);
|
|
|
+// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REBOOT);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.REBOOT,HttpMethod.PUT,null);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return true;
|
|
@@ -545,7 +571,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("MemberNum", 0);
|
|
|
map.put("Name", companyInfo.getName());
|
|
|
map.put("Type", 3);
|
|
|
- JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
+ //JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDLIBRARY,HttpMethod.POST, map);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
lapiResult.setMsg("添加成功");
|
|
@@ -591,7 +619,8 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("MemberNum", 0);
|
|
|
map.put("Name", "默认员工库");
|
|
|
map.put("Type", 3);
|
|
|
- JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
+// JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDLIBRARY,HttpMethod.POST, map);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return response.getString("ID");
|
|
@@ -618,7 +647,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
LapiResult lapiResult = new LapiResult();
|
|
|
try {
|
|
|
- JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryId);
|
|
|
+// JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryId);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),
|
|
|
+ LApiConstant.DELETELIBRARY + libraryId,HttpMethod.DELETE,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
lapiResult.setSuccess(true);
|
|
@@ -664,7 +696,8 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map1.put("BelongIndex", "");
|
|
|
list.add(map1);
|
|
|
map.put("LibList", list);
|
|
|
- JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY, map);
|
|
|
+// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.UPDATALIBRARY,HttpMethod.PUT, map);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
|
@@ -687,7 +720,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (deviceInfo == null) {
|
|
|
throw new Exception("设备不存在");
|
|
|
}
|
|
|
- JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY);
|
|
|
+
|
|
|
+ //JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.UPDATALIBRARY,HttpMethod.GET,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List<LibraryVo> list = JSONObject.parseArray(response.getString("LibList"), LibraryVo.class);
|
|
@@ -698,7 +734,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
for (LibraryVo libraryVo : list) {
|
|
|
LapiResult lapiResult = new LapiResult();
|
|
|
try {
|
|
|
- JSONObject jsonObject1 = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryVo.getID());
|
|
|
+// JSONObject jsonObject1 = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryVo.getID());
|
|
|
+ JSONObject jsonObject1 = lapiRequest.send(deviceInfo.getDeviceNo(),
|
|
|
+ LApiConstant.DELETELIBRARY + libraryVo.getID(),HttpMethod.DELETE,null);
|
|
|
+
|
|
|
JSONObject dataJson1 = jsonObject1.getJSONObject("Response");
|
|
|
JSONObject response1 = LApiUtil.getResponse(dataJson1);
|
|
|
lapiResult.setSuccess(true);
|
|
@@ -730,7 +769,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
list.add(map1);
|
|
|
map.put("QueryInfos", list);
|
|
|
try {
|
|
|
- JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People/Info", map);
|
|
|
+ //JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People/Info", map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDPERSON + faceDbId + "/People/Info",HttpMethod.POST, map);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
Integer num = response.getInteger("Total");
|
|
@@ -756,7 +797,9 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (!deviceInfo.getIsOnline()) {
|
|
|
throw new Exception("设备离校,请联系管理员");
|
|
|
}
|
|
|
- JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE);
|
|
|
+ //JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.RULE,HttpMethod.GET,null);
|
|
|
+
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return response;
|
|
@@ -802,13 +845,13 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("TemperatureRule", temperatureMap);
|
|
|
}
|
|
|
|
|
|
+// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.RULE,HttpMethod.PUT, map);
|
|
|
|
|
|
- JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE, map);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
- return true;
|
|
|
-
|
|
|
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|