This commit is contained in:
那些花儿
2025-05-14 18:25:35 +08:00
parent 31709a69f8
commit 8eeb4843ee
8 changed files with 2439 additions and 66 deletions
@@ -0,0 +1,113 @@
package com.budwk.app.module.activity.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.result.Result;
import com.budwk.app.module.activity.models.ActItemGroupScore;
import com.budwk.app.module.activity.models.Activity;
import com.budwk.app.module.activity.service.ActivityManageService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
@IocBean
@At("/platform/activity/bigScreen")
@Ok("json:full")
public class ActBigScreenController {
@Inject
private ActivityManageService activityManageService;
@Inject
private Dao dao;
@At("")
@SaCheckPermission("activity.bigScreen")
@Ok("beetl:/platform/activity/bigScreen/index.html")
public void index() {
}
/**
* 获取活动列表及其项目
*/
@At("/listAct")
@SaCheckPermission("activity.bigScreen")
public Result listAct() {
List<Activity> list = dao.query(Activity.class, Cnd.NEW().desc("startTime"));
for (Activity activity : list) {
dao.fetchLinks(activity, "items");
}
return Result.success().addData(list);
}
/**
* 获取活动成绩
*/
@At("/score")
@SaCheckPermission("activity.bigScreen")
@Ok("json:full")
public Result score(Long activityId) {
if (activityId == null) {
return Result.error("活动ID不能为空");
}
Sql sql = Sqls.create("""
SELECT
t1.itemId,
t1.groupId,
t1.score,
t1.ranking,
t2.groupName\s
FROM
act_item_group_score t1
LEFT JOIN act_group t2 ON t2.id = t1.groupId\s
WHERE
t1.activityId = @activityId
""");
sql.setParam("activityId", activityId);
List<NutMap> list = activityManageService.listMap(sql);
Map<Integer, Map<String, Object>> groupMap = new HashMap<>();
for (NutMap item : list) {
Integer groupId = item.getInt("groupId");
String groupName = item.getString("groupName");
Integer itemId = item.getInt("itemId");
Integer score = StrUtil.isBlank(item.getString("score")) ? null : item.getInt("score", 0);
String ranking = item.getString("ranking");
// 获取或创建分组
Map<String, Object> group = groupMap.computeIfAbsent(groupId, k -> {
Map<String, Object> newGroup = new HashMap<>();
newGroup.put("groupId", groupId);
newGroup.put("groupName", groupName);
newGroup.put("itemScores", new ArrayList<Map<String, Object>>());
return newGroup;
});
// 如果有分数,则添加到itemScores中
List<Map<String, Object>> itemScores = (List<Map<String, Object>>) group.get("itemScores");
Map<String, Object> scoreItem = new HashMap<>();
scoreItem.put("itemId", itemId);
scoreItem.put("score", score);
scoreItem.put("ranking", ranking);
itemScores.add(scoreItem);
}
ArrayList<Map<String, Object>> groupScores = new ArrayList<>(groupMap.values());
return Result.success(groupScores);
}
}
@@ -29,6 +29,7 @@ import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
@@ -239,7 +240,6 @@ public class ActGroupController {
dao.insert(actGroups[i].getGroupUsers());
}
// 查询项目列表
List<ActivityItem> items = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", activityId));
@@ -260,6 +260,16 @@ public class ActGroupController {
itemGroupScoreList.addAll(groupScoreList);
}
dao.insert(itemGroupScoreList);
// 更新小队表中的总积分
for (ActGroup group : actGroups) {
List<ActItemGroupScore> scores = dao.query(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getGroupId, "=", group.getId())
.and(ActivityItem::getActivityId, "=", activityId));
BigDecimal total = scores.stream().map(ActItemGroupScore::getScore).reduce(BigDecimal::add).orElse(new BigDecimal(0));
group.setTotalScore(total);
}
dao.update(actGroups, "totalScore");
return Result.success();
}
File diff suppressed because it is too large Load Diff
@@ -39,6 +39,7 @@ layout("/layouts/platform_1.html"){
</el-card>
<el-card shadow="never" class="mt-3">
<el-row type="flex" class="mb-3" style="justify-content: flex-end">
<el-button type="primary" size="small" @click="openBigScreen">打开成绩大屏</el-button>
<el-button type="primary" size="small" @click="doExport">导出</el-button>
</el-row>
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData" @cell-click="cellClick">
@@ -215,6 +216,9 @@ layout("/layouts/platform_1.html"){
this.$message.error(msg)
}
console.log(this.tableData)
},
openBigScreen(){
window.open("/platform/activity/bigScreen?activityId=" + this.pageForm.activityId)
}
},
created() {
+326 -56
View File
@@ -12,7 +12,12 @@ import com.budwk.app.sys.models.Sys_dict;
import com.budwk.app.sys.services.SysDictService;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import lombok.Data;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFSimpleShape;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.nutz.boot.test.junit4.NbJUnit4Runner;
@@ -24,6 +29,7 @@ import org.nutz.lang.util.NutMap;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -38,75 +44,339 @@ public class Test1 {
@Inject
private SysDictService sysDictService;
@Test
public void to01() {
String str = """
'旅行', '摄影', '音乐', '电影', '美食', '健身', '阅读', '跑步','游泳', '爬山', '滑雪', '烹饪', '绘画', '书法', '手工', '舞蹈','瑜伽', '钢琴', '吉他', '写作', '篮球', '足球', '网球', '羽毛球','动漫', '游戏', '宠物', '园艺', '咖啡', '茶艺', '插花', '收藏','志愿服务', '数码', '科技', '投资', '理财', '历史', '哲学', '心理学'
""";
String[] split = str.split(",");
System.out.println(split.toString());
for (String s : split) {
Sys_dict dict = new Sys_dict();
dict.setName(s);
dict.setCode(s);
dict.setHasChildren(false);
sysDictService.save(dict, "dbfa9ef2c6f447ceac84926dcf67d6c8");
System.out.println(s);
public static void exportScoreSheet(String filePath, List<Team> teams) throws IOException {
// 创建工作簿
XSSFWorkbook workbook = new XSSFWorkbook();
// 创建工作表
Sheet sheet = workbook.createSheet("Sheet1");
// 创建标题行样式
CellStyle titleStyle = workbook.createCellStyle();
Font titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontHeightInPoints((short) 14);
titleStyle.setFont(titleFont);
titleStyle.setAlignment(HorizontalAlignment.CENTER);
// 创建表头样式
CellStyle headerStyle = workbook.createCellStyle();
Font headerFont = workbook.createFont();
headerFont.setBold(true);
headerStyle.setFont(headerFont);
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
headerStyle.setBorderTop(BorderStyle.THIN);
headerStyle.setBorderBottom(BorderStyle.THIN);
headerStyle.setBorderLeft(BorderStyle.THIN);
headerStyle.setBorderRight(BorderStyle.THIN);
// 创建数据单元格样式
CellStyle dataStyle = workbook.createCellStyle();
dataStyle.setAlignment(HorizontalAlignment.CENTER);
dataStyle.setBorderTop(BorderStyle.THIN);
dataStyle.setBorderBottom(BorderStyle.THIN);
dataStyle.setBorderLeft(BorderStyle.THIN);
dataStyle.setBorderRight(BorderStyle.THIN);
// 创建标题行
Row titleRow = sheet.createRow(0);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellValue("第二届 钟声杯 评分表");
titleCell.setCellStyle(titleStyle);
// 合并标题单元格
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
// 创建表头行
Row headerRow1 = sheet.createRow(1);
Cell teamHeaderCell = headerRow1.createCell(0);
// 合并第一列第二行和第三行的单元格
sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
// 在合并的单元格中画两条斜线
ArrayList<SlashLinePosition> slpList = new ArrayList<>();
// 第一条斜线(左上到右下)
SlashLinePosition slp1 = new SlashLinePosition();
slp1.setStartX(0); // 起点X坐标
slp1.setStartY(0); // 起点Y坐标
slp1.setEndX(1023); // 终点X坐标
slp1.setEndY(1023); // 终点Y坐标
slpList.add(slp1);
// 第二条斜线(左下到右上)
SlashLinePosition slp2 = new SlashLinePosition();
slp2.setStartX(0); // 起点X坐标
slp2.setStartY(1023); // 起点Y坐标
slp2.setEndX(1023); // 终点X坐标
slp2.setEndY(0); // 终点Y坐标
slpList.add(slp2);
// 调用画线方法
// drawLineXlsx(sheet, 1, 0, "LEFT_TOP", slpList);
Cell project1HeaderCell = headerRow1.createCell(1);
project1HeaderCell.setCellValue("项目一");
project1HeaderCell.setCellStyle(headerStyle);
sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
Cell project2HeaderCell = headerRow1.createCell(3);
project2HeaderCell.setCellValue("项目二");
project2HeaderCell.setCellStyle(headerStyle);
sheet.addMergedRegion(new CellRangeAddress(1, 1, 3, 4));
Cell project3HeaderCell = headerRow1.createCell(5);
project3HeaderCell.setCellValue("项目三");
project3HeaderCell.setCellStyle(headerStyle);
sheet.addMergedRegion(new CellRangeAddress(1, 1, 5, 6));
Cell project4HeaderCell = headerRow1.createCell(7);
project4HeaderCell.setCellValue("项目四");
project4HeaderCell.setCellStyle(headerStyle);
sheet.addMergedRegion(new CellRangeAddress(1, 1, 7, 8));
Cell totalHeaderCell = headerRow1.createCell(9);
totalHeaderCell.setCellValue("总分");
totalHeaderCell.setCellStyle(headerStyle);
// 创建子表头
Row headerRow2 = sheet.createRow(2);
Cell emptyCell = headerRow2.createCell(0);
emptyCell.setCellStyle(headerStyle);
String[] subHeaders = {"成绩", "得分", "成绩", "得分", "成绩", "得分", "成绩", "得分", ""};
for (int i = 0; i < subHeaders.length; i++) {
Cell cell = headerRow2.createCell(i + 1);
cell.setCellValue(subHeaders[i]);
cell.setCellStyle(headerStyle);
}
// 填充队伍数据
for (int i = 0; i < teams.size(); i++) {
Row row = sheet.createRow(i + 3);
Team team = teams.get(i);
// 队伍序号
Cell indexCell = row.createCell(0);
indexCell.setCellValue(i + 1);
indexCell.setCellStyle(dataStyle);
// 项目一
Cell project1ScoreCell = row.createCell(1);
project1ScoreCell.setCellValue(team.getProject1Score());
project1ScoreCell.setCellStyle(dataStyle);
Cell project1PointsCell = row.createCell(2);
project1PointsCell.setCellValue(team.getProject1Points());
project1PointsCell.setCellStyle(dataStyle);
// 项目二
Cell project2ScoreCell = row.createCell(3);
project2ScoreCell.setCellValue(team.getProject2Score());
project2ScoreCell.setCellStyle(dataStyle);
Cell project2PointsCell = row.createCell(4);
project2PointsCell.setCellValue(team.getProject2Points());
project2PointsCell.setCellStyle(dataStyle);
// 项目三
Cell project3ScoreCell = row.createCell(5);
project3ScoreCell.setCellValue(team.getProject3Score());
project3ScoreCell.setCellStyle(dataStyle);
Cell project3PointsCell = row.createCell(6);
project3PointsCell.setCellValue(team.getProject3Points());
project3PointsCell.setCellStyle(dataStyle);
// 项目四
Cell project4ScoreCell = row.createCell(7);
project4ScoreCell.setCellValue(team.getProject4Score());
project4ScoreCell.setCellStyle(dataStyle);
Cell project4PointsCell = row.createCell(8);
project4PointsCell.setCellValue(team.getProject4Points());
project4PointsCell.setCellStyle(dataStyle);
// 总分
Cell totalCell = row.createCell(9);
totalCell.setCellValue(team.getTotalPoints());
totalCell.setCellStyle(dataStyle);
}
// 调整列宽
sheet.setColumnWidth(0, 3000);
for (int i = 1; i <= 9; i++) {
sheet.setColumnWidth(i, 2500);
}
// 调整行高以容纳绘图元素
sheet.getRow(1).setHeight((short) 600);
// 写入文件
try (FileOutputStream fileOut = new FileOutputStream(filePath)) {
workbook.write(fileOut);
} finally {
workbook.close();
}
}
@Test
public void t002() {
List<ExcelUser> list = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\工作簿3.xlsx"), ExcelUser.class, new ImportParams());
// 队伍类
public static class Team {
private String project1Score;
private Double project1Points;
private String project2Score;
private Double project2Points;
private String project3Score;
private Double project3Points;
private String project4Score;
private Double project4Points;
private Double totalPoints;
List<ExcelUser> list2 = ExcelImportUtil.importExcel(new File("D:\\downloads\\会员名单 (3).xls"), ExcelUser.class, new ImportParams());
// 构造函数
public Team(String project1Score, Double project1Points,
String project2Score, Double project2Points,
String project3Score, Double project3Points,
String project4Score, Double project4Points) {
this.project1Score = project1Score;
this.project1Points = project1Points;
this.project2Score = project2Score;
this.project2Points = project2Points;
this.project3Score = project3Score;
this.project3Points = project3Points;
this.project4Score = project4Score;
this.project4Points = project4Points;
// 计算总分
this.totalPoints = (project1Points != null ? project1Points : 0) +
(project2Points != null ? project2Points : 0) +
(project3Points != null ? project3Points : 0) +
(project4Points != null ? project4Points : 0);
}
List<NutMap> changeUsers = new ArrayList<>();
// Getter方法
public String getProject1Score() {
return project1Score;
}
// 找出list中的人员在list2中单位不一样的数据
list.forEach(e -> {
Optional<ExcelUser> first = list2.stream().filter(e2 -> e2.getGh().equals(e.getGh())).findFirst();
if (first.isPresent()) {
String dw = StrUtil.blankToDefault(first.get().getDw(), "");
if (!dw.equals(e.getDw())) {
// System.out.println("姓名:" + e.getName() + ",工号:" + e.getGh() + ",原单位:" + e.getDw() + ",现单位:" + dw);
changeUsers.add(NutMap.NEW()
.addv("name", e.getName())
.addv("gh", e.getGh())
.addv("ydw", e.getDw())
.addv("xdw", dw));
}
public Double getProject1Points() {
return project1Points;
}
public String getProject2Score() {
return project2Score;
}
public Double getProject2Points() {
return project2Points;
}
public String getProject3Score() {
return project3Score;
}
public Double getProject3Points() {
return project3Points;
}
public String getProject4Score() {
return project4Score;
}
public Double getProject4Points() {
return project4Points;
}
public Double getTotalPoints() {
return totalPoints;
}
}
// SlashLinePosition类定义
public static class SlashLinePosition {
private int startX;
private int startY;
private int endX;
private int endY;
// getter和setter方法
public int getStartX() { return startX; }
public void setStartX(int startX) { this.startX = startX; }
public int getStartY() { return startY; }
public void setStartY(int startY) { this.startY = startY; }
public int getEndX() { return endX; }
public void setEndX(int endX) { this.endX = endX; }
public int getEndY() { return endY; }
public void setEndY(int endY) { this.endY = endY; }
}
/**
* @Author 通靈鹿小六
* @Description 在XLSX文件中画斜线
* @param sheet XSSFSheet格式对象
* @param rowIndex 斜线表头单元格行索引
* @param colIndex 斜线表头单元格列索引
* @param slashType 斜线类型
* @param slpList 斜线表头线集合
**/
private static void drawLineXlsx(XSSFSheet sheet, int rowIndex, int colIndex, String slashType, ArrayList<SlashLinePosition> slpList) {
XSSFDrawing xssfDrawing = sheet.createDrawingPatriarch();
for (SlashLinePosition slp : slpList) {
XSSFClientAnchor xssfClientAnchor = new XSSFClientAnchor(
slp.getStartX(), slp.getStartY(), slp.getEndX(), slp.getEndY(),
colIndex, rowIndex, colIndex, rowIndex);
XSSFSimpleShape shape = xssfDrawing.createSimpleShape(xssfClientAnchor);
if (slashType == "LEFT_TOP" || slashType == "RIGHT_BOTTOM") {
//斜线类型为左上,右下的时候,使用斜线
shape.setShapeType(ShapeTypes.LINE);
} else {
//斜线类型为左下,右上的时候,使用反斜线
shape.setShapeType(ShapeTypes.LINE_INV);
}
});
// 设置线宽
shape.setLineWidth(0.5);
// 设置线的风格
shape.setLineStyle(0);
// 设置线的颜色
shape.setLineStyleColor(0, 0, 0);
}
}
ArrayList<ExcelExportEntity> entities = new ArrayList<>();
entities.add(new ExcelExportEntity("姓名", "name"));
entities.add(new ExcelExportEntity("工号", "gh"));
entities.add(new ExcelExportEntity("原单位", "ydw"));
entities.add(new ExcelExportEntity("现单位", "xdw"));
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entities, changeUsers);
// 示例使用方法
public static void main(String[] args) {
try {
FileOutputStream outputStream = new FileOutputStream("C:\\Users\\jug\\Desktop\\单位变动人员.xlsx");
workbook.write(outputStream);
}catch (Exception e){
// 创建测试数据
List<Team> teams = List.of(
new Team("95", 9.5, "88", 8.8, "92", 9.2, "90", 9.0),
new Team("87", 8.7, "93", 9.3, "85", 8.5, "91", 9.1),
new Team("92", 9.2, "89", 8.9, "94", 9.4, "88", 8.8),
new Team("89", 8.9, "91", 9.1, "87", 8.7, "93", 9.3),
new Team("94", 9.4, "86", 8.6, "91", 9.1, "89", 8.9),
new Team("85", 8.5, "94", 9.4, "88", 8.8, "92", 9.2),
new Team("91", 9.1, "88", 8.8, "93", 9.3, "86", 8.6),
new Team("88", 8.8, "92", 9.2, "89", 8.9, "94", 9.4),
new Team("93", 9.3, "85", 8.5, "90", 9.0, "87", 8.7),
new Team("86", 8.6, "90", 9.0, "92", 9.2, "88", 8.8),
new Team("90", 9.0, "93", 9.3, "87", 8.7, "91", 9.1),
new Team("87", 8.7, "89", 8.9, "94", 9.4, "90", 9.0),
new Team("92", 9.2, "91", 9.1, "86", 8.6, "93", 9.3),
new Team("89", 8.9, "87", 8.7, "91", 9.1, "95", 9.5),
new Team("94", 9.4, "92", 9.2, "88", 8.8, "90", 9.0),
new Team("90", 9.0, "94", 9.4, "92", 9.2, "89", 8.9)
);
// 导出Excel
exportScoreSheet("C:\\Users\\jug\\Desktop\\工作簿3.xlsx第二届钟声杯评分表.xlsx", teams);
System.out.println("Excel导出成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
@Data
public static class ExcelUser {
@Excel(name = "工号")
private String gh;
@Excel(name = "姓名")
private String name;
@Excel(name = "单位")
private String dw;
}
}
+2 -2
View File
@@ -133,7 +133,7 @@
<view class="footer-info">
<view class="footer-item">主办单位:浙江省教育工会</view>
<view class="footer-item">承办单位:杭州医学院工会</view>
<view class="footer-item">技术支持:武汉地大三思科技有限公司</view>
<view class="footer-item">技术支持:武汉地大三思科技有限公司(智慧工会提供商)</view>
</view>
</view>
</template>
@@ -531,7 +531,7 @@ body {
}
.footer-item {
font-size: 12px;
font-size: 12.5px;
color: #999;
line-height: 1.8;
}
+2 -2
View File
@@ -138,7 +138,7 @@
<view class="footer-info">
<view class="footer-item">主办单位:浙江省教育工会</view>
<view class="footer-item">承办单位:杭州医学院工会</view>
<view class="footer-item">技术支持:武汉地大三思科技有限公司</view>
<view class="footer-item">技术支持:武汉地大三思科技有限公司(智慧工会提供商)</view>
</view>
<!-- 自定义单位选择弹窗 -->
@@ -703,7 +703,7 @@ onMounted(() => {
}
.footer-item {
font-size: 12px;
font-size: 12.5px;
color: #999;
line-height: 1.8;
}
+16 -5
View File
@@ -12,14 +12,26 @@ export const setupRouterInterceptor = (whiteList = []) => {
}
export const checkAuth = async () => {
if (process.env.VUE_APP_PLATFORM === 'h5' && window.location.pathname !== '/') {
const path = window.location.pathname.replace(/^\//, '')
if (!getDefaultWhiteList().includes(path)) {
if (process.env.VUE_APP_PLATFORM === 'h5') {
if(window.location.pathname !== '/'){
const path = window.location.pathname.replace(/^\//, '')
if (!getDefaultWhiteList().includes(path)) {
const token = uni.getStorageSync('token')
if (token) {
await useUserStore().getUserInfo()
} else {
uni.setStorageSync('REDIRECT_URL', window.location.pathname + window.location.search)
await uni.redirectTo({
url: '/pages/login/index'
})
}
}
}else{
const token = uni.getStorageSync('token')
if (token) {
await useUserStore().getUserInfo()
} else {
uni.setStorageSync('REDIRECT_URL', window.location.pathname + window.location.search)
uni.setStorageSync('REDIRECT_URL', '/pages/index/index')
await uni.redirectTo({
url: '/pages/login/index'
})
@@ -120,7 +132,6 @@ async function routeInterceptor(args, whiteList) {
*/
export const getDefaultWhiteList = () => {
return [
'/pages/index/index',
'/pages/login/index',
'/pages/login/register',
'/pages/activity/list/index'