Merge remote-tracking branch 'origin/dev_2307' into dev_2307

dev^2
guilongma 1 year ago
commit ae38db469c
  1. 11
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java
  2. 55
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/dto/ExcelInfo.java
  3. 3
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/service/impl/FieldxServiceImpl.java
  4. 34
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/modulex/service/impl/ModulexServiceImpl.java

@ -12,10 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -432,12 +429,12 @@ public class FieldxController extends JeecgController<Fieldx, IFieldxService> {
for(int r=3;r<=Sheet.getLastRowNum();r++) { for(int r=3;r<=Sheet.getLastRowNum();r++) {
Row cells = Sheet.getRow(r); Row cells = Sheet.getRow(r);
String cell = cells.getCell(0).getStringCellValue(); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
if (StringUtils.isEmpty(String.valueOf(cell))) { Cell cell = cells.getCell(0);
if (cell==null||String.valueOf(cell).equals("")) {
break; break;
} }
ExcelInfo excelInfo = new ExcelInfo(); ExcelInfo excelInfo = new ExcelInfo();
excelInfo.setcells(cells,workbook); excelInfo.setcells(cells,workbook);
Fieldx222 fieldx222 = new Fieldx222(); Fieldx222 fieldx222 = new Fieldx222();

@ -125,57 +125,57 @@ public class ExcelInfo {
return null; return null;
if(value.equals("否")||value.equals("历史")||value.equals("停用")) if(value.equals("否")||value.equals("历史")||value.equals("停用"))
return "0"; return "0";
if(value.equals("是")|| value.equals("正常")||value.equals("当前")||value.equals("TINYINT")) if(value.equals("是")|| value.equals("正常")||value.equals("当前")||value.equals("TINYINT")||value.equals("tinyint"))
return "1"; return "1";
if(value.equals("SMALLINT")) if(value.equals("SMALLINT")||value.equals("smallint"))
return "2"; return "2";
if(value.equals("MEDIUMINT")) if(value.equals("MEDIUMINT")||value.equals("mediumint"))
return "3"; return "3";
if(value.equals("INT")) if(value.equals("INT")||value.equals("int"))
return "4"; return "4";
if(value.equals("BIGINT")) if(value.equals("BIGINT")||value.equals("bigint"))
return "5"; return "5";
if(value.equals("FLOAT")) if(value.equals("FLOAT")||value.equals("float"))
return "6"; return "6";
if(value.equals("DOUBLE")) if(value.equals("DOUBLE")||value.equals("double"))
return "7"; return "7";
if(value.equals("DECIMAL")) if(value.equals("DECIMAL")||value.equals("decimal"))
return "8"; return "8";
if(value.equals("YEAR")||value.equals("废弃")) if(value.equals("YEAR")||value.equals("year")||value.equals("废弃"))
return "9"; return "9";
if(value.equals("TIME")) if(value.equals("TIME")||value.equals("time"))
return "10"; return "10";
if(value.equals("DATE")) if(value.equals("DATE")||value.equals("date"))
return "11"; return "11";
if(value.equals("DATETIME")) if(value.equals("DATETIME")||value.equals("datetime"))
return "12"; return "12";
if(value.equals("TIMESTAMP")) if(value.equals("TIMESTAMP")||value.equals("timestamp"))
return "13"; return "13";
if(value.equals("CHAR")) if(value.equals("CHAR")||value.equals("char"))
return "14"; return "14";
if(value.equals("VARCHAR")) if(value.equals("VARCHAR")||value.equals("varchar"))
return "15"; return "15";
if(value.equals("BINARY")) if(value.equals("BINARY")||value.equals("binary"))
return "16"; return "16";
if(value.equals("VARBINARY")) if(value.equals("VARBINARY")||value.equals("varbinary"))
return "17"; return "17";
if(value.equals("BLOB")) if(value.equals("BLOB")||value.equals("blob"))
return "18"; return "18";
if(value.equals("TEXT")) if(value.equals("TEXT")||value.equals("text"))
return "19"; return "19";
if(value.equals("ENUM")) if(value.equals("ENUM")||value.equals("enum"))
return "20"; return "20";
if(value.equals("SET")) if(value.equals("SET")||value.equals("set"))
return "21"; return "21";
if(value.equals("BIT")) if(value.equals("BIT")||value.equals("bit"))
return "22"; return "22";
if(value.equals("TINYBLOB")) if(value.equals("TINYBLOB")||value.equals("tinyblob"))
return "23"; return "23";
if(value.equals("BLOB")) if(value.equals("BLOB")||value.equals("blob"))
return "24"; return "24";
if(value.equals("MEDIUMBLOB")) if(value.equals("MEDIUMBLOB")||value.equals("mediumblob"))
return "25"; return "25";
if(value.equals("LONGBLOB")) if(value.equals("LONGBLOB")||value.equals("longblob"))
return "26"; return "26";
return value; return value;
} }
@ -186,6 +186,9 @@ private String zhcell(Cell cell){
DataFormatter formatter = new DataFormatter(); DataFormatter formatter = new DataFormatter();
// 清除单元格的样式 // 清除单元格的样式
if (cell==null||String.valueOf(cell).equals("")) {
return null;
}
cell.setCellStyle(null); cell.setCellStyle(null);
//使用数据格式化器和公式求值器,将单元格的值格式化为字符串 //使用数据格式化器和公式求值器,将单元格的值格式化为字符串
String name = formatter.formatCellValue(cell, evaluator); String name = formatter.formatCellValue(cell, evaluator);

@ -40,9 +40,6 @@ public class FieldxServiceImpl extends ServiceImpl<FieldxMapper, Fieldx> impleme
Thread.sleep(500L); Thread.sleep(500L);
message.put("uploaded", String.valueOf(i + 1)); message.put("uploaded", String.valueOf(i + 1));
this.save(fieldxList.get(i)); this.save(fieldxList.get(i));
Tablex tablex = tablexService.getById(fieldxList.get(i).getTableId());
tablexService.updateVersion(fieldxList.get(i).getTableId(), tablex.getVerison() + 1);
tablexService.updateSql(fieldxList.get(i).getTableId(), fieldxController.createSql(fieldxList.get(i).getTableId()));
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

@ -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