From 2d724995c3ab857869a2c2f5cdb69b732666796a Mon Sep 17 00:00:00 2001 From: roger Date: Mon, 29 Jan 2024 09:38:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-113769=20=E4=BF=AE=E6=94=B9WebServic?= =?UTF-8?q?e=E7=A8=8B=E5=BA=8F=E6=95=B0=E6=8D=AE=E9=9B=86=E5=B8=AE?= =?UTF-8?q?=E5=8A=A9=E6=96=87=E6=A1=A3=E4=B8=AD=E7=9A=84=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/data/WebServiceTableData.java | 86 ++++++++++++++----- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/fr/data/WebServiceTableData.java b/src/main/java/com/fr/data/WebServiceTableData.java index b9f8e51..7c89b12 100644 --- a/src/main/java/com/fr/data/WebServiceTableData.java +++ b/src/main/java/com/fr/data/WebServiceTableData.java @@ -1,38 +1,80 @@ package com.fr.data; -import javax.xml.namespace.QName; +import com.fr.general.data.TableDataException; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ParameterProvider; import org.apache.axis.client.Call; import org.apache.axis.client.Service; -import com.fr.data.AbstractTableData; -import com.fr.general.data.TableDataException; -public class WebServiceTableData extends AbstractTableData{ - private String[][] data; +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; - public WebServiceTableData() { - this.data = this.createData(); - } +public class WebServiceTableData extends SimpleTableData { - //获取列数 - public int getColumnCount() throws TableDataException { - return data[0].length; - } + private static final int COLUMN_COUNT = 10; - //获取列的名称为数组中第一行的值 - public String getColumnName(int columnIndex) throws TableDataException { - return data[0][columnIndex]; + /** + * 初始化列名数组 + * + * @return {col1,col2,col3...} + * @throws TableDataException + */ + @Override + public String[] initColumnNames() { + String[] columnNames = new String[COLUMN_COUNT]; + for (int i = 0; i < COLUMN_COUNT; i++) { + columnNames[i] = "column#" + i; + } + return columnNames; } - //获取行数为数据的长度-1 - public int getRowCount() throws TableDataException { - return data.length - 1; - } + /** + * 加载数据 + * + * @return 行列数据 + */ + @Override + public List loadData() { + String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString(); + FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: \n" + tableName); - //获取值 - public Object getValueAt(int rowIndex, int columnIndex) { - return data[rowIndex + 1][columnIndex]; + // 保存得到的结果集 + ArrayList valueList = new ArrayList(); + + try { + // 调用 Web 服务获取数据 + String[][] data = createData(); + + // 如果数据为空,直接返回空列表 + if (data == null || data.length == 0) { + return valueList; + } + + // 获得总列数 + int colNum = data[0].length; + + // 用对象保存数据 + Object[] objArray = null; + for (int rowIndex = 1; rowIndex < data.length; rowIndex++) { + objArray = new Object[colNum]; + for (int i = 0; i < colNum; i++) { + objArray[i] = data[rowIndex][i]; + } + // 在valueList中加入这一行数据 + valueList.add(objArray); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return valueList; } + /** + * 调用 Web 服务获取数据 + * + * @return + */ public String[][] createData() { try { String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws"; From 2edf2f371b1512345ef4ed2294f2abd972e5b449 Mon Sep 17 00:00:00 2001 From: roger Date: Mon, 29 Jan 2024 09:48:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/data/WebServiceTableData.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fr/data/WebServiceTableData.java b/src/main/java/com/fr/data/WebServiceTableData.java index 7c89b12..e01867b 100644 --- a/src/main/java/com/fr/data/WebServiceTableData.java +++ b/src/main/java/com/fr/data/WebServiceTableData.java @@ -10,6 +10,13 @@ import javax.xml.namespace.QName; import java.util.ArrayList; import java.util.List; +/** + * WebService程序数据集 + * + * @Author Roger + * @Date 2022/10/10 15:46 + * @Version 11.0 + */ public class WebServiceTableData extends SimpleTableData { private static final int COLUMN_COUNT = 10; @@ -37,7 +44,7 @@ public class WebServiceTableData extends SimpleTableData { @Override public List loadData() { String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString(); - FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: \n" + tableName); + FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: {}", tableName); // 保存得到的结果集 ArrayList valueList = new ArrayList(); From 19eb4d058c4c44f424ba73eb79dd57ec25151f04 Mon Sep 17 00:00:00 2001 From: roger Date: Mon, 29 Jan 2024 09:53:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/data/WebServiceTableData.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/fr/data/WebServiceTableData.java b/src/main/java/com/fr/data/WebServiceTableData.java index e01867b..122a1e8 100644 --- a/src/main/java/com/fr/data/WebServiceTableData.java +++ b/src/main/java/com/fr/data/WebServiceTableData.java @@ -13,9 +13,9 @@ import java.util.List; /** * WebService程序数据集 * - * @Author Roger - * @Date 2022/10/10 15:46 - * @Version 11.0 + * @author Roger + * @since 11.0 + * Created on 2024/1/8 */ public class WebServiceTableData extends SimpleTableData {