|
@@ -15,6 +15,8 @@ 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.dto.DataServersDTO;
|
|
|
+import com.jpsoft.smart.modules.lapi.dto.ServerAddrDTO;
|
|
|
import com.jpsoft.smart.modules.lapi.request.LapiRequest;
|
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
|
import com.jpsoft.smart.modules.lapi.vo.*;
|
|
@@ -72,7 +74,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("设备未绑定");
|
|
|
}
|
|
|
// JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.KEEPALIVE);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.KEEPALIVE, HttpMethod.GET,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.KEEPALIVE, HttpMethod.GET, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
return true;
|
|
@@ -165,7 +167,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
|
// 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 jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.ADDPERSON + faceDbId + "/People", HttpMethod.POST, map);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -182,20 +184,20 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),true);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
} else {
|
|
|
lapiResult.setMsg("绑定失败");
|
|
|
lapiResult.setSuccess(false);
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),false);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -211,7 +213,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
lapiResult.setMsg(e.getMessage().contains("timed out") ? "设备连接超时" : e.getMessage());
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),null);
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), null);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -293,7 +295,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
|
|
//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 jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.ADDPERSON + faceDbId + "/People", HttpMethod.POST, map);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -309,20 +311,20 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
lapiResult.setSuccess(true);
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),true);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
} else {
|
|
|
lapiResult.setMsg("绑定失败");
|
|
|
lapiResult.setSuccess(false);
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),false);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -341,7 +343,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
lapiResult.setMsg(e.getMessage().contains("timed out") ? "设备连接超时" : e.getMessage());
|
|
|
lapiResult.setData(dataMap);
|
|
|
lapiResultList.add(lapiResult);
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),null);
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), null);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -359,7 +361,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
String faceDbId = "";
|
|
|
|
|
|
//JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.GETFACEDB,HttpMethod.GET,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.GETFACEDB, HttpMethod.GET, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -403,7 +405,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
String faceDbId = "";
|
|
|
// JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.GETFACEDB,HttpMethod.GET,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.GETFACEDB, HttpMethod.GET, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -456,7 +458,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
// 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);
|
|
|
+ LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId(), HttpMethod.DELETE, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -508,7 +510,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
// 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);
|
|
|
+ LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId(), HttpMethod.DELETE, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -547,7 +549,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
|
|
|
// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REMOTEOPENED);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.REMOTEOPENED,HttpMethod.PUT,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.REMOTEOPENED, HttpMethod.PUT, null);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return true;
|
|
@@ -563,7 +565,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("设备已删除");
|
|
|
}
|
|
|
// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REBOOT);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.REBOOT,HttpMethod.PUT,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.REBOOT, HttpMethod.PUT, null);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
return true;
|
|
@@ -598,7 +600,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("Name", companyInfo.getName());
|
|
|
map.put("Type", 3);
|
|
|
//JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDLIBRARY,HttpMethod.POST, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.ADDLIBRARY, HttpMethod.POST, map);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -646,7 +648,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("Name", "默认员工库");
|
|
|
map.put("Type", 3);
|
|
|
// JSONObject jsonObject = LApiUtil.postRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDLIBRARY,HttpMethod.POST, 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");
|
|
@@ -675,7 +677,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
try {
|
|
|
// JSONObject jsonObject = LApiUtil.deleteRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryId);
|
|
|
JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),
|
|
|
- LApiConstant.DELETELIBRARY + libraryId,HttpMethod.DELETE,null);
|
|
|
+ LApiConstant.DELETELIBRARY + libraryId, HttpMethod.DELETE, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -723,7 +725,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
list.add(map1);
|
|
|
map.put("LibList", list);
|
|
|
// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY, map);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.UPDATALIBRARY,HttpMethod.PUT, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.UPDATALIBRARY, HttpMethod.PUT, map);
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
|
@@ -748,7 +750,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
|
|
|
//JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.UPDATALIBRARY,HttpMethod.GET,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.UPDATALIBRARY, HttpMethod.GET, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -762,7 +764,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
try {
|
|
|
// 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);
|
|
|
+ LApiConstant.DELETELIBRARY + libraryVo.getID(), HttpMethod.DELETE, null);
|
|
|
|
|
|
JSONObject dataJson1 = jsonObject1.getJSONObject("Response");
|
|
|
JSONObject response1 = LApiUtil.getResponse(dataJson1);
|
|
@@ -796,30 +798,30 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("QueryInfos", list);
|
|
|
try {
|
|
|
//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 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");
|
|
|
if (num > 0) {
|
|
|
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),true);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
- }else {
|
|
|
- try{
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),false);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
- personDeviceRelationService.updateIsBound(personInfo.getId(),deviceInfo.getId(),null);
|
|
|
+ personDeviceRelationService.updateIsBound(personInfo.getId(), deviceInfo.getId(), null);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -842,7 +844,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
map.put("QueryInfos", list);
|
|
|
try {
|
|
|
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.ADDPERSON + faceDbId + "/People/Info",HttpMethod.POST, 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);
|
|
@@ -854,7 +856,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
Map map2 = (Map) personInfoList.get(0);
|
|
|
|
|
|
Integer imageNum = (Integer) map2.get("ImageNum");
|
|
|
- if (imageNum>0){
|
|
|
+ if (imageNum > 0) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -879,7 +881,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
throw new Exception("设备离线,请联系管理员");
|
|
|
}
|
|
|
//JSONObject jsonObject = LApiUtil.getRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(),LApiConstant.RULE,HttpMethod.GET,null);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.RULE, HttpMethod.GET, null);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -916,7 +918,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
list.add(map1);
|
|
|
list.add(map2);
|
|
|
list.add(map3);
|
|
|
- map.put("RuleList",list);
|
|
|
+ map.put("RuleList", list);
|
|
|
if (measureTemperature == 1) {
|
|
|
HashMap<String, Object> temperatureMap = new HashMap<>();
|
|
|
temperatureMap.put("Type", type);
|
|
@@ -927,7 +929,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
}
|
|
|
|
|
|
// JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.RULE, map);
|
|
|
- JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.RULE,HttpMethod.PUT, map);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceInfo.getDeviceNo(), LApiConstant.RULE, HttpMethod.PUT, map);
|
|
|
|
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
@@ -935,5 +937,55 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean updateDeviceNo(String oldDeviceNo, String newDeviceNo) throws Exception{
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(oldDeviceNo);
|
|
|
+ DataServersDTO dataServersDTO = getDeviceDateServer(oldDeviceNo);
|
|
|
+ if (dataServersDTO !=null){
|
|
|
+ dataServersDTO.setTollgateID(newDeviceNo);
|
|
|
+ List<DataServersDTO> dataServersDTOList = new ArrayList<>();
|
|
|
+ dataServersDTOList.add(dataServersDTO);
|
|
|
+ HashMap<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Num",1);
|
|
|
+ map.put("DataServerList",dataServersDTOList);
|
|
|
+ JSONObject jsonObject = lapiRequest.send(oldDeviceNo, LApiConstant.DATASERVERS, HttpMethod.PUT, map);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+
|
|
|
+ if (dataJson.getString("ResponseString").equals("Succeed") && dataJson.getString("StatusString").equals("Succeed")){
|
|
|
+ deviceInfo.setDeviceNo(newDeviceNo);
|
|
|
+ deviceInfo.setUpdateTime(new Date());
|
|
|
+ deviceInfoService.update(deviceInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DataServersDTO getDeviceDateServer(String deviceNo) throws Exception {
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ throw new Exception("设备不存在");
|
|
|
+ }
|
|
|
+ if (!deviceInfo.getIsOnline()) {
|
|
|
+ throw new Exception("设备离线");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = lapiRequest.send(deviceNo, LApiConstant.DATASERVERS, HttpMethod.GET, null);
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
+ String s = response.getString("DataServerList");
|
|
|
+ List<DataServersDTO> dataServersDTOList = JSONObject.parseArray(s,DataServersDTO.class);
|
|
|
+ if (dataServersDTOList.size() > 0) {
|
|
|
+ for (DataServersDTO dataServersDTO : dataServersDTOList) {
|
|
|
+ if (dataServersDTO.getEnabled() > 0) {
|
|
|
+ return dataServersDTO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|