修改导入实体

dev^2
mqh 1 year ago
parent b9884b1c45
commit 24740d7d44
  1. 53
      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<Tablex, ITablexService> {
StringUtils.isBlank(tablexVo.getVerison())) { StringUtils.isBlank(tablexVo.getVerison())) {
continue; 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); tablexVoService.save(tablexVo);
} }
@ -386,6 +378,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
Tablex tablex = new Tablex(); Tablex tablex = new Tablex();
//判断对应模块是否为空,且对应模块是否存在
String moduleId = voList.get(i).getModuleId(); String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")) { if (moduleId == null || moduleId.equals("")) {
message.put("isError", "true"); message.put("isError", "true");
@ -414,6 +407,38 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断版本状态 //判断版本状态
//int verisonStatusInt = verisonStatus.equals("当前") ? 1 : verisonStatus.equals("历史") ? 0 : 3; //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<Tablex> query = new LambdaQueryWrapper<>();
query.eq(Tablex::getTableName,voList.get(i).getTableName());
List<Tablex> 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("")) { if (modulexId != null && voList.get(i).getModuleId() != null && !voList.get(i).getModuleId().equals("")) {
//判断中文名称 //判断中文名称
@ -424,8 +449,6 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
if (status.equals("1") || status.equals("0") || status.equals("9")) { if (status.equals("1") || status.equals("0") || status.equals("9")) {
//判断版本状态 //判断版本状态
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { if (verisonStatus.equals("1") || verisonStatus.equals("0")) {
//判断版本号
if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) {
message.put("status", "数据校验成功"); message.put("status", "数据校验成功");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
@ -438,17 +461,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablex.setCreateBy(loginUser.getRealname()); tablex.setCreateBy(loginUser.getRealname());
tablex.setStatus(Integer.valueOf(voList.get(i).getStatus())); tablex.setStatus(Integer.valueOf(voList.get(i).getStatus()));
tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus())); tablex.setVerisonStatus(Integer.valueOf(voList.get(i).getVerisonStatus()));
tablex.setVerison(Integer.valueOf(voList.get(i).getVerison()));
tablexList.add(tablex); 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 { } else {
message.put("isError", "true"); message.put("isError", "true");
message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!");

Loading…
Cancel
Save