From 9da3041d5a71f30a0f0f9dc005ffc4af88ef7bec Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 02 三月 2026 09:45:57 +0800
Subject: [PATCH] bug处理

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java |  127 +++++++++++++++++++++++++++++++----------
 1 files changed, 95 insertions(+), 32 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java
index 2e92259..9da68e2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLargeKeyGridUserController.java
@@ -13,6 +13,7 @@
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.WebUtils;
+import com.ruoyi.system.export.LargeKeyGridPointUserImport;
 import com.ruoyi.system.export.LargeKeyGridUserImport;
 import com.ruoyi.system.model.TLargeKeyGridUser;
 import com.ruoyi.system.model.TLargeKeyPersonnelType;
@@ -140,7 +141,7 @@
         return R.ok(largeKeyGridUserService.removeByIds(ids));
     }
 
-    @ApiOperation(value = "重点人员-网格人员导入模板下载")
+    @ApiOperation(value = "网格人员导入模板下载")
     @GetMapping("/import-template")
     public void importTemplate() {
         List<LargeKeyGridUserImport> largeLargeKeyGridUserImports = new ArrayList<>();
@@ -150,7 +151,7 @@
         HttpServletResponse response = WebUtils.response();
         ServletOutputStream outputStream = null;
         try {
-            String fileName = URLEncoder.encode("重点人员-网格人员信息导入模板.xls", "utf-8");
+            String fileName = URLEncoder.encode("网格人员信息导入模板.xls", "utf-8");
             response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
             response.setHeader("content-Type", "application/vnd.ms-excel");
             response.setHeader("Pragma", "no-cache");
@@ -159,7 +160,35 @@
             workbook.write(outputStream);
         } catch (IOException e) {
             e.printStackTrace();
-            System.out.println("重点人员-网格人员导入模板下载失败!");
+            System.out.println("网格人员导入模板下载失败!");
+        } finally {
+            try {
+                outputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+    @ApiOperation(value = "重点人员导入模板下载")
+    @GetMapping("/import-point-template")
+    public void importPointTemplate() {
+        List<LargeKeyGridPointUserImport> largeKeyGridPointUserImports = new ArrayList<>();
+        LargeKeyGridPointUserImport largeKeyGridPointUserImport = new LargeKeyGridPointUserImport();
+        largeKeyGridPointUserImports.add(largeKeyGridPointUserImport);
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), LargeKeyGridPointUserImport.class, largeKeyGridPointUserImports);
+        HttpServletResponse response = WebUtils.response();
+        ServletOutputStream outputStream = null;
+        try {
+            String fileName = URLEncoder.encode("重点人员信息导入模板.xls", "utf-8");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.setHeader("content-Type", "application/vnd.ms-excel");
+            response.setHeader("Pragma", "no-cache");
+            response.setHeader("Cache-Control", "no-cache");
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.out.println("重点人员导入模板下载失败!");
         } finally {
             try {
                 outputStream.close();
@@ -202,50 +231,62 @@
         for (LargeKeyGridUserImport largeKeyGridUserImport : largeKeyGridUserImports) {
             if (!StringUtils.hasLength(largeKeyGridUserImport.getGridInfo())){
                 result.append("第"+i+"行:[", "网格"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getCommunityName())){
                 result.append("第"+i+"行:[", "小区名称"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getBuildingInfo())){
                 result.append("第"+i+"行:[", "楼栋信息"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getUnitNumber())){
                 result.append("第"+i+"行:[", "单元号"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getHouseNumber())){
                 result.append("第"+i+"行:[", "门牌号"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getUserName())){
                 result.append("第"+i+"行:[", "姓名"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getUserSexStr())){
                 result.append("第"+i+"行:[", "性别"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getIdCard())){
                 result.append("第"+i+"行:[", "身份证号"+"]不能为空");
+                i++;
                 continue;
             }
-            if (largeKeyGridUserImport.getIdCard().matches("^$|(^[1-9]\\\\d{7}((0\\\\d)|(1[0-2]))(([0-2]\\\\d)|3[0-1])\\\\d{3}$)|(^[1-9]\\\\d{5}[1-9]\\\\d{3}((0\\\\d)|(1[0-2]))(([0-2]\\\\d)|3[0-1])((\\\\d{4})|\\\\d{3}[Xx])$)")){
+            if (!largeKeyGridUserImport.getIdCard().matches("^$|(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$)|(^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}[Xx])$)")){
                 result.append("第"+i+"行:[", "身份证号"+"]格式不正确");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getContactNumber())){
                 result.append("第"+i+"行:[", "联系电话"+"]不能为空");
+                i++;
                 continue;
             }
-            if (largeKeyGridUserImport.getContactNumber().matches("^1[3-9]\\\\d{9}$")){
+            if (largeKeyGridUserImport.getContactNumber().length() != 11){
                 result.append("第"+i+"行:[", "联系电话"+"]格式不正确");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getTypeName())){
                 result.append("第"+i+"行:[", "类型名称"+"]不能为空");
+                i++;
                 continue;
             }
             TLargeKeyGridUser largeKeyGridUser = new TLargeKeyGridUser();
@@ -260,6 +301,7 @@
                     break;
                 default:
                     result.append("第"+i+"行:[", "性别"+"]格式错误");
+                    i++;
                     continue;
             }
 
@@ -268,6 +310,7 @@
                     .last("LIMIT 1"));
             if(Objects.isNull(largeKeyPersonnelType)){
                 result.append("第"+i+"行:[", "类型名称"+"]不存在");
+                i++;
                 continue;
             }
             largeKeyGridUser.setTypeId(largeKeyPersonnelType.getId());
@@ -313,48 +356,64 @@
         JSONObject result = new JSONObject();
         int i = 1;
         for (LargeKeyGridUserImport largeKeyGridUserImport : largeKeyGridUserImports) {
-            if (!StringUtils.hasLength(largeKeyGridUserImport.getGridInfo())){
-                result.append("第"+i+"行:[", "网格"+"]不能为空");
-                continue;
-            }
-            if (!StringUtils.hasLength(largeKeyGridUserImport.getCommunityName())){
-                result.append("第"+i+"行:[", "小区名称"+"]不能为空");
-                continue;
-            }
-            if (!StringUtils.hasLength(largeKeyGridUserImport.getBuildingInfo())){
-                result.append("第"+i+"行:[", "楼栋信息"+"]不能为空");
-                continue;
-            }
-            if (!StringUtils.hasLength(largeKeyGridUserImport.getUnitNumber())){
-                result.append("第"+i+"行:[", "单元号"+"]不能为空");
-                continue;
-            }
-            if (!StringUtils.hasLength(largeKeyGridUserImport.getHouseNumber())){
-                result.append("第"+i+"行:[", "门牌号"+"]不能为空");
-                continue;
-            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getGridInfo())){
+//                result.append("第"+i+"行:[", "网格"+"]不能为空");
+//                i++;
+//                continue;
+//            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getCommunityName())){
+//                result.append("第"+i+"行:[", "小区名称"+"]不能为空");
+//                i++;
+//                continue;
+//            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getRegisteredResidence())){
+//                result.append("第"+i+"行:[", "户籍地"+"]不能为空");
+//                i++;
+//                continue;
+//            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getBuildingInfo())){
+//                result.append("第"+i+"行:[", "楼栋信息"+"]不能为空");
+//                i++;
+//                continue;
+//            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getUnitNumber())){
+//                result.append("第"+i+"行:[", "单元号"+"]不能为空");
+//                i++;
+//                continue;
+//            }
+//            if (!StringUtils.hasLength(largeKeyGridUserImport.getHouseNumber())){
+//                result.append("第"+i+"行:[", "门牌号"+"]不能为空");
+//                i++;
+//                continue;
+//            }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getUserName())){
                 result.append("第"+i+"行:[", "姓名"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getUserSexStr())){
                 result.append("第"+i+"行:[", "性别"+"]不能为空");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getIdCard())){
                 result.append("第"+i+"行:[", "身份证号"+"]不能为空");
+                i++;
                 continue;
             }
-            if (largeKeyGridUserImport.getIdCard().matches("^$|(^[1-9]\\\\d{7}((0\\\\d)|(1[0-2]))(([0-2]\\\\d)|3[0-1])\\\\d{3}$)|(^[1-9]\\\\d{5}[1-9]\\\\d{3}((0\\\\d)|(1[0-2]))(([0-2]\\\\d)|3[0-1])((\\\\d{4})|\\\\d{3}[Xx])$)")){
+            if (!largeKeyGridUserImport.getIdCard().matches("^$|(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$)|(^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])((\\d{4})|\\d{3}[Xx])$)")){
                 result.append("第"+i+"行:[", "身份证号"+"]格式不正确");
+                i++;
                 continue;
             }
             if (!StringUtils.hasLength(largeKeyGridUserImport.getContactNumber())){
                 result.append("第"+i+"行:[", "联系电话"+"]不能为空");
+                i++;
                 continue;
             }
-            if (largeKeyGridUserImport.getContactNumber().matches("^1[3-9]\\\\d{9}$")){
+            if (largeKeyGridUserImport.getContactNumber().length() != 11){
                 result.append("第"+i+"行:[", "联系电话"+"]格式不正确");
+                i++;
                 continue;
             }
             TLargeKeyGridUser largeKeyGridUser = new TLargeKeyGridUser();
@@ -369,6 +428,7 @@
                     break;
                 default:
                     result.append("第"+i+"行:[", "性别"+"]格式错误");
+                    i++;
                     continue;
             }
 
@@ -376,20 +436,23 @@
                 TLargeKeyPersonnelType largeKeyPersonnelType = largeKeyPersonnelTypeService.getOne(Wrappers.lambdaQuery(TLargeKeyPersonnelType.class)
                         .eq(TLargeKeyPersonnelType::getTypeName, largeKeyGridUserImport.getTypeName())
                         .last("LIMIT 1"));
-                if(Objects.isNull(largeKeyPersonnelType)){
-                    result.append("第"+i+"行:[", "类型名称"+"]不存在");
-                    continue;
+//                if(Objects.isNull(largeKeyPersonnelType)){
+//                    result.append("第"+i+"行:[", "类型名称"+"]不存在");
+//                    i++;
+//                    continue;
+//                }
+                if(Objects.nonNull(largeKeyPersonnelType)){
+                    largeKeyGridUser.setTypeId(largeKeyPersonnelType.getId());
                 }
-                largeKeyGridUser.setTypeId(largeKeyPersonnelType.getId());
             }
             largeKeyGridUser.setUserType(2);
             largeKeyGridUsers.add(largeKeyGridUser);
             i++;
         }
-        largeKeyGridUserService.saveBatch(largeKeyGridUsers);
         if(!result.isEmpty()){
             return R.fail(result.toString());
         }
+        largeKeyGridUserService.saveBatch(largeKeyGridUsers);
         return R.ok();
     }
 

--
Gitblit v1.7.1