工作组分发资料邮件发送失败不影响业务
This commit is contained in:
+4
-4
@@ -261,8 +261,8 @@ public class PayWorkingGroupDistributionRecordController extends JeroController<
|
||||
@ApiOperation(value="资料分发-分发", notes="资料分发-分发")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
payWorkingGroupDistributionRecordService.add(payWorkingGroupDistributionRecord);
|
||||
return Result.OK("分发成功!");
|
||||
List<String> list = payWorkingGroupDistributionRecordService.add(payWorkingGroupDistributionRecord);
|
||||
return Result.OK("分发成功!",list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,8 +276,8 @@ public class PayWorkingGroupDistributionRecordController extends JeroController<
|
||||
@ApiOperation(value="资料分发-批量分发", notes="资料分发-批量分发")
|
||||
@PostMapping(value = "/addBatch")
|
||||
public Result<?> addBatch(@RequestBody PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
payWorkingGroupDistributionRecordService.addBatch(payWorkingGroupDistributionRecord);
|
||||
return Result.OK("添加成功!");
|
||||
List<String> list = payWorkingGroupDistributionRecordService.addBatch(payWorkingGroupDistributionRecord);
|
||||
return Result.OK("分发成功!",list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-3
@@ -6,7 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.project.entity.DownloadFileRecord;
|
||||
import com.jero.project.entity.PayWorkingGroupDistributionRecord;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: pay_working_group_distribution_record
|
||||
@@ -24,7 +25,7 @@ public interface IPayWorkingGroupDistributionRecordService extends IService<PayW
|
||||
* @Return
|
||||
* @Exception
|
||||
*/
|
||||
void add(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord);
|
||||
List<String> add(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord);
|
||||
/**
|
||||
* @Description 批量分发
|
||||
* @Author lqt
|
||||
@@ -33,7 +34,7 @@ public interface IPayWorkingGroupDistributionRecordService extends IService<PayW
|
||||
* @Return
|
||||
* @Exception
|
||||
*/
|
||||
void addBatch(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord);
|
||||
List<String> addBatch(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord);
|
||||
|
||||
/**
|
||||
* 企业端资料下载分页列表查询
|
||||
|
||||
+78
-62
@@ -87,7 +87,7 @@ public class PayWorkingGroupDistributionRecordServiceImpl extends ServiceImpl<Pa
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
public List<String> add(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
if(StringUtils.isBlank(payWorkingGroupDistributionRecord.getContactsIds())){
|
||||
throw new JeroBootException("成员id不能为空!");
|
||||
}
|
||||
@@ -208,44 +208,52 @@ public class PayWorkingGroupDistributionRecordServiceImpl extends ServiceImpl<Pa
|
||||
// 发送消息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String finalMsg = msg;
|
||||
List<String> listMsg = new ArrayList<>();
|
||||
list.forEach(p->{
|
||||
List<PayWorkingGroupDistributionRecord> listStr = listPayWorkingGroupDistributionRecord.stream().filter(item->
|
||||
(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1) ?
|
||||
Objects.equals(item.getTemporaryContactsId(),p.getId()) :
|
||||
Objects.equals(item.getContactsId(),p.getId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(listStr)){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<PayWorkingGroupDistributionRecord> listStr = listPayWorkingGroupDistributionRecord.stream().filter(item->
|
||||
(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1) ?
|
||||
Objects.equals(item.getTemporaryContactsId(),p.getId()) :
|
||||
Objects.equals(item.getContactsId(),p.getId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(listStr)){
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
if(!StringUtils.isBlank(p.getEmail())){
|
||||
sendMessageDTO.setEmail(PasswordUtil.decrypt(p.getEmail()));
|
||||
// 发送消息
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
if(!StringUtils.isBlank(p.getEmail())){
|
||||
sendMessageDTO.setEmail(PasswordUtil.decrypt(p.getEmail()));
|
||||
}
|
||||
if(!StringUtils.isEmpty(p.getPhone())){
|
||||
sendMessageDTO.setToUser(PasswordUtil.decrypt(p.getPhone()));
|
||||
sendMessageDTO.setPhone(PasswordUtil.decrypt(p.getPhone()));
|
||||
}
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("workGroupName", finalMsg);
|
||||
sendMessageDTO.setFromUser(sysUser.getUsername());
|
||||
sendMessageDTO.setTemplateCode(CompanyMessageEnums.MSG12.getCode());
|
||||
sendMessageDTO.setTemplateParam(map);
|
||||
sendMessageDTO.setListFile(listFile);
|
||||
sendMessageDTO.setBusType("C_OPEN_TYPE12");
|
||||
JSONObject json = new JSONObject();
|
||||
if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1){
|
||||
json.put("id",listStr.get(0).getSubId());
|
||||
}else if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE2){
|
||||
json.put("id",listStr.get(0).getProjectId());
|
||||
}
|
||||
sendMessageDTO.setBusId(json.toJSONString());
|
||||
sendMessageService.SendMessageService(sendMessageDTO);
|
||||
}catch (Exception e){
|
||||
if(e.getMessage().contains("邮件发送") && !listMsg.contains(p.getName() + "邮件发送失败")){
|
||||
listMsg.add(p.getName() + "邮件发送失败");
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isEmpty(p.getPhone())){
|
||||
sendMessageDTO.setToUser(PasswordUtil.decrypt(p.getPhone()));
|
||||
sendMessageDTO.setPhone(PasswordUtil.decrypt(p.getPhone()));
|
||||
}
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("workGroupName", finalMsg);
|
||||
sendMessageDTO.setFromUser(sysUser.getUsername());
|
||||
sendMessageDTO.setTemplateCode(CompanyMessageEnums.MSG12.getCode());
|
||||
sendMessageDTO.setTemplateParam(map);
|
||||
sendMessageDTO.setListFile(listFile);
|
||||
sendMessageDTO.setBusType("C_OPEN_TYPE12");
|
||||
JSONObject json = new JSONObject();
|
||||
if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1){
|
||||
json.put("id",listStr.get(0).getSubId());
|
||||
}else if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE2){
|
||||
json.put("id",listStr.get(0).getProjectId());
|
||||
}
|
||||
sendMessageDTO.setBusId(json.toJSONString());
|
||||
sendMessageService.SendMessageService(sendMessageDTO);
|
||||
});
|
||||
return listMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
public List<String> addBatch(PayWorkingGroupDistributionRecord payWorkingGroupDistributionRecord) {
|
||||
if(StringUtils.isBlank(payWorkingGroupDistributionRecord.getContactsIds())){
|
||||
throw new JeroBootException("成员id不能为空!");
|
||||
}
|
||||
@@ -394,39 +402,47 @@ public class PayWorkingGroupDistributionRecordServiceImpl extends ServiceImpl<Pa
|
||||
// 发送消息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String finalMsg = msg;
|
||||
List<String> listMsg = new ArrayList<>();
|
||||
list.forEach(p->{
|
||||
List<PayWorkingGroupDistributionRecord> listStr = listPayWorkingGroupDistributionRecord.stream().filter(item->
|
||||
(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1) ?
|
||||
Objects.equals(item.getTemporaryContactsId(),p.getId()) :
|
||||
Objects.equals(item.getContactsId(),p.getId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(listStr)){
|
||||
return;
|
||||
try {
|
||||
List<PayWorkingGroupDistributionRecord> listStr = listPayWorkingGroupDistributionRecord.stream().filter(item->
|
||||
(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1) ?
|
||||
Objects.equals(item.getTemporaryContactsId(),p.getId()) :
|
||||
Objects.equals(item.getContactsId(),p.getId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(listStr)){
|
||||
return;
|
||||
}
|
||||
// 发送消息
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
if(!StringUtils.isBlank(p.getEmail())){
|
||||
sendMessageDTO.setEmail(PasswordUtil.decrypt(p.getEmail()));
|
||||
}
|
||||
if(!StringUtils.isEmpty(p.getPhone())){
|
||||
sendMessageDTO.setToUser(PasswordUtil.decrypt(p.getPhone()));
|
||||
sendMessageDTO.setPhone(PasswordUtil.decrypt(p.getPhone()));
|
||||
}
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("workGroupName", finalMsg);
|
||||
sendMessageDTO.setFromUser(sysUser.getUsername());
|
||||
sendMessageDTO.setTemplateCode(CompanyMessageEnums.MSG12.getCode());
|
||||
sendMessageDTO.setTemplateParam(map);
|
||||
sendMessageDTO.setListFile(listFile);
|
||||
sendMessageDTO.setBusType("C_OPEN_TYPE12");
|
||||
JSONObject json = new JSONObject();
|
||||
if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1){
|
||||
json.put("id",listStr.get(0).getSubId());
|
||||
}else if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE2){
|
||||
json.put("id",listStr.get(0).getProjectId());
|
||||
}
|
||||
sendMessageDTO.setBusId(json.toJSONString());
|
||||
sendMessageService.SendMessageService(sendMessageDTO);
|
||||
}catch (Exception e){
|
||||
if(e.getMessage().contains("邮件发送") && !listMsg.contains(p.getName() + "邮件发送失败")){
|
||||
listMsg.add(p.getName() + "邮件发送失败");
|
||||
}
|
||||
}
|
||||
// 发送消息
|
||||
SendMessageDTO sendMessageDTO = new SendMessageDTO();
|
||||
if(!StringUtils.isBlank(p.getEmail())){
|
||||
sendMessageDTO.setEmail(PasswordUtil.decrypt(p.getEmail()));
|
||||
}
|
||||
if(!StringUtils.isEmpty(p.getPhone())){
|
||||
sendMessageDTO.setToUser(PasswordUtil.decrypt(p.getPhone()));
|
||||
sendMessageDTO.setPhone(PasswordUtil.decrypt(p.getPhone()));
|
||||
}
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("workGroupName", finalMsg);
|
||||
sendMessageDTO.setFromUser(sysUser.getUsername());
|
||||
sendMessageDTO.setTemplateCode(CompanyMessageEnums.MSG12.getCode());
|
||||
sendMessageDTO.setTemplateParam(map);
|
||||
sendMessageDTO.setListFile(listFile);
|
||||
sendMessageDTO.setBusType("C_OPEN_TYPE12");
|
||||
JSONObject json = new JSONObject();
|
||||
if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE1){
|
||||
json.put("id",listStr.get(0).getSubId());
|
||||
}else if(payWorkingGroupDistributionRecord.getProjectType() == PayProjectCommon.PROJECT_TYPE_FILE2){
|
||||
json.put("id",listStr.get(0).getProjectId());
|
||||
}
|
||||
sendMessageDTO.setBusId(json.toJSONString());
|
||||
sendMessageService.SendMessageService(sendMessageDTO);
|
||||
});
|
||||
return listMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user