南大三十年教职工疗休养

This commit is contained in:
2026-06-25 20:54:58 +08:00
parent f39dad393f
commit a1547b133e
16 changed files with 328 additions and 62 deletions
@@ -16,6 +16,7 @@ import com.budwk.app.web.commons.base.Globals;
import com.budwk.app.web.commons.auth.utils.AuthUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.activity.basic.models.ActivityUserScope;
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourSetting;
import com.budwk.app.zhgh.dayofficework.tour.models.TourSetting;
import io.swagger.annotations.ApiOperation;
import org.jsoup.Jsoup;
@@ -310,7 +311,30 @@ public class SysHomeController {
.addv("year", setting.getYear())
.addv("title", setting.getYear() + "暑期疗休养")
.addv("imageUrl", imageUrl)
.addv("href", "/platform/tour/signup"));
.addv("href", "/platform/tour/signup")
.addv("vx", 0.028)
.addv("vy", 0.022));
}
Cnd thirtyTeachCnd = Cnd.where(ThirtyTeachTourSetting::getDelFlag, "=", false)
.and(ThirtyTeachTourSetting::getEnabled, "=", true)
.and(ThirtyTeachTourSetting::getYear, "=", currentYear)
.and(ThirtyTeachTourSetting::getHomeSignupEntryEnabled, "=", true);
thirtyTeachCnd.asc(ThirtyTeachTourSetting::getSortNo);
thirtyTeachCnd.desc(ThirtyTeachTourSetting::getUpdatedAt);
thirtyTeachCnd.desc(ThirtyTeachTourSetting::getCreatedAt);
List<ThirtyTeachTourSetting> thirtyTeachSettings = dao.query(ThirtyTeachTourSetting.class, thirtyTeachCnd);
for (ThirtyTeachTourSetting setting : thirtyTeachSettings) {
// 30年教龄疗休养与暑期疗休养共用首页默认图,但跳转地址和浮动方向保持独立。
String imageUrl = StrUtil.blankToDefault(setting.getHomeSignupEntryImage(), Globals.AppDomain + "/assets/platform/images/thirtyTeachTour/疗休养logo.png");
rows.add(NutMap.NEW()
.addv("id", "thirtyTeachTour-" + setting.getId())
.addv("year", setting.getYear())
.addv("title", setting.getYear() + "30年教龄疗休养")
.addv("imageUrl", imageUrl)
.addv("href", "/platform/thirtyTeachTour/signup")
.addv("startCorner", "rightTop")
.addv("vx", -0.026)
.addv("vy", 0.024));
}
return Result.success(rows);
}
@@ -50,10 +50,10 @@ public class ThirtyTeachTourBranchUserAssignmentController {
*/
@At
@SaCheckPermission("thirtyTeachTour.branchUserAssignment")
public Result pageData(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword) {
public Result pageData(PageForm pageForm, Integer year, String settingId, String matterId, String periodId,
String personType, String keyword) {
return Result.success(tourUserAssignmentService.branchAssignmentPage(pageForm, year, settingId, matterId,
personType, keyword));
periodId, personType, keyword));
}
/**
@@ -62,10 +62,10 @@ public class ThirtyTeachTourBranchUserAssignmentController {
@At
@SaCheckPermission("thirtyTeachTour.branchUserAssignment")
@Ok("void")
public void exportData(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword, HttpServletResponse response) {
public void exportData(PageForm pageForm, Integer year, String settingId, String matterId, String periodId,
String personType, String keyword, HttpServletResponse response) {
List<NutMap> rows = tourUserAssignmentService.branchAssignmentExportRows(pageForm, year, settingId, matterId,
personType, keyword);
periodId, personType, keyword);
ExportParams exportParams = new ExportParams();
exportParams.setSheetName("分工会人员分配");
exportParams.setType(ExcelType.XSSF);
@@ -113,7 +113,7 @@ public class ThirtyTeachTourBranchUserAssignmentController {
* 查询当前配置下已启用的出行时间段,供人员分配弹窗按钮组使用。
*/
@At
@SaCheckPermission("thirtyTeachTour.branchUserAssignment.assign")
@SaCheckPermission("thirtyTeachTour.branchUserAssignment")
public Result travelPeriodOptions(String settingId) {
return Result.success(tourUserAssignmentService.listBranchEnabledTravelPeriods(settingId));
}
@@ -367,6 +367,7 @@ public class ThirtyTeachTourLedgerController {
entities.add(new ExcelExportEntity("携带家属", "familyCountText", 14));
entities.add(new ExcelExportEntity("是否参加", "joinedText", 14));
entities.add(new ExcelExportEntity("报销超出费用", "overCostReimbursedText", 18));
entities.add(new ExcelExportEntity("图片材料", "photoFiles", 36));
List<NutMap> rows = queryLedgerExportRows(startYear, endYear, keyword, unionId, lineId, travelPeriod,
lineType, directFamilyOnly, overCostOnly);
@@ -406,6 +407,7 @@ public class ThirtyTeachTourLedgerController {
END AS travelPeriod,
t.lineType,
t.signupTime,
t.photoFiles,
IFNULL(f.familyCount, 0) AS familyCount,
t.joined,
t.overCostReimbursed
@@ -51,10 +51,10 @@ public class ThirtyTeachTourSchoolUserAssignmentController {
*/
@At
@SaCheckPermission("thirtyTeachTour.schoolUserAssignment")
public Result pageData(PageForm pageForm, Integer year, String settingId, String matterId, String unionId,
String personType, String keyword, String assignSource, Boolean cancelled) {
public Result pageData(PageForm pageForm, Integer year, String settingId, String matterId, String periodId,
String unionId, String personType, String keyword, String assignSource, Boolean cancelled) {
return Result.success(tourUserAssignmentService.schoolAssignmentPage(pageForm, year, settingId, matterId,
unionId, personType, keyword, assignSource, cancelled));
periodId, unionId, personType, keyword, assignSource, cancelled));
}
/**
@@ -63,10 +63,11 @@ public class ThirtyTeachTourSchoolUserAssignmentController {
@At
@SaCheckPermission("thirtyTeachTour.schoolUserAssignment")
@Ok("void")
public void exportData(PageForm pageForm, Integer year, String settingId, String matterId, String unionId,
String personType, String keyword, String assignSource, Boolean cancelled, HttpServletResponse response) {
public void exportData(PageForm pageForm, Integer year, String settingId, String matterId, String periodId,
String unionId, String personType, String keyword, String assignSource, Boolean cancelled,
HttpServletResponse response) {
List<NutMap> rows = tourUserAssignmentService.schoolAssignmentExportRows(pageForm, year, settingId, matterId,
unionId, personType, keyword, assignSource, cancelled);
periodId, unionId, personType, keyword, assignSource, cancelled);
ExportParams exportParams = new ExportParams();
exportParams.setSheetName("校工会人员分配");
exportParams.setType(ExcelType.XSSF);
@@ -82,14 +83,15 @@ public class ThirtyTeachTourSchoolUserAssignmentController {
@Aop(TransAop.READ_COMMITTED)
@SaCheckPermission("thirtyTeachTour.schoolUserAssignment")
@SLog(type = "tour", tag = "疗休养校工会人员分配", msg = "发送校工会人员分配提醒")
public Result sendReminder(PageForm pageForm, Integer year, String settingId, String matterId, String unionId,
String personType, String keyword, String assignSource, Boolean cancelled, String content) {
public Result sendReminder(PageForm pageForm, Integer year, String settingId, String matterId, String periodId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled, String content) {
if (StrUtil.isBlank(content)) {
return Result.error("请输入提醒内容");
}
try {
return Result.success(tourUserAssignmentService.sendSchoolAssignmentReminder(pageForm, year, settingId,
matterId, unionId, personType, keyword, assignSource, cancelled, content));
matterId, periodId, unionId, personType, keyword, assignSource, cancelled, content));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
@@ -124,6 +126,15 @@ public class ThirtyTeachTourSchoolUserAssignmentController {
return Result.success(tourUserAssignmentService.listMatterOptions(settingId));
}
/**
* 查询当前配置下已启用的出行时间段,供校工会人员分配列表筛选使用。
*/
@At
@SaCheckPermission("thirtyTeachTour.schoolUserAssignment")
public Result travelPeriodOptions(String settingId) {
return Result.success(tourUserAssignmentService.listBranchEnabledTravelPeriods(settingId));
}
/**
* 查询分工会选项,供筛选和候选人员过滤使用。
*/
@@ -155,7 +155,7 @@ public class ThirtyTeachTourSettingController {
if (StrUtil.isNotBlank(quotaLimitMessage)) {
return Result.error(quotaLimitMessage);
}
String periodQuotaLimitMessage = tourSettingService.checkPeriodQuotaLimit(periodQuotas, unionQuotas);
String periodQuotaLimitMessage = tourSettingService.checkPeriodQuotaLimit(tourSetting.getId(), periodQuotas, unionQuotas);
if (StrUtil.isNotBlank(periodQuotaLimitMessage)) {
return Result.error(periodQuotaLimitMessage);
}
@@ -1129,6 +1129,11 @@ public class ThirtyTeachTourSignupController {
if (scopeResult != null) {
return scopeResult;
}
String periodPermissionMessage = tourUserAssignmentService.checkSignupAssignmentPeriodPermission(
setting.getId(), matter.getTravelStartTime(), matter.getTravelEndTime());
if (StrUtil.isNotBlank(periodPermissionMessage)) {
return Result.error(periodPermissionMessage);
}
CycleAllowedTimes cycleAllowedTimes = calculateCycleAllowedTimes(matter, setting, oldLedger);
if (!cycleAllowedTimes.canApply()) {
return Result.error(buildCycleAllowedTimesNotice(cycleAllowedTimes));
@@ -63,4 +63,9 @@ public class ThirtyTeachTourSettingUnionQuota extends BaseModel implements Seria
* 页面展示用实时会员数不落库
*/
private Integer memberCount;
/**
* Page-only count of formal users already assigned by school union for this branch union.
*/
private Integer schoolFormalAssignedCount;
}
@@ -76,11 +76,12 @@ public interface ThirtyTeachTourSettingService extends BaseService<ThirtyTeachTo
/**
* 校验时间段名额合计是否超过对应分工会正式名额
*
* @param settingId 疗休养配置ID用于统计校工会已占用的分工会正式名额
* @param periodQuotas 时间段名额 JSON
* @param unionQuotas 分工会名额 JSON
* @return 通过返回空字符串不通过返回业务提示
*/
String checkPeriodQuotaLimit(String periodQuotas, String unionQuotas);
String checkPeriodQuotaLimit(String settingId, String periodQuotas, String unionQuotas);
/**
* 清理指定疗休养配置下的分工会名额
@@ -25,8 +25,8 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
* @return 校工会分配记录分页数据
*/
Pagination<NutMap> schoolAssignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled);
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled);
/**
* 按校工会人员分配页面当前筛选条件查询导出数据不做分页截断
@@ -43,8 +43,8 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
* @return 符合当前页面查询条件的人员分配导出数据
*/
List<NutMap> schoolAssignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled);
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled);
/**
* 按校工会人员分配页面当前筛选条件发送报名提醒
@@ -62,8 +62,8 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
* @return 发送结果receiverCount 表示本次去重后的接收人数
*/
NutMap sendSchoolAssignmentReminder(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled, String content);
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled, String content);
/**
* 分页查询校工会可分配候选人候选人来自疗休养配置的可参加人员范围并排除同一配置下已分配人员
@@ -92,7 +92,7 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
* @return 分工会分配记录分页数据
*/
Pagination<NutMap> branchAssignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword);
String periodId, String personType, String keyword);
/**
* 按分工会人员分配页面当前筛选条件查询导出数据不做分页截断
@@ -106,7 +106,7 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
* @return 当前登录人所在分工会下符合页面查询条件的人员分配导出数据
*/
List<NutMap> branchAssignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword);
String periodId, String personType, String keyword);
/**
* 分页查询当前登录人所在分工会可分配候选人候选人来自疗休养配置的可参加人员范围
@@ -263,6 +263,17 @@ public interface ThirtyTeachTourUserAssignmentService extends BaseService<Thirty
*/
NutMap currentUserAssignmentInfo(String settingId);
/**
* 校验当前报名人员的分配时间段是否允许报名当前线路
* 人员分配记录中未维护 periodIdperiodName 时不限制维护后必须与线路出行起止日期完全一致
*
* @param settingId 30年教龄疗休养配置ID
* @param matterTravelStartTime 线路出行开始时间
* @param matterTravelEndTime 线路出行结束时间
* @return 为空表示允许报名不为空时返回前端提示文案
*/
String checkSignupAssignmentPeriodPermission(String settingId, String matterTravelStartTime, String matterTravelEndTime);
/**
* 用户报名写入台账后回填该用户在同一疗休养配置下已存在的人员分配记录
* 仅更新事项线路旅行社快照字段不新增记录不修改 assignSource 和人员类型
@@ -7,6 +7,7 @@ import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourSe
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourSettingPeriodQuota;
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourSettingTravelPeriod;
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourSettingUnionQuota;
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.models.ThirtyTeachTourUserAssignment;
import com.budwk.app.zhgh.dayofficework.thirtyTeachTour.service.ThirtyTeachTourSettingService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
@@ -47,7 +48,8 @@ public class ThirtyTeachTourSettingServiceImpl extends BaseServiceImpl<ThirtyTea
un.name AS unionName,
COALESCE(quota.formalQuota, 0) AS formalQuota,
COALESCE(quota.backupQuota, 0) AS backupQuota,
COALESCE(user_count.memberCount, 0) AS memberCount
COALESCE(user_count.memberCount, 0) AS memberCount,
COALESCE(school_assigned.schoolFormalAssignedCount, 0) AS schoolFormalAssignedCount
FROM sys_union un
LEFT JOIN thirty_teach_tour_setting_union_quota quota
ON quota.unionId = un.id
@@ -70,12 +72,21 @@ public class ThirtyTeachTourSettingServiceImpl extends BaseServiceImpl<ThirtyTea
SELECT 1
FROM tour_ledger summer_ledger
WHERE summer_ledger.delFlag = 0
AND summer_ledger.joined = 1
AND summer_ledger.`year` = @year
AND summer_ledger.jobNo = u.loginname
)
GROUP BY u.unionid
) user_count ON user_count.unionId = un.id
LEFT JOIN (
SELECT assignment.unionId AS unionId, COUNT(1) AS schoolFormalAssignedCount
FROM thirty_teach_tour_user_assignment assignment
WHERE assignment.settingId = @quotaSettingId
AND assignment.delFlag = 0
AND assignment.assignSource = 'SCHOOL_UNION'
AND assignment.personType = 'FORMAL'
AND (assignment.cancelled IS NULL OR assignment.cancelled = 0)
GROUP BY assignment.unionId
) school_assigned ON school_assigned.unionId = un.id
ORDER BY un.unionCode ASC
""");
sql.setParam("quotaSettingId", quotaSettingId);
@@ -92,6 +103,7 @@ public class ThirtyTeachTourSettingServiceImpl extends BaseServiceImpl<ThirtyTea
quota.setFormalQuota(defaultInt(row.getInt("formalQuota")));
quota.setBackupQuota(defaultInt(row.getInt("backupQuota")));
quota.setMemberCount(defaultInt(row.getInt("memberCount")));
quota.setSchoolFormalAssignedCount(defaultInt(row.getInt("schoolFormalAssignedCount")));
return quota;
}).collect(Collectors.toList());
}
@@ -242,7 +254,7 @@ public class ThirtyTeachTourSettingServiceImpl extends BaseServiceImpl<ThirtyTea
}
@Override
public String checkPeriodQuotaLimit(String periodQuotas, String unionQuotas) {
public String checkPeriodQuotaLimit(String settingId, String periodQuotas, String unionQuotas) {
if (StrUtil.isBlank(periodQuotas)) {
return "";
}
@@ -260,18 +272,47 @@ public class ThirtyTeachTourSettingServiceImpl extends BaseServiceImpl<ThirtyTea
.filter(item -> item != null && StrUtil.isNotBlank(item.getUnionId()))
.collect(Collectors.groupingBy(ThirtyTeachTourSettingPeriodQuota::getUnionId,
Collectors.summingInt(item -> defaultInt(item.getFormalQuota()))));
Map<String, Integer> schoolAssignedCountMap = countSchoolFormalAssignedByUnion(settingId);
for (Map.Entry<String, Integer> entry : periodQuotaTotalMap.entrySet()) {
ThirtyTeachTourSettingUnionQuota unionQuota = unionQuotaMap.get(entry.getKey());
int formalQuota = unionQuota == null ? 0 : defaultInt(unionQuota.getFormalQuota());
if (entry.getValue() > formalQuota) {
int schoolAssignedCount = schoolAssignedCountMap.getOrDefault(entry.getKey(), 0);
// Time-period quota can only use branch-union quota that has not been occupied by school-union assignment.
int availableFormalQuota = Math.max(formalQuota - schoolAssignedCount, 0);
if (entry.getValue() > availableFormalQuota) {
String unionName = unionQuota == null ? "" : unionQuota.getUnionName();
return "分工会【" + StrUtil.blankToDefault(unionName, entry.getKey()) + "】时间段名额合计 "
+ entry.getValue() + ",不能大于当前分工会正式名额 " + formalQuota;
+ entry.getValue() + ",不能大于扣除校工会已分配后的可分配正式名额 " + availableFormalQuota;
}
}
return "";
}
/**
* Count active formal users assigned by school union, grouped by branch union, for quota validation.
*/
private Map<String, Integer> countSchoolFormalAssignedByUnion(String settingId) {
if (StrUtil.isBlank(settingId)) {
return Collections.emptyMap();
}
Sql sql = Sqls.create("""
SELECT unionId, COUNT(1) AS assignedCount
FROM thirty_teach_tour_user_assignment
WHERE settingId = @settingId
AND delFlag = 0
AND assignSource = @assignSource
AND personType = @personType
AND (cancelled IS NULL OR cancelled = 0)
GROUP BY unionId
""");
sql.setParam("settingId", settingId);
sql.setParam("assignSource", ThirtyTeachTourUserAssignment.ASSIGN_SOURCE_SCHOOL_UNION);
sql.setParam("personType", ThirtyTeachTourUserAssignment.PERSON_TYPE_FORMAL);
return listMap(sql).stream()
.filter(row -> StrUtil.isNotBlank(row.getString("unionId")))
.collect(Collectors.toMap(row -> row.getString("unionId"), row -> defaultInt(row.getInt("assignedCount")), (a, b) -> a));
}
@Override
public void clearUnionQuotas(String settingId) {
if (StrUtil.isNotBlank(settingId)) {
@@ -51,8 +51,8 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
@Override
public Pagination<NutMap> schoolAssignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled) {
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled) {
Sql sql = Sqls.create("""
SELECT
a.*,
@@ -75,6 +75,8 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
cnd.andEX("s.`year`", "=", year);
cnd.andEX("a.settingId", "=", settingId);
cnd.andEX("a.matterId", "=", matterId);
// 校工会人员分配列表支持按配置中的出行时间段精确筛选
cnd.andEX("a.periodId", "=", periodId);
cnd.andEX("a.unionId", "=", unionId);
cnd.andEX("a.personType", "=", personType);
appendCancelledCondition(cnd, cancelled);
@@ -91,21 +93,23 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
@Override
public List<NutMap> schoolAssignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled) {
List<NutMap> rows = assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword, assignSource, cancelled);
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled) {
List<NutMap> rows = assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword,
assignSource, cancelled, periodId);
fillAssignmentExportText(rows);
return rows;
}
@Override
public NutMap sendSchoolAssignmentReminder(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled, String content) {
String periodId, String unionId, String personType, String keyword,
String assignSource, Boolean cancelled, String content) {
if (StrUtil.isBlank(content)) {
throw new IllegalArgumentException("请输入提醒内容");
}
List<NutMap> rows = assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword, assignSource, cancelled);
List<NutMap> rows = assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword,
assignSource, cancelled, periodId);
List<String> receiverIds = rows.stream()
.map(row -> row.getString("userId"))
.filter(StrUtil::isNotBlank)
@@ -144,24 +148,24 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
@Override
public Pagination<NutMap> branchAssignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword) {
String periodId, String personType, String keyword) {
String unionId = SecurityUtil.getUnionId();
if (StrUtil.isBlank(unionId)) {
return emptyPagination(pageForm);
}
return assignmentPage(pageForm, year, settingId, matterId, unionId, personType, keyword,
return assignmentPage(pageForm, year, settingId, matterId, periodId, unionId, personType, keyword,
ThirtyTeachTourUserAssignment.ASSIGN_SOURCE_BRANCH_UNION);
}
@Override
public List<NutMap> branchAssignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String personType, String keyword) {
String periodId, String personType, String keyword) {
String unionId = SecurityUtil.getUnionId();
if (StrUtil.isBlank(unionId)) {
return Collections.emptyList();
}
List<NutMap> rows = assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword,
ThirtyTeachTourUserAssignment.ASSIGN_SOURCE_BRANCH_UNION, null);
ThirtyTeachTourUserAssignment.ASSIGN_SOURCE_BRANCH_UNION, null, periodId);
fillAssignmentExportText(rows);
return rows;
}
@@ -178,9 +182,15 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
/**
* 构建人员分配导出查询筛选条件与页面分页列表保持一致但导出时不追加分页
*/
private List<NutMap> assignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled) {
return assignmentExportRows(pageForm, year, settingId, matterId, unionId, personType, keyword, assignSource, cancelled, null);
}
private List<NutMap> assignmentExportRows(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource,
Boolean cancelled) {
Boolean cancelled, String periodId) {
Sql sql = Sqls.create("""
SELECT
a.*,
@@ -204,6 +214,7 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
cnd.andEX("a.matterId", "=", matterId);
cnd.andEX("a.unionId", "=", unionId);
cnd.andEX("a.personType", "=", personType);
cnd.andEX("a.periodId", "=", periodId);
appendCancelledCondition(cnd, cancelled);
if (StrUtil.isNotBlank(keyword)) {
SqlExpressionGroup group = new SqlExpressionGroup();
@@ -875,6 +886,8 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
unionName,
boardingPlace,
photoFiles,
periodId,
periodName,
personType,
assignSource,
IFNULL(cancelled, 0) AS cancelled
@@ -893,6 +906,61 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
return map == null ? NutMap.NEW() : map;
}
/**
* 校验当前报名人员的分配时间段是否允许报名当前线路
* 只有人员分配记录维护了 periodId periodName 时才限制线路未维护时沿用原报名规则
*/
@Override
public String checkSignupAssignmentPeriodPermission(String settingId, String matterTravelStartTime, String matterTravelEndTime) {
if (StrUtil.isBlank(settingId)) {
return "";
}
NutMap assignment = currentUserAssignmentInfo(settingId);
if (assignment == null || assignment.isEmpty()) {
return "";
}
String periodId = assignment.getString("periodId", "");
String periodName = assignment.getString("periodName", "");
if (StrUtil.isBlank(periodId) && StrUtil.isBlank(periodName)) {
return "";
}
ThirtyTeachTourSettingTravelPeriod period = fetchAssignmentTravelPeriod(settingId, periodId, periodName);
if (period == null || !sameTravelDate(period.getStartDate(), matterTravelStartTime)
|| !sameTravelDate(period.getEndDate(), matterTravelEndTime)) {
return "没有该路线报名权限";
}
return "";
}
/**
* 优先按 periodId 获取人员分配时间段历史数据只有 periodName 时再按名称兜底匹配
*/
private ThirtyTeachTourSettingTravelPeriod fetchAssignmentTravelPeriod(String settingId, String periodId, String periodName) {
Cnd cnd = Cnd.where("settingId", "=", settingId)
.and("enabled", "=", true)
.and("delFlag", "=", false);
if (StrUtil.isNotBlank(periodId)) {
cnd.and("id", "=", periodId);
} else {
cnd.and("periodName", "=", periodName);
}
return dao().fetch(ThirtyTeachTourSettingTravelPeriod.class, cnd);
}
/**
* 事项时间可能带时分秒时间段配置只有日期统一截取日期部分后比较
*/
private boolean sameTravelDate(String periodDate, String matterDateTime) {
if (StrUtil.isBlank(periodDate) || StrUtil.isBlank(matterDateTime)) {
return false;
}
String normalizedMatterDate = matterDateTime.trim();
if (normalizedMatterDate.length() >= 10) {
normalizedMatterDate = normalizedMatterDate.substring(0, 10);
}
return periodDate.trim().equals(normalizedMatterDate);
}
@Override
public int backfillExistingAssignmentAfterSignup(String settingId, String matterId, String userId, String boardingPlace, String photoFiles) {
if (StrUtil.isBlank(settingId) || StrUtil.isBlank(matterId) || StrUtil.isBlank(userId)) {
@@ -1113,7 +1181,12 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
}
private Pagination<NutMap> assignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String unionId, String personType, String keyword, String assignSource) {
String unionId, String personType, String keyword, String assignSource) {
return assignmentPage(pageForm, year, settingId, matterId, null, unionId, personType, keyword, assignSource);
}
private Pagination<NutMap> assignmentPage(PageForm pageForm, Integer year, String settingId, String matterId,
String periodId, String unionId, String personType, String keyword, String assignSource) {
Sql sql = Sqls.create("""
SELECT
a.*,
@@ -1135,6 +1208,7 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
cnd.andEX("s.`year`", "=", year);
cnd.andEX("a.settingId", "=", settingId);
cnd.andEX("a.matterId", "=", matterId);
cnd.andEX("a.periodId", "=", periodId);
cnd.andEX("a.unionId", "=", unionId);
cnd.andEX("a.personType", "=", personType);
if (StrUtil.isNotBlank(keyword)) {
@@ -1179,7 +1253,6 @@ public class ThirtyTeachTourUserAssignmentServiceImpl extends BaseServiceImpl<Th
SELECT jobNo, COUNT(1) AS joinedCount
FROM tour_ledger
WHERE delFlag = 0
AND joined = 1
AND `year` = @currentYear
GROUP BY jobNo
) summer_joined ON summer_joined.jobNo = u.loginname