diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/ghkh/controller/GhkhKhphController.java b/src/main/java/com/budwk/app/zhgh/dayofficework/ghkh/controller/GhkhKhphController.java index d72766c..e083f8f 100644 --- a/src/main/java/com/budwk/app/zhgh/dayofficework/ghkh/controller/GhkhKhphController.java +++ b/src/main/java/com/budwk/app/zhgh/dayofficework/ghkh/controller/GhkhKhphController.java @@ -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 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 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) { + + } + } } diff --git a/src/main/resources/views/platform/zhgh/dayofficework/ghkh/khph.html b/src/main/resources/views/platform/zhgh/dayofficework/ghkh/khph.html index 82ebd33..f405837 100644 --- a/src/main/resources/views/platform/zhgh/dayofficework/ghkh/khph.html +++ b/src/main/resources/views/platform/zhgh/dayofficework/ghkh/khph.html @@ -27,7 +27,9 @@ layout("/layouts/platform.html"){ - + + 导出 + @@ -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})