SmsNoticeServiceImpl.java
3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.zhongzhi.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongzhi.common.constant.SMSTemplate;
import com.zhongzhi.common.utils.AliyunSmsUtil;
import com.zhongzhi.dao.ProjectDAO;
import com.zhongzhi.dao.StudentDAO;
import com.zhongzhi.dto.notice.SmsNoticeDTO;
import com.zhongzhi.dto.notice.SmsNoticePageDTO;
import com.zhongzhi.model.ProjectDO;
import com.zhongzhi.model.SmsNoticeDO;
import com.zhongzhi.dao.SmsNoticeMapper;
import com.zhongzhi.model.StudentDO;
import com.zhongzhi.service.SmsNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongzhi.vo.project.SeedTrackProjectPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
* 短信通知记录 服务实现类
* </p>
*
* @author DengMin
* @since 2022-04-15
*/
@Service
public class SmsNoticeServiceImpl extends ServiceImpl<SmsNoticeMapper, SmsNoticeDO> implements SmsNoticeService {
@Autowired
private AliyunSmsUtil aliyunSmsUtil;
@Autowired
private ProjectDAO projectDAO;
@Autowired
private StudentDAO studentDAO;
@Override
@Transactional(rollbackFor = Exception.class)
public void batchSend(SmsNoticeDTO smsNoticeDTO) {
List<SeedTrackProjectPageVO> list = projectDAO.getProjectList(smsNoticeDTO.getMatchId(), smsNoticeDTO.getProjectGroup(), smsNoticeDTO.getProjectSchedule(), smsNoticeDTO.getProjectStatus(), smsNoticeDTO.getName());
if (list.size() > 0) {
for (SeedTrackProjectPageVO projectDO : list) {
String msg = projectDO.getProjectSchedule() + "," + projectDO.getProjectStatus();
aliyunSmsUtil.sendTemplateMsg(msg, projectDO.getTelephone(), SMSTemplate.PROJECT_PROGRESS);
SmsNoticeDO smsNoticeDO = new SmsNoticeDO();
smsNoticeDO.setProjectId(projectDO.getId());
smsNoticeDO.setName(projectDO.getName());
smsNoticeDO.setTelephone(projectDO.getTelephone());
smsNoticeDO.setContent(msg);
this.baseMapper.insert(smsNoticeDO);
}
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void send(SmsNoticeDTO smsNoticeDTO) {
if (smsNoticeDTO.getIds().size() > 0) {
for (Long id : smsNoticeDTO.getIds()) {
ProjectDO projectDO = projectDAO.selectById(id);
if (projectDO != null) {
StudentDO studentDO = studentDAO.selectById(projectDO.getProposerId());
String msg = projectDO.getProjectSchedule() + "," + projectDO.getProjectStatus();
aliyunSmsUtil.sendTemplateMsg(msg, studentDO.getTelephone(), SMSTemplate.PROJECT_PROGRESS);
SmsNoticeDO smsNoticeDO = new SmsNoticeDO();
smsNoticeDO.setProjectId(projectDO.getId());
smsNoticeDO.setName(studentDO.getName());
smsNoticeDO.setTelephone(studentDO.getTelephone());
smsNoticeDO.setContent(msg);
this.baseMapper.insert(smsNoticeDO);
}
}
}
}
@Override
public IPage getListByPage(SmsNoticePageDTO smsNoticePageDTO) {
Page page = new Page(smsNoticePageDTO.getPageNo(), smsNoticePageDTO.getPageSize());
return this.baseMapper.getListByPage(page, smsNoticePageDTO.getDate(), smsNoticePageDTO.getName());
}
}