提交 170f2e79 authored 作者: 吕本才's avatar 吕本才

1、百分比2、文件名称优化

上级 518f4779
...@@ -3,10 +3,8 @@ package com.ruoyi.web.controller.dealer; ...@@ -3,10 +3,8 @@ package com.ruoyi.web.controller.dealer;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dealer.domain.DealerBaseInfo; import com.ruoyi.dealer.domain.DealerBaseInfo;
import com.ruoyi.dealer.domain.dto.WechatDealerRoundInfoReq; import com.ruoyi.dealer.domain.dto.WechatDealerRoundInfoReq;
import com.ruoyi.dealer.service.DealerRoundInfoService; import com.ruoyi.dealer.service.DealerRoundInfoService;
...@@ -15,9 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -15,9 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/** /**
* 经销商信息Controller * 经销商信息Controller
* *
...@@ -34,23 +29,23 @@ public class DealerBaseInfoController extends BaseController { ...@@ -34,23 +29,23 @@ public class DealerBaseInfoController extends BaseController {
/** /**
* 查询经销商信息列表 * 查询经销商信息列表
*/ */
@GetMapping("/list") // @GetMapping("/list")
public TableDataInfo list(DealerBaseInfo dealerBaseInfo) { // public TableDataInfo list(DealerBaseInfo dealerBaseInfo) {
startPage(); // startPage();
List<DealerBaseInfo> list = dealerBaseInfoService.queryList(dealerBaseInfo); // List<DealerBaseInfo> list = dealerBaseInfoService.queryList(dealerBaseInfo);
return getDataTable(list); // return getDataTable(list);
} // }
/** /**
* 导出经销商信息列表 * 导出经销商信息列表
*/ */
@Log(title = "经销商信息", businessType = BusinessType.EXPORT) // @Log(title = "经销商信息", businessType = BusinessType.EXPORT)
@GetMapping("/export") // @GetMapping("/export")
public AjaxResult export(DealerBaseInfo dealerBaseInfo) { // public AjaxResult export(DealerBaseInfo dealerBaseInfo) {
List<DealerBaseInfo> list = dealerBaseInfoService.queryList(dealerBaseInfo); // List<DealerBaseInfo> list = dealerBaseInfoService.queryList(dealerBaseInfo);
ExcelUtil<DealerBaseInfo> util = new ExcelUtil<DealerBaseInfo>(DealerBaseInfo.class); // ExcelUtil<DealerBaseInfo> util = new ExcelUtil<DealerBaseInfo>(DealerBaseInfo.class);
return util.exportExcel(list, "dealerBaseInfo"); // return util.exportExcel(list, "dealerBaseInfo");
} // }
/** /**
* 获取经销商当前轮次的详细信息 * 获取经销商当前轮次的详细信息
...@@ -82,11 +77,11 @@ public class DealerBaseInfoController extends BaseController { ...@@ -82,11 +77,11 @@ public class DealerBaseInfoController extends BaseController {
/** /**
* 删除经销商信息 * 删除经销商信息
*/ */
@Log(title = "经销商信息", businessType = BusinessType.DELETE) // @Log(title = "经销商信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{dealerBaseInfoIds}") // @DeleteMapping("/{dealerBaseInfoIds}")
public AjaxResult remove(@PathVariable Long[] dealerBaseInfoIds) { // public AjaxResult remove(@PathVariable Long[] dealerBaseInfoIds) {
return toAjax(dealerBaseInfoService.removeByIds(Arrays.asList(dealerBaseInfoIds))); // return toAjax(dealerBaseInfoService.removeByIds(Arrays.asList(dealerBaseInfoIds)));
} // }
} }
package com.ruoyi.web.controller.dealer; package com.ruoyi.web.controller.dealer;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
...@@ -108,7 +109,8 @@ public class DealerBigScreenController extends BaseController { ...@@ -108,7 +109,8 @@ public class DealerBigScreenController extends BaseController {
// 设置响应头 // 设置响应头
response.setContentType("application/zip"); response.setContentType("application/zip");
String encodedFileName = URLEncoder.encode("竞拍分组结果.zip", "UTF-8"); String fileName = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + "竞拍分组结果.zip";
String encodedFileName = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\""); response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"");
// 输出 ZIP 文件内容到浏览器 // 输出 ZIP 文件内容到浏览器
......
package com.ruoyi.common.utils; package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/** /**
* 处理结果中的百分比计算,处理小数点问题 * 处理结果中的百分比计算,处理小数点问题
*/ */
public class NumberUtil { public class NumberUtil {
/**
* 格式化数字字符串:60则返回"60",其他数字保留两位小数
* @param numStr 输入的数字字符串(如"69.0112"、"60"、"60.00")
* @return 处理后的字符串
*/
/**
* 格式化数字字符串:纯整数(无小数点)保持原样,含小数点的格式化为两位小数
* @param numStr 输入的数字字符串(如"60"、"69.0112"、"60.0")
* @return 处理后的字符串
*/
public static String formatNumber(String numStr, int scale) {
// 校验输入合法性
if (numStr == null || numStr.trim().isEmpty()) {
throw new IllegalArgumentException("输入字符串不能为空");
}
// 去除首尾空格,判断是否为纯整数(无小数点)
String trimmedStr = numStr.trim();
if (!trimmedStr.contains(".")) {
// 纯整数(无小数点):直接返回trim后的字符串
return trimmedStr;
}
// 含小数点的字符串:解析为数字并格式化为两位小数
try {
BigDecimal number = new BigDecimal(trimmedStr);
// 保留两位小数,四舍五入
BigDecimal formatted = number.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros();
return formatted.toPlainString();
} catch (NumberFormatException e) {
throw new IllegalArgumentException("输入不是有效的数字格式:" + numStr, e);
}
}
} }
...@@ -18,6 +18,6 @@ public class DealerBigScreenGroupResultDto { ...@@ -18,6 +18,6 @@ public class DealerBigScreenGroupResultDto {
/** /**
* 达成率 * 达成率
*/ */
private Double paymentPercentage; private String paymentPercentage;
} }
...@@ -60,7 +60,7 @@ public class DealerBaseInfoImpl extends ServiceImpl<DealerBaseInfoMapper, Dealer ...@@ -60,7 +60,7 @@ public class DealerBaseInfoImpl extends ServiceImpl<DealerBaseInfoMapper, Dealer
// 获取支付百分比 保留两位小数点 // 获取支付百分比 保留两位小数点
roundInfoRes.setPaymentPercentage( getPercentage(dealerBaseInfo.getPaymentTtl(),dealerBaseInfo.getGoalTtlAct()) + "%"); roundInfoRes.setPaymentPercentage(getPercentage(dealerBaseInfo.getPaymentTtl(),dealerBaseInfo.getGoalTtlAct()) + "%");
// 轮次 // 轮次
roundInfoRes.setRoundTime(round); roundInfoRes.setRoundTime(round);
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.NumberUtil;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.dealer.domain.DealerBaseInfo; import com.ruoyi.dealer.domain.DealerBaseInfo;
import com.ruoyi.dealer.domain.DealerResult; import com.ruoyi.dealer.domain.DealerResult;
...@@ -76,13 +77,14 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe ...@@ -76,13 +77,14 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
// 如果数据存在,则为1 未存在,则为0 // 如果数据存在,则为1 未存在,则为0
List<DealerRoundInfo> list = this.list(new LambdaQueryWrapper<DealerRoundInfo>() List<DealerRoundInfo> list = this.list(new LambdaQueryWrapper<DealerRoundInfo>()
.eq(DealerRoundInfo::getDealerId, userId) .eq(DealerRoundInfo::getDealerId, userId)
.gt(DealerRoundInfo::getPaymentTtlNew, dealerRoundInfoReq.getPaymentTtlNew()) .ge(DealerRoundInfo::getPaymentTtlNew, dealerRoundInfoReq.getPaymentTtlNew())
); );
// 有超过当前金额的记录 则为1不出特效 ,标识已有更大的预付款,并且出过特效 否则为0 没有出过特效 // 有超过当前金额的记录 则为1不出特效 ,标识已有更大的预付款,并且出过特效 否则为0 没有出过特效
Integer repetition = list.size() > 0 ? 1 : 0; Integer repetition = list.size() > 0 ? 1 : 0;
dealerRoundInfo.setRepetition(repetition); dealerRoundInfo.setRepetition(repetition);
dealerRoundInfo.setPaymentPercentage(getPercentage(dealerRoundInfoReq.getPaymentTtlNew(), dealerRoundInfoReq.getGoalTtlAct(),4));
this.save(dealerRoundInfo); this.save(dealerRoundInfo);
...@@ -152,7 +154,8 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe ...@@ -152,7 +154,8 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
res.setPaymentTtl(info.getPaymentTtlNew()); res.setPaymentTtl(info.getPaymentTtlNew());
res.setPhone(info.getPhone()); res.setPhone(info.getPhone());
res.setPaymentChange(info.getPaymentTtlNew() > info.getPaymentTtlPre() ? "up" : "down"); res.setPaymentChange(info.getPaymentTtlNew() > info.getPaymentTtlPre() ? "up" : "down");
res.setPaymentPercentage(getPercentage(info.getPaymentTtlNew(), info.getGoalTtlAct(),2) + "%"); // res.setPaymentPercentage(getPercentage(info.getPaymentTtlNew(), info.getGoalTtlAct(),2) + "%");
res.setPaymentPercentage(NumberUtil.formatNumber(info.getPaymentPercentage(),2) + "%");
res.setRoundId(info.getRoundId()); res.setRoundId(info.getRoundId());
res.setRepetition(info.getRepetition()); res.setRepetition(info.getRepetition());
...@@ -185,6 +188,7 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe ...@@ -185,6 +188,7 @@ public class DealerRoundInfoServiceImpl extends ServiceImpl<DealerRoundInfoMappe
item.setRoundTime(result.getRoundTime()); item.setRoundTime(result.getRoundTime());
item.setPaymentTtl(result.getPaymentTtl()); item.setPaymentTtl(result.getPaymentTtl());
item.setGoalTtlAct(result.getGoalTtlAct()); item.setGoalTtlAct(result.getGoalTtlAct());
// item.setPaymentPercentage(getPercentage(result.getPaymentTtl(), result.getGoalTtlAct(),4));
item.setPaymentPercentage(getPercentage(result.getPaymentTtl(), result.getGoalTtlAct(),4)); item.setPaymentPercentage(getPercentage(result.getPaymentTtl(), result.getGoalTtlAct(),4));
item.setSalesRegionGroupName(result.getSalesRegionGroupName()); item.setSalesRegionGroupName(result.getSalesRegionGroupName());
return item; return item;
......
// 文件路径:ruoyi-system/src/main/java/com/ruoyi/dealer/service/impl/DealerRoundResultServiceImpl.java // 文件路径:ruoyi-system/src/main/java/com/ruoyi/dealer/service/impl/DealerRoundResultServiceImpl.java
package com.ruoyi.dealer.service.impl; package com.ruoyi.dealer.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
...@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.NumberUtil;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dealer.domain.DealerBaseInfo; import com.ruoyi.dealer.domain.DealerBaseInfo;
import com.ruoyi.dealer.domain.DealerResult; import com.ruoyi.dealer.domain.DealerResult;
...@@ -32,6 +34,7 @@ import java.math.RoundingMode; ...@@ -32,6 +34,7 @@ import java.math.RoundingMode;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -77,7 +80,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -77,7 +80,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
res.setRoundTime(item.getRoundTime()); res.setRoundTime(item.getRoundTime());
res.setGoalTtlAct(item.getGoalTtlAct()); res.setGoalTtlAct(item.getGoalTtlAct());
res.setPaymentTtl(item.getPaymentTtl()); res.setPaymentTtl(item.getPaymentTtl());
res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 2) + "%"); // res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 2) + "%");
res.setPaymentPercentage(NumberUtil.formatNumber(item.getPaymentPercentage(),2) + "%");
list.add(res); list.add(res);
}); });
...@@ -95,8 +99,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -95,8 +99,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
res.setSalesRegionGroupName(item.getGroupName()); res.setSalesRegionGroupName(item.getGroupName());
res.setPaymentTtl(item.getPaymentTtl()); res.setPaymentTtl(item.getPaymentTtl());
res.setGoalTtlAct(item.getGoalTtlAct()); res.setGoalTtlAct(item.getGoalTtlAct());
// res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 4) + "%");
res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 2) + "%"); res.setPaymentPercentage(NumberUtil.formatNumber(item.getPaymentPercentage(),4) + "%");
list.add(res); list.add(res);
}); });
return list; return list;
...@@ -132,7 +136,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -132,7 +136,8 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
res.setPaymentTtl(item.getPaymentTtl()); res.setPaymentTtl(item.getPaymentTtl());
res.setGoalTtlAct(item.getGoalTtlAct()); res.setGoalTtlAct(item.getGoalTtlAct());
res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 4) + "%"); // res.setPaymentPercentage(getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 4) + "%");
res.setPaymentPercentage(NumberUtil.formatNumber(item.getPaymentPercentage(),4) + "%");
list.add(res); list.add(res);
}); });
...@@ -194,7 +199,7 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -194,7 +199,7 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
item.setGoalTtlAct(baseInfo.getGoalTtlAct()); item.setGoalTtlAct(baseInfo.getGoalTtlAct());
item.setPaymentTtlPre(baseInfo.getPaymentTtl()); item.setPaymentTtlPre(baseInfo.getPaymentTtl());
item.setPaymentTtl(baseInfo.getPaymentTtl()); item.setPaymentTtl(baseInfo.getPaymentTtl());
item.setPaymentPercentage(getPercentage(baseInfo.getPaymentTtl(), baseInfo.getGoalTtlAct(), 2)); item.setPaymentPercentage(baseInfo.getPaymentPercentage());
roundResults.add(item); roundResults.add(item);
}); });
this.saveOrUpdateBatch(roundResults); this.saveOrUpdateBatch(roundResults);
...@@ -274,8 +279,10 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -274,8 +279,10 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
// 导出到excel文件 // 导出到excel文件
ExcelUtil<DealerRoundResult> util = new ExcelUtil<>(DealerRoundResult.class); ExcelUtil<DealerRoundResult> util = new ExcelUtil<>(DealerRoundResult.class);
String encodedFileName = null; String encodedFileName = null;
String fileName = DateUtil.format(new Date(), "yyyyMMddHHmmss") + "个人分组明细.xlsx";
try { try {
encodedFileName = URLEncoder.encode("个人分组明细.xlsx", "UTF-8"); encodedFileName = URLEncoder.encode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -287,8 +294,9 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -287,8 +294,9 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
// 导出到excel文件 // 导出到excel文件
ExcelUtil<DealerResult> util = new ExcelUtil<>(DealerResult.class); ExcelUtil<DealerResult> util = new ExcelUtil<>(DealerResult.class);
String encodedFileName = null; String encodedFileName = null;
String fileName = DateUtil.format(new Date(), "yyyyMMddHHmmss") + "团队汇总.xlsx";
try { try {
encodedFileName = URLEncoder.encode("团队汇总.xlsx", "UTF-8"); encodedFileName = URLEncoder.encode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -311,7 +319,7 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -311,7 +319,7 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
res.setGroupName(item.getSalesRegionGroupName()); res.setGroupName(item.getSalesRegionGroupName());
res.setPaymentTtl(item.getPaymentTtl()); res.setPaymentTtl(item.getPaymentTtl());
res.setGoalTtlAct(item.getGoalTtlAct()); res.setGoalTtlAct(item.getGoalTtlAct());
res.setPaymentPercentage(item.getPaymentPercentage()+"%"); res.setPaymentPercentage(NumberUtil.formatNumber(item.getPaymentPercentage(),2)+"%");
res.setSalesRegionGroupName(item.getSalesRegionGroupName()); res.setSalesRegionGroupName(item.getSalesRegionGroupName());
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
...@@ -343,7 +351,9 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM ...@@ -343,7 +351,9 @@ public class DealerRoundResultServiceImpl extends ServiceImpl<DealerRoundResultM
res.setGroupName(item.getGroupName()); res.setGroupName(item.getGroupName());
res.setPaymentTtl(item.getPaymentTtl()); res.setPaymentTtl(item.getPaymentTtl());
res.setGoalTtlAct(item.getGoalTtlAct()); res.setGoalTtlAct(item.getGoalTtlAct());
res.setPaymentPercentage(this.getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 2)+"%"); // res.setPaymentPercentage(this.getPercentage(item.getPaymentTtl(), item.getGoalTtlAct(), 2)+"%");
// res.setPaymentPercentage(item.getPaymentPercentage()+"%");
res.setPaymentPercentage(NumberUtil.formatNumber(item.getPaymentPercentage(),2)+"%");
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return resList; return resList;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论