Browse Source

更新门锁报错

liu 1 year ago
parent
commit
596fdb13a8

+ 63 - 20
src/main/java/com/template/controller/PasswordIssController.java

@@ -192,6 +192,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             Unlocking unlocking = new Unlocking();
             Unlocking unlocking = new Unlocking();
 //            锁用户id
 //            锁用户id
@@ -217,9 +221,8 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
     }
     }
 
 
     /**
     /**
@@ -239,6 +242,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             Unlocking unlocking = new Unlocking();
             Unlocking unlocking = new Unlocking();
 //            锁用户id
 //            锁用户id
@@ -260,9 +267,8 @@ public class PasswordIssController {
             return unlocking;
             return unlocking;
 
 
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
     }
     }
 
 
     /**
     /**
@@ -282,6 +288,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             String temporaryPassword = data.getString("temporaryPassword");
             String temporaryPassword = data.getString("temporaryPassword");
             String passWord = AesUtils.decrypt(temporaryPassword, pr.getLuid());
             String passWord = AesUtils.decrypt(temporaryPassword, pr.getLuid());
@@ -304,9 +314,8 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
     }
     }
 
 
     /**
     /**
@@ -339,6 +348,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             String temporaryPassword = data.getString("temporaryPassword");
             String temporaryPassword = data.getString("temporaryPassword");
             String passWord2 = AesUtils.decrypt(temporaryPassword, luid);
             String passWord2 = AesUtils.decrypt(temporaryPassword, luid);
@@ -356,9 +369,8 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
 
 
 
 
     }
     }
@@ -388,6 +400,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             UnlockingAdmin unlocking = new UnlockingAdmin();
             UnlockingAdmin unlocking = new UnlockingAdmin();
 //            锁用户id
 //            锁用户id
@@ -408,9 +424,9 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
+
     }
     }
 
 
     /**
     /**
@@ -437,6 +453,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             UnlockingAdmin unlocking = new UnlockingAdmin();
             UnlockingAdmin unlocking = new UnlockingAdmin();
 //            锁用户id
 //            锁用户id
@@ -451,9 +471,9 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
+
     }
     }
 
 
     /**
     /**
@@ -498,10 +518,14 @@ public class PasswordIssController {
         String jsonContent = JSONObject.toJSONString(map);
         String jsonContent = JSONObject.toJSONString(map);
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.DeleteLockUser.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.DeleteLockUser.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
 //            System.out.println("jsonObject = " + jsonObject);
 //            System.out.println("jsonObject = " + jsonObject);
 //            return jsonObject;
 //            return jsonObject;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
 //        return null;
 //        return null;
     }
     }
@@ -568,6 +592,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Password.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             String temporaryPassword = data.getString("temporaryPassword");
             String temporaryPassword = data.getString("temporaryPassword");
             String passWord2 = AesUtils.decrypt(temporaryPassword, luid);
             String passWord2 = AesUtils.decrypt(temporaryPassword, luid);
@@ -585,9 +613,9 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
+
 
 
     }
     }
 
 
@@ -613,6 +641,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Card_Info.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             UnlockingCustom unlocking = new UnlockingCustom();
             UnlockingCustom unlocking = new UnlockingCustom();
 //            锁用户id
 //            锁用户id
@@ -632,9 +664,8 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
     }
     }
 
 
     public UnlockingCustom addCustomFingerprintDto(CustomKeyFingerprintDto dto) {
     public UnlockingCustom addCustomFingerprintDto(CustomKeyFingerprintDto dto) {
@@ -658,6 +689,10 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.Fingerprint_Data.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             UnlockingCustom unlocking = new UnlockingCustom();
             UnlockingCustom unlocking = new UnlockingCustom();
 //            锁用户id
 //            锁用户id
@@ -672,9 +707,9 @@ public class PasswordIssController {
 
 
             return unlocking;
             return unlocking;
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return null;
+
 
 
     }
     }
 
 
@@ -688,6 +723,10 @@ public class PasswordIssController {
         String jsonContent = JSONObject.toJSONString(map);
         String jsonContent = JSONObject.toJSONString(map);
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.SetNFC.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.SetNFC.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             String data = jsonObject.getString("data");
             String data = jsonObject.getString("data");
             System.out.println("data = " + data);
             System.out.println("data = " + data);
         } catch (Exception e) {
         } catch (Exception e) {
@@ -712,10 +751,14 @@ public class PasswordIssController {
 
 
         try {
         try {
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.ModifyPassword.getUrl());
             JSONObject jsonObject = queryData(jsonContent, PasswordUrlEnum.ModifyPassword.getUrl());
+            String result = jsonObject.getString("result");
+            if (!"1".equals(result)) {
+                throw new RuntimeException(jsonObject.getString("message"));
+            }
             JSONObject data = jsonObject.getJSONObject("data");
             JSONObject data = jsonObject.getJSONObject("data");
             System.out.println("data = " + data);
             System.out.println("data = " + data);
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
 
 
     }
     }

+ 9 - 5
src/main/java/com/template/controller/UnlockingAdminController.java

@@ -172,10 +172,12 @@ public class UnlockingAdminController implements UnlockingAdminControllerAPI {
         try {
         try {
             unlockingAdmin = passwordIssController.addCard(keyCardDto);
             unlockingAdmin = passwordIssController.addCard(keyCardDto);
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+//            e.printStackTrace();
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
             unlockingAdmin.setName(byId.getName());
             unlockingAdmin.setName(byId.getName());
             unlockingAdmin.setPhone(byId.getPhoneNumber());
             unlockingAdmin.setPhone(byId.getPhoneNumber());
@@ -242,9 +244,11 @@ public class UnlockingAdminController implements UnlockingAdminControllerAPI {
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
 
 
             unlockingAdmin.setName(byId.getName());
             unlockingAdmin.setName(byId.getName());

+ 13 - 7
src/main/java/com/template/controller/UnlockingCustomController.java

@@ -113,10 +113,12 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
             operatingRecordService.save(operatingRecord);
             operatingRecordService.save(operatingRecord);
             return CommonResult.ok();
             return CommonResult.ok();
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+//            e.printStackTrace();
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+           return CommonResult.fail(e.getMessage());
         }
         }
 
 
     }
     }
@@ -172,8 +174,10 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
     }
     }
 
 
@@ -227,8 +231,10 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
     }
     }
 
 

+ 12 - 6
src/main/java/com/template/controller/UnlockingEmployeeController.java

@@ -106,9 +106,11 @@ public class UnlockingEmployeeController implements UnlockingEmployeeControllerA
             unlockingEmployeeService.save(unlockingEmployee);
             unlockingEmployeeService.save(unlockingEmployee);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
 //        添加操作记录
 //        添加操作记录
 
 
@@ -186,9 +188,11 @@ public class UnlockingEmployeeController implements UnlockingEmployeeControllerA
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }
 
 
 //        添加操作记录
 //        添加操作记录
@@ -261,8 +265,10 @@ public class UnlockingEmployeeController implements UnlockingEmployeeControllerA
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
 //            删除锁
 //            删除锁
-            passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
-            return CommonResult.fail();
+            if (ObjectUtils.isNotEmpty(unlockingAdmin)) {
+                passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
+            }
+            return CommonResult.fail(e.getMessage());
         }
         }