|
|
|
@ -44,6 +44,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
|
|
|
|
import org.jsoup.helper.StringUtil; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
@ -316,6 +317,7 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Transactional |
|
|
|
|
@PostMapping("/importExcel") |
|
|
|
|
public Result<?> importExcel(@RequestPart MultipartFile file) throws Exception { |
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
@ -389,6 +391,40 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
List<Fieldx222> list = new ArrayList<>(); |
|
|
|
|
//获取excel的所有页
|
|
|
|
|
HashSet<String> zt = new HashSet<>(); |
|
|
|
|
zt.add("0"); |
|
|
|
|
zt.add("1"); |
|
|
|
|
zt.add("9"); |
|
|
|
|
HashSet<String> sf = new HashSet<>(); |
|
|
|
|
sf.add("0"); |
|
|
|
|
sf.add("1"); |
|
|
|
|
HashSet<String> sjlx = new HashSet<>(); |
|
|
|
|
sjlx.add("1"); |
|
|
|
|
sjlx.add("2"); |
|
|
|
|
sjlx.add("3"); |
|
|
|
|
sjlx.add("4"); |
|
|
|
|
sjlx.add("5"); |
|
|
|
|
sjlx.add("6"); |
|
|
|
|
sjlx.add("7"); |
|
|
|
|
sjlx.add("8"); |
|
|
|
|
sjlx.add("9"); |
|
|
|
|
sjlx.add("10"); |
|
|
|
|
sjlx.add("11"); |
|
|
|
|
sjlx.add("12"); |
|
|
|
|
sjlx.add("13"); |
|
|
|
|
sjlx.add("14"); |
|
|
|
|
sjlx.add("15"); |
|
|
|
|
sjlx.add("16"); |
|
|
|
|
sjlx.add("17"); |
|
|
|
|
sjlx.add("18"); |
|
|
|
|
sjlx.add("19"); |
|
|
|
|
sjlx.add("20"); |
|
|
|
|
sjlx.add("21"); |
|
|
|
|
sjlx.add("22"); |
|
|
|
|
sjlx.add("23"); |
|
|
|
|
sjlx.add("24"); |
|
|
|
|
sjlx.add("25"); |
|
|
|
|
sjlx.add("26"); |
|
|
|
|
int numberofSheets= workbook.getNumberOfSheets(); |
|
|
|
|
for (int i=0;i< numberofSheets;i++) |
|
|
|
|
{ |
|
|
|
@ -406,10 +442,9 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
Fieldx222 fieldx222 = new Fieldx222(); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getTableId())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”表名”不能为空"); |
|
|
|
|
message.put("closeable","true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”表名”不能为空或是此表不存在"); |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的表名不能为空"); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的表名不能为空或是此表不纯在"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setTableId(excelInfo.getTableId()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getFieldName())) { |
|
|
|
@ -435,15 +470,36 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的数据类型不能为空"); |
|
|
|
|
} |
|
|
|
|
else if(!sjlx.contains(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.getIsPk())) { |
|
|
|
|
fieldx222.setIsPk("0"); |
|
|
|
|
} |
|
|
|
|
else if(!sf.contains(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()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsFk())) { |
|
|
|
|
fieldx222.setIsFk("0"); |
|
|
|
|
} |
|
|
|
|
else if(!sf.contains(excelInfo.getIsFk())){ |
|
|
|
|
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()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsNull())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
@ -452,7 +508,14 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否为空不能为空"); |
|
|
|
|
} |
|
|
|
|
fieldx222.setIsFk(excelInfo.getIsFk()); |
|
|
|
|
else if(!sf.contains(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()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getIsUniqueness())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
|
message.put("status","序号为" + (r - 2) + "的”是否重复”不能为空"); |
|
|
|
@ -460,6 +523,13 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的是否重复不能为空"); |
|
|
|
|
} |
|
|
|
|
else if(!sf.contains(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.getStatus())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
@ -468,6 +538,13 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的”字段状态”不能为空"); |
|
|
|
|
} |
|
|
|
|
else if(!zt.contains(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.setStatus(excelInfo.getStatus()); |
|
|
|
|
if (StringUtil.isBlank(excelInfo.getVerisonStatus())) { |
|
|
|
|
message.put("isError", "true"); |
|
|
|
@ -476,6 +553,13 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> { |
|
|
|
|
webSocketUtils.sendMessage(loginUser.getId(), message); |
|
|
|
|
return Result.error("序号为" + (r - 2) + "的”版本状态”不能为空"); |
|
|
|
|
} |
|
|
|
|
else if(!sf.contains(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.setVerisonStatus(excelInfo.getVerisonStatus()); |
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(excelInfo.getAccuracy())) |
|
|
|
|