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
d76dd983
Commit
d76dd983
authored
Jul 19, 2023
by
zhengfunan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整修改
parent
4bbd8ad5
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1283 additions
and
908 deletions
+1283
-908
PimsAsset.java
src/main/java/com/tongda/tdpimssdk/api/PimsAsset.java
+66
-418
PimsBusiness.java
src/main/java/com/tongda/tdpimssdk/api/PimsBusiness.java
+124
-125
PimsDocument.java
src/main/java/com/tongda/tdpimssdk/api/PimsDocument.java
+80
-118
PimsQuery.java
src/main/java/com/tongda/tdpimssdk/api/PimsQuery.java
+89
-89
SaAuth.java
src/main/java/com/tongda/tdpimssdk/auth/SaAuth.java
+78
-78
Product.java
src/main/java/com/tongda/tdpimssdk/entities/Product.java
+1
-1
AppConfigurationSamples.java
...om/tongda/tdpimssdk/examples/AppConfigurationSamples.java
+104
-0
AssetSamples.java
...main/java/com/tongda/tdpimssdk/examples/AssetSamples.java
+430
-0
DocumentSamples.java
...n/java/com/tongda/tdpimssdk/examples/DocumentSamples.java
+119
-0
QuerySamples.java
...main/java/com/tongda/tdpimssdk/examples/QuerySamples.java
+1
-1
PimHttpUtil.java
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
+12
-55
RemoteAppConfiguration.java
...a/com/tongda/tdpimssdk/remote/RemoteAppConfiguration.java
+5
-3
RemoteAsset.java
src/main/java/com/tongda/tdpimssdk/remote/RemoteAsset.java
+2
-6
RemoteDocument.java
...main/java/com/tongda/tdpimssdk/remote/RemoteDocument.java
+4
-1
RemoteTdPimHelper.java
...n/java/com/tongda/tdpimssdk/remote/RemoteTdPimHelper.java
+168
-13
No files found.
src/main/java/com/tongda/tdpimssdk/api/PimsAsset.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
com.tongda.tdpimssdk.entities.Product
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.util.List
;
public
class
PimsAsset
{
/**
* 新建资产
* @param vo
* @return
*/
public
String
pimsTemplate
(
AssetVo
vo
){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 查询资产详情
* @param id
* @return
*/
public
List
<
Product
>
getAssetContent
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/details?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Product
.
class
);
}
/**
* 修改资产或文档属性(字段)
* @param vo
* @return
*/
public
String
updateMetadataValues
(
AssetVo
vo
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/field?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 删除资产
* @param id
* @return
*/
public
String
deleteAsset
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
public
static
String
update
=
"{\n"
+
" \"id\": \"Product-1129487294932189184\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"北京一区\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
create
=
"{\n"
+
" \"templateID\": \"ProductTemplate-1110986502562643968\",\n"
+
" \"label\": \"安全设备\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_name\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_serial_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_belong_project\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_desc\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_brand\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_device_manufacturer\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_model\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.power.watt\",\n"
+
" \"key\": \"rated_total_power\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.quantity.u\",\n"
+
" \"key\": \"device_u\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_usage\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"asset_ownership_epartment\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_department\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_name\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_email\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_procurement_get_method\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_purchase_quantity\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_price\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_amount\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"acquisition_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_person\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_factory\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"storage_warehouse\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"aircraft_building\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"machine_room\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"cabinet_number\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_area\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_start_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"operating_system\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"firmware_version\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"in_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"out_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"business_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
//package com.tongda.tdpimssdk.api;
//
//import com.alibaba.fastjson.JSONObject;
//import com.tongda.tdpimssdk.auth.SaAuth;
//import com.tongda.tdpimssdk.entities.Product;
//import com.tongda.tdpimssdk.http.PimHttpUtil;
//import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
//
//import java.util.List;
//
//public class PimsAsset {
//
// /**
// * 新建资产
// * @param vo
// * @return
// */
// public String pimsTemplate(AssetVo vo){
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPost(this.rsh.saToken,url,(JSONObject)JSONObject.toJSON(vo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 查询资产详情
// * @param id
// * @return
// */
// public List<Product> getAssetContent(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/details?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.sendGet(this.rsh.saToken,url);
// String s=PimsQuery.resultUtil(response);
// return JSONObject.parseArray(s,Product.class);
// }
//
// /**
// * 修改资产或文档属性(字段)
// * @param vo
// * @return
// */
// public String updateMetadataValues(AssetVo vo) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/field?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPut(url,(JSONObject)JSONObject.toJSON(vo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 删除资产
// * @param id
// * @return
// */
// public String deleteAsset(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.sendDelete(url);
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
//
//
//
//
//
//}
src/main/java/com/tongda/tdpimssdk/api/PimsBusiness.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
com.tongda.tdpimssdk.entities.Product
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.entities.common.Team2
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
com.tongda.tdpimssdk.resultVo.vo.CatalogItem
;
import
com.tongda.tdpimssdk.resultVo.vo.TeamVo
;
import
java.util.List
;
public
class
PimsBusiness
{
/**
* 新建业务
* @param teamVo
* @return
*/
public
String
createBusiness
(
TeamVo
teamVo
){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 查询业务详情
* @param id
* @return
*/
public
List
<
Team2
>
getBusinessDetails
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business/details?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Team2
.
class
);
}
/**
* 查询目录下资产列表
* @param id
* @return
*/
public
List
<
CatalogRoot
>
queryAssetByCatalog
(
String
id
,
String
catalogID
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business/details?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
+
"&catalogID="
+
catalogID
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
/**
* 修改资产或文档属性(字段)
* @param vo
* @return
*/
public
String
getLifeCycleDefinitionList
(
AssetVo
vo
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/field?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 删除业务
* @param id
* @return
*/
public
String
deleteTeam
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business?dbName="
+
SaAuth
.
dbName
;
TeamVo
teamVo
=
new
TeamVo
();
teamVo
.
setTeamID
(
id
);
String
response
=
PimHttpUtil
.
sendDeleteBody
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 将资源从业务团队中移除
* {
* "dbName": "TXPIMDB",
* "id": "Team2-1125463491344334848",
* "assetID": "Product-1125819770889830400"
* }
* @return
*/
public
String
removeAssetFromTeam
(
CatalogItem
item
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business/asset?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendDeleteBody
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 修改资产或文档属性(字段)
* @param item
* @return
*/
public
String
addAssetRefToTeam
(
CatalogItem
item
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business/asset?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
public
static
String
remove
=
"{\n"
+
" \"dbName\": \"TXPIMDB\",\n"
+
" \"id\": \"Team2-1125463491344334848\",\n"
+
" \"assetID\": \"Product-1126119026813042688\"\n"
+
"}"
;
public
static
String
create
=
"{\n"
+
" \"userId\": \"EndUser-1128343251971997696\",\n"
+
" \"label\": \"test16\",\n"
+
" \"desc\": \"test\",\n"
+
" \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n"
+
"}"
;
}
//package com.tongda.tdpimssdk.api;
//
//import com.alibaba.fastjson.JSONObject;
//import com.tongda.tdpimssdk.auth.SaAuth;
//import com.tongda.tdpimssdk.entities.Product;
//import com.tongda.tdpimssdk.entities.common.CatalogRoot;
//import com.tongda.tdpimssdk.entities.common.Team2;
//import com.tongda.tdpimssdk.http.PimHttpUtil;
//import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
//import com.tongda.tdpimssdk.resultVo.vo.CatalogItem;
//import com.tongda.tdpimssdk.resultVo.vo.TeamVo;
//
//import java.util.List;
//
//public class PimsBusiness {
//
// /**
// * 新建业务
// * @param teamVo
// * @return
// */
// public String createBusiness(TeamVo teamVo){
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPost(this.rsh.saToken,url,(JSONObject)JSONObject.toJSON(teamVo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 查询业务详情
// * @param id
// * @return
// */
// public List<Team2> getBusinessDetails(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/details?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.sendGet(url);
// String s=PimsQuery.resultUtil(response);
// return JSONObject.parseArray(s,Team2.class);
// }
//
// /**
// * 查询目录下资产列表
// * @param id
// * @return
// */
// public List<CatalogRoot> queryAssetByCatalog(String id, String catalogID) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/details?dbName="+SaAuth.dbName+"&id="+id+"&catalogID="+catalogID;
// String response= PimHttpUtil.sendGet(url);
// String s=PimsQuery.resultUtil(response);
// return JSONObject.parseArray(s,CatalogRoot.class);
// }
//
// /**
// * 修改资产或文档属性(字段)
// * @param vo
// * @return
// */
// public String getLifeCycleDefinitionList(AssetVo vo) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/field?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPut(url,(JSONObject)JSONObject.toJSON(vo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 删除业务
// * @param id
// * @return
// */
// public String deleteTeam(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business?dbName="+SaAuth.dbName;
// TeamVo teamVo=new TeamVo();
// teamVo.setTeamID(id);
// String response= PimHttpUtil.sendDeleteBody(url,(JSONObject)JSONObject.toJSON(teamVo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 将资源从业务团队中移除
// * {
// * "dbName": "TXPIMDB",
// * "id": "Team2-1125463491344334848",
// * "assetID": "Product-1125819770889830400"
// * }
//
// * @return
// */
// public String removeAssetFromTeam(CatalogItem item) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/asset?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendDeleteBody(url,(JSONObject)JSONObject.toJSON(item));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
//
// /**
// * 修改资产或文档属性(字段)
// * @param item
// * @return
// */
// public String addAssetRefToTeam(CatalogItem item) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/asset?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPut(url,(JSONObject)JSONObject.toJSON(item));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
//
//
// public static String remove="{\n" +
// " \"dbName\": \"TXPIMDB\",\n" +
// " \"id\": \"Team2-1125463491344334848\",\n" +
// " \"assetID\": \"Product-1126119026813042688\"\n" +
// "}";
// public static String create="{\n" +
// " \"userId\": \"EndUser-1128343251971997696\",\n" +
// " \"label\": \"test16\",\n" +
// " \"desc\": \"test\",\n" +
// " \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n" +
// "}";
//
//
//}
src/main/java/com/tongda/tdpimssdk/api/PimsDocument.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
com.tongda.tdpimssdk.entities.Product
;
import
com.tongda.tdpimssdk.entities.Resource
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.io.File
;
import
java.util.List
;
public
class
PimsDocument
{
/**
* 新建文档
* @param vo
* @return
*/
public
String
createDocumentAsset
(
AssetVo
vo
){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/document?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 查询文档详情
* @param id
* @return
*/
public
List
<
Resource
>
getDocumentContent
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/document/content?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Resource
.
class
);
}
/**
* 修改资产或文档属性(字段)
* @param vo
* @return
*/
public
String
getLifeCycleDefinitionList
(
AssetVo
vo
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/document/field?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 删除文档
* @param id
* @return
*/
public
String
deleteAsset
(
String
id
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/document?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
url
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
/**
* 上传文档
* @param id
* @param file
* @return
*/
public
String
uploadBinary
(
String
id
,
File
file
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/document/upload?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
uploadFile
(
url
,
file
);
String
s
=
PimsQuery
.
resultUtil
(
response
);
return
s
;
}
public
static
String
update
=
"{\n"
+
" \"id\": \"Resource-1129783425285226496\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test1234\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
create
=
"{\n"
+
" \"templateID\": \"ResourceTemplate-1125740648473821184\",\n"
+
" \"label\": \"测试7\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test123456789\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
//package com.tongda.tdpimssdk.api;
//
//import com.alibaba.fastjson.JSONObject;
//import com.tongda.tdpimssdk.auth.SaAuth;
//import com.tongda.tdpimssdk.entities.Product;
//import com.tongda.tdpimssdk.entities.Resource;
//import com.tongda.tdpimssdk.http.PimHttpUtil;
//import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
//
//import java.io.File;
//import java.util.List;
//
//public class PimsDocument {
//
// /**
// * 新建文档
// * @param vo
// * @return
// */
// public String createDocumentAsset(AssetVo vo){
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/document?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPost(this.rsh.saToken,url,(JSONObject)JSONObject.toJSON(vo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 查询文档详情
// * @param id
// * @return
// */
// public List<Resource> getDocumentContent(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/document/content?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.sendGet(url);
// String s=PimsQuery.resultUtil(response);
// return JSONObject.parseArray(s,Resource.class);
// }
//
// /**
// * 修改资产或文档属性(字段)
// * @param vo
// * @return
// */
// public String getLifeCycleDefinitionList(AssetVo vo) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/document/field?dbName="+SaAuth.dbName;
// String response= PimHttpUtil.sendPut(url,(JSONObject)JSONObject.toJSON(vo));
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 删除文档
// * @param id
// * @return
// */
// public String deleteAsset(String id) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/document?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.sendDelete(url);
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
// /**
// * 上传文档
// * @param id
// * @param file
// * @return
// */
// public String uploadBinary(String id, File file) {
// String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/document/upload?dbName="+SaAuth.dbName+"&id="+id;
// String response= PimHttpUtil.uploadFile(url,file);
// String s=PimsQuery.resultUtil(response);
// return s;
// }
//
//
//
//
//
//}
src/main/java/com/tongda/tdpimssdk/api/PimsQuery.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
api
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.entities.Entity
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo
;
import
java.util.List
;
public
class
PimsQuery
{
/**
* 查询资产模型清单
* @return
*/
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
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
/**
* 查询文档模型清单
* @return
*/
public
List
<
CatalogRoot
>
queryDocumentList
(){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/template/document?dbName="
+
SaAuth
.
dbName
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
/**
* 根据模型ID查询资产/文档清单
* @param templateID
* @param page
* @param size
* @return
*/
public
GeneralPagerVo
<
AssetAbstract
>
getAssetByTemplate
(
String
templateID
,
int
page
,
int
size
){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset?dbName="
+
SaAuth
.
dbName
+
"&templateID="
+
templateID
+
"&page="
+
page
+
"&size="
+
size
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseObject
(
s
,
new
TypeReference
<
GeneralPagerVo
<
AssetAbstract
>>(){});
}
/**
* 查询资产所属业务
* @param id
* @return
*/
public
List
<
Entity
>
queryAssetAppViewPath
(
String
id
){
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/asset/business/path?dbName="
+
SaAuth
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Entity
.
class
);
}
/**
* 查询业务清单
* @return
*/
public
List
<
Entity
>
getBusinessList
(
String
label
)
{
String
url
=
"http://"
+
SaAuth
.
serverId
+
":"
+
SaAuth
.
serverPort
+
"/pims/business?dbName="
+
SaAuth
.
dbName
+
"&label="
+
label
;
String
response
=
PimHttpUtil
.
sendGet
(
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
Entity
.
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
);
}
}
}
//
package com.tongda.tdpimssdk.api;
//
//
import com.alibaba.fastjson.JSONObject;
//
import com.alibaba.fastjson.TypeReference;
//
import com.tongda.tdpimssdk.auth.SaAuth;
//
import com.tongda.tdpimssdk.entities.AssetAbstract;
//
import com.tongda.tdpimssdk.entities.Entity;
//
import com.tongda.tdpimssdk.entities.common.CatalogRoot;
//
import com.tongda.tdpimssdk.http.PimHttpUtil;
//
import com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo;
//
//
import java.util.List;
//
//
public class PimsQuery {
//
//
/**
//
* 查询资产模型清单
//
* @return
//
*/
//
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);
//
return JSONObject.parseArray(s,CatalogRoot.class);
//
}
//
//
/**
//
* 查询文档模型清单
//
* @return
//
*/
//
public List<CatalogRoot> queryDocumentList(){
//
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/template/document?dbName="+SaAuth.dbName;
//
String response=PimHttpUtil.sendGet(url);
//
String s=resultUtil(response);
//
return JSONObject.parseArray(s,CatalogRoot.class);
//
}
//
//
/**
//
* 根据模型ID查询资产/文档清单
//
* @param templateID
//
* @param page
//
* @param size
//
* @return
//
*/
//
public GeneralPagerVo<AssetAbstract> getAssetByTemplate(String templateID, int page, int size){
//
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset?dbName="+SaAuth.dbName+"&templateID="+templateID+"&page="+page+"&size="+size;
//
String response=PimHttpUtil.sendGet(url);
//
String s=resultUtil(response);
//
return JSONObject.parseObject(s,new TypeReference<GeneralPagerVo<AssetAbstract>>(){});
//
}
//
//
/**
//
* 查询资产所属业务
//
* @param id
//
* @return
//
*/
//
public List<Entity> queryAssetAppViewPath(String id){
//
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/business/path?dbName="+SaAuth.dbName+"&id="+id;
//
String response=PimHttpUtil.sendGet(url);
//
String s=resultUtil(response);
//
return JSONObject.parseArray(s,Entity.class);
//
}
//
//
/**
//
* 查询业务清单
//
* @return
//
*/
//
public List<Entity> getBusinessList(String label) {
//
//
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business?dbName="+SaAuth.dbName+"&label="+label;
//
String response=PimHttpUtil.sendGet(url);
//
String s=resultUtil(response);
//
return JSONObject.parseArray(s,Entity.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/SaAuth.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
auth
;
import
com.tongda.tdpimssdk.api.PimsAsset
;
import
com.tongda.tdpimssdk.api.PimsBusiness
;
import
com.tongda.tdpimssdk.api.PimsDocument
;
import
com.tongda.tdpimssdk.api.PimsQuery
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
lombok.Data
;
@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
loginGetSatoken
(){
String
url
=
"http://"
+
id
+
":"
+
port
+
"/sso/doLogin"
;
satoken
=
PimHttpUtil
.
loginGetSaToken
(
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
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
String
satoken
=
SaAuth
.
loginGetSatoken
();
System
.
out
.
println
(
satoken
);
PimsQuery
pimsQuery
=
new
PimsQuery
();
// //查询5个接口
// System.out.println(pimsQuery.pimsTemplate());
//package com.tongda.tdpimssdk.auth;
//
// System.out.println(pimsQuery.queryDocumentList());
//import com.tongda.tdpimssdk.api.PimsAsset;
//import com.tongda.tdpimssdk.api.PimsBusiness;
//import com.tongda.tdpimssdk.api.PimsDocument;
//import com.tongda.tdpimssdk.api.PimsQuery;
//import com.tongda.tdpimssdk.http.PimHttpUtil;
//import lombok.Data;
//
// System.out.println(pimsQuery.getBusinessList(""));
//@Data
//public class SaAuth {
//
System
.
out
.
println
(
pimsQuery
.
getAssetByTemplate
(
"ProductTemplate-1125744743611891712"
,
1
,
20
));
// 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;
//
// System.out.println(pimsQuery.queryAssetAppViewPath("Product-1128330059979948032"));
PimsAsset
pimsAsset
=
new
PimsAsset
();
// System.out.println(pimsAsset.pimsTemplate(JSONObject.parseObject(PimsAsset.create, AssetVo.class)));
// public SaAuth(String user, String password, String id, int port) {
// this.user = user;
// this.password = password;
// this.id = id;
// this.port = port;
// }
//
// System.out.println(pimsAsset.getAssetContent("Product-1129500005887901696"));
// public static String loginGetSatoken(){
// String url="http://"+id+":"+port+"/sso/doLogin";
// satoken=PimHttpUtil.loginGetSaToken(url,user,password);
// return satoken;
// }
//
//
System.out.println(pimsAsset.getLifeCycleDefinitionList(JSONObject.parseObject(PimsAsset.update, AssetVo.class)));
//
public static void main(String[] args) {
//
// System.out.println(pimsAsset.deleteAsset("Product-1129500005887901696"));
PimsDocument
pimsDocument
=
new
PimsDocument
();
// System.out.println(pimsDocument.createDocumentAsset(JSONObject.parseObject(PimsDocument.create, AssetVo.class)));
// SaAuth.serverId="150.158.75.213";
// SaAuth.serverPort=8080;
// SaAuth.dbName="TXPIMDB";
// SaAuth saAuth=new SaAuth("guantiantian","q1w2e3r4","121.199.160.117",9000);
// String satoken=SaAuth.loginGetSatoken();
// System.out.println(satoken);
//
// System.out.println(pimsDocument.getDocumentContent("Resource-1129786933577252864"));
// PimsQuery pimsQuery =new PimsQuery();
//// //查询5个接口
//// System.out.println(pimsQuery.pimsTemplate());
////
// // System.out.println(pimsQuery.queryDocumentList());
////
//// System.out.println(pimsQuery.getBusinessList(""));
////
//// System.out.println(pimsQuery.getAssetByTemplate("ProductTemplate-1125744743611891712",1,20));
////
//// System.out.println(pimsQuery.queryAssetAppViewPath("Product-1128330059979948032"));
//
// System.out.println(pimsDocument.getLifeCycleDefinitionList(JSONObject.parseObject(PimsDocument.update, AssetVo.class)));
// PimsAsset pimsAsset=new PimsAsset();
//// System.out.println(pimsAsset.pimsTemplate(JSONObject.parseObject(PimsAsset.create, AssetVo.class)));
////
//// System.out.println(pimsAsset.getAssetContent("Product-1129500005887901696"));
////
//// System.out.println(pimsAsset.getLifeCycleDefinitionList(JSONObject.parseObject(PimsAsset.update, AssetVo.class)));
////
//// System.out.println(pimsAsset.deleteAsset("Product-1129500005887901696"));
// PimsDocument pimsDocument=new PimsDocument();
//
// System.out.println(pimsDocument.deleteAsset("Resource-1129433907997966336"));
PimsBusiness
pimsBusiness
=
new
PimsBusiness
();
// System.out.println(pimsBusiness.createBusiness(JSONObject.parseObject(PimsBusiness.create, TeamVo.class)));
//// System.out.println(pimsDocument.createDocumentAsset(JSONObject.parseObject(PimsDocument.create, AssetVo.class)));
////
//// System.out.println(pimsDocument.getDocumentContent("Resource-1129786933577252864"));
////
//// System.out.println(pimsDocument.getLifeCycleDefinitionList(JSONObject.parseObject(PimsDocument.update, AssetVo.class)));
////
//// System.out.println(pimsDocument.deleteAsset("Resource-1129433907997966336"));
//
//
System.out.println(pimsBusiness.getBusinessDetails("Team2-1129450504951169024")
);
//
PimsBusiness pimsBusiness=new PimsBusiness(
);
//
// System.out.println(pimsBusiness.deleteTeam("Team2-1129450504951169024"));
//// System.out.println(pimsBusiness.createBusiness(JSONObject.parseObject(PimsBusiness.create, TeamVo.class)));
////
//// System.out.println(pimsBusiness.getBusinessDetails("Team2-1129450504951169024"));
////
//// System.out.println(pimsBusiness.deleteTeam("Team2-1129450504951169024"));
////
//// System.out.println(pimsBusiness.queryAssetByCatalog("Team2-1129497138993037312","CatalogAppView-1129455551755845632"));
////
//// System.out.println(pimsBusiness.removeAssetFromTeam(JSONObject.parseObject(PimsBusiness.remove, CatalogItem.class)));
////
//// System.out.println(pimsBusiness.addAssetRefToTeam(JSONObject.parseObject(PimsBusiness.remove, CatalogItem.class)));
//
// System.out.println(pimsBusiness.queryAssetByCatalog("Team2-1129497138993037312","CatalogAppView-1129455551755845632"));
//// File file=new File("C:\\Users\\zfn\\Desktop\\新建 文本文档1.txt");
//// System.out.println(pimsDocument.uploadBinary("Resource-1126839993566756864",file));
//
// System.out.println(pimsBusiness.removeAssetFromTeam(JSONObject.parseObject(PimsBusiness.remove, CatalogItem.class)));
//
// System.out.println(pimsBusiness.addAssetRefToTeam(JSONObject.parseObject(PimsBusiness.remove, CatalogItem.class)));
// File file=new File("C:\\Users\\zfn\\Desktop\\新建 文本文档1.txt");
// System.out.println(pimsDocument.uploadBinary("Resource-1126839993566756864",file));
}
}
// }
//}
src/main/java/com/tongda/tdpimssdk/entities/Product.java
View file @
d76dd983
...
...
@@ -60,7 +60,7 @@ import javax.xml.bind.annotation.XmlType;
"resourceCatalog"
,
"tsVariableDefGroup"
})
public
class
Product
{
public
class
Product
extends
AssetAbstract
{
@XmlElement
(
name
=
"Permission"
,
required
=
true
)
protected
Permission
permission
;
...
...
src/main/java/com/tongda/tdpimssdk/examples/AppConfigurationSamples.java
0 → 100644
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.common.Catalog
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.remote.RemoteAppConfiguration
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
com.tongda.tdpimssdk.resultVo.vo.CatalogItem
;
import
com.tongda.tdpimssdk.resultVo.vo.TeamVo
;
import
java.util.List
;
public
class
AppConfigurationSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
serverIP
=
"150.158.75.213"
;
rsh
.
serverPort
=
8080
;
rsh
.
dbName
=
"TXPIMDB"
;
System
.
out
.
println
(
"登录数据"
+
rsh
.
toString
());
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
String
id
;
// id=rqh.createAppConfig(JSONObject.parseObject(createAppConfig, TeamVo.class));
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK createAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("创建返回结果:"+id);
id
=
"Team2-1131290597932400640"
;
// RemoteAppConfiguration remoteAppConfiguration=rqh.fetchAppConfig(id);
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK fetchAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("查询返回结果:"+ remoteAppConfiguration.getId()+"/"+remoteAppConfiguration.getLabel()+"/"+remoteAppConfiguration.getDesc());
List
<
CatalogRoot
>
catalogList
=
rqh
.
queryAssetByCatalog
(
id
,
"CatalogAppView-1129455551755845632"
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK queryAssetByCatalog:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"查询目录资产结果:"
+
catalogList
.
toString
());
// String re=rqh.deleteAppConfig(id);
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK deleteAppConfig:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("返回结果:"+re);
// CatalogItem catalogItem=new CatalogItem();
// catalogItem.setId("Team2-1125463491344334848");
// catalogItem.setAssetID("Product-1126119026813042688");
// String re=rqh.removeAssetFromApp(catalogItem);
// System.out.println(
// "-------------------------------------------" + "\n" +
// "SDK removeAssetFromApp:" + "\n" +
// "-------------------------------------------"
// );
// System.out.println("资源移除返回结果:"+re);
CatalogItem
catalogItem
=
new
CatalogItem
();
catalogItem
.
setId
(
"Team2-1125463491344334848"
);
catalogItem
.
setAssetID
(
"Product-1126119026813042688"
);
catalogItem
.
setCatalogID
(
"CatalogAppView-1126118732670697472"
);
String
re
=
rqh
.
addAssetRefToAppConfig
(
JSONObject
.
parseObject
(
removeAppConfig
,
CatalogItem
.
class
));
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK addAssetRefToAppConfig:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"资产加入业务返回结果:"
+
re
);
}
public
static
String
removeAppConfig
=
"{\n"
+
" \"id\": \"Team2-1125463491344334848\",\n"
+
" \"assetID\": \"Product-1126119026813042688\"\n"
+
"}"
;
public
static
String
createAppConfig
=
"{\n"
+
" \"userId\": \"EndUser-1128343251971997696\",\n"
+
" \"label\": \"test16\",\n"
+
" \"desc\": \"test\",\n"
+
" \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n"
+
"}"
;
public
static
String
updateAppConfig
=
"{\n"
+
" \"userId\": \"EndUser-1128343251971997696\",\n"
+
" \"label\": \"test16\",\n"
+
" \"desc\": \"test\",\n"
+
" \"lifecycleID\": \"TDLifeCycleDefinition-Common\"\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/AssetSamples.java
0 → 100644
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.entities.AssetAbstract
;
import
com.tongda.tdpimssdk.remote.RemoteAsset
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
AssetSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
rsh
.
serverIP
=
"127.0.0.1"
;
rsh
.
serverPort
=
8080
;
rsh
.
dbName
=
"TXPIMDB"
;
System
.
out
.
println
(
"登录数据"
+
rsh
.
toString
());
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
//创建资产
String
id
=
rqh
.
createAsset
(
JSONObject
.
parseObject
(
createAsset
,
AssetVo
.
class
));
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK createAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"创建返回结果:"
+
id
);
//修改资产的数值
AssetVo
assetVo
=
new
AssetVo
();
assetVo
.
setId
(
id
);
AssetVo
.
AssetField
assetField
=
new
AssetVo
.
AssetField
();
assetField
.
setKey
(
"td_data_center"
);
assetField
.
setMode
(
"tdpim.dict.system.metadata.mode.single.select.value"
);
assetField
.
setValue
(
"北京一区"
);
List
<
AssetVo
.
AssetField
>
list
=
new
LinkedList
<>();
//添加修改项,可以多个
list
.
add
(
assetField
);
assetVo
.
setFields
(
list
);
//执行修改
String
re
=
rqh
.
updateAssetValues
(
assetVo
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK updateAssetValues:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"修改返回结果:"
+
re
);
RemoteAsset
remoteAsset
=
rqh
.
fetchAsset
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK fetchAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"查询资产:"
+
remoteAsset
.
getId
()+
"/"
+
remoteAsset
.
getLabel
()+
"/"
+
remoteAsset
.
getDesc
());
re
=
rqh
.
deleteAsset
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK deleteAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"删除资产:"
+
re
);
}
public
static
String
updateAsset
=
"{\n"
+
" \"id\": \"Product-1129487294932189184\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"北京一区\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
createAsset
=
"{\n"
+
" \"templateID\": \"ProductTemplate-1110986502562643968\",\n"
+
" \"label\": \"安全设备\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_name\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_serial_number\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_belong_project\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_desc\",\n"
+
" \"value\": \"test\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_data_center\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_brand\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_device_manufacturer\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_model\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.power.watt\",\n"
+
" \"key\": \"rated_total_power\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.quantity.u\",\n"
+
" \"key\": \"device_u\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_usage\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"asset_ownership_epartment\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_department\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_name\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"responsible_person_email\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_procurement_get_method\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_purchase_quantity\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_price\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"tdpim.dict.custom.uom.td_currency.cny.yuan\",\n"
+
" \"key\": \"td_purchase_amount\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"acquisition_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_person\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_factory\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"original_contact_phone\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"storage_warehouse\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"aircraft_building\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"machine_room\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"cabinet_number\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_area\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"service_start_date\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"operating_system\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"firmware_version\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"in_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"out_band_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"business_ip\",\n"
+
" \"value\": \"\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/DocumentSamples.java
0 → 100644
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
examples
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.remote.RemoteDocument
;
import
com.tongda.tdpimssdk.remote.RemoteSaAuthHandler
;
import
com.tongda.tdpimssdk.remote.RemoteTdPimHelper
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
java.io.File
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
DocumentSamples
{
public
static
void
main
(
String
[]
args
)
{
RemoteSaAuthHandler
rsh
=
new
RemoteSaAuthHandler
(
"guantiantian"
,
"q1w2e3r4"
,
"121.199.160.117"
,
9000
);
rsh
.
loginGetSaToken
();
// rsh.serverIP ="127.0.0.1";
rsh
.
serverIP
=
"150.158.75.213"
;
rsh
.
serverPort
=
8080
;
rsh
.
dbName
=
"TXPIMDB"
;
//初始化远程查询对象
RemoteTdPimHelper
rqh
=
new
RemoteTdPimHelper
(
rsh
);
String
id
=
rqh
.
createDocument
(
JSONObject
.
parseObject
(
createDocument
,
AssetVo
.
class
));
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK createAsset:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"创建返回结果:"
+
id
);
RemoteDocument
remoteDocument
=
rqh
.
fetchDocument
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK fetchDocument:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"查询文档:"
+
remoteDocument
.
getId
()+
"/"
+
remoteDocument
.
getLabel
()+
"/"
+
remoteDocument
.
getDesc
());
//
AssetVo
assetVo
=
new
AssetVo
();
assetVo
.
setId
(
id
);
AssetVo
.
AssetField
assetField
=
new
AssetVo
.
AssetField
();
assetField
.
setKey
(
"td_asset_number"
);
assetField
.
setMode
(
"tdpim.dict.system.metadata.mode.single.value"
);
assetField
.
setValue
(
"test1234"
);
List
<
AssetVo
.
AssetField
>
list
=
new
LinkedList
<>();
//添加修改项,可以多个
list
.
add
(
assetField
);
assetVo
.
setFields
(
list
);
//执行修改
String
re
=
rqh
.
updateDocumentValues
(
assetVo
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK updateDocumentValues:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"修改文档:"
+
re
);
re
=
rqh
.
deleteDocument
(
id
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK deleteDocument:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"删除文档:"
+
re
);
File
file
=
new
File
(
"C:\\Users\\zfn\\Desktop\\新建 文本文档1.txt"
);
re
=
rqh
.
uploadBinary
(
"Resource-1131278751615680512"
,
file
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK uploadBinary:"
+
"\n"
+
"-------------------------------------------"
);
System
.
out
.
println
(
"上传文档:"
+
re
);
}
public
static
String
updateDocumentValues
=
"{\n"
+
" \"id\": \"Resource-1129783425285226496\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test1234\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
public
static
String
createDocument
=
"{\n"
+
" \"templateID\": \"ResourceTemplate-1125740648473821184\",\n"
+
" \"label\": \"测试7\",\n"
+
" \"fields\": [\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_number\",\n"
+
" \"value\": \"test123456789\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" },\n"
+
" {\n"
+
" \"mode\": \"tdpim.dict.system.metadata.mode.single.select.value\",\n"
+
" \"uom\": \"\",\n"
+
" \"key\": \"td_asset_subtype\",\n"
+
" \"value\": \"安全设备\",\n"
+
" \"valueMin\": null,\n"
+
" \"valueMax\": null,\n"
+
" \"selectedIDs\": null\n"
+
" }\n"
+
" ]\n"
+
"}"
;
}
src/main/java/com/tongda/tdpimssdk/examples/QuerySamples.java
View file @
d76dd983
...
...
@@ -56,7 +56,7 @@ public class QuerySamples {
}
List
<
Entity
>
le
=
rqh
.
fetchApp
Service
List
(
""
);
List
<
Entity
>
le
=
rqh
.
fetchApp
Config
List
(
""
);
System
.
out
.
println
(
"-------------------------------------------"
+
"\n"
+
"SDK getAppServiceList:"
+
"\n"
+
...
...
src/main/java/com/tongda/tdpimssdk/http/PimHttpUtil.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
http
;
import
com.alibaba.fastjson.JSONObject
;
import
com.tongda.tdpimssdk.auth.SaAuth
;
import
org.apache.http.Consts
;
import
org.apache.http.Header
;
import
org.apache.http.HeaderElement
;
...
...
@@ -78,49 +77,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendGet
(
String
url
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
//创建一个uri对象
URIBuilder
uriBuilder
=
null
;
uriBuilder
=
new
URIBuilder
(
url
);
//创建httpGet远程连接实例,这里传入目标的网络地址
HttpGet
httpGet
=
new
HttpGet
(
uriBuilder
.
build
());
httpGet
.
setHeader
(
"Satoken"
,
SaAuth
.
satoken
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
.
setSocketTimeout
(
60000
)
// 数据读取超时时间
.
build
();
// 为httpGet实例设置配置
httpGet
.
setConfig
(
requestConfig
);
//执行请求
CloseableHttpResponse
response
=
client
.
execute
(
httpGet
);
//获取Response状态码
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
statusCode
);
//获取响应实体, 响应内容
HttpEntity
entity
=
response
.
getEntity
();
//通过EntityUtils中的toString方法将结果转换为字符串
String
str
=
EntityUtils
.
toString
(
entity
);
System
.
out
.
println
(
str
);
response
.
close
();
client
.
close
();
return
str
;
}
catch
(
URISyntaxException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
ClientProtocolException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
static
String
sendGet
(
String
token
,
String
url
){
public
static
String
sendGet
(
String
token
,
String
url
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -141,7 +98,7 @@ public class PimHttpUtil {
CloseableHttpResponse
response
=
client
.
execute
(
httpGet
);
//获取Response状态码
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
//
System.out.println(statusCode);
System
.
out
.
println
(
statusCode
);
//获取响应实体, 响应内容
HttpEntity
entity
=
response
.
getEntity
();
//通过EntityUtils中的toString方法将结果转换为字符串
...
...
@@ -161,7 +118,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendPost
(
String
url
,
JSONObject
jsonObject
){
public
static
String
sendPost
(
String
token
,
String
url
,
JSONObject
jsonObject
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -170,7 +127,7 @@ public class PimHttpUtil {
uriBuilder
=
new
URIBuilder
(
url
);
//创建httpGet远程连接实例,这里传入目标的网络地址
HttpPost
httpPost
=
new
HttpPost
(
uriBuilder
.
build
());
httpPost
.
setHeader
(
"Satoken"
,
SaAuth
.
sa
token
);
httpPost
.
setHeader
(
"Satoken"
,
token
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
...
...
@@ -203,7 +160,7 @@ public class PimHttpUtil {
}
}
public
static
String
uploadFile
(
String
url
,
File
file
){
public
static
String
uploadFile
(
String
token
,
String
url
,
File
file
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -212,7 +169,7 @@ public class PimHttpUtil {
uriBuilder
=
new
URIBuilder
(
url
);
HttpPost
httpPost
=
new
HttpPost
(
uriBuilder
.
build
());
// 设置请求头信息,鉴权(没有可忽略)
httpPost
.
setHeader
(
"Satoken"
,
SaAuth
.
sa
token
);
httpPost
.
setHeader
(
"Satoken"
,
token
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
...
...
@@ -255,7 +212,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendPut
(
String
url
,
JSONObject
jsonObject
){
public
static
String
sendPut
(
String
token
,
String
url
,
JSONObject
jsonObject
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -264,7 +221,7 @@ public class PimHttpUtil {
uriBuilder
=
new
URIBuilder
(
url
);
//创建远程连接实例,这里传入目标的网络地址
HttpPut
httpPut
=
new
HttpPut
(
uriBuilder
.
build
());
httpPut
.
setHeader
(
"Satoken"
,
SaAuth
.
sa
token
);
httpPut
.
setHeader
(
"Satoken"
,
token
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
...
...
@@ -296,7 +253,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendDelete
(
String
url
){
public
static
String
sendDelete
(
String
token
,
String
url
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -305,7 +262,7 @@ public class PimHttpUtil {
//创建远程连接实例,这里传入目标的网络地址
HttpDelete
httpDelete
=
new
HttpDelete
(
uriBuilder
.
build
());
// 设置请求头信息,鉴权(没有可忽略)
httpDelete
.
setHeader
(
"Satoken"
,
SaAuth
.
sa
token
);
httpDelete
.
setHeader
(
"Satoken"
,
token
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
...
...
@@ -337,7 +294,7 @@ public class PimHttpUtil {
}
}
public
static
String
sendDeleteBody
(
String
url
,
JSONObject
jsonObject
){
public
static
String
sendDeleteBody
(
String
token
,
String
url
,
JSONObject
jsonObject
){
try
{
//创建httpClient实例
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
...
...
@@ -346,7 +303,7 @@ public class PimHttpUtil {
//创建远程连接实例,这里传入目标的网络地址
HttpDeleteWithBody
httpDelete
=
new
HttpDeleteWithBody
(
uriBuilder
.
build
());
// 设置请求头信息,鉴权(没有可忽略)
httpDelete
.
setHeader
(
"Satoken"
,
SaAuth
.
sa
token
);
httpDelete
.
setHeader
(
"Satoken"
,
token
);
// 设置配置请求参数(没有可忽略)
RequestConfig
requestConfig
=
RequestConfig
.
custom
().
setConnectTimeout
(
60000
)
// 连接主机服务超时时间
.
setConnectionRequestTimeout
(
60000
)
// 请求超时时间
...
...
src/main/java/com/tongda/tdpimssdk/remote/RemoteAppConfiguration.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
lombok.Data
;
import
com.tongda.tdpimssdk.entities.common.Team2
;
public
class
RemoteAppConfiguration
extends
Team2
{
@Data
public
class
RemoteAppConfiguration
{
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteAsset.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
remote
;
import
com.tongda.tdpimssdk.entities.Product
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
lombok.Data
;
public
class
RemoteAsset
extends
Product
{
public
String
updateMetadataValues
(
AssetVo
vo
){
return
""
;
}
public
class
RemoteAsset
extends
Product
{
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteDocument.java
View file @
d76dd983
package
com
.
tongda
.
tdpimssdk
.
remote
;
public
class
RemoteDocument
{
import
com.tongda.tdpimssdk.entities.Resource
;
public
class
RemoteDocument
extends
Resource
{
}
src/main/java/com/tongda/tdpimssdk/remote/RemoteTdPimHelper.java
View file @
d76dd983
...
...
@@ -6,8 +6,12 @@ import com.tongda.tdpimssdk.entities.AssetAbstract;
import
com.tongda.tdpimssdk.entities.Entity
;
import
com.tongda.tdpimssdk.entities.common.CatalogRoot
;
import
com.tongda.tdpimssdk.http.PimHttpUtil
;
import
com.tongda.tdpimssdk.resultVo.vo.AssetVo
;
import
com.tongda.tdpimssdk.resultVo.vo.CatalogItem
;
import
com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo
;
import
com.tongda.tdpimssdk.resultVo.vo.TeamVo
;
import
java.io.File
;
import
java.util.List
;
public
class
RemoteTdPimHelper
{
...
...
@@ -16,6 +20,7 @@ public class RemoteTdPimHelper {
public
RemoteTdPimHelper
(
RemoteSaAuthHandler
rsh
){
this
.
rsh
=
rsh
;
}
/**
* 查询资产模型清单
* @return
...
...
@@ -77,7 +82,7 @@ public class RemoteTdPimHelper {
* 查询业务清单
* @return
*/
public
List
<
Entity
>
fetchApp
Service
List
(
String
label
)
{
public
List
<
Entity
>
fetchApp
Config
List
(
String
label
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
+
"&label="
+
label
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
...
...
@@ -85,45 +90,195 @@ public class RemoteTdPimHelper {
return
JSONObject
.
parseArray
(
s
,
Entity
.
class
);
}
//------------资产相关------------
public
void
createAsset
(){
/**
* 修改资产
* @param vo
* @return
*/
public
String
updateAssetValues
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/field?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
void
deleteAsset
(){
/**
* 新建资产
* @param vo
* @return
*/
public
String
createAsset
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
RemoteAsset
fetchAsset
(){
return
null
;
/**
* 删除资产
* @param id
* @return
*/
public
String
deleteAsset
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 查询资产
* @param id
* @return
*/
public
RemoteAsset
fetchAsset
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
RemoteAsset
.
class
).
get
(
0
);
}
//------------文档相关------------
public
void
createDocument
(){
/**
* 创建文档
* @param vo
* @return
*/
public
String
createDocument
(
AssetVo
vo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/document?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 查询文档
* @param id
* @return
*/
public
RemoteDocument
fetchDocument
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/document/content?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
RemoteDocument
.
class
).
get
(
0
);
}
public
void
deleteDocument
(){
/**
* 修改文档
* @param vo
* @return
*/
public
String
updateDocumentValues
(
AssetVo
vo
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/document/field?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
vo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 删除文档
* @param id
* @return
*/
public
String
deleteDocument
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/asset/document?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendDelete
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
s
;
}
public
RemoteDocument
fetchDocument
(){
return
null
;
/**
* 上传文件
* @param id
* @param file
* @return
*/
public
String
uploadBinary
(
String
id
,
File
file
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/document/upload?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
uploadFile
(
this
.
rsh
.
saToken
,
url
,
file
);
String
s
=
resultUtil
(
response
);
return
s
;
}
public
void
createAppConfiguration
(){
//------------业务相关------------
/**
* 新建业务
* @param teamVo
* @return
*/
public
String
createAppConfig
(
TeamVo
teamVo
){
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPost
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
void
createDeleteConfiguration
(){
/**
* 查询业务详情
* @param id
* @return
*/
public
RemoteAppConfiguration
fetchAppConfig
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
RemoteAppConfiguration
.
class
).
get
(
0
);
}
/**
* 查询目录下资产列表
* @param id
* @return
*/
public
List
<
CatalogRoot
>
queryAssetByCatalog
(
String
id
,
String
catalogID
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/details?dbName="
+
this
.
rsh
.
dbName
+
"&id="
+
id
+
"&catalogID="
+
catalogID
;
String
response
=
PimHttpUtil
.
sendGet
(
this
.
rsh
.
saToken
,
url
);
String
s
=
resultUtil
(
response
);
return
JSONObject
.
parseArray
(
s
,
CatalogRoot
.
class
);
}
public
RemoteAppConfiguration
fetchAppConfiguration
(){
return
null
;
/**
* 删除业务
* @param id
* @return
*/
public
String
deleteAppConfig
(
String
id
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business?dbName="
+
this
.
rsh
.
dbName
;
TeamVo
teamVo
=
new
TeamVo
();
teamVo
.
setTeamID
(
id
);
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
teamVo
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 将资源从业务团队中移除
* @return
*/
public
String
removeAssetFromApp
(
CatalogItem
item
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendDeleteBody
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
resultUtil
(
response
);
return
s
;
}
/**
* 将资产加入业务
* @param item
* @return
*/
public
String
addAssetRefToAppConfig
(
CatalogItem
item
)
{
String
url
=
"http://"
+
this
.
rsh
.
serverIP
+
":"
+
this
.
rsh
.
serverPort
+
"/pims/business/asset?dbName="
+
this
.
rsh
.
dbName
;
String
response
=
PimHttpUtil
.
sendPut
(
this
.
rsh
.
saToken
,
url
,(
JSONObject
)
JSONObject
.
toJSON
(
item
));
String
s
=
resultUtil
(
response
);
return
s
;
}
public
static
String
resultUtil
(
String
re
){
// System.out.println(re);
...
...
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