替换okHttp

master
anthonyywj2 3 years ago
parent 387fcca543
commit 752dc93d98

@ -83,6 +83,8 @@ public class UdiRelevanceController {
CustomerService customerService;
@Resource
RedisUtil redisUtil;
@Resource
HttpOkClient httpOkClient;
@AuthRuleAnnotation("")
@GetMapping("/udi/udirel/download")
@ -414,7 +416,7 @@ public class UdiRelevanceController {
postSmpUdiInfoRequest.setErpName(item.getThirdName());
return postSmpUdiInfoRequest;
}).collect(Collectors.toList());
String response = HttpClient.uCloudPost(postUrl, postDatas);
String response = httpOkClient.uCloudPost(postUrl, postDatas);
BaseResponse baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});

@ -36,6 +36,8 @@ public class InvErpOnhandController {
BasicThirdSysDetailService basicThirdSysDetailService;
@Resource
private ThrInvProductsService thrInvProductsService;
@Resource
ErpInvClient erpInvClient;
@GetMapping("/udiwms/inv/getOnHand")
public BaseResponse getOnhand(ErpOnhandRequest onhandQueryRequest,
@ -73,7 +75,7 @@ public class InvErpOnhandController {
}
if (basicThirdSysDetailEntity.getFromType() == 0 || (onhandQueryRequest.getIsDownThrSys() != null && onhandQueryRequest.getIsDownThrSys())) {
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = new ErpInvClient().getInvPrdoductResponse(onhandQueryRequest, onHandUrl);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = erpInvClient.getInvPrdoductResponse(onhandQueryRequest, onHandUrl);
return responseBaseResponse;
} else {
FilterThrInvProductsRequest filterThrInvProductsRequest = new FilterThrInvProductsRequest();

@ -46,6 +46,9 @@ public class InvPrintController {
@Resource
InCodeLogService inCodeLogService;
@Resource
ErpInvClient erpInvClient;
@PostMapping("/udiwarehouse/stockPrint/filter")
public BaseResponse filterAll(@RequestBody FilterStockprintRequest stockprintRequest,
BindingResult bindingResult) {
@ -127,7 +130,7 @@ public class InvPrintController {
for (StockPrintEntity stockPrintEntity : stockPrintEntities) {
ErpOnhandRequest erpOnhandRequest = new ErpOnhandRequest();
erpOnhandRequest.setInventoryCode(stockPrintEntity.getThirdId());
List<ErpInvProductResponse> erpOnHandResponses = new ErpInvClient().getInvPrdoduct(erpOnhandRequest, onHandUrl);
List<ErpInvProductResponse> erpOnHandResponses =erpInvClient.getInvPrdoduct(erpOnhandRequest, onHandUrl);
if (erpOnHandResponses != null && erpOnHandResponses.size() > 0) {
for (ErpInvProductResponse onhandQueryResponse : erpOnHandResponses) {
if (onhandQueryResponse.getBatchNo().equals(stockPrintEntity.getBatchNo()) && onhandQueryResponse.getWarehouseCode().equals(stockPrintEntity.getWarehouseCode())) {

@ -48,6 +48,8 @@ public class ThrInvProductsExportLogController {
BasicThirdSysDetailService basicThirdSysDetailService;
@Resource
private ThrInvProductsService thrInvProductsService;
@Resource
ErpInvClient erpInvClient;
@GetMapping("/udiwms/invProducts/exportLog/filter")
public BaseResponse filter(FilterUdiEpLogRequest filterUdiEpLogReques,
@ -157,9 +159,9 @@ public class ThrInvProductsExportLogController {
if (!basicThirdSysDetailEntity.getEnabled()) {
return ResultVOUtils.error(500, "第三方系统库存信息接口服务未启用!");
}
if (basicThirdSysDetailEntity.getFromType() == 0 ) {
if (basicThirdSysDetailEntity.getFromType() == 0) {
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = new ErpInvClient().getInvPrdoductResponse(onhandQueryRequest, onHandUrl);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = erpInvClient.getInvPrdoductResponse(onhandQueryRequest, onHandUrl);
return responseBaseResponse;
} else {
FilterThrInvProductsRequest filterThrInvProductsRequest = new FilterThrInvProductsRequest();

@ -24,6 +24,7 @@ import com.glxp.api.admin.thread.ThrOrderImportService;
import com.glxp.api.admin.thread.ThrOrdersDlService;
import com.glxp.api.admin.util.CustomUtil;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.admin.util.RedisUtil;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
@ -55,7 +56,8 @@ public class ThrOrderController {
private SystemParamConfigService systemParamConfigService;
@Resource
ThrOrderImportService thrOrderImportService;
@Resource
HttpOkClient httpOkClient;
@Resource
private OrderDetailService myErpOrderService;
@ -262,7 +264,7 @@ public class ThrOrderController {
if (filterThrProductsRequest.getErpOrderResponses() != null) {//选中导出
thrOrdersDlService.importSelectOrders(genKey, filterThrProductsRequest.getErpOrderResponses(), filterThrProductsRequest.getThirdSysFk());
} else { //结果导出
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(),null);
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(), null);
}
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
@ -288,10 +290,10 @@ public class ThrOrderController {
thrOrderImportLogEntity.setUpdateTime(new Date());
thrOrderImportLogEntity.setThirdSysFk(filterThrProductsRequest.getThirdSysFk());
thrOrderImportLogService.insertImportLog(thrOrderImportLogEntity);
if (filterThrProductsRequest.getErpOrderResponses() != null && filterThrProductsRequest.getErpOrderResponses().size()>0) {//选中导出
if (filterThrProductsRequest.getErpOrderResponses() != null && filterThrProductsRequest.getErpOrderResponses().size() > 0) {//选中导出
thrOrdersDlService.importSelectOrders(genKey, filterThrProductsRequest.getErpOrderResponses(), filterThrProductsRequest.getThirdSysFk());
} else { //结果导出
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(),filterThrProductsRequest);
thrOrdersDlService.importOrders(genKey, filterThrProductsRequest.getBillAction(), filterThrProductsRequest);
}
return ResultVOUtils.success("后台开始下载更新,请稍后刷新查看");
}
@ -331,7 +333,7 @@ public class ThrOrderController {
}
uploadSmpRequest.setSubErpOrders(subErpOrders);
String response = HttpClient.uCloudPost(postUrl, uploadSmpRequest);
String response = httpOkClient.uCloudPost(postUrl, uploadSmpRequest);
BaseResponse baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});

@ -18,6 +18,7 @@ import com.glxp.api.admin.res.erp.UdiwmsWarehouseDetail;
import com.glxp.api.admin.res.erp.UdiwmsWarehouseResponse;
import com.glxp.api.admin.service.basic.BasicThirdSysService;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
@ -33,7 +34,8 @@ import java.util.List;
@Slf4j
@Service
public class ErpBasicClient {
@Resource
HttpOkClient httpOkClient;
@Resource
private BasicThirdSysService basicThirdSysService;
@ -47,7 +49,7 @@ public class ErpBasicClient {
try {
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getUnits";
String response = HttpClient.uCloudPost(url, udiwmsUnitRequest, basicThirdSysEntity);
String response = httpOkClient.uCloudPost(url, udiwmsUnitRequest, basicThirdSysEntity);
BaseResponse<PageSimpleResponse<ErpUnitsResponse>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpUnitsResponse>>>() {
});
@ -65,7 +67,7 @@ public class ErpBasicClient {
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getProducts";
try {
String response = HttpClient.uCloudPost(url, filterErpGoodsRequest, basicThirdSysEntity);
String response = httpOkClient.uCloudPost(url, filterErpGoodsRequest, basicThirdSysEntity);
BaseResponse<PageSimpleResponse<ErpProductsResponse>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpProductsResponse>>>() {
});
@ -85,7 +87,7 @@ public class ErpBasicClient {
udiwmsBusTypeRequest.setPage(filterBasicThirdSysDetailRequest.getPage());
udiwmsBusTypeRequest.setLimit(filterBasicThirdSysDetailRequest.getLimit());
try {
String response = HttpClient.uCloudPost(url, udiwmsBusTypeRequest, basicThirdSysEntity);
String response = httpOkClient.uCloudPost(url, udiwmsBusTypeRequest, basicThirdSysEntity);
log.info(response);
BaseResponse<PageSimpleResponse<BasicThirdSysBusApiEntity>> udiDlDeviceResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<BasicThirdSysBusApiEntity>>>() {
@ -102,7 +104,7 @@ public class ErpBasicClient {
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(udiwmsWarehouseRequest.getThirdSys());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getWarehouse";
try {
String response = HttpClient.uCloudPost(url, udiwmsWarehouseRequest);
String response = httpOkClient.uCloudPost(url, udiwmsWarehouseRequest);
BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>> listBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>>>() {
});
@ -116,7 +118,7 @@ public class ErpBasicClient {
//测试连通性
public BaseResponse testConnection(BasicThirdSysEntity basicThirdSysEntity) {
String response = HttpClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/testConnection", "{}");
String response = httpOkClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/testConnection", "{}");
log.info(response);
try {
return JSONObject.parseObject(response, BaseResponse.class);
@ -128,7 +130,7 @@ public class ErpBasicClient {
//测试连通性
public BaseResponse testThridConnect(BasicThirdSysEntity basicThirdSysEntity) {
String response = HttpClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/testThirdSys", "{}");
String response = httpOkClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/testThirdSys", "{}");
log.info(response);
try {
return JSONObject.parseObject(response, BaseResponse.class);

@ -7,14 +7,20 @@ import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.inventory.ErpInvProductResponse;
import com.glxp.api.admin.res.inventory.ErpOnHandResponse;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.common.res.BaseResponse;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ErpInvClient {
@Resource
HttpOkClient httpOkClient;
public List<ErpOnHandResponse> getOnHand(ErpOnhandRequest onhandRequest, String url) {
@ -37,7 +43,7 @@ public class ErpInvClient {
if (onhandRequest.getLimit() != null)
paramMap.put("limit", onhandRequest.getLimit());
// String response = HttpClient.mipsGet(url, paramMap);
String response = HttpClient.uCloudPost(url, onhandRequest);
String response = httpOkClient.uCloudPost(url, onhandRequest);
try {
BaseResponse<PageSimpleResponse<ErpOnHandResponse>> onHandsResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpOnHandResponse>>>() {
@ -74,7 +80,7 @@ public class ErpInvClient {
if (onhandRequest.getLimit() != null)
paramMap.put("limit", onhandRequest.getLimit());
// String response = HttpClient.mipsGet(url, paramMap);
String response = HttpClient.uCloudPost(url, onhandRequest);
String response = httpOkClient.uCloudPost(url, onhandRequest);
try {
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> onHandsResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpInvProductResponse>>>() {

@ -13,11 +13,13 @@ import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.inout.ErpOrderResponse;
import com.glxp.api.admin.service.basic.BasicThirdSysService;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.common.res.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -32,6 +34,8 @@ public class ErpOrderClient {
@Autowired
private BasicThirdSysService basicThirdSysService;
@Resource
HttpOkClient httpOkClient;
public List<ErpOrderEntity> getErpOrder(String url, List<String> billCodes, String action) {
List<ErpOrderEntity> erpOrderEntities = new ArrayList<>();
@ -51,7 +55,7 @@ public class ErpOrderClient {
//查询第三方服务授权参数
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(filterOrderRequest.getThirdOrderFk());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/getUnits";
String response = HttpClient.uCloudPost(url, filterOrderRequest, basicThirdSysEntity);
String response = httpOkClient.uCloudPost(url, filterOrderRequest, basicThirdSysEntity);
try {
BaseResponse<PageSimpleResponse<ErpOrderResponse>> responseBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpOrderResponse>>>() {
@ -102,7 +106,7 @@ public class ErpOrderClient {
public BaseResponse submitOrder(UdiwmsOrderRequest udiwmsOrderRequest) {
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(udiwmsOrderRequest.getThirdSys());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders";
String response = HttpClient.uCloudPost(url, udiwmsOrderRequest);
String response = httpOkClient.uCloudPost(url, udiwmsOrderRequest);
try {
BaseResponse<PageSimpleResponse<ErpOrderResponse>> responseBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpOrderResponse>>>() {
@ -122,14 +126,14 @@ public class ErpOrderClient {
//查询第三方服务授权参数
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(thirdSysFk);
String response = HttpClient.uCloudPost(uploadUrl, erpPostBillRequest, basicThirdSysEntity);
String response = httpOkClient.uCloudPost(uploadUrl, erpPostBillRequest, basicThirdSysEntity);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
return baseResponse;
}
public BaseResponse postBill(ERPPostBillRequest erpPostBillRequest, String uploadUrl) {
String response = HttpClient.uCloudPost(uploadUrl, erpPostBillRequest);
String response = httpOkClient.uCloudPost(uploadUrl, erpPostBillRequest);
BaseResponse baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
@ -137,7 +141,7 @@ public class ErpOrderClient {
}
public BaseResponse signBill(USignRequest signRequest, String url) {
String response = HttpClient.uCloudPost(url, signRequest);
String response = httpOkClient.uCloudPost(url, signRequest);
BaseResponse baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});

@ -31,9 +31,6 @@ import java.util.Map;
@Service
public class SpGetHttpClient {
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
private OkHttpCli okHttpCli;
@ -47,9 +44,9 @@ public class SpGetHttpClient {
public BaseResponse<PageSimpleResponse<IOOrderStatusEntity>> getOrderStatus() {
Map<String, Object> paramMap = new HashMap<>(16);
paramMap.put("status", 1);
String response = UHttpClient.mipsGet(getIpUrl() + "/spms/inout/order/status", paramMap);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("status", 1 + "");
String response = okHttpCli.doGet(getIpUrl() + "/spms/inout/order/status", paramMap);
try {
BaseResponse<PageSimpleResponse<IOOrderStatusEntity>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<IOOrderStatusEntity>>>() {
@ -64,9 +61,9 @@ public class SpGetHttpClient {
public BaseResponse<List<DlOrderResponse>> getOrders(String orderId) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("orderId", orderId);
String response = UHttpClient.mipsGet(getIpUrl() + "/spms/inout/order/dlByStatus", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/spms/inout/order/dlByStatus", paramMap);
try {
BaseResponse<List<DlOrderResponse>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<DlOrderResponse>>>() {
@ -83,7 +80,8 @@ public class SpGetHttpClient {
OrderStatusFilterRequest orderStatusFilterRequest = new OrderStatusFilterRequest();
orderStatusFilterRequest.setOrderId(orderId);
orderStatusFilterRequest.setStatus(2);
String result = UHttpClient.postJson(getIpUrl() + "/spms/inout/order/updateStatus", orderStatusFilterRequest);
String json = JSONUtil.toJsonStr(orderStatusFilterRequest);
String result = okHttpCli.doPostJson(getIpUrl() + "/spms/inout/order/updateStatus", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -92,9 +90,9 @@ public class SpGetHttpClient {
public BaseResponse<List<BasicExportStatusEntity>> getBasicStatus(String type) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("type", type);
String response = UHttpClient.mipsGet(getIpUrl() + "/spssync/basic/udiinfo/getStatus", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/spssync/basic/udiinfo/getStatus", paramMap);
try {
BaseResponse<List<BasicExportStatusEntity>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<BasicExportStatusEntity>>>() {
@ -108,8 +106,7 @@ public class SpGetHttpClient {
}
public BaseResponse<String> testConnect() {
Map<String, Object> paramMap = new HashMap<>(16);
String response = UHttpClient.mipsGet(getIpUrl() + "/sps/sync/connect/test", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/sps/sync/connect/test");
try {
BaseResponse<String> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<String>>() {
@ -123,7 +120,7 @@ public class SpGetHttpClient {
}
public BaseResponse<List<BasicExportStatusEntity>> getBasicStatus(BasicExportStatusRequest basicExportStatusRequest) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
if (basicExportStatusRequest.getType() != null)
paramMap.put("type", basicExportStatusRequest.getType() + "");
if (basicExportStatusRequest.getStatus() != null)
@ -131,8 +128,8 @@ public class SpGetHttpClient {
if (basicExportStatusRequest.getId() != null)
paramMap.put("id", basicExportStatusRequest.getId());
if (basicExportStatusRequest.getScheduleType() != null)
paramMap.put("scheduleType", basicExportStatusRequest.getScheduleType());
String response = UHttpClient.mipsGet(getIpUrl() + "/spssync/basic/udiinfo/getStatus", paramMap);
paramMap.put("scheduleType", basicExportStatusRequest.getScheduleType() + "");
String response = okHttpCli.doGet(getIpUrl() + "/spssync/basic/udiinfo/getStatus", paramMap);
try {
BaseResponse<List<BasicExportStatusEntity>> data =
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<BasicExportStatusEntity>>>() {
@ -160,7 +157,8 @@ public class SpGetHttpClient {
public BaseResponse<String> postBasicStatus(String id) {
BasicExportStatusRequest basicStatusFilterRequest = new BasicExportStatusRequest();
basicStatusFilterRequest.setId(id);
String result = UHttpClient.postJson(getIpUrl() + "/spssync/basic/udiinfo/deleteByStatus", basicStatusFilterRequest);
String json = JSONUtil.toJsonStr(basicStatusFilterRequest);
String result = okHttpCli.doPostJson(getIpUrl() + "/spssync/basic/udiinfo/deleteByStatus", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -169,7 +167,8 @@ public class SpGetHttpClient {
public BaseResponse<String> postAllBaseData(SpsSyncDataResponse syncDataResponse) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/sync/basic/upload", syncDataResponse);
String json = JSONUtil.toJsonStr(syncDataResponse);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/basic/upload", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -178,7 +177,8 @@ public class SpGetHttpClient {
public BaseResponse<String> postAllBus(SpsSyncBusResponse spsSyncBusResponse) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/sync/busType/upload", spsSyncBusResponse);
String json = JSONUtil.toJsonStr(spsSyncBusResponse);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/busType/upload", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -187,7 +187,8 @@ public class SpGetHttpClient {
public BaseResponse<String> postAllOrder(SpsSyncOrderResponse spsSyncOrderResponse) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/sync/order/upload", spsSyncOrderResponse);
String json = JSONUtil.toJsonStr(spsSyncOrderResponse);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/order/upload", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -195,7 +196,8 @@ public class SpGetHttpClient {
}
public BaseResponse<String> postAllSchedule(SpsSyncScheduleResponse spsSyncScheduleResponse) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/sync/schedule/upload", spsSyncScheduleResponse);
String json = JSONUtil.toJsonStr(spsSyncScheduleResponse);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/sync/schedule/upload", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});

@ -1,11 +1,13 @@
package com.glxp.api.admin.httpclient;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.admin.entity.info.SyncDataSetEntity;
import com.glxp.api.admin.req.inout.OrderFilterRequest;
import com.glxp.api.admin.req.inout.PostOrderRequest;
import com.glxp.api.admin.service.info.SyncDataSetService;
import com.glxp.api.admin.util.OkHttpCli;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.beans.factory.annotation.Value;
@ -17,10 +19,11 @@ import java.util.Map;
@Service
public class SpsDirectClient {
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
private OkHttpCli okHttpCli;
@Resource
SyncDataSetService syncDataSetService;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
return syncDataSetEntity.getSyncIp();
@ -28,7 +31,8 @@ public class SpsDirectClient {
//单据验收
public BaseResponse reviewOrder(OrderFilterRequest orderFilterRequest) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/review/download/order/finsih", orderFilterRequest);
String json = JSONUtil.toJsonStr(orderFilterRequest);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/review/download/order/finsih", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});
@ -38,11 +42,11 @@ public class SpsDirectClient {
//获取未验收的单据
public BaseResponse downloadOrder(String orderId, String wmsUserId, String action) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("wmsUserId", wmsUserId);
paramMap.put("orderId", orderId);
paramMap.put("action", action);
String response = UHttpClient.mipsGet(getIpUrl() + "/sps/review/download/order", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/order", paramMap);
try {
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
@ -55,10 +59,10 @@ public class SpsDirectClient {
//获取未验收的单据详情
public BaseResponse downloadOrderDetail(String orderId, String wmsUserId) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("wmsUserId", wmsUserId);
paramMap.put("orderId", orderId);
String response = UHttpClient.mipsGet(getIpUrl() + "/sps/review/download/orderDetail", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/orderDetail", paramMap);
try {
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
@ -72,10 +76,10 @@ public class SpsDirectClient {
//获取未验收的单据条码
public BaseResponse downloadCodes(String wmsUserId, String orderId) {
Map<String, Object> paramMap = new HashMap<>(16);
Map<String, String> paramMap = new HashMap<>(16);
paramMap.put("wmsUserId", wmsUserId);
paramMap.put("orderId", orderId);
String response = UHttpClient.mipsGet(getIpUrl() + "/sps/review/download/codes", paramMap);
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/codes", paramMap);
try {
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
@ -89,7 +93,8 @@ public class SpsDirectClient {
//单据上传
public BaseResponse uploadPdaOrder(PostOrderRequest postOrderRequest) {
String result = UHttpClient.postJson(getIpUrl() + "/sps/pda/upload/orders", postOrderRequest);
String json = JSONUtil.toJsonStr(postOrderRequest);
String result = okHttpCli.doPostJson(getIpUrl() + "/sps/pda/upload/orders", json);
BaseResponse<String> response =
JSONObject.parseObject(result, new TypeReference<BaseResponse<String>>() {
});

@ -42,6 +42,7 @@ import com.glxp.api.admin.service.inventory.InvWarehouseService;
import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.admin.util.DateUtil;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
@ -56,7 +57,8 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class StockOrderServiceImpl implements StockOrderService {
@Resource
HttpOkClient httpOkClient;
@Resource
StockOrderDao stockOrderDao;
@Resource
@ -302,7 +304,7 @@ public class StockOrderServiceImpl implements StockOrderService {
uploadLog.setBillNo(udiwmsOrderRequest.getBillNo());
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysDao.selectByThirdId(thirdSysBusApiEntity.getThirdSys());
String response = HttpClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders", udiwmsOrderRequest);
String response = httpOkClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders", udiwmsOrderRequest);
if (StrUtil.isNotBlank(response)) {
try {

@ -19,6 +19,7 @@ import com.glxp.api.admin.service.info.SyncDataSetService;
import com.glxp.api.admin.service.info.SystemParamConfigService;
import com.glxp.api.admin.util.ExcelUtil;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.beans.BeanUtils;
@ -35,10 +36,10 @@ import java.util.List;
@Service
public class BasicGenExcelService {
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
SyncDataSetService syncDataSetService;
@Resource
HttpOkClient httpOkClient;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
@ -164,7 +165,7 @@ public class BasicGenExcelService {
//todo 上传SMP
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("smp_service_ip");
// if (systemParamConfigEntity != null) {
String response = HttpClient.uCloudPost(getIpUrl() + "/udiwms/basic/corps/upload", postCorpsRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/udiwms/basic/corps/upload", postCorpsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
@ -186,7 +187,7 @@ public class BasicGenExcelService {
public void uploadCorpSmpJson(String genKey, BasicUnitMaintainExportResponse exportData) {
CorpExportLogEntity corpExportLogEntity = corpExportLogService.selectByGenKey(genKey);
String response = HttpClient.uCloudPost(getIpUrl() + "/spssync/basic/corp/upload", exportData);
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/basic/corp/upload", exportData);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
@ -255,7 +256,7 @@ public class BasicGenExcelService {
public void uploadProductsSmpJson(String genKey, UdiRelevanceExportJsonResponse exportData) {
UdiInfoExportLogEntity udiInfoExportLogEntity = udiInfoExportLogService.selectByGenKey(genKey);
// String response = HttpClient.uCloudPost(spsSyncUrl + "/udiwms/basic/products/upload", exportData);
String response = HttpClient.uCloudPost(getIpUrl() + "/spssync/basic/udiinfo/upload", exportData);
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/basic/udiinfo/upload", exportData);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
@ -294,7 +295,7 @@ public class BasicGenExcelService {
//todo 上传SMP
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("smp_service_ip");
// if (systemParamConfigEntity != null) {
String response = HttpClient.uCloudPost(getIpUrl() + "/udiwms/basic/products/upload", postUdiInfoRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/udiwms/basic/products/upload", postUdiInfoRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {

@ -54,6 +54,8 @@ public class BasicUpdateProductService {
BasicThirdSysService basicThirdSysService;
@Resource
GennerOrderUtils gennerOrderUtils;
@Resource
ErpInvClient erpInvClient;
public String addLocalProduct(CombineRequest combineRequest) {
String errMsg = null;
@ -81,7 +83,7 @@ public class BasicUpdateProductService {
ErpOnhandRequest erpOnhandRequest = new ErpOnhandRequest();
erpOnhandRequest.setInventoryCodes(inventoryCodes);
erpOnhandRequest.setFilterCount(2);
List<ErpInvProductResponse> erpOnHandResponses = new ErpInvClient().getInvPrdoduct(erpOnhandRequest, inQuery.getValue());
List<ErpInvProductResponse> erpOnHandResponses =erpInvClient.getInvPrdoduct(erpOnhandRequest, inQuery.getValue());
if (erpOnHandResponses != null && erpOnHandResponses.size() > 0) {
ErpInvProductResponse erpInvProductResponse = erpOnHandResponses.get(0);
Map<String, ErpProductsResponse> erpProductsMap = new HashMap<>();

@ -68,6 +68,8 @@ public class InvImportStockService {
@Resource
BasicThirdSysDetailService basicThirdSysDetailService;
final Logger logger = LoggerFactory.getLogger(InvImportStockService.class);
@Resource
ErpInvClient erpInvClient;
//产品信息生成全部
@Async
@ -157,14 +159,14 @@ public class InvImportStockService {
//根据第三方产品ID生成
@Async
public void updateByCode(String code, String url,String thirdSysFk) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(code,thirdSysFk);
public void updateByCode(String code, String url, String thirdSysFk) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(code, thirdSysFk);
UdiRelevanceResponse udiRelevanceResponse = new UdiRelevanceResponse();
BeanUtils.copyProperties(udiRelevanceEntity, udiRelevanceResponse);
List<StockPrintEntity> stockPrintEntities = new ArrayList<>();
ErpOnhandRequest erpOnhandRequest = new ErpOnhandRequest();
erpOnhandRequest.setInventoryCode(udiRelevanceResponse.getThirdId());
List<ErpInvProductResponse> uOnhandQueryResponses = new ErpInvClient().getInvPrdoduct(erpOnhandRequest, url);
List<ErpInvProductResponse> uOnhandQueryResponses = erpInvClient.getInvPrdoduct(erpOnhandRequest, url);
if (uOnhandQueryResponses != null && uOnhandQueryResponses.size() > 0) {
for (ErpInvProductResponse onhandQueryResponse : uOnhandQueryResponses) {
@ -195,9 +197,9 @@ public class InvImportStockService {
filterThrInvProductsRequest.setThirdSysFk(thirsysFk);
filterThrInvProductsRequest.setInventoryCode(id);
List<ThrInvProductsEntity> thrInvProductsEntities = thrInvProductsService.filterThrInvProductss(filterThrInvProductsRequest);
if(thrInvProductsEntities!=null){
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(id,thirsysFk);
for(ThrInvProductsEntity thrInvProductsEntity:thrInvProductsEntities){
if (thrInvProductsEntities != null) {
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(id, thirsysFk);
for (ThrInvProductsEntity thrInvProductsEntity : thrInvProductsEntities) {
StockPrintEntity stockPrintEntity = new StockPrintEntity();
stockPrintEntity.setNameCode(thrInvProductsEntity.getInventoryCode());
stockPrintEntity.setBatchNo(thrInvProductsEntity.getBatchNo());
@ -268,7 +270,7 @@ public class InvImportStockService {
UdiRelevanceResponse udiRelevanceResponse, String genKey) {
ErpOnhandRequest erpOnhandRequest = new ErpOnhandRequest();
erpOnhandRequest.setInventoryCode(inventoryCode);
List<ErpInvProductResponse> uOnhandQueryResponses = new ErpInvClient().getInvPrdoduct(erpOnhandRequest, url);
List<ErpInvProductResponse> uOnhandQueryResponses = erpInvClient.getInvPrdoduct(erpOnhandRequest, url);
if (uOnhandQueryResponses != null && uOnhandQueryResponses.size() > 0) {
for (ErpInvProductResponse onhandQueryResponse : uOnhandQueryResponses) {
StockPrintEntity stockPrintEntity = new StockPrintEntity();
@ -401,7 +403,7 @@ public class InvImportStockService {
if (udiRelevanceEntities != null && udiRelevanceEntities.size() == 1) {
ErpOnhandRequest erpOnhandRequest = new ErpOnhandRequest();
erpOnhandRequest.setInventoryCode(udiRelevanceEntities.get(0).getThirdId());
List<ErpInvProductResponse> erpOnHandResponses = new ErpInvClient().getInvPrdoduct(erpOnhandRequest, url);
List<ErpInvProductResponse> erpOnHandResponses = erpInvClient.getInvPrdoduct(erpOnhandRequest, url);
if (erpOnHandResponses != null && erpOnHandResponses.size() > 0) {
for (int i = 0; i < erpOnHandResponses.size(); i++) {
if (erpOnHandResponses.get(i).getBatchNo().equals(erpOrderEntity.getBatchNo())

@ -58,6 +58,8 @@ public class ThrCorpsDlService {
ErpBasicClient erpBasicClient;
@Resource
SyncDataSetService syncDataSetService;
@Resource
HttpOkClient httpOkClient;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
@ -460,7 +462,7 @@ public class ThrCorpsDlService {
postThrCorpRequest.setGenKey(genKey);
postThrCorpRequest.setThirdSys(thrCorpExportRequest.getThirdSys());
postThrCorpRequest.setUploadType("接口上传");
String response = HttpClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/corp/upload", postThrCorpRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/corp/upload", postThrCorpRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {

@ -42,7 +42,8 @@ public class ThrInvProductsDlService {
ThrInvProductsExportLogService thrInvProductsExportLogService;
@Resource
ThrInvProductsDetailService thrInvProductsDetailService;
@Resource
ErpInvClient erpInvClient;
@Async
public void importSelcyInvProducrs(String genKey, String thirdSys, List<ErpInvProductResponse> erpInvProductResponses) {
@ -227,7 +228,7 @@ public class ThrInvProductsDlService {
erpOnhandRequest.setPage(page);
erpOnhandRequest.setLimit(limit);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = new ErpInvClient().getInvPrdoductResponse(erpOnhandRequest, productUrl);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = erpInvClient.getInvPrdoductResponse(erpOnhandRequest, productUrl);
if (responseBaseResponse.getCode() != 20000) {
thrInvProductsImportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL);
@ -288,7 +289,7 @@ public class ThrInvProductsDlService {
erpOnhandRequest.setPage(page);
erpOnhandRequest.setLimit(limit);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = new ErpInvClient().getInvPrdoductResponse(erpOnhandRequest, invPiUrl);
BaseResponse<PageSimpleResponse<ErpInvProductResponse>> responseBaseResponse = erpInvClient.getInvPrdoductResponse(erpOnhandRequest, invPiUrl);
if (responseBaseResponse != null && responseBaseResponse.getCode() == 20000) {
List<ErpInvProductResponse> erpInvProductResponses = responseBaseResponse.getData().getList();
if (erpInvProductResponses != null && erpInvProductResponses.size() > 0) {

@ -29,6 +29,7 @@ import com.glxp.api.admin.service.info.SyncDataSetService;
import com.glxp.api.admin.service.thrsys.*;
import com.glxp.api.admin.util.ExcelUtil;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.admin.util.HttpOkClient;
import com.glxp.api.admin.util.RedisUtil;
import com.glxp.api.common.res.BaseResponse;
import org.springframework.beans.BeanUtils;
@ -71,6 +72,8 @@ public class ThrOrdersDlService {
@Resource
SyncDataSetService syncDataSetService;
@Resource
HttpOkClient httpOkClient;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
@ -412,7 +415,7 @@ public class ThrOrdersDlService {
}
thrOrderExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS);
thrOrderExportLogService.updateThrOrderExportLog(thrOrderExportLogEntity);
String response = HttpClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/order/upload", thrOrderExportJsonResponse);
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/order/upload", thrOrderExportJsonResponse);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
@ -493,7 +496,7 @@ public class ThrOrdersDlService {
postThrOrderRequest.setThirdSys(thrOrderExportRequest.getThirdSysFk());
// SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey("smp_service_ip");
// if (systemParamConfigEntity != null) {
String response = HttpClient.uCloudPost(getIpUrl() + "/udiwms/thrsys/postOrderDetail", postThrOrderRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/udiwms/thrsys/postOrderDetail", postThrOrderRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {

@ -43,11 +43,11 @@ import java.util.stream.Collectors;
@Service
public class ThrProductsDlService {
// @Value("${SPSYNC_IP}")
// private String spsSyncUrl;
@Resource
HttpOkClient httpOkClient;
@Resource
SyncDataSetService syncDataSetService;
public String getIpUrl() {
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
return syncDataSetEntity.getSyncIp();
@ -274,7 +274,7 @@ public class ThrProductsDlService {
}
String response = HttpClient.uCloudPost(getIpUrl() + "/udiwms/thrsys/postThrProducts", postThrProductsRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/udiwms/thrsys/postThrProducts", postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
@ -354,7 +354,7 @@ public class ThrProductsDlService {
}
String response = HttpClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/products/upload", postThrProductsRequest);
String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/thirdsys/products/upload", postThrProductsRequest);
BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {

@ -19,77 +19,39 @@ import java.util.Map;
@Slf4j
public class HttpClient {
public static String post(String url, Object object) {
RestTemplate restTemplate = new RestTemplate();
String json = JSONObject.toJSON(object).toString();
log.info(url + "\n" + json);
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
postParameters.add("params", json);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/x-www-form-urlencoded");
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(postParameters, headers);
return restTemplate.postForObject(UdidConfig.apiUrl + url, httpEntity, String.class);
}
public static String postU8(String url, Object object) {
RestTemplate restTemplate = new RestTemplate();
String json = JSONObject.toJSON(object).toString();
// MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
// postParameters.add("params", json);
log.info(url + "\n" + json);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
headers.add("system", "1");
headers.add("apicode", "1b723931cca84aee8ced6b607fc7dabb");
HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
String response = restTemplate.postForObject(url, httpEntity, String.class);
log.info(response);
return response;
}
public static String uCloudPost(String url, Object object) {
RestTemplate restTemplate = new RestTemplate();
String json = JSONObject.toJSON(object).toString();
log.info(url + "\n" + json);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
log.info(httpEntity.toString());
String response = restTemplate.postForObject(url, httpEntity, String.class);
log.info(response);
return response;
}
// public static String uCloudPost(String url, Object object) {
// RestTemplate restTemplate = new RestTemplate();
// String json = JSONObject.toJSON(object).toString();
// log.info(url + "\n" + json);
// HttpHeaders headers = new HttpHeaders();
// headers.add("Content-Type", "application/json");
// HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
// log.info(httpEntity.toString());
// String response = restTemplate.postForObject(url, httpEntity, String.class);
// log.info(response);
// return response;
// }
/**
*
*
* @param url
* @param object
* @param basicThirdSysEntity
* @return
*/
public static String uCloudPost(String url, Object object, BasicThirdSysEntity basicThirdSysEntity) {
RestTemplate restTemplate = new RestTemplate();
String json = JSONObject.toJSON(object).toString();
log.info(url + "\n" + json);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json");
if (null != basicThirdSysEntity) {
headers.add("api_key", basicThirdSysEntity.getApikey());
headers.add("secret_key", basicThirdSysEntity.getSecretkey());
}
HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
log.info(httpEntity.toString());
return restTemplate.postForObject(url, httpEntity, String.class);
}
public static String mipsGet(String url) {
RestTemplate restTemplate = new RestTemplate();
String accessTokenRequestUrl = url;//"http://127.0.0.1:9997/mips/druginfo/list";
return restTemplate.getForObject(accessTokenRequestUrl, String.class);
}
// public static String uCloudPost(String url, Object object, BasicThirdSysEntity basicThirdSysEntity) {
// RestTemplate restTemplate = new RestTemplate();
// String json = JSONObject.toJSON(object).toString();
// log.info(url + "\n" + json);
// HttpHeaders headers = new HttpHeaders();
// headers.add("Content-Type", "application/json");
// if (null != basicThirdSysEntity) {
// headers.add("api_key", basicThirdSysEntity.getApikey());
// headers.add("secret_key", basicThirdSysEntity.getSecretkey());
// }
// HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
// log.info(httpEntity.toString());
// return restTemplate.postForObject(url, httpEntity, String.class);
// }
public static String mipsGet(String url, Map params) {
StringBuffer stringBuffer = new StringBuffer(url);
if (params instanceof Map) {

@ -0,0 +1,41 @@
package com.glxp.api.admin.util;
import com.alibaba.fastjson.JSONObject;
import com.glxp.api.admin.entity.basic.BasicThirdSysEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class HttpOkClient {
@Resource
OkHttpCli okHttpCli;
public String uCloudPost(String url, Object object) {
String json = JSONObject.toJSON(object).toString();
String response = okHttpCli.doPostJson(url, json, "Content-Type", "application/json");
return response;
}
public String uCloudPost(String url, Object object, BasicThirdSysEntity basicThirdSysEntity) {
String json = JSONObject.toJSON(object).toString();
log.info(url + "\n" + json);
List<String> header = new ArrayList<>();
header.add("Content-Type");
header.add("application/json");
if (null != basicThirdSysEntity) {
header.add("api_key");
header.add(basicThirdSysEntity.getApikey());
header.add("secret_key");
header.add(basicThirdSysEntity.getSecretkey());
}
return okHttpCli.doPostJson(url, json, (String[]) header.toArray());
}
}

@ -1,6 +1,8 @@
package com.glxp.api.admin.util;
import okhttp3.*;
import okhttp3.internal.http.HttpHeaders;
import okhttp3.internal.http2.Header;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -135,6 +137,11 @@ public class OkHttpCli {
return exectePost(url, json, JSON);
}
public String doPostJson(String url, String json, String... headers) {
log.info("do post request and url[{}]", url);
return exectePost(url, json, JSON, headers);
}
/**
* post , xml
*
@ -155,6 +162,14 @@ public class OkHttpCli {
return execute(request);
}
private String exectePost(String url, String data, MediaType contentType, String... headParms) {
RequestBody requestBody = RequestBody.create(contentType, data);
Request request = new Request.Builder().headers(Headers.of(headParms)).url(url).post(requestBody).build();
return execute(request);
}
private String execute(Request request) {
Response response = null;
try {

Loading…
Cancel
Save