|
@@ -9,10 +9,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.amazonaws.services.ecs.model.Tmpfs;
|
|
|
import com.cdf.common.CacheUtil;
|
|
|
import com.cdf.common.ResultCode;
|
|
|
-import com.cdf.entity.Brand;
|
|
|
-import com.cdf.entity.HotOutline;
|
|
|
-import com.cdf.entity.HotRelation;
|
|
|
-import com.cdf.entity.ProductSource;
|
|
|
+import com.cdf.entity.*;
|
|
|
import com.cdf.httpClient.client.CdfClient;
|
|
|
import com.cdf.httpClient.client.CdfHKClient;
|
|
|
import com.cdf.httpClient.response.cdf.CdfProduct;
|
|
@@ -24,10 +21,7 @@ import com.cdf.exception.BusinessException;
|
|
|
import com.cdf.response.HotUploadTemplate;
|
|
|
import com.cdf.response.OutlineUploadTemplate;
|
|
|
import com.cdf.response.ProductUploadTemplate;
|
|
|
-import com.cdf.service.IBrandService;
|
|
|
-import com.cdf.service.IHotOutlineService;
|
|
|
-import com.cdf.service.IHotRelationService;
|
|
|
-import com.cdf.service.IProductSourceService;
|
|
|
+import com.cdf.service.*;
|
|
|
import com.cdf.util.ExcelUtil;
|
|
|
import com.cdf.util.UploadToCdfOssUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -42,10 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -71,6 +62,12 @@ public class ExcelService {
|
|
|
private IBrandService brandService;
|
|
|
@Autowired
|
|
|
private IHotRelationService hotRelationService;
|
|
|
+ @Autowired
|
|
|
+ private IHotRecommendService hotRecommendService;
|
|
|
+ @Autowired
|
|
|
+ IFdkkUserService fdkkUserService;
|
|
|
+ @Autowired
|
|
|
+ INumRegionService numRegionService;
|
|
|
|
|
|
|
|
|
// 0 外框设置 ,1 瀑布流, 2,精选推荐设置 ,3 品牌推荐设置
|
|
@@ -219,11 +216,11 @@ public class ExcelService {
|
|
|
|
|
|
private void checkUploadProduct(File file, List<String> errorList){
|
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
|
- List<HotUploadTemplate> list = null;
|
|
|
Integer colum = 0;
|
|
|
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<>();
|
|
|
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
|
String sourceId = map.get(3);
|
|
@@ -261,15 +258,12 @@ public class ExcelService {
|
|
|
errorList.add(colum.toString());
|
|
|
continue;
|
|
|
}
|
|
|
- if(list == null){
|
|
|
- list = getHotsList(sceneNum);
|
|
|
+ if(numMap.get(sceneNum) == null){
|
|
|
+ List<HotRelation> hotRelations = hotRelationService.getByNum(sceneNum);
|
|
|
+ List<String> sidList = hotRelations.stream().map(HotRelation::getHotId).collect(Collectors.toList());
|
|
|
+ numMap.put(sceneNum,sidList);
|
|
|
}
|
|
|
- if(list .isEmpty()){
|
|
|
- errorList.add(colum.toString());
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<String> collect = list.stream().map(HotUploadTemplate::getSid).collect(Collectors.toList());
|
|
|
- if(!collect.contains(sid)){
|
|
|
+ if(!numMap.get(sceneNum).contains(sid)){
|
|
|
errorList.add(colum.toString());
|
|
|
continue;
|
|
|
}
|
|
@@ -373,20 +367,79 @@ public class ExcelService {
|
|
|
|
|
|
private void uploadProduct(File file) {
|
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
|
+ HashMap<String,HashMap<String,HashSet<String>>> numMap = new HashMap<>();
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
|
String sceneNum = map.get(0);
|
|
|
String sid = map.get(1);
|
|
|
String title = map.get(2);
|
|
|
String mchId = map.get(3);
|
|
|
String pid = map.get(4);
|
|
|
+ numMap.computeIfAbsent(sceneNum, k -> new HashMap<>());
|
|
|
+ numMap.get(sceneNum).computeIfAbsent(sid,k -> new HashSet<>());
|
|
|
+ numMap.get(sceneNum).get(sid).add(pid);
|
|
|
+ }
|
|
|
+ List<HotRelation> updateList = new ArrayList<>();
|
|
|
+ for (String num : numMap.keySet()) {
|
|
|
+ HashMap<String, HashSet<String>> sidMap = numMap.get(num);
|
|
|
+ for (String sid : sidMap.keySet()) {
|
|
|
+ HotRelation hotRelation = hotRelationService.getById(sid);
|
|
|
+ if(hotRelation == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ HashSet<String> pidSet = sidMap.get(sid);
|
|
|
+ hotRelation.setRelationIds(JSONArray.toJSONString(pidSet));
|
|
|
+ updateList.add(hotRelation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!updateList.isEmpty()){
|
|
|
+ hotRelationService.updateBatchById(updateList);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String num : numMap.keySet()) {
|
|
|
+ NumRegion numRegion = fdkkUserService.getRegionByNum(num);
|
|
|
+ fdkkSceneEditService.writeHotJson(num,numRegion.getRegion());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void uploadHot(File file,Integer type) {
|
|
|
|
|
|
List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
|
|
|
+ HashMap<String,HashSet<String>> numMap = new HashMap<>();
|
|
|
for (HashMap<Integer, String> map : excelRowList) {
|
|
|
-
|
|
|
+ String sceneNum = map.get(0);
|
|
|
+ String sid = map.get(1);
|
|
|
+ String title = map.get(2);
|
|
|
+ numMap.computeIfAbsent(sceneNum, k -> new HashSet<>());
|
|
|
+ numMap.get(sceneNum).add(sid);
|
|
|
+ HotRecommend recommend = hotRecommendService.getByNumAndSid(sceneNum,sid);
|
|
|
+ if(recommend == null){
|
|
|
+ recommend = new HotRecommend();
|
|
|
+ recommend.setSceneNum(sceneNum);
|
|
|
+ recommend.setSid(sid);
|
|
|
+ }
|
|
|
+ if(type == 2){
|
|
|
+ recommend.setRecommendSelection(1);
|
|
|
+ }
|
|
|
+ if(type == 3){
|
|
|
+ recommend.setRecommendBrand(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Integer> delIds = new ArrayList<>();
|
|
|
+ for (String num : numMap.keySet()) {
|
|
|
+ List<HotRecommend> list = hotRecommendService.getByNum(num);
|
|
|
+ HashSet<String> strings = numMap.get(num);
|
|
|
+ for (HotRecommend recommend : list) {
|
|
|
+ if(!strings.contains(recommend.getSid())){
|
|
|
+ delIds.add(recommend.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!delIds.isEmpty()){
|
|
|
+ hotRecommendService.removeByIds(delIds);
|
|
|
+ }
|
|
|
+ for (String num : numMap.keySet()) {
|
|
|
+ NumRegion numRegion = fdkkUserService.getRegionByNum(num);
|
|
|
+ fdkkSceneEditService.writeHotJson(num,numRegion.getRegion());
|
|
|
}
|
|
|
}
|
|
|
}
|