Browse Source

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 years ago
parent
commit
3ae3883065

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/constant/LApiConstant.java

@@ -63,6 +63,10 @@ public class LApiConstant {
      */
     public static final String RULE = "/LAPI/V1.0/PACS/Controller/AttributeVerification/Rule";
 
+    /**
+     * 设备服务器
+     */
+    public static final String DATASERVERS = "/LAPI/V1.0/Channels/0/System/DataServers";
 
 
 }

+ 28 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/dto/DataServersDTO.java

@@ -0,0 +1,28 @@
+package com.jpsoft.smart.modules.lapi.dto;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-9 9:29
+ * 门禁设备服务器数据dto
+ */
+@Data
+public class DataServersDTO {
+
+    private String areaId;
+    private String cameraID;
+    private String deviceID;
+    private String directionID;
+    private String drivewayID;
+    private Integer enabled;
+    private Integer index;
+    private Integer protocol;
+    private ServerAddrDTO serverAddr;
+    private Integer subProtocol;
+    private String tollgateID;
+    private String userName;
+
+
+
+}

+ 14 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/dto/ServerAddrDTO.java

@@ -0,0 +1,14 @@
+package com.jpsoft.smart.modules.lapi.dto;
+
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2020-4-9 9:33
+ */
+@Data
+public class ServerAddrDTO {
+
+    private String address;
+    private Integer port;
+}

+ 18 - 1
common/src/main/java/com/jpsoft/smart/modules/lapi/service/ILapiService.java

@@ -2,6 +2,8 @@ package com.jpsoft.smart.modules.lapi.service;
 
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.lapi.dto.DataServersDTO;
+import com.jpsoft.smart.modules.lapi.dto.ServerAddrDTO;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiResult;
 import com.sun.org.apache.xpath.internal.operations.Bool;
@@ -139,7 +141,7 @@ public interface ILapiService {
     Boolean isSuccessAddPerson(PersonInfo personInfo, DeviceInfo deviceInfo, String faceDbId);
 
     /**
-     * 人员是否成功写入设备
+     * 人员照片是否存在设备
      * @param
      * @return
      */
@@ -169,5 +171,20 @@ public interface ILapiService {
      */
     Boolean setDeviceRule(String deviceInfoId, Integer needCap, Integer needMask, Integer measureTemperature, Integer type, BigDecimal minTemper,BigDecimal maxTemper,BigDecimal alarmThreshold) throws Exception;
 
+    /**
+     * 修改设备的设备序列号
+     * @param oldDeviceNo
+     * @param newDeviceNo
+     * @return
+     */
+    Boolean updateDeviceNo(String oldDeviceNo,String newDeviceNo) throws Exception;
+
+    /**
+     * 获取设备的服务器信息
+     * @param deviceNo
+     * @return
+     */
+    DataServersDTO getDeviceDateServer(String deviceNo) throws Exception;
+
 
 }

+ 101 - 49
common/src/main/java/com/jpsoft/smart/modules/lapi/service/impl/LapiServiceImpl.java

@@ -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;
+    }
+
 
 }

+ 6 - 0
web/src/main/java/com/jpsoft/smart/modules/wechat/controller/WxCpController.java

@@ -2,6 +2,7 @@ package com.jpsoft.smart.modules.wechat.controller;
 
 import com.jpsoft.smart.config.WxCpConfig;
 import com.jpsoft.smart.config.WxCpConfiguration;
+import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.cp.api.WxCpService;
@@ -25,6 +26,9 @@ public class WxCpController {
     @Autowired
     private WxCpConfig wxCpConfig;
 
+    @Autowired
+    private ILapiService lapiService;
+
 
     @ApiOperation(value = "验证服务器地址的有效性")
     @GetMapping(produces = "text/plain;charset=utf-8")
@@ -96,4 +100,6 @@ public class WxCpController {
     }
 
 
+
+
 }

+ 13 - 0
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -272,6 +272,19 @@ public class LApiTest {
 
     }
 
+    @Test
+    public void testGetDeviceDateServer(){
+        try {
+
+            lapiService.getDeviceDateServer("210235C4C53203006756");
+
+            System.out.println("11");
+        } catch (Exception e) {
+            e.printStackTrace();
+            String message = e.getMessage();
+        }
+
+    }
 
 
 }