南理工体育活动-体育比赛活动-活动信息管理:导出活动人员名单新增字段(导出信息需要新增报名人是否会员、是否在职在编、是何人填报的报名信息以及报名人电话号码。并且导出数据需要按照所属学院编号进行排序,对于缺乏必要信息的数据如身份证号,电话,工号等需要进行警示);

This commit is contained in:
2026-09-23 19:47:52 +08:00
parent 4b110407c6
commit 693848bb16
@@ -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<String> requiredHeaders = new HashSet<>(Arrays.asList("工号", "身份证号", "报名人电话号码"));
List<Integer> requiredColumns = new ArrayList<>();
for (Cell cell : headerRow) {
if (requiredHeaders.contains(cell.getStringCellValue())) {
requiredColumns.add(cell.getColumnIndex());
}
}
Map<Short, CellStyle> 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 {