From c0f16750cb9097a8db7b68f8c1794c2aec28ca15 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期四, 24 七月 2025 15:01:10 +0800
Subject: [PATCH] 新增

---
 multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java |   57 ++++++---------------------------------------------------
 1 files changed, 6 insertions(+), 51 deletions(-)

diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java
index 856bce3..1faff8d 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/CompanyIndustryTemplateServiceImpl.java
@@ -1,5 +1,6 @@
 package com.gkhy.exam.system.service.impl;
 
+import cn.hutool.core.collection.ListUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gkhy.exam.common.api.CommonPage;
@@ -191,13 +192,13 @@
             return CommonResult.failed(errorBuilder.toString());
         }
 
-        // 8. 批量插入
-        int affectedRows = companyIndustryTemplateMapper.insertIndustrys(companyIndustryTemplates);
+        List<List<CompanyIndustryTemplate>> split = ListUtil.split(companyIndustryTemplates, 50);
+        for (List<CompanyIndustryTemplate> industryTemplates : split) {
+            int affectedRows = companyIndustryTemplateMapper.insertIndustrys(industryTemplates);
+        }
+
         workbook.close();
 
-        if (affectedRows < 1) {
-            throw new ApiException("导入行业模版失败");
-        }
         return CommonResult.success();
     }
         // 安全获取单元格值
@@ -207,52 +208,6 @@
             return formatter.formatCellValue(cell).trim();
         }
 
-//    List<CompanyIndustryType> companyIndustryTypes = sysIndustryTypeMapper.selectIndustryTypeList();
-//    List<SysCompany> list = sysCompanyService.selectCompanyLists();
-//    Workbook workbook = WorkbookFactory.create(file.getInputStream());
-//    Sheet sheetAt = workbook.getSheetAt(0);
-//    List<CompanyIndustryTemplate> companyIndustryTemplates = new ArrayList<>();
-//    LoginUserDetails loginUser = SecurityUtils.getLoginUser();
-//    DataFormatter dataFormatter = new DataFormatter();
-//    StringBuilder stringBuilder = new StringBuilder();
-//        for (int i = 0; i <sheetAt.getLastRowNum(); i++) {
-//        Row row = sheetAt.getRow(i + 1);
-//        CompanyIndustryTemplate companyIndustryTemplate = new CompanyIndustryTemplate();
-//        if (row!=null){
-//            companyIndustryTemplate.setChapter(dataFormatter.formatCellValue(row.getCell(0)));
-//            companyIndustryTemplate.setTemplateName(dataFormatter.formatCellValue(row.getCell(1)));
-//            companyIndustryTemplate.setType(dataFormatter.formatCellValue(row.getCell(2)));
-//            for (CompanyIndustryType companyIndustryType : companyIndustryTypes) {
-//                if (dataFormatter.formatCellValue(row.getCell(3)).equals(companyIndustryType.getName())){
-//                    companyIndustryTemplate.setIndustryType(companyIndustryType.getId());
-//                }
-//            }
-//            if (companyIndustryTemplate.getIndustryType()==null){
-//                stringBuilder.append("未找到对应行业类型:["+dataFormatter.formatCellValue(row.getCell(3))+"]   ,");
-//            }
-//            companyIndustryTemplate.setCreateBy(loginUser.getUsername());
-//            companyIndustryTemplate.setCreateTime(LocalDateTime.now());
-//            for (SysCompany sysCompany : list) {
-//                if (dataFormatter.formatCellValue(row.getCell(4)).equals(sysCompany.getName())){
-//                    companyIndustryTemplate.setCompanyId(sysCompany.getId());
-//                }
-//            }
-//            if (companyIndustryTemplate.getCompanyId()==null){
-//                stringBuilder.append("未找到对应企业:["+dataFormatter.formatCellValue(row.getCell(4))+"]");
-//            }
-//            companyIndustryTemplates.add(companyIndustryTemplate);
-//        }
-//    }
-//        if (StringUtils.isNotBlank(stringBuilder)){
-//        workbook.close();
-//        return CommonResult.failed(stringBuilder.toString());
-//    }
-//    int i = companyIndustryTemplateMapper.insertIndustrys(companyIndustryTemplates);
-//        if (i<1){
-//        throw new ApiException("导入行业模版失败");
-//    }
-//        workbook.close();
-//        return CommonResult.success();
 
 
 }

--
Gitblit v1.9.2