Commit 11e2789a authored by zhengfunan's avatar zhengfunan

提交各接口调用方法

parent 6b2d4890
...@@ -80,6 +80,13 @@ ...@@ -80,6 +80,13 @@
<version>2.10.1</version> <version>2.10.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
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.http.PimHttpUtil;
import com.tongda.tdpimssdk.resultVo.vo.AssetVo;
import javax.validation.constraints.NotBlank;
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
* @param lcID
* @param stateKey
* @return
*/
public List<Product> getAssetContent(String id, String lcID, String stateKey) {
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset/details?dbName="+SaAuth.dbName+"&id="+id+"&lcID="+lcID+"&stateKey="+stateKey;
String response= PimHttpUtil.sendGet(url);
String s=PimsQuery.resultUtil(response);
return JSONObject.parseArray(s,Product.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 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.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
* @param lcID
* @param stateKey
* @return
*/
public List<Team2> getBusinessDetails(String id, String lcID, String stateKey) {
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/details?dbName="+SaAuth.dbName+"&id="+id+"&lcID="+lcID+"&stateKey="+stateKey;
String response= PimHttpUtil.sendGet(url);
String s=PimsQuery.resultUtil(response);
return JSONObject.parseArray(s,Team2.class);
}
/**
* 查询目录下资产列表
* @param id
* @param lcID
* @param stateKey
* @return
*/
public List<CatalogRoot> queryAssetByCatalog(String id, String catalogID,String lcID, String stateKey) {
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/business/details?dbName="+SaAuth.dbName+"&id="+id+"&catalogID="+catalogID+"&lcID="+lcID+"&stateKey="+stateKey;
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.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
* @param lcID
* @param stateKey
* @return
*/
public List<Resource> getDocumentContent(String id, String lcID, String stateKey) {
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/document/content?dbName="+SaAuth.dbName+"&id="+id+"&lcID="+lcID+"&stateKey="+stateKey;
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/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;
}
public String uploadBinary(String id, String lcID, String stateKey, File file) {
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/document/upload?dbName="+SaAuth.dbName+"&id="+id+"&lcID="+lcID+"&stateKey="+stateKey;
String response= PimHttpUtil.uploadFile(url,file);
String s=PimsQuery.resultUtil(response);
return s;
}
public static String update="{\n" +
" \"id\": \"Resource-1129783425285226496\",\n" +
" \"lcID\":\"TDLifeCycleDefinition-Common\",\n" +
" \"stateKey\":\"Editing\",\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; package com.tongda.tdpimssdk.api;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.tongda.tdpimssdk.auth.SaAuth; 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.entities.common.CatalogRoot;
import com.tongda.tdpimssdk.http.PimHttpUtil; import com.tongda.tdpimssdk.http.PimHttpUtil;
import com.tongda.tdpimssdk.resultVo.vo.GeneralPagerVo;
import java.util.List; import java.util.List;
public class PimsApi { public class PimsQuery {
/**
* 查询资产模型清单
* @return
*/
public List<CatalogRoot> pimsTemplate(){ public List<CatalogRoot> pimsTemplate(){
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/template?dbName="+SaAuth.dbName; String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/template?dbName="+SaAuth.dbName;
String response=PimHttpUtil.sendGet(url); String response=PimHttpUtil.sendGet(url);
String s=resultUtil(response); String s=resultUtil(response);
JSONObject.parseArray(s,CatalogRoot.class);
return JSONObject.parseArray(s,CatalogRoot.class); 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> getLifeCycleDefinitionList(String templateID, int page, int size){
String url="http://"+ SaAuth.serverId +":"+SaAuth.serverPort+"/pims/asset?dbName="+SaAuth.dbName+"&templateID="+templateID+"&page="+page+templateID+"&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){ public static String resultUtil(String re){
System.out.println(re); System.out.println(re);
......
package com.tongda.tdpimssdk.auth; package com.tongda.tdpimssdk.auth;
import com.tongda.tdpimssdk.api.PimsApi; import com.alibaba.fastjson.JSON;
import com.tongda.tdpimssdk.entities.common.CatalogRoot; import com.alibaba.fastjson.JSONObject;
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 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 lombok.Data; import lombok.Data;
import java.util.List; import java.io.File;
@Data @Data
public class SaAuth { public class SaAuth {
...@@ -26,27 +33,69 @@ public class SaAuth { ...@@ -26,27 +33,69 @@ public class SaAuth {
this.port = port; this.port = port;
} }
public static String loginAndSatoken(){ public static String loginGetSatoken(){
String url="http://"+id+":"+port+"/sso/doLogin"; String url="http://"+id+":"+port+"/sso/doLogin";
satoken=PimHttpUtil.loginGet(url,user,password); satoken=PimHttpUtil.loginGetSatoken(url,user,password);
return satoken; return satoken;
} }
public static void main(String[] args) { public static void main(String[] args) {
SaAuth.serverId="150.158.75.213"; // SaAuth.serverId="150.158.75.213";
SaAuth.serverId="127.0.0.1";
SaAuth.serverPort=8080; SaAuth.serverPort=8080;
SaAuth.dbName="TXPIMDB"; SaAuth.dbName="TXPIMDB";
SaAuth saAuth=new SaAuth("zhengfunan","q1w2e3r4","121.199.160.117",9000); SaAuth saAuth=new SaAuth("guantiantian","q1w2e3r4","121.199.160.117",9000);
String satoken=SaAuth.loginAndSatoken(); String satoken=SaAuth.loginGetSatoken();
PimsApi pimsApi =new PimsApi(); System.out.println(satoken);
List<CatalogRoot> list= pimsApi.pimsTemplate();
System.out.println(list);
// s= pimsApi.pimsTemplate();
// System.out.println(s);
PimsQuery pimsQuery =new PimsQuery();
// //查询5个接口
// System.out.println(pimsQuery.pimsTemplate());
//
// System.out.println(pimsQuery.queryDocumentList());
//
// System.out.println(pimsQuery.getBusinessList(""));
//
// System.out.println(pimsQuery.getLifeCycleDefinitionList("ResourceTemplate-1125740648473821184",1,20));
//
// System.out.println(pimsQuery.queryAssetAppViewPath("Product-1128330059979948032"));
} PimsAsset pimsAsset=new PimsAsset();
// System.out.println(pimsAsset.pimsTemplate(JSONObject.parseObject(PimsAsset.create, AssetVo.class)));
// System.out.println(pimsAsset.getAssetContent("Product-1129500005887901696","TDLifeCycleDefinition-Common","Editing"));
// 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.createDocumentAsset(JSONObject.parseObject(PimsDocument.create, AssetVo.class)));
// System.out.println(pimsDocument.getDocumentContent("Resource-1129786933577252864","TDLifeCycleDefinition-Common","Editing"));
// System.out.println(pimsDocument.getLifeCycleDefinitionList(JSONObject.parseObject(PimsDocument.update, AssetVo.class)));
// 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(pimsBusiness.getBusinessDetails("Team2-1129450504951169024","TDLifeCycleDefinition-Common","Editing"));
// System.out.println(pimsBusiness.deleteTeam("Team2-1129450504951169024"));
// System.out.println(pimsBusiness.queryAssetByCatalog("Team2-1129497138993037312","CatalogAppView-1129455551755845632","TDLifeCycleDefinition-Common","Editing"));
// 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","TDLifeCycleDefinition-Common","Editing",file));
}
} }
...@@ -47,7 +47,8 @@ public class ChangeLog { ...@@ -47,7 +47,8 @@ public class ChangeLog {
protected String userName; protected String userName;
@XmlAttribute(name = "stamp") @XmlAttribute(name = "stamp")
@XmlSchemaType(name = "dateTime") @XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar stamp; protected String stamp;
// protected XMLGregorianCalendar stamp;
@XmlAttribute(name = "type") @XmlAttribute(name = "type")
protected String type; protected String type;
@XmlAttribute(name = "version") @XmlAttribute(name = "version")
......
package com.tongda.tdpimssdk.http;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import java.net.URI;
class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
/**
* 获取方法(必须重载)
*
* @return
*/
@Override
public String getMethod() {
return METHOD_NAME;
}
public HttpDeleteWithBody(final String uri) {
super();
setURI(URI.create(uri));
}
public HttpDeleteWithBody(final URI uri) {
super();
setURI(uri);
}
public HttpDeleteWithBody() {
super();
}
}
package com.tongda.tdpimssdk.http; package com.tongda.tdpimssdk.http;
import com.alibaba.fastjson.JSONObject;
import com.tongda.tdpimssdk.auth.SaAuth; import com.tongda.tdpimssdk.auth.SaAuth;
import org.apache.http.Consts;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HeaderElement; import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.*;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder; import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
public class PimHttpUtil { public class PimHttpUtil {
public static String loginGet(String url ,String user ,String password){ public static String loginGetSatoken(String url ,String user ,String password){
try { try {
//创建httpClient实例 //创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
...@@ -34,8 +42,6 @@ public class PimHttpUtil { ...@@ -34,8 +42,6 @@ public class PimHttpUtil {
//创建httpGet远程连接实例,这里传入目标的网络地址 //创建httpGet远程连接实例,这里传入目标的网络地址
HttpGet httpGet = new HttpGet(uriBuilder.build()); HttpGet httpGet = new HttpGet(uriBuilder.build());
// 设置请求头信息,鉴权(没有可忽略)
// httpGet.setHeader("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
// 设置配置请求参数(没有可忽略) // 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(3000)// 连接主机服务超时时间 RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(3000)// 连接主机服务超时时间
.setConnectionRequestTimeout(10000)// 请求超时时间 .setConnectionRequestTimeout(10000)// 请求超时时间
...@@ -45,6 +51,7 @@ public class PimHttpUtil { ...@@ -45,6 +51,7 @@ public class PimHttpUtil {
httpGet.setConfig(requestConfig); httpGet.setConfig(requestConfig);
//执行请求 //执行请求
CloseableHttpResponse response = client.execute(httpGet); CloseableHttpResponse response = client.execute(httpGet);
Header [] headers=response.getHeaders("Set-Cookie"); Header [] headers=response.getHeaders("Set-Cookie");
String satoken=""; String satoken="";
for (Header header:headers){ for (Header header:headers){
...@@ -55,9 +62,6 @@ public class PimHttpUtil { ...@@ -55,9 +62,6 @@ public class PimHttpUtil {
} }
} }
} }
//获取Response状态码
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(statusCode);
//获取响应实体, 响应内容 //获取响应实体, 响应内容
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
//通过EntityUtils中的toString方法将结果转换为字符串 //通过EntityUtils中的toString方法将结果转换为字符串
...@@ -84,16 +88,9 @@ public class PimHttpUtil { ...@@ -84,16 +88,9 @@ public class PimHttpUtil {
//创建一个uri对象 //创建一个uri对象
URIBuilder uriBuilder = null; URIBuilder uriBuilder = null;
uriBuilder = new URIBuilder(url); uriBuilder = new URIBuilder(url);
//塞入form参数
// uriBuilder.addParameter("name", user);
// uriBuilder.addParameter("pwd", password);
//创建httpGet远程连接实例,这里传入目标的网络地址 //创建httpGet远程连接实例,这里传入目标的网络地址
HttpGet httpGet = new HttpGet(uriBuilder.build()); HttpGet httpGet = new HttpGet(uriBuilder.build());
httpGet.setHeader("Satoken", SaAuth.satoken); httpGet.setHeader("Satoken", SaAuth.satoken);
// 设置请求头信息,鉴权(没有可忽略)
// httpGet.setHeader("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
// 设置配置请求参数(没有可忽略) // 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间 RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(60000)// 请求超时时间 .setConnectionRequestTimeout(60000)// 请求超时时间
...@@ -125,32 +122,160 @@ public class PimHttpUtil { ...@@ -125,32 +122,160 @@ public class PimHttpUtil {
} }
} }
public static String sendPost(String url , HashMap hashMap,String satoken){ public static String sendPost(String url , JSONObject jsonObject){
try { try {
//创建httpClient实例 //创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象 //创建一个uri对象
URIBuilder uriBuilder = null; URIBuilder uriBuilder = null;
uriBuilder = new URIBuilder(url); uriBuilder = new URIBuilder(url);
//塞入form参数
// uriBuilder.addParameter("name", user);
// uriBuilder.addParameter("pwd", password);
//创建httpGet远程连接实例,这里传入目标的网络地址 //创建httpGet远程连接实例,这里传入目标的网络地址
HttpPost httpPost = new HttpPost(uriBuilder.build());
httpPost.setHeader("Satoken", SaAuth.satoken);
// 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(60000)// 请求超时时间
.setSocketTimeout(60000)// 数据读取超时时间
.build();
// 为httpGet实例设置配置
httpPost.setHeader("Content-Type", "application/json");
httpPost.setConfig(requestConfig);
StringEntity entity = new StringEntity(jsonObject.toString(), Consts.UTF_8);
httpPost.setEntity(entity);
//执行请求
CloseableHttpResponse response = client.execute(httpPost);
//获取Response状态码
int statusCode = response.getStatusLine().getStatusCode();
//获取响应实体, 响应内容
HttpEntity responseEntity = response.getEntity();
//通过EntityUtils中的toString方法将结果转换为字符串
String str = EntityUtils.toString(responseEntity);
response.close();
client.close();
HttpGet httpGet = new HttpGet(uriBuilder.build()); return str;
httpGet.setHeader("Satoken",satoken);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
} catch (ClientProtocolException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static String uploadFile(String url , File file){
try {
//创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象
URIBuilder uriBuilder = null;
uriBuilder = new URIBuilder(url);
HttpPost httpPost = new HttpPost(uriBuilder.build());
// 设置请求头信息,鉴权(没有可忽略) // 设置请求头信息,鉴权(没有可忽略)
// httpGet.setHeader("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0"); httpPost.setHeader("Satoken", SaAuth.satoken);
// 设置配置请求参数(没有可忽略) // 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(10000)// 连接主机服务超时时间 RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(10000)// 请求超时时间 .setConnectionRequestTimeout(60000)// 请求超时时间
.setSocketTimeout(60000)// 数据读取超时时间 .setSocketTimeout(60000)// 数据读取超时时间
.build(); .build();
// 为httpGet实例设置配置 // 为实例设置配置
httpGet.setConfig(requestConfig); // httpPost.setHeader("Content-Type", "multipart/form-data");
httpPost.setConfig(requestConfig);
httpPost.setEntity(
MultipartEntityBuilder.create()
.setCharset(StandardCharsets.UTF_8)
.setContentType(ContentType.MULTIPART_FORM_DATA)
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
// .setCharset(Charset.forName("UTF-8"))
// 还有文件的话继续往下添加
.addBinaryBody("file", file)
.build()
);
//执行请求 //执行请求
CloseableHttpResponse response = client.execute(httpGet); CloseableHttpResponse response = client.execute(httpPost);
//获取Response状态码
int statusCode = response.getStatusLine().getStatusCode();
//获取响应实体, 响应内容
HttpEntity responseEntity = response.getEntity();
//通过EntityUtils中的toString方法将结果转换为字符串
String str = EntityUtils.toString(responseEntity);
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 sendPut(String url , JSONObject jsonObject){
try {
//创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象
URIBuilder uriBuilder = null;
uriBuilder = new URIBuilder(url);
//创建远程连接实例,这里传入目标的网络地址
HttpPut httpPut = new HttpPut(uriBuilder.build());
httpPut.setHeader("Satoken", SaAuth.satoken);
// 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(60000)// 请求超时时间
.setSocketTimeout(60000)// 数据读取超时时间
.build();
// 为实例设置配置
httpPut.setHeader("Content-Type", "application/json");
httpPut.setConfig(requestConfig);
StringEntity entity = new StringEntity(jsonObject.toString(), Consts.UTF_8);
httpPut.setEntity(entity);
//执行请求
CloseableHttpResponse response = client.execute(httpPut);
//获取Response状态码
int statusCode = response.getStatusLine().getStatusCode();
//获取响应实体, 响应内容
HttpEntity responseEntity = response.getEntity();
//通过EntityUtils中的toString方法将结果转换为字符串
String str = EntityUtils.toString(responseEntity);
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 sendDelete(String url){
try {
//创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象
URIBuilder uriBuilder = new URIBuilder(url);
//创建远程连接实例,这里传入目标的网络地址
HttpDelete httpDelete = new HttpDelete(uriBuilder.build());
// 设置请求头信息,鉴权(没有可忽略)
httpDelete.setHeader("Satoken", SaAuth.satoken);
// 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(60000)// 请求超时时间
.setSocketTimeout(60000)// 数据读取超时时间
.build();
// 为实例设置配置
httpDelete.setConfig(requestConfig);
//执行请求
CloseableHttpResponse response = client.execute(httpDelete);
//获取Response状态码 //获取Response状态码
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
System.out.println(statusCode); System.out.println(statusCode);
...@@ -162,7 +287,53 @@ public class PimHttpUtil { ...@@ -162,7 +287,53 @@ public class PimHttpUtil {
response.close(); response.close();
client.close(); client.close();
return ""; 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 sendDeleteBody(String url,JSONObject jsonObject){
try {
//创建httpClient实例
CloseableHttpClient client = HttpClients.createDefault();
//创建一个uri对象
URIBuilder uriBuilder = new URIBuilder(url);
//创建远程连接实例,这里传入目标的网络地址
HttpDeleteWithBody httpDelete = new HttpDeleteWithBody(uriBuilder.build());
// 设置请求头信息,鉴权(没有可忽略)
httpDelete.setHeader("Satoken", SaAuth.satoken);
// 设置配置请求参数(没有可忽略)
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000)// 连接主机服务超时时间
.setConnectionRequestTimeout(60000)// 请求超时时间
.setSocketTimeout(60000)// 数据读取超时时间
.build();
// 为实例设置配置
httpDelete.setConfig(requestConfig);
System.out.println(jsonObject);
StringEntity reEntity = new StringEntity(jsonObject.toString(), Consts.UTF_8);
reEntity.setContentType("application/json");
httpDelete.setEntity(reEntity);
//执行请求
CloseableHttpResponse response = client.execute(httpDelete);
//获取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) { } catch (URISyntaxException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
package com.tongda.tdpimssdk.resultVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 自定义异常
*
* @author xcq
* {@code @date} 2023/03/14
*/
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BusinessException extends RuntimeException{
private Integer code;
private String desc;
/**
* 业务异常构造方法
*
* @param resultVoEnum 返回值枚举
* @param exception 异常
*/
public BusinessException(ResultVoEnum resultVoEnum, Throwable exception) {
super(exception);
this.code = resultVoEnum.getCode();
this.desc = resultVoEnum.getDesc();
}
}
package com.tongda.tdpimssdk.resultVo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Rest返回值对象
*
* @author xcq
* @date 2023/03/15
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVo<T> implements Serializable {
private Integer code;
private String desc;
private T data;
/**
* 从枚举中构造返回值
*
* @param resultVoEnum 返回值枚举
*/
public ResultVo(ResultVoEnum resultVoEnum) {
this.code = resultVoEnum.getCode();
this.desc = resultVoEnum.getDesc();
}
/**
* 成功
*
* @param data 数据
* @return {@link ResultVo}<{@link T}>
*/
public static <T> ResultVo<T> success(T data) {
ResultVo<T> resultVO = new ResultVo<>(ResultVoEnum.SUCCESS);
resultVO.setData(data);
return resultVO;
}
/**
* 错误
*
* @param businessException 业务异常
* @return {@link ResultVo}<{@link String}>
*/
public static ResultVo<String> error(BusinessException businessException) {
return ResultVo.<String>builder()
.code(businessException.getCode())
.desc(businessException.getDesc())
.data(businessException.getMessage())
.build();
}
/**
* 错误
*
* @param exception 系统异常
* @return {@link ResultVo}<{@link String}>
*/
public static ResultVo<String> error(Exception exception) {
ResultVo<String> resultVO = new ResultVo<>(ResultVoEnum.INTERNAL_SERVER_EXCEPTION);
resultVO.setData(exception.getMessage());
return resultVO;
}
}
package com.tongda.tdpimssdk.resultVo;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 返回值枚举
*
* @author xcq
* @date 2023/03/15
*/
@Getter
@AllArgsConstructor
public enum ResultVoEnum {
SUCCESS(200, "success"),
INTERNAL_SERVER_EXCEPTION(-1, "exception"),
FAIL(1, "fail"),
JSON_MAPPING_ERROR(2, "JsonProcessingException"),
// 2000-2999 代表客户异常
ACCOUNT_ERROR(2000, "检测到您尚未登录,请先登录!"),
PARAM_ERROR(2001, "请求参数不合法!"),
PARAM_PARSE_ERROR(2002, "请求参数解析失败"),
// 3000-3999 代表服务异常
XML_PARSE_ERROR(3000, "数据解析异常"),
XQUERY_FILE_ANALYZE_ERROR(3001, "xquery文件解析出错"),
JAXB_ANALYZE_ERROR(3002, "XML解析出错"),
// 4000-4999 代表xquery请求异常
XQUERY_IOEXCEPTION_ERROR(4000, "IoException"),
XQUERY_EXECUTE_ERROR(4001, "请求出错,请检查!");
private final Integer code;
private final String desc;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Tittle: AssetVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/25 19:10
*/
@Data
public class AssetVo {
// 模型ID
private String templateID;
// 资产ID
private String id;
// 模型名称
private String label;
private String userID;
private String userName;
private List<AssetField> fields;
/**
* '[
* {"key": "tdpim.asset.mainframe.cpu.count", "type":"SingleValue", "value":"6"},
* {"key": "tdpim.asset.mainframe.cpu.temp", "type":"Range", "valueMin":"1", "valueMax":"5"},
* {"key": "tdpim.asset.mainframe.area", "type":"MultiSelect", "selectedIDs":["CandidateValue-1110951999471353858","CandidateValue-1110951999471353859"]}
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class AssetField {
// 单值/单选
private String key;
private String mode; //元数据模式
private String value;
// 范围
// private String key;
// private String type;
private String valueMin;
private String valueMax;
// 多选
// private String key;
// private String type;
private List<String> selectedIDs;
}
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: CatalogItem
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/8 10:44
*/
@Data
public class CatalogItem {
// * declare variable $dbName external := 'TXPIMDB';
// * declare variable $parentCatalogID external := 'Catalog-1092230561717551104';
// * declare variable $label external := '未归类产品';
// * declare variable $type external := 'ProductRef'; (: Catalog | ProductSeriesRef | ProductRef:)
// * declare variable $idRef external := 'Product-1092049602028240896';
// 目录父节点ID
private String parentCatalogID;
// 目录ID
private String catalogID;
// 目录名称
private String label;
private String type;
private String templateID;
// 业务ID
private String id;
private String assetID;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Tittle: DataGroupVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/16 14:32
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DataGroupVo {
private String groupId; // 元数据组ID
private String id; //可为空
private String key; //不可为空
private String label; //不可为空
private String modeId; //不可为空
private String dataTypeId; //不可为空
protected String status;
private String uomId; //可为空
private String regPatternId; //可为空
private String desc; //可为空
private String value; //可为空
private List<Option> options;
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class Option {
private String key; //不可为空
private String id;
private String label;
private String value;
}
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: DocumentFieldVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/7 16:48
*/
@Data
public class DocumentFieldVo {
@NotBlank(message = "id不能为空")
private String docID;
@NotBlank(message = "名称不能为空")
private String label;
private String desc;
private String rollBackFrom;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import java.util.List;
/**
* @Tittle: GeneralPagerVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/26 16:33
*/
@Data
public class GeneralPagerVo<T> {
private String total;
private List<T> data;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: LifeCycleVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/20 14:09
*/
@Data
public class LifeCycleVo {
private String lcID;
private String templateID;
private String status;
private String label;
private String lifeCycleXml;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: GeneralPagerVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/26 16:33
*/
@Data
public class LifecycleGraphJsonVo<T> {
private T graphJson;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* @Tittle: Templete
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/6 17:56
*/
@Data
public class MetadataEntityVo {
@NotBlank(message = "元数据组id不能为空")
private String metadataGroupID;
@NotBlank(message = "尚未选中元数据,请先选择后添加")
private List<String> metadata;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MetadataGroupDicVo {
private String dictEntryKey;
private String dictEntryLabel;
private String dictEntryValue;
private String dataType; //正则表达式字典表
private String uomCatalogKey; //计量单位字典表
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: Templete
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/6 17:56
*/
@Data
public class MetadataGroupVo {
@NotBlank(message = "模板id不能为空")
private String documentID;
@NotBlank(message = "元数据分类组key不能为空")
private String key;
}
package com.tongda.tdpimssdk.resultVo.vo;
import com.tongda.tdpimssdk.entities.common.CandidateValue;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @Tittle: MetadataOption
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/4 17:01
*/
@Data
public class MetadataOption extends CandidateValue {
@NotNull(message = "缺少元数据编码字段")
@NotEmpty(message = "元数据编码不能为空")
private String mdeFullKey;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: ProductVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/8 18:47
*/
@Data
public class ProductVo {
@NotBlank(message = "产品系、产品或资源名不能为空")
private String label;
@NotBlank(message = "产品系、产品或资源模板不能为空")
private String templateID;
// 资源链接id
private String resRefID;
private String productSeriesID;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: RegularDicVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/12 13:59
*/
@Data
public class RegularDicVo {
// * declare variable $dataType external := ''; (:数据类型key:)
// * declare variable $dictEntryKey external := ''; (:正则编码:)
// * declare variable $dictEntryLabel external := ''; (:正则名称:)
// * declare variable $dictEntryValue external := ''; (:正则值:)
private String dataType;
private String dictEntryKey;
private String dictEntryLabel;
private String dictEntryValue;
private String isSelected; // "true" "false"
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: ResourceListVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/7 17:47
*/
@Data
public class ResourceListVo {
@NotBlank(message = "资源id不能为空")
private String docID;
/**
* 从下拉框选择,数据源自资源分类字典表
*/
@NotBlank(message = "资源类型编码不能为空")
private String key;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: ResourceVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/7 17:51
*/
@Data
public class ResourceVo {
/**
* 资源分类id
*/
@NotBlank(message = "资源分类id不能为空")
private String resListID;
/**
* 资源模板id
*/
private String resTplID;
/**
* 资源id
*/
private String resID;
/**
* 资源名称
*/
@NotBlank(message = "资源名称不能为空")
private String newLabel;
}
package com.tongda.tdpimssdk.resultVo.vo;
import com.tongda.tdpimssdk.entities.common.TDEvent;
import lombok.Data;
/**
* @Tittle: StateMachineVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/6/6 11:13
*/
@Data
public class StateMachineVo {
private String lcID; // 生命周期ID
private String sourceStateID; // 源状态ID
private String entityId; // 资产ID、模型ID、文档ID、业务ID
private TDEvent tdEvent;
}
package com.tongda.tdpimssdk.resultVo.vo;
import com.tongda.tdpimssdk.entities.common.PermDef;
import lombok.Data;
/**
* @Tittle: TeamVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/23 19:07
*/
@Data
public class TeamVo {
private String teamID;
private String teamRoleID;
private String teamRoleLabel;
private String label;
private String desc;
private PermDef permDef;
private String endUserID;
private String productID;
private String productRefID;
// * declare variable $teamAdminID external := 'admin';
// * declare variable $teamAdminName external := '系统管理员';
private String userId;
private String userName;
private String lifecycleID;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: Templete
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/6 17:56
*/
@Data
public class TemplateInfoVo {
private String groupId;
private String key;
private String id;
private String label;
private String icon;
private String userID;
private String userName;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: TemplateMetadataList
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/5/18 10:55
*/
@Data
public class TemplateMetadataList {
@NotBlank(message = "模型id不能为空")
private String id;
@NotBlank(message = "文档或元数据模型ID列表不能为空")
private String batchID;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Tittle: Templete
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/6 17:56
*/
@Data
public class TempleteVo {
@NotBlank(message = "模板类型不能为空")
private String templateType;
@NotBlank(message = "模板名称不能为空")
private String label;
private String userID;
private String userName;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: TimeSeriesVariableVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/20 16:48
*/
@Data
public class TimeSeriesVariableVo {
private String key; // 时序变量编码
private String label; // 时序变量名称
private String parentID; // 产品系或产品ID
private String dataType; // 数据类型ID
private String uom; // 数据单位ID
private String keepInSeconds; // 数据保留时间
private String id;
private String value;
}
package com.tongda.tdpimssdk.resultVo.vo;
import lombok.Data;
/**
* @Tittle: UomDicVo
* @description:
* @Package: com.tongda.pimdemo.http.resultVo.vo
* @Date 2023/4/12 15:26
*/
@Data
public class UomDicVo {
// (:计量单位组:)
//declare variable $uomCatalogKey external := '';
//(:计量单位组名称:)
//declare variable $uomCatalogLabel external := '';
// params.put("uomCatalogKey", uomDicVo.getUomCatalogKey());
// params.put("dictEntryKey", uomDicVo.getUomCatalogKey());
// params.put("dictEntryLabel", uomDicVo.getUomCatalogLabel());
/**
* 计量单位组key
*/
private String uomCatalogKey;
/**
* 计量单位组label
*/
private String uomCatalogLabel;
/**
* 计量单位key
*/
private String dictEntryKey;
/**
* 计量单位label
*/
private String dictEntryLabel;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment