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.
udi-wms-java/src/main/java/com/glxp/api/http/ErpOrderClient.java

66 lines
2.3 KiB
Java

package com.glxp.api.http;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.entity.thrsys.ThrSystemEntity;
import com.glxp.api.req.thrsys.FilterThrOrderRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.thrsys.ThrErpOrderResponse;
import com.glxp.api.res.thrsys.ThrOrderResponse;
import com.glxp.api.service.thrsys.ThrSystemService;
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;
/**
* 获取ERP出入库单据
*/
@Slf4j
@Service
public class ErpOrderClient {
@Autowired
private ThrSystemService thrSystemService;
@Resource
HttpOkClient httpOkClient;
public List<ThrOrderResponse> getErpOrder(String url, List<String> billCodes, String action) {
List<ThrOrderResponse> erpOrderEntities = new ArrayList<>();
if (billCodes != null && billCodes.size() > 0) {
for (int i = 0; i < billCodes.size(); i++) {
List<ThrOrderResponse> ThrErpOrderResponses = getErpOrder(url, Arrays.asList(billCodes.get(i)), action);
if (ThrErpOrderResponses != null) {
erpOrderEntities.addAll(ThrErpOrderResponses);
}
}
}
return erpOrderEntities;
}
public BaseResponse<PageSimpleResponse<ThrOrderResponse>> getThrOrderResponse(FilterThrOrderRequest filterOrderRequest) {
//查询第三方服务授权参数
ThrSystemEntity thrSystemEntity = thrSystemService.selectByThirdId("thirdId");
String url = thrSystemEntity.getThridUrl() + "/udiwms/erp/getOrders";
String response = httpOkClient.uCloudPost(url, filterOrderRequest, thrSystemEntity);
try {
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrOrderResponse>>>() {
});
return responseBaseResponse;
} catch (Exception e) {
log.error("获取订单数据异常", e);
}
return null;
}
}