MailBoxServiceImpl.java
3.31 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
package com.huaheng.pc.config.sendMail.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.documentWarning.service.IDocumentWarningService;
import com.huaheng.pc.config.receiptType.domain.ReceiptType;
import com.huaheng.pc.config.sendMail.domain.MailBox;
import com.huaheng.pc.config.sendMail.domain.SendMail;
import com.huaheng.pc.config.sendMail.mapper.MailBoxMapper;
import com.huaheng.pc.config.sendMail.mapper.SendMailMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class MailBoxServiceImpl extends ServiceImpl<MailBoxMapper, MailBox> implements MailBoxService {
@Resource
private MailBoxMapper mailBoxMapper;
@Resource
private IDocumentWarningService documentWarningService;
@Resource
private SendMailService sendMailService;
@Resource
private MailService mailService;
/**
* 根据邮件类型发送邮件
*
* @param type
* @return
*/
@Override
@Transactional
public AjaxResult sendMail(Integer type) {
MailBox
mailBox = new MailBox();
mailBox.setType(type);
LambdaQueryWrapper<MailBox> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(MailBox::getType,type);
List<MailBox> mailBoxs = this.list(lambdaQueryWrapper);
List<String> persons = new ArrayList<>();
for (MailBox box : mailBoxs) {
persons.add(box.getEmail());
}
String subject = "昆山仓部报表";
String content = "<html><body><a href=\"http://172.16.2.10:9008/jmreport/view/1370215917140709376\" >七天物料交易图</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369889034708586496\" >七天物料交易数据</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1370570301456388096\" >物料交易频次数据</a>" +
"<br/><a href=\"http://172.16.2.10:9008/jmreport/view/1368849556351094784\" >库龄分布图</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369887964003438592\" >库龄0-3个月数据</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369888140189372416\" >库龄3-6个月数据</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369888410508070912\" >库龄6-9个月数据</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369888507509739520\" >库龄9-12个月数据</a>" +
" <a href=\"http://172.16.2.10:9008/jmreport/view/1369888675143487488\" >库龄大于1年数据</a>" +
"<br/><br/><br/>昆山wms推送</body></html>";
String[] cc = null;
mailService.sendHtmlMail(persons.toArray(new String[persons.size()]),subject,content,cc);
return AjaxResult.success("成功");
}
}