当前位置: 首页 > news >正文

怎么做一元抢购网站桂林北站到象鼻山多远

怎么做一元抢购网站,桂林北站到象鼻山多远,广西壮族自治区建设厅网站,哪个网站可以做加工使用场景 拿到了一个商品的list,然后要循环list去获取每个商品的明细#xff0c;由于调用api很依赖于网络#xff0c;一个个执行速度慢#xff0c;所以考虑使用线程去解决。 //根据机器id 获取 所有商品信息 public ListProductResponse productList(MachineConf…使用场景 拿到了一个商品的list,然后要循环list去获取每个商品的明细由于调用api很依赖于网络一个个执行速度慢所以考虑使用线程去解决。 //根据机器id 获取 所有商品信息 public ListProductResponse productList(MachineConfigRequest.Code request) {//一次性查询数据库机器对应的商品listBoolQuery boolQuery new BoolQuery();ListQuery queryList new ArrayList();TermQuery termQuery1 new TermQuery();termQuery1.setFieldName(ProductListConfigEnum.MACHINE_ID.getValue());termQuery1.setTerm(ColumnValue.fromString(request.getMachine_id()));queryList.add(termQuery1);boolQuery.setMustQueries(queryList);MachineCommonTableStore tableStore new MachineCommonTableStore();SearchQuery searchQuery new SearchQuery();searchQuery.setQuery(boolQuery);ListProductResponse searchResponse tableStore.getRowList(searchQuery, ProductResponse.class, ModelEnum.PRODUCT_LIST.getModel(), ModelEnum.PRODUCT_LIST_INDEX.getModel());//根据机器id 和 获取所有的货道信息 key:slot value productInfoMapString, ProductSlotInfo map this.getSlotInfo(request.getMachine_id());//转换为 keyproductId value:slotListMapString, ListProductSlotInfo productSlotMap this.getProductSlotList(map);//不需要更新货架图 直接返回库里面存的if (request.getLabel() 0) {searchResponse.forEach(productResponse - {//根据商品ID获取商品对应的货道listListProductSlotInfo productSlotInfos productSlotMap.get(productResponse.getProduct_id());//塞货道信息和库存this.setSlotAndQuantity(productResponse, productSlotInfos);});return searchResponse.parallelStream().sorted(Comparator.comparing(ProductResponse::getSlot_info)).collect(Collectors.toList());}//根据机器id 调用API 获取所有商品idMachineService service new MachineService();ListProductResponse list service.getProductInventory(request.getMachine_id(), ProductResponse.class);//循环对比 把之前已经配置过赏级的商品的id和赏级塞进去list.forEach(response - searchResponse.stream().filter(row - response.getProduct_id().equals(row.getProduct_id())).forEach(row - {response.setId(row.getId());response.setMarket(row.getMarket());}));ListProductResponse responseList Lists.newArrayList();if (CollectionUtils.isNotEmpty(list)) {ThreadPoolExecutor pool new ThreadPoolExecutor(50, 50, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(100), (r, executor) - {try {executor.getQueue().put(r);} catch (InterruptedException e) {e.printStackTrace();}});list.forEach(response - pool.submit(() - {//调用API 获取商品信息JSONObject object new JSONObject();object.put(CeresonApiEnum.product_id.getValue(), response.getProduct_id());String json RobotShopClient.callApiGet(CallMachineShopApiConstants.GET_PRODUCT_BY_ID, object.toJSONString());JSONObject jsonObject JSON.parseObject(json);String data jsonObject.getString(CeresonApiEnum.data.getValue());JSONObject js JSON.parseObject(data);String productStr js.getString(CeresonApiEnum.product.getValue());//把API获取的商品信息转换为ObjProductResponse productResponse JSON.parseObject(productStr, ProductResponse.class);//根据商品ID获取商品对应的货道listListProductSlotInfo productSlotInfos productSlotMap.get(response.getProduct_id());//塞货道信息和库存this.setSlotAndQuantity(productResponse, productSlotInfos);responseList.add(productResponse);}));boolean allThreadsIsDone pool.getTaskCount() pool.getCompletedTaskCount();while (!allThreadsIsDone) {allThreadsIsDone pool.getTaskCount() pool.getCompletedTaskCount();}pool.shutdown();}return responseList.parallelStream().sorted(Comparator.comparing(ProductResponse::getSlot_info)).collect(Collectors.toList()); }public PageResponseAuctionListByUserIdResponse getAuctionListByUserId(AuctionRequest.GetAuctionByUserId request) {AuctionTableStore auctionTableStore new AuctionTableStore();ListQuery list new ArrayList();BoolQuery boolQuery new BoolQuery();BoolQuery shouldQuery new BoolQuery();ListSort.Sorter sorter TableStoreTemplate.getSorter(request.getSort());PageResponseAuctionListByUserIdResponse pageResponse new PageResponse();try {pageResponse auctionTableStore.queryAll(request.getNextToken(), sorter, boolQuery, request.getLimit(),AuctionListByUserIdResponse.class);} catch (Exception e) {log.error(getAuctionList failed exception {}, e);throw new BaseException(ResponseCode.Bad_Request.getCode(), 查询失败);}ListAuctionListByUserIdResponse auctionListByUserIdResponses pageResponse.getData();if (null ! auctionListByUserIdResponses auctionListByUserIdResponses.size() 0) {ThreadPoolExecutor pool new ThreadPoolExecutor(auctionListByUserIdResponses.size(), auctionListByUserIdResponses.size(), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new RejectedExecutionHandler() {Overridepublic void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {try {executor.getQueue().put(r);} catch (InterruptedException e) {e.printStackTrace();}}});String robotSign ##robot;auctionListByUserIdResponses.forEach(response - {pool.submit(new Runnable() {Overridepublic void run() {String sellerId response.getSellerId();String buyerId response.getBuyerId();String auctionId response.getId();String twr ;/* 处理是否为机器人 robotSign */if (buyerId.endsWith(robotSign) || sellerId.endsWith(robotSign)) {twr 是;} else {twr 否;}response.setWhetherRobot(twr);response.setAuctionGoodsList(getGoodsRangeByAuctionId(sellerId, auctionId, DeleteFlagEnum.DELETE));response.setAuctionBidGoodsList(getGoodsRangeByAuctionId(buyerId, auctionId, DeleteFlagEnum.DELETE));response.setCostPrice(getTotalCostPrice(response.getAuctionGoodsList()));}});});boolean allThreadsIsDone pool.getTaskCount() pool.getCompletedTaskCount();while (!allThreadsIsDone) {allThreadsIsDone pool.getTaskCount() pool.getCompletedTaskCount();}pool.shutdown();}for (AuctionListByUserIdResponse info : pageResponse.getData()){System.out.println(info.getTransactionPrice() , info.getCostPrice());}return pageResponse; }
http://www.dnsts.com.cn/news/170200.html

相关文章:

  • 十一冶建设集团有限责任公司网站注册公司分类大全
  • 婚纱摄影网站设计论文域名已买 可以找其它人做网站吗
  • 深圳建网站有哪些公司蚌埠做网站
  • 重庆网站优化公司哪家便宜深圳前十设计公司
  • 济南网站建设方案聊城网站建设工作室
  • 网站开发的费用是怎么计算的wordpress屏蔽右键
  • 网站设计步骤的教学设计信息系统软件有哪些
  • 百度怎样建立网站四川 优质高职建设网站
  • 如何做好网站需求分析百度宁波运营中心
  • 网站建设使用工具wordpress菜单跳转页面
  • cms站群管理系统江汉建站公司
  • 有什么手机做网站的杭州网站推广与优化
  • 南宁网络企业网站淘宝客app开发
  • 网站开发 策划是干嘛的网站商城建站
  • 张槎网站开发网站界面设计的优点
  • 企业网站开发设计杭州网站制作方法
  • 做盗版电影网站赚钱手机版网站如何制作软件
  • 公司网站是怎么样的做网站和软件有区别吗
  • 网站建设 百度云wordpress选择菜单
  • 网站专题页是什么模板网站系统
  • 已经建网站做外贸湖南网站制作公司
  • 茶叶网站建站wordpress支付宝收银台
  • 网站制作价格行情新网站怎么做论坛推广
  • 做兼职的网站有哪些兰州新站点seo加盟
  • 做图字体网站wordpress 图片说明
  • 有edi证书可以做网站运营么手机网站导航栏如何做
  • 建立网站商城建议百度pc权重
  • 朗格手表网站寿光网站建设m0536
  • 建网站源码建站详解企业门户网站的建设与实现
  • 网站上怎么做推广比较好呢怎样注册公司流程