From b34b278fb78659c10f605f8ce1e5625fc7861c7c Mon Sep 17 00:00:00 2001 From: lijinyu <3023846734@qq.com> Date: Wed, 26 Jul 2023 13:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=AE=A1=E7=90=86=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=8A=9F=E8=83=BD=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ModulexServiceImpl.java | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java index 42ead9e..ef8335e 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java @@ -10,10 +10,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.SecurityUtils; import org.checkerframework.checker.units.qual.A; @@ -380,6 +377,9 @@ public class ModulexServiceImpl extends ServiceImpl impl //标题需要单独处理 //获取页行数 Row row = sheet.getRow(j); + if(row==null){ + continue; + } //获取单行单元格数 Integer physicalNumberOfCells = null; if (row == null) { @@ -390,7 +390,14 @@ public class ModulexServiceImpl extends ServiceImpl impl if (j == 2) { for (int k = 0; k < physicalNumberOfCells; k++) { Cell cell = row.getCell(k); - String name = cell.getStringCellValue(); + if(cell==null){ + propertyNames.add(null); + } + FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); + DataFormatter formatter = new DataFormatter(); + //单元格不设置数字格式 + cell.setCellStyle(null); + String name = formatter.formatCellValue(cell,evaluator); propertyNames.add(name); } if(propertyNames.size()!=19 || !propertyNames.get(0).equals("上级模块名称") @@ -425,13 +432,6 @@ public class ModulexServiceImpl extends ServiceImpl impl int annual = 0; for (int k = 0; k < physicalNumberOfCells; k++) { Cell cell = row.getCell(k); - if(cell==null){ - message.put("isError", "true"); - message.put("status","表格中有空白行,"+"请重新导入"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("数据匹配读取失败,"+"请重新导入"); - } String value = cell.getStringCellValue(); switch (k){ case 0: @@ -565,7 +565,7 @@ public class ModulexServiceImpl extends ServiceImpl impl List list = this.list(queryWrapper); if(list==null ||list.size()==0){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级"); + message.put("status","导入失败,第" + (i+4) +"行" +"此模块不存在上级"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,此模块不存在上级"); @@ -573,14 +573,14 @@ public class ModulexServiceImpl extends ServiceImpl impl Modulex one =list.get(0); if(one==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级"); + message.put("status","导入失败,第" + (i+4) +"行" +"此模块不存在上级"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,此模块不存在上级"); }String pid1 = one.getId(); if(pid1==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"此模块不存在上级"); + message.put("status","导入失败,第" + (i+4) +"行" +"此模块不存在上级"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,此模块不存在上级"); @@ -590,7 +590,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String projectId = modulexTemplate.getProjectId(); if(projectId==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"项目名称不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"项目名称不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,项目名称不能为空"); @@ -600,7 +600,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Projectx projectx = projectxService.getOne(projectxLambdaQueryWrapper); if(projectx==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"项目名称不存在"); + message.put("status","导入失败,第" + (i+4) +"行" +"项目名称不存在"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,项目名称不存在"); @@ -613,7 +613,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String pid1 = modulex.getPid(); if(moduleName==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"中文名称不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"中文名称不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,中文名称不能为空"); @@ -623,7 +623,7 @@ public class ModulexServiceImpl extends ServiceImpl impl List modulexes = this.list(queryWrapper); if(modulexes.size()>0){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"模块中文名称已存在,请重新输入"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块中文名称已存在,请重新输入"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("模块中文名称已存在,请重新输入"); @@ -635,7 +635,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Modulex modulex1 = this.getOne(modulexLambdaQueryWrapper); if(modulex1!=null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"相同的上级模块不能重名"); + message.put("status","导入失败,第" + (i+4) +"行" +"相同的上级模块不能重名"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,相同的上级模块不能重名"); @@ -643,7 +643,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String moduleEnName = modulexTemplate.getModuleEnName(); if(moduleEnName==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"英文名称不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"英文名称不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,英文名称不能为空"); @@ -651,7 +651,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String moduleCode = modulexTemplate.getModuleCode(); if(moduleCode==null||moduleCode.length()>30){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"模块编码不能为空或者模块编码过长"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不能为空或者模块编码过长"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,模块编码不能为空或者模块编码过长"); @@ -664,7 +664,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String projectCode = projectx.getProjectCode(); if(projectCode==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"项目编码不存在,请重新填写"); + message.put("status","导入失败,第" + (i+4) +"行" +"项目编码不存在,请重新填写"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("项目编码不存在,请重新填写"); @@ -672,7 +672,7 @@ public class ModulexServiceImpl extends ServiceImpl impl modulecode = projectCode + firstChar; if(!modulecode.equals(moduleCode)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"模块编码不规范,导入失败"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块编码不规范,导入失败"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("模块编码不规范,导入失败"); @@ -683,7 +683,7 @@ public class ModulexServiceImpl extends ServiceImpl impl modulex.setPmDescribe(null); }if(pmDescribe.length()>500){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"内容描述过长,导入失败"); + message.put("status","导入失败,第" + (i+4) +"行" +"内容描述过长,导入失败"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("内容描述过长,导入失败"); @@ -701,7 +701,7 @@ public class ModulexServiceImpl extends ServiceImpl impl List iSysUserServiceOne = iSysUserService.list(sysUserLambdaQueryWrapper); if(iSysUserServiceOne==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"责任人信息查询不到"); + message.put("status","导入失败,第" + (i+4) +"行" +"责任人信息查询不到"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); @@ -709,7 +709,7 @@ public class ModulexServiceImpl extends ServiceImpl impl List list = iSysUserServiceOne.stream().map(SysUser::getId).collect(Collectors.toList()); if (list == null) { message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"责任人信息查询不到"); + message.put("status","导入失败,第" + (i+4) +"行" +"责任人信息查询不到"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,责任人信息查询不到"); @@ -727,7 +727,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String workLevel = modulexTemplate.getWorkLevel(); if(StringUtils.isBlank(workLevel)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务等级不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务等级不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务等级不能为空"); @@ -738,14 +738,14 @@ public class ModulexServiceImpl extends ServiceImpl impl integer = Integer.valueOf(workLevel); } catch (Exception e) { message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务等级不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务等级不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务等级不规范"); } if(integer<=0&&integer>=6){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务等级不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务等级不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务等级不规范"); @@ -755,7 +755,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String workStatus = modulexTemplate.getWorkStatus(); if(StringUtils.isBlank(workStatus)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务状态不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务状态不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务状态不能为空"); @@ -776,7 +776,7 @@ public class ModulexServiceImpl extends ServiceImpl impl break; default: message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务状态不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务状态不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务状态不规范"); @@ -790,7 +790,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Boolean result = this.checkTime(publishTime); if(!result){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"日期格式不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"日期格式不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,日期格式不规范"); @@ -802,7 +802,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String duration = modulexTemplate.getDuration(); if(StringUtils.isBlank(duration)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"任务时长不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"任务时长不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,任务时长不能为空"); @@ -817,7 +817,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Boolean result = this.checkTime(startTime); if(!result){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"开始时间不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"开始时间不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,开始时间不规范"); @@ -833,7 +833,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Boolean result = this.checkTime(submitTime); if(!result){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"提交时间不规范"); + message.put("status","导入失败,第" + (i+4) +"行" +"提交时间不规范"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,提交时间不规范"); @@ -845,7 +845,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String realDuration = modulexTemplate.getRealDuration(); if(StringUtils.isBlank(realDuration)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"实际时长不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"实际时长不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,实际时长不能为空"); @@ -853,7 +853,7 @@ public class ModulexServiceImpl extends ServiceImpl impl double parseDouble = Double.parseDouble(realDuration); if(parseDouble<0.1){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"最小时间0.1小时"); + message.put("status","导入失败,第" + (i+4) +"行" +"最小时间0.1小时"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,最小时间0.1小时"); @@ -869,7 +869,7 @@ public class ModulexServiceImpl extends ServiceImpl impl SysRole one = iSysRoleService.getOne(sysRoleLambdaQueryWrapper); if(one==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"用户角色不存在"); + message.put("status","导入失败,第" + (i+4) +"行" +"用户角色不存在"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,用户角色不存在"); @@ -877,7 +877,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String useRole = one.getId(); if(useRole==null){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"用户角色不存在"); + message.put("status","导入失败,第" + (i+4) +"行" +"用户角色不存在"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,用户角色不存在"); @@ -890,7 +890,7 @@ public class ModulexServiceImpl extends ServiceImpl impl Boolean extracted = extracted(modulex, relatedBean); if(!extracted){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"关联实体不存在"); + message.put("status","导入失败,第" + (i+4) +"行" +"关联实体不存在"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("关联实体不存在"); @@ -899,7 +899,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String status = modulexTemplate.getStatus(); if(StringUtils.isBlank(status)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"模块状态不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块状态不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,模块状态不能为空"); @@ -914,7 +914,7 @@ public class ModulexServiceImpl extends ServiceImpl impl break; default: message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"模块状态不规范匹配不到"); + message.put("status","导入失败,第" + (i+4) +"行" +"模块状态不规范匹配不到"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,模块状态不规范匹配不到"); @@ -924,7 +924,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String verisonStatus = modulexTemplate.getVerisonStatus(); if(StringUtils.isBlank(verisonStatus)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"版本状态不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" +"版本状态不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,版本状态不能为空"); @@ -937,7 +937,7 @@ public class ModulexServiceImpl extends ServiceImpl impl break; default: message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" +"版本状态不规范,匹配失败"); + message.put("status","导入失败,第" + (i+4) +"行" +"版本状态不规范,匹配失败"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,版本状态不规范,匹配失败"); @@ -947,7 +947,7 @@ public class ModulexServiceImpl extends ServiceImpl impl String verison = modulexTemplate.getVerison(); if(StringUtils.isBlank(verison)){ message.put("isError", "true"); - message.put("status","导入失败,第" + i+4 +"行" + "版本号不能为空"); + message.put("status","导入失败,第" + (i+4) +"行" + "版本号不能为空"); message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,版本号不能为空");