From 679dc7dd1552f0c0679321418abb4e986df2584f Mon Sep 17 00:00:00 2001 From: guilongma <3307671311@qq.com> Date: Fri, 28 Jul 2023 17:02:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=AF=BC=E5=85=A5=E5=89=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=B8=AD=E6=96=87=E5=90=8D=E7=A7=B0=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E5=90=8D=E9=87=8D=E5=A4=8D=EF=BC=8C=E5=B0=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=BC=96=E7=A0=81=E6=94=B9=E4=B8=BA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=8C=E8=A7=A3=E5=86=B3=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E3=80=81=E5=AE=9E=E9=99=85=E6=97=B6=E9=95=BF?= =?UTF-8?q?=E4=B8=BA=E8=B4=9F=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/functionx/entity/FunctionxTest.java | 5 +- .../impl/FunctionXTestServiceImpl.java | 192 +++++++++++------- 2 files changed, 119 insertions(+), 78 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java index 54ecb0e..2cfb58a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/entity/FunctionxTest.java @@ -24,8 +24,7 @@ public class FunctionxTest implements Serializable { /** * 对应上级模块 */ - @TableField("p_module_name") - private String pModuleName; + private String project; /** * 对应模块 @@ -45,7 +44,7 @@ public class FunctionxTest implements Serializable { /** * 功能编码 */ - private String functionCode; +// private String functionCode; /** * 功能类型 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 1ea2434..6c0f80f 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 @@ -23,13 +23,14 @@ import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.service.IModulexService; import org.jeecg.modules.projectUserRole.entity.ProjectUserRole; import org.jeecg.modules.projectUserRole.service.IProjectUserRoleService; +import org.jeecg.modules.projectx.entity.Projectx; +import org.jeecg.modules.projectx.service.IProjectxService; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysUserService; -import org.jeecg.modules.tablex.vo.TablexVo; import org.jeecg.modules.tablex.ws.WebSocketUtils; -import org.jeecgframework.poi.excel.entity.ImportParams; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; @@ -49,8 +50,11 @@ public class FunctionXTestServiceImpl extends ServiceImpl importExcel(MultipartFile file) { // 获取当前操作用户 @@ -137,46 +141,51 @@ public class FunctionXTestServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(username != null, FunctionxTest::getCreatName, username); + List list = this.list(queryWrapper); + + + int isSaveTestSuccess = saveTest(listVo); + if (isSaveTestSuccess != -1){ + this.remove(queryWrapper); message.put("isError", "true"); - message.put("status", "文件读入失败"); + message.put("status", "第" + (isSaveTestSuccess+1) + "行中文名或英文名有重复"); message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("文件读入失败"); + return Result.error("中文名或英文名有重复"); } message.put("status", "数据校验"); webSocketUtils.sendMessage(loginUser.getId(), message); //************************具体字段校验****************************** - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(username != null, FunctionxTest::getCreatName, username); - List list = this.list(queryWrapper); + boolean remove = this.remove(queryWrapper); if (!remove) { @@ -193,11 +202,11 @@ public class FunctionXTestServiceImpl extends ServiceImpl projectxQueryWrapper =new LambdaQueryWrapper<>(); + projectxQueryWrapper.eq(Projectx::getProjectName,project); + List list1 = projectxService.list(projectxQueryWrapper); + if (list1.size()==0){ + message.put("isError", "true"); + message.put("status", "第" + i + "行数据项目名称错误"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("项目名称错误"); + } + project = list1.get(0).getId(); // 此时project为项目id + } + if (StringUtils.isBlank(moduleId)) { message.put("isError", "true"); message.put("status", "第" + i + "行数据对应模块不能为空"); @@ -223,30 +254,13 @@ 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)) { - functionx.setModuleId(modulex.getId()); - moduleId = modulex.getId(); - moduleName = modulex.getModuleName(); - break; - } - } - } else { - for (Modulex modulex : modulexList) { - if (modulex.getModuleName().equals(moduleId) && modulex.getPid() == null) { - functionx.setModuleId(modulex.getId()); - moduleId = modulex.getId(); - moduleName = modulex.getModuleName(); - break; - } + for (Modulex modulex : modulexList) { + if (modulex.getModuleName().equals(moduleId) && modulex.getProjectId().equals(project)) { + functionx.setModuleId(modulex.getId()); + moduleId = modulex.getId(); + moduleName = modulex.getModuleName(); + moduleCode = modulex.getModuleCode(); + break; } } if (functionx.getModuleId() == null) { @@ -342,30 +356,32 @@ public class FunctionXTestServiceImpl extends ServiceImpl queryWrapperModulex = new LambdaQueryWrapper<>(); - 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)) { - message.put("isError", "true"); - message.put("status", "第" + (i+1) + "行数据数据功能编码错误"); - message.put("closeable", "true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("功能编码错误"); - } - - functionx.setFunctionCode(functionCode); - } + // 模块编码+功能缩写;自动填充+手动修改 // 改为自动生成 + String firstChar = toFirstChar(functionName); + String functionCode = moduleCode + firstChar; + functionx.setFunctionCode(functionCode); +// if (StringUtils.isBlank(functionCode)) { +// message.put("isError", "true"); +// message.put("status", "第" + (i+1) + "行数据数据功能编码不能为空"); +// message.put("closeable", "true"); +// webSocketUtils.sendMessage(loginUser.getId(), message); +// return Result.error("功能编码不能为空"); +// } else { +// LambdaQueryWrapper queryWrapperModulex = new LambdaQueryWrapper<>(); +// queryWrapperModulex.eq(Modulex::getModuleName, moduleName); +// Modulex modulex = modulexService.getOne(queryWrapperModulex); +// String moduleCode = modulex.getModuleCode(); +// String firstChar = toFirstChar(functionName); +// String str = moduleCode + firstChar; +// if (!str.equals(functionCode)) { +// message.put("isError", "true"); +// message.put("status", "第" + (i+1) + "行数据数据功能编码错误"); +// message.put("closeable", "true"); +// webSocketUtils.sendMessage(loginUser.getId(), message); +// return Result.error("功能编码错误"); +// } +// functionx.setFunctionCode(functionCode); +// } if (StringUtils.isNotBlank(pmDescribe)) { // 功能描述 functionx.setPmDescribe(pmDescribe); @@ -514,6 +530,13 @@ public class FunctionXTestServiceImpl extends ServiceImpl listVo) { + for (int i = 0; i < listVo.size(); i++) { + try { + this.save(listVo.get(i)); + } catch (Exception e) { + return i; + } + } + return -1; + } + private boolean funCheck(List list) { for (int i=0;i0){