This commit is contained in:
@jyuhsin
2025-12-02 17:55:31 +08:00
parent b8e4ecb777
commit ade83bf8d5
2 changed files with 59 additions and 1 deletions
@@ -1,25 +1,34 @@
package com.budwk.app.zhgh.dayofficework.ghkh.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.utils.CommonDownloadUtil;
import com.budwk.app.zhgh.dayofficework.ghkh.model.ExamConfig;
import com.budwk.app.zhgh.dayofficework.ghkh.model.Kh_record;
import com.budwk.app.zhgh.dayofficework.ghkh.model.Kh_zb;
import com.budwk.app.zhgh.dayofficework.ghkh.service.KhXghshService;
import com.budwk.app.zhgh.dayofficework.ghkh.service.KhZbService;
import io.swagger.models.auth.In;
import org.apache.poi.ss.usermodel.Workbook;
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 org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
@@ -93,4 +102,48 @@ public class GhkhKhphController {
khZbService.dao().update(list);
return Result.success();
}
@At
@Ok("void")
public void downloadList(Integer annual, String khid, HttpServletResponse response) {
Sql sql = Sqls.create("""
SELECT zb.annual,zb.assessment,un.unionname,re.* FROM `kh_record` re
LEFT JOIN `vw_user` un ON re.union_id = un.unionId
LEFT JOIN kh_zb zb ON zb.id = re.zb_id
$condition
""");
Cnd cnd = Cnd.NEW();
cnd.and("re.zb_id ", "=", khid);
cnd.and("re.state", "=", 3);
cnd.andEX("zb.`annual`","=",annual);
cnd.desc("re.totalScore");
cnd.groupBy("re.union_id");
sql.setCondition(cnd);
List<NutMap> listMap = khXghshService.listMap(sql);
for (int i = 0; i < listMap.size(); i++) {
listMap.get(i).put("index", i + 1);
}
ExamConfig config = khZbService.dao().fetch(ExamConfig.class, Cnd.NEW());
List<ExcelExportEntity> exportEntities = new ArrayList<>();
exportEntities.add(new ExcelExportEntity("序号", "index", 10));
exportEntities.add(new ExcelExportEntity("年度", "annual", 10));
exportEntities.add(new ExcelExportEntity("分工会名称", "unionname", 30));
exportEntities.add(new ExcelExportEntity("线上得分", "xgh_score", 20));
exportEntities.add(new ExcelExportEntity("线上最终得分" + (config.getOnLine() != null ? "" + config.getOnLine() + "%" : ""), "onLineFinalScore", 20));
exportEntities.add(new ExcelExportEntity("线下得分", "offLineScore", 20));
exportEntities.add(new ExcelExportEntity("线下最终得分" + (config.getOffLine() != null ? "" + config.getOffLine() + "%" : ""), "offLineFinalScore", 20));
exportEntities.add(new ExcelExportEntity("最终考核得分", "totalScore", 20));
exportEntities.add(new ExcelExportEntity("排名", "sort", 20));
try {
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, listMap);
CommonDownloadUtil.download("得分列表.xlsx", workbook, response);
} catch (Exception ignored) {
}
}
}
@@ -27,7 +27,9 @@ layout("/layouts/platform.html"){
</search>
</el-card>
<el-card shadow="never" class="mt20">
<table-tool label="得分列表"></table-tool>
<table-tool label="得分列表">
<el-button @click="onExport" icon="el-icon-download" size="small" type="primary">导出</el-button>
</table-tool>
<el-table :data="tableData" style="width: 100%" row-key="record_id"
v-loading="tabLoading">
<el-table-column align="center" header-align="center" label="序号" width="100px">
@@ -110,6 +112,9 @@ layout("/layouts/platform.html"){
}
},
methods: {
onExport() {
this.$downLoad('/platform/ghkh/khph/downloadList', this.pageForm)
},
async openEdit(row) {
this.rowDataEdit = !this.rowDataEdit
const res = await $.post(loc() + "/doEditScore", {id: row.record_id, score: row.offLineScore, khId: this.pageForm.khid})