From c243daddec7e8bf38fce6f6f910f39ed9bbde8f3 Mon Sep 17 00:00:00 2001 From: "@jyuhsin" <729757837@qq.com> Date: Wed, 11 Jun 2025 17:35:30 +0800 Subject: [PATCH] commit --- .../lxy/controller/LxyHdTjController.java | 92 ++++----- .../views/platform/zgfw/lxy/HdTj.html | 180 +++++------------- 2 files changed, 97 insertions(+), 175 deletions(-) diff --git a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdTjController.java b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdTjController.java index 4b0148a..19ac646 100644 --- a/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdTjController.java +++ b/src/main/java/io/v/nutz/zhgh/lxy/controller/LxyHdTjController.java @@ -2,17 +2,22 @@ package io.v.nutz.zhgh.lxy.controller; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; +import com.deepoove.poi.policy.HackLoopTableRenderPolicy; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.utils.MsgApi; import io.v.nutz.base.utils.OfficeTemplateUtil; import io.v.nutz.base.utils.Vi; import io.v.nutz.zhgh.lxy.model.Lxy_bm; +import io.v.nutz.zhgh.lxy.model.Lxy_hd; import io.v.nutz.zhgh.lxy.service.LxyGrxxService; import io.v.nutz.zhgh.lxy.service.LxyHdService; import org.apache.poi.ss.usermodel.Workbook; import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; import org.nutz.dao.Sqls; import org.nutz.dao.entity.Record; import org.nutz.dao.sql.Sql; @@ -29,6 +34,7 @@ import org.nutz.mvc.annotation.Param; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; @@ -45,19 +51,16 @@ public class LxyHdTjController { @Inject private LxyHdService lxyHdService; - @Inject private LxyGrxxService lxyGrxxService; - @Inject private Vi vi; - @Inject private OfficeTemplateUtil officeTemplateUtil; - - @Inject private MsgApi msgApi; + @Inject + private Dao dao; @At("") @Ok("beetl:/platform/zgfw/lxy/HdTj.html") @@ -73,9 +76,24 @@ public class LxyHdTjController { @Param(value = "searchKey", required = false) String searchKey, @Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize) { Cnd cnd = Cnd.NEW(); - Sql sql = Sqls.create("SELECT gr.* ,u.unionname,u.unioncode,u.unitname unitname,u.unitcode FROM `lxy_grxx` gr \n" + - "LEFT JOIN lxy_bm bm ON bm.userid = gr.userid \n" + - "LEFT JOIN `user` u ON u.id=bm.userid $condition"); + Sql sql = Sqls.create(""" + SELECT + gr.*, + u.unionname, + u.unioncode, + u.unitname, + u.unitcode, + bm.zyhj, + bm.bz, + bm.talent, + bm.nation, + bm.bmzt + FROM + lxy_grxx gr + LEFT JOIN lxy_bm bm ON bm.userid = gr.userid + LEFT JOIN `user` u ON u.id = bm.userid + $condition + """); cnd.and(new Static("bm.bmzt = 5")); cnd.and("gr.hdid", "=", hdid); @@ -108,56 +126,44 @@ public class LxyHdTjController { Cnd cnd = Cnd.NEW(); Sql sql = Sqls.create(""" SELECT - gr.*, - bm.unionname, + gr.username as uName, bm.unitname, + gr.sex, + bm.nation, bm.zyhj, - bm.bz + bm.idcard, + bm.mobile, + bm.talent FROM `lxy_grxx` gr LEFT JOIN lxy_bm bm ON bm.userid = gr.userid LEFT JOIN `user` u ON u.id = bm.userid $condition """); - - cnd.and(new Static("bm.bmzt = 5")); + cnd.and("bm.bmzt", "=", 5); cnd.and("gr.hdid", "=", hdid); - - if (Strings.isNotBlank(ghid)) { - cnd.and("gr.ghid", "=", ghid); - } + cnd.andEX("gr.ghid", "=", ghid); cnd.groupBy("bm.userid"); - cnd.asc("bm.unionname").asc("bm.unitname").asc("gr.age"); + cnd.asc("u.unioncode"); sql.setCondition(cnd); List list = lxyGrxxService.list(sql); - int i = 1; - for (Record r : list) { - r.set("index", i); - List chry = Json.fromJsonAsList(NutMap.class, r.getString("chry")); - for (NutMap map : chry) { - r.set("rych", (r.getString("rych") == null ? "" : r.getString("rych")) + " " + map.getString("shry")); - } - i++; + for (int i = 0; i < list.size(); i++) { + list.get(i).set("index", i + 1); } -// HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); -// Configure config = Configure.newBuilder().bind("list", policy).build(); - HashMap map = new HashMap<>(); - map.put("hdmc", hdname); - map.put("mapList", list); - String fileName = "疗休养人员名单汇总表.xls"; - response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1")); -// TemplateExportParams params = new TemplateExportParams("C:\\Users\\mayn\\Desktop\\lxyrymd.xls"); - TemplateExportParams params = new TemplateExportParams(officeTemplateUtil.getPath("lxy_lxyrymd")); -// Workbook workbook = ExcelExportUtil.exportExcel(params, map); -// workbook.write(response.getOutputStream()); - Workbook workbook = ExcelExportUtil.exportExcel(params, map); - ServletOutputStream outputStream = response.getOutputStream(); - workbook.write(outputStream); - outputStream.close(); - } + NutMap map = new NutMap(); + map.put("list", list); + HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + Configure config = Configure.builder().bind("list", policy).build(); + + String fileName = "疗休养人员名单汇总表.docx"; + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), "ISO8859-1")); + + XWPFTemplate.compile(officeTemplateUtil.getPath("lxy_lxyrymd"), config).render(map).write(response.getOutputStream()); + response.getOutputStream().close(); + } @At @RequiresPermissions("zgfw.lxy.hdtj") diff --git a/src/main/resources/views/platform/zgfw/lxy/HdTj.html b/src/main/resources/views/platform/zgfw/lxy/HdTj.html index c7312e8..82159a9 100644 --- a/src/main/resources/views/platform/zgfw/lxy/HdTj.html +++ b/src/main/resources/views/platform/zgfw/lxy/HdTj.html @@ -2,19 +2,10 @@ layout("/layouts/platform.html"){ #-->
@@ -63,38 +54,43 @@ layout("/layouts/platform.html"){
-
- 一键发送 - - 导 出 -
+ + + - - - - - - - - - + + + + + + + + + + + @@ -120,101 +116,21 @@ layout("/layouts/platform.html"){ @@ -289,7 +205,7 @@ display: -webkit-box; cancelButtonText: '取消', type: 'warning' }).then(async () => { - window.location.href = '/platform/zgfw/lxy/hdtj/doExport?hdid=' + this.pageForm.hdid + '&ghid=' + this.pageForm.ghid + '&hdname=' + obj.name + window.open('/platform/zgfw/lxy/hdtj/doExport?hdid=' + this.pageForm.hdid + '&ghid=' + this.pageForm.ghid + '&hdname=' + obj.name) }) },