|
@@ -1,8 +1,10 @@
|
|
|
package nckd.jxccl.sit.hcsi.business.importtaskguide;
|
|
package nckd.jxccl.sit.hcsi.business.importtaskguide;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
+import com.kingdee.util.DateTimeUtils;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.resource.ResManager;
|
|
import kd.bos.dataentity.resource.ResManager;
|
|
|
|
|
+import kd.bos.dataentity.utils.StringUtils;
|
|
|
import kd.bos.exception.ErrorCode;
|
|
import kd.bos.exception.ErrorCode;
|
|
|
import kd.bos.exception.KDException;
|
|
import kd.bos.exception.KDException;
|
|
|
import kd.bos.form.FormShowParameter;
|
|
import kd.bos.form.FormShowParameter;
|
|
@@ -11,27 +13,21 @@ import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
import kd.bos.orm.query.QFilter;
|
|
|
import kd.bos.orm.util.CollectionUtils;
|
|
import kd.bos.orm.util.CollectionUtils;
|
|
|
-import kd.swc.hsas.business.cal.export.SWCExportDataHelper;
|
|
|
|
|
-import kd.swc.hsas.business.cal.service.CalResultCoverImportService;
|
|
|
|
|
-import kd.swc.hsbp.common.enums.DataTypeEnum;
|
|
|
|
|
import kd.swc.hsbp.common.enums.SWCShowType;
|
|
import kd.swc.hsbp.common.enums.SWCShowType;
|
|
|
-import kd.swc.hsbp.common.enums.WriteTaskTypeEnum;
|
|
|
|
|
-import kd.swc.hsbp.common.util.SWCDateTimeUtils;
|
|
|
|
|
import kd.swc.hsbp.common.util.SWCStringUtils;
|
|
import kd.swc.hsbp.common.util.SWCStringUtils;
|
|
|
|
|
+import nckd.jxccl.base.sit.helper.SITExportDataHelper;
|
|
|
import nckd.jxccl.sit.hcsi.business.importtaskguide.utils.ImportTaskUtils;
|
|
import nckd.jxccl.sit.hcsi.business.importtaskguide.utils.ImportTaskUtils;
|
|
|
|
|
+import nckd.jxccl.sit.hcsi.common.constant.enums.DataTypeEnum;
|
|
|
|
|
+import nckd.jxccl.sit.hcsi.common.constant.enums.SITShowType;
|
|
|
import nckd.jxccl.sit.hcsi.formplugin.web.tp.enums.SinsurPresetItemEnum;
|
|
import nckd.jxccl.sit.hcsi.formplugin.web.tp.enums.SinsurPresetItemEnum;
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
-import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
-import org.apache.poi.ss.usermodel.Comment;
|
|
|
|
|
-import org.apache.poi.ss.usermodel.Font;
|
|
|
|
|
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.streaming.*;
|
|
import org.apache.poi.xssf.streaming.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
|
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
|
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
|
|
|
|
|
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Tyx 2025-10-21
|
|
* Tyx 2025-10-21
|
|
@@ -65,7 +61,7 @@ public class ImportTaskGuideExportService {
|
|
|
Long sinsurTplId = (Long) parameter.getCustomParam("sinsurTplId");
|
|
Long sinsurTplId = (Long) parameter.getCustomParam("sinsurTplId");
|
|
|
// 导入任务ID
|
|
// 导入任务ID
|
|
|
Long importTaskId = (Long) parameter.getCustomParam("importTaskId");
|
|
Long importTaskId = (Long) parameter.getCustomParam("importTaskId");
|
|
|
- String dd = SWCDateTimeUtils.format(new Date(), "yyyyMMdd");
|
|
|
|
|
|
|
+ String dd = DateTimeUtils.format(new Date(), "yyyyMMdd");
|
|
|
String exportFileName = MessageFormat.format(ResManager.loadKDString("外部系统数据导入任务_数据导入模板_{0}", "ImportTaskGuideExportService_1", "swc-hsas-business", new Object[0]), dd);
|
|
String exportFileName = MessageFormat.format(ResManager.loadKDString("外部系统数据导入任务_数据导入模板_{0}", "ImportTaskGuideExportService_1", "swc-hsas-business", new Object[0]), dd);
|
|
|
createImportTaskDataSheet(sinsurTplId, wb, importTaskId);
|
|
createImportTaskDataSheet(sinsurTplId, wb, importTaskId);
|
|
|
flushAllAndDownload(wb, exportFileName, view);
|
|
flushAllAndDownload(wb, exportFileName, view);
|
|
@@ -109,11 +105,11 @@ public class ImportTaskGuideExportService {
|
|
|
sheet.setRandomAccessWindowSize(-1);
|
|
sheet.setRandomAccessWindowSize(-1);
|
|
|
SXSSFDrawing drawingPatriarch = sheet.createDrawingPatriarch();
|
|
SXSSFDrawing drawingPatriarch = sheet.createDrawingPatriarch();
|
|
|
SXSSFRow headRow = sheet.createRow(startLine - 2);
|
|
SXSSFRow headRow = sheet.createRow(startLine - 2);
|
|
|
- CellStyle headDateStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.DATE.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
- CellStyle headTextStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
- CellStyle headRequriedNumStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.NUM.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
|
|
+ CellStyle headDateStyle = getColumnStyle(true, 0, 0, SITShowType.DATE.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
+ CellStyle headTextStyle = getColumnStyle(true, 0, 0, SITShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
+ CellStyle headRequriedNumStyle = getColumnStyle(true, 0, 0, SITShowType.NUM.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
Font font = sheet.getWorkbook().createFont();
|
|
Font font = sheet.getWorkbook().createFont();
|
|
|
- CellStyle requrriedStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
|
|
+ CellStyle requrriedStyle = getColumnStyle(true, 0, 0, SITShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
font.setColor((short) 10);
|
|
font.setColor((short) 10);
|
|
|
requrriedStyle.setFont(font);
|
|
requrriedStyle.setFont(font);
|
|
|
headRequriedNumStyle.setFont(font);
|
|
headRequriedNumStyle.setFont(font);
|
|
@@ -199,15 +195,15 @@ public class ImportTaskGuideExportService {
|
|
|
|
|
|
|
|
private String getDataType(SinsurPresetItemEnum presetItemEnum) {
|
|
private String getDataType(SinsurPresetItemEnum presetItemEnum) {
|
|
|
if (presetItemEnum.getDataTypeId() == DataTypeEnum.DATE.getDbId()) {
|
|
if (presetItemEnum.getDataTypeId() == DataTypeEnum.DATE.getDbId()) {
|
|
|
- return SWCShowType.DATE.getCode();
|
|
|
|
|
|
|
+ return SITShowType.DATE.getCode();
|
|
|
} else {
|
|
} else {
|
|
|
- return presetItemEnum.getDataTypeId() == DataTypeEnum.NUMBERIC.getDbId() ? SWCShowType.NUM.getCode() : SWCShowType.TEXT.getCode();
|
|
|
|
|
|
|
+ return presetItemEnum.getDataTypeId() == DataTypeEnum.NUMBERIC.getDbId() ? SITShowType.NUM.getCode() : SITShowType.TEXT.getCode();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void flushAllAndDownload(SXSSFWorkbook wb, String fileName, IFormView view) {
|
|
private void flushAllAndDownload(SXSSFWorkbook wb, String fileName, IFormView view) {
|
|
|
- String url = SWCExportDataHelper.storeFile(wb, fileName);
|
|
|
|
|
- if (SWCStringUtils.isNotEmpty(url)) {
|
|
|
|
|
|
|
+ String url = SITExportDataHelper.storeFile(wb, fileName);
|
|
|
|
|
+ if (StringUtils.isNotEmpty(url)) {
|
|
|
view.download(url);
|
|
view.download(url);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -222,7 +218,7 @@ public class ImportTaskGuideExportService {
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(rowNum);
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(rowNum);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- String dd = SWCDateTimeUtils.format(new Date(), "yyyyMMdd");
|
|
|
|
|
|
|
+ String dd = DateTimeUtils.format(new Date(), "yyyyMMdd");
|
|
|
String exportFileName = MessageFormat.format(ResManager.loadKDString("历史数据迁移任务_数据导入失败结果_{0}", "ImportTaskGuideExportService_3", "swc-hsas-business", new Object[0]), dd);
|
|
String exportFileName = MessageFormat.format(ResManager.loadKDString("历史数据迁移任务_数据导入失败结果_{0}", "ImportTaskGuideExportService_3", "swc-hsas-business", new Object[0]), dd);
|
|
|
String sheetName = ResManager.loadKDString("数据导入模板", "ImportTaskGuideExportService_2", "swc-hsas-business", new Object[0]);
|
|
String sheetName = ResManager.loadKDString("数据导入模板", "ImportTaskGuideExportService_2", "swc-hsas-business", new Object[0]);
|
|
|
SXSSFSheet sheet = wb.createSheet(sheetName);
|
|
SXSSFSheet sheet = wb.createSheet(sheetName);
|
|
@@ -247,7 +243,7 @@ public class ImportTaskGuideExportService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.addDataRow(dataRowList, errDataList, headIndex, wb, sheet);
|
|
this.addDataRow(dataRowList, errDataList, headIndex, wb, sheet);
|
|
|
- url = SWCExportDataHelper.storeFile(wb, exportFileName);
|
|
|
|
|
|
|
+ url = SITExportDataHelper.storeFile(wb, exportFileName);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -268,12 +264,12 @@ public class ImportTaskGuideExportService {
|
|
|
|
|
|
|
|
private void createHeadRow(List<Map<Integer, String>> dataHeadList, int headIndex, SXSSFSheet sheet, SXSSFDrawing drawingPatriarch, String writeTaskType) {
|
|
private void createHeadRow(List<Map<Integer, String>> dataHeadList, int headIndex, SXSSFSheet sheet, SXSSFDrawing drawingPatriarch, String writeTaskType) {
|
|
|
SXSSFRow headRow = sheet.createRow(headIndex);
|
|
SXSSFRow headRow = sheet.createRow(headIndex);
|
|
|
- CellStyle headTextStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
|
|
+ CellStyle headTextStyle = getColumnStyle(true, 0, 0, SITShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
SXSSFCell errMsgCell = headRow.createCell(0);
|
|
SXSSFCell errMsgCell = headRow.createCell(0);
|
|
|
errMsgCell.setCellValue(ResManager.loadKDString("失败原因", "CalResultCoverImportService_58", "swc-hsas-business", new Object[0]));
|
|
errMsgCell.setCellValue(ResManager.loadKDString("失败原因", "CalResultCoverImportService_58", "swc-hsas-business", new Object[0]));
|
|
|
errMsgCell.setCellStyle(headTextStyle);
|
|
errMsgCell.setCellStyle(headTextStyle);
|
|
|
Font font = sheet.getWorkbook().createFont();
|
|
Font font = sheet.getWorkbook().createFont();
|
|
|
- CellStyle requrriedStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, SWCShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
|
|
|
|
+ CellStyle requrriedStyle = getColumnStyle(true, 0, 0, SITShowType.TEXT.getCode(), HorizontalAlignment.LEFT, sheet.getWorkbook(), HSSFColor.HSSFColorPredefined.GREY_25_PERCENT.getIndex(), true);
|
|
|
font.setColor((short)10);
|
|
font.setColor((short)10);
|
|
|
requrriedStyle.setFont(font);
|
|
requrriedStyle.setFont(font);
|
|
|
Set<Integer> requireFixColumnSet = ImportTaskUtils.getExportTplRequireColumnSet();
|
|
Set<Integer> requireFixColumnSet = ImportTaskUtils.getExportTplRequireColumnSet();
|
|
@@ -300,7 +296,7 @@ public class ImportTaskGuideExportService {
|
|
|
List<Map<String, String>> paramMapList = (List)entry.getValue();
|
|
List<Map<String, String>> paramMapList = (List)entry.getValue();
|
|
|
if (!CollectionUtils.isEmpty(paramMapList)) {
|
|
if (!CollectionUtils.isEmpty(paramMapList)) {
|
|
|
String dataTypeIdStr = (String)((Map)paramMapList.get(0)).get("datatypeid");
|
|
String dataTypeIdStr = (String)((Map)paramMapList.get(0)).get("datatypeid");
|
|
|
- if (!SWCStringUtils.isEmpty(dataTypeIdStr) && Long.parseLong(dataTypeIdStr) == DataTypeEnum.STRING.getDbId()) {
|
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(dataTypeIdStr) && Long.parseLong(dataTypeIdStr) == DataTypeEnum.STRING.getDbId()) {
|
|
|
textIndexList.add((Integer)entry.getKey() + 1);
|
|
textIndexList.add((Integer)entry.getKey() + 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -312,11 +308,11 @@ public class ImportTaskGuideExportService {
|
|
|
Map<Integer, List<String>> errorMap = this.getErrorMap(errDataList);
|
|
Map<Integer, List<String>> errorMap = this.getErrorMap(errDataList);
|
|
|
boolean isTplError = "1".equals(((Map)errDataList.get(0)).get("isAll"));
|
|
boolean isTplError = "1".equals(((Map)errDataList.get(0)).get("isAll"));
|
|
|
int tplIndex = headIndex++;
|
|
int tplIndex = headIndex++;
|
|
|
- CellStyle errColumnStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, "text", HorizontalAlignment.LEFT, wb, (short)9, true);
|
|
|
|
|
|
|
+ CellStyle errColumnStyle = getColumnStyle(true, 0, 0, "text", HorizontalAlignment.LEFT, wb, (short)9, true);
|
|
|
Font font = wb.createFont();
|
|
Font font = wb.createFont();
|
|
|
font.setColor((short)10);
|
|
font.setColor((short)10);
|
|
|
errColumnStyle.setFont(font);
|
|
errColumnStyle.setFont(font);
|
|
|
- CellStyle columnStyle = CalResultCoverImportService.getColumnStyle(true, 0, 0, "text", HorizontalAlignment.LEFT, wb, (short)9, true);
|
|
|
|
|
|
|
+ CellStyle columnStyle = getColumnStyle(true, 0, 0, "text", HorizontalAlignment.LEFT, wb, (short)9, true);
|
|
|
List<String> errorList = null;
|
|
List<String> errorList = null;
|
|
|
Map<Integer, String> rowMap = null;
|
|
Map<Integer, String> rowMap = null;
|
|
|
SXSSFRow dataRow = null;
|
|
SXSSFRow dataRow = null;
|
|
@@ -375,4 +371,60 @@ public class ImportTaskGuideExportService {
|
|
|
return key.toString();
|
|
return key.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public static CellStyle getColumnStyle(boolean isTmpl, int precision, int scale, String columnType, HorizontalAlignment alignment, SXSSFWorkbook wb, short colorIndex, boolean needBoard) {
|
|
|
|
|
+ CellStyle headColumnStyle = wb.createCellStyle();
|
|
|
|
|
+ DataFormat dataFormat = wb.createDataFormat();
|
|
|
|
|
+ short format;
|
|
|
|
|
+ if (!isTmpl) {
|
|
|
|
|
+ if (SWCStringUtils.equals(SWCShowType.DATE.getCode(), columnType)) {
|
|
|
|
|
+ format = dataFormat.getFormat("yyyy-MM-dd");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String amountFormat;
|
|
|
|
|
+ if (SWCStringUtils.equals(SWCShowType.AMOUNT.getCode(), columnType)) {
|
|
|
|
|
+ amountFormat = getAmountFormat(precision);
|
|
|
|
|
+ format = dataFormat.getFormat(amountFormat);
|
|
|
|
|
+ } else if (SWCStringUtils.equals(SWCShowType.NUM.getCode(), columnType)) {
|
|
|
|
|
+ amountFormat = getAmountFormat(scale);
|
|
|
|
|
+ format = dataFormat.getFormat(amountFormat);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ format = dataFormat.getFormat("text");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (SWCStringUtils.equals(SWCShowType.DATE.getCode(), columnType)) {
|
|
|
|
|
+ format = dataFormat.getFormat("yyyy-MM-dd");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ format = dataFormat.getFormat("text");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ headColumnStyle.setDataFormat(format);
|
|
|
|
|
+ if (needBoard) {
|
|
|
|
|
+ headColumnStyle.setBorderBottom(BorderStyle.HAIR);
|
|
|
|
|
+ headColumnStyle.setBorderTop(BorderStyle.HAIR);
|
|
|
|
|
+ headColumnStyle.setBorderLeft(BorderStyle.HAIR);
|
|
|
|
|
+ headColumnStyle.setBorderRight(BorderStyle.HAIR);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ headColumnStyle.setFillForegroundColor(colorIndex);
|
|
|
|
|
+ headColumnStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
|
|
+ headColumnStyle.setAlignment(alignment);
|
|
|
|
|
+ headColumnStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
+ headColumnStyle.setHidden(true);
|
|
|
|
|
+ return headColumnStyle;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String getAmountFormat(int precision) {
|
|
|
|
|
+ StringBuilder format = new StringBuilder("0");
|
|
|
|
|
+ if (precision > 0) {
|
|
|
|
|
+ format.append('.');
|
|
|
|
|
+
|
|
|
|
|
+ for(int i = 0; i < precision; ++i) {
|
|
|
|
|
+ format.append('0');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return format.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|