소스 검색

批量导入添加默认值

cr 4 일 전
부모
커밋
43b95903f7
1개의 변경된 파일35개의 추가작업 그리고 9개의 파일을 삭제
  1. 35 9
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

+ 35 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -704,8 +704,7 @@ public class WbsTreeContractController extends BladeController {
                     // 给单元格添加默认值并设置背景色为灰色
                     if (cell != null) {
                         // 设置默认值
-                        cell.setCellValue("公式配置,无法填写数据导入");
-
+                        cell.setCellValue("公式配置");
                         // 创建灰色背景样式
                         CellStyle grayStyle = singleSheetWorkbook.createCellStyle();
                         grayStyle.cloneStyleFrom(cell.getCellStyle()); // 保留原有样式
@@ -734,7 +733,7 @@ public class WbsTreeContractController extends BladeController {
                         if (cell != null) {
                             if(cell.getCellTypeEnum()==CellType.STRING){
                                 if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                                    if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                                    if(cell.getStringCellValue().equals("公式配置")){
                                         continue;
                                     }
                                 }
@@ -761,7 +760,7 @@ public class WbsTreeContractController extends BladeController {
                         if (cell != null) {
                             if(cell.getCellTypeEnum()==CellType.STRING){
                                 if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                                    if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                                    if(cell.getStringCellValue().equals("公式配置")){
                                         continue;
                                     }
                                 }
@@ -794,7 +793,7 @@ public class WbsTreeContractController extends BladeController {
                         if (cell != null) {
                             if(cell.getCellTypeEnum()==CellType.STRING){
                                 if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                                    if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                                    if(cell.getStringCellValue().equals("公式配置")){
                                         continue;
                                     }
                                 }
@@ -817,7 +816,7 @@ public class WbsTreeContractController extends BladeController {
                         if (cell != null) {
                             if(cell.getCellTypeEnum()==CellType.STRING){
                                 if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                                    if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                                    if(cell.getStringCellValue().equals("公式配置")){
                                         continue;
                                     }
                                 }
@@ -846,7 +845,7 @@ public class WbsTreeContractController extends BladeController {
                 if (cell != null) {
                     if(cell.getCellTypeEnum()==CellType.STRING){
                         if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                            if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                            if(cell.getStringCellValue().equals("公式配置")){
                                 continue;
                             }
                         }
@@ -874,7 +873,7 @@ public class WbsTreeContractController extends BladeController {
                 if (cell != null) {
                     if(cell.getCellTypeEnum()==CellType.STRING){
                         if(StringUtils.isNotEmpty(cell.getStringCellValue())){
-                            if(cell.getStringCellValue().equals("公式配置,无法填写数据导入")){
+                            if(cell.getStringCellValue().equals("公式配置")){
                                 continue;
                             }
                         }
@@ -891,6 +890,33 @@ public class WbsTreeContractController extends BladeController {
                 }
             }
         }
+        //6.对默认值字段添加默认值
+        Elements deflist = doc.getElementsByAttribute("defText");
+        if(!deflist.isEmpty()){
+            for (Element element : deflist) {
+                Elements x1 = element.getElementsByAttribute("x1");
+                Elements y1 = element.getElementsByAttribute("y1");
+                Cell cell = getCellAt(sourceSheet, x1.attr("x1"), y1.attr("y1"));
+                if (cell != null) {
+                    if(cell.getCellTypeEnum()==CellType.STRING){
+                        if(StringUtils.isNotEmpty(cell.getStringCellValue())){
+                            if(cell.getStringCellValue().equals("公式配置")){
+                                continue;
+                            }
+                        }
+                    }
+                    // 设置单元格值为"电签配置,请勿填写数据"
+                    cell.setCellValue("默认值配置");
+                    // 创建或获取单元格样式并设置居中
+                    CellStyle centerStyle = singleSheetWorkbook.createCellStyle();
+                    centerStyle.cloneStyleFrom(cell.getCellStyle()); // 保留原有样式
+                    centerStyle.setAlignment(HorizontalAlignment.CENTER); // 水平居中
+                    centerStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
+                    // 应用样式到单元格
+                    cell.setCellStyle(centerStyle);
+                }
+            }
+        }
     }
     Cell getCellAt(Sheet sheet, String x, String y) {
         Row row = sheet.getRow(Integer.parseInt(y)-1);
@@ -1288,7 +1314,7 @@ public class WbsTreeContractController extends BladeController {
             String key = entry.getKey();
             String value = entry.getValue()+"";
             value = value.replaceAll("\\s+", "");
-            if(StringUtils.isNotEmpty(value)&&(value.equals("公式配置,无法填写数据导入")||value.equals("日期框")||value.equals("日期范围框,两日期用-分割")||value.equals("多选下拉框,如需填写选项内容,并用、分割")||value.equals("单选下拉框,如需填写选项内容,否则无法导入")||value.equals("电签配置,请勿填写数据")||value.equals("图片框,请到客户端上传"))){
+            if(StringUtils.isNotEmpty(value)&&(value.equals("公式配置")||value.equals("日期框")||value.equals("日期范围框,两日期用-分割")||value.equals("多选下拉框,如需填写选项内容,并用、分割")||value.equals("单选下拉框,如需填写选项内容,否则无法导入")||value.equals("电签配置,请勿填写数据")||value.equals("图片框,请到客户端上传")||value.equals("默认配置"))){
                 continue;
             }
             Matcher matcher = pattern.matcher(key);