邮件发送记录增加发送状态

This commit is contained in:
hejinbo
2023-11-06 11:16:54 +08:00
parent d3701b7299
commit f0e9261c22
4 changed files with 56 additions and 24 deletions
@@ -93,7 +93,7 @@ public class EmailOutUtil {
* @param subject 邮件主题
* @param fileList 邮件附件
*/
public void sendEmil(String to, String message, String subject, List<File> fileList, File file) {
public Boolean sendEmil(String to, String message, String subject, List<File> fileList, File file) {
try {
String messageContent = "<html><body><p style=\"font-family: Arial, sans-serif; font-size: 18px;\">"+message+"。</p></body></html>";
MimeBodyPart messageBodyPart = new MimeBodyPart();
@@ -160,8 +160,9 @@ public class EmailOutUtil {
Transport.send(msg);
} catch (Exception e) {
e.printStackTrace();
return Boolean.FALSE;
}
return Boolean.TRUE;
}
/**
@@ -34,6 +34,22 @@ public class SendMailRecord extends BaseEntity {
/** 案件编号 */
private String caseNum;
/** 发送状态 */
private Integer sendStatus;
public Integer getSendStatus() {
return sendStatus;
}
public void setSendStatus(Integer sendStatus) {
this.sendStatus = sendStatus;
}
public String getCaseNum() {
return caseNum;
}
@@ -105,10 +105,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("resName", affiliate.getName());
datas.put("resAddress", affiliate.getResidenAffili());
String responSex = affiliate.getResponSex();
if (responSex.equals("0")){
datas.put("resSex","男");
}else{
datas.put("resSex","女");
if (responSex.equals("0")) {
datas.put("resSex", "男");
} else {
datas.put("resSex", "女");
}
Date responBirth = affiliate.getResponBirth();
if (responBirth != null) {
@@ -264,7 +264,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
String annexName = caseAttach.getAnnexName();
boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
if (isImageFile) {
String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
System.out.println("路径是===========" + annexPath);
PictureRenderData pictureRenderData = WordUtil
.rebuildImageContent(100, 100, null, annexPath);
@@ -274,7 +274,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
String annexName = caseAttach.getAnnexName();
boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
if (isImageFile) {
String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
System.out.println("路径是===========" + annexPath);
PictureRenderData pictureRenderData = WordUtil
.rebuildImageContent(100, 100, null, annexPath);
@@ -326,10 +326,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
.build();
//保存到附件表里,先判断之前有没有,有的话更新,没有的话新增
List<CaseAttach> caseAttachList = caseAttachMapper.getCaseAttachByCaseIdAndType(caseAttach);
if (caseAttachList != null && caseAttachList.size()>0) {
if (caseAttachList != null && caseAttachList.size() > 0) {
//之前已经生成过了,更新
int i = caseAttachMapper.updateCaseAttachBycaseid(caseAttach);
}else {
} else {
//之前没生成过,新增
int i = caseAttachMapper.save(caseAttach);
if (i > 0) {
@@ -540,8 +540,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
}
}
//发送邮件
sendCaseEmail(caseApplication1, appEmail, resEmail);
boolean b = sendCaseEmail(caseApplication1, appEmail, resEmail);
SendMailRecord sendMailRecord = new SendMailRecord();
sendMailRecord.setCaseId(id);
sendMailRecord.setMailAddress(appEmail);
@@ -549,8 +548,12 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
sendMailRecord.setMailName("签署后的裁决书");
sendMailRecord.setSendTime(new Date());
sendMailRecord.setCreateBy(getUsername());
if (b) {
sendMailRecord.setSendStatus(1);
} else {
sendMailRecord.setSendStatus(0);
}
sendMailRecordMapper.saveSendMailRecord(sendMailRecord);
SendMailRecord sendMailRecord1 = new SendMailRecord();
sendMailRecord1.setCaseId(id);
sendMailRecord1.setMailAddress(resEmail);
@@ -558,6 +561,11 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
sendMailRecord1.setMailName("签署后的裁决书");
sendMailRecord1.setSendTime(new Date());
sendMailRecord1.setCreateBy(getUsername());
if (b) {
sendMailRecord1.setSendStatus(1);
} else {
sendMailRecord1.setSendStatus(0);
}
sendMailRecordMapper.saveSendMailRecord(sendMailRecord1);
// 新增日志
@@ -573,7 +581,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
* @param appEmail
* @param resEmail
*/
private void sendCaseEmail(CaseApplication caseApplication1, String appEmail, String resEmail) {
private boolean sendCaseEmail(CaseApplication caseApplication1, String appEmail, String resEmail) {
List<File> fileList = new ArrayList<>();
File file = null;
@@ -593,14 +601,18 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
}
if (file != null) {
try {
emailOutUtil.sendEmil(appEmail, "您好,审核后的裁决书在附件中请查阅", "签署后的裁决书", fileList, null);
emailOutUtil.sendEmil(resEmail, "您好,审核后的裁决书在附件中请查阅", "签署后的裁决书", fileList, null);
Boolean aBoolean = emailOutUtil.sendEmil(appEmail, "您好,审核后的裁决书在附件中请查阅", "签署后的裁决书", fileList, null);
Boolean aBoolean1 = emailOutUtil.sendEmil(resEmail, "您好,审核后的裁决书在附件中请查阅", "签署后的裁决书", fileList, null);
if (aBoolean && aBoolean1){
return Boolean.TRUE;
}
} catch (Exception e) {
System.out.println("邮件发送失败++++++++++++++++++++++++++++++++");
System.out.println(e.toString());
return Boolean.FALSE;
}
}
return Boolean.FALSE;
}
@Override
@@ -678,10 +690,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("resName", affiliate.getName());
datas.put("resAddress", affiliate.getResidenAffili());
String responSex = affiliate.getResponSex();
if (responSex.equals("0")){
datas.put("resSex","男");
}else{
datas.put("resSex","女");
if (responSex.equals("0")) {
datas.put("resSex", "男");
} else {
datas.put("resSex", "女");
}
Date responBirth = affiliate.getResponBirth();
if (responBirth != null) {
@@ -838,7 +850,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
String annexName = caseAttach.getAnnexName();
boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
if (isImageFile) {
String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
System.out.println("路径是===========" + annexPath);
PictureRenderData pictureRenderData = WordUtil
.rebuildImageContent(100, 100, null, annexPath);
@@ -848,7 +860,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
String annexName = caseAttach.getAnnexName();
boolean isImageFile = Pattern.matches(".*\\.(jpg|png|gif|bmp)$", annexName);
if (isImageFile) {
String annexPath = "/home/ruoyi"+caseAttach.getAnnexPath();
String annexPath = "/home/ruoyi" + caseAttach.getAnnexPath();
System.out.println("路径是===========" + annexPath);
PictureRenderData pictureRenderData = WordUtil
.rebuildImageContent(100, 100, null, annexPath);
@@ -12,12 +12,13 @@
<result property="sendTime" column="send_time" />
<result property="caseId" column="case_id" />
<result property="caseNum" column="case_num" />
<result property="sendStatus" column="send_status" />
</resultMap>
<select id="selectSendMailRecord" parameterType="SendMailRecord" resultMap="SendMailRecordResult">
SELECT s.id ,s.mail_name ,s.mail_content ,s.mail_address ,s.send_time ,s.case_id ,s.create_time ,s.create_by ,
s.update_by ,s.update_time ,c.case_num
s.update_by ,s.update_time , s.send_status ,c.case_num
from send_mail_record s left join case_application c
on s.case_id = c.id
<where>
@@ -35,6 +36,7 @@
<if test="mailAddress != null and mailAddress != ''">mail_address,</if>
<if test="sendTime != null ">send_time,</if>
<if test="caseId != null ">case_id,</if>
<if test="sendStatus != null ">send_status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
@@ -43,6 +45,7 @@
<if test="mailAddress != null and mailAddress != ''">#{mailAddress},</if>
<if test="sendTime != null ">#{sendTime},</if>
<if test="caseId != null ">#{caseId},</if>
<if test="sendStatus != null ">#{sendStatus},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)