|
@@ -20,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -45,7 +46,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
@Override
|
|
|
public DeviceInfo findByIpAddressAndPort(String ipAddress, String port) throws Exception {
|
|
|
- JSONObject jsonObject = LApiUtil.GetRequest(ipAddress + ":" + port + LApiConstant.DEVICEBASICINFO);
|
|
|
+ JSONObject jsonObject = LApiUtil.getRequest(ipAddress + ":" + port + LApiConstant.DEVICEBASICINFO);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
@@ -64,7 +65,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
return true;
|
|
|
}
|
|
@@ -120,7 +121,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
HashMap<String, Object> map3 = new HashMap<>();
|
|
|
|
|
|
|
|
|
- if (StringUtils.isNotBlank(base64Data)){
|
|
|
+ if (StringUtils.isNotBlank(base64Data)) {
|
|
|
|
|
|
Integer imageSize = base64Data.length();
|
|
|
//照片字节大小
|
|
@@ -133,8 +134,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map3.put("Data", base64Data);
|
|
|
map3.put("FaceID", personInfo.getId());
|
|
|
map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
map1.put("ImageNum", 0);
|
|
|
map3.put("FaceID", 0);
|
|
|
map3.put("Name", "");
|
|
@@ -152,11 +152,10 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("PersonInfoList", listMap1);
|
|
|
|
|
|
|
|
|
-
|
|
|
//获取人员人脸库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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -235,8 +234,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
HashMap<String, Object> map3 = new HashMap<>();
|
|
|
|
|
|
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(base64Data)){
|
|
|
+ if (StringUtils.isNotBlank(base64Data)) {
|
|
|
map1.put("ImageNum", 1L);
|
|
|
//照片base64长度
|
|
|
Integer imageSize = base64Data.length();
|
|
@@ -251,8 +249,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
|
|
|
throw new Exception("人员照片大小限定为10k~512k");
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
map1.put("ImageNum", 0);
|
|
|
map3.put("FaceID", 0);
|
|
|
map3.put("Name", "");
|
|
@@ -271,7 +268,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -323,7 +320,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List listData = response.getJSONArray("LibList");
|
|
@@ -365,7 +362,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List listData = response.getJSONArray("LibList");
|
|
@@ -414,7 +411,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -462,7 +459,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
@@ -548,7 +545,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
lapiResult.setMsg("添加成功");
|
|
@@ -594,7 +591,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return response.getString("ID");
|
|
@@ -621,7 +618,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
lapiResult.setSuccess(true);
|
|
@@ -690,7 +687,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
List<LibraryVo> list = JSONObject.parseArray(response.getString("LibList"), LibraryVo.class);
|
|
@@ -701,7 +698,7 @@ 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 dataJson1 = jsonObject1.getJSONObject("Response");
|
|
|
JSONObject response1 = LApiUtil.getResponse(dataJson1);
|
|
|
lapiResult.setSuccess(true);
|
|
@@ -733,7 +730,7 @@ 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 dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
Integer num = response.getInteger("Total");
|
|
@@ -749,5 +746,70 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getDeviceRule(String deviceInfoId) throws Exception {
|
|
|
+
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ throw new Exception("设备不存在");
|
|
|
+ }
|
|
|
+ if (!deviceInfo.getIsOnline()) {
|
|
|
+ throw new Exception("设备离校,请联系管理员");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean setDeviceRule(String deviceInfoId, Integer needCap, Integer needMask, Integer measureTemperature, Integer type, BigDecimal minTemper, BigDecimal maxTemper, BigDecimal alarmThreshold) throws Exception {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ throw new Exception("设备不存在");
|
|
|
+ }
|
|
|
+ if (!deviceInfo.getIsOnline()) {
|
|
|
+ throw new Exception("设备离校,请联系管理员");
|
|
|
+ }
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("Num", 3);
|
|
|
+ List list = new ArrayList();
|
|
|
+ //安全帽数据
|
|
|
+ HashMap<String, Object> map1 = new HashMap<>();
|
|
|
+ map1.put("DoorOpenMode", 0);
|
|
|
+ map1.put("Mode", 1);
|
|
|
+ map1.put("Enabled", needCap);
|
|
|
+ //口罩数据
|
|
|
+ HashMap<String, Object> map2 = new HashMap<>();
|
|
|
+ map2.put("DoorOpenMode", 0);
|
|
|
+ map2.put("Mode", 2);
|
|
|
+ map2.put("Enabled", needMask);
|
|
|
+ //测温数据
|
|
|
+ HashMap<String, Object> map3 = new HashMap<>();
|
|
|
+ map3.put("DoorOpenMode", 0);
|
|
|
+ map3.put("Mode", 3);
|
|
|
+ map3.put("Enabled", measureTemperature);
|
|
|
+ list.add(map1);
|
|
|
+ list.add(map2);
|
|
|
+ list.add(map3);
|
|
|
+ map.put("RuleList",list);
|
|
|
+ if (measureTemperature == 1) {
|
|
|
+ HashMap<String, Object> temperatureMap = new HashMap<>();
|
|
|
+ temperatureMap.put("Type", type);
|
|
|
+ temperatureMap.put("Minimum", minTemper);
|
|
|
+ temperatureMap.put("Maximum", maxTemper);
|
|
|
+ temperatureMap.put("AlarmThreshold", alarmThreshold);
|
|
|
+ map.put("TemperatureRule", temperatureMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE, map);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+ return true;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|