|
@@ -6,12 +6,20 @@ import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyMessa
|
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyMessagePlanSaveReqVO;
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyMessagePlanSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyMessagePlanDO;
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyMessagePlanDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.notifyconfig.NotifyMessagePlanMapper;
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.notifyconfig.NotifyMessagePlanMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
+import java.lang.reflect.Type;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 计划发送的站内信消息 Service 实现类
|
|
* 计划发送的站内信消息 Service 实现类
|
|
@@ -24,6 +32,8 @@ public class NotifyMessagePlanServiceImpl extends ServiceImpl<NotifyMessagePlanM
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private NotifyMessagePlanMapper notifyMessagePlanMapper;
|
|
private NotifyMessagePlanMapper notifyMessagePlanMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private NotifySendService notifySendService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Long createNotifyMessagePlan(NotifyMessagePlanSaveReqVO createReqVO) {
|
|
public Long createNotifyMessagePlan(NotifyMessagePlanSaveReqVO createReqVO) {
|
|
@@ -59,4 +69,34 @@ public class NotifyMessagePlanServiceImpl extends ServiceImpl<NotifyMessagePlanM
|
|
|
return notifyMessagePlanMapper.selectPage(pageReqVO);
|
|
return notifyMessagePlanMapper.selectPage(pageReqVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean checkPlanSend() {
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ List<NotifyMessagePlanDO> list = list(Wrappers.<NotifyMessagePlanDO>lambdaQuery()
|
|
|
|
|
+ .le(NotifyMessagePlanDO::getPlanSendTime, now)
|
|
|
|
|
+ .eq(NotifyMessagePlanDO::getSendStatus, 0));
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+ Type type = new TypeToken<Map<String, Object>>(){}.getType();
|
|
|
|
|
+ for (NotifyMessagePlanDO notifyMessagePlanDO : list) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 执行发送
|
|
|
|
|
+ NotifyTemplateSendReqVO notifyTemplateSendReqVO = new NotifyTemplateSendReqVO();
|
|
|
|
|
+ notifyTemplateSendReqVO.setUserId(notifyMessagePlanDO.getUserId());
|
|
|
|
|
+ notifyTemplateSendReqVO.setUserType(notifyMessagePlanDO.getUserType());
|
|
|
|
|
+ notifyTemplateSendReqVO.setTemplateCode(notifyMessagePlanDO.getTemplateCode());
|
|
|
|
|
+ Map<String, Object> map = gson.fromJson(notifyMessagePlanDO.getTemplateParams(), type);
|
|
|
|
|
+ notifyTemplateSendReqVO.setTemplateParams(map);
|
|
|
|
|
+ notifySendService.sendSingleNotifyFromPlan(notifyTemplateSendReqVO);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("发送消息出现异常:{}", e);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ // 修改掉状态
|
|
|
|
|
+ update(Wrappers.<NotifyMessagePlanDO>lambdaUpdate()
|
|
|
|
|
+ .eq(NotifyMessagePlanDO::getId, notifyMessagePlanDO.getId())
|
|
|
|
|
+ .set(NotifyMessagePlanDO::getSendStatus, 1));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|