|
|
|
@ -1,19 +1,25 @@
|
|
|
|
|
package com.glxp.sale.admin.thread;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import com.glxp.sale.admin.entity.basic.UdiCompanyEntity;
|
|
|
|
|
import com.glxp.sale.admin.entity.receipt.ProductInfoEntity;
|
|
|
|
|
import com.glxp.sale.admin.service.receipt.ProductInfoService;
|
|
|
|
|
import com.glxp.sale.admin.util.HttpClient;
|
|
|
|
|
import com.glxp.sale.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.sale.common.util.ResultVOUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class AsyncDiDlHelper {
|
|
|
|
|
@Value("${UDI_SERVER_URL}")
|
|
|
|
@ -115,4 +121,33 @@ public class AsyncDiDlHelper {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
ProductInfoService productInfoService;
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
|
public void dlByUuid(String uuid) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> paramMap = new HashMap<>(16);
|
|
|
|
|
paramMap.put("uuid", uuid);
|
|
|
|
|
String response = HttpClient.mipsGet(udiUrl + "/udidl/device/searchDlByUuid", paramMap);
|
|
|
|
|
try {
|
|
|
|
|
BaseResponse<List<ProductInfoEntity>> baseResponse =
|
|
|
|
|
JSONObject.parseObject(response, new TypeReference<BaseResponse<List<ProductInfoEntity>>>() {
|
|
|
|
|
});
|
|
|
|
|
if (baseResponse != null && baseResponse.getCode() == 20000) {
|
|
|
|
|
List<ProductInfoEntity> productInfoEntityList = baseResponse.getData();
|
|
|
|
|
if (CollUtil.isNotEmpty(productInfoEntityList)) {
|
|
|
|
|
productInfoService.insertProductInfos(productInfoEntityList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
log.error("下载出错");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|