commit
This commit is contained in:
+52
-3
@@ -1,25 +1,30 @@
|
||||
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.ActGroup;
|
||||
import com.budwk.app.module.activity.models.Activity;
|
||||
import com.budwk.app.module.activity.models.ActivityItem;
|
||||
import com.budwk.app.module.activity.models.*;
|
||||
import com.budwk.app.module.activity.service.ActivityManageService;
|
||||
import com.budwk.app.module.activity.vo.ActItemScoreVo;
|
||||
import com.budwk.app.module.activity.vo.page.ActScoreEnterPageForm;
|
||||
import com.budwk.app.module.activity.vo.page.ActSignInUserPageForm;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
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.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -96,9 +101,53 @@ public class ActScoreEnterController {
|
||||
@SaCheckPermission("activity.scoreEnter")
|
||||
@ApiOperation(value = "获取项目列表", nickname = "/list-item", httpMethod = "GET")
|
||||
public Result listItem(Long activityId) {
|
||||
Sql sql = Sqls.create("""
|
||||
|
||||
""");
|
||||
List<ActivityItem> items = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", activityId).asc(ActivityItem::getSort));
|
||||
return Result.success(items);
|
||||
}
|
||||
|
||||
@At("/list-item-score/?")
|
||||
@SaCheckPermission("activity.scoreEnter")
|
||||
@ApiOperation(value = "获取项目列表", nickname = "/list-item-score", httpMethod = "GET")
|
||||
public Result listItemScore(Long activityId) {
|
||||
List<ActItemGroupScore> scoreList = dao.query(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getActivityId, "=", activityId));
|
||||
return Result.success(scoreList);
|
||||
}
|
||||
|
||||
@At("/save-score")
|
||||
@SaCheckPermission("activity.scoreEnter")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@ApiOperation(value = "保存成绩", nickname = "/list-activity", httpMethod = "POST")
|
||||
public Result saveScore(ActItemScoreVo actItemScoreVo) {
|
||||
|
||||
List<ActivityItem> itemList = dao.query(ActivityItem.class, Cnd.where(ActivityItem::getActivityId, "=", actItemScoreVo.getActivityId()));
|
||||
dao.clear(ActItemGroupScore.class, Cnd.where(ActItemGroupScore::getActivityId, "=", actItemScoreVo.getActivityId()));
|
||||
List<ActItemGroupScore> activityItemScores = new ArrayList<>();
|
||||
actItemScoreVo.getData().forEach(item -> {
|
||||
itemList.forEach(i -> {
|
||||
ActItemGroupScore score = new ActItemGroupScore();
|
||||
NutMap data = item.getAs(i.getId().toString(), NutMap.class);
|
||||
if (Lang.isNotEmpty(data)) {
|
||||
String totalScore = StrUtil.isNotEmpty(data.getString("totalScore")) ? data.getString("totalScore") : "0";
|
||||
score.setScore(new BigDecimal(totalScore));
|
||||
int totalRank = data.getInt("totalRank");
|
||||
score.setRanking(totalRank);
|
||||
} else {
|
||||
score.setScore(new BigDecimal(0));
|
||||
score.setRanking(0);
|
||||
}
|
||||
score.setItemId(i.getId());
|
||||
score.setActivityId(actItemScoreVo.getActivityId());
|
||||
score.setGroupId(item.getLong("groupId"));
|
||||
activityItemScores.add(score);
|
||||
});
|
||||
});
|
||||
|
||||
dao.insert(activityItemScores);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.budwk.app.module.activity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhf
|
||||
* @date 2025/4/30 10:57
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class ActItemScoreVo {
|
||||
|
||||
// 活动ID
|
||||
private Long activityId;
|
||||
|
||||
private List<NutMap> data;
|
||||
}
|
||||
@@ -8,13 +8,13 @@ layout("/layouts/platform_1.html"){
|
||||
<div class="search-item-label">年度</div>
|
||||
<div class="search-item-option">
|
||||
<el-date-picker
|
||||
:clearable="false"
|
||||
placeholder="选择年"
|
||||
style="width: 100%"
|
||||
@change="listAct"
|
||||
type="year"
|
||||
v-model="pageForm.year"
|
||||
value-format="yyyy"
|
||||
:clearable="false"
|
||||
placeholder="选择年"
|
||||
style="width: 100%"
|
||||
@change="listAct"
|
||||
type="year"
|
||||
v-model="pageForm.year"
|
||||
value-format="yyyy"
|
||||
></el-date-picker>
|
||||
</div>
|
||||
</div>
|
||||
@@ -23,10 +23,10 @@ layout("/layouts/platform_1.html"){
|
||||
<div class="search-item-option">
|
||||
<el-select v-model="pageForm.activityId" placeholder="请选择活动" @change="activityChange">
|
||||
<el-option
|
||||
v-for="item in activityOptions"
|
||||
:key="item.id"
|
||||
:label="item.title"
|
||||
:value="item.id">
|
||||
v-for="item in activityOptions"
|
||||
:key="item.id"
|
||||
:label="item.title"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
@@ -59,7 +59,7 @@ layout("/layouts/platform_1.html"){
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-row type="flex"justify="end" class="mt-3">
|
||||
<el-row type="flex" justify="end" class="mt-3">
|
||||
<el-button type="primary" @click="saveScore">保存</el-button>
|
||||
</el-row>
|
||||
</el-card>
|
||||
@@ -76,7 +76,8 @@ layout("/layouts/platform_1.html"){
|
||||
},
|
||||
activityOptions: [],
|
||||
groupOptions: [],
|
||||
itemOptions: []
|
||||
itemOptions: [],
|
||||
itemScoreList: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -134,7 +135,22 @@ layout("/layouts/platform_1.html"){
|
||||
async activityChange() {
|
||||
await this.listGroup()
|
||||
await this.listItem()
|
||||
await this.listItemScore()
|
||||
this.buildTableData()
|
||||
|
||||
},
|
||||
|
||||
async listItemScore() {
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await $.get("/platform/activity/scoreEnter/list-item-score/" + this.pageForm.activityId)
|
||||
if (code === 0) {
|
||||
this.itemScoreList = data
|
||||
} else {
|
||||
this.$message.error(msg)
|
||||
}
|
||||
},
|
||||
// 构建表格数据
|
||||
buildTableData() {
|
||||
@@ -144,21 +160,41 @@ layout("/layouts/platform_1.html"){
|
||||
groupName: group.groupName
|
||||
}
|
||||
this.itemOptions.forEach((item) => {
|
||||
row[item.id] = {
|
||||
totalScore: item.totalScore,
|
||||
totalRank: item.totalRank
|
||||
let data = this.itemScoreList.find(s => s.groupId === group.id && s.itemId === item.id);
|
||||
if (data) {
|
||||
row[item.id] = {
|
||||
totalScore: data.score ? data.score : null,
|
||||
totalRank: data.ranking ? data.ranking : null
|
||||
}
|
||||
} else {
|
||||
row[item.id] = {
|
||||
totalScore: null,
|
||||
totalRank: null
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
return row
|
||||
})
|
||||
console.log(this.tableData)
|
||||
},
|
||||
// 单元格点击
|
||||
cellClick(row, column){
|
||||
console.log(row, column)
|
||||
cellClick(row, column) {
|
||||
},
|
||||
// 保存成绩
|
||||
saveScore(){
|
||||
saveScore() {
|
||||
const formData = {
|
||||
activityId: this.pageForm.activityId,
|
||||
data: JSON.stringify(this.tableData)
|
||||
}
|
||||
$.post("/platform/activity/scoreEnter/save-score", formData).then(async res => {
|
||||
if (res.code === 0) {
|
||||
await this.listItemScore()
|
||||
this.buildTableData()
|
||||
this.$message.success("保存成功")
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
}
|
||||
})
|
||||
console.log(this.tableData)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user