diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/controller/ShopMaterialStoreController.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/controller/ShopMaterialStoreController.java index 2750303c..46f2db9e 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/controller/ShopMaterialStoreController.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/controller/ShopMaterialStoreController.java @@ -46,6 +46,14 @@ public class ShopMaterialStoreController { shopMaterialStoreService.queryShopMaterialById(inputObject, outputObject); } + @ApiOperation(id = "queryShopMaterialByIds", value = "根据id批量获取商城商品信息", method = "POST", allUse = "0") + @ApiImplicitParams(value = { + @ApiImplicitParam(id = "ids", name = "ids", value = "主键id,多个逗号隔开", required = "required")}) + @RequestMapping("/post/ShopMaterialStoreController/queryShopMaterialByIds") + public void queryShopMaterialByIds(InputObject inputObject, OutputObject outputObject) { + shopMaterialStoreService.queryShopMaterialByIds(inputObject, outputObject); + } + @ApiOperation(id = "queryShopMaterialByMaterialIdAndStoreId", value = "根据商品id和门店id获取商城商品信息", method = "GET", allUse = "0") @ApiImplicitParams(value = { @ApiImplicitParam(id = "materialId", name = "materialId", value = "商品id", required = "required"), diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java index 67a2e135..3ccbe4fa 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/ShopMaterialStoreService.java @@ -48,4 +48,6 @@ public interface ShopMaterialStoreService extends SkyeyeBusinessService> queryShopMaterialListByStoreIds(List storeIds); + + void queryShopMaterialByIds(InputObject inputObject, OutputObject outputObject); } diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java index 860c82ca..0aa0218d 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/shopmaterial/service/impl/ShopMaterialStoreServiceImpl.java @@ -13,6 +13,7 @@ import com.github.pagehelper.PageHelper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.skyeye.annotation.service.SkyeyeService; import com.skyeye.base.business.service.impl.SkyeyeBusinessServiceImpl; +import com.skyeye.common.constans.CommonCharConstants; import com.skyeye.common.constans.CommonNumConstants; import com.skyeye.common.entity.search.CommonPageInfo; import com.skyeye.common.object.InputObject; @@ -34,6 +35,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -203,6 +205,39 @@ public class ShopMaterialStoreServiceImpl extends SkyeyeBusinessServiceImpl idList = Arrays.asList(ids.split(CommonCharConstants.COMMA_MARK)) + .stream().filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList()); + if (CollectionUtil.isEmpty(idList)) { + return; + } + List shopMaterialStoreList = selectByIds(idList.toArray(new String[]{})); + Map storeMap = shopMaterialStoreList.stream() + .collect(Collectors.toMap(ShopMaterialStore::getMaterialId, Function.identity(), (v1, v2) -> v1)); + + List materialIds = shopMaterialStoreList.stream() + .map(ShopMaterialStore::getMaterialId).distinct().collect(Collectors.toList()); + Map shopMaterialMap = shopMaterialService.queryShopMaterialByMaterialId(materialIds); + List shopMaterialList = shopMaterialMap.values().stream().collect(Collectors.toList()); + shopMaterialList.forEach(shopMaterial -> { + shopMaterial.getMaterialMation().setMaterialNorms(null); + shopMaterial.getMaterialMation().setUnitGroupMation(null); + shopMaterial.getMaterialMation().setMaterialProcedure(null); + shopMaterial.getMaterialMation().setNormsSpec(null); + shopMaterial.getShopMaterialNormsList().forEach(shopMaterialNorms -> { + shopMaterialNorms.setEstimatePurchasePrice(null); + }); + // 门店商品数据 + ShopMaterialStore shopMaterialStore = storeMap.get(shopMaterial.getMaterialId()); + shopMaterial.setShopMaterialStore(shopMaterialStore); + shopMaterial.setDefaultStoreId(shopMaterialStore.getStoreId()); + }); + outputObject.setBeans(shopMaterialList); + outputObject.settotal(shopMaterialList.size()); + } + @Override public void queryShopMaterialByMaterialIdAndStoreId(InputObject inputObject, OutputObject outputObject) { Map params = inputObject.getParams(); diff --git a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/rest/IShopMaterialNormsRest.java b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/rest/IShopMaterialNormsRest.java index 2d909d09..1d2e7a69 100644 --- a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/rest/IShopMaterialNormsRest.java +++ b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/rest/IShopMaterialNormsRest.java @@ -27,6 +27,15 @@ public interface IShopMaterialNormsRest { @PostMapping("/queryShopMaterialByMaterialIdList") String queryShopMaterialByMaterialIdList(@RequestParam("materialIds") String materialIds); + /** + * 根据id批量获取商城商品信息 + * + * @param ids 主键id,多个逗号隔开 + * @return + */ + @PostMapping("/queryShopMaterialByIds") + String queryShopMaterialByIds(@RequestParam("ids") String ids); + /** * 新增门店时,将所有商品同步到该门店 * diff --git a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/IShopMaterialNormsService.java b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/IShopMaterialNormsService.java index 289c4621..075f871b 100644 --- a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/IShopMaterialNormsService.java +++ b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/IShopMaterialNormsService.java @@ -20,5 +20,13 @@ public interface IShopMaterialNormsService { List> queryShopMaterialByMaterialIdList(String materialIds); + /** + * 根据id批量获取商城商品信息 + * + * @param ids 商城商品materialId与storeId的关系id + * @return + */ + List> queryShopMaterialByIds(List ids); + List> queryAllShopMaterialListForChoose(); } \ No newline at end of file diff --git a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/service/IShopMaterialNormsServiceImpl.java b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/service/IShopMaterialNormsServiceImpl.java index 340bda50..678abd71 100644 --- a/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/service/IShopMaterialNormsServiceImpl.java +++ b/skyeye-shop/shop-common/src/main/java/com/skyeye/rest/shopmaterialnorms/sevice/service/IShopMaterialNormsServiceImpl.java @@ -4,16 +4,22 @@ package com.skyeye.rest.shopmaterialnorms.sevice.service; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import com.google.common.base.Joiner; import com.skyeye.base.rest.service.impl.IServiceImpl; import com.skyeye.common.client.ExecuteFeignClient; +import com.skyeye.common.constans.CommonCharConstants; import com.skyeye.common.object.ResultEntity; import com.skyeye.rest.shopmaterialnorms.rest.IShopMaterialNormsRest; import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @ClassName: IShopMaterialNormsServiceImpl @@ -43,6 +49,21 @@ public class IShopMaterialNormsServiceImpl extends IServiceImpl implements IShop return rows; } + @Override + public List> queryShopMaterialByIds(List ids) { + if (ids == null) { + return new ArrayList<>(); + } + ids = ids.stream().filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList()); + if (CollectionUtil.isEmpty(ids)) { + return new ArrayList<>(); + } + String joinIds = Joiner.on(CommonCharConstants.COMMA_MARK).join(ids); + ResultEntity resultEntity = ExecuteFeignClient.get(() -> iShopMaterialNormsRest.queryShopMaterialByIds(joinIds)); + List> rows = resultEntity.getRows(); + return rows; + } + @Override public List> queryAllShopMaterialListForChoose() { ResultEntity resultEntity = ExecuteFeignClient.get(() -> iShopMaterialNormsRest.queryAllShopMaterialListForChoose());