|
|
@@ -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;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 铲车订单状态统计
|