|
@@ -17,6 +17,7 @@ import com.cdf.httpClient.client.CdfHKClient;
|
|
import com.cdf.httpClient.response.cdf.CdfProduct;
|
|
import com.cdf.httpClient.response.cdf.CdfProduct;
|
|
import com.cdf.httpClient.response.cdf.CdfProductListByIdsRequest;
|
|
import com.cdf.httpClient.response.cdf.CdfProductListByIdsRequest;
|
|
import com.cdf.httpClient.response.cdf.CdfProductListByIdsVo;
|
|
import com.cdf.httpClient.response.cdf.CdfProductListByIdsVo;
|
|
|
|
+import com.cdf.httpClient.response.cdf.CdfProductVo;
|
|
import com.cdf.request.UploadHotsParam;
|
|
import com.cdf.request.UploadHotsParam;
|
|
import com.cdf.response.*;
|
|
import com.cdf.response.*;
|
|
import com.cdf.exception.BusinessException;
|
|
import com.cdf.exception.BusinessException;
|
|
@@ -33,6 +34,7 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -236,35 +238,10 @@ public class ExcelService {
|
|
private void checkUploadProduct(File file, List<String> errorList){
|
|
private void checkUploadProduct(File file, List<String> errorList){
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
Integer colum = 1;
|
|
Integer colum = 1;
|
|
- HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
|
|
|
|
- HashMap<String, List<String>> resultPMap = new HashMap<>();
|
|
|
|
HashMap<String, List<String>> numMap = new HashMap<>();
|
|
HashMap<String, List<String>> numMap = new HashMap<>();
|
|
HashMap<String,ProductSource> productMap = new HashMap<>();
|
|
HashMap<String,ProductSource> productMap = new HashMap<>();
|
|
|
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
- String sourceId = map.get(3);
|
|
|
|
- String pid = map.get(4);
|
|
|
|
- if(StringUtils.isNotBlank(pid)){
|
|
|
|
- List<String> pidList = productSourceProductMap.computeIfAbsent(sourceId, k -> new ArrayList<>());
|
|
|
|
- pidList.add(pid);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (String mchId : productSourceProductMap.keySet()) {
|
|
|
|
- ProductSource productSource = productSourceService.getByMchId(mchId);
|
|
|
|
- if(productSource !=null){
|
|
|
|
- JSONArray ids = new JSONArray();
|
|
|
|
- ids.addAll(productSourceProductMap.get(mchId));
|
|
|
|
- CdfProductListByIdsRequest idsRequest = new CdfProductListByIdsRequest(ids);
|
|
|
|
- CdfProductListByIdsVo vos = cdfHKClient.getProductListByIds(productSource.getCdfHost(), productSource.getCdfMchId(), idsRequest);
|
|
|
|
- if(vos.getProductCardList()!=null && vos.getProductCardList().size() >0){
|
|
|
|
- for (CdfProduct cdfProduct : vos.getProductCardList()) {
|
|
|
|
- List<String> pidList = resultPMap.computeIfAbsent(mchId, k -> new ArrayList<>());
|
|
|
|
- pidList.add(cdfProduct.getId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (HashMap<Integer, String> map : excelRowList) {
|
|
|
|
colum ++;
|
|
colum ++;
|
|
String sceneNum = map.get(0);
|
|
String sceneNum = map.get(0);
|
|
String sid = map.get(1);
|
|
String sid = map.get(1);
|
|
@@ -298,12 +275,8 @@ public class ExcelService {
|
|
errorList.add(colum.toString());
|
|
errorList.add(colum.toString());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- List<String> cdfProductList = resultPMap.get(mchId);
|
|
|
|
- if(cdfProductList.isEmpty()){
|
|
|
|
- errorList.add(colum.toString());
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if(!cdfProductList.contains(pid)){
|
|
|
|
|
|
+ CdfProductVo productById = cdfHKClient.getProductById(productSource.getCdfHost(),productSource.getCdfMchId(),pid);
|
|
|
|
+ if(productById == null || productById.getId() == null || !productById.getId().equals(pid)){
|
|
errorList.add(colum.toString());
|
|
errorList.add(colum.toString());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -377,6 +350,13 @@ public class ExcelService {
|
|
break;
|
|
break;
|
|
default: throw new BusinessException(ResultCode.PARAM_MISS);
|
|
default: throw new BusinessException(ResultCode.PARAM_MISS);
|
|
}
|
|
}
|
|
|
|
+ try {
|
|
|
|
+ file.delete();
|
|
|
|
+ uploadToCdfOssUtil.delete(awsKey);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.info("删除文件失败:",e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|