From 9befe75f4ade796d2829e911673eafd1c86d5ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cxxxxxxx=E8=AF=A6?= <286460656@qq.com> Date: Wed, 13 Sep 2023 19:36:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E8=BF=94=E5=9B=9E=E6=8A=96=E5=BA=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MoveCollectTaskDetailService.java | 2 ++ .../MoveCollectTaskDetailServiceImpl.java | 5 +++ .../GetMoveHistoryProductListService.java | 3 +- .../spi/move/GetProductInfoByProductId.java | 28 +++++++++++++--- .../api/spi/move/GetProductInfoService.java | 32 +++++++++++++------ .../mapper/MoveCollectTaskDetailMapper.java | 2 ++ .../mapper/MoveCollectTaskDetailMapper.xml | 5 +++ 7 files changed, 62 insertions(+), 15 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/service/MoveCollectTaskDetailService.java b/ms-biz/src/main/java/com/ms/api/service/MoveCollectTaskDetailService.java index 9fcac96a..83f25e0d 100644 --- a/ms-biz/src/main/java/com/ms/api/service/MoveCollectTaskDetailService.java +++ b/ms-biz/src/main/java/com/ms/api/service/MoveCollectTaskDetailService.java @@ -25,6 +25,8 @@ public interface MoveCollectTaskDetailService { int updateByPrimaryKey(MoveCollectTaskDetail record); + int getMoveCollectTaskProcessingCount(Long shopId); + MoveCollectTaskDetail getMoveCollectTaskDetail(long shopId, long moveCollectTaskDetailId) ; Pager getMoveCollectTaskList(GetMoveHistoryProductListRequestDTO condition); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/MoveCollectTaskDetailServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/MoveCollectTaskDetailServiceImpl.java index ddeb1b43..685004a7 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/MoveCollectTaskDetailServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/MoveCollectTaskDetailServiceImpl.java @@ -54,6 +54,11 @@ public class MoveCollectTaskDetailServiceImpl implements MoveCollectTaskDetailSe return moveCollectTaskDetailMapper.updateByPrimaryKey(record); } + @Override + public int getMoveCollectTaskProcessingCount(Long shopId) { + return moveCollectTaskDetailMapper.getMoveCollectTaskProcessingCount(shopId); + } + @Override public MoveCollectTaskDetail getMoveCollectTaskDetail(long shopId, long moveCollectTaskDetailId) { return moveCollectTaskDetailMapper.selectByPrimaryKey(moveCollectTaskDetailId); diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetMoveHistoryProductListService.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetMoveHistoryProductListService.java index e5d49829..d6d861d3 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetMoveHistoryProductListService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetMoveHistoryProductListService.java @@ -46,11 +46,12 @@ public class GetMoveHistoryProductListService extends SPIBaseService implements condition.setPageSize(fields.getPageSize()); condition.setShopId(shopId); Pager moveCollectTaskPager = moveCollectTaskDetailService.getMoveCollectTaskList(condition); + int processingTaskCount = moveCollectTaskDetailService.getMoveCollectTaskProcessingCount(shopId); Map result = new HashMap<>(); result.put("taskDetailList", moveCollectTaskPager.getData()); result.put("taskTotal", moveCollectTaskPager.getTotal()); - result.put("processingTaskCount", moveCollectTaskPager.getTotal()); + result.put("processingTaskCount", processingTaskCount); result.put("page", moveCollectTaskPager.getPage()); result.put("pageSize", moveCollectTaskPager.getPageSize()); // ----结果返回---- diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java index 53a75b0d..e3db9701 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoByProductId.java @@ -11,8 +11,10 @@ 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.dal.entity.Category; import com.ms.dal.entity.MoveSystemSourceCategory; import lombok.extern.slf4j.Slf4j; import org.phprpc.util.AssocArray; @@ -39,6 +41,9 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi @Autowired private MoveSystemSourceCategoryService moveSystemSourceCategoryService; + @Autowired + private CategoryService categoryService; + @Override public BaseResponse handle(BaseRequest req) { // ----逻辑校验---- @@ -69,14 +74,16 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi String content = moveSystemSourceCategory.getMatchCategoryList(); AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes()); Map assocMap = assocArrayToHash(assocArray); - List assocMapValues = new ArrayList<>(assocMap.values()); - Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1); List assocMapKeys = new ArrayList<>(assocMap.keySet()); - log.info("assocArrayToHash" + inMap.get("path")); log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1)); - product.put("ddCid", inMap.get("path")); - product.put("ddCategoryList", assocMapKeys.get(assocMapKeys.size() - 1)); + Long categoryId = Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1)); + List categoryIds = this.getCategoryIdList(categoryId); + Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1))); + String path = category.getPath(); + List pathArr = Arrays.asList(path.split(">")); + product.put("ddCid", categoryIds); + product.put("ddCategoryList", pathArr); } else { product.put("ddCid", ""); product.put("ddCategoryList", ""); @@ -98,6 +105,17 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi return R.ok(Ret.success(result)); } + private List getCategoryIdList(Long categoryId) { + List 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(); diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java index 536b4f15..93a47fec 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/GetProductInfoService.java @@ -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 handle(BaseRequest 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 assocMapValues = new ArrayList<>(assocMap.values()); - Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1); List 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 categoryIds = this.getCategoryIdList(categoryId); + Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1))); + String path = category.getPath(); + List 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 getCategoryIdList(Long categoryId) { + List 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(); diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/MoveCollectTaskDetailMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/MoveCollectTaskDetailMapper.java index 563e7ec9..9b450eea 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/MoveCollectTaskDetailMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/MoveCollectTaskDetailMapper.java @@ -28,6 +28,8 @@ public interface MoveCollectTaskDetailMapper { Integer getMoveCollectTaskCount(Long shopId, String status); + Integer getMoveCollectTaskProcessingCount(Long shopId); + List getMoveCollectTaskListByDetailIds(Long shopId, List moveCollectTaskDetailIds); List getMoveDetailIdsByStatus(Long shopId, String status); diff --git a/ms-dal/src/main/resources/mapper/MoveCollectTaskDetailMapper.xml b/ms-dal/src/main/resources/mapper/MoveCollectTaskDetailMapper.xml index 371e0d53..ad64047b 100644 --- a/ms-dal/src/main/resources/mapper/MoveCollectTaskDetailMapper.xml +++ b/ms-dal/src/main/resources/mapper/MoveCollectTaskDetailMapper.xml @@ -250,6 +250,11 @@ and status = #{status} +