From 216b43c84804b2ce5b1e1b7b808942078f73ee69 Mon Sep 17 00:00:00 2001
From: 6c <420680616@qq.com>
Date: 星期二, 02 十二月 2025 16:05:49 +0800
Subject: [PATCH] 接口集成-保存
---
.gitignore | 4 +
src/main/java/com/product/integration/service/InterfaceIntegrationService.java | 115 ++++++++++++++++++++++++++++++++++++++
pom.xml | 45 +++++++++++++++
3 files changed, 164 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2945707
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+target/
+.classpath
+.project
+.settings/
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..eee65c3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>product-server</artifactId>
+ <groupId>com.lx</groupId>
+ <version>2.0.0-release</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>product-server-integration</artifactId>
+ <name>product-server-integration</name>
+ <version>2.0.0-release</version>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+ <distributionManagement>
+ <repository>
+ <id>nexus-releases</id>
+ <name>LX-PRODUCT-RELEASE</name>
+ <url>http://nonxin.cn:8088/repository/LX-PRODUCT-RELEASE/</url>
+ <uniqueVersion>true</uniqueVersion>
+ </repository>
+ </distributionManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.lx</groupId>
+ <artifactId>product-server-admin</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/com/product/integration/service/InterfaceIntegrationService.java b/src/main/java/com/product/integration/service/InterfaceIntegrationService.java
new file mode 100644
index 0000000..6c51293
--- /dev/null
+++ b/src/main/java/com/product/integration/service/InterfaceIntegrationService.java
@@ -0,0 +1,115 @@
+package com.product.integration.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Maps;
+import com.product.admin.service.PublicService;
+import com.product.common.lang.StringUtils;
+import com.product.core.dao.BaseDao;
+import com.product.core.entity.DataTableEntity;
+import com.product.core.entity.FieldSetEntity;
+import com.product.core.spring.context.SpringMVCContextHolder;
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 瀹炵幇鍔熻兘锛�
+ *
+ * @author 浣滆�匸澶滀付鍏塢
+ * @version 1.0.00 2025-12-01 11:15
+ */
+@Service
+public class InterfaceIntegrationService implements IInterfaceIntegrationService {
+ @Autowired
+ private BaseDao baseDao;
+ @Autowired
+ private PublicService publicService;
+
+ /**
+ * 鏌ヨ鏁版嵁
+ * @param fse
+ * @return
+ */
+ public FieldSetEntity find(FieldSetEntity fse) {
+ FieldSetEntity integrationFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION, fse.getUUID(), true);
+ 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);
+ integrationFse.removeSubData(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
+ integrationFse.setValue(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO, arr.toString());
+ return integrationFse;
+ }
+
+ /**
+ * 淇濆瓨
+ * @param fse
+ * @return
+ */
+ @Override
+ public String save(FieldSetEntity fse) {
+ String responseInfo = fse.getString(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
+
+ // 娓呯悊鍝嶅簲缁撴瀯瀛愯〃
+ String uuid = fse.getUUID();
+ if (!StringUtils.isEmpty(uuid)) {
+ baseDao.delete(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO, String.format("%s=?", CmnConst.PARENT_UUID), new Object[]{uuid});
+ }
+
+ DataTableEntity responseInfoDte = dealResponseInfo(responseInfo);
+ fse.addSubDataTable(responseInfoDte);
+ return publicService.saveFieldSetEntity(fse);
+ }
+ /**
+ * 澶勭悊鍝嶅簲鏁版嵁缁撴瀯
+ * @param responseInfo 鍝嶅簲鏍戠粨鏋勫瓙琛ㄤ俊鎭�
+ * @return
+ */
+ private DataTableEntity dealResponseInfo(String responseInfo) {
+ DataTableEntity responseInfoDte = new DataTableEntity();
+ try {
+ if (!StringUtils.isEmpty(responseInfo)) {
+ saveDealResponseInfoPart(responseInfoDte, JSONArray.parseArray(responseInfo), "");
+ }
+ } catch (Exception e) {
+ SpringMVCContextHolder.getSystemLogger().error(IntegrationCode.SAVE_DEAL_RESPONSE_INFO);
+ }
+ return responseInfoDte;
+ }
+ /**
+ * 淇濆瓨-澶勭悊鍝嶅簲鏁版嵁缁撴瀯-寰幆鏂规硶
+ * @param responseInfoDte 瀛樺偍瀹瑰櫒锛屽搷搴斿瓙琛ㄦ暟鎹甦te
+ * @param responseInfoArr 鍝嶅簲瀛愯〃鏁版嵁寰呭鐞嗘暟缁�
+ * @param parentCode 鐖剁紪鐮�
+ */
+ private void saveDealResponseInfoPart(DataTableEntity responseInfoDte, JSONArray responseInfoArr, String parentCode) {
+ for (int i = 0; i < responseInfoArr.size(); i++) {
+ JSONObject responseInfoObj = responseInfoArr.getJSONObject(i);
+ FieldSetEntity fse = new FieldSetEntity(CmnConst.PRODUCT_SYS_INTERFACE_INTEGRATION_RESPONSE_INFO);
+ List<String> passList = Arrays.asList("promptName", "children", "front_uuid");
+ List<String> fieldList = Arrays.asList("name", "type", "db_info", "unique_sign");
+ String code = String.format("%s%0" + 3 + "d", parentCode, i + 1);
+ responseInfoObj.forEach((key, value) -> {
+ if (!passList.contains(key)) {
+ fse.setValue(key, value);
+ }
+ });
+ fieldList.forEach(fieldName -> {
+ if (StringUtils.isEmpty(fse.getString(fieldName))) {
+ fse.setValue(fieldName, "");
+ }
+ });
+ fse.setValue(CmnConst.TRICODE, code);
+ responseInfoDte.addFieldSetEntity(fse);
+ saveDealResponseInfoPart(responseInfoDte, responseInfoObj.getJSONArray(CmnConst.CHILDREN), code);
+ }
+ }
+}
--
Gitblit v1.9.2