|
@@ -236,17 +236,13 @@ 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,ProductSource> productSourceHashMap = new HashMap<>();
|
|
|
|
HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
|
|
HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
|
|
HashMap<String, List<String>> resultPMap = 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<>();
|
|
|
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
String sourceId = map.get(3);
|
|
String sourceId = map.get(3);
|
|
- if(StringUtils.isNotBlank(sourceId)){
|
|
|
|
- ProductSource byMchId = productSourceService.getByMchId(sourceId);
|
|
|
|
- productSourceHashMap.put(sourceId,byMchId);
|
|
|
|
- }
|
|
|
|
String pid = map.get(4);
|
|
String pid = map.get(4);
|
|
if(StringUtils.isNotBlank(pid)){
|
|
if(StringUtils.isNotBlank(pid)){
|
|
List<String> pidList = productSourceProductMap.computeIfAbsent(sourceId, k -> new ArrayList<>());
|
|
List<String> pidList = productSourceProductMap.computeIfAbsent(sourceId, k -> new ArrayList<>());
|
|
@@ -254,15 +250,17 @@ public class ExcelService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (String mchId : productSourceProductMap.keySet()) {
|
|
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());
|
|
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -282,11 +280,21 @@ public class ExcelService {
|
|
List<String> sidList = hotRelations.stream().map(HotRelation::getHotId).collect(Collectors.toList());
|
|
List<String> sidList = hotRelations.stream().map(HotRelation::getHotId).collect(Collectors.toList());
|
|
numMap.put(sceneNum,sidList);
|
|
numMap.put(sceneNum,sidList);
|
|
}
|
|
}
|
|
- if(!numMap.get(sceneNum).contains(sid)){
|
|
|
|
|
|
+ if(productMap.get(sid) == null){
|
|
|
|
+ ProductSource productSource = productSourceService.getByMchId(mchId);
|
|
|
|
+ if(productSource == null){
|
|
|
|
+ errorList.add(colum.toString());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ productMap.put(sid,productSource);
|
|
|
|
+ }
|
|
|
|
+ ProductSource productSource = productMap.get(sid);
|
|
|
|
+ if(!mchId.equals(productSource.getCdfMchId())){
|
|
errorList.add(colum.toString());
|
|
errorList.add(colum.toString());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(!productSourceHashMap.containsKey(mchId)){
|
|
|
|
|
|
+
|
|
|
|
+ if(!numMap.get(sceneNum).contains(sid)){
|
|
errorList.add(colum.toString());
|
|
errorList.add(colum.toString());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -397,6 +405,7 @@ public class ExcelService {
|
|
Integer colum = 1;
|
|
Integer colum = 1;
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
HashMap<String,HashMap<String,HashSet<String>>> numMap = new HashMap<>();
|
|
HashMap<String,HashMap<String,HashSet<String>>> numMap = new HashMap<>();
|
|
|
|
+ HashMap<String,ProductSource> sidProMap = new HashMap<>();
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
colum ++;
|
|
colum ++;
|
|
if(errorList.contains(colum.toString())){
|
|
if(errorList.contains(colum.toString())){
|
|
@@ -410,10 +419,18 @@ public class ExcelService {
|
|
if(StringUtils.isBlank(mchId) || StringUtils.isBlank(sceneNum) || StringUtils.isBlank(pid) || StringUtils.isBlank(sid)){
|
|
if(StringUtils.isBlank(mchId) || StringUtils.isBlank(sceneNum) || StringUtils.isBlank(pid) || StringUtils.isBlank(sid)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if(sidProMap.get(sid) == null){
|
|
|
|
+ ProductSource productSource = productSourceService.getByMchId(mchId);
|
|
|
|
+ if(productSource != null){
|
|
|
|
+ sidProMap.put(sid,productSource);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
numMap.computeIfAbsent(sceneNum, k -> new HashMap<>());
|
|
numMap.computeIfAbsent(sceneNum, k -> new HashMap<>());
|
|
numMap.get(sceneNum).computeIfAbsent(sid,k -> new HashSet<>());
|
|
numMap.get(sceneNum).computeIfAbsent(sid,k -> new HashSet<>());
|
|
numMap.get(sceneNum).get(sid).add(pid);
|
|
numMap.get(sceneNum).get(sid).add(pid);
|
|
}
|
|
}
|
|
|
|
+
|
|
List<HotRelation> updateList = new ArrayList<>();
|
|
List<HotRelation> updateList = new ArrayList<>();
|
|
for (String num : numMap.keySet()) {
|
|
for (String num : numMap.keySet()) {
|
|
HashMap<String, HashSet<String>> sidMap = numMap.get(num);
|
|
HashMap<String, HashSet<String>> sidMap = numMap.get(num);
|
|
@@ -422,8 +439,13 @@ public class ExcelService {
|
|
if(hotRelation == null){
|
|
if(hotRelation == null){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ ProductSource productSource = sidProMap.get(sid);
|
|
|
|
+ if(productSource == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
HashSet<String> pidSet = sidMap.get(sid);
|
|
HashSet<String> pidSet = sidMap.get(sid);
|
|
hotRelation.setRelationIds(JSONArray.toJSONString(pidSet));
|
|
hotRelation.setRelationIds(JSONArray.toJSONString(pidSet));
|
|
|
|
+ hotRelation.setProductSourceId(productSource.getId());
|
|
updateList.add(hotRelation);
|
|
updateList.add(hotRelation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -482,7 +504,7 @@ public class ExcelService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!delIds.isEmpty()){
|
|
if(!delIds.isEmpty()){
|
|
- hotRecommendService.removeByIds(delIds);
|
|
|
|
|
|
+ hotRecommendService.updateRecomend(delIds,type);
|
|
}
|
|
}
|
|
for (String num : numMap.keySet()) {
|
|
for (String num : numMap.keySet()) {
|
|
NumRegion numRegion = fdkkUserService.getRegionByNum(num);
|
|
NumRegion numRegion = fdkkUserService.getRegionByNum(num);
|