From 8889a0656537127cf2d73c5a45c55bb5e960ba97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=90=E5=A4=A9=E5=A4=A7=E5=9C=A3?= <17615834396@163.com> Date: Sat, 13 Jan 2024 16:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OilNumberServiceImpl.java | 46 ++++++------------- gasStation-uni/pagesMy/today/today.vue | 6 +-- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilNumberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilNumberServiceImpl.java index 665ed34e5..d5b711337 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilNumberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/petrolStationManagement/service/impl/OilNumberServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -61,39 +62,20 @@ public class OilNumberServiceImpl extends ServiceImpl selectOilNumberList3(Page page, OilNumber oilNumber) { - - //获取预设油价列表 - OilPresetPrices oilPresetPrices = new OilPresetPrices(); - oilPresetPrices.setStoreId(oilNumber.getStoreId()); - IPage oilPresetPricesIPage = oilPresetPricesMapper.selectOilPresetPricesList(page, oilPresetPrices); - List records1 = oilPresetPricesIPage.getRecords(); - List collect = records1.stream().map(s -> { + OilNumber oilNumber1 = new OilNumber(); + oilNumber1.setStoreId(oilNumber.getStoreId()); + IPage oilNumberIPage = selectOilNumberList2(page, oilNumber1); + List records = oilNumberIPage.getRecords(); + List collect = records.stream().map(s -> { OilPresetPricesVO oilPresetPricesVO = new OilPresetPricesVO(); - //如果预设时间等于当前时间 - if (s.getEffectiveTime().equals(DateUtil.format(new Date(), "yyyy-MM-dd"))){ - LambdaQueryWrapper oilNumberLambdaQueryWrapper = new LambdaQueryWrapper<>(); - oilNumberLambdaQueryWrapper.eq(OilNumber::getStoreId,s.getStoreId()); - oilNumberLambdaQueryWrapper.eq(OilNumber::getOilType,s.getOilType()); - OilNumber oilNumber1 = this.getOne(oilNumberLambdaQueryWrapper); - BeanUtils.copyProperties(s,oilPresetPricesVO); - oilPresetPricesVO.setCurrentPetrolPrices(s.getPresetOilPrices()); - oilPresetPricesVO.setPresetGbPrice(s.getPresetGbPrice()); - //升降率 TODO - oilPresetPricesVO.setOilName(oilNumber1.getOilName()); - oilPresetPricesVO.setStatus("1"); - oilPresetPricesVO.setRate("0%"); - }else { - LambdaQueryWrapper oilNumberLambdaQueryWrapper = new LambdaQueryWrapper<>(); - oilNumberLambdaQueryWrapper.eq(OilNumber::getStoreId,oilNumber.getStoreId()); - oilNumberLambdaQueryWrapper.eq(OilNumber::getOilName,s.getOilType()); - OilNumber oilNumber1 = this.getOne(oilNumberLambdaQueryWrapper); - OilName oilName = oilNameService.selectOilNameById(Integer.parseInt(oilNumber1.getOilName())); - oilPresetPricesVO.setPresetOilPrices(oilNumber1.getOilPrice()); - oilPresetPricesVO.setPresetGbPrice(oilNumber1.getGbPrice()); - oilPresetPricesVO.setOilName(oilName.getOilName()); - oilPresetPricesVO.setStatus("1"); - oilPresetPricesVO.setRate("0%"); - } + oilPresetPricesVO.setOilName(s.getOilName()); + oilPresetPricesVO.setPresetOilPrices(s.getOilPrice()); + oilPresetPricesVO.setPresetGbPrice(s.getGbPrice()); + DecimalFormat decimalFormat = new DecimalFormat("#0.00"); // 设置要显示的小数位数 + + double v = s.getOilPrice() / s.getGbPrice(); + String formattedNumber = decimalFormat.format((1-v) * 100); + oilPresetPricesVO.setRate(formattedNumber + "%"); return oilPresetPricesVO; }).collect(Collectors.toList()); return collect; diff --git a/gasStation-uni/pagesMy/today/today.vue b/gasStation-uni/pagesMy/today/today.vue index 07b755edb..62e843542 100644 --- a/gasStation-uni/pagesMy/today/today.vue +++ b/gasStation-uni/pagesMy/today/today.vue @@ -23,13 +23,13 @@ 政府指导油价(元) {{item.presetGbPrice}} - + - 最新油价 + 本站油价 {{item.presetOilPrices}}