评估申请添加序号
This commit is contained in:
@@ -81,7 +81,7 @@ public class LbAssessmentApply implements Serializable {
|
||||
|
||||
@TableField("sorted_num")
|
||||
@Schema(description = "排序序号")
|
||||
private Integer sortedNum;
|
||||
private String sortedNum;
|
||||
|
||||
@TableField("created_at")
|
||||
@Schema(description = "创建时间")
|
||||
|
||||
@@ -194,7 +194,7 @@ public class LbAssessmentApplyServiceImpl
|
||||
entity.setCreatedAt(now);
|
||||
}
|
||||
entity.setUpdatedAt(now);
|
||||
if (entity.getSortedNum() == null) {
|
||||
if (entity.getSortedNum() == null || entity.getSortedNum().trim().isEmpty()) {
|
||||
entity.setSortedNum(resolveNextSortedNum(entity.getTenantId()));
|
||||
}
|
||||
refreshNotificationText(entity);
|
||||
@@ -392,11 +392,7 @@ public class LbAssessmentApplyServiceImpl
|
||||
* 返回可用的通知文案:库中已有则直接返回,否则生成并落库。
|
||||
*/
|
||||
private String ensureAndSaveNotificationText(LbAssessmentApply record) {
|
||||
String text = record.getNotificationText();
|
||||
if (text != null && !text.trim().isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
text = formatAssessmentNotificationText(record);
|
||||
String text = formatAssessmentNotificationText(record);
|
||||
LbAssessmentApply update = new LbAssessmentApply();
|
||||
update.setId(record.getId());
|
||||
update.setNotificationText(text);
|
||||
@@ -436,6 +432,7 @@ public class LbAssessmentApplyServiceImpl
|
||||
String moderatorDateTimeText = formatModeratorConnectDateTime(record.getApplicationDatetime());
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(record.getSortedNum());
|
||||
sb.append(teacherName).append(" ,您好!\n");
|
||||
if (!assessmentDateTimeText.isEmpty()) {
|
||||
sb.append(assessmentDateTimeText).append("由您主评\n");
|
||||
@@ -643,20 +640,31 @@ public class LbAssessmentApplyServiceImpl
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private Integer resolveNextSortedNum(String tenantId) {
|
||||
private String resolveNextSortedNum(String tenantId) {
|
||||
LambdaQueryWrapper<LbAssessmentApply> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LbAssessmentApply::getTenantId, tenantId.trim())
|
||||
.orderByDesc(LbAssessmentApply::getSortedNum)
|
||||
.last("LIMIT 1");
|
||||
LbAssessmentApply latest = this.getOne(queryWrapper);
|
||||
if (latest == null || latest.getSortedNum() == null) {
|
||||
return 1;
|
||||
.isNotNull(LbAssessmentApply::getSortedNum)
|
||||
.ne(LbAssessmentApply::getSortedNum, "");
|
||||
List<LbAssessmentApply> list = this.list(queryWrapper);
|
||||
int max = 0;
|
||||
for (LbAssessmentApply item : list) {
|
||||
String num = item.getSortedNum();
|
||||
if (num == null || num.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
max = Math.max(max, Integer.parseInt(num.trim()));
|
||||
} catch (NumberFormatException ignored) {
|
||||
// 非数字序号不参与自增计算
|
||||
}
|
||||
}
|
||||
return latest.getSortedNum() + 1;
|
||||
return String.valueOf(max + 1);
|
||||
}
|
||||
|
||||
private static String formatSortedNum(Integer sortedNum, int fallback) {
|
||||
return sortedNum != null ? String.valueOf(sortedNum) : String.valueOf(fallback);
|
||||
private static String formatSortedNum(String sortedNum, int fallback) {
|
||||
return sortedNum != null && !sortedNum.trim().isEmpty()
|
||||
? sortedNum.trim()
|
||||
: String.valueOf(fallback);
|
||||
}
|
||||
|
||||
private static String nullToEmpty(String value) {
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE `lb_assessment_apply`
|
||||
ADD COLUMN `sorted_num` int NULL DEFAULT NULL COMMENT '排序序号' AFTER `application_datetime`;
|
||||
ADD COLUMN `sorted_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '排序序号' AFTER `application_datetime`;
|
||||
|
||||
Reference in New Issue
Block a user