Pārlūkot izejas kodu

添加根据设备删除人脸信息

M墨鱼—_mo 5 gadi atpakaļ
vecāks
revīzija
ce7cbdf8a1

+ 2 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -143,7 +143,8 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
                 if (deviceInfo == null){
                     throw new Exception(personDeviceLog.getDeviceNo()+"设备不存在");
                 }
-                WechatMessageUtil.sendTemperatureAlarmInfo("oLowyuBJaAJvuOkzrEm5078SJQDA",companyInfo.getName()+"_"+deviceInfo.getAliasName(),wxConfig.getAppId(),wxConfig.getAppSecret(),"Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
+
+                WechatMessageUtil.sendTemperatureAlarmInfo("oLowyuM2vn3HHZU6NvYSNoLoeZcc",companyInfo.getName()+"_"+deviceInfo.getAliasName(),wxConfig.getAppId(),wxConfig.getAppSecret(),"Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
             }
 
         } catch (Exception e) {

+ 0 - 4
common/src/main/java/com/jpsoft/smart/modules/common/utils/WechatMessageUtil.java

@@ -18,10 +18,6 @@ public class WechatMessageUtil {
 
 	public static final String send_template = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";
 
-
-
-
-
 	private static final String TEMPLATE_REDIRECT_PRE_URL = "http://wuyeopenlocktest-wecat.sudaonline.net";
 
 	private static final String TEMPERATURE_ALARM_PRE_URL = "http://wisdomhousewechat.sudaonline.net/123.jpg";

+ 12 - 0
common/src/main/java/com/jpsoft/smart/modules/lapi/service/ILapiService.java

@@ -51,6 +51,16 @@ public interface ILapiService {
      */
     List<LapiMsgResult> deletePerson(Long id) throws Exception;
 
+
+    /**
+     * 根据设备编码和人员id删除数据
+     * @param id 人员id
+     * @param deviceIds 设备id(多个以逗号隔开)
+     * @return
+     * @throws Exception
+     */
+    List<LapiMsgResult> deleteDevicePerson(Long id,String deviceIds) throws Exception;
+
     /**
      * 远程手机开门
      * @param deviceInfoId
@@ -109,4 +119,6 @@ public interface ILapiService {
 
 
 
+
+
 }

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

@@ -229,7 +229,53 @@ public class LapiServiceImpl implements ILapiService {
 
             } catch (Exception e) {
 
-                log.error(e.getMessage());
+                log.error(e.getMessage(),e);
+                LapiMsgResult lapiMsgResult = new LapiMsgResult();
+                lapiMsgResult.setPersonName(personInfo.getName());
+                lapiMsgResult.setSuccess(false);
+                lapiMsgResult.setMsg(e.getMessage());
+                lapiMsgResult.setAliasName(deviceInfo.getAliasName());
+                lapiMsgResults.add(lapiMsgResult);
+
+            }
+
+
+        }
+
+        return lapiMsgResults;
+    }
+
+    @Override
+    public List<LapiMsgResult> deleteDevicePerson(Long id,String deviceIds) throws Exception {
+        if (StringUtils.isBlank(deviceIds)){
+            throw new Exception("相关设备不能为空");
+        }
+        PersonInfo personInfo = personInfoService.get(id);
+        if (personInfo == null){
+            throw new Exception("人员信息不存在");
+        }
+        CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+        if (companyInfo == null){
+            throw new Exception("人员没有相应公司");
+        }
+        List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
+        List<String> deviceIdList = Arrays.asList(deviceIds.split(","));
+        for (String deviceId:deviceIdList ){
+            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 dataJson = jsonObject.getJSONObject("Response");
+                JSONObject response = LApiUtil.getResponse(dataJson);
+                if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
+                    LapiMsgResult lapiMsgResult = new LapiMsgResult();
+                    lapiMsgResult.setPersonName(personInfo.getName());
+                    lapiMsgResult.setSuccess(true);
+                    lapiMsgResult.setAliasName(deviceInfo.getAliasName());
+                    lapiMsgResults.add(lapiMsgResult);
+                }
+            }catch (Exception e){
+                log.error(e.getMessage(),e);
                 LapiMsgResult lapiMsgResult = new LapiMsgResult();
                 lapiMsgResult.setPersonName(personInfo.getName());
                 lapiMsgResult.setSuccess(false);

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

@@ -76,6 +76,18 @@ public class LApiTest {
 
     }
 
+    @Test
+    public void testDeletDevicePerson(){
+        try {
+            List<LapiMsgResult> result = lapiService.deleteDevicePerson(10013L,"9f254a38-2b6c-4169-a53c-765ec5e16c51");
+            System.out.println(result);
+        } catch (Exception e) {
+            e.printStackTrace();
+            String message = e.getMessage();
+        }
+
+    }
+
     @Test
     public void testRemoteOpened(){
         try {