新增改为增加,单元格格式校验

dev^2
guilongma 1 year ago
parent 476e56d02b
commit 9290f843b5
  1. 94
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/functionx/service/impl/FunctionXTestServiceImpl.java

@ -9,10 +9,7 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
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.XSSFWorkbook;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
@ -114,7 +111,9 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
List<FunctionxTest> listVo = new ArrayList<>();
for (int i = 1; i <= lastRowIndex; i++) {
Row row = sheet.getRow(i); // 行
if(row!=null){
if (row == null ) {
continue;
} else {
short lastCellNum = row.getLastCellNum();
List<String> list = new ArrayList<>();
for (int j = 0; j < lastCellNum; j++) {
@ -122,7 +121,12 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
if (cell == null) {
list.add(null);
} else {
String cellValue = cell.getStringCellValue();
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
DataFormatter formatter = new DataFormatter();
//单元格不设置数字格式
cell.setCellStyle(null);
String cellValue = formatter.formatCellValue(cell,evaluator);
list.add(cellValue);
}
}
@ -214,7 +218,7 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块不能为空");
} else {
if (pModuleId != null){
if (pModuleId != null && pModuleId.length()>0) {
String pid = "";
for (Modulex modulex : modulexList) {
if (modulex.getModuleName().equals(pModuleId)) {
@ -300,14 +304,30 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
return Result.error("功能类型不能为空");
} else {
switch (functionType) {
case "列表": type=0; break;
case "新增": type=1; break;
case "删除": type=2; break;
case "修改": type=3; break;
case "查看": type=4; break;
case "导入": type=5; break;
case "导出": type=6; break;
case "其它": type=99; break;
case "列表":
type = 0;
break;
case "增加":
type = 1;
break;
case "删除":
type = 2;
break;
case "修改":
type = 3;
break;
case "查看":
type = 4;
break;
case "导入":
type = 5;
break;
case "导出":
type = 6;
break;
case "其它":
type = 99;
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i + 2) + "行功能类型错误");
@ -411,12 +431,24 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
} else {
// 值:未发布0、已发布1、开发中2、已完成3、已撤回4、已取消9;默认0
switch (workStatus) {
case "未发布": type=0; break;
case "已发布": type=1; break;
case "开发中": type=2; break;
case "已完成": type=3; break;
case "已撤回": type=4; break;
case "已取消": type=9; break;
case "未发布":
type = 0;
break;
case "已发布":
type = 1;
break;
case "开发中":
type = 2;
break;
case "已完成":
type = 3;
break;
case "已撤回":
type = 4;
break;
case "已取消":
type = 9;
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i + 2) + "行任务状态错误");
@ -518,9 +550,15 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
} else {
// 值:正常1、停用0、废弃9;默认1
switch (status) {
case "正常": type=1; break;
case "停用": type=0; break;
case "废弃": type=9; break;
case "正常":
type = 1;
break;
case "停用":
type = 0;
break;
case "废弃":
type = 9;
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i + 2) + "行任务状态错误");
@ -539,8 +577,12 @@ public class FunctionXTestServiceImpl extends ServiceImpl<FunctionxTestMapper, F
} else {
// 值:当前1、历史0;默认1
switch (verisonStatus) {
case "当前": type=1; break;
case "历史": type=0; break;
case "当前":
type = 1;
break;
case "历史":
type = 0;
break;
default:
message.put("isError", "true");
message.put("status", "第" + (i + 2) + "行版本状态错误");

Loading…
Cancel
Save