From 9290f843b561334b4c354fb42aae4e3dd670bd23 Mon Sep 17 00:00:00 2001 From: guilongma <3307671311@qq.com> Date: Wed, 26 Jul 2023 11:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=94=B9=E4=B8=BA=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=EF=BC=8C=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FunctionXTestServiceImpl.java | 412 ++++++++++-------- 1 file changed, 227 insertions(+), 185 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java index 9b5c72e..896db75 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java @@ -9,10 +9,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.jeecg.common.api.vo.Result; @@ -65,31 +62,31 @@ public class FunctionXTestServiceImpl extends ServiceImpl listVo = new ArrayList<>(); - for (int i=1;i<=lastRowIndex;i++) { + for (int i = 1; i <= lastRowIndex; i++) { Row row = sheet.getRow(i); // 行 - if(row!=null){ + if (row == null ) { + continue; + } else { short lastCellNum = row.getLastCellNum(); List list = new ArrayList<>(); - for (int j=0;j queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(username!=null, FunctionxTest::getCreatName,username); + queryWrapper.eq(username != null, FunctionxTest::getCreatName, username); List list = this.list(queryWrapper); boolean remove = this.remove(queryWrapper); - if (!remove){ + if (!remove) { log.error("临时表删除错误!"); } @@ -204,86 +208,86 @@ public class FunctionXTestServiceImpl extends ServiceImpl0) { + String pid = ""; + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(pModuleId)) { pid = modulex.getId(); break; } } - for(Modulex modulex : modulexList){ - if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)){ + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(moduleId) && modulex.getPid().equals(pid)) { functionx.setModuleId(modulex.getId()); moduleId = modulex.getId(); - moduleName=modulex.getModuleName(); + moduleName = modulex.getModuleName(); break; } } - }else { - for(Modulex modulex : modulexList){ - if (modulex.getModuleName().equals(moduleId) && modulex.getPid()==null){ + } else { + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) { functionx.setModuleId(modulex.getId()); moduleId = modulex.getId(); - moduleName=modulex.getModuleName(); + moduleName = modulex.getModuleName(); break; } } } - if(functionx.getModuleId() == null){ + if (functionx.getModuleId() == null) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行对应模块有错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行对应模块有错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("请输入正确的对应模块"); } } - if(StringUtils.isBlank(functionName)){ + if (StringUtils.isBlank(functionName)) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行中文名称不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行中文名称不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("中文名称不能为空"); - } else{ + } else { LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); - queryWrapper1.eq(moduleId!=null,Functionx::getModuleId,moduleId); - queryWrapper1.eq(Functionx::getFunctionName,functionName); + queryWrapper1.eq(moduleId != null, Functionx::getModuleId, moduleId); + queryWrapper1.eq(Functionx::getFunctionName, functionName); int count = functionxService.count(queryWrapper1); - if(count>0){ + if (count > 0) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行中文名称在模块下重复"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行中文名称在模块下重复"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("中文名称在模块下重复"); } functionx.setFunctionName(functionName); } - if(StringUtils.isBlank(functionEnName)){ + if (StringUtils.isBlank(functionEnName)) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行英文名称不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行英文名称不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("英文名称不能为空"); - } else{ + } else { LambdaQueryWrapper queryWrapper2 = new LambdaQueryWrapper<>(); - queryWrapper2.eq(moduleId!=null,Functionx::getModuleId,moduleId); - queryWrapper2.eq(Functionx::getFunctionEnName,functionEnName); + queryWrapper2.eq(moduleId != null, Functionx::getModuleId, moduleId); + queryWrapper2.eq(Functionx::getFunctionEnName, functionEnName); int count = functionxService.count(queryWrapper2); - if(count>0){ + if (count > 0) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行英文名称在模块下重复"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行英文名称在模块下重复"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("英文名称在模块下重复"); } @@ -292,49 +296,65 @@ public class FunctionXTestServiceImpl extends ServiceImpl queryWrapperModulex = new LambdaQueryWrapper<>(); - queryWrapperModulex.eq(Modulex::getModuleName,moduleName); + queryWrapperModulex.eq(Modulex::getModuleName, moduleName); Modulex modulex = modulexService.getOne(queryWrapperModulex); String moduleCode = modulex.getModuleCode(); String firstChar = toFirstChar(functionType); - String str = moduleCode+firstChar; - if(!str.equals(functionCode)){ + String str = moduleCode + firstChar; + if (!str.equals(functionCode)) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行功能编码错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行功能编码错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("功能编码错误"); } @@ -342,221 +362,243 @@ public class FunctionXTestServiceImpl extends ServiceImpl queryWrapperUser = new LambdaQueryWrapper<>(); - queryWrapperUser.eq(ProjectUserRole::getUserRole,userRole); // 是否匹配项目id? + queryWrapperUser.eq(ProjectUserRole::getUserRole, userRole); // 是否匹配项目id? int count = projectUserRoleService.count(queryWrapperUser); - if(count>0) + if (count > 0) functionx.setUserRole(userRole); - else{ + else { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行请输入正确的用户角色"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行请输入正确的用户角色"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("请输入正确的用户角色"); } } - if(StringUtils.isNotBlank(managerUsers)){ // 责任人 + if (StringUtils.isNotBlank(managerUsers)) { // 责任人 String[] splitManager = managerUsers.split("\\s+|,|;|、"); int count = 0; - for (String manager : splitManager){ + for (String manager : splitManager) { LambdaQueryWrapper queryWrapperUserName = new LambdaQueryWrapper<>(); - queryWrapperUserName.eq(!manager.isEmpty(),SysUser::getUsername,manager); + queryWrapperUserName.eq(!manager.isEmpty(), SysUser::getUsername, manager); count = sysUserService.count(queryWrapperUserName); - if(count == 0) { + if (count == 0) { break; } } - if(count>0) + if (count > 0) functionx.setManagerUsers(managerUsers); - else{ + else { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("请输入正确的责任人,并确保多个责任人之间用空格或者逗号、分号隔开"); } } // 值:1、2、3、4、5,默认2 - if(StringUtils.isBlank(workLevel)){ // 任务等级 + if (StringUtils.isBlank(workLevel)) { // 任务等级 message.put("isError", "true"); - message.put("status","第"+(i+2)+"行任务等级不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行任务等级不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务等级不能为空"); - } else{ + } else { int integer = Integer.parseInt(workLevel); - if (integer<1 || integer>5){ + if (integer < 1 || integer > 5) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行任务等级错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行任务等级错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务等级错误"); } functionx.setWorkLevel(integer); } - if(StringUtils.isBlank(workStatus)){ + if (StringUtils.isBlank(workStatus)) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行任务状态不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行任务状态不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务状态不能为空"); } else { // 值:未发布0、已发布1、开发中2、已完成3、已撤回4、已取消9;默认0 - switch (workStatus){ - case "未发布": type=0; break; - case "已发布": type=1; break; - case "开发中": type=2; break; - case "已完成": type=3; break; - case "已撤回": type=4; break; - case "已取消": type=9; break; + switch (workStatus) { + case "未发布": + type = 0; + break; + case "已发布": + type = 1; + break; + case "开发中": + type = 2; + break; + case "已完成": + type = 3; + break; + case "已撤回": + type = 4; + break; + case "已取消": + type = 9; + break; default: message.put("isError", "true"); - message.put("status","第"+(i+2)+"行任务状态错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行任务状态错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务状态错误"); } functionx.setWorkStatus(type); } - if(StringUtils.isNotBlank(publishTime)){ + if (StringUtils.isNotBlank(publishTime)) { Date date; Boolean isTime = checkTime(publishTime); - if (!isTime){ + if (!isTime) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行发布时间格式错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行发布时间格式错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("发布时间错误,应为"+pattern+"类型"); + return Result.error("发布时间错误,应为" + pattern + "类型"); } try { date = dateFormat.parse(publishTime); } catch (Exception e) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行发布时间错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行发布时间错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("发布时间错误,应为"+pattern+"类型"); + return Result.error("发布时间错误,应为" + pattern + "类型"); } functionx.setPublishTime(date); } - if(StringUtils.isNotBlank(startTime)){ + if (StringUtils.isNotBlank(startTime)) { Date date; Boolean isTime = checkTime(startTime); - if (!isTime){ + if (!isTime) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行开始时间格式错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行开始时间格式错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("开始时间错误,应为"+pattern+"类型"); + return Result.error("开始时间错误,应为" + pattern + "类型"); } try { date = dateFormat.parse(startTime); } catch (Exception e) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行开始时间错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行开始时间错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("开始时间错误,应为"+pattern+"类型"); + return Result.error("开始时间错误,应为" + pattern + "类型"); } functionx.setStartTime(date); } - if(StringUtils.isNotBlank(duration)){ + if (StringUtils.isNotBlank(duration)) { Double aDouble = Double.valueOf(duration); functionx.setDuration(aDouble); } - if(StringUtils.isNotBlank(submitTime)){ + if (StringUtils.isNotBlank(submitTime)) { Date date; Boolean isTime = checkTime(submitTime); - if (!isTime){ + if (!isTime) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行提交时间格式错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行提交时间格式错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("提交时间格式错误,应为"+pattern+"类型"); + return Result.error("提交时间格式错误,应为" + pattern + "类型"); } try { date = dateFormat.parse(submitTime); } catch (Exception e) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行提交时间时间错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行提交时间时间错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("提交时间时间错误,应为"+pattern+"类型"); + return Result.error("提交时间时间错误,应为" + pattern + "类型"); } functionx.setSubmitTime(date); } - if(StringUtils.isNotBlank(realDuration)){ + if (StringUtils.isNotBlank(realDuration)) { Double aDouble = Double.valueOf(realDuration); - if (aDouble<0.1){ + if (aDouble < 0.1) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行实际时长错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行实际时长错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("实际时长错误"); } functionx.setDuration(aDouble); } - if(StringUtils.isBlank(status)){ // 空和null + if (StringUtils.isBlank(status)) { // 空和null message.put("isError", "true"); - message.put("status","第"+(i+2)+"行功能状态不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行功能状态不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("功能状态不能为空"); - } else{ + } else { // 值:正常1、停用0、废弃9;默认1 - switch (status){ - case "正常": type=1; break; - case "停用": type=0; break; - case "废弃": type=9; break; + switch (status) { + case "正常": + type = 1; + break; + case "停用": + type = 0; + break; + case "废弃": + type = 9; + break; default: message.put("isError", "true"); - message.put("status","第"+(i+2)+"行任务状态错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行任务状态错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("任务状态错误"); } functionx.setStatus(type); } - if(StringUtils.isBlank(verisonStatus)){ // 空和null + if (StringUtils.isBlank(verisonStatus)) { // 空和null message.put("isError", "true"); - message.put("status","第"+(i+2)+"行版本状态不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行版本状态不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本状态不能为空"); - } else{ + } else { // 值:当前1、历史0;默认1 - switch (verisonStatus){ - case "当前": type=1; break; - case "历史": type=0; break; + switch (verisonStatus) { + case "当前": + type = 1; + break; + case "历史": + type = 0; + break; default: message.put("isError", "true"); - message.put("status","第"+(i+2)+"行版本状态错误"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行版本状态错误"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本状态错误"); } functionx.setStatus(type); } - if(StringUtils.isBlank(verison)){ + if (StringUtils.isBlank(verison)) { message.put("isError", "true"); - message.put("status","第"+(i+2)+"行版本号不能为空"); - message.put("closeable","true"); + message.put("status", "第" + (i + 2) + "行版本号不能为空"); + message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("版本号不能为空"); - } else{ + } else { Integer integer = Integer.valueOf(verison); functionx.setStatus(integer); } @@ -566,16 +608,16 @@ public class FunctionXTestServiceImpl extends ServiceImpl