From 8d7dbd6d2c0775d45043474c1525ad827b4cd3bd Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期四, 31 八月 2023 11:59:55 +0800 Subject: [PATCH] 用户端代码 49码头 --- src/main/java/com/stylefeng/guns/modular/system/service/impl/TCompanyServiceImpl.java | 57 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/stylefeng/guns/modular/system/service/impl/TCompanyServiceImpl.java b/src/main/java/com/stylefeng/guns/modular/system/service/impl/TCompanyServiceImpl.java index 30b60d9..eee3801 100644 --- a/src/main/java/com/stylefeng/guns/modular/system/service/impl/TCompanyServiceImpl.java +++ b/src/main/java/com/stylefeng/guns/modular/system/service/impl/TCompanyServiceImpl.java @@ -85,15 +85,11 @@ tCompanyCalculationRespOne.setPickupStr(tOrder.getAccessorialStr()); tCompanyCalculationRespOne.setDestinationStr(tOrder.getDeliveryStr()); tCompanyCalculationRespOne.setCustomer(user.getCompanyName()); - - + System.out.println(quote.getCreateId()); if(quote.getCreateId()!=null){ - User user1 = userMapper.selectById(quote.getCreateId()); - tCompanyCalculationRespOne.setCreateUser(user1.getName()); - }else { - tCompanyCalculationRespOne.setCreateUser(user.getCompanyName()); + TCompany company = companyMapper.selectById(quote.getCreateId()); + tCompanyCalculationRespOne.setCreateUser(company.getName()); } - Integer port = tOrder.getPort(); TPort tPort = tPortMapper.selectById(port); TCountry tCountry = tCountryMapper.selectById(tPort.getCity()); @@ -117,12 +113,13 @@ ArrayList<LonLat> lonLats = new ArrayList<>(); LonLat latLng = new LonLat(); - latLng.setLat("-113.6510249618184"); - latLng.setLng("37.8924429618184"); + latLng.setLat(orders1.get(0).getStartLat()); + latLng.setLng(orders1.get(0).getStartLon()); lonLats.add(latLng); latLng=new LonLat(); - latLng.setLat("-113.066919618184"); - latLng.setLng("37.684389618184"); + GeocodeVo geocode = googleMapUtil.getGeocode(orders1.get(0).geteAddress()); + latLng.setLat(String.valueOf(geocode.getLat())); + latLng.setLng(String.valueOf(geocode.getLng())); lonLats.add(latLng); tCompanyCalculationRespOne.setLonLats(lonLats); ArrayList<TGoods> tGoods = new ArrayList<>(); @@ -136,6 +133,13 @@ ArrayList<CompanyInfo> companyInfos = new ArrayList<>(); for (TOrder order : orders) { + + Integer port1 = order.getPort(); + // 获取码头的上级id + TPort tPort1 = tPortMapper.selectById(port1); + TCountry tCountry2 = tCountryMapper.selectById(tPort1.getCity()); + + CompanyInfo tCompanyCalculationResp = new CompanyInfo(); // 查询公司 TCompany company = companyMapper.selectById(order.getCompanyId()); @@ -146,16 +150,18 @@ tCompanyCalculationResp.setExpirationDate(company.getExpirationTime()); // 查询公司下的价格集合 - List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId())); + List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", order.getId()).eq("status",1)); List<TCompanyResp> tCompanyRespList = new ArrayList<>(); for (TPrice price : prices) { TCompanyResp tCompanyResp = new TCompanyResp(); tCompanyResp.setOrderId(order.getId()); tCompanyResp.setName(price.getType()); + tCompanyResp.setAdminPrice(price.getPrice()); tCompanyResp.setPrice(price.getCarPrice()); + tCompanyResp.setDay(price.getDay()); tCompanyRespList.add(tCompanyResp); } - BigDecimal bigDecimal = tCompanyRespList.stream().map(e->e.getPrice()==null?new BigDecimal(0):e.getPrice()).reduce(BigDecimal::add).orElse(new BigDecimal(0.00)); + BigDecimal bigDecimal = tCompanyRespList.stream().map(TCompanyResp::getAdminPrice).reduce(BigDecimal::add).orElse(new BigDecimal(0.00)); tCompanyCalculationResp.setAllTotal(bigDecimal); tCompanyCalculationResp.setList(tCompanyRespList); // 过滤订单 @@ -173,10 +179,30 @@ companyInfos.add(tCompanyCalculationResp); } ArrayList<CompanyInfo> collect = companyInfos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CompanyInfo::getCompanyId))), ArrayList::new)); + for (CompanyInfo companyInfo : collect) { + Map<String, BigDecimal> map = new HashMap<>(); + List<CompanyInfo> collect1 = companyInfos.stream().filter(e -> e.getCompanyId().equals(companyInfo.getCompanyId())).collect(Collectors.toList()); + BigDecimal bigDecimal1 = collect1.stream().map(CompanyInfo::getAllTotal).reduce(BigDecimal::add).get(); + companyInfo.setAllTotal(bigDecimal1); + for (CompanyInfo info : collect1) { + List<TCompanyResp> list = info.getList(); + for (TCompanyResp tCompanyResp : list) { + Object o = map.get(tCompanyResp.getName()); + if(o!=null){ + map.put(tCompanyResp.getName(),new BigDecimal(o.toString()).add(tCompanyResp.getAdminPrice())); + }else { + map.put(tCompanyResp.getName(),tCompanyResp.getAdminPrice()); + } + } + } + List<TCompanyResp> list = companyInfo.getList(); + for (TCompanyResp tCompanyResp : list) { + tCompanyResp.setAdminPrice(map.get(tCompanyResp.getName())); + } + } tCompanyCalculationRespOne.setCompanyInfos(collect); return tCompanyCalculationRespOne; } - @Override public TCompanyCalculationRespOne getQuotaFromIdAndCompanyId(Long id, Integer companyIds) { TQuote quote = quoteService.selectById(id); @@ -255,9 +281,10 @@ tCompanyResp.setOrderId(order.getId()); tCompanyResp.setName(price.getType()); tCompanyResp.setPrice(price.getPrice()); + tCompanyResp.setAdminPrice(price.getPrice()); tCompanyRespList.add(tCompanyResp); } - BigDecimal bigDecimal = tCompanyRespList.stream().map(TCompanyResp::getPrice).reduce(BigDecimal::add).orElse(new BigDecimal(0.00)); + BigDecimal bigDecimal = tCompanyRespList.stream().map(TCompanyResp::getAdminPrice).reduce(BigDecimal::add).orElse(new BigDecimal(0.00)); tCompanyCalculationResp.setAllTotal(bigDecimal); tCompanyCalculationResp.setList(tCompanyRespList); // 过滤订单 -- Gitblit v1.7.1