Browse Source

删除人脸 不写Excel

jz.kai 5 years ago
parent
commit
28b67d1318

+ 50 - 51
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -282,19 +282,20 @@ public class PersonInfoController {
             personInfo.setFaceEnabled(false);
             personInfo.setFaceEnabled(false);
 
 
             int affectCount = personInfoService.update(personInfo);
             int affectCount = personInfoService.update(personInfo);
-
-            HSSFWorkbook workbook = new HSSFWorkbook();
-            HSSFSheet sheet = workbook.createSheet();
-            if(!deleteDevicePerson(id, sheet)){
-                ByteArrayOutputStream output = new ByteArrayOutputStream();
-                workbook.write(output);
-                byte[] buffer = output.toByteArray();
-                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
-                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
-
-                msgResult.setData(false);
-                msgResult.setMessage(downloadUrl);
-            }
+            lapiService.deletePerson(personInfo.getId());
+
+//            HSSFWorkbook workbook = new HSSFWorkbook();
+//            HSSFSheet sheet = workbook.createSheet();
+//            if(!deleteDevicePerson(personInfo, sheet)){
+//                ByteArrayOutputStream output = new ByteArrayOutputStream();
+//                workbook.write(output);
+//                byte[] buffer = output.toByteArray();
+//                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+//                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+//
+//                msgResult.setData(false);
+//                msgResult.setMessage(downloadUrl);
+//            }
 
 
             if (affectCount > 0) {
             if (affectCount > 0) {
                 msgResult.setResult(true);
                 msgResult.setResult(true);
@@ -334,23 +335,24 @@ public class PersonInfoController {
                 personInfo.setFaceEnabled(false);
                 personInfo.setFaceEnabled(false);
 
 
                 affectCount += personInfoService.update(personInfo);
                 affectCount += personInfoService.update(personInfo);
-
-                ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
-                for (int i = 0; i < 10; i++) {
-                    final int index = i;
-                    try {
-                        Thread.sleep(index * 1000);
-                    } catch (InterruptedException e) {
-                        e.printStackTrace();
-                    }
-                    cachedThreadPool.execute(new Runnable() {
-                        public void run() {
-                            if(!deleteDevicePerson(id, sheet)){
-                                msgResult.setData(false);
-                            }
-                        }
-                    });
-                }
+                lapiService.deletePerson(personInfo.getId());
+
+//                ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
+//                for (int i = 0; i < 10; i++) {
+//                    final int index = i;
+//                    try {
+//                        Thread.sleep(index * 1000);
+//                    } catch (InterruptedException e) {
+//                        e.printStackTrace();
+//                    }
+//                    cachedThreadPool.execute(new Runnable() {
+//                        public void run() {
+//                            if(!deleteDevicePerson(personInfo, sheet)){
+//                                msgResult.setData(false);
+//                            }
+//                        }
+//                    });
+//                }
             }
             }
 
 
             if (affectCount > 0) {
             if (affectCount > 0) {
@@ -507,9 +509,10 @@ public class PersonInfoController {
                     throw new Exception("人员信息不存在!");
                     throw new Exception("人员信息不存在!");
                 }
                 }
 
 
-                if(!deleteDevicePerson(id, sheet)){
-                    msgResult.setData(false);
-                }
+                lapiService.deletePerson(personInfo.getId());
+//                if(!deleteDevicePerson(personInfo, sheet)){
+//                    msgResult.setData(false);
+//                }
 
 
                 personInfo.setFaceBound(false);
                 personInfo.setFaceBound(false);
                 personInfo.setUpdateTime(new Date());
                 personInfo.setUpdateTime(new Date());
@@ -524,15 +527,15 @@ public class PersonInfoController {
 
 
             if (affectCount > 0) {
             if (affectCount > 0) {
                 msgResult.setResult(true);
                 msgResult.setResult(true);
-                if(!msgResult.getData()){
-                    ByteArrayOutputStream output = new ByteArrayOutputStream();
-                    workbook.write(output);
-                    byte[] buffer = output.toByteArray();
-                    ByteArrayInputStream input = new ByteArrayInputStream(buffer);
-                    String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
-
-                    msgResult.setMessage(downloadUrl);
-                }
+//                if(!msgResult.getData()){
+//                    ByteArrayOutputStream output = new ByteArrayOutputStream();
+//                    workbook.write(output);
+//                    byte[] buffer = output.toByteArray();
+//                    ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+//                    String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+//
+//                    msgResult.setMessage(downloadUrl);
+//                }
             }else{
             }else{
                 msgResult.setResult(false);
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库保存失败");
                 msgResult.setMessage("数据库保存失败");
@@ -1027,7 +1030,7 @@ public class PersonInfoController {
                     throw new Exception("人员信息不存在!");
                     throw new Exception("人员信息不存在!");
                 }
                 }
 
 
-                if(!addDevicePerson(Long.valueOf(id), sheet)){
+                if(!addDevicePerson(personInfo, sheet)){
                     msgResult.setData(false);
                     msgResult.setData(false);
                     personInfo.setFaceBound(false);
                     personInfo.setFaceBound(false);
                 }else {
                 }else {
@@ -1059,13 +1062,11 @@ public class PersonInfoController {
     }
     }
 
 
     @ApiOperation(value="删除设备人员图片")
     @ApiOperation(value="删除设备人员图片")
-    private Boolean deleteDevicePerson(Long  personId, HSSFSheet sheet){
+    private Boolean deleteDevicePerson(PersonInfo personInfo, HSSFSheet sheet){
         boolean bl = true;
         boolean bl = true;
 
 
         try {
         try {
-            PersonInfo personInfo = personInfoService.get(personId);
-
-            List<LapiMsgResult> msgResultList = lapiService.deletePerson(personId);
+            List<LapiMsgResult> msgResultList = lapiService.deletePerson(personInfo.getId());
             for (int i = 0; i < msgResultList.size(); i++) {
             for (int i = 0; i < msgResultList.size(); i++) {
                 LapiMsgResult lapiMsgResult = msgResultList.get(i);
                 LapiMsgResult lapiMsgResult = msgResultList.get(i);
 
 
@@ -1092,13 +1093,11 @@ public class PersonInfoController {
     }
     }
 
 
     @ApiOperation(value="添加设备人员图片")
     @ApiOperation(value="添加设备人员图片")
-    private Boolean addDevicePerson(Long  personId, HSSFSheet sheet){
+    private Boolean addDevicePerson(PersonInfo personInfo, HSSFSheet sheet){
         boolean bl = true;
         boolean bl = true;
 
 
         try {
         try {
-            PersonInfo personInfo = personInfoService.get(personId);
-
-            List<LapiMsgResult> msgResultList = lapiService.addPerson(personId);
+            List<LapiMsgResult> msgResultList = lapiService.addPerson(personInfo.getId());
             for (int i = 0; i < msgResultList.size(); i++) {
             for (int i = 0; i < msgResultList.size(); i++) {
                 LapiMsgResult lapiMsgResult = msgResultList.get(i);
                 LapiMsgResult lapiMsgResult = msgResultList.get(i);