From 693848bb16dac2a07d385d7cd5a347860aac1260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E5=AD=A6=E6=88=90?= <1274337408@qq.com> Date: Wed, 23 Sep 2026 19:47:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=97=E7=90=86=E5=B7=A5=E4=BD=93=E8=82=B2?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8-=E4=BD=93=E8=82=B2=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8-=E6=B4=BB=E5=8A=A8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=9A=E5=AF=BC=E5=87=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=90=8D=E5=8D=95=E6=96=B0=E5=A2=9E=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=88=E5=AF=BC=E5=87=BA=E4=BF=A1=E6=81=AF=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=96=B0=E5=A2=9E=E6=8A=A5=E5=90=8D=E4=BA=BA=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=BC=9A=E5=91=98=E3=80=81=E6=98=AF=E5=90=A6=E5=9C=A8?= =?UTF-8?q?=E8=81=8C=E5=9C=A8=E7=BC=96=E3=80=81=E6=98=AF=E4=BD=95=E4=BA=BA?= =?UTF-8?q?=E5=A1=AB=E6=8A=A5=E7=9A=84=E6=8A=A5=E5=90=8D=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=8A=A5=E5=90=8D=E4=BA=BA=E7=94=B5=E8=AF=9D?= =?UTF-8?q?=E5=8F=B7=E7=A0=81=E3=80=82=E5=B9=B6=E4=B8=94=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9C=80=E8=A6=81=E6=8C=89=E7=85=A7=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E5=AD=A6=E9=99=A2=E7=BC=96=E5=8F=B7=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=EF=BC=8C=E5=AF=B9=E4=BA=8E=E7=BC=BA=E4=B9=8F?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E4=BF=A1=E6=81=AF=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A6=82=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=8F=B7=EF=BC=8C=E7=94=B5?= =?UTF-8?q?=E8=AF=9D=EF=BC=8C=E5=B7=A5=E5=8F=B7=E7=AD=89=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=AD=A6=E7=A4=BA=EF=BC=89=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../school/ActivityCommonController.java | 107 ++++++++++++++---- 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/v/nutz/activity/controller/school/ActivityCommonController.java b/src/main/java/io/v/nutz/activity/controller/school/ActivityCommonController.java index 0219cfb..9a5c4fe 100644 --- a/src/main/java/io/v/nutz/activity/controller/school/ActivityCommonController.java +++ b/src/main/java/io/v/nutz/activity/controller/school/ActivityCommonController.java @@ -18,6 +18,12 @@ import io.v.nutz.service.ViService; import io.v.nutz.sys.models.Sys_union; import io.v.nutz.sys.services.SysUnionService; import io.v.nutz.util.ShiroUtil; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.nutz.dao.Cnd; @@ -256,33 +262,45 @@ public class ActivityCommonController { @At + @Ok("void") public void exportXlsx(String id, String unionId, HttpServletResponse response) throws IOException { Sql sql = Sqls.create(""" SELECT - app.username, - app.loginname, - app.identity, - app.activityUnionName, - app.sex, - app.mobile, - u.idCard, - u.userState, - ev.allName, - sc.`name` activityName, - app.`team` teamName, - app.`unitname` + app.username, + COALESCE(NULLIF(app.loginname, ''), u.loginname) loginname, + app.identity, + app.activityUnionName, + app.sex, + COALESCE(NULLIF(app.mobile, ''), u.mobile) mobile, + u.idCard idcard, + COALESCE(unit.unitcode, u.unitcode) unitcode, + CASE WHEN u.member = 1 THEN '是' ELSE '否' END isMember, + CASE + WHEN u.userState IN ('在职', '在岗') + AND (u.preparedBy LIKE '%事业编%' OR u.preparedBy LIKE '%在编%') + AND u.preparedBy NOT LIKE '%非事业编%' + THEN '是' ELSE '否' + END isOnStaff, + apply_user.username applyUsername, + ev.allName, + sc.`name` activityName, + app.`team` teamName, + app.`unitname` FROM - `activity_school_apply` app - LEFT JOIN `user` u ON u.id = app.userId - LEFT JOIN activity_event ev ON ev.id = app.eventId - LEFT JOIN activity_school sc ON sc.id=app.activityId + `activity_school_apply` app + LEFT JOIN `user` u ON u.id = app.userId + LEFT JOIN `user` apply_user ON apply_user.id = app.applyUser + LEFT JOIN sys_unit unit ON unit.id = app.unitId + LEFT JOIN activity_event ev ON ev.id = app.eventId + LEFT JOIN activity_school sc ON sc.id=app.activityId WHERE - activityId = @id - $cnd + activityId = @id + $cnd ORDER BY - ev.projectCode desc, - app.activityUnionName DESC, - app.`team` ASC, + COALESCE(unit.unitcode, u.unitcode) ASC, + ev.projectCode DESC, + app.activityUnionName DESC, + app.`team` ASC, CASE WHEN JSON_SEARCH( app.identity, 'one', '7' ) IS NOT NULL THEN 1 @@ -312,7 +330,10 @@ public class ActivityCommonController { entityList.add(new ExcelExportEntity("姓名", "username", 20)); entityList.add(new ExcelExportEntity("性别", "sex", 10)); entityList.add(new ExcelExportEntity("身份证号", "idcard", 20)); - entityList.add(new ExcelExportEntity("电话", "mobile", 20)); + entityList.add(new ExcelExportEntity("报名人电话号码", "mobile", 20)); + entityList.add(new ExcelExportEntity("是否会员", "isMember", 15)); + entityList.add(new ExcelExportEntity("是否在职在编", "isOnStaff", 20)); + entityList.add(new ExcelExportEntity("填报人", "applyUsername", 20)); entityList.add(new ExcelExportEntity("所在单位", "unitname", 50)); entityList.add(new ExcelExportEntity("身份", "sf", 30)); @@ -324,9 +345,51 @@ public class ActivityCommonController { response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment;filename=" + new String((activityName + "报名表.xls").getBytes("utf-8"), "ISO8859-1")); Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, nutMaps); + markMissingRequiredInfo(workbook); workbook.write(response.getOutputStream()); } + /** + * 对导出名单中缺失的必要信息进行醒目标记。 + */ + private void markMissingRequiredInfo(Workbook workbook) { + Sheet sheet = workbook.getSheetAt(0); + Row headerRow = sheet.getRow(0); + if (headerRow == null) { + return; + } + + Set requiredHeaders = new HashSet<>(Arrays.asList("工号", "身份证号", "报名人电话号码")); + List requiredColumns = new ArrayList<>(); + for (Cell cell : headerRow) { + if (requiredHeaders.contains(cell.getStringCellValue())) { + requiredColumns.add(cell.getColumnIndex()); + } + } + + Map warningStyles = new HashMap<>(); + for (int rowIndex = 1; rowIndex <= sheet.getLastRowNum(); rowIndex++) { + Row row = sheet.getRow(rowIndex); + if (row == null) { + continue; + } + for (Integer columnIndex : requiredColumns) { + Cell cell = row.getCell(columnIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); + if (Strings.isBlank(cell.toString())) { + cell.setCellValue("信息缺失"); + CellStyle warningStyle = warningStyles.computeIfAbsent(cell.getCellStyle().getIndex(), key -> { + CellStyle style = workbook.createCellStyle(); + style.cloneStyleFrom(cell.getCellStyle()); + style.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + return style; + }); + cell.setCellStyle(warningStyle); + } + } + } + } + private static class personType {