|
|
@ -281,7 +281,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
* 通过excel导入数据 |
|
|
|
* 通过excel导入数据 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param file |
|
|
|
* @param file |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
public Result<?> importExcel(MultipartFile file) { |
|
|
|
public Result<?> importExcel(MultipartFile file) { |
|
|
@ -293,7 +293,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
message.put("uploaded", "0"); |
|
|
|
message.put("uploaded", "0"); |
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
message.put("isError", "false"); |
|
|
|
message.put("isError", "false"); |
|
|
|
message.put("closeable", "false"); |
|
|
|
message.put("closeable","false"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -303,8 +303,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
(!originalFilename.endsWith("xls") && |
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
!originalFilename.endsWith("xlsx"))) { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "文件格式不正确"); |
|
|
|
message.put("status","文件格式不正确"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
return Result.error("文件格式不正确"); |
|
|
|
} |
|
|
|
} |
|
|
@ -320,16 +320,16 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
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("isError", "true"); |
|
|
|
message.put("status", "文件读取失败"); |
|
|
|
message.put("status","文件读取失败"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
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("isError", "true"); |
|
|
|
message.put("status", "Excel数据为空"); |
|
|
|
message.put("status","Excel数据为空"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
return Result.error("Excel数据为空"); |
|
|
|
} |
|
|
|
} |
|
|
@ -363,8 +363,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
|
|
|
|
|
|
|
|
if (voList.size() == 0) { |
|
|
|
if (voList.size() == 0) { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "导入失败,数据为空"); |
|
|
|
message.put("status","导入失败,数据为空"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
return Result.error("导入失败,数据为空"); |
|
|
|
} |
|
|
|
} |
|
|
@ -382,20 +382,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("isError", "true"); |
|
|
|
message.put("status", "导入失败,对应模块填写不能为空"); |
|
|
|
message.put("status","导入失败,对应模块填写不能为空"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
return Result.error("对应模块填写不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//判断实体是否已存在
|
|
|
|
//判断实体是否已存在
|
|
|
|
LambdaQueryWrapper<Tablex> query = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<Tablex> query = new LambdaQueryWrapper<>(); |
|
|
|
query.eq(Tablex::getModuleId, voList.get(i).getModuleId()); |
|
|
|
query.eq(Tablex::getModuleId,voList.get(i).getModuleId()); |
|
|
|
Tablex tablex1 = tablexService.getOne(query); |
|
|
|
Tablex tablex1 = tablexService.getOne(query); |
|
|
|
if (tablex1 != null) { |
|
|
|
if (tablex1 != null){ |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "导入失败,第" + (i + 1) + "条的实体已存在"); |
|
|
|
message.put("status","导入失败,第" + (i + 1) + "条的实体已存在"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的实体已存在"); |
|
|
|
} |
|
|
|
} |
|
|
@ -405,8 +405,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
Modulex modulex = modulexService.getOne(queryWrapper); |
|
|
|
if (modulex == null) { |
|
|
|
if (modulex == null) { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "导入失败,对应模块填写错误"); |
|
|
|
message.put("status","导入失败,对应模块填写错误"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
return Result.error("对应模块填写错误"); |
|
|
|
} |
|
|
|
} |
|
|
@ -421,19 +421,19 @@ 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;
|
|
|
|
|
|
|
|
|
|
|
|
//判断版本号
|
|
|
|
//判断版本号
|
|
|
|
if (voList.get(i).getVerison() == null || voList.get(i).getVerison().equals("")) { |
|
|
|
if(voList.get(i).getVerison() == null || voList.get(i).getVerison().equals("")){ |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); |
|
|
|
message.put("status","导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的版本号填写不能为空!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//判断版本号是否为正整数且长度不能大于5
|
|
|
|
//判断版本号是否为正整数且长度不能大于5
|
|
|
|
if (!voList.get(i).getVerison().matches("^[0-9]*[1-9][0-9]*$") || voList.get(i).getVerison().length() > 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("isError", "true"); |
|
|
|
message.put("status", "导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -449,53 +449,52 @@ public class TablexController extends JeecgController<Tablex, ITablexService> { |
|
|
|
//判断版本状态
|
|
|
|
//判断版本状态
|
|
|
|
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { |
|
|
|
if (verisonStatus.equals("1") || verisonStatus.equals("0")) { |
|
|
|
|
|
|
|
|
|
|
|
message.put("status", "数据校验成功"); |
|
|
|
message.put("status", "数据校验成功"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
tablex.setModuleId(voList.get(i).getModuleId()); |
|
|
|
tablex.setModuleId(voList.get(i).getModuleId()); |
|
|
|
tablex.setTableName(voList.get(i).getTableName()); |
|
|
|
tablex.setTableName(voList.get(i).getTableName()); |
|
|
|
tablex.setTableEnName(voList.get(i).getTableEnName()); |
|
|
|
tablex.setTableEnName(voList.get(i).getTableEnName()); |
|
|
|
tablex.setTableStructure(voList.get(i).getTableStructure()); |
|
|
|
tablex.setTableStructure(voList.get(i).getTableStructure()); |
|
|
|
tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); |
|
|
|
tablex.setStructuralDiagram(voList.get(i).getStructuralDiagram()); |
|
|
|
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.setTableStructure("CREATE TABLE '" + voList.get(i).getTableEnName() + "' ();"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tablexList.add(tablex); |
|
|
|
tablexList.add(tablex); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
message.put("status","导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的版本状态填写错误!"); |
|
|
|
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) + "条的实体状态填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的实体状态填写错误!"); |
|
|
|
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) + "条的英文名称填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的英文名称填写错误!"); |
|
|
|
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) + "条的中文名称填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的中文名称填写错误!"); |
|
|
|
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) + "条的对应模块填写错误!"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的对应模块填写错误!"); |
|
|
|
return Result.error("导入失败,第" + (i + 1) + "条的对应模块填写错误!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -507,44 +506,44 @@ 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"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("isError", "true"); |
|
|
|
message.put("status", "文件导入失败"); |
|
|
|
message.put("status","文件导入失败"); |
|
|
|
message.put("closeable", "true"); |
|
|
|
message.put("closeable","true"); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
return Result.error("文件导入失败"); |
|
|
|
return Result.error("文件导入失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
return Result.ok("文件导入成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//导出实体标准模板
|
|
|
|
//导出实体标准模板
|
|
|
|
@RequestMapping(value = "/templateExcel") |
|
|
|
@RequestMapping(value = "/templateExcel") |
|
|
|
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
public ModelAndView wbsExcelTemplate(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
//设置导出文件名称
|
|
|
|
//设置导出文件名称
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Date date = new Date(System.currentTimeMillis()); |
|
|
|
Date date = new Date(System.currentTimeMillis()); |
|
|
|
String currTime = formatter.format(date); |
|
|
|
String currTime = formatter.format(date); |
|
|
|
String fileName = currTime + "-" + "模板.xlsx"; |
|
|
|
String fileName = currTime + "-" + "模板.xlsx"; |
|
|
|
try { |
|
|
|
try { |
|
|
|
String url = getClass().getClassLoader().getResource("static").getPath(); |
|
|
|
String url = getClass().getClassLoader().getResource("static").getPath(); |
|
|
|
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
|
|
|
|
// 模板存放地址 这里写的地址根本拿不到 在其他人的电脑上
|
|
|
|
String templateUrl = wordPath + File.separator + "实体表模板.xls"; |
|
|
|
String templateUrl = wordPath + File.separator + "实体表模板.xls"; |
|
|
|
TemplateExportParams params = new TemplateExportParams( |
|
|
|
TemplateExportParams params = new TemplateExportParams( |
|
|
|
templateUrl); |
|
|
|
templateUrl); |
|
|
|
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); |
|
|
|
ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView()); |
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); |
|
|
|
mv.addObject(TemplateExcelConstants.FILE_NAME, fileName); |
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, params); |
|
|
|
mv.addObject(TemplateExcelConstants.PARAMS, params); |
|
|
|
// 添加模板参数
|
|
|
|
// 添加模板参数
|
|
|
|
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
|
|
|
|
mv.addObject(TemplateExcelConstants.MAP_DATA, map); //data
|
|
|
|
return mv; |
|
|
|
return mv; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("下载模板异常--》{}", e); |
|
|
|
log.error("下载模板异常--》{}", e); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|