|
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* FileName: CompanyEmailConfigServiceImpl
|
|
@@ -130,16 +131,21 @@ public class CompanyEmailConfigServiceImpl implements CompanyEmailConfigService
|
|
|
|
|
|
@Override
|
|
|
public void sendCompanyEmail(List<Integer> idList) {
|
|
|
- for(Integer id : idList){
|
|
|
- CompanyEmailConfigDO configDO = companyEmailConfigMapper.selectCompanyEmailConfigById(id);
|
|
|
- //把缺失数据的邮件发送到该公司名下的邮箱地址
|
|
|
- if(configDO.getOpenStatus().equals(OpenStatusType.YES.getCode())){
|
|
|
- sendEmail(configDO.getCompanyId(),configDO.getEmail());
|
|
|
+ List<CompanyEmailConfigDO> configDOList = companyEmailConfigMapper.selectCompanyEmailConfigByIdList(idList);
|
|
|
+ Map<String,List<CompanyEmailConfigDO>> companyListMap = configDOList.stream().collect(Collectors.groupingBy(e -> e.getCompanyId()));
|
|
|
+ for(String companyId : companyListMap.keySet()){
|
|
|
+ StringBuffer emails = new StringBuffer();
|
|
|
+ List<CompanyEmailConfigDO> configDOS = companyListMap.get(companyId);
|
|
|
+ for(CompanyEmailConfigDO configDO: configDOS){
|
|
|
+ emails.append(configDO.getEmail()).append(";");
|
|
|
}
|
|
|
+ //把缺失数据的邮件发送到该公司名下的邮箱地址
|
|
|
+ sendEmail(companyId,emails.toString());
|
|
|
}
|
|
|
}
|
|
|
+ @Override
|
|
|
//邮件校验处理
|
|
|
- private void sendEmail(String companyId, String email) {
|
|
|
+ public void sendEmail(String companyId, String emails) {
|
|
|
List<String> fundIdList = fundInfoMapper.getFundIdByCompanyId(companyId);
|
|
|
if(fundIdList.size() < 1){
|
|
|
return;
|
|
@@ -156,13 +162,19 @@ public class CompanyEmailConfigServiceImpl implements CompanyEmailConfigService
|
|
|
file.setExecutable(true);
|
|
|
try {
|
|
|
MailboxInfoDTO dto = getFromEmailInfo();
|
|
|
- EmailUtil.senEmail(dto,email,file,javaMailSender);
|
|
|
+ EmailUtil.senEmail(dto,emails,file,javaMailSender);
|
|
|
//发送成功之后修改数据为已发送
|
|
|
deletionInfoMapper.updateSendStatusByFundId(fundIdList);
|
|
|
//写入发送历史
|
|
|
- saveCompanyEmailSendHistory(companyId,email,1,ResultCode.SEND_SUCCESS.getMsg());
|
|
|
+ String[] emailList = emails.split(";");
|
|
|
+ for(String email : emailList){
|
|
|
+ saveCompanyEmailSendHistory(companyId,email,1,ResultCode.SEND_SUCCESS.getMsg());
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
- saveCompanyEmailSendHistory(companyId,email,0,e.getMessage());
|
|
|
+ String[] emailList = emails.split(";");
|
|
|
+ for(String email : emailList){
|
|
|
+ saveCompanyEmailSendHistory(companyId,email,0,e.getMessage());
|
|
|
+ }
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
@@ -211,7 +223,7 @@ public class CompanyEmailConfigServiceImpl implements CompanyEmailConfigService
|
|
|
}
|
|
|
values.put(sheetName,dataList);
|
|
|
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName,head,values,null);
|
|
|
- File file = new File(path+"/"+DateUtils.getDate()+"基金缺失明细.xls");
|
|
|
+ File file = new File(path+"/"+DateUtils.format(new Date(),DateUtils.YYYYMMDDHHMMSS)+"基金缺失明细.xls");
|
|
|
if(!file.exists()){
|
|
|
try {
|
|
|
file.createNewFile();
|