|
|
|
@ -11,9 +11,11 @@ import com.ms.api.common.R;
|
|
|
|
|
import com.ms.api.common.Ret;
|
|
|
|
|
import com.ms.api.common.SPIBaseService;
|
|
|
|
|
import com.ms.api.dto.move.GetProductInfoRequestDTO;
|
|
|
|
|
import com.ms.api.service.CategoryService;
|
|
|
|
|
import com.ms.api.service.MoveSystemSourceCategoryService;
|
|
|
|
|
import com.ms.api.tool.DsJsonRequestTemplate;
|
|
|
|
|
import com.ms.api.common.UniqueKeyMultiValueMap;
|
|
|
|
|
import com.ms.dal.entity.Category;
|
|
|
|
|
import com.ms.dal.entity.MoveSystemSourceCategory;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.phprpc.util.AssocArray;
|
|
|
|
@ -21,10 +23,7 @@ import org.phprpc.util.PHPSerializer;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
@ -45,6 +44,9 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
@Autowired
|
|
|
|
|
private MoveSystemSourceCategoryService moveSystemSourceCategoryService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CategoryService categoryService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse<Ret> handle(BaseRequest<GetProductInfoRequestDTO> req) {
|
|
|
|
|
initHandle(req);
|
|
|
|
@ -80,14 +82,16 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
String content = moveSystemSourceCategory.getMatchCategoryList();
|
|
|
|
|
AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes());
|
|
|
|
|
Map assocMap = assocArrayToHash(assocArray);
|
|
|
|
|
List<Object> assocMapValues = new ArrayList<>(assocMap.values());
|
|
|
|
|
Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1);
|
|
|
|
|
List<String> assocMapKeys = new ArrayList<>(assocMap.keySet());
|
|
|
|
|
|
|
|
|
|
log.info("assocArrayToHash" + inMap.get("path"));
|
|
|
|
|
log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1));
|
|
|
|
|
product.put("ddCid", assocMapKeys.get(assocMapKeys.size() - 1));
|
|
|
|
|
product.put("ddCategoryList", inMap.get("path"));
|
|
|
|
|
Long categoryId = Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1));
|
|
|
|
|
List<Long> categoryIds = this.getCategoryIdList(categoryId);
|
|
|
|
|
Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1)));
|
|
|
|
|
String path = category.getPath();
|
|
|
|
|
List<String> pathArr = Arrays.asList(path.split(">"));
|
|
|
|
|
product.put("ddCid", categoryIds);
|
|
|
|
|
product.put("ddCategoryList", pathArr);
|
|
|
|
|
} else {
|
|
|
|
|
product.put("ddCid", "");
|
|
|
|
|
product.put("ddCategoryList", "");
|
|
|
|
@ -114,6 +118,16 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
// ----结果返回----
|
|
|
|
|
return R.ok(Ret.success(result));
|
|
|
|
|
}
|
|
|
|
|
private List<Long> getCategoryIdList(Long categoryId) {
|
|
|
|
|
List<Long> categoryIdList = new ArrayList<>();
|
|
|
|
|
while(categoryId != 0) {
|
|
|
|
|
Category category = categoryService.selectByPrimaryKey(categoryId);
|
|
|
|
|
categoryIdList.add(categoryId);
|
|
|
|
|
categoryId = Long.valueOf(category.getParentCategoryId());
|
|
|
|
|
}
|
|
|
|
|
Collections.reverse(categoryIdList);
|
|
|
|
|
return categoryIdList;
|
|
|
|
|
}
|
|
|
|
|
private static Map assocArrayToHash(AssocArray assocArray) {
|
|
|
|
|
HashMap hashMap = assocArray.toHashMap();
|
|
|
|
|
Map result = new HashMap();
|
|
|
|
|