|
@@ -236,35 +236,34 @@ public class ExcelService {
|
|
|
private void checkUploadProduct(File file, List<String> errorList){
|
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
|
Integer colum = 1;
|
|
|
- HashMap<String,ProductSource> productSourceHashMap = new HashMap<>();
|
|
|
HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
|
|
|
HashMap<String, List<String>> resultPMap = new HashMap<>();
|
|
|
HashMap<String, List<String>> numMap = new HashMap<>();
|
|
|
+ HashMap<String, Integer> sourceMap = new HashMap<>();
|
|
|
+ HashMap<String,ProductSource> productMap = new HashMap<>();
|
|
|
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
|
String sourceId = map.get(3);
|
|
|
- if(StringUtils.isNotBlank(sourceId)){
|
|
|
- ProductSource byMchId = productSourceService.getByMchId(sourceId);
|
|
|
- if(byMchId!=null){
|
|
|
- productSourceHashMap.put(sourceId,byMchId);
|
|
|
- }
|
|
|
- }
|
|
|
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 = productSourceHashMap.get(mchId);
|
|
|
- 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());
|
|
|
+ if(productSourceProductMap.size()<=1){
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -281,14 +280,35 @@ public class ExcelService {
|
|
|
}
|
|
|
if(numMap.get(sceneNum) == null){
|
|
|
List<HotRelation> hotRelations = hotRelationService.getByNum(sceneNum);
|
|
|
+ for (HotRelation hotRelation : hotRelations) {
|
|
|
+ sourceMap.put(hotRelation.getHotId(),hotRelation.getProductSourceId());
|
|
|
+ }
|
|
|
List<String> sidList = hotRelations.stream().map(HotRelation::getHotId).collect(Collectors.toList());
|
|
|
numMap.put(sceneNum,sidList);
|
|
|
}
|
|
|
- if(!numMap.get(sceneNum).contains(sid)){
|
|
|
+ if(sourceMap.get(sid) == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!productMap.isEmpty() && !productMap.containsKey(mchId)){
|
|
|
errorList.add(colum.toString());
|
|
|
continue;
|
|
|
}
|
|
|
- if(!productSourceHashMap.containsKey(mchId)){
|
|
|
+ if(productMap.get(mchId) == null){
|
|
|
+ ProductSource productSource = productSourceService.getByMchId(mchId);
|
|
|
+ if(productSource == null){
|
|
|
+ errorList.add(colum.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ productMap.put(mchId,productSource);
|
|
|
+ }
|
|
|
+ ProductSource productSource = productMap.get(mchId);
|
|
|
+ if(!productSource.getId().equals(sourceMap.get(sid))){
|
|
|
+ errorList.add(colum.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!numMap.get(sceneNum).contains(sid)){
|
|
|
errorList.add(colum.toString());
|
|
|
continue;
|
|
|
}
|