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

网上做任务赚钱网站有哪些站长之家新网址

网上做任务赚钱网站有哪些,站长之家新网址,dw做网站,wordpress连接网盘插件使用场景 拿到了一个商品的list,然后要循环list去获取每个商品的明细&#xff0c;由于调用api很依赖于网络&#xff0c;一个个执行速度慢&#xff0c;所以考虑使用线程去解决。 //根据机器id 获取 所有商品信息 public List<ProductResponse> productList(MachineConf…

使用场景

拿到了一个商品的list,然后要循环list去获取每个商品的明细,由于调用api很依赖于网络,一个个执行速度慢,所以考虑使用线程去解决。

//根据机器id  获取 所有商品信息
public List<ProductResponse> productList(MachineConfigRequest.Code request) {//一次性查询数据库机器对应的商品listBoolQuery boolQuery = new BoolQuery();List<Query> 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);List<ProductResponse> searchResponse = tableStore.getRowList(searchQuery, ProductResponse.class, ModelEnum.PRODUCT_LIST.getModel(), ModelEnum.PRODUCT_LIST_INDEX.getModel());//根据机器id 和 获取所有的货道信息  key:slot value productInfoMap<String, ProductSlotInfo> map = this.getSlotInfo(request.getMachine_id());//转换为 key:productId value:slotListMap<String, List<ProductSlotInfo>> productSlotMap = this.getProductSlotList(map);//不需要更新货架图 直接返回库里面存的if (request.getLabel() == 0) {searchResponse.forEach(productResponse -> {//根据商品ID获取商品对应的货道listList<ProductSlotInfo> 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();List<ProductResponse> 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());}));List<ProductResponse> 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获取商品对应的货道listList<ProductSlotInfo> 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 PageResponse<AuctionListByUserIdResponse> getAuctionListByUserId(AuctionRequest.GetAuctionByUserId request) {AuctionTableStore auctionTableStore = new AuctionTableStore();List<Query> list = new ArrayList<>();BoolQuery boolQuery = new BoolQuery();BoolQuery shouldQuery = new BoolQuery();List<Sort.Sorter> sorter = TableStoreTemplate.getSorter(request.getSort());PageResponse<AuctionListByUserIdResponse> 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(), "查询失败!");}List<AuctionListByUserIdResponse> 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.mmbaike.com/news/37358.html

相关文章:

  • 网站建设 设计提成谷歌推广开户多少费用
  • 邹平网站开发江西seo推广
  • php网站导航精准信息300099
  • java 建网站seo怎么快速提高排名
  • 邯郸市市长公司官网优化方案
  • 乌兰察布建设局网站swot分析
  • 网站建设都用哪个好现在有哪些培训学校
  • ppt做的好的网站有哪些软文代理平台
  • 国资委两学一做网站怎么进入百度推广账户
  • 南京公司网站建设个人网站制作教程
  • 金融系统网站模板北京疫情最新消息情况
  • 网站建设的活怎么接近期舆情热点事件
  • 如何查找昆明做网站服务的公司sem专员
  • 可做用户密码暴力破解测试的网站新乡网站优化公司推荐
  • 做图片能去哪些网站免费推广网站排行榜
  • 网页设计师常用网站建站系统源码
  • 做网站运营的要求网络营销推广有哪些方法
  • 做网站是什么软件app下载
  • 教师做网站赚钱百度网盘客户端
  • 手机网站制作关联词有哪些三年级
  • 深圳市做网站公司好用的网站推荐
  • 我做的网站怎么是危险网站网站模板大全
  • 品牌网站的目的镇江网站建设推广
  • 网站数据库丢失百度公司好进吗
  • 体检营销型网站微博上如何做网站推广
  • 业务代刷平台网站怎么做seo网站有优化培训班吗
  • 案例网站模板_案例网站长工具app官方下载
  • 环境设计网站推荐爱站网站长百度查询权重
  • 做58同城这样的网站快速排名刷
  • 个人网页的代码优化网站seo