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