Browse Source

铲车司机新增过滤条件接口

donglang 1 month ago
parent
commit
76b8dbd939

+ 2 - 0
sckw-modules-api/sckw-product-api/src/main/java/com/sckw/product/api/dubbo/GoodsInfoService.java

@@ -82,4 +82,6 @@ public interface GoodsInfoService {
     List<KwpGoods> findGoodsByGoodsName(String goodsName);
 
     AddressInfoDetail getGoodsAddress(Long goodsId);
+
+    List<KwpGoods> queryGoodsByEntId(Long entId);
 }

+ 12 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/dubbo/GoodsInfoServiceImpl.java

@@ -190,4 +190,16 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
         goods.setDelFlag(g.getDelFlag());
         return goods;
     }
+
+    @Override
+    public List<KwpGoods> queryGoodsByEntId(Long entId) {
+        List<com.sckw.product.model.KwpGoods> kwpGoods = kwpGoodsRepository.queryGoodsByEntId(entId);
+        if (CollectionUtils.isEmpty(kwpGoods)){
+            return Collections.emptyList();
+        }
+
+        return kwpGoods.stream()
+                .map(GoodsInfoServiceImpl::getKwpGoods)
+                .collect(Collectors.toList());
+    }
 }

+ 6 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/repository/KwpGoodsRepository.java

@@ -39,4 +39,10 @@ public class KwpGoodsRepository extends ServiceImpl<KwpGoodsMapper, KwpGoods> {
                 .eq(KwpGoods::getDelFlag,0)
                 .like(StringUtils.isNotBlank(goodsName),KwpGoods::getName,goodsName));
     }
+
+    public List<KwpGoods> queryGoodsByEntId(Long entId) {
+        return list(Wrappers.<KwpGoods>lambdaQuery()
+                .eq(KwpGoods::getEntId,entId)
+                .eq(KwpGoods::getDelFlag,0));
+    }
 }

+ 18 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/enterpriseApp/AppForkliftController.java

@@ -3,8 +3,10 @@ package com.sckw.transport.controller.enterpriseApp;
 
 import com.sckw.core.web.response.BaseResult;
 import com.sckw.core.web.response.result.PageDataResult;
+import com.sckw.transport.model.param.forklift.reponse.ForkliftOrderFilterResp;
 import com.sckw.transport.model.param.forklift.reponse.ForkliftOrderResp;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderCancelParam;
+import com.sckw.transport.model.param.forklift.request.ForkliftOrderFilterParam;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderQueryParam;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderTakingParam;
 import com.sckw.transport.model.vo.StatisticsWaybillResp;
@@ -18,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * Author: donglang
  * Time: 2026-01-05
@@ -46,6 +50,20 @@ public class AppForkliftController {
         return BaseResult.success(LogisticsOrderList);
     }
 
+    /**
+     * 筛选
+     *
+     * @param param
+     * @return
+     */
+    @Operation(summary = "筛选", description = "筛选")
+    @PostMapping("/filterQuery")
+    public BaseResult<List<ForkliftOrderFilterResp>> filterQuery(@RequestBody @Valid ForkliftOrderFilterParam param){
+        List<ForkliftOrderFilterResp> LogisticsOrderList = forkliftOrderService.filterQuery(param);
+        return BaseResult.success(LogisticsOrderList);
+    }
+
+
     /**
      * 铲车订单状态统计
      *

+ 59 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/forklift/reponse/ForkliftOrderFilterResp.java

@@ -0,0 +1,59 @@
+package com.sckw.transport.model.param.forklift.reponse;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author :chenXiaoFei
+ * @version :1.0
+ * @description : 铲车筛选返回
+ * @create :2025-11-11 20:16:00
+ */
+@Data
+public class ForkliftOrderFilterResp implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5633966065692727347L;
+
+    /**
+     * 商品类别名称
+     */
+    @Schema(description = "商品一级名称")
+    private String groupName;
+
+    /**
+     * 商品类别值
+     */
+    private String groupValue;
+
+    /**
+     * 规格类别
+     */
+    private List<SpecOptionDTO> options = new ArrayList<>();
+
+
+    @Data
+    public static class SpecOptionDTO {
+
+        /**
+         * 类型id
+         */
+        private Long id;
+
+        /**
+         * 名称
+         */
+        private String label;
+
+        /**
+         * 实际值
+         */
+        private String value;
+    }
+
+    }

+ 32 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/forklift/request/ForkliftOrderFilterParam.java

@@ -0,0 +1,32 @@
+package com.sckw.transport.model.param.forklift.request;
+
+import com.sckw.core.web.request.PageReq;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author :donglang
+ * @version :1.0
+ * @description :
+ * @create :2026-01-05 08:59:00
+ */
+@Data
+public class ForkliftOrderFilterParam extends PageReq implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 527604637646248848L;
+
+    /**
+     * 归属企业id
+     */
+    @NotNull(message = "归属企业id不能为空!")
+    @Schema(description = "归属企业id")
+    private Long entId;
+
+
+
+}

+ 89 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/ForkliftOrderService.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sckw.contract.api.RemoteContractService;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.common.enums.enums.ErrorCodeEnum;
 import com.sckw.core.exception.BusinessPlatfromException;
 import com.sckw.core.model.constant.Global;
@@ -17,11 +18,15 @@ import com.sckw.core.web.response.result.PageDataResult;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.OrderUnitInfoDetailVO;
 import com.sckw.product.api.dubbo.GoodsInfoService;
+import com.sckw.product.api.model.KwpGoods;
 import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
 import com.sckw.transport.model.*;
 import com.sckw.transport.model.param.WaybillOrderLoadingParam;
+import com.sckw.transport.model.param.forklift.reponse.ForkliftOrderFilterResp;
 import com.sckw.transport.model.param.forklift.reponse.ForkliftOrderResp;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderCancelParam;
+import com.sckw.transport.model.param.forklift.request.ForkliftOrderFilterParam;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderQueryParam;
 import com.sckw.transport.model.param.forklift.request.ForkliftOrderTakingParam;
 import com.sckw.transport.model.vo.StatisticsWaybillResp;
@@ -371,6 +376,90 @@ public class ForkliftOrderService {
         return forklift;
     }
 
+    /**
+     * 筛选
+     * @param param
+     * @return
+     */
+    public List<ForkliftOrderFilterResp> filterQuery(ForkliftOrderFilterParam param) {
+        log.info("铲车司机列表筛选:{}", JSON.toJSONString(param));
+        // 1.查询归属企业下的商品
+        List<KwpGoods> goodsList = goodsInfoService.queryGoodsByEntId(param.getEntId());
+        if (CollectionUtils.isEmpty(goodsList)) {
+            return Collections.emptyList();
+        }
+
+        // 2.提取商goods_type
+        Set<String> goodsTypeSet = goodsList.stream().map(KwpGoods::getGoodsType).filter(Objects::nonNull).collect(Collectors.toSet());
+
+        // 3.查询出所有商品类型的字典数据
+        List<SysDictResDto> allTypeDictList = remoteSystemService.queryDictByType(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+        // 过滤出当前商品对应的类型
+        List<SysDictResDto> goodsTypeDictList = allTypeDictList.stream()
+                .filter(dict -> goodsTypeSet.contains(dict.getValue()))
+                .collect(Collectors.toList());
+
+        if (CollectionUtils.isEmpty(goodsTypeDictList)) {
+            return Collections.emptyList();
+        }
+
+        // 查询上一级类型
+        List<SysDictResDto> classificationDictList = remoteSystemService.queryDictByType(DictTypeEnum.CLASSIFICATION_TYPE.getType());
+        Map<Long, SysDictResDto> classificationMap = classificationDictList.stream()
+                .collect(Collectors.toMap(SysDictResDto::getId, dict -> dict));
+
+
+        // 5. 查询所有商品规格字典(goods_spec)
+        List<SysDictResDto> specDictList = remoteSystemService.queryDictByType(DictTypeEnum.GOODS_SPEC.getType());
+        Map<String, SysDictResDto> specDictMap = specDictList.stream()
+                .collect(Collectors.toMap(SysDictResDto::getValue, d -> d));
+
+        // 6. 按 classification_type类型分组
+        Map<Long, List<SysDictResDto>> groupByClassification = goodsTypeDictList.stream()
+                .collect(Collectors.groupingBy(SysDictResDto::getParentId));
+
+        // 7. 组装最终返回结果
+        List<ForkliftOrderFilterResp> result = new ArrayList<>();
+        for (Map.Entry<Long, List<SysDictResDto>> entry : groupByClassification.entrySet()) {
+            Long parentId = entry.getKey();
+            List<SysDictResDto> childTypes = entry.getValue();
+
+            SysDictResDto firstType = classificationMap.get(parentId);
+            if (firstType == null) {
+                continue;
+            }
+            // 获取该组下所有规格
+            Set<String> specValues = goodsList.stream()
+                    .filter(g -> childTypes.stream().anyMatch(t -> t.getValue().equals(g.getGoodsType())))
+                    .map(KwpGoods::getSpec)
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toSet());
+
+            List<ForkliftOrderFilterResp.SpecOptionDTO> options = new ArrayList<>();
+            // 规格
+            for (String specValue : specValues) {
+                SysDictResDto spec = specDictMap.get(specValue);
+                if (spec == null) {
+                    continue;
+                }
+                ForkliftOrderFilterResp.SpecOptionDTO opt = new ForkliftOrderFilterResp.SpecOptionDTO();
+                opt.setId(spec.getId());
+                opt.setLabel(spec.getLabel());
+                opt.setValue(spec.getValue());
+                options.add(opt);
+            }
+
+            // 组装返回对象
+            ForkliftOrderFilterResp resp = new ForkliftOrderFilterResp();
+            resp.setGroupName(firstType.getLabel());
+            resp.setGroupValue(firstType.getValue());
+            resp.setOptions(options);
+            result.add(resp);
+        }
+
+        return result;
+
+    }
 
     /**
      * 铲车订单状态统计