|
|
@@ -2,10 +2,14 @@ package com.etotem.cfc.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.dto.EmotionAlertVO;
|
|
|
+import com.etotem.cfc.entity.Child;
|
|
|
import com.etotem.cfc.entity.EmotionAlert;
|
|
|
import com.etotem.cfc.entity.EmotionCheckin;
|
|
|
+import com.etotem.cfc.entity.FollowUp;
|
|
|
+import com.etotem.cfc.mapper.ChildMapper;
|
|
|
import com.etotem.cfc.mapper.EmotionAlertMapper;
|
|
|
import com.etotem.cfc.mapper.EmotionCheckinMapper;
|
|
|
+import com.etotem.cfc.mapper.FollowUpMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -29,6 +33,12 @@ public class EmotionAlertService {
|
|
|
@Resource
|
|
|
private EmotionCheckinMapper emotionCheckinMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private FollowUpMapper followUpMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ChildMapper childMapper;
|
|
|
+
|
|
|
@Resource
|
|
|
private WechatAlertTemplateService wechatAlertTemplateService;
|
|
|
|
|
|
@@ -134,6 +144,30 @@ public class EmotionAlertService {
|
|
|
alert.setResolved(true);
|
|
|
alert.setResolvedAt(new Date());
|
|
|
emotionAlertMapper.updateById(alert);
|
|
|
+
|
|
|
+ // Auto-create follow_up record
|
|
|
+ try {
|
|
|
+ FollowUp followUp = new FollowUp();
|
|
|
+ followUp.setChildId(alert.getChildId());
|
|
|
+ Child child = childMapper.selectById(alert.getChildId());
|
|
|
+ if (child != null && child.getFamilyId() != null) {
|
|
|
+ followUp.setFamilyId(child.getFamilyId());
|
|
|
+ }
|
|
|
+ followUp.setDescription("情绪/心理危机告警已处理,待7天后复核");
|
|
|
+ followUp.setStatus("pending");
|
|
|
+ followUp.setPriority("high");
|
|
|
+
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.add(Calendar.DAY_OF_YEAR, 7);
|
|
|
+ followUp.setDueDate(cal.getTime());
|
|
|
+
|
|
|
+ followUp.setCreatedAt(new Date());
|
|
|
+
|
|
|
+ followUpMapper.insert(followUp);
|
|
|
+ log.info("告警解决后自动生成follow_up: childId={}, alertId={}", alert.getChildId(), alertId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建follow_up失败: {}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|