生成通知文案
This commit is contained in:
@@ -109,6 +109,19 @@ public class LbAssessmentApplyController {
|
|||||||
return ResponseEntity.internalServerError().body(result);
|
return ResponseEntity.internalServerError().body(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/notificationText")
|
||||||
|
@Operation(summary = "生成评估会议通知文案", description = "根据租户ID与记录ID查询申请评估记录,拼接并返回格式化通知文本")
|
||||||
|
public ResponseEntity<Map<String, Object>> getNotificationText(
|
||||||
|
@Parameter(description = "租户ID", required = true) @RequestParam String tenantId,
|
||||||
|
@Parameter(description = "申请评估记录ID(UUID)", required = true) @RequestParam String id) {
|
||||||
|
Map<String, Object> result = lbAssessmentApplyService.buildAssessmentNotificationText(tenantId, id);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.badRequest().body(result);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@Operation(summary = "导出申请评估Excel", description = "按租户ID与申请日期时间范围导出申请评估列表")
|
@Operation(summary = "导出申请评估Excel", description = "按租户ID与申请日期时间范围导出申请评估列表")
|
||||||
public void export(
|
public void export(
|
||||||
|
|||||||
@@ -36,4 +36,9 @@ public interface ILbAssessmentApplyService extends IService<LbAssessmentApply> {
|
|||||||
String applicationDatetimeEnd,
|
String applicationDatetimeEnd,
|
||||||
HttpServletResponse response);
|
HttpServletResponse response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据记录ID生成评估会议通知文案。
|
||||||
|
*/
|
||||||
|
Map<String, Object> buildAssessmentNotificationText(String tenantId, String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.net.URLEncoder;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -286,6 +287,98 @@ public class LbAssessmentApplyServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final DateTimeFormatter NOTIFICATION_DATE_TIME_FORMATTER =
|
||||||
|
DateTimeFormatter.ofPattern("M月d日 HH:mm");
|
||||||
|
private static final DateTimeFormatter MODERATOR_DATE_TIME_FORMATTER =
|
||||||
|
DateTimeFormatter.ofPattern("M月d日 H:mm");
|
||||||
|
private static final long MODERATOR_CONNECT_MINUTES_BEFORE = 20L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> buildAssessmentNotificationText(String tenantId, String id) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (tenantId == null || tenantId.trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "tenantId不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (id == null || id.trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "id不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<LbAssessmentApply> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(LbAssessmentApply::getTenantId, tenantId.trim())
|
||||||
|
.eq(LbAssessmentApply::getId, id.trim());
|
||||||
|
LbAssessmentApply record = this.getOne(queryWrapper);
|
||||||
|
if (record == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "未找到对应的申请评估记录");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = formatAssessmentNotificationText(record);
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("message", "生成成功");
|
||||||
|
result.put("data", text);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成评估会议通知文案失败, tenantId={}, id={}", tenantId, id, e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "生成失败:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatAssessmentNotificationText(LbAssessmentApply record) {
|
||||||
|
String teacherName = nullToEmpty(record.getAssessmentTeacherName());
|
||||||
|
String applicantName = nullToEmpty(record.getApplicantName());
|
||||||
|
String colleagueName = nullToEmpty(record.getColleagueName());
|
||||||
|
String teamLeaderName = nullToEmpty(record.getTeamLeaderName());
|
||||||
|
String moderatorName = nullToEmpty(record.getModeratorName());
|
||||||
|
String meetingNumber = nullToEmpty(record.getMeetingNumber());
|
||||||
|
|
||||||
|
String assessmentDateTimeText = formatNotificationDateTime(record.getApplicationDatetime());
|
||||||
|
String moderatorDateTimeText = formatModeratorConnectDateTime(record.getApplicationDatetime());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(teacherName).append(" 老师,您好!\n");
|
||||||
|
if (!assessmentDateTimeText.isEmpty()) {
|
||||||
|
sb.append(assessmentDateTimeText).append("由您主评\n");
|
||||||
|
} else {
|
||||||
|
sb.append("由您主评\n");
|
||||||
|
}
|
||||||
|
sb.append("申评人: ").append(applicantName).append('\n');
|
||||||
|
sb.append("同事: ").append(colleagueName).append('\n');
|
||||||
|
sb.append("团队长: ").append(teamLeaderName).append('\n');
|
||||||
|
sb.append("评估老师: ").append(teacherName).append("老师\n");
|
||||||
|
sb.append("主持人: ").append(moderatorName);
|
||||||
|
if (!moderatorDateTimeText.isEmpty()) {
|
||||||
|
sb.append(" ").append(moderatorDateTimeText);
|
||||||
|
}
|
||||||
|
sb.append("连线☎\n\n");
|
||||||
|
sb.append("#腾讯会议: ").append(meetingNumber).append('\n');
|
||||||
|
sb.append("❤旁听学习须关麦静场\n");
|
||||||
|
sb.append("❤影响干扰会被移出");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatNotificationDateTime(LocalDateTime datetime) {
|
||||||
|
if (datetime == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return datetime.format(NOTIFICATION_DATE_TIME_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatModeratorConnectDateTime(LocalDateTime applicationDatetime) {
|
||||||
|
if (applicationDatetime == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
LocalDateTime connectTime = applicationDatetime.minus(MODERATOR_CONNECT_MINUTES_BEFORE, ChronoUnit.MINUTES);
|
||||||
|
return connectTime.format(MODERATOR_DATE_TIME_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exportExcel(String tenantId,
|
public void exportExcel(String tenantId,
|
||||||
String applicationDatetimeStart,
|
String applicationDatetimeStart,
|
||||||
|
|||||||
Reference in New Issue
Block a user