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 9888b99..239b0f5 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 @@ -349,15 +349,7 @@ public class TablexController extends JeecgController { StringUtils.isBlank(tablexVo.getVerison())) { continue; } - //判断版本号长度 - String verison = tablexVo.getVerison(); - if (verison.length() > 5) { - message.put("isError", "true"); - message.put("status","预读入失败,版本号格式错误"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("预读入失败,版本号格式错误"); - } + //存入临时表中 tablexVoService.save(tablexVo); } @@ -386,6 +378,7 @@ public class TablexController extends JeecgController { Tablex tablex = new Tablex(); + //判断对应模块是否为空,且对应模块是否存在 String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { message.put("isError", "true"); @@ -414,6 +407,38 @@ public class TablexController extends JeecgController { //判断版本状态 //int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3; + //判断版本号,若实体已存在,查找最大的版本号并且版本号+1 + if(voList.get(i).getVerison() == null || voList.get(i).getVerison().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 query = new LambdaQueryWrapper<>(); + query.eq(Tablex::getTableName,voList.get(i).getTableName()); + List verisonList = tablexService.list(query); + if (verisonList != null){ + int version = 0; + for(Tablex verisonMax : verisonList){ + if(verisonMax.getVerison() > version){ + version = verisonMax.getVerison(); + } + } + int v = version + 1; + tablex.setVerison(v); + }else { + //判断版本号是否为正整数且长度不能大于5 + if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") && voList.get(i).getVerison().length() > 5){ + message.put("isError", "true"); + message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); + return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); + } + tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); + } + //判断对应模块 if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) { //判断中文名称 @@ -424,8 +449,6 @@ public class TablexController extends JeecgController { if (status.equals("1") || status.equals("0") || status.equals("9")) { //判断版本状态 if (verisonStatus.equals("1") || verisonStatus.equals("0")) { - //判断版本号 - if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) { message.put("status", "数据校验成功"); webSocketUtils.sendMessage(loginUser.getId(), message); @@ -438,17 +461,9 @@ public class TablexController extends JeecgController { tablex.setCreateBy(loginUser.getRealname()); tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); - tablex.setVerison(Integer.valueOf(voList.get(i).getVerison())); tablexList.add(tablex); - } else { - message.put("isError", "true"); - message.put("status","导入失败,第" + (i + 1) + "条的版本号填写错误!"); - message.put("closeable","true"); - webSocketUtils.sendMessage(loginUser.getId(), message); - return Result.error("导入失败,第" + (i + 1) + "条的版本号填写错误!"); - } } else { message.put("isError", "true"); message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!");