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.
146 lines
6.8 KiB
Java
146 lines
6.8 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;
|
|
}
|
|
|
|
public List<ThrErpOrderResponse> getErpOrder(FilterThrOrderRequest filterOrderRequest) {
|
|
try {
|
|
BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse = getThrOrderResponse(filterOrderRequest);
|
|
List<ThrOrderResponse> purchaseinResponseList = responseBaseResponse.getData().getList();
|
|
if (purchaseinResponseList != null && purchaseinResponseList.size() > 0) {
|
|
List<ThrErpOrderResponse> erpOrderEntities = new ArrayList<>();
|
|
for (ThrOrderResponse ThrOrderResponse : purchaseinResponseList) {
|
|
for (ThrOrderResponse.SubErpOrder subPurchase : ThrOrderResponse.getSubErpOrders()) {
|
|
ThrErpOrderResponse ThrErpOrderResponse = new ThrErpOrderResponse();
|
|
ThrErpOrderResponse.setErpOrderId(ThrOrderResponse.getBillNo());
|
|
ThrErpOrderResponse.setCompanyid(ThrOrderResponse.getCorpId());
|
|
ThrErpOrderResponse.setCompanyname(ThrOrderResponse.getCorpName());
|
|
ThrErpOrderResponse.setCredate(ThrOrderResponse.getBilldate());
|
|
ThrErpOrderResponse.setGoodsid(subPurchase.getProductId());
|
|
ThrErpOrderResponse.setGoodsname(subPurchase.getProductName());
|
|
ThrErpOrderResponse.setBatchNo(subPurchase.getBatchNo());
|
|
ThrErpOrderResponse.setProductDate(subPurchase.getProductDate());
|
|
ThrErpOrderResponse.setExpireDate(subPurchase.getExpireDate());
|
|
ThrErpOrderResponse.setErpCount(subPurchase.getCount());
|
|
ThrErpOrderResponse.setReCount(subPurchase.getReCount());
|
|
ThrErpOrderResponse.setOriginType(ThrOrderResponse.getOriginType());
|
|
ThrErpOrderResponse.setGoodsunit(subPurchase.getSpec());
|
|
ThrErpOrderResponse.setOrderFromType(ConstantStatus.SORDER_FROM_ONLINE);
|
|
erpOrderEntities.add(ThrErpOrderResponse);
|
|
}
|
|
}
|
|
return erpOrderEntities;
|
|
}
|
|
} catch (
|
|
Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
// public BaseResponse submitOrder(UdiwmsOrderRequest udiwmsOrderRequest) {
|
|
// BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(udiwmsOrderRequest.getThirdSys());
|
|
// String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders";
|
|
// String response = httpOkClient.uCloudPost(url, udiwmsOrderRequest);
|
|
// try {
|
|
// BaseResponse<PageSimpleResponse<ThrOrderResponse>> responseBaseResponse =
|
|
// JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ThrOrderResponse>>>() {
|
|
// });
|
|
// return responseBaseResponse;
|
|
// } catch (Exception e) {
|
|
// log.error("获取订单数据异常", e);
|
|
// }
|
|
// return null;
|
|
// }
|
|
|
|
|
|
// public BaseResponse postBill(Map<String, List<ThrErpOrderResponse>> postMap, String billAction, String uploadUrl, String thirdSysFk) {
|
|
// ERPPostBillRequest erpPostBillRequest = new ERPPostBillRequest();
|
|
// erpPostBillRequest.setPostMap(postMap);
|
|
// erpPostBillRequest.setBillAction(billAction);
|
|
//
|
|
// //查询第三方服务授权参数
|
|
// BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(thirdSysFk);
|
|
// 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 = httpOkClient.uCloudPost(uploadUrl, erpPostBillRequest);
|
|
// BaseResponse baseResponse =
|
|
// JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
// });
|
|
// return baseResponse;
|
|
// }
|
|
//
|
|
// public BaseResponse signBill(USignRequest signRequest, String url) {
|
|
// String response = httpOkClient.uCloudPost(url, signRequest);
|
|
// BaseResponse baseResponse =
|
|
// JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
|
|
// });
|
|
// return baseResponse;
|
|
// }
|
|
|
|
}
|