From ff0d89eacc7b34e90dc587fd38a527b9776a38d7 Mon Sep 17 00:00:00 2001 From: wuchunlei Date: Tue, 13 May 2025 17:56:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=96=E5=88=86=E5=AF=BC=E5=87=BA=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AD=97=E4=BD=93=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserContributionController.java | 63 ++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/peanut/modules/master/controller/UserContributionController.java b/src/main/java/com/peanut/modules/master/controller/UserContributionController.java index d7ffaa4c..2677ff5a 100644 --- a/src/main/java/com/peanut/modules/master/controller/UserContributionController.java +++ b/src/main/java/com/peanut/modules/master/controller/UserContributionController.java @@ -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 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 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++; } // 合并单元格