修改bug

This commit is contained in:
齐天大圣 2024-01-13 16:34:22 +08:00
parent 4a5dcf2c61
commit 8889a06565
2 changed files with 17 additions and 35 deletions

View File

@ -24,6 +24,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -61,39 +62,20 @@ public class OilNumberServiceImpl extends ServiceImpl<OilNumberMapper, OilNumber
@Override @Override
public List<OilPresetPricesVO> selectOilNumberList3(Page page, OilNumber oilNumber) { public List<OilPresetPricesVO> selectOilNumberList3(Page page, OilNumber oilNumber) {
OilNumber oilNumber1 = new OilNumber();
//获取预设油价列表 oilNumber1.setStoreId(oilNumber.getStoreId());
OilPresetPrices oilPresetPrices = new OilPresetPrices(); IPage<OilNumber> oilNumberIPage = selectOilNumberList2(page, oilNumber1);
oilPresetPrices.setStoreId(oilNumber.getStoreId()); List<OilNumber> records = oilNumberIPage.getRecords();
IPage<OilPresetPrices> oilPresetPricesIPage = oilPresetPricesMapper.selectOilPresetPricesList(page, oilPresetPrices); List<OilPresetPricesVO> collect = records.stream().map(s -> {
List<OilPresetPrices> records1 = oilPresetPricesIPage.getRecords();
List<OilPresetPricesVO> collect = records1.stream().map(s -> {
OilPresetPricesVO oilPresetPricesVO = new OilPresetPricesVO(); OilPresetPricesVO oilPresetPricesVO = new OilPresetPricesVO();
//如果预设时间等于当前时间 oilPresetPricesVO.setOilName(s.getOilName());
if (s.getEffectiveTime().equals(DateUtil.format(new Date(), "yyyy-MM-dd"))){ oilPresetPricesVO.setPresetOilPrices(s.getOilPrice());
LambdaQueryWrapper<OilNumber> oilNumberLambdaQueryWrapper = new LambdaQueryWrapper<>(); oilPresetPricesVO.setPresetGbPrice(s.getGbPrice());
oilNumberLambdaQueryWrapper.eq(OilNumber::getStoreId,s.getStoreId()); DecimalFormat decimalFormat = new DecimalFormat("#0.00"); // 设置要显示的小数位数
oilNumberLambdaQueryWrapper.eq(OilNumber::getOilType,s.getOilType());
OilNumber oilNumber1 = this.getOne(oilNumberLambdaQueryWrapper); double v = s.getOilPrice() / s.getGbPrice();
BeanUtils.copyProperties(s,oilPresetPricesVO); String formattedNumber = decimalFormat.format((1-v) * 100);
oilPresetPricesVO.setCurrentPetrolPrices(s.getPresetOilPrices()); oilPresetPricesVO.setRate(formattedNumber + "%");
oilPresetPricesVO.setPresetGbPrice(s.getPresetGbPrice());
//升降率 TODO
oilPresetPricesVO.setOilName(oilNumber1.getOilName());
oilPresetPricesVO.setStatus("1");
oilPresetPricesVO.setRate("0%");
}else {
LambdaQueryWrapper<OilNumber> 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%");
}
return oilPresetPricesVO; return oilPresetPricesVO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return collect; return collect;

View File

@ -23,13 +23,13 @@
<view class="hui-box">政府指导油价()</view> <view class="hui-box">政府指导油价()</view>
<view class="dis-c"> <view class="dis-c">
<view class="dlan">{{item.presetGbPrice}}</view> <view class="dlan">{{item.presetGbPrice}}</view>
<view class="dis"> <u-icon name="arrow-up-fill" color="#FF5700" size="12"></u-icon> <!-- <view class="dis"> <u-icon name="arrow-up-fill" color="#FF5700" size="12"></u-icon>
<text style="font-size: 12px; color: #FF5700; ">{{item.rate}}</text> <text style="font-size: 12px; color: #FF5700; ">{{item.rate}}</text>
</view> </view> -->
</view> </view>
</view> </view>
<view style="width: 50%;"> <view style="width: 50%;">
<view class="hui-box">最新油价</view> <view class="hui-box">本站油价</view>
<view class="dis-c"> <view class="dis-c">
<view class="dlan" style="color: #333333;">{{item.presetOilPrices}}</view> <view class="dlan" style="color: #333333;">{{item.presetOilPrices}}</view>
<view class="dis"> <u-icon name="arrow-down-fill" color="#1FAD40" size="12"></u-icon> <view class="dis"> <u-icon name="arrow-down-fill" color="#1FAD40" size="12"></u-icon>