Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
TDPIMS-SDK
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengfunan
TDPIMS-SDK
Commits
6b2d4890
Commit
6b2d4890
authored
Jul 12, 2023
by
zhengfunan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json解析
parent
df2f2307
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
64 deletions
+115
-64
pom.xml
pom.xml
+6
-0
Pim.java
src/main/java/com/tongda/tdpimssdk/api/Pim.java
+0
-7
PimsApi.java
src/main/java/com/tongda/tdpimssdk/api/PimsApi.java
+34
-0
Login.java
src/main/java/com/tongda/tdpimssdk/auth/Login.java
+0
-31
SaAuth.java
src/main/java/com/tongda/tdpimssdk/auth/SaAuth.java
+52
-0
MetadataEntryTemplate.java
.../com/tongda/tdpimssdk/entities/MetadataEntryTemplate.java
+16
-21
ChangeLog.java
.../java/com/tongda/tdpimssdk/entities/common/ChangeLog.java
+1
-0
PimHttpUtil.java
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
+6
-5
No files found.
pom.xml
View file @
6b2d4890
...
...
@@ -74,6 +74,12 @@
<version>
2.9.6
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.10.1
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/tongda/tdpimssdk/api/Pim.java
deleted
100644 → 0
View file @
df2f2307
package
com
.
tongda
.
tdpimssdk
.
api
;
public
class
Pim
{
// private String
}
src/main/java/com/tongda/tdpimssdk/api/PimsApi.java
0 → 100644
View file @
6b2d4890
package
com
.
tongda
.
tdpimssdk
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
java.util.List
;
public
class
PimsApi
{
public
List
<
CatalogRoot
>
pimsTemplate
(){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/template?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
resultUtil
(
response
);
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
public
static
String
resultUtil
(
String
re
){
System
.
out
.
println
(
re
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
re
);
if
(
jsonObject
.
get
(
"code"
).
toString
().
equals
(
"200"
)){
return
jsonObject
.
get
(
"data"
).
toString
();
}
else
{
throw
new
RuntimeException
(
"调用接口异常:"
+
re
);
}
}
}
src/main/java/com/tongda/tdpimssdk/auth/Login.java
deleted
100644 → 0
View file @
df2f2307
package
com
.
tongda
.
tdpimssdk
.
auth
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
lombok.Data
;
import
java.util.HashMap
;
@Data
public
class
Login
{
private
String
user
;
private
String
password
;
private
String
satoken
;
public
static
void
main
(
String
[]
args
)
{
String
url
=
"http://121.199.160.117:9000/sso/doLogin"
;
// String url="http://121.199.160.117:9000/sso/auth?redirect=#";
String
satoken
=
PimHttpUtil
.
loginGet
(
url
,
"zhengfunan"
,
"q1w2e3r4"
);
System
.
out
.
println
(
"aaaaaaaaaaaaaaaaaaa;"
+
satoken
);
String
testurl
=
"http://150.158.75.213:8080/pims/metadata/details?dbName=TXPIMDB&id=storage_warehouse"
;
PimHttpUtil
.
sendGet
(
testurl
,
new
HashMap
<>(),
satoken
);
}
}
src/main/java/com/tongda/tdpimssdk/auth/SaAuth.java
0 → 100644
View file @
6b2d4890
package
com
.
tongda
.
tdpimssdk
.
auth
;
import
com.tongda.tdpimssdk.api.PimsApi
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
SaAuth
{
public
static
String
user
;
public
static
String
password
;
public
static
String
id
;
public
static
int
port
;
public
static
String
satoken
;
public
static
String
serverId
;
public
static
int
serverPort
;
public
static
String
dbName
;
public
SaAuth
(
String
user
,
String
password
,
String
id
,
int
port
)
{
this
.
user
=
user
;
this
.
password
=
password
;
this
.
id
=
id
;
this
.
port
=
port
;
}
public
static
String
loginAndSatoken
(){
String
url
=
"http://"
+
id
+
":"
+
port
+
"/sso/doLogin"
;
satoken
=
PimHttpUtil
.
loginGet
(
url
,
user
,
password
);
return
satoken
;
}
public
static
void
main
(
String
[]
args
)
{
SaAuth
.
serverId
=
"150.158.75.213"
;
SaAuth
.
serverPort
=
8080
;
SaAuth
.
dbName
=
"TXPIMDB"
;
SaAuth
saAuth
=
new
SaAuth
(
"zhengfunan"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
String
satoken
=
SaAuth
.
loginAndSatoken
();
PimsApi
pimsApi
=
new
PimsApi
();
List
<
CatalogRoot
>
list
=
pimsApi
.
pimsTemplate
();
System
.
out
.
println
(
list
);
// s= pimsApi.pimsTemplate();
// System.out.println(s);
}
}
src/main/java/com/tongda/tdpimssdk/entities/MetadataEntryTemplate.java
View file @
6b2d4890
...
...
@@ -38,44 +38,39 @@ import javax.xml.bind.annotation.XmlType;
*
*
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlType
(
name
=
""
,
propOrder
=
{
"candidateValue"
})
@Data
@XmlRootElement
(
name
=
"MetadataEntryTemplate"
)
public
class
MetadataEntryTemplate
extends
AbstractDBEntity
{
@XmlElement
(
name
=
"CandidateValue"
)
protected
List
<
CandidateValue
>
candidateValue
;
@NotNull
(
message
=
"缺少元数据编码字段"
)
@NotEmpty
(
message
=
"元数据编码不能为空"
)
@XmlAttribute
(
name
=
"key"
,
required
=
true
)
protected
String
key
;
@XmlAttribute
(
name
=
"mode"
,
required
=
true
)
protected
String
mode
;
@XmlAttribute
(
name
=
"modeLabel"
)
protected
String
modeLabel
;
@XmlAttribute
(
name
=
"dataType"
,
required
=
true
)
protected
String
dataType
;
@XmlAttribute
(
name
=
"dataTypeLabel"
)
protected
String
dataTypeLabel
;
@XmlAttribute
(
name
=
"uom"
)
protected
String
uom
;
@XmlAttribute
(
name
=
"uomLabel"
)
protected
String
uomLabel
;
@XmlAttribute
(
name
=
"value"
,
required
=
true
)
protected
String
value
;
@XmlAttribute
(
name
=
"valueMin"
)
protected
String
valueMin
;
@XmlAttribute
(
name
=
"valueMax"
)
protected
String
valueMax
;
@XmlAttribute
(
name
=
"regPattern"
)
protected
String
regPattern
;
@XmlAttribute
(
name
=
"regPatternLabel"
)
protected
String
regPatternLabel
;
@XmlAttribute
(
name
=
"desc"
)
protected
String
desc
;
}
src/main/java/com/tongda/tdpimssdk/entities/common/ChangeLog.java
View file @
6b2d4890
...
...
@@ -11,6 +11,7 @@ import javax.xml.bind.annotation.XmlSchemaType;
import
javax.xml.bind.annotation.XmlType
;
import
javax.xml.bind.annotation.XmlValue
;
import
javax.xml.datatype.XMLGregorianCalendar
;
import
java.util.GregorianCalendar
;
/**
...
...
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
View file @
6b2d4890
package
com
.
tongda
.
tdpimssdk
.
http
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
org.apache.http.Header
;
import
org.apache.http.HeaderElement
;
import
org.apache.http.HttpEntity
;
...
...
@@ -76,7 +77,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendGet
(
String
url
,
HashMap
hashMap
,
String
satoken
){
public
static
String
sendGet
(
String
url
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -90,12 +91,12 @@ public class PimHttpUtil {
//创建httpGet远程连接实例,这里传入目标的网络地址
HttpGet
httpGet
=
new
HttpGet
(
uriBuilder
.
build
());
httpGet
.
setHeader
(
"Satoken"
,
satoken
);
httpGet
.
setHeader
(
"Satoken"
,
SaAuth
.
satoken
);
// 设置请求头信息,鉴权(没有可忽略)
// httpGet.setHeader("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
1
0000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
1
0000
)
// 请求超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
6
0000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
6
0000
)
// 请求超时时间
.
setSocketTimeout
(
60000
)
// 数据读取超时时间
.
build
();
// 为httpGet实例设置配置
...
...
@@ -113,7 +114,7 @@ public class PimHttpUtil {
response
.
close
();
client
.
close
();
return
""
;
return
str
;
}
catch
(
URISyntaxException
e
)
{
throw
new
RuntimeException
(
e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment