6c
2025-12-12 16ddfc8e22559480a2b039b896f1e882f286c9c9
接口集成
已修改4个文件
540 ■■■■■ 文件已修改
src/main/java/com/product/integration/config/CmnConst.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/integration/config/IntegrationCode.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/integration/controller/InterfaceIntegrationController.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/integration/service/InterfaceIntegrationService.java 475 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/integration/config/CmnConst.java
@@ -20,6 +20,8 @@
    public static final String PRODUCT_SYS_INTERFACE_INTEGRATION_REQUEST_PARAM = "product_sys_interface_integration_request_param";
    public static final String PRODUCT_SYS_INTERFACE_INTEGRATION_REQUEST_HEADER = "product_sys_interface_integration_request_header";
    public static final String PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO = "product_sys_interface_integration_response_info";
    public static final String PRODUCT_SYS_INTERFACE_INTEGRATION_LOG = "product_sys_interface_integration_log";
    public static final String PRODUCT_SYS_TIMED_TASK = "product_sys_timed_task";
    // 字段-通用
    public static final String ID = "id";
@@ -46,4 +48,23 @@
    public static final String RESPONSE_CUSTOM_METHOD = "response_custom_method";
    public static final String AFTER_SAVE_CUSTOM_METHOD = "after_save_custom_method";
    public static final String PARENT_UUID = "parent_uuid";
    public static final String VALUE = "value";
    public static final String CONFIG_UUID = "config_uuid";
    public static final String CODE = "code";
    public static final String MESSAGE = "message";
    public static final String CONTENT = "content";
    public static final String ERROR_INFO = "error_info";
    public static final String TABLE = "table";
    public static final String JOB_NAME = "job_name";
    public static final String JOB_GROUP = "job_group";
    public static final String IS_CONCEAL = "is_conceal";
    public static final String MISFIRE_POLICY = "misfire_policy";
    public static final String CONCURRENT = "concurrent";
    public static final String CRON_EXPRESSION = "cron_expression";
    public static final String INVOKE_TARGET = "invoke_target";
    public static final String STATUS = "status";
    public static final String OPEN_TRANSACTION = "open_transaction";
    public static final String FREQUENCY = "frequency";
    public static final String FIELD_NAME = "field_name";
    public static final String FIELD_TYPE = "field_type";
}
src/main/java/com/product/integration/config/IntegrationCode.java
@@ -11,8 +11,14 @@
    SAVE_FAIL("保存失败", "001"),
    FIND_FAIL("查询失败", "002"),
    DELETE_FAIL("删除失败", "003"),
    GET_SYSTEM_CACHE_TABLE_STRUCTURE_FAIL("获取系统缓存中表结构失败", "004"),
    GET_SYSTEM_CACHE_FIELD_INFO_FAIL("获取系统缓存中字段信息失败", "005"),
    TEST_METHOD_FAIL("测试方法报错", "009"),
    SAVE_DEAL_RESPONSE_INFO("保存-处理响应数据结构失败", "010"),
    INTERFACE_INTEGRATION_SAVE_DEAL_RESPONSE_INFO_FAIL("接口集成保存-处理响应数据结构失败", "010"),
    INTERFACE_INTEGRATION_REQUEST_DATA_FAIL("接口集成请求数据失败", "011"),
    INTERFACE_INTEGRATION_REQUEST_DEAL_DATA_FAIL("接口集成请求处理数据失败", "012"),
    INTERFACE_INTEGRATION_EXECUTE_FAIL("接口集成执行失败", "013"),
    ;
    private String text;
    private String value;
src/main/java/com/product/integration/controller/InterfaceIntegrationController.java
@@ -103,4 +103,40 @@
            return error(IntegrationCode.SAVE_FAIL);
        }
    }
    /**
     * 立即执行
     * @param request
     * @return
     */
    @RequestMapping(value = "/execute/{version}")
    @ApiVersion(1)
    public String execute(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            if (fse.getTableName() == null || !CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION.equals(fse.getTableName())) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            interfaceIntegrationService.timedTaskTrigger(fse.getUUID());
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return error(IntegrationCode.INTERFACE_INTEGRATION_EXECUTE_FAIL);
        }
    }
}
src/main/java/com/product/integration/service/InterfaceIntegrationService.java
@@ -2,23 +2,37 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.product.admin.service.PublicService;
import com.product.common.lang.ExceptionUtils;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import com.product.core.config.Global;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.core.util.ReflectUtil;
import com.product.file.service.FileManagerService;
import com.product.integration.config.CmnConst;
import com.product.integration.config.IntegrationCode;
import com.product.integration.service.idel.IInterfaceIntegrationService;
import com.product.util.BaseUtil;
import com.product.util.SystemParamReplace;
import com.product.util.http.HttpRequestUtil;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.File;
import java.io.IOException;
import java.util.*;
/**
 * 实现功能:
@@ -32,6 +46,8 @@
    private BaseDao baseDao;
    @Autowired
    private PublicService publicService;
    @Autowired
    private FileManagerService fileManagerService;
    /**
     * 查询数据
@@ -43,7 +59,7 @@
        DataTableEntity responseInfoDte = integrationFse.getSubDataTable(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
        Map<String, String> acceptKayMap = Maps.newHashMap();
        acceptKayMap.put("uuid", "front_uuid");
        JSONArray arr = BaseUtil.dataTableToTreeData(responseInfoDte, CmnConst.TRICODE, acceptKayMap, null, null);
        JSONArray arr = BaseUtil.dataTableToTreeData(responseInfoDte, CmnConst.TRICODE, 3, acceptKayMap, null, null);
        integrationFse.removeSubData(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
        integrationFse.setValue(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO, arr.toString());
        return integrationFse;
@@ -66,7 +82,12 @@
        DataTableEntity responseInfoDte = dealResponseInfo(responseInfo);
        fse.addSubDataTable(responseInfoDte);
        return publicService.saveFieldSetEntity(fse);
        uuid = publicService.saveFieldSetEntity(fse);
        // 验证定时任务是否创建,若是未创建,那么创建定时任务
        generateTimedTask(fse);
        return uuid;
    }
    /**
     * 处理响应数据结构
@@ -80,7 +101,7 @@
                saveDealResponseInfoPart(responseInfoDte, JSONArray.parseArray(responseInfo), "");
            }
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(IntegrationCode.SAVE_DEAL_RESPONSE_INFO);
            SpringMVCContextHolder.getSystemLogger().error(IntegrationCode.INTERFACE_INTEGRATION_SAVE_DEAL_RESPONSE_INFO_FAIL);
        }
        return responseInfoDte;
    }
@@ -112,4 +133,446 @@
            saveDealResponseInfoPart(responseInfoDte, responseInfoObj.getJSONArray(CmnConst.CHILDREN), code);
        }
    }
    /**
     * 验证定时任务是否创建,若是未创建,那么创建定时任务
     * @param fse
     */
    public void generateTimedTask(FieldSetEntity fse) {
        String invokeTarget = String.format("interfaceIntegrationService.timedTaskTrigger('%s')", fse.getUUID());
        FieldSetEntity timedTaskFse = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_TIMED_TASK, String.format("%s=?", CmnConst.INVOKE_TARGET), new Object[]{invokeTarget}, false);
        if (FieldSetEntity.isEmpty(timedTaskFse)) {
            timedTaskFse = new FieldSetEntity(CmnConst.PRODUCT_SYS_TIMED_TASK);
            timedTaskFse.setValue(CmnConst.JOB_GROUP, "system");
            timedTaskFse.setValue(CmnConst.MISFIRE_POLICY, "3");
            timedTaskFse.setValue(CmnConst.CONCURRENT, 0);
            timedTaskFse.setValue(CmnConst.INVOKE_TARGET, invokeTarget);
            BaseUtil.createCreatorAndCreationTime(timedTaskFse);
        } else {
            BaseUtil.updatedRegeneratorAndUpdateTime(SpringMVCContextHolder.getCurrentUser(), timedTaskFse);
        }
        timedTaskFse.setValue(CmnConst.JOB_NAME, String.format("接口集成-%s", fse.getString(CmnConst.NAME)));
        timedTaskFse.setValue(CmnConst.CRON_EXPRESSION, fse.getString(CmnConst.FREQUENCY));
        timedTaskFse.setValue(CmnConst.IS_CONCEAL, 0);
        timedTaskFse.setValue(CmnConst.STATUS, 1);
        baseDao.saveFieldSetEntity(timedTaskFse);
    }
    /**
     * 定时任务触发方法
     * @param uuid  接口集成uuid
     */
    public void timedTaskTrigger(String uuid) {
        String code = "";
        String message = "";
        StringBuilder content = new StringBuilder(128);
        String errorInfo = null;
        try {
            // 数据准备
            FieldSetEntity paramFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION, uuid, true);
            DataTableEntity requestParamDte = paramFse.getSubDataTable(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_REQUEST_PARAM);
            DataTableEntity requestHederDte = paramFse.getSubDataTable(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_REQUEST_HEADER);
            String requestType = paramFse.getString(CmnConst.REQUEST_TYPE);
            String url = paramFse.getString(CmnConst.ADDRESS);
            MultipartBody.Builder builder = new MultipartBody.Builder().setType(okhttp3.MultipartBody.FORM);
            // 请求头信息
            Map<String, String> headerMap = Maps.newHashMap();
            if (!DataTableEntity.isEmpty(requestHederDte)) {
                for (int i = 0; i < requestHederDte.getRows(); i++) {
                    FieldSetEntity fse = requestHederDte.getFieldSetEntity(i);
                    headerMap.put(fse.getString(CmnConst.NAME), dealValue(fse.getString(CmnConst.VALUE)));
                }
            }
            // 添加请求参数信息
            Map<String, String> paramMap = Maps.newHashMap();
            if (!DataTableEntity.isEmpty(requestParamDte)) {
                for (int i = 0; i < requestParamDte.getRows(); i++) {
                    FieldSetEntity fse = requestParamDte.getFieldSetEntity(i);
                    paramMap.put(fse.getString(CmnConst.NAME), dealValue(fse.getString(CmnConst.VALUE)));
                }
            }
            // 请求参数方法自定义处理
            String customRequestParamInfo = paramFse.getString(CmnConst.REQUEST_PARAM_CUSTOM_METHOD);
            if (!StringUtils.isEmpty(customRequestParamInfo)) {
                String[] customMethodInfoArr = customRequestParamInfo.split("\\.");
                String beanName = customMethodInfoArr[0];
                String methodName = customMethodInfoArr[1];
                ReflectUtil.invoke(beanName, methodName, new Object[]{headerMap, paramMap});
                content.append(String.format("%s 执行自定义方法[%s]补充处理请求参数\n", BaseUtil.getCurTimeWithMill(), customRequestParamInfo));
            }
            // 发起请求
            Object requestResult;
            try {
                if ("post".equals(requestType)) {
                    paramMap.forEach(builder::addFormDataPart);
                    RequestBody requestBody = builder.build();
                    requestResult = HttpRequestUtil.request(url, "POST", "multipart/form-data", requestBody, JSONObject.class, headerMap);
                } else {
                    StringBuilder urlParamPart = new StringBuilder(128);
                    paramMap.forEach((name, value) -> {
                        if (urlParamPart.length() > 0) {
                            urlParamPart.append("&");
                        } else {
                            urlParamPart.append("?");
                        }
                        urlParamPart.append(name).append("=").append(value);
                    });
                    requestResult = HttpRequestUtil.request(url + urlParamPart, "GET", "application/json", null, JSONObject.class, headerMap);
                }
                System.out.println(requestResult);
            } catch (Exception e) {
                e.printStackTrace();
                throw new BaseException(IntegrationCode.INTERFACE_INTEGRATION_REQUEST_DATA_FAIL);
            }
            // 数据处理
            String customResponseInfo = paramFse.getString(CmnConst.RESPONSE_CUSTOM_METHOD);
            if (!StringUtils.isEmpty(customResponseInfo)) {
                // 自定义方法处理
                String[] customMethodInfoArr = customResponseInfo.split("\\.");
                String beanName = customMethodInfoArr[0];
                String methodName = customMethodInfoArr[1];
                ReflectUtil.invoke(beanName, methodName, new Object[]{paramFse, requestResult});
                content.append(String.format("%s 执行自定义数据处理方法[%s]\n", BaseUtil.getCurTimeWithMill(), customResponseInfo));
            } else {
                // 默认方法处理
                FieldSetEntity clientFse = baseDao.getFieldSetEntityByFilter("product_sys_clients", "1=1", new Object[]{}, false);
                String clientUUID = clientFse.getUUID();
                String coverSign = paramFse.getString(CmnConst.IS_COVER);
                DataTableEntity responseInfoDte = paramFse.getSubDataTable(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
                if (DataTableEntity.isEmpty(responseInfoDte)) {
                    content.append(String.format("%s 响应结构配置信息为空\n", BaseUtil.getCurTimeWithMill()));
                    return;
                }
                Map<String, String> keyMap = Maps.newHashMap();
                for (Object key : responseInfoDte.getFieldSetEntity(0).getFields()) {
                    keyMap.put(key.toString(), String.format("[%s]", key));
                }
                JSONObject structureObj = BaseUtil.dataTableToTreeDataObj(responseInfoDte, CmnConst.NAME, CmnConst.TRICODE, 3, keyMap, null, null);
                if (structureObj.isEmpty()) {
                    return;
                }
                JSONObject resultObj = (JSONObject) requestResult;
                JSONObject dealtDataObj = dealResult(resultObj, structureObj);
                for (Map.Entry<String, Object> entry : dealtDataObj.entrySet()) {
                    String key = entry.getKey();
                    Object value = entry.getValue();
                    if (CmnConst.CODE.equals(key)) {
                        code = value != null ? value.toString() : null;
                    } else if (CmnConst.MESSAGE.equals(key)) {
                        message = value != null ? value.toString() : null;
                    } else {
                        // 表处理
                        JSONObject tableObj = (JSONObject) value;
                        Set<String> uniqueFieldSet = (Set<String>) tableObj.get(CmnConst.UNIQUE_SIGN);
                        DataTableEntity waitDealDte = (DataTableEntity) tableObj.get(CmnConst.TABLE);
                        // 优先处理文件内容,需要根据表结构信息进行处理
                        dealFile(waitDealDte, clientUUID);
                        String tableName = waitDealDte.getTableName().toString();
                        if (uniqueFieldSet == null || uniqueFieldSet.isEmpty()) {
                            if ("1".equals(coverSign)) {
                                // 覆盖
                                baseDao.executeUpdate(String.format("TRUNCATE TABLE %s", tableName));
                                content.append(String.format("%s 开始-处理[%s]表-无标识且覆盖\n", BaseUtil.getCurTimeWithMill(), tableName));
                                content.append(String.format("%s 清理[%s]表\n", BaseUtil.getCurTimeWithMill(), tableName));
                            } else {
                                content.append(String.format("%s 开始-处理[%s]表-无标识不覆盖\n", BaseUtil.getCurTimeWithMill(), tableName));
                            }
                            BaseUtil.generateTime(waitDealDte);
                            baseDao.add(waitDealDte);
                        } else {
                            StringBuilder filter = new StringBuilder(128);
                            List<String> paramList = Lists.newArrayList();
                            for (int i = 0; i < waitDealDte.getRows(); i++) {
                                FieldSetEntity waitDealFse = waitDealDte.getFieldSetEntity(i);
                                if (filter.length() > 0) {
                                    filter.append("\nOR ");
                                }
                                StringBuilder singleFilter = new StringBuilder(128);
                                for (String uniqueField : uniqueFieldSet) {
                                    if (singleFilter.length() > 0) {
                                        singleFilter.append(" AND ");
                                    }
                                    singleFilter.append(uniqueField).append("=?");
                                    paramList.add(waitDealFse.getString(uniqueField));
                                }
                                filter.append("(").append(singleFilter).append(")");
                            }
                            if ("1".equals(coverSign)) {
                                // 覆盖
                                content.append(String.format("%s 开始-处理[%s]表-无标识且覆盖\n", BaseUtil.getCurTimeWithMill(), tableName));
                                baseDao.executeUpdate(String.format("DELETE FROM %s WHERE %s", tableName, filter), paramList.toArray());
                                content.append(String.format("%s 根据唯一标识字段[%s]进行清理\n", BaseUtil.getCurTimeWithMill(), BaseUtil.collection2String(uniqueFieldSet)));
                                baseDao.add(waitDealDte);
                            } else {
                                // 不覆盖
                                content.append(String.format("%s 开始-处理[%s]表-无标识不覆盖\n", BaseUtil.getCurTimeWithMill(), tableName));
                                DataTableEntity waitUpdateDte = baseDao.listTable(tableName, filter.toString(), paramList.toArray());
                                int waitAddCount = 0;
                                Map<JSONObject, FieldSetEntity> waitUpdateMap = Maps.newHashMap();
                                for (int i = 0; i < waitUpdateDte.getRows(); i++) {
                                    FieldSetEntity waitUpdateFse = waitUpdateDte.getFieldSetEntity(i);
                                    JSONObject keyObj = extractFseAimField2Obj(waitUpdateFse, uniqueFieldSet);
                                    waitUpdateMap.put(keyObj, waitUpdateFse);
                                }
                                for (int i = 0; i < waitDealDte.getRows(); i++) {
                                    FieldSetEntity waitDealFse = waitDealDte.getFieldSetEntity(i);
                                    JSONObject keyObj = extractFseAimField2Obj(waitDealFse, uniqueFieldSet);
                                    FieldSetEntity waitUpdateFse = waitUpdateMap.get(keyObj);
                                    if (waitUpdateFse != null) {
                                        waitUpdateFse.getValues().forEach((fieldNameObj, fieldValue) -> {
                                            String fieldName = fieldNameObj.toString();
                                            if (StringUtils.isEmpty(waitDealFse.getString(fieldName))) {
                                                waitDealFse.setValue(fieldName, fieldValue);
                                            }
                                        });
                                        waitDealFse.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
                                    } else {
                                        waitAddCount++;
                                    }
                                }
                                baseDao.update(waitDealDte);
                                content.append(String.format("%s 根据[%s]表唯一标识字段[%s]进行更新\n", BaseUtil.getCurTimeWithMill(), tableName, BaseUtil.collection2String(uniqueFieldSet)));
                                content.append(String.format("%s 更新[%s]条数据\n", BaseUtil.getCurTimeWithMill(), waitUpdateDte.getRows()));
                                content.append(String.format("%s 新增[%s]条数据\n", BaseUtil.getCurTimeWithMill(), waitAddCount));
                            }
                        }
                        content.append(String.format("%s 完成-执行默认方法处理数据-操作[%s]数据,共[%s]条\n", BaseUtil.getCurTimeWithMill(), tableName, waitDealDte.getRows()));
                    }
                }
                code = dealtDataObj.getString(CmnConst.CODE);
                message = dealtDataObj.getString(CmnConst.MESSAGE);
            }
            // 完成后方法调用
            String customAfterSaveInfo = paramFse.getString(CmnConst.AFTER_SAVE_CUSTOM_METHOD);
            if (!StringUtils.isEmpty(customAfterSaveInfo)) {
                String[] customMethodInfoArr = customAfterSaveInfo.split("\\.");
                String beanName = customMethodInfoArr[0];
                String methodName = customMethodInfoArr[1];
                ReflectUtil.invoke(beanName, methodName, new Object[]{requestResult});
                content.append(String.format("%s 执行自定义保存后方法[%s]\n", BaseUtil.getCurTimeWithMill(), customAfterSaveInfo));
            }
        } catch (BaseException e) {
            errorInfo = ExceptionUtils.getStackTraceAsString(e);
            e.printStackTrace();
            throw new BaseException(e);
        } catch (Exception e) {
            errorInfo = ExceptionUtils.getStackTraceAsString(e);
            e.printStackTrace();
            throw new BaseException(IntegrationCode.INTERFACE_INTEGRATION_REQUEST_DEAL_DATA_FAIL);
        } finally {
            // 日志记录
            recordLog(uuid, code, message, content.toString(), errorInfo);
        }
    }
    /**
     * 优先处理文件内容,需要根据表结构信息进行处理
     * @param waitDealDte
     * @param clientUUID
     * @throws IOException
     */
    private void dealFile(DataTableEntity waitDealDte, String clientUUID) throws IOException {
        String tableName = waitDealDte.getTableName().toString();
        DataTableEntity tableDte = DataPoolCacheImpl.getInstance().getCacheData("所有表信息", new String[]{tableName});
        if (DataTableEntity.isEmpty(tableDte)) {
            throw new BaseException(IntegrationCode.GET_SYSTEM_CACHE_TABLE_STRUCTURE_FAIL.getValue(), IntegrationCode.GET_SYSTEM_CACHE_TABLE_STRUCTURE_FAIL.getText() + ":" + tableName);
        }
        FieldSetEntity tableFse = tableDte.getFieldSetEntity(0);
        DataTableEntity fieldDte = DataPoolCacheImpl.getInstance().getCacheData("所有字段信息并按表分组", new String[]{tableFse.getUUID()});
        if (DataTableEntity.isEmpty(fieldDte)) {
            throw new BaseException(IntegrationCode.GET_SYSTEM_CACHE_FIELD_INFO_FAIL.getValue(), IntegrationCode.GET_SYSTEM_CACHE_FIELD_INFO_FAIL.getText() + ":" + tableName);
        }
        Map<String, FieldSetEntity> fieldMap = BaseUtil.dte2Map(fieldDte, CmnConst.FIELD_NAME);
        List<String> fileTypeList = Arrays.asList("file", "file-image", "blob-attachment");
        for (int i = 0; i < waitDealDte.getRows(); i++) {
            FieldSetEntity waitDealFse = waitDealDte.getFieldSetEntity(i);
            for (Map.Entry<Object, Object> entry : waitDealFse.getValues().entrySet()) {
                String fieldName = entry.getKey().toString();
                String value = entry.getValue().toString();
                FieldSetEntity fieldFse = fieldMap.get(fieldName);
                if (fieldFse != null && fileTypeList.contains(fieldFse.getString(CmnConst.FIELD_TYPE))) {
                    // 文件处理
                    String fileName = waitDealFse.getString(String.format("~%s~", fieldName));
                    String attachmentUUID = saveFile(tableName, fieldName, fileName, value, clientUUID);
                    waitDealFse.setValue(fieldName, attachmentUUID);
                }
            }
        }
    }
    /**
     * 保存文件返回uuid
     * @param tableName         表名
     * @param fieldName         字段名
     * @param fileName          文件名
     * @param base64Content     文件流字符串
     * @param clientUUID        客户uuid,通常是默认顶级
     * @return
     * @throws IOException
     */
    private String saveFile(String tableName, String fieldName, String fileName, String base64Content, String clientUUID) throws IOException {
        String outPath = Global.getSystemConfig("upload.file.path", "") + File.separator + BaseUtil.getCurDateTime("yyyy/MM/dd") + File.separator + UUID.randomUUID() + "_" + fileName;
        byte[] fileBytes = Base64.getDecoder().decode(base64Content);
        FileUtils.writeByteArrayToFile(new File(outPath), fileBytes);
        RequestParameterEntity requestParameterEntity = new RequestParameterEntity();
        Map<String, File> fileMap = new HashMap<>();
        fileMap.put(fileName, new File(outPath));
        requestParameterEntity.setFiles(fileMap);
        FieldSetEntity fseAttachment = new FieldSetEntity();
        fseAttachment.setTableName(tableName);
        fseAttachment.setValue("~field_name~", fieldName);
        fseAttachment.setValue(UUID.randomUUID().toString(), fileName);
        fseAttachment.setValue("client_uuid", clientUUID);
        requestParameterEntity.setFormData(fseAttachment);
        FieldSetEntity resultFse = fileManagerService.uploadFile(requestParameterEntity);
        return resultFse.getString(fieldName);
    }
    /**
     * 提取fse中指定字段信息转化为JSONObject
     * @param fse                   待处理数据
     * @param acceptCollection      接收字段的集合
     * @return
     */
    private JSONObject extractFseAimField2Obj(FieldSetEntity fse, Collection<String> acceptCollection) {
        JSONObject resultObj = new JSONObject();
        acceptCollection.forEach(fieldName -> resultObj.put(fieldName, fse.getString(fieldName)));
        return resultObj;
    }
    /**
     * 处理值,若是含有系统参数,那么替换,若是不含,则直接返回
     * @param value
     * @return
     */
    private String dealValue(String value) {
        if (value.contains("{")) {
            return SystemParamReplace.systemParamsReplace(value);
        } else {
            return value;
        }
    }
    /**
     * 处理结果信息-默认方法
     * @param resultObj     结果内容obj
     * @param structureObj  结构信息arr
     * @return
     */
    private JSONObject dealResult(JSONObject resultObj, JSONObject structureObj) {
        JSONObject infoObj = new JSONObject();
        dealResultPart(infoObj, resultObj, structureObj, "");
        return infoObj;
    }
    private void dealResultPart(JSONObject infoObj, JSONObject resultObj, JSONObject structureObj, String curTableName) {
        if (structureObj == null || resultObj.isEmpty()) {
            return;
        }
        FieldSetEntity fse = null;
        if (!StringUtils.isEmpty(curTableName)) {
            fse = new FieldSetEntity(curTableName);
            DataTableEntity dte = (DataTableEntity) infoObj.getJSONObject(curTableName).get(CmnConst.TABLE);
            dte.addFieldSetEntity(fse);
        }
        for (Map.Entry<String, Object> entry : resultObj.entrySet()) {
            String resultKey = entry.getKey();
            Object resultValue = entry.getValue();
            JSONObject singleStructureObj = structureObj.getJSONObject(resultKey);
            if (singleStructureObj == null || singleStructureObj.isEmpty()) {
                if (fse != null) {
                    fse.setValue(resultKey, resultValue);
                }
            } else {
                String dealtCodeField = String.format("[%s]", CmnConst.CODE);
                String dealtMessageField = String.format("[%s]", CmnConst.MESSAGE);
                String dealtTypeField = String.format("[%s]", CmnConst.TYPE);
                String dealtDBInfoField = String.format("[%s]", CmnConst.DB_INFO);
                if ("1".equals(singleStructureObj.getString(dealtTypeField)) && StringUtils.isEmpty(infoObj.getString(dealtCodeField))) {
                    // 状态码
                    infoObj.put(CmnConst.CODE, resultValue);
                } else if ("2".equals(singleStructureObj.getString(dealtTypeField)) && StringUtils.isEmpty(infoObj.getString(dealtMessageField))) {
                    // 消息内容
                    infoObj.put(CmnConst.MESSAGE, resultValue);
                } else if ("3".equals(singleStructureObj.getString(dealtTypeField))) {
                    // 表
                    JSONObject tableInfoObj = new JSONObject();
                    curTableName = singleStructureObj.getString(dealtDBInfoField);
                    infoObj.put(curTableName, tableInfoObj);
                    DataTableEntity dte = new DataTableEntity();
                    tableInfoObj.put(CmnConst.TABLE, dte);
                    Set<String> uniqueSignSet = Sets.newHashSet();
                    tableInfoObj.put(CmnConst.UNIQUE_SIGN, uniqueSignSet);
                } else if ("4".equals(singleStructureObj.getString(dealtTypeField))) {
                    // 字段
                    if (fse != null) {
                        fse.setValue(singleStructureObj.getString(dealtDBInfoField), resultValue);
                    }
                    String dealtUniqueSignField = String.format("[%s]", CmnConst.UNIQUE_SIGN);
                    if ("1".equals(singleStructureObj.getString(dealtUniqueSignField))) {
                        Set<String> uniqueSignSet = (Set<String>) infoObj.getJSONObject(curTableName).get(CmnConst.UNIQUE_SIGN);
                        uniqueSignSet.add(singleStructureObj.getString(dealtDBInfoField));
                    }
                }
            }
            if (resultValue instanceof JSONArray) {
                JSONArray arr = (JSONArray) resultValue;
                for (int i = 0; i < arr.size(); i++) {
                    dealResultPart(infoObj, arr.getJSONObject(i), singleStructureObj, curTableName);
                }
            } else if (resultValue instanceof JSONObject) {
                if (singleStructureObj != null) {
                    dealResultPart(infoObj, (JSONObject) resultValue, singleStructureObj, curTableName);
                }
            }
        }
        JSONObject tableInfoObj = resultObj.getJSONObject(curTableName);
        if (tableInfoObj != null) {
            ((DataTableEntity) tableInfoObj.get(curTableName)).addFieldSetEntity(fse);
        }
    }
    /**
     * 日志记录
     * @param configUUID    配置uuid
     * @param code          状态码
     * @param message       返回消息内容
     * @param content       执行明细内容
     */
    private void recordLog(String configUUID, String code, String message, String content) {
        recordLog(configUUID, code, message, content, null);
    }
    /**
     * 日志记录
     * @param configUUID    配置uuid
     * @param code          状态码
     * @param message       返回消息内容
     * @param content       执行明细内容
     * @param errorInfo     错误信息
     */
    private void recordLog(String configUUID, String code, String message, String content, String errorInfo) {
        FieldSetEntity logFse = new FieldSetEntity(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_LOG);
        logFse.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
        logFse.setValue(CmnConst.CONFIG_UUID, configUUID);
        logFse.setValue(CmnConst.CODE, code);
        logFse.setValue(CmnConst.MESSAGE, message);
        if (!StringUtils.isEmpty(errorInfo)) {
            content = BaseUtil.getCurTimeWithMill() + " 执行失败\n" + content;
        } else {
            content = BaseUtil.getCurTimeWithMill() + " 执行成功\n" + content;
        }
        logFse.setValue(CmnConst.CONTENT, content);
        logFse.setValue(CmnConst.ERROR_INFO, errorInfo);
        baseDao.saveFieldSetEntity(logFse);
    }
}