// 封装返回对象
        String bizDataStr = bizMessage.getBizDataStr();
        ConSellerGoods conSellerGoods = JsonUtil.fromJson(bizDataStr, ConSellerGoods.class);
        // 获取商家编码和商品编码,查询所有设备商品信息
        GoodsBoxDto goodsBoxDto = new GoodsBoxDto();
        goodsBoxDto.setSellerNo(conSellerGoods.getSellerNo());
        ArrayList<String> listSkus = new ArrayList<>();
        listSkus.add(conSellerGoods.getGoodsNo());
        goodsBoxDto.setSkuList(listSkus);
        Result result = conBoxGoodsService.getBoxGoodsList(goodsBoxDto);
        if (result.isSuccess()) {
            List<ConBoxGoods> conBoxGoodsList =
                    (List<ConBoxGoods>) result.get(BaseConstants.SERVICE_RESULT_SUCCESS_CODE);
            // 设备列表-根据商家和设备查询设备商品列表
//            List<GoodsBoxDto> listSellerBox = conBoxGoodsList.stream()
//                    .map(e -> new GoodsBoxDto(e.getSellerNo(), e.getBoxNo()))
//                    .collect(Collectors.toList());
            List<String> listBoxNos=conBoxGoodsList.stream().map(p->p.getBoxNo()).collect(Collectors.toList());
            UIGoodsBoxDto uiGoodsBoxDto = new UIGoodsBoxDto();
            uiGoodsBoxDto.setSellerNo(conSellerGoods.getSellerNo());
            uiGoodsBoxDto.setListBoxNos(listBoxNos);
            Result boxGoodsListByListResult = conBoxGoodsService.getBoxGoodsListByListDto(uiGoodsBoxDto);
            // 根据商家和设备分组
            List<ConBoxGoods> conBoxGoodsList2 =
                    (List<ConBoxGoods>) boxGoodsListByListResult.get(BaseConstants.SERVICE_RESULT_SUCCESS_CODE);
            Map<String, List<ConBoxGoods>> listSellerBox2 =
                    conBoxGoodsList2.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e)));
            ICRBoxListRequestDto icrBoxListRequestDto = new ICRBoxListRequestDto();
            ArrayList<ICRSkuRequestDto> icrSkuRequestDtoArrayList = new ArrayList<>();

 

@Override
    public Result updateConSellerGoodsPriceMqDeal(BizMessage bizMessage) throws Exception {
        // 封装返回对象
        String bizDataStr = bizMessage.getBizDataStr();
        ConSellerGoods conSellerGoods = JsonUtil.fromJson(bizDataStr, ConSellerGoods.class);
        // 获取商家编码和商品编码,查询所有设备商品信息
        GoodsBoxDto goodsBoxDto = new GoodsBoxDto();
        goodsBoxDto.setSellerNo(conSellerGoods.getSellerNo());
        ArrayList<String> listSkus = new ArrayList<>();
        listSkus.add(conSellerGoods.getGoodsNo());
        goodsBoxDto.setSkuList(listSkus);
        Result result = conBoxGoodsService.getBoxGoodsList(goodsBoxDto);
        if (result.isSuccess()) {
            List<ConBoxGoods> conBoxGoodsList =
                    (List<ConBoxGoods>) result.get(BaseConstants.SERVICE_RESULT_SUCCESS_CODE);
            // 设备列表-根据商家和设备list查询设备商品列表
            List<String> listBoxNos=conBoxGoodsList.stream().map(p->p.getBoxNo()).collect(Collectors.toList());
            UIGoodsBoxDto uiGoodsBoxDto = new UIGoodsBoxDto();
            uiGoodsBoxDto.setSellerNo(conSellerGoods.getSellerNo());
            uiGoodsBoxDto.setListBoxNos(listBoxNos);
            Result boxGoodsListResult = conBoxGoodsService.getBoxGoodsListByListDto(uiGoodsBoxDto);
            // 根据商家和设备分组
            List<ConBoxGoods> conBoxGoodsListNew =
                    (List<ConBoxGoods>) boxGoodsListResult.get(BaseConstants.SERVICE_RESULT_SUCCESS_CODE);
            // 设备对应商品信息
            Map<String, List<ConBoxGoods>> listSellerBoxMap =
                    conBoxGoodsListNew.stream().collect(Collectors.groupingBy(e -> e.getBoxNo()));


            // 组装数据
            ICRBoxListRequestDto icrBoxListRequestDto = new ICRBoxListRequestDto();
            ArrayList<ICRSkuRequestDto> icrSkuRequestDtoArrayList = new ArrayList<>();
            icrBoxListRequestDto.setListICRDto(icrSkuRequestDtoArrayList);
            for (String key : listSellerBoxMap.keySet()) {

                ICRSkuRequestDto icrSkuRequestDto = new ICRSkuRequestDto();
                List<GoodsBoxPushDto> goodsBoxPushDtoList = new ArrayList<GoodsBoxPushDto>();
                icrSkuRequestDto.setSellerNo(conSellerGoods.getSellerNo());
                icrSkuRequestDto.setDeviceId(key);
                icrSkuRequestDto.setSkuList(goodsBoxPushDtoList);
                icrSkuRequestDtoArrayList.add(icrSkuRequestDto);
                // 组装商品
                List<ConBoxGoods> conBoxGoodList =(List<ConBoxGoods>)listSellerBoxMap.get(key);
                goodsBoxPushDtoList=conBoxGoodsList.stream().
                        map(e -> new GoodsBoxPushDto(e.getGoodsNo(), e.getGoodsName(),
                                e.getRealtimePrice(),e.getGoodsStatus())).collect(Collectors.toList());

            }
            // 开始签名,并推送
            String uuid = UUID.randomUUID().toString();
            TaskToken token = new TaskToken();
            token.setUuid(uuid);                                            //uuid
            token.setBizNo(uuid);                                            //业务编号
            token.setBizType(GoodsConstants.pushGoodsListToIRC);              //任务类型
            token.setOperatorName(CommonConfig.User_IRC);                        //操作人/操作系统
            token.setCallCode(CommonConfig.User_IRC);
            token.setTaskJson(JsonUtil.toJson(icrBoxListRequestDto));
            String sign = SignValidata.createSign(token, CommonConfig.IRC_Key);
            token.setSign(sign);//签名
            BaseDto baseDto = centerClient.receiveTask(token);
            System.out.println(baseDto);
        }
        return null;
    }

 

posted on 2020-03-21 17:03  王洪洪  阅读(139)  评论(0编辑  收藏  举报