模块管理导入功能交互

dev^2
lijinyu 1 year ago
parent 7f392c6c26
commit ef40ab58f4
  1. 34
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -371,6 +371,7 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
int numberOfSheets = wb.getNumberOfSheets(); int numberOfSheets = wb.getNumberOfSheets();
for (int i = 0; i < numberOfSheets; i++) { for (int i = 0; i < numberOfSheets; i++) {
Sheet sheet = wb.getSheetAt(i); Sheet sheet = wb.getSheetAt(i);
//获取行数 //获取行数
int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
for (int j = 2; j < physicalNumberOfRows; j++) { for (int j = 2; j < physicalNumberOfRows; j++) {
@ -380,6 +381,14 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
if(row==null){ if(row==null){
continue; continue;
} }
boolean rowEmpty = isRowEmpty(row);
if(rowEmpty){
message.put("isError", "true");
message.put("status", "模块管理execl表格不规范有空行存在,请重新上传");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("模块管理execl表格不规范有空行存在,请重新上传");
}
//获取单行单元格数 //获取单行单元格数
Integer physicalNumberOfCells = null; Integer physicalNumberOfCells = null;
if (row == null) { if (row == null) {
@ -432,7 +441,10 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
int annual = 0; int annual = 0;
for (int k = 0; k < physicalNumberOfCells; k++) { for (int k = 0; k < physicalNumberOfCells; k++) {
Cell cell = row.getCell(k); Cell cell = row.getCell(k);
String value = cell.getStringCellValue(); String value="";
if(cell!=null){
value = cell.getStringCellValue();
}
switch (k){ switch (k){
case 0: case 0:
modulexVo.setPid(value); modulexVo.setPid(value);
@ -957,9 +969,6 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
modulexList.add(modulex); modulexList.add(modulex);
} }
// for (ModulexTemplate modulexTemplate : modulexTemplates) {
//
// }
boolean result = this.saveSingleBatch(modulexList, loginUser, message); boolean result = this.saveSingleBatch(modulexList, loginUser, message);
if(!result){ if(!result){
message.put("isError", "true"); message.put("isError", "true");
@ -1323,7 +1332,18 @@ public class ModulexServiceImpl extends ServiceImpl<ModulexMapper, Modulex> impl
} }
return pinyinStr; return pinyinStr;
} }
/**
* 判断是否有空行
* @param row
* @return
*/
private boolean isRowEmpty(Row row) {
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
Cell cell = row.getCell(c);
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
return false;
}
}
return true;
}
} }

Loading…
Cancel
Save