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.
70 lines
2.7 KiB
Java
70 lines
2.7 KiB
Java
package com.glxp.api.service.thrsys;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.entity.thrsys.ThrProductsEntity;
|
|
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
|
|
import com.glxp.api.httpClient.ErpBasicClient;
|
|
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.thrsys.ThrProductsResponse;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 根据系统设置,获取对应的第三方数据信息
|
|
*/
|
|
|
|
@Service
|
|
public class ThrDataService {
|
|
|
|
@Resource
|
|
private ThrSystemDetailService thrSystemDetailService;
|
|
@Resource
|
|
private ThrProductsService thrProductsService;
|
|
@Resource
|
|
private ErpBasicClient erpBasicClient;
|
|
|
|
final Logger logger = LoggerFactory.getLogger(ThrDataService.class);
|
|
|
|
public ThrProductsEntity getProducts(String code, String thirdSys) {
|
|
|
|
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", thirdSys);
|
|
|
|
if (thrSystemDetailEntity == null || !thrSystemDetailEntity.getEnabled()) {
|
|
logger.info("第三方系统产品信息接口服务未启用");
|
|
return null;
|
|
}
|
|
|
|
if (thrSystemDetailEntity.getFromType() == 0) {
|
|
FilterThrProductsRequest filterErpGoodsRequest = new FilterThrProductsRequest();
|
|
filterErpGoodsRequest.setCode(code);
|
|
filterErpGoodsRequest.setPage(1);
|
|
filterErpGoodsRequest.setLimit(1);
|
|
BaseResponse<PageSimpleResponse<ThrProductsResponse>> udiDlDeviceResponse = erpBasicClient.getErpProducts(filterErpGoodsRequest);
|
|
if (udiDlDeviceResponse.getCode() == 20000) {
|
|
List<ThrProductsResponse> erpProductsResponses = udiDlDeviceResponse.getData().getList();
|
|
if (erpProductsResponses != null) {
|
|
ThrProductsEntity thrProductsEntity = new ThrProductsEntity();
|
|
BeanUtil.copyProperties(erpProductsResponses.get(0), thrProductsEntity);
|
|
return thrProductsEntity;
|
|
}
|
|
}
|
|
} else {
|
|
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
|
|
filterThrProductsRequest.setCode(code);
|
|
filterThrProductsRequest.setThirdSysFk(thirdSys);
|
|
List<ThrProductsEntity> thrProductsEntitys = thrProductsService.filterThrProducts(filterThrProductsRequest);
|
|
if (thrProductsEntitys != null && thrProductsEntitys.size() > 0) {
|
|
return thrProductsEntitys.get(0);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|