湖分导出添加字体颜色

This commit is contained in:
wuchunlei
2025-05-13 17:56:26 +08:00
parent 6ec399baff
commit ff0d89eacc

View File

@@ -177,6 +177,7 @@ public class UserContributionController {
mw.selectAs(SysDictDataEntity::getDictValue,"typeInfo");
mw.eq(UserContribution::getUserId,contribution.getUserId());
mw.eq(SysDictDataEntity::getDictLabel,"userContributionLabel");
mw.orderByDesc(UserContribution::getCreateTime);
List<UserContribution> cs = contributionService.list(mw);
if(params.containsKey("startTime")&&StringUtils.isNotEmpty(params.get("startTime").toString())){
BigDecimal statQueryScore = BigDecimal.ZERO;
@@ -205,9 +206,6 @@ public class UserContributionController {
List<UserContribution> list = getStatQueryData(params).getRecords();
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("Sheet1");
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
Row headerRow = sheet.createRow(0);// 创建表头行
Cell headerCell0 = headerRow.createCell(0);
headerCell0.setCellValue("序号");
@@ -228,25 +226,74 @@ public class UserContributionController {
int startI = 1;
int i = 1;
for (UserContribution userContribution : list) {
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
Font font = workbook.createFont();
//涨星等级颜色变化
//半星 黄色
//一星 绿色
//一星半 红色
//二星 蓝色
if (userContribution.getStatQueryScore()!=null&&userContribution.getStatQueryScore().compareTo(BigDecimal.ZERO)>0){
if (userContribution.getScore().compareTo(new BigDecimal(150))<1){
if (userContribution.getStatQueryScore().compareTo(new BigDecimal(60))>=0){
font.setColor(IndexedColors.BLUE.getIndex());
}else if (userContribution.getStatQueryScore().compareTo(new BigDecimal(45))>=0){
font.setColor(IndexedColors.RED.getIndex());
}else if (userContribution.getStatQueryScore().compareTo(new BigDecimal(30))>=0){
font.setColor(IndexedColors.GREEN.getIndex());
}else if (userContribution.getStatQueryScore().compareTo(new BigDecimal(15))>=0){
font.setColor(IndexedColors.ORANGE.getIndex());
}
}else {
if ("6星".equals(userContribution.getLevel())){
if (userContribution.getStatQueryScore().compareTo(new BigDecimal(150))>=0){
int count = (userContribution.getStatQueryScore().subtract(new BigDecimal(150))).intValue()%15;
if (count>=2){
font.setColor(IndexedColors.BLUE.getIndex());
}else if (count>=1){
font.setColor(IndexedColors.RED.getIndex());
}else {
font.setColor(IndexedColors.GREEN.getIndex());
}
}
}
if ("7星".equals(userContribution.getLevel())){
if (userContribution.getStatQueryScore().compareTo(new BigDecimal(200))>=0){
if (userContribution.getStatQueryScore().compareTo(new BigDecimal(350))>=0){
font.setColor(IndexedColors.BLUE.getIndex());
}else {
font.setColor(IndexedColors.GREEN.getIndex());
}
}
}
}
}
cellStyle.setFont(font);
for (UserContribution c : userContribution.getContributions()) {
Row dataRow = sheet.createRow(i);
Cell dataCell0 = dataRow.createCell(0);
dataCell0.setCellStyle(cellStyle);
dataCell0.setCellValue(no);
dataCell0.setCellStyle(cellStyle);
Cell dataCell2 = dataRow.createCell(1);
dataCell2.setCellStyle(cellStyle);
dataCell2.setCellValue(userContribution.getUserName());
dataCell2.setCellStyle(cellStyle);
Cell dataCell3 = dataRow.createCell(2);
dataCell3.setCellStyle(cellStyle);
dataCell3.setCellValue(userContribution.getUserTel());
dataCell3.setCellStyle(cellStyle);
Cell dataCell1 = dataRow.createCell(3);
dataCell1.setCellStyle(cellStyle);
dataCell1.setCellValue(userContribution.getLevel());
dataCell1.setCellStyle(cellStyle);
Cell dataCell4 = dataRow.createCell(4);
dataCell4.setCellStyle(cellStyle);
dataCell4.setCellValue(userContribution.getScore().toString());
dataCell4.setCellStyle(cellStyle);
Cell dataCell5 = dataRow.createCell(5);
dataCell5.setCellValue(c.getTypeInfo() + "-" + c.getDetail() + "(" + c.getScore() + "分)");
if (c.getStatQueryFlag()==1){
cellStyle.setAlignment(HorizontalAlignment.LEFT);
dataCell5.setCellStyle(cellStyle);
}
i++;
}
// 合并单元格