|
|
|
@ -324,14 +324,24 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
message.put("isVisible", "true"); |
|
|
|
|
message.put("uploaded", "0"); |
|
|
|
|
message.put("status", "判断文件结构"); |
|
|
|
|
message.put("isError", "false"); |
|
|
|
|
message.put("closeable","false"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
if (file == null) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","文件上传失败"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件上传失败"); |
|
|
|
|
} |
|
|
|
|
//判断格式
|
|
|
|
|
String path = file.getOriginalFilename(); |
|
|
|
|
if (!(path.endsWith(".xls") || path.endsWith(".xlsx"))) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","文件格式上传有误"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件格式上传有误"); |
|
|
|
|
} |
|
|
|
|
//根据格式读取
|
|
|
|
@ -347,7 +357,14 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
//判断表结构
|
|
|
|
|
Row row=first.getRow(2); |
|
|
|
|
if(row==null) |
|
|
|
|
{ |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","表结构不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("表结构不能为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!"序号".equals(row.getCell(0).getStringCellValue())||!"表名".equals(row.getCell(1).getStringCellValue()) |
|
|
|
|
||!"中文名称".equals(row.getCell(2).getStringCellValue())||!"英文名称".equals(row.getCell(3).getStringCellValue()) |
|
|
|
@ -357,8 +374,14 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
||!"关联实体".equals(row.getCell(10).getStringCellValue())||!"关联字段".equals(row.getCell(11).getStringCellValue()) |
|
|
|
|
||!"是否为空".equals(row.getCell(12).getStringCellValue())||!"是否重复".equals(row.getCell(13).getStringCellValue()) |
|
|
|
|
||!"字段规则".equals(row.getCell(14).getStringCellValue())||!"字段状态".equals(row.getCell(15).getStringCellValue()) |
|
|
|
|
||!"版本状态".equals(row.getCell(16).getStringCellValue())) |
|
|
|
|
||!"版本状态".equals(row.getCell(16).getStringCellValue())){ |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","表结构不正确"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("表结构不正确"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//读取表
|
|
|
|
@ -374,56 +397,94 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
for(int r=3;r<=Sheet.getLastRowNum();r++) { |
|
|
|
|
Row cells = Sheet.getRow(r); |
|
|
|
|
String cell = cells.getCell(0).getStringCellValue(); |
|
|
|
|
if (StringUtils.isEmpty(cell)) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(String.valueOf(cell))) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
ExcelInfo excelInfo = new ExcelInfo(); |
|
|
|
|
excelInfo.setcells(cells); |
|
|
|
|
Fieldx222 fieldx222 = new Fieldx222(); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getTableId())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”表名”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的表名不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setTableId(excelInfo.getTableId()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getFieldName())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为 + (r - 2) + 的”中文名称”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的中文名称不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setFieldName(excelInfo.getFieldName()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getFieldEnName())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”英文名称”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的英文名称不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setFieldEnName(excelInfo.getFieldEnName()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getType())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”数据类型”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的数据类型不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setType(excelInfo.getType()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getLength())) { |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的数据长度不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setLength(excelInfo.getLength()); |
|
|
|
|
|
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsPk())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”是否主键”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否主键不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setIsPk(excelInfo.getIsPk()); |
|
|
|
|
fieldx222.setIsPk(excelInfo.getIsFk()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsFk())) { |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否外键不能为空"); |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”是否外键”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "”的是否外键”不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setIsFk(excelInfo.getIsFk()); |
|
|
|
|
fieldx222.setIsFk(excelInfo.getIsNull()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsNull())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”是否为空”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否为空不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setIsNull(excelInfo.getIsNull()); |
|
|
|
|
fieldx222.setIsNull(excelInfo.getIsUniqueness()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsUniqueness())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”是否重复”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否重复不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setIsUniqueness(excelInfo.getIsUniqueness()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getVerisonStatus())) { |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的字段状态不能为空"); |
|
|
|
|
fieldx222.setStatus(excelInfo.getStatus()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getStatus())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”字段状态”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的”字段状态”不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setVerisonStatus(excelInfo.getVerisonStatus()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getVerison())) { |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的版本状态不能为空"); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getVerisonStatus())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”版本状态”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的”版本状态”不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setVerison(excelInfo.getVerison()); |
|
|
|
|
fieldx222.setVerisonStatus(excelInfo.getVerisonStatus()); |
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(excelInfo.getAccuracy())) |
|
|
|
|
fieldx222.setAccuracy(excelInfo.getAccuracy()); |
|
|
|
@ -435,11 +496,14 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
fieldx222.setAssociateField(excelInfo.getAssociateField()); |
|
|
|
|
if (!StringUtils.isEmpty(excelInfo.getRule())) |
|
|
|
|
fieldx222.setRull(excelInfo.getRule()); |
|
|
|
|
if (!StringUtils.isEmpty(excelInfo.getLength())) |
|
|
|
|
fieldx222.setLength(excelInfo.getLength()); |
|
|
|
|
list.add(fieldx222); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
message.put("status", "数据预读入成功"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
|
|
|
|
|
message.put("status", "正在上传"); |
|
|
|
@ -449,9 +513,16 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
message.put("records", String.valueOf(list222.size())); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
fieldx222Service.remove(null); |
|
|
|
|
if(list222==null) |
|
|
|
|
if(list222==null){ |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","文件格式不正确"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("文件上传失败"); |
|
|
|
|
} |
|
|
|
|
//将中间表导入数据库
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
List<Fieldx> list1= list222.stream().map((item)->{ |
|
|
|
|
Fieldx fieldx=new Fieldx(); |
|
|
|
|
String id=item.getId(); |
|
|
|
@ -459,13 +530,12 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
fieldx.setFieldName(item.getFieldName()); |
|
|
|
|
fieldx.setFieldEnName(item.getFieldName()); |
|
|
|
|
fieldx.setType(Integer.valueOf(item.getType())); |
|
|
|
|
fieldx.setLength(Integer.valueOf(item.getLength())); |
|
|
|
|
fieldx.setIsPk(Integer.valueOf(item.getIsPk())); |
|
|
|
|
fieldx.setIsFk(Integer.valueOf(item.getIsFk())); |
|
|
|
|
fieldx.setIsNull(Integer.valueOf(item.getIsNull())); |
|
|
|
|
fieldx.setIsUniqueness(Integer.valueOf(item.getIsUniqueness())); |
|
|
|
|
fieldx.setStatus(Integer.valueOf(item.getStatus())); |
|
|
|
|
fieldx.setVerisonStatus(Integer.valueOf(item.getVerisonStatus())); |
|
|
|
|
fieldx.setVerison(Integer.valueOf(item.getVerison())); |
|
|
|
|
if(!StringUtils.isEmpty(item.getAccuracy())) |
|
|
|
|
fieldx.setAccuracy(Integer.valueOf(item.getAccuracy())); |
|
|
|
|
if(!StringUtils.isEmpty(item.getFormat())) |
|
|
|
@ -476,13 +546,23 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
fieldx.setAssociateField(item.getAssociateField()); |
|
|
|
|
if(!StringUtils.isEmpty(item.getRull())) |
|
|
|
|
fieldx.setRule(item.getRull()); |
|
|
|
|
if(!StringUtils.isEmpty(item.getLength())) |
|
|
|
|
fieldx.setLength(Integer.valueOf(item.getLength())); |
|
|
|
|
return fieldx; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
//将中间表数据导入数据库
|
|
|
|
|
fieldxService.saveBatch(list1); |
|
|
|
|
//将表数据导入数据库
|
|
|
|
|
|
|
|
|
|
fieldxService.saveSingleBatch(list1,loginUser, message); |
|
|
|
|
message.put("status", "上传成功"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","单元格样式错误,请根据注意事项保证单元格样式正确"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
} |
|
|
|
|
return Result.OK("文件上传成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|