From c33a3ab60cd529763fdf234ca6405042050b94ca Mon Sep 17 00:00:00 2001 From: mqh <1571896045@qq.com> Date: Fri, 28 Jul 2023 11:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/modulex/ModulexList.vue | 3 +- .../tablex/controller/TablexController.java | 57 +++++++++++++------ .../org/jeecg/modules/tablex/vo/TablexVo.java | 5 ++ 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index 5f3d235..fc29ea6 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -505,7 +505,8 @@ export default { }, tablexData: function () { return { - note: ['对应模块(必填):填写正确的模块名称', + note: ['项目名称(必填): 填写已导入的正确的项目名称', + '对应模块(必填):填写已导入的正确的模块名称', '中文名称(必填):与模块名称相同。', '英文名称(必填):与模块名称相同,填写模块名称的英文名称。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index e4f86c2..aff48e7 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -29,6 +29,8 @@ import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.service.IFieldxService; import org.jeecg.modules.modulex.entity.Modulex; import org.jeecg.modules.modulex.service.IModulexService; +import org.jeecg.modules.projectx.entity.Projectx; +import org.jeecg.modules.projectx.service.IProjectxService; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; @@ -78,6 +80,10 @@ public class TablexController extends JeecgController { @Autowired private IModulexService modulexService; + + @Autowired + private IProjectxService projectxService; + @Autowired private IFieldxService fieldxService; @@ -337,7 +343,7 @@ public class TablexController extends JeecgController { message.put("status", "数据预读入"); webSocketUtils.sendMessage(loginUser.getId(), message); - Iterator iterator = list.iterator(); + for (TablexVo tablexVo : list) { //判断当前存入条是否为空值 if (StringUtils.isBlank(tablexVo.getModuleId()) && @@ -376,18 +382,49 @@ public class TablexController extends JeecgController { List tablexList = new ArrayList<>(); for (int i = 0; i < voList.size(); i++) { - Tablex tablex = new Tablex(); + //判断对应的项目名称 + String projectId = voList.get(i).getProjectId(); + if (projectId == null || projectId.equals("")){ + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条项目名称填写不能为空"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条项目名称填写不能为空"); + } + LambdaQueryWrapper queryProjectx = new LambdaQueryWrapper<>(); + queryProjectx.eq(Projectx::getId, projectId); + Projectx projectx = projectxService.getOne(queryProjectx); + if (projectx == null) { + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条项目名称不存在"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条项目名称不存在"); + } + //判断对应模块是否为空,且对应模块是否存在 String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { message.put("isError", "true"); - message.put("status", "导入失败,对应模块填写不能为空"); + message.put("status", "导入失败,第" + (i + 1) + "条对应模块填写不能为空"); message.put("closeable", "true"); webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("对应模块填写不能为空"); + return Result.error("导入失败,第" + (i + 1) + "条对应模块填写不能为空"); } + LambdaQueryWrapper queryModulex = new LambdaQueryWrapper<>(); + queryModulex.eq(Modulex::getProjectId,projectId); + queryModulex.eq(Modulex::getId, moduleId); + Modulex modulex = modulexService.getOne(queryModulex); + if (modulex == null) { + message.put("isError", "true"); + message.put("status", "导入失败,第" + (i + 1) + "条对应模块不存在"); + message.put("closeable", "true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条对应模块不存在"); + } + String modulexId = modulex.getId(); //判断实体是否已存在 LambdaQueryWrapper query = new LambdaQueryWrapper<>(); @@ -401,18 +438,6 @@ public class TablexController extends JeecgController { return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); } - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Modulex::getId, moduleId); - Modulex modulex = modulexService.getOne(queryWrapper); - if (modulex == null) { - message.put("isError", "true"); - message.put("status", "导入失败,对应模块填写错误"); - message.put("closeable", "true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("对应模块填写错误"); - } - String modulexId = modulex.getId(); - String status = voList.get(i).getStatus(); String verisonStatus = voList.get(i).getVerisonStatus(); diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java index 10f703c..28d5e49 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/vo/TablexVo.java @@ -34,6 +34,11 @@ public class TablexVo implements Serializable { @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value = "主键") private java.lang.String id; + /**项目名称*/ + @Excel(name = "项目名称", width = 15, dictTable = "projectx", dicText = "project_name", dicCode = "id") + @Dict(dictTable = "projectx", dicText = "project_name", dicCode = "id") + @ApiModelProperty(value = "项目名称") + private java.lang.String projectId; /**对应模块id*/ @Excel(name = "对应模块", width = 15, dictTable = "modulex", dicText = "module_name", dicCode = "id") @Dict(dictTable = "modulex", dicText = "module_name", dicCode = "id")