You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.7 KiB
Java
104 lines
3.7 KiB
Java
package com.glxp.api.http;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.entity.system.SyncDataSetEntity;
|
|
import com.glxp.api.req.inout.PostOrderRequest;
|
|
import com.glxp.api.service.system.SyncDataSetService;
|
|
import com.glxp.api.util.OkHttpCli;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
@Service
|
|
public class SpsDirectClient {
|
|
@Resource
|
|
private OkHttpCli okHttpCli;
|
|
@Resource
|
|
SyncDataSetService syncDataSetService;
|
|
|
|
public String getIpUrl() {
|
|
SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet();
|
|
return syncDataSetEntity.getSyncIp();
|
|
}
|
|
|
|
//单据验收 todo
|
|
// public BaseResponse reviewOrder(OrderFilterRequest 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>>() {
|
|
// });
|
|
// return response;
|
|
//
|
|
// }
|
|
|
|
//获取未验收的单据
|
|
public BaseResponse downloadOrder(String orderId, String wmsUserId, String action) {
|
|
Map<String, String> paramMap = new HashMap<>(16);
|
|
paramMap.put("wmsUserId", wmsUserId);
|
|
paramMap.put("orderId", orderId);
|
|
paramMap.put("action", action);
|
|
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/order", paramMap);
|
|
try {
|
|
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
});
|
|
return data;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return ResultVOUtils.error(500, "连接失败!");
|
|
}
|
|
}
|
|
|
|
//获取未验收的单据详情
|
|
public BaseResponse downloadOrderDetail(String orderId, String wmsUserId) {
|
|
Map<String, String> paramMap = new HashMap<>(16);
|
|
paramMap.put("wmsUserId", wmsUserId);
|
|
paramMap.put("orderId", orderId);
|
|
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/orderDetail", paramMap);
|
|
try {
|
|
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
});
|
|
return data;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return ResultVOUtils.error(500, "连接失败!");
|
|
}
|
|
}
|
|
|
|
|
|
//获取未验收的单据条码
|
|
public BaseResponse downloadCodes(String wmsUserId, String orderId) {
|
|
Map<String, String> paramMap = new HashMap<>(16);
|
|
paramMap.put("wmsUserId", wmsUserId);
|
|
paramMap.put("orderId", orderId);
|
|
String response = okHttpCli.doGet(getIpUrl() + "/sps/review/download/codes", paramMap);
|
|
try {
|
|
BaseResponse data = JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
});
|
|
return data;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return ResultVOUtils.error(500, "连接失败!");
|
|
}
|
|
}
|
|
|
|
|
|
//单据上传
|
|
public BaseResponse uploadPdaOrder(PostOrderRequest 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>>() {
|
|
});
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|