dev^2
itcast 1 year ago
parent 9d748bffeb
commit 7f392c6c26
  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

@ -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.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
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.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
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++) {
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;
}
ExcelInfo excelInfo = new ExcelInfo();
excelInfo.setcells(cells,workbook);
Fieldx222 fieldx222 = new Fieldx222();

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

@ -40,9 +40,6 @@ public class FieldxServiceImpl extends ServiceImpl<FieldxMapper, Fieldx> impleme
Thread.sleep(500L);
message.put("uploaded", String.valueOf(i + 1));
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);
} catch (InterruptedException e) {
log.error(e.getMessage(), e);

Loading…
Cancel
Save