|
|
|
@ -300,8 +300,6 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -311,20 +309,14 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
params.setHeadRows(1);//表头行数,默认1
|
|
|
|
|
params.setNeedSave(true);//是否需要保存上传的Excel,默认为false
|
|
|
|
|
List<TablexVo> list = null; |
|
|
|
|
message.put("status", "读取数据中"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
try { |
|
|
|
|
//读取excel数据
|
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件读取失败"); |
|
|
|
|
} |
|
|
|
|
//判断文件中是否存在数据
|
|
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -376,16 +368,12 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
|
|
|
|
|
String moduleId = voList.get(i).getModuleId(); |
|
|
|
|
if (moduleId == null || moduleId.equals("")) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
|
} |
|
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(Modulex::getId, moduleId); |
|
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
|
if (modulex == null) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
|
} |
|
|
|
|
String modulexId = modulex.getId(); |
|
|
|
@ -410,6 +398,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
tablex.setModuleId(voList.get(i).getModuleId()); |
|
|
|
|
tablex.setTableName(voList.get(i).getTableName()); |
|
|
|
|
tablex.setTableEnName(voList.get(i).getTableEnName()); |
|
|
|
@ -422,47 +414,37 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
|
|
|
|
|
tablexList.add(tablex); |
|
|
|
|
|
|
|
|
|
message.put("status", "正在上传"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
//单条保存到真实表中
|
|
|
|
|
tablexService.saveSingleBatch(tablexList, loginUser, message); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
message.put("status", "上传成功"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
/*message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件导入失败"); |
|
|
|
|
} |
|
|
|
|
/*message.put("isVisible", "false");*/ |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|