Просмотр исходного кода

1.社保外部系统数据导入相关插件

Tyx 1 неделя назад
Родитель
Сommit
7616e00a4c
13 измененных файлов с 1572 добавлено и 53 удалено
  1. 202 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/ImportTaskGuideExportService.java
  2. 431 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/ImportTaskGuideImportService.java
  3. 236 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/utils/ImportTaskUtils.java
  4. 138 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SinsurTempDataListPlugin.java
  5. 10 4
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SinsurTemplateEdit.java
  6. 44 32
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SitItemSelectAddItemPlugin.java
  7. 77 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/basedata/SinsurImpTaskListPlugin.java
  8. 128 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/basedata/TaskGuideImportFormPlugin.java
  9. 20 4
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/enums/SinsurPresetItemEnum.java
  10. 158 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/guide/TaskImpGuideListPlugin.java
  11. 2 2
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/helper/SinsurTemplateHelper.java
  12. 68 11
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/helper/SitItemSelectAddItemServiceHelper.java
  13. 58 0
      code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/utils/ReportUtils.java

+ 202 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/ImportTaskGuideExportService.java

@@ -0,0 +1,202 @@
+package nckd.jxccl.sit.hcsi.business.importtaskguide;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.IFormView;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.orm.query.QFilter;
+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.util.SWCDateTimeUtils;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+import nckd.jxccl.sit.hcsi.business.importtaskguide.utils.ImportTaskUtils;
+import nckd.jxccl.sit.hcsi.formplugin.web.tp.enums.SinsurPresetItemEnum;
+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.xssf.streaming.*;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+
+import java.text.MessageFormat;
+import java.util.*;
+
+/**
+ * Tyx 2025-10-21
+ * 导出Service,nckd_taskguideimport
+ */
+public class ImportTaskGuideExportService {
+
+    private static final Log logger = LogFactory.getLog(ImportTaskGuideExportService.class);
+    private static final int PAGE_SIZE = 500;
+    private static final String TPLERROR = "1";
+
+    /**
+     * 导入模板方法
+     * @param view
+     */
+    public void exportExcelTemplate(IFormView view) {
+        logger.info("-------- begin exportExcelTemplate --------");
+
+        try {
+            SXSSFWorkbook wb = new SXSSFWorkbook(500);
+            Throwable exp = null;
+            try {
+                FormShowParameter parameter = view.getFormShowParameter();
+                // 外部系统数据导入模板
+                Long sinsurTplId = (Long) parameter.getCustomParam("sinsurTplId");
+                // 导入任务ID
+                Long importTaskId = (Long) parameter.getCustomParam("importTaskId");
+                String dd = SWCDateTimeUtils.format(new Date(), "yyyyMMdd");
+                String exportFileName = MessageFormat.format(ResManager.loadKDString("外部系统数据导入任务_数据导入模板_{0}", "ImportTaskGuideExportService_1", "swc-hsas-business", new Object[0]), dd);
+                createImportTaskDataSheet(sinsurTplId, wb, importTaskId);
+                flushAllAndDownload(wb, exportFileName, view);
+            } catch (Throwable var18) {
+                exp = var18;
+                throw var18;
+            } finally {
+                if (wb != null) {
+                    if (exp != null) {
+                        try {
+                            wb.close();
+                        } catch (Throwable e1) {
+                            exp.addSuppressed(e1);
+                        }
+                    } else {
+                        wb.close();
+                    }
+                }
+
+            }
+        } catch (Exception e2) {
+            logger.error("ImportTaskGuideExportService  error : ", e2);
+            String str = ResManager.loadKDString("下载导入模板失败。", "ImportTaskGuideExportService_0", "swc-hsas-business", new Object[0]);
+            view.showErrorNotification(str);
+        }
+        logger.info("end exportExcelTemplate");
+    }
+
+    /**
+     * 创建Excel
+     * @param sinsurTplId
+     * @param wb
+     * @param importTaskId
+     */
+    private void createImportTaskDataSheet(Long sinsurTplId, SXSSFWorkbook wb, Long importTaskId) {
+        DynamicObject sinsurData = ImportTaskUtils.getSinsurTplData(sinsurTplId, "id,number,nckd_startline", (QFilter)null);
+        int startLine = sinsurData.getInt("nckd_startline");
+        String sheetName = ResManager.loadKDString("数据导入模板", "ImportTaskGuideExportService_2", "swc-hsas-business", new Object[0]);
+        SXSSFSheet sheet = wb.createSheet(sheetName);
+        sheet.setRandomAccessWindowSize(-1);
+        SXSSFDrawing drawingPatriarch = sheet.createDrawingPatriarch();
+        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);
+        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);
+        font.setColor((short)10);
+        requrriedStyle.setFont(font);
+        headRequriedNumStyle.setFont(font);
+        Map<Long, SinsurPresetItemEnum> itemEnumMap = SinsurPresetItemEnum.getSinsurPresetItemEnumMap();
+        List<Map<String, String>> columnHeadList = ImportTaskUtils.getColumnHeadList(sinsurTplId, importTaskId);
+        List<Integer> textIndexList = new ArrayList(columnHeadList.size());
+        Set<Integer> allIndexSet = new HashSet(columnHeadList.size());
+        SinsurPresetItemEnum presetItemEnum = null;
+        for (int i = 0; i < columnHeadList.size(); ++i) {
+            Map<String, String> columnHead = columnHeadList.get(i);
+            String columnIndexStr = (String)columnHead.get("columnIndex");
+            String dataTypeIdStr = (String)columnHead.get("datatypeid");
+            String name = (String)columnHead.get("name");
+            String itemType = (String)columnHead.get("itemType");
+            String comment = (String)columnHead.get("comment");
+            int columnIndex = Integer.parseInt(columnIndexStr);
+            if (allIndexSet.add(columnIndex) && !textIndexList.contains(columnIndex)) {
+                if (Long.parseLong(dataTypeIdStr) == DataTypeEnum.STRING.getDbId()) {
+                    textIndexList.add(columnIndex);
+                }
+                if ("0".equals(itemType)) {
+                    presetItemEnum = (SinsurPresetItemEnum)itemEnumMap.get(Long.valueOf((String)columnHead.get("id")));
+                    CellStyle style = this.getFixCellStyle(presetItemEnum, requrriedStyle, headDateStyle, headTextStyle, headRequriedNumStyle);
+                    this.createCell(comment, headRow, columnIndex, presetItemEnum.getImportColumnName(), presetItemEnum.isRequire(), style, this.getDataType(presetItemEnum), drawingPatriarch);
+                } else {
+                    this.createCell(comment, headRow, columnIndex, name, false, headTextStyle, dataTypeIdStr, drawingPatriarch);
+                }
+            }
+        }
+
+        Iterator<Integer> it = allIndexSet.iterator();
+        while(it.hasNext()) {
+            int index = (Integer)it.next();
+            int columnIndex = sheet.getColumnWidth(index);
+            sheet.setColumnWidth(index, columnIndex * 3);
+        }
+
+        this.batchSetDefaulColumnStyle(sheet, textIndexList, this.getTextCellStyle(sheet));
+    }
+
+    private CellStyle getFixCellStyle(SinsurPresetItemEnum presetItemEnum, CellStyle requrriedStyle, CellStyle headDateStyle, CellStyle headTextStyle, CellStyle headRequriedNumStyle) {
+        if (presetItemEnum.isRequire()) {
+            return presetItemEnum.getDataTypeId() == DataTypeEnum.NUMBERIC.getDbId() ? headRequriedNumStyle : requrriedStyle;
+        } else {
+            return presetItemEnum.getDataTypeId() == DataTypeEnum.DATE.getDbId() ? headDateStyle : headTextStyle;
+        }
+    }
+
+    private void createCell(String comment, SXSSFRow headRow, int cellIndex, String name, boolean isRequried, CellStyle cellStyle, String dataType, SXSSFDrawing drawingPatriarch) {
+        SXSSFCell cell = headRow.createCell(cellIndex);
+        String value = "";
+        if (isRequried) {
+            value = "*" + name;
+        } else {
+            value = name;
+        }
+        cell.setCellValue(value);
+        cell.setCellStyle(cellStyle);
+        if (dataType != null) {
+            cell.setCellComment(this.getComment(comment, drawingPatriarch, cell));
+        }
+    }
+
+    private Comment getComment(String commentStr, SXSSFDrawing drawingPatriarch, SXSSFCell cell) {
+        Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(cell.getColumnIndex(), cell.getRowIndex(), cell.getColumnIndex() + 1, cell.getRowIndex() + 2, cell.getColumnIndex(), cell.getRowIndex(), cell.getColumnIndex() + 1, cell.getRowIndex() + 2));
+        comment.setString(new XSSFRichTextString(commentStr));
+        return comment;
+    }
+
+    private void batchSetDefaulColumnStyle(SXSSFSheet sheet, List<Integer> indexList, CellStyle cellStyle) {
+        Iterator var4 = indexList.iterator();
+        while(var4.hasNext()) {
+            int index = (Integer)var4.next();
+            sheet.setDefaultColumnStyle(index, cellStyle);
+        }
+    }
+
+    private CellStyle getTextCellStyle(SXSSFSheet sheet) {
+        CellStyle textCellStyle = sheet.getWorkbook().createCellStyle();
+        textCellStyle.setDataFormat((short)49);
+        return textCellStyle;
+    }
+
+    private String getDataType(SinsurPresetItemEnum presetItemEnum) {
+        if (presetItemEnum.getDataTypeId() == DataTypeEnum.DATE.getDbId()) {
+            return SWCShowType.DATE.getCode();
+        } else {
+            return presetItemEnum.getDataTypeId() == DataTypeEnum.NUMBERIC.getDbId() ? SWCShowType.NUM.getCode() : SWCShowType.TEXT.getCode();
+        }
+    }
+
+    private void flushAllAndDownload(SXSSFWorkbook wb, String fileName, IFormView view) {
+        String url = SWCExportDataHelper.storeFile(wb, fileName);
+        if (SWCStringUtils.isNotEmpty(url)) {
+            view.download(url);
+        }
+    }
+
+}

+ 431 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/ImportTaskGuideImportService.java

@@ -0,0 +1,431 @@
+package nckd.jxccl.sit.hcsi.business.importtaskguide;
+
+import com.google.common.collect.Lists;
+import java.math.BigDecimal;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.db.tx.TX;
+import kd.bos.db.tx.TXHandle;
+import kd.bos.entity.EntityMetadataCache;
+import kd.bos.entity.EntityType;
+import kd.bos.entity.MainEntityType;
+import kd.bos.exception.KDBizException;
+import kd.bos.fileservice.FileService;
+import kd.bos.fileservice.FileServiceFactory;
+import kd.bos.impt.ExcelReader;
+import kd.bos.impt.SheetHandler;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.orm.query.QFilter;
+import kd.bos.threads.ThreadPools;
+import kd.hr.hbp.business.bgtask.HRBackgroundTaskHelper;
+import kd.swc.hsas.common.enums.PresetItemEnum;
+import kd.swc.hsbp.business.servicehelper.SWCDataServiceHelper;
+import kd.swc.hsbp.common.cache.ISWCAppCache;
+import kd.swc.hsbp.common.cache.SWCAppCache;
+import kd.swc.hsbp.common.util.SWCDateTimeUtils;
+import kd.swc.hsbp.common.util.SWCListUtils;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+import nckd.jxccl.sit.hcsi.business.importtaskguide.utils.ImportTaskUtils;
+import nckd.jxccl.sit.hcsi.formplugin.web.tp.enums.SinsurPresetItemEnum;
+import org.apache.commons.lang.exception.ExceptionUtils;
+
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.*;
+
+public class ImportTaskGuideImportService {
+
+    private static final Log logger = LogFactory.getLog(ImportTaskGuideImportService.class);
+    private Long importTaskId;
+    private Long sinsurTplId;
+    private Long welfarepayerId;
+    private Long periodId;
+    private String url;
+    private static final long DATE_TYPE_ID = 1050L;
+    private static final long NUMBER_TYPE_ID = 1010L;
+    private static final long DECIMAL_TYPE_ID = 1020L;
+    private static final String DATE_FORMAT = "yyyy-MM-dd";
+
+    public ImportTaskGuideImportService(String url, Long importTaskId, Long sinsurTplId, Long periodId, Long welfarepayerId) {
+        this.url = url;
+        this.importTaskId = importTaskId;
+        this.sinsurTplId = sinsurTplId;
+        this.periodId = periodId;
+        this.welfarepayerId = welfarepayerId;
+    }
+
+    public Map<String, String> parseAndCheckExcelData(Long orgId, String pageId, String importTaskName) {
+        Map<String, String> resultMap = new HashMap(5);
+        List<Map<Integer, String>> dataHeadList = Lists.newArrayListWithCapacity(10);
+        List<Map<Integer, String>> dataRowList = Lists.newArrayListWithCapacity(10);
+        DynamicObject sinsurData = ImportTaskUtils.getSinsurTplData(sinsurTplId, "id,number,nckd_startline,nckd_endline", (QFilter)null);
+        logger.info("readExcelData begin");
+        this.readExcelData(dataHeadList, dataRowList, sinsurData.getInt("nckd_startline") - 2, sinsurData.getInt("nckd_endline") - 1);
+        logger.info("readExcelData end");
+        if (dataHeadList.size() == 0) {
+            throw new KDBizException(ResManager.loadKDString("没有找到对应的列标题。", "ImportTaskGuideImportService_0", "swc-hsas-business", new Object[0]));
+        } else if (dataRowList.size() == 0) {
+            resultMap.put("errorMsg", ResManager.loadKDString("未解析到有效数据,请录入数据后再试。", "ImportTaskGuideImportService_17", "swc-hsas-business", new Object[0]));
+            return resultMap;
+        } else {
+            Set<String> errDataList = new HashSet(16);
+            List<Map<String, String>> columnList = ImportTaskUtils.getColumnHeadList(this.sinsurTplId, this.importTaskId);
+            Map<Integer, SinsurPresetItemEnum> tplFixItemMap = this.getTplFixItemMap(columnList);
+            this.checkExcelTemplate(dataHeadList, errDataList, tplFixItemMap);
+            String cacheKey;
+            if (errDataList.size() > 0) {
+                cacheKey = ResManager.loadKDString("模板列名“{0}”不能删除。", "ImportTaskGuideImportService_1", "swc-hsas-business", new Object[0]);
+                String errorMsg = SWCListUtils.join(errDataList, "、");
+                throw new KDBizException(MessageFormat.format(cacheKey, errorMsg));
+            } else {
+                cacheKey = UUID.randomUUID().toString();
+                resultMap.put("totalCount", String.valueOf(dataRowList.size()));
+                resultMap.put("cacheKey", cacheKey);
+                Map<String, Object> params = new HashMap(16);
+                String name = ResManager.loadKDString("外部系统数据导入-%s", "ImportTaskGuideImportService_10", "swc-hsas-business", new Object[0]);
+                name = String.format(Locale.ROOT, name, importTaskName);
+                params.put("importTaskId", this.importTaskId);
+                params.put("verifyId", cacheKey);
+                params.put("totalCount", dataRowList.size());
+                params.put("startTime", SWCDateTimeUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+                params.put("progressType", "22");
+                String bgTaskId = HRBackgroundTaskHelper.getInstance().createBaskgroundTask("swc_hsas_importtaskguide_import", name, true, pageId, params);
+                ISWCAppCache appCache = SWCAppCache.get(String.format(Locale.ROOT, "bggroud_taskid_%s", cacheKey));
+                appCache.put("bgTaskId", bgTaskId);
+                appCache.put("totalCount", dataRowList.size());
+                RequestContext ctx = RequestContext.get();
+                ThreadPools.executeOnce("IMPORTTASK_IMPORT_IN_POOL_ASYNC", () -> {
+                    RequestContext.copyAndSet(ctx);
+                    logger.info("parseAndCheckExcelData ,tranceId={}", ctx.getTraceId());
+                    this.importData(dataHeadList, dataRowList, sinsurData, cacheKey, null, orgId, tplFixItemMap);
+                });
+                return resultMap;
+            }
+        }
+    }
+
+    private void importData(List<Map<Integer, String>> dataHeadList, List<Map<Integer, String>> dataRowList, DynamicObject migrationTplData, String cacheKey, String writeTaskType, Long orgId, Map<Integer, SinsurPresetItemEnum> tplFixItemMap) {
+        logger.info("importData begin,importTaskId={}", this.importTaskId);
+        List<Map<String, String>> errDataList = new ArrayList(10);
+        ImportTaskGuideExportService service = new ImportTaskGuideExportService();
+        if (!this.isCancel(cacheKey)) {
+            boolean hasWorkStartDate = tplFixItemMap.containsKey(11);
+            Map<Integer, List<Map<String, String>>> columnIndexMap = this.getColumnIndexMap();
+            int defaultSize = 500;
+            List<List<Map<Integer, String>>> splitDataList = SWCListUtils.split(dataRowList, defaultSize);
+            int lineIndex = 0;
+            List<Map<Integer, String>> tempList = null;
+            int index = 0;
+
+            for(int size = splitDataList.size(); index < size; ++index) {
+                tempList = (List)splitDataList.get(index);
+                lineIndex = index * defaultSize;
+                this.checkImportData(tempList, errDataList, columnIndexMap, lineIndex, cacheKey, writeTaskType, orgId, hasWorkStartDate, false);
+            }
+
+            if (!this.isCancel(cacheKey)) {
+                if (errDataList.size() > 0) {
+                    // TODO String fileUrl = service.getImportErrorExcelFile(dataHeadList, dataRowList, errDataList, migrationTplData.getInt("startline") - 2, writeTaskType, columnIndexMap, hasWorkStartDate);
+                    // TODO kd.swc.hsas.business.importtaskguide.utils.ImportTaskUtils.updateImportDataProgress(0, 0, cacheKey, fileUrl);
+                }
+
+                logger.info("importData end,importTaskId={}", this.importTaskId);
+            }
+        }
+    }
+
+    private Boolean isCancel(String cacheKey) {
+        String key = String.format(Locale.ROOT, "import_cache_%s", cacheKey);
+        ISWCAppCache appCache = SWCAppCache.get(key);
+        Boolean isCancel = (Boolean)appCache.get(String.format(Locale.ROOT, "isCancel_%s", cacheKey), Boolean.class);
+        return isCancel != null && isCancel ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    // TODO 校验导入数据
+    private void checkImportData(List<Map<Integer, String>> dataRowList, List<Map<String, String>> allErrDataList, Map<Integer, List<Map<String, String>>> columnIndexMap, int lineIndex, String cacheKey, String writeTaskType, Long orgId, boolean hasWorkStartDate, boolean isMulTimeOnePeriod) {
+        Map<Integer, Map<Integer, Object>> passDataRowMap = new HashMap(16);
+        int lineIndexVer = lineIndex;
+        List<Map<String, String>> errDataList = new ArrayList(10);
+        int successCount = 0;
+        int failCount = 0;
+
+        try {
+            boolean isSuccess = true;
+            Iterator<Map<Integer, String>> it = dataRowList.iterator();
+            while(it.hasNext()) {
+                Map<Integer, Object> passRowMap = new HashMap(16);
+                Map<Integer, String> rowMap = (Map)it.next();
+                isSuccess = this.checkFieldRequriedForCommon(rowMap, errDataList, lineIndex, passRowMap);
+                if(!isSuccess) {
+                    ++lineIndex;
+                } else if (!this.checkItemValue(columnIndexMap, passRowMap, errDataList, lineIndex, rowMap)) {
+                    ++lineIndex;
+                } else {
+                    if(isSuccess) {
+                        passDataRowMap.put(lineIndex, passRowMap);
+                    }
+                    ++lineIndex;
+                }
+            }
+
+            if (!this.isCancel(cacheKey)) {
+                this.saveData(passDataRowMap, columnIndexMap);
+                successCount = passDataRowMap.size();
+                failCount = dataRowList.size() - successCount;
+                return;
+            }
+
+        } catch (Exception e) {
+            logger.error(e);
+            successCount = 0;
+            failCount = dataRowList.size();
+            errDataList.clear();
+            // TODO this.setErrorData(dataRowList.size(), lineIndexVer, errDataList, e.getMessage());
+            return;
+        } finally {
+            allErrDataList.addAll(errDataList);
+            kd.swc.hsas.business.importtaskguide.utils.ImportTaskUtils.updateImportDataProgress(successCount, failCount, cacheKey, (String)null);
+        }
+    }
+
+    private void saveData(Map<Integer, Map<Integer, Object>> passDataRowMap, Map<Integer, List<Map<String, String>>> columnIndexMap) {
+        if (passDataRowMap != null && passDataRowMap.size() != 0) {
+            DynamicObjectCollection result = new DynamicObjectCollection();
+            MainEntityType type = EntityMetadataCache.getDataEntityType("nckd_sinsurtempdata");
+            EntityType entryType = (EntityType)type.getAllEntities().get("entryentity");
+            DynamicObject temporary = null;
+            Map<Integer, Object> rowMap = null;
+            Iterator<Map.Entry<Integer, Map<Integer, Object>>> it = passDataRowMap.entrySet().iterator();
+            while(it.hasNext()) {
+                Map.Entry<Integer, Map<Integer, Object>> entry = (Map.Entry)it.next();
+                temporary = (DynamicObject)type.createInstance();
+                rowMap = (Map)entry.getValue();
+                temporary.set("nckd_datastatus", "0");
+                ImportTaskUtils.setTemporaryValueForCommon(temporary, rowMap);
+                temporary.set("nckd_importtask", this.importTaskId);
+                temporary.set("creator", RequestContext.get().getCurrUserId());
+                temporary.set("createtime", new Date());
+                temporary.set("modifier", RequestContext.get().getCurrUserId());
+                temporary.set("modifytime", new Date());
+                temporary.set("billstatus", "A");
+                temporary.set("entryentity", ImportTaskUtils.getItemEntryList(rowMap, columnIndexMap, entryType));
+                result.add(temporary);
+            }
+            SWCDataServiceHelper helper = new SWCDataServiceHelper("nckd_sinsurtempdata");
+            TXHandle txHandle = TX.requiresNew();
+
+            try {
+                helper.save(result);
+                helper.setEntityName("nckd_sinsurimptask");
+                DynamicObject importTask = helper.queryOne(this.importTaskId);
+                importTask.set("nckd_taskstatus", "1");
+                importTask.set("modifytime", new Date());
+                importTask.set("modifier", RequestContext.get().getCurrUserId());
+                importTask.set("nckd_count", importTask.getInt("nckd_count") + result.size());
+                helper.updateOne(importTask);
+            } catch (Exception var18) {
+                logger.error("save error,", var18);
+                txHandle.markRollback();
+                throw new KDBizException(ExceptionUtils.getFullStackTrace(var18));
+            } finally {
+                txHandle.close();
+            }
+        }
+    }
+
+    private boolean checkItemValue(Map<Integer, List<Map<String, String>>> columnIndexMap,
+                                   Map<Integer, Object> passRowMap,
+                                   List<Map<String, String>> errDataList,
+                                   int lineIndex,
+                                   Map<Integer, String> rowMap) {
+        boolean isPass = true;
+        String errorMsgTemplate = ResManager.loadKDString("{0}:数据格式填写错误。",
+                "ImportTaskGuideImportService_4", "swc-hsas-business", new Object[0]);
+
+        for (Map.Entry<Integer, List<Map<String, String>>> columnEntry : columnIndexMap.entrySet()) {
+            Integer columnIndex = columnEntry.getKey();
+            String itemValue = rowMap.get(columnIndex);
+
+            if (SWCStringUtils.isEmpty(itemValue)) {
+                continue;
+            }
+
+            for (Map<String, String> itemMap : columnEntry.getValue()) {
+                long dataTypeId = Long.parseLong(itemMap.get("datatypeid"));
+                String itemName = itemMap.get("name");
+
+                try {
+                    String processedValue = processValueByType(itemValue, dataTypeId);
+                    passRowMap.put(columnIndex, processedValue);
+                } catch (Exception e) {
+                    isPass = false;
+                    errDataList.add(assembleErrMap(lineIndex, false,
+                            MessageFormat.format(errorMsgTemplate, itemName)));
+                }
+            }
+        }
+        return isPass;
+    }
+
+    private String processValueByType(String value, long dataTypeId) throws Exception {
+        if (DATE_TYPE_ID == dataTypeId) {
+            return SWCDateTimeUtils.format(SWCDateTimeUtils.parseDate(value), DATE_FORMAT);
+        }
+
+        if (NUMBER_TYPE_ID == dataTypeId || DECIMAL_TYPE_ID == dataTypeId) {
+            return new BigDecimal(value).toPlainString();
+        }
+
+        return value;
+    }
+
+
+    private boolean checkFieldRequriedForCommon(Map<Integer, String> rowMap, List<Map<String, String>> errDataList, int lineIndex, Map<Integer, Object> passRowMap) {
+        String msg = ResManager.loadKDString("请填写“{0}”。", "ImportTaskGuideImportService_2", "swc-hsas-business", new Object[0]);
+        if (SWCStringUtils.isEmpty((String)rowMap.get(0))) {
+            errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.CALPERIOD.getItemName())));
+            return false;
+        } else {
+            passRowMap.put(0, rowMap.get(0));
+            if (SWCStringUtils.isEmpty((String)rowMap.get(1))) {
+                errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_IDCARD.getItemName())));
+                return false;
+            } else {
+                passRowMap.put(1, rowMap.get(1));
+                if (SWCStringUtils.isEmpty((String)rowMap.get(2))) {
+                    errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_NAME.getItemName())));
+                    return false;
+                } else {
+                    passRowMap.put(2, rowMap.get(2));
+                    if (SWCStringUtils.isEmpty((String)rowMap.get(3))) {
+                        errDataList.add(this.assembleErrMap(lineIndex, false, MessageFormat.format(msg, SinsurPresetItemEnum.EMP_NUMBER.getItemName())));
+                        return false;
+                    } else {
+                        passRowMap.put(3, rowMap.get(3));
+                        return true;
+                    }
+                }
+            }
+        }
+    }
+
+    private Map<Integer, List<Map<String, String>>> getColumnIndexMap() {
+        List<Map<String, String>> columnHeadList = kd.swc.hsas.business.importtaskguide.utils.ImportTaskUtils.getColumnHeadList(this.sinsurTplId, this.importTaskId);
+        Map<Integer, List<Map<String, String>>> columnIndexMap = new HashMap(columnHeadList.size());
+        List<Map<String, String>> tempMapList = null;
+        Iterator var4 = columnHeadList.iterator();
+
+        while(var4.hasNext()) {
+            Map<String, String> obj = (Map)var4.next();
+            if (!"0".equals(obj.get("itemType"))) {
+                tempMapList = (List)columnIndexMap.get(Integer.valueOf((String)obj.get("columnIndex")));
+                if (tempMapList == null) {
+                    tempMapList = new ArrayList(10);
+                    columnIndexMap.put(Integer.valueOf((String)obj.get("columnIndex")), tempMapList);
+                }
+
+                ((List)tempMapList).add(obj);
+            }
+        }
+
+        return columnIndexMap;
+    }
+
+    private Map<String, String> assembleErrMap(int dataIndex, boolean isAll, String msg) {
+        Map<String, String> errMap = new HashMap(4);
+        errMap.put("errMsg", msg);
+        errMap.put("isAll", isAll ? "1" : "0");
+        errMap.put("dataIndex", String.valueOf(dataIndex));
+        return errMap;
+    }
+
+    private void checkExcelTemplate(List<Map<Integer, String>> dataHeadList, Set<String> errDataList, Map<Integer, SinsurPresetItemEnum> tplFixItemMap) {
+        Map<Integer, String> dataHeadMap = (Map)dataHeadList.get(0);
+        String excelName = null;
+        StringBuilder tplName = new StringBuilder();
+        Iterator var7 = tplFixItemMap.entrySet().iterator();
+        while(var7.hasNext()) {
+            Map.Entry<Integer, SinsurPresetItemEnum> entry = (Map.Entry)var7.next();
+            excelName = (String)dataHeadMap.get(entry.getKey());
+            if (SWCStringUtils.isEmpty(excelName)) {
+                errDataList.add(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
+            } else {
+                tplName.setLength(0);
+                if (((SinsurPresetItemEnum)entry.getValue()).isRequire()) {
+                    tplName.append('*');
+                }
+                tplName.append(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
+                if (!excelName.equals(tplName.toString())) {
+                    errDataList.add(((SinsurPresetItemEnum)entry.getValue()).getImportColumnName());
+                }
+            }
+        }
+    }
+
+    private Map<Integer, SinsurPresetItemEnum> getTplFixItemMap(List<Map<String, String>> columnList) {
+        Map<Integer, SinsurPresetItemEnum> map = new HashMap(16);
+        Map<Long, SinsurPresetItemEnum> presetItemEnumMap = SinsurPresetItemEnum.getSinsurPresetItemEnumMap();
+        SinsurPresetItemEnum tempItemEnum = null;
+        Iterator it = columnList.iterator();
+        while(it.hasNext()) {
+            Map<String, String> temp = (Map)it.next();
+            if ("0".equals(temp.get("itemType"))) {
+                Long itemId = Long.valueOf((String)temp.get("id"));
+                String columnIndexStr = (String)temp.get("columnIndex");
+                tempItemEnum = (SinsurPresetItemEnum)presetItemEnumMap.get(itemId);
+                map.put(Integer.valueOf(columnIndexStr), tempItemEnum);
+            }
+        }
+        return map;
+    }
+
+    /**
+     * 读excel数据
+     * @param dataHeadList
+     * @param dataRowList
+     * @param headIndex
+     * @param dataEndIndex
+     * @throws KDBizException
+     */
+    private void readExcelData(final List<Map<Integer, String>> dataHeadList, final List<Map<Integer, String>> dataRowList, final int headIndex, final int dataEndIndex) throws KDBizException {
+        FileService service = FileServiceFactory.getAttachmentFileService();
+        try {
+            InputStream in = service.getInputStream(this.url);
+            Throwable exp = null;
+            try {
+                (new ExcelReader()).read(in, new SheetHandler() {
+                    public void handleRow(SheetHandler.ParsedRow row) {
+                        if (row.getRowNum() == headIndex) {
+                            dataHeadList.add(row.getData());
+                        } else if (row.getRowNum() > headIndex && row.getRowNum() <= dataEndIndex && row.getData().size() > 0) {
+                            dataRowList.add(row.getData());
+                        }
+
+                    }
+                });
+            } catch (Throwable e) {
+                exp = e;
+                throw e;
+            } finally {
+                if (in != null) {
+                    if (exp != null) {
+                        try {
+                            in.close();
+                        } catch (Throwable e1) {
+                            exp.addSuppressed(e1);
+                        }
+                    } else {
+                        in.close();
+                    }
+                }
+            }
+        } catch (Throwable e2) {
+            logger.error("parse excel error,", e2);
+            throw new KDBizException(ExceptionUtils.getFullStackTrace(e2));
+        }
+    }
+
+}

+ 236 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/business/importtaskguide/utils/ImportTaskUtils.java

@@ -0,0 +1,236 @@
+package nckd.jxccl.sit.hcsi.business.importtaskguide.utils;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.serialization.SerializationUtils;
+import kd.bos.entity.EntityType;
+import kd.bos.orm.query.QFilter;
+import kd.swc.hsas.common.enums.PresetItemEnum;
+import kd.swc.hsbp.business.servicehelper.SWCDataServiceHelper;
+import kd.swc.hsbp.common.cache.ISWCAppCache;
+import kd.swc.hsbp.common.cache.SWCAppCache;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+import nckd.jxccl.sit.hcsi.formplugin.web.tp.enums.SinsurPresetItemEnum;
+
+import java.util.*;
+
+public class ImportTaskUtils {
+
+    private static final String SINSURTPL_ENTITY = "nckd_sinsurtpl";
+    private static final String INSURANCEITEM_ENTITY = "sitbs_insuranceitem";
+
+
+    public static DynamicObject getSinsurTplData(Long sinsurTplId, String fields, QFilter qFilter) {
+        SWCDataServiceHelper helper = new SWCDataServiceHelper(SINSURTPL_ENTITY);
+        QFilter filter = new QFilter("id", "=", sinsurTplId);
+        if (qFilter != null) {
+            filter.and(qFilter);
+        }
+        return helper.queryOne(fields, new QFilter[]{filter});
+    }
+
+    private static DynamicObjectCollection getSinsurTplDataList(Long sinsurTplId) {
+        SWCDataServiceHelper helper = new SWCDataServiceHelper(SINSURTPL_ENTITY);
+        String fields = "nckd_sinsurtplentry.nckd_itemtype,nckd_sinsurtplentry.nckd_itemid,nckd_sinsurtplentry.nckd_matchcolumn,nckd_sinsurtplentry.nckd_comment";
+        QFilter qFilter = new QFilter("id", "=", sinsurTplId);
+        return helper.queryOriginalCollection(fields, new QFilter[]{qFilter}, "nckd_sinsurtplentry.seq asc");
+    }
+
+    public static List<Map<String, String>> getColumnHeadList(Long sinsurTplId, Long importTaskId) {
+        List<Map<String, String>> columnHeadList = new ArrayList(10);
+        if (sinsurTplId != null && sinsurTplId != 0L && importTaskId != null && importTaskId != 0L) {
+            String cacheKey = importTaskId + "_" + sinsurTplId;
+            ISWCAppCache appCache = SWCAppCache.get(cacheKey);
+            String json = (String)appCache.get("columnHeadList", String.class);
+            if (SWCStringUtils.isNotEmpty(json)) {
+                columnHeadList = (List) SerializationUtils.fromJsonString(json, List.class);
+                return columnHeadList;
+            }
+        }
+        DynamicObjectCollection list = getSinsurTplDataList(sinsurTplId);
+        if (list.size() == 0) {
+            return columnHeadList;
+        } else {
+            List<String> itemList = new ArrayList(10);
+            Map<String, Map<String, String>> itemMap = new HashMap(list.size());
+            Set<Long> fixSet = new HashSet(16);
+            Set<Long> iiItemSet = new HashSet(16);
+            Map<String, Integer> indexMap = new HashMap(16);
+            String keyStr = "";
+            Map<String, String> commentMap = new HashMap(list.size());
+            String comment = null;
+            Iterator columnIndex;
+            DynamicObject obj;
+            for(columnIndex = list.iterator(); columnIndex.hasNext(); commentMap.put(keyStr, comment)) {
+                obj = (DynamicObject)columnIndex.next();
+                String itemType = obj.getString("nckd_sinsurtplentry.nckd_itemtype");
+                Long itemId = obj.getLong("nckd_sinsurtplentry.nckd_itemid");
+                comment = obj.getString("nckd_sinsurtplentry.nckd_comment");
+                if ("0".equals(itemType)) {
+                    keyStr = "fix" + itemId;
+                    itemList.add(keyStr);
+                    indexMap.put(keyStr, getExcelRowIndexByTitle(obj.getString("nckd_sinsurtplentry.nckd_matchcolumn")));
+                    fixSet.add(itemId);
+                }
+                else if ("1".equals(itemType)) {
+                    keyStr = "ii" + itemId;
+                    itemList.add(keyStr);
+                    indexMap.put(keyStr, getExcelRowIndexByTitle(obj.getString("nckd_sinsurtplentry.nckd_matchcolumn")));
+                    iiItemSet.add(itemId);
+                }
+            }
+            addFixValue(commentMap, fixSet, "fix", itemMap, "0");
+            addItemValue(commentMap, iiItemSet, "ii", itemMap, INSURANCEITEM_ENTITY, "1");
+            if (itemMap.size() == 0) {
+                return columnHeadList;
+            } else {
+                columnIndex = null;
+                obj = null;
+                Iterator it = itemList.iterator();
+                while(it.hasNext()) {
+                    String key = (String)it.next();
+                    Map<String, String> tempMap = (Map)itemMap.get(key);
+                    if (tempMap != null) {
+                        Integer index = (Integer)indexMap.get(key);
+                        tempMap.put("columnIndex", String.valueOf(index));
+                        columnHeadList.add(tempMap);
+                    }
+                }
+                if (sinsurTplId != null && sinsurTplId != 0L && importTaskId != null && importTaskId != 0L) {
+                    String cacheKey = importTaskId + "_" + sinsurTplId;
+                    ISWCAppCache appCache = SWCAppCache.get(cacheKey);
+                    appCache.put("columnHeadList", SerializationUtils.toJsonString(columnHeadList));
+                }
+                return columnHeadList;
+            }
+        }
+    }
+
+    /**
+     * 处理预置项目
+     * @param commentMap
+     * @param itemSet
+     * @param itemKey
+     * @param itemMap
+     * @param itemType
+     */
+    private static void addFixValue(Map<String, String> commentMap, Set<Long> itemSet, String itemKey, Map<String, Map<String, String>> itemMap, String itemType) {
+        if (itemSet.size() != 0) {
+            Map<Long, SinsurPresetItemEnum> map = SinsurPresetItemEnum.getSinsurPresetItemEnumMap();
+            SinsurPresetItemEnum itemEnum = null;
+            Map<String, String> tempMap = null;
+            Iterator it = itemSet.iterator();
+            while(it.hasNext()) {
+                Long itemId = (Long)it.next();
+                itemEnum = (SinsurPresetItemEnum)map.get(itemId);
+                tempMap = new HashMap(16);
+                tempMap.put("name", itemEnum.getItemName());
+                tempMap.put("datatypeid", String.valueOf(itemEnum.getDataTypeId()));
+                tempMap.put("id", String.valueOf(itemId));
+                tempMap.put("key", getFixColumnKeyByItemId(itemId.toString()));
+                tempMap.put("itemType", itemType);
+                tempMap.put("comment", commentMap.get(itemKey + itemId));
+                itemMap.put(itemKey + itemId, tempMap);
+            }
+        }
+    }
+
+    private static String getFixColumnKeyByItemId(String itemId) {
+        String columnKey = null;
+        switch (itemId) {
+            case "1":
+                columnKey = "period";
+                break;
+            case "2":
+                columnKey = "nckd_idcard";
+                break;
+            case "3":
+                columnKey = "nckd_empname";
+                break;
+            case "4":
+                columnKey = "nckd_empnumber";
+                break;
+        }
+
+        return columnKey;
+    }
+
+    private static void addItemValue(Map<String, String> commentMap, Set<Long> itemSet, String itemKey, Map<String, Map<String, String>> itemMap, String entityId, String itemType) {
+        if (itemSet.size() != 0) {
+            SWCDataServiceHelper helper = new SWCDataServiceHelper(entityId);
+            String fields = "id,datatype.id,name";
+            DynamicObjectCollection result = helper.queryOriginalCollection(fields, new QFilter[]{new QFilter("id", "in", itemSet)});
+            Map<String, String> tempMap = null;
+            Iterator var11 = result.iterator();
+
+            while(var11.hasNext()) {
+                DynamicObject obj = (DynamicObject)var11.next();
+                tempMap = new HashMap(16);
+                String keyStr = itemKey + obj.getLong("id");
+                tempMap.put("name", obj.getString("name"));
+                tempMap.put("datatypeid", String.valueOf(obj.getLong("datatype.id")));
+                tempMap.put("id", String.valueOf(obj.getLong("id")));
+                tempMap.put("key", keyStr);
+                tempMap.put("itemType", itemType);
+                tempMap.put("comment", commentMap.get(keyStr));
+                itemMap.put(keyStr, tempMap);
+            }
+
+        }
+    }
+
+
+    public static int getExcelRowIndexByTitle(String columnTitle) {
+        int length = columnTitle.length();
+        int num = 0;
+        for(int i = 0; i < length; ++i) {
+            num = num * 26 + columnTitle.charAt(i) - 65 + 1;
+        }
+        return num - 1;
+    }
+
+    public static void setTemporaryValueForCommon(DynamicObject temporary, Map<Integer, Object> rowMap) {
+        temporary.set("nckd_periodname", rowMap.get(0));
+        temporary.set("nckd_idcard", rowMap.get(1));
+        temporary.set("nckd_empname", rowMap.get(2));
+        temporary.set("nckd_empnumber", rowMap.get(3));
+    }
+
+    public static DynamicObjectCollection getItemEntryList(Map<Integer, Object> rowMap, Map<Integer, List<Map<String, String>>> columnIndexMap, EntityType entryType) {
+        DynamicObjectCollection itemEntryList = new DynamicObjectCollection();
+        int sequence = 0;
+        for (Map.Entry<Integer, List<Map<String, String>>> entry : columnIndexMap.entrySet()) {
+            Object itemValue = rowMap.get(entry.getKey());
+            if (itemValue == null) {
+                continue;
+            }
+            for (Map<String, String> itemMap : entry.getValue()) {
+                try {
+                    DynamicObject item = (DynamicObject) entryType.createInstance();
+
+                    item.set("nckd_itemvalue", itemValue);
+                    item.set("nckd_itemtype", itemMap.get("itemType"));
+                    item.set("nckd_itemname", itemMap.get("name"));
+                    item.set("seq", sequence);
+
+                    String id = itemMap.get("id");
+                    if (id != null) {
+                        item.set("nckd_itemid", Long.valueOf(id));
+                    }
+
+                    String datatypeId = itemMap.get("datatypeid");
+                    if (datatypeId != null) {
+                        item.set("nckd_datatype", Long.valueOf(datatypeId));
+                    }
+                    sequence++;
+                    itemEntryList.add(item);
+                } catch (Exception e) {
+                    // 记录错误日志,但继续处理其他条目
+                    System.err.println("Error processing item: " + e.getMessage());
+                }
+            }
+        }
+        return itemEntryList;
+    }
+
+}

+ 138 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SinsurTempDataListPlugin.java

@@ -0,0 +1,138 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.form.CloseCallBack;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.ShowType;
+import kd.bos.form.events.BeforeDoOperationEventArgs;
+import kd.bos.form.events.ClosedCallBackEvent;
+import kd.bos.form.operate.FormOperate;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.orm.query.QFilter;
+import kd.sdk.plugin.Plugin;
+import kd.swc.hsbp.business.servicehelper.SWCDataServiceHelper;
+import kd.swc.hsbp.common.util.SWCDateTimeUtils;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * Tyx 2025-10-21
+ * 外部数据中间表数据列表插件 nckd_sinsurtempdata
+ */
+public class SinsurTempDataListPlugin extends AbstractListPlugin implements Plugin {
+
+    @Override
+    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
+        super.beforeDoOperation(args);
+        Long importTaskId = (Long)this.getView().getFormShowParameter().getCustomParam("importTaskId");
+        String creatorId = (String)this.getView().getFormShowParameter().getCustomParam("creator");
+        FormOperate formOperate = (FormOperate)args.getSource();
+        String opKey = formOperate.getOperateKey();
+        switch (opKey) {
+            case "donothing_import":
+                this.opeanImportStartPage();
+                break;
+        }
+    }
+
+    /**
+     * 打开选择导入模板界面
+     */
+    private void opeanImportStartPage() {
+        if (!this.checkTaskStatus(false, true)) {
+            FormShowParameter formShowParameter = new FormShowParameter();
+            formShowParameter.setShowTitle(false);
+            formShowParameter.setFormId("nckd_taskguideimport");
+            formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
+            formShowParameter.setCustomParam("importTaskName", this.getView().getFormShowParameter().getCustomParam("importTaskName"));
+            formShowParameter.setCustomParam("sinsurTplId", this.getView().getFormShowParameter().getCustomParam("sinsurTplId"));
+            formShowParameter.setCustomParam("importTaskId", this.getView().getFormShowParameter().getCustomParam("importTaskId"));
+            formShowParameter.setCustomParam("periodId", this.getView().getFormShowParameter().getCustomParam("periodId"));
+            formShowParameter.setCustomParam("welfarepayerId", this.getView().getFormShowParameter().getCustomParam("welfarepayerId"));
+            formShowParameter.setCustomParam("orgId", this.getView().getFormShowParameter().getCustomParam("orgId"));
+            formShowParameter.setCloseCallBack(new CloseCallBack(this, "importData"));
+            this.getView().showForm(formShowParameter);
+        }
+    }
+
+    private boolean checkTaskStatus(boolean checkIsRunning, boolean checkIsClosed) {
+        Long importTaskId = (Long)this.getView().getFormShowParameter().getCustomParam("importTaskId");
+        SWCDataServiceHelper helper = new SWCDataServiceHelper("nckd_sinsurimptask");
+        DynamicObject importTask = helper.queryOriginalOne("id,nckd_taskstatus", new QFilter[]{new QFilter("id", "=", importTaskId)});
+        String taskStatus = importTask.getString("nckd_taskstatus");
+        String msg = null;
+        if (checkIsRunning) {
+            if (SWCStringUtils.equals(taskStatus, "4")) {
+                msg = ResManager.loadKDString("当前任务后台执行校验中,请稍后再试。", "ImportTaskGuideOpereateBillList_13", "swc-hsas-formplugin", new Object[0]);
+            } else if (SWCStringUtils.equals(taskStatus, "3")) {
+                msg = ResManager.loadKDString("当前任务后台执行预处理中,请稍后再试。", "ImportTaskGuideOpereateBillList_14", "swc-hsas-formplugin", new Object[0]);
+            } else if (SWCStringUtils.equals(taskStatus, "6")) {
+                msg = ResManager.loadKDString("当前任务后台执行反写中,请稍后再试。", "ImportTaskGuideOpereateBillList_15", "swc-hsas-formplugin", new Object[0]);
+            } else if (SWCStringUtils.equals(taskStatus, "5")) {
+                msg = ResManager.loadKDString("当前任务后台执行写入中,请稍后再试。", "ImportTaskGuideOpereateBillList_16", "swc-hsas-formplugin", new Object[0]);
+            } else if (SWCStringUtils.equals(taskStatus, "9")) {
+                msg = ResManager.loadKDString("当前任务后台执行清除中间表数据中,请稍后再试。", "ImportTaskGuideOpereateBillList_36", "swc-hsas-formplugin", new Object[0]);
+            }
+
+            if (msg != null) {
+                this.getView().showTipNotification(msg);
+                return true;
+            }
+        }
+
+        if (!checkIsClosed || !SWCStringUtils.equals(taskStatus, "7") && !SWCStringUtils.equals(taskStatus, "8")) {
+            return false;
+        } else {
+            msg = ResManager.loadKDString("任务已关闭,无法操作。", "ImportTaskGuideOpereateBillList_35", "swc-hsas-formplugin", new Object[0]);
+            this.getView().showErrorNotification(msg);
+            return true;
+        }
+    }
+
+    @Override
+    public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
+        super.closedCallBack(closedCallBackEvent);
+        String actionId = closedCallBackEvent.getActionId();
+        if ("importData".equals(actionId)) {
+            Map<String, Object> returnData = (Map)closedCallBackEvent.getReturnData();
+            if (returnData == null) {
+                return;
+            }
+            if ((Boolean)returnData.get("isOk")) {
+                int totalCount = Integer.parseInt(returnData.get("totalCount").toString());
+                Long importTaskId = (Long)returnData.get("importTaskId");
+                String cacheKey = (String)returnData.get("cacheKey");
+                String caption = ResManager.loadKDString("导入看板", "ImportTaskGuideOpereateBillList_33", "swc-hsas-formplugin", new Object[0]);
+                this.openProgressPage(totalCount, importTaskId, "22", "importingData", caption, cacheKey);
+            }
+        }
+        else if ("importingData".equals(actionId)) {
+            this.getView().invokeOperation("refresh");
+        } else if (!"checkprogress".equals(actionId) && !"dataPreDeal".equals(actionId)) {
+            if ("donothing_writein".equals(actionId)) {
+                this.getView().invokeOperation("refresh");
+            } else if ("donothing_unwritein".equals(actionId)) {
+                this.getView().invokeOperation("refresh");
+            }
+        } else {
+            this.getView().invokeOperation("refresh");
+        }
+    }
+
+    private void openProgressPage(int totalCount, Long importTaskId, String progressType, String closeCalBackId, String caption, String verifyId) {
+        FormShowParameter formShowParameter = new FormShowParameter();
+        formShowParameter.setFormId("hsas_datacheckprogress");
+        formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
+        formShowParameter.setCaption(caption);
+        formShowParameter.setCustomParam("importTaskId", importTaskId);
+        formShowParameter.setCustomParam("totalCount", totalCount);
+        formShowParameter.setCustomParam("verifyId", verifyId);
+        formShowParameter.setCustomParam("startTime", SWCDateTimeUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+        formShowParameter.setCustomParam("progressType", progressType);
+        formShowParameter.setCloseCallBack(new CloseCallBack(this, closeCalBackId));
+        this.getView().showForm(formShowParameter);
+    }
+}

+ 10 - 4
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SinsurTemplateEdit.java

@@ -38,6 +38,7 @@ public class SinsurTemplateEdit extends AbstractFormPlugin implements Plugin {
         super.afterCreateNewData(e);
         // 添加预置数据:
         createPresetItemData();
+        //this.getModel().setValue("number", "1");
     }
 
     @Override
@@ -99,7 +100,12 @@ public class SinsurTemplateEdit extends AbstractFormPlugin implements Plugin {
         switch (e.getProperty().getName()) {
             case "org":
                 this.clearUnPresetItemData();
+                this.createPresetItemData();
+                this.getView().updateView("nckd_sinsurtplentry");
                 break;
+//            case "nckd_startline":
+//                this.createPresetItemData();
+//                this.getView().updateView("nckd_sinsurtplentry");
         }
 
     }
@@ -137,7 +143,7 @@ public class SinsurTemplateEdit extends AbstractFormPlugin implements Plugin {
 
         }
 
-        this.deleteEntry(this.getChangeableRowIndexs(allRowIndex));
+        this.deleteEntry(allRowIndex);
     }
     private TableValueSetter createTableValueSetter() {
         TableValueSetter setter = new TableValueSetter(new String[0]);
@@ -305,7 +311,7 @@ public class SinsurTemplateEdit extends AbstractFormPlugin implements Plugin {
             DynamicObject entry;
             for(index = 0; index < presetDataSize; ++index) {
                 entry = (DynamicObject)entryDatas.get(index);
-                Long itemId = entry.getLong("itemid");
+                Long itemId = entry.getLong("nckd_itemid");
                 PresetItemEnum presetItemEnum = SinsurTemplateHelper.getPresetItemEnum(itemId);
                 if (presetItemEnum != null) {
                     model.setValue("nckd_itemnumber", '-', index);
@@ -316,8 +322,8 @@ public class SinsurTemplateEdit extends AbstractFormPlugin implements Plugin {
 
             for(index = presetDataSize; index < entryDatas.size(); ++index) {
                 entry = (DynamicObject)entryDatas.get(index);
-                String itemType = entry.getString("itemtype");
-                Long itemId = entry.getLong("itemid");
+                String itemType = entry.getString("nckd_itemtype");
+                Long itemId = entry.getLong("nckd_itemid");
                 Map<String, Object> itemParam = (Map)itemParamMap.get(itemType + '-' + itemId);
                 if (itemParam != null) {
                     model.setValue("nckd_itemnumber", itemParam.get("nckd_itemnumber"), index);

+ 44 - 32
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/SitItemSelectAddItemPlugin.java

@@ -1,5 +1,6 @@
 package nckd.jxccl.sit.hcsi.formplugin.web.tp;
 
+import com.kingdee.util.StringUtils;
 import kd.bos.base.AbstractBasePlugIn;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
@@ -120,7 +121,7 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
     private void checkSelectedTreeNode(TreeView treeView, List<TreeNode> nodeList) {
         DynamicObjectCollection selectDatas = this.getView().getModel().getEntryEntity("nckd_itemselectentry");
         Set<String> uniqueCodeSet = selectDatas.stream()
-                .map(selectData -> selectData.getString("itemunicodeid"))
+                .map(selectData -> selectData.getString("nckd_treenodeid"))
                 .collect(Collectors.toSet());
 
         List<TreeNode> checkNodeList = FormulaItemOrFuncTreeHelper.getCheckTreeNodeList(nodeList, uniqueCodeSet);
@@ -130,11 +131,7 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
     }
 
     public void loadMainPageData() {
-        if (isMigrationTemplate()) {
-            loadMainPageDataFromMigrationTempate();
-        } else {
-            loadMainPageDataFromResultList();
-        }
+        loadMainPageDataFromMigrationTempate();
     }
 
     private boolean isMigrationTemplate() {
@@ -164,14 +161,14 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
 
     private void loadMainPageDataFromMigrationTempate() {
         DynamicObjectCollection matchRelationDatas = this.getView().getParentView().getModel()
-                .getEntryEntity("hsas_migrationtplent");
+                .getEntryEntity("nckd_sinsurtplentry");
         if (CollectionUtils.isEmpty(matchRelationDatas)) {
             return;
         }
 
         IDataModel model = this.getModel();
         for (DynamicObject matchRelationData : matchRelationDatas) {
-            String itemType = matchRelationData.getString("itemtype");
+            String itemType = matchRelationData.getString("nckd_itemtype");
             String itemCategory = ITEM_TYPE_MAPPING.get(itemType);
 
             if (itemCategory != null) {
@@ -183,11 +180,11 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
     }
 
     private void populateEntryData(IDataModel model, DynamicObject sourceData, String itemCategory, int detailIndex) {
-        model.setValue("itemnumber", sourceData.getString("itemnumber"), detailIndex);
-        model.setValue("itemcategory", itemCategory, detailIndex);
-        model.setValue("itemname", sourceData.getString("itemname"), detailIndex);
-        model.setValue("itemunicodeid", sourceData.getString("uniquecode"), detailIndex);
-        model.setValue("treenodeid", sourceData.getString("uniquecode"), detailIndex);
+        model.setValue("nckd_itemnumber", sourceData.getString("nckd_itemnumber"), detailIndex);
+        model.setValue("nckd_itemcategory", itemCategory, detailIndex);
+        model.setValue("nckd_itemname", sourceData.getString("nckd_itemname"), detailIndex);
+        model.setValue("nckd_itemunicodeid", sourceData.getString("nckd_uniquecode"), detailIndex);
+        model.setValue("nckd_treenodeid", sourceData.getString("nckd_itemid"), detailIndex);
     }
 
     public void btnOkClickEvent() {
@@ -287,7 +284,8 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
             List<TreeNode> checkNodeList = new ArrayList<>(selectNodeIds.size());
 
             for (String selectNodeId : selectNodeIds) {
-                TreeNode treeNode = nodeMap.get(selectNodeId);
+                TreeNode treeNode = getTreeNodeByTreeId(nodeMap, selectNodeId);
+//                TreeNode treeNode = nodeMap.get(selectNodeId);
                 if (!isValidNode(treeNode, selectNodeId)) {
                     continue;
                 }
@@ -340,9 +338,10 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
     }
 
     private String getItemCategory(TreeNode treeNode) {
-        String treeNodeId = treeNode.getId();
-        String itemCategory = treeNodeId.substring(0, treeNodeId.indexOf('_'));
-        return normalizeItemCategory(itemCategory);
+//        String treeNodeId = treeNode.getId();
+//        String itemCategory = treeNodeId.substring(0, treeNodeId.indexOf('_'));
+//        String itemCategory = ITEM_TYPE_II;
+        return normalizeItemCategory(ITEM_TYPE_II);
     }
 
     private void removeCheckNode(int[] rows) {
@@ -414,25 +413,38 @@ public class SitItemSelectAddItemPlugin extends AbstractBasePlugIn {
     }
 
     public TreeNode getTreeNodeByTreeId(Map<String, TreeNode> nodeMap, String treeId) {
-        return nodeMap.entrySet().stream()
-                .map(Map.Entry::getValue)
-                .filter(node -> findInSubTree(node, treeId))
-                .findFirst()
-                .orElse(new TreeNode());
-    }
-
-    private boolean findInSubTree(TreeNode node, String treeId) {
-        if (SWCStringUtils.equals(node.getId(), treeId)) {
-            return true;
+        if (nodeMap == null || StringUtils.isEmpty(treeId)) {
+            return null;
         }
 
-        List<TreeNode> children = node.getChildren();
-        if (CollectionUtils.isEmpty(children)) {
-            return false;
+        for (Map.Entry<String, TreeNode> entry : nodeMap.entrySet()) {
+            TreeNode node = entry.getValue();
+            TreeNode result = getSubTreeNode(treeId, node);
+            if (result != null) {
+                return result;
+            }
         }
+        return null;
+    }
 
-        return children.stream()
-                .anyMatch(child -> findInSubTree(child, treeId));
+    private TreeNode getSubTreeNode(String treeId, TreeNode node) {
+        if (node == null) {
+            return null;
+        }
+        // 检查当前节点
+        if (treeId.equals(node.getId())) {
+            return node;
+        }
+        // 递归检查子节点
+        if (node.getChildren() != null) {
+            for (TreeNode child : node.getChildren()) {
+                TreeNode result = getSubTreeNode(treeId, child);
+                if (result != null) {
+                    return result;
+                }
+            }
+        }
+        return null;
     }
 
     public void removeColumn() {

+ 77 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/basedata/SinsurImpTaskListPlugin.java

@@ -0,0 +1,77 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp.basedata;
+
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.entity.datamodel.ListSelectedRow;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.ShowType;
+import kd.bos.form.events.HyperLinkClickArgs;
+import kd.bos.list.IListView;
+import kd.bos.list.ListShowParameter;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.sdk.plugin.Plugin;
+import kd.swc.hsbp.business.servicehelper.SWCDataServiceHelper;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+
+import java.text.MessageFormat;
+
+/**
+ * Tyx 2025-10-21
+ * 外部数据导入任务列表插件 nckd_sinsurimptask
+ */
+public class SinsurImpTaskListPlugin extends AbstractListPlugin implements Plugin {
+
+    /**
+     * 点击任务名称跳转到导入中间表:nckd_taskimpguide
+     * @param args
+     */
+    public void billListHyperLinkClick(HyperLinkClickArgs args) {
+        ListShowParameter listShowParameter = (ListShowParameter)this.getView().getFormShowParameter();
+        if (!listShowParameter.isLookUp()) {
+            String fieldName = args.getHyperLinkClickEvent().getFieldName();
+            if (SWCStringUtils.equals("name", fieldName)) {
+                args.setCancel(true);
+                IListView listView = (IListView)this.getView();
+                ListSelectedRow selectRow = listView.getCurrentSelectedRowInfo();
+                Long importTaskId = (Long)selectRow.getPrimaryKeyValue();
+                this.openTempDataPage(importTaskId);
+            }
+
+        }
+    }
+
+    /**
+     * 处理跳转参数并打开页面
+     * @param importTaskId
+     */
+    private void openTempDataPage(Long importTaskId) {
+        SWCDataServiceHelper helper = new SWCDataServiceHelper("nckd_sinsurimptask");
+        DynamicObject data = helper.queryOne("id,name,nckd_org.id,nckd_welfarepayer.id,nckd_period.id,creator.id,nckd_sinsurtpl.id,nckd_taskstatus", importTaskId);
+        String msg;
+        if (data == null) {
+            msg = ResManager.loadKDString("数据已不存在。", "ImportTaskList_0", "swc-hsas-formplugin", new Object[0]);
+            this.getView().showErrorNotification(msg);
+        } else if (SWCStringUtils.equals("8", data.getString("nckd_taskstatus"))) {
+            msg = ResManager.loadKDString("所选任务已清除中间表数据,无法查看。", "ImportTaskList_4", "swc-hsas-formplugin", new Object[0]);
+            this.getView().showErrorNotification(msg);
+        } else {
+            FormShowParameter parameter = new FormShowParameter();
+            parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
+            parameter.setFormId("nckd_taskimpguide");
+            String caption = MessageFormat.format(ResManager.loadKDString("外部数据导入任务 - {0}", "ImportTaskList_1", "swc-hsas-formplugin", new Object[0]), data.getString("name"));
+            parameter.setCaption(caption);
+            parameter.setCustomParam("importTaskId", importTaskId);
+            parameter.setCustomParam("importTaskName", data.getString("name"));
+            parameter.setCustomParam("welfarepayerId", data.getLong("nckd_welfarepayer.id"));
+            parameter.setCustomParam("periodId", data.getLong("nckd_period.id"));
+            parameter.setCustomParam("sinsurTplId", data.getLong("nckd_sinsurtpl.id"));
+            parameter.setCustomParam("orgId", String.valueOf(data.getLong("nckd_org.id")));
+            parameter.setCustomParam("creator", String.valueOf(data.getLong("creator.id")));
+            String pageId = this.getView().getMainView() == null ? this.getView().getPageId() : this.getView().getMainView().getPageId();
+            pageId = pageId + '_' + importTaskId;
+            parameter.setPageId(pageId);
+            this.getView().showForm(parameter);
+        }
+    }
+
+}

+ 128 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/basedata/TaskGuideImportFormPlugin.java

@@ -0,0 +1,128 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp.basedata;
+
+import com.google.common.collect.Maps;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.dataentity.utils.StringUtils;
+import kd.bos.entity.datamodel.IDataModel;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.IFormView;
+import kd.bos.form.MessageTypes;
+import kd.bos.form.control.Control;
+import kd.bos.form.control.Image;
+import kd.bos.form.control.Label;
+import kd.bos.form.control.events.UploadEvent;
+import kd.bos.form.control.events.UploadListener;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.url.UrlService;
+import kd.sdk.plugin.Plugin;
+import kd.swc.hsbp.business.servicehelper.SWCPermissionServiceHelper;
+import kd.swc.hsbp.common.constants.ImportConstants;
+import kd.swc.hsbp.common.util.SWCStringUtils;
+import nckd.jxccl.sit.hcsi.business.importtaskguide.ImportTaskGuideExportService;
+import nckd.jxccl.sit.hcsi.business.importtaskguide.ImportTaskGuideImportService;
+
+import java.util.EventObject;
+import java.util.Map;
+
+/**
+ * 动态表单插件
+ */
+public class TaskGuideImportFormPlugin extends AbstractFormPlugin implements UploadListener {
+
+    private static final String KEY_BTN_OK = "btnok";
+    private static final String KEY_BTN_DOWNLOAD = "btndownload";
+    private static final String KEY_BTN_RESETFILE = "btnresetfile";
+    private static final String KEY_BTN_UPLOAD = "btnupload";
+
+    public TaskGuideImportFormPlugin() {}
+
+    @Override
+    public void initialize() {
+        this.addClickListeners(new String[]{KEY_BTN_OK, KEY_BTN_DOWNLOAD, KEY_BTN_RESETFILE});
+        Image label = (Image)this.getControl(KEY_BTN_UPLOAD);
+        label.addUploadListener(this);
+    }
+
+    @Override
+    public void afterCreateNewData(EventObject e) {
+        this.getView().setVisible(Boolean.FALSE, new String[]{"filepanel"});
+        this.getView().setEnable(Boolean.FALSE, new String[]{"keyfields"});
+        Label title = (Label)this.getControl("title");
+        title.setText(ResManager.loadKDString("导入任务", "TaskGuideImportViewPlugin_0", "swc-hsas-formplugin", new Object[0]));
+    }
+
+    @Override
+    public void click(EventObject evt) {
+        switch (((Control)evt.getSource()).getKey()) {
+            case KEY_BTN_OK:
+                this.importData();
+                break;
+            case KEY_BTN_DOWNLOAD:
+                ImportTaskGuideExportService exportService = new ImportTaskGuideExportService();
+                exportService.exportExcelTemplate(this.getView());
+                break;
+            case KEY_BTN_RESETFILE:
+                this.resetFileInfo();
+        }
+    }
+
+    public void upload(UploadEvent evt) {
+        Object[] urls = evt.getUrls();
+        if (urls.length > 0) {
+            IFormView view = this.getView();
+            String url = (String)urls[0];
+            view.setVisible(Boolean.TRUE, new String[]{"filepanel"});
+            view.setVisible(Boolean.FALSE, new String[]{"uploadpanel"});
+            IDataModel model = this.getModel();
+            model.setValue("filename", url.substring(url.lastIndexOf(47) + 1));
+            String fullUrl = UrlService.getAttachmentFullUrl(url);
+            model.setValue("filepath", url);
+            model.setValue("fullpath", fullUrl);
+        }
+    }
+
+    private void resetFileInfo() {
+        this.getModel().setValue("filename", "");
+        this.getModel().setValue("filepath", "");
+        this.getView().setVisible(Boolean.FALSE, new String[]{"filepanel"});
+        this.getView().setVisible(Boolean.TRUE, new String[]{"uploadpanel"});
+    }
+
+    private void importData() {
+        String url = this.getModel().getDataEntity().getString("filepath");
+        if (StringUtils.isBlank(url)) {
+            this.getView().showErrorNotification(ResManager.loadKDString("请先上传数据文件后操作。", "HSASCalTableImportStartPlugin_1", "swc-hsas-formplugin", new Object[0]));
+        } else {
+            FormShowParameter params = this.getView().getFormShowParameter();
+            Long importTaskId = (Long)params.getCustomParam("importTaskId");
+            Long sinsurTplId = (Long)params.getCustomParam("sinsurTplId");
+            Long welfarepayerId = params.getCustomParam("welfarepayerId");
+            Long periodId = params.getCustomParam("periodId");
+            Long orgId = Long.valueOf(params.getCustomParam("orgId").toString());
+            String importTaskName = (String)params.getCustomParam("importTaskName");
+            String pageId = this.getView().getParentView().getPageId();
+            ImportTaskGuideImportService importService = new ImportTaskGuideImportService(url, importTaskId, sinsurTplId, periodId, welfarepayerId);
+
+            try {
+                Map<String, String> result = importService.parseAndCheckExcelData(orgId, pageId, importTaskName);
+                String errorMsg = (String)result.get("errorMsg");
+                if (!SWCStringUtils.isEmpty(errorMsg)) {
+                    this.getView().showErrorNotification(errorMsg);
+                    return;
+                }
+
+                Map<String, Object> returnData = Maps.newHashMapWithExpectedSize(16);
+                returnData.put("isOk", Boolean.TRUE);
+                returnData.put("totalCount", result.get("totalCount"));
+                returnData.put("cacheKey", result.get("cacheKey"));
+                returnData.put("importTaskId", importTaskId);
+                returnData.put("sinsurTplId", sinsurTplId);
+                this.getView().returnDataToParent(returnData);
+                this.getView().close();
+            } catch (Exception e) {
+                this.getView().showMessage(ImportConstants.IMPORT_TEMPLATE_ERROR(), e.getMessage(), MessageTypes.Default);
+            }
+
+        }
+    }
+}

+ 20 - 4
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/enums/SinsurPresetItemEnum.java

@@ -1,12 +1,16 @@
 package nckd.jxccl.sit.hcsi.formplugin.web.tp.enums;
 
+import kd.swc.hsas.common.enums.PresetItemEnum;
 import kd.swc.hsbp.common.entity.SWCI18NParam;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public enum SinsurPresetItemEnum {
-    CALPERIOD("A", 5L, new SWCI18NParam("期间", "PresetItemEnum_4", "swc-hsas-common"), 1030L, new SWCI18NParam("必填项,体现缴纳期间,格式:yyyy-MM", "PresetItemEnum_13", "swc-hsas-common"), new SWCI18NParam("期间.名称", "PresetItemEnum_28", "swc-hsas-common"), true),
-    EMP_IDCARD("B", 7L, new SWCI18NParam("员工身份证", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("必填项,用于确认社保人员", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), true),
-    EMP_NAME("C", 7L, new SWCI18NParam("员工姓名", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("非必填项", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), false),
-    EMP_NUMBER("D", 7L, new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("非必填项", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), false);
+    CALPERIOD("A", 1L, new SWCI18NParam("期间", "PresetItemEnum_4", "swc-hsas-common"), 1030L, new SWCI18NParam("必填项,体现缴纳期间,格式:202501", "PresetItemEnum_13", "swc-hsas-common"), new SWCI18NParam("期间编码", "PresetItemEnum_28", "swc-hsas-common"), true),
+    EMP_IDCARD("B", 2L, new SWCI18NParam("员工身份证", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("必填项,用于确认社保人员", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("员工身份证", "PresetItemEnum_6", "swc-hsas-common"), true),
+    EMP_NAME("C", 3L, new SWCI18NParam("员工姓名", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("非必填项", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("员工姓名", "PresetItemEnum_6", "swc-hsas-common"), false),
+    EMP_NUMBER("D", 4L, new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), 1030L, new SWCI18NParam("非必填项", "PresetItemEnum_15", "swc-hsas-common"), new SWCI18NParam("工号", "PresetItemEnum_6", "swc-hsas-common"), false);
 
     private String matchColumn;
     private Long itemId;
@@ -54,4 +58,16 @@ public enum SinsurPresetItemEnum {
         return this.isRequire;
     }
 
+    public static Map<Long, SinsurPresetItemEnum> getSinsurPresetItemEnumMap() {
+        Map<Long, SinsurPresetItemEnum> map = new HashMap(16);
+        SinsurPresetItemEnum[] values = values();
+        int count = values.length;
+
+        for(int i = 0; i < count; ++i) {
+            SinsurPresetItemEnum obj = values[i];
+            map.put(obj.getItemId(), obj);
+        }
+        return map;
+    }
+
 }

+ 158 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/guide/TaskImpGuideListPlugin.java

@@ -0,0 +1,158 @@
+package nckd.jxccl.sit.hcsi.formplugin.web.tp.guide;
+
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.dataentity.utils.ObjectUtils;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.ShowType;
+import kd.bos.form.container.Tab;
+import kd.bos.form.control.events.TabSelectEvent;
+import kd.bos.form.control.events.TabSelectListener;
+import kd.bos.form.events.BeforeClosedEvent;
+import kd.bos.form.operate.MutexHelper;
+import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.list.ListShowParameter;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.mutex.DataMutex;
+import kd.bos.orm.query.QFilter;
+import kd.sdk.plugin.Plugin;
+import kd.swc.hsbp.common.cache.ISWCAppCache;
+import kd.swc.hsbp.common.cache.SWCAppCache;
+import kd.swc.hsbp.common.cache.SWCPageCache;
+
+import java.io.IOException;
+import java.util.EventObject;
+import java.util.Map;
+
+/**
+ * Tyx 2025-10-21
+ * 外部数据导入向导界面插件 nckd_taskimpguide
+ */
+public class TaskImpGuideListPlugin extends AbstractListPlugin implements TabSelectListener {
+
+    @Override
+    public void registerListener(EventObject e) {
+        Tab tabSteps = (Tab)this.getControl("tabap");
+        tabSteps.addTabSelectListener(this);
+    }
+
+    public void beforeBindData(EventObject arg) {
+        this.applyMutexLock();
+        this.clearAppCache();
+        Tab tabSteps = (Tab)this.getControl("tabap");
+        tabSteps.activeTab("dataimport");
+    }
+
+    private void applyMutexLock() {
+        Long importTaskId = (Long)this.getView().getFormShowParameter().getCustomParam("importTaskId");
+        StringBuilder msg = new StringBuilder();
+        boolean require = MutexHelper.require("nckd_sinsurimptask", importTaskId, "modify", true, msg);
+        SWCPageCache cache = new SWCPageCache(this.getView());
+        if (require) {
+            cache.put("currentPageLocked", Boolean.TRUE);
+        } else {
+            cache.put("isLocked", Boolean.TRUE);
+            this.getView().showTipNotification(msg.toString());
+        }
+    }
+
+    @Override
+    public void tabSelected(TabSelectEvent tabSelectEvent) {
+        String tabKey = tabSelectEvent.getTabKey();
+        this.getPageCache().put("tabKey", tabKey);
+        switch (tabKey) {
+            case "dataimport":
+                this.loadChildrenPage("dataimport", "dataimportflex");
+                this.getPageCache().put("targetKey", "dataimportflex");
+                break;
+        }
+    }
+
+    private void loadChildrenPage(String tabKey, String targetKey) {
+        SWCPageCache pageCache = new SWCPageCache(this.getView());
+        Boolean isLocked = (Boolean)pageCache.get("isLocked", Boolean.class);
+        FormShowParameter parameter = this.getView().getFormShowParameter();
+        ListShowParameter showParameter = new ListShowParameter();
+        showParameter.getOpenStyle().setShowType(ShowType.InContainer);
+        showParameter.getOpenStyle().setTargetKey(targetKey);
+        showParameter.setBillFormId("nckd_sinsurtempdata");
+        showParameter.setFormId("bos_list");
+        showParameter.setLookUp(false);
+        showParameter.setShowTitle(false);
+        showParameter.setCustomParam("importTaskId", parameter.getCustomParam("importTaskId"));
+        showParameter.setCustomParam("importTaskName", parameter.getCustomParam("importTaskName"));
+        showParameter.setCustomParam("sinsurTplId", parameter.getCustomParam("sinsurTplId"));
+        showParameter.setCustomParam("periodId", parameter.getCustomParam("periodId"));
+        showParameter.setCustomParam("welfarepayerId", parameter.getCustomParam("welfarepayerId"));
+        showParameter.setCustomParam("orgId", parameter.getCustomParam("orgId"));
+        if (isLocked != null && isLocked) {
+            showParameter.setCustomParam("isLocked", Boolean.TRUE);
+        } else {
+            showParameter.setCustomParam("isLocked", Boolean.FALSE);
+        }
+
+        String title = null;
+        if ("dealandcheck".equals(tabKey)) {
+            title = ResManager.loadKDString("数据处理与校验", "ImportTaskGuideListPlugin_1", "swc-hsas-formplugin", new Object[0]);
+        } else if ("approveandwrite".equals(tabKey)) {
+            title = ResManager.loadKDString("审核并写入薪资结果", "ImportTaskGuideListPlugin_2", "swc-hsas-formplugin", new Object[0]);
+        } else {
+            title = ResManager.loadKDString("数据导入", "ImportTaskGuideListPlugin_0", "swc-hsas-formplugin", new Object[0]);
+        }
+
+        showParameter.setCaption(title);
+        showParameter.setCustomParam("creator", parameter.getCustomParam("creator"));
+        showParameter.setCustomParam("tabKey", tabKey);
+        showParameter.setCustomParam("verifyRecordId", this.getPageCache().get("verifyRecordId"));
+        this.getPageCache().put("verifyRecordId", (String)null);
+        showParameter.setSendToClient(true);
+        showParameter.getListFilterParameter().getQFilters().add(new QFilter("nckd_importtask", "=", parameter.getCustomParam("importTaskId")));
+        this.getView().showForm(showParameter);
+    }
+
+    public void pageRelease(EventObject e) {
+        String groupId = MutexHelper.getMutexGroupId("nckd_sinsurimptask", "modify");
+        Long importTaskId = (Long)this.getView().getFormShowParameter().getCustomParam("importTaskId");
+        DataMutex dataMutex = null;
+        try {
+            dataMutex = DataMutex.create();
+            Map<String, String> mutex = dataMutex.getLockInfo(String.valueOf(importTaskId), groupId, "nckd_sinsurimptask");
+            if (null != mutex && !mutex.isEmpty()) {
+                String lockOwner = (String)mutex.get("GLOBALSESSION");
+                String currentOwner = RequestContext.get().getGlobalSessionId();
+                if (ObjectUtils.nullSafeEquals(lockOwner, currentOwner)) {
+                    SWCPageCache cache = new SWCPageCache(this.getView());
+                    Boolean isCurrentPageLocked = (Boolean)cache.get("currentPageLocked", Boolean.class);
+                    if (isCurrentPageLocked == null) {
+                        return;
+                    }
+                    MutexHelper.release("nckd_sinsurimptask", "modify", String.valueOf(importTaskId));
+                    return;
+                }
+                return;
+            }
+        } finally {
+            if (dataMutex != null) {
+                try {
+                    dataMutex.close();
+                } catch (IOException e1) {
+                }
+            }
+
+        }
+
+    }
+
+    @Override
+    public void beforeClosed(BeforeClosedEvent e) {
+        super.beforeClosed(e);
+        this.clearAppCache();
+    }
+
+    private void clearAppCache() {
+        FormShowParameter parameter = this.getView().getFormShowParameter();
+        String cacheKey = parameter.getCustomParam("importTaskId") + "_" + parameter.getCustomParam("sinsurTplId");
+        ISWCAppCache appCache = SWCAppCache.get(cacheKey);
+        appCache.remove("columnHeadList");
+    }
+}

+ 2 - 2
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/helper/SinsurTemplateHelper.java

@@ -101,8 +101,8 @@ public class SinsurTemplateHelper {
 
             while(var5.hasNext()) {
                 DynamicObject entry = (DynamicObject)var5.next();
-                String itemType = entry.getString("itemtype");
-                Long itemId = entry.getLong("itemid");
+                String itemType = entry.getString("nckd_itemtype");
+                Long itemId = entry.getLong("nckd_itemid");
                 if (SWCStringUtils.equals("1", itemType)) {
                     SLItemIdList.add(itemId);
                 } else if (SWCStringUtils.equals("2", itemType)) {

+ 68 - 11
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/formplugin/web/tp/helper/SitItemSelectAddItemServiceHelper.java

@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
 public class SitItemSelectAddItemServiceHelper {
 
     private static final String INSURANCEITEM_ENTITY = "sitbs_insuranceitem";
-    private static final String QUERY_FIELDS = "id,number,name,group.name.group.number,group.id";
+    private static final String QUERY_FIELDS = "id,number,name,group.name,group.number,group.id";
     private static final String DEFAULT_ORDER = "number asc";
 
     private static final String INSURANCEITEM_KEY = "insuranceitemkey";
@@ -78,31 +78,88 @@ public class SitItemSelectAddItemServiceHelper {
         itemMap.put("id", item.getLong("id"));
         itemMap.put("number", item.getString("number"));
         itemMap.put("name", item.getString("name"));
+        itemMap.put("group_name", item.getString("group.name"));
+        itemMap.put("group_number", item.getString("group.number"));
+        itemMap.put("group_id", item.getString("group.id"));
         return itemMap;
     }
 
+    /**
+     * 构建险种项目树结构
+     * 顶层ID : II
+     * 险种分类节点ID:险种编码 + _@_
+     * 险种项目子节点ID:险种项目ID
+     * @param name
+     * @param isExpend
+     * @param dataMap
+     * @return
+     */
     public static List<TreeNode> loadInsuranceItemChildNode(String name, boolean isExpend,
                                                      Map<String, Map<String, Map<String, Object>>> dataMap) {
+        // 所有险种项目
         List<Map<String, Object>> insuranceItemList = getInsuranceItemList(name, dataMap);
         List<TreeNode> tree = createRootNode(isExpend);
         if (CollectionUtils.isEmpty(insuranceItemList)) {
             return tree;
         }
-        List<TreeNode> treeNodeList = new ArrayList<>(insuranceItemList.size() + 1);
+
+        // 最后返回树:
+        List<TreeNode> totalNodeList = new ArrayList<>(insuranceItemList.size() + 1);
+
+        // 构建根节点:
         TreeNode itemRoot = new TreeNode("", ITEM_TYPE_II,
                 ResManager.loadKDString("险种项目-II", "FormulaItemOrFuncTreeHelper_1",
                         "swc-hsas-business", new Object[0]));
         itemRoot.setExpend(isExpend);
         itemRoot.setIsOpened(isExpend);
-        treeNodeList.add(itemRoot);
-
-        insuranceItemList.forEach(item ->  {
-            TreeNode itemNode = new TreeNode(ITEM_TYPE_II, ITEM_TYPE_II + "_" + item.get("id").toString(),
-                    item.get("name").toString());
-            treeNodeList.add(itemNode);
-        });
-
-        return treeNodeList;
+        totalNodeList.add(itemRoot);
+
+        // 构建子节点:
+        if (!CollectionUtils.isEmpty(insuranceItemList)) {
+            Map<String, TreeNode> itemTypeNodeMap = new LinkedHashMap(insuranceItemList.size());
+            Map<String, List<TreeNode>> insuranceItemNodeMap = new HashMap(16);
+            List<TreeNode> treeNodeList = null;
+            String itemTypeNum = null;
+            for (Map<String, Object> map : insuranceItemList) {
+                itemTypeNum = (String)map.get("group_number");
+                String itemTypeName = (String)map.get("group_name");
+                treeNodeList = (List)insuranceItemNodeMap.get(itemTypeNum);
+                if (treeNodeList == null) {
+                    treeNodeList = new ArrayList(10);
+                    insuranceItemNodeMap.put(itemTypeNum, treeNodeList);
+                }
+                ((List)treeNodeList).add(new TreeNode(itemTypeNum + PREFIX_SEPARATOR, String.valueOf(map.get("id")), (String)map.get("name")));
+                if (!itemTypeNodeMap.containsKey(itemTypeNum)) {
+                    TreeNode itemTreeNode = new TreeNode(ITEM_TYPE_II, itemTypeNum + PREFIX_SEPARATOR, itemTypeName);
+                    itemTreeNode.setExpend(isExpend);
+                    itemTreeNode.setIsOpened(isExpend);
+                    itemTypeNodeMap.put(itemTypeNum, itemTreeNode);
+                }
+            }
+            treeNodeList = new ArrayList(itemTypeNodeMap.size());
+            Iterator it = itemTypeNodeMap.entrySet().iterator();
+            while (it.hasNext()) {
+                Map.Entry<String, TreeNode> entry = (Map.Entry)it.next();
+                TreeNode typeNode = (TreeNode)entry.getValue();
+                typeNode.setChildren((List)insuranceItemNodeMap.get(entry.getKey()));
+                treeNodeList.add(typeNode);
+            }
+            itemRoot.setChildren(treeNodeList);
+            return totalNodeList;
+        }
+        else {
+            return totalNodeList;
+        }
+//
+//
+//
+//        insuranceItemList.forEach(item ->  {
+//            TreeNode itemNode = new TreeNode(ITEM_TYPE_II, ITEM_TYPE_II + "_" + item.get("id").toString(),
+//                    item.get("name").toString());
+//            treeNodeList.add(itemNode);
+//        });
+//
+//        return treeNodeList;
     }
 
     private static List<Map<String, Object>> getInsuranceItemList(String name,

+ 58 - 0
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/sit/hcsi/utils/ReportUtils.java

@@ -0,0 +1,58 @@
+package nckd.jxccl.sit.hcsi.utils;
+
+import kd.bos.algo.DataSet;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.orm.query.QCP;
+import kd.bos.orm.query.QFilter;
+import kd.hr.hbp.business.servicehelper.HRBaseServiceHelper;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class ReportUtils {
+
+    private static final String CALPERSON_ENTITY = "hcsi_calperson";
+    private static final String INSURANCEITEM_ENTITY = "sitbs_insuranceitem";
+    //参保单位,险种,工号,姓名,证件号,单位缴费金额 = 单位固定+单位缴费+单位补缴,个人缴费金额=个人固定+个人缴费+个人补缴
+    private static String CALPERSON_FIELDS = "welfarepayer.id as welfarepayer,entryentity.insuranceitem.group.id as welfaretypeid,"
+            +"empnumberdb as empnumber,namedb as empname,percre.number as empidcard,entryentity.famountvalue as value,"
+            +"case when entryentity.insuranceitem.insurancetypeattr.number in ('1005_S','1009_S','1011_S') then '1'"
+            +"     when entryentity.insuranceitem.insurancetypeattr.number in ('1006_S','1010_S','1012_S') then '2' end as type";
+    private static final String[] INSURANCEPROP = new String[]{"1005_S","1006_S","1009_S","1010_S","1011_S","1012_S"};
+
+
+    public ReportUtils() {
+
+    }
+    /**
+     * 获取人员计算详情数据
+     * @param welfareTypeIds
+     * @param taskIds
+     */
+    public static DataSet queryCalPersonDetail(List<Long> welfareTypeIds, List<Long> taskIds) {
+        List<Long> itemIds = queryInsuranceItem(welfareTypeIds);
+        QFilter filter = new QFilter("sinsurtask.id", QCP.in, taskIds);
+        filter.and("entryentity.insuranceitem.id", QCP.in, itemIds);
+        HRBaseServiceHelper helper = new HRBaseServiceHelper(CALPERSON_ENTITY);
+        CALPERSON_FIELDS = "welfarepayer.id as welfarepayer,entryentity.insuranceitem.group.id as welfaretypeid,"
+                +"empnumberdb as empnumber,namedb as empname,percre.number as empidcard,entryentity.amountvalue as value,"
+                +"case when entryentity.insuranceitem.insurancetypeattr.number in ('1005_S','1009_S','1011_S') then '1'"
+                +"     when entryentity.insuranceitem.insurancetypeattr.number in ('1006_S','1010_S','1012_S') then '2' end as type";
+        return helper.queryDataSet("DetailComReport", CALPERSON_FIELDS, new QFilter[]{filter});
+    }
+
+    /**
+     * 根据险种ID获取险种项目
+     * @param welfareTypeIds
+     * @return
+     */
+    public static List<Long> queryInsuranceItem(List<Long> welfareTypeIds) {
+        HRBaseServiceHelper helper = new HRBaseServiceHelper(INSURANCEITEM_ENTITY);
+        QFilter filter = new QFilter("group.id", QCP.in, welfareTypeIds);
+        filter.and("insurancetypeattr.number", QCP.in, INSURANCEPROP);
+        DynamicObjectCollection cols = helper.queryOriginalCollection("id", new QFilter[]{filter});
+        List<Long> itemIds = cols.stream().map(obj -> obj.getLong("id")).collect(Collectors.toList());
+        return itemIds;
+    }
+
+}