|
|
@ -292,6 +292,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
message.put("isVisible", "true"); |
|
|
|
message.put("isVisible", "true"); |
|
|
|
message.put("uploaded", "0"); |
|
|
|
message.put("uploaded", "0"); |
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
|
|
|
|
message.put("isError", "false"); |
|
|
|
|
|
|
|
message.put("closeable","false"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -300,6 +302,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
if (StringUtils.isBlank(originalFilename) || |
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","文件格式不正确"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -313,10 +319,18 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
//读取excel数据
|
|
|
|
//读取excel数据
|
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); |
|
|
|
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","文件读取失败"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("文件读取失败"); |
|
|
|
return Result.error("文件读取失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
//判断文件中是否存在数据
|
|
|
|
//判断文件中是否存在数据
|
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
if (list == null || list.size() == 0) { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","Excel数据为空"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -338,7 +352,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
//判断版本号长度
|
|
|
|
//判断版本号长度
|
|
|
|
String verison = tablexVo.getVerison(); |
|
|
|
String verison = tablexVo.getVerison(); |
|
|
|
if (verison.length() > 5) { |
|
|
|
if (verison.length() > 5) { |
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","预读入失败,版本号格式错误"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("预读入失败,版本号格式错误"); |
|
|
|
return Result.error("预读入失败,版本号格式错误"); |
|
|
|
} |
|
|
|
} |
|
|
@ -354,7 +370,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
tablexVoService.removeAll(voList); |
|
|
|
tablexVoService.removeAll(voList); |
|
|
|
|
|
|
|
|
|
|
|
if (voList.size() == 0) { |
|
|
|
if (voList.size() == 0) { |
|
|
|
/* message.put("isVisible", "false");*/ |
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,数据为空"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
} |
|
|
|
} |
|
|
@ -368,12 +386,20 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
|
|
|
|
|
|
|
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("status","导入失败,对应模块填写不能为空"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(Modulex::getId, moduleId); |
|
|
|
queryWrapper.eq(Modulex::getId, moduleId); |
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
if (modulex == null) { |
|
|
|
if (modulex == null) { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,对应模块填写错误"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
} |
|
|
|
} |
|
|
|
String modulexId = modulex.getId(); |
|
|
|
String modulexId = modulex.getId(); |
|
|
@ -421,28 +447,57 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
tablexService.saveSingleBatch(tablexList, loginUser, message); |
|
|
|
tablexService.saveSingleBatch(tablexList, loginUser, message); |
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "上传成功"); |
|
|
|
message.put("status", "上传成功"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
|
|
|
message.put("status","文件导入失败"); |
|
|
|
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("文件导入失败"); |
|
|
|
return Result.error("文件导入失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|