|
|
|
@ -2070,12 +2070,71 @@ public class QcServiceImpl implements QcService { |
|
|
|
for (int i = 0; i < data.getItemList().size(); i++) { |
|
|
|
qcMapper.updateFAIDetailedRecord(data.getItemList().get(i)); |
|
|
|
} |
|
|
|
|
|
|
|
// 判断检验结论,不合格则发送邮件 |
|
|
|
if ("不合格".equals(data.getInspectionResult())) { |
|
|
|
try { // 发送邮件 |
|
|
|
sendMail(data, "FAI"); |
|
|
|
} catch (Exception e) { |
|
|
|
//logger.info(e.getMessage()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
// 修改子明细提交标识 |
|
|
|
//qcMapper.updateSubDetailedRecord(data); |
|
|
|
// 修改明细信息 |
|
|
|
//qcMapper.saveDetailInformation(data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发送邮件 |
|
|
|
* @param data |
|
|
|
* @param type |
|
|
|
*/ |
|
|
|
public void sendMail(QcFAIRecordData data, String type) throws Exception { |
|
|
|
// 获取数据库设置的邮件接收地址 |
|
|
|
MailAddressData qc = qcMapper.getSendMailAddress(data.getSite(), "qc"); |
|
|
|
List<String> collect = data.getItemList().stream().filter(a -> "N".equals(a.getItemResult())).map(QcFAIRecordData::getItemDesc).collect(Collectors.toList()); |
|
|
|
if (qc != null) { |
|
|
|
//设置邮件内容 |
|
|
|
String text = "<!DOCTYPE>" + |
|
|
|
"<div>" + |
|
|
|
"检验单号:"+ data.getInspectionNo() + ",物料编码:" + data.getPartNo() + ",物料名称:" + data.getPartDesc() + ",发生不合格,不合格项:" + collect + " (此邮件为自动提示发送,无需回复!)<br/><br/>" + |
|
|
|
"</div>"; |
|
|
|
//发送邮件 |
|
|
|
JavaMailSenderImpl sender = new JavaMailSenderImpl(); |
|
|
|
MailSendAddressData mailSendData = qcMapper.getSendMailFromAddress(); |
|
|
|
sender.setHost(mailSendData.getHost()); |
|
|
|
sender.setPort(mailSendData.getPort()); |
|
|
|
sender.setUsername(mailSendData.getUsername()); |
|
|
|
sender.setPassword(mailSendData.getPassword()); |
|
|
|
sender.setDefaultEncoding("Utf-8"); |
|
|
|
Properties p = new Properties(); |
|
|
|
p.setProperty("mail.smtp.timeout", mailSendData.getTimeout()); |
|
|
|
p.setProperty("mail.smtp.auth", "false"); |
|
|
|
p.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); |
|
|
|
sender.setJavaMailProperties(p); |
|
|
|
MimeMessage mimeMessage = sender.createMimeMessage(); |
|
|
|
// 设置utf-8或GBK编码,否则邮件会有乱码 |
|
|
|
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); |
|
|
|
messageHelper.setFrom(mailSendData.getEmailForm(), mailSendData.getPersonal()); |
|
|
|
//判断是否存在分号 |
|
|
|
if (qc.getMailAddress().contains(";")) { |
|
|
|
String[] toAddress = qc.getMailAddress().split(";"); |
|
|
|
messageHelper.setTo(toAddress[0]); |
|
|
|
String[] arr2 = new String[toAddress.length-1]; |
|
|
|
System.arraycopy(toAddress, 1, arr2, 0, toAddress.length-1); |
|
|
|
messageHelper.setCc(arr2); |
|
|
|
} else { |
|
|
|
messageHelper.setTo(qc.getMailAddress()); |
|
|
|
} |
|
|
|
messageHelper.setSubject(type + "质量检验结果"); //标题 |
|
|
|
messageHelper.setText(text, true); |
|
|
|
sender.send(mimeMessage); |
|
|
|
logger.info(type + "检验不合格通知邮件已发送!收件箱地址:"+qc.getMailAddress()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 删除检验记录 |
|
|
|
* @author: fengyuan_yang |
|
|
|
@ -2636,6 +2695,16 @@ public class QcServiceImpl implements QcService { |
|
|
|
for (int i = 0; i < data.getItemList().size(); i++) { |
|
|
|
qcMapper.updateFQCDetailedRecord(data.getItemList().get(i)); |
|
|
|
} |
|
|
|
|
|
|
|
// 判断检验结论,不合格则发送邮件 |
|
|
|
if ("不合格".equals(data.getInspectionResult())) { |
|
|
|
try { // 发送邮件 |
|
|
|
sendMail(data, "FQC"); |
|
|
|
} catch (Exception e) { |
|
|
|
//logger.info(e.getMessage()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -3194,6 +3263,15 @@ public class QcServiceImpl implements QcService { |
|
|
|
for (int i = 0; i < data.getItemList().size(); i++) { |
|
|
|
qcMapper.updateIPQCDetailedRecord(data.getItemList().get(i)); |
|
|
|
} |
|
|
|
// 判断检验结论,不合格则发送邮件 |
|
|
|
if ("不合格".equals(data.getInspectionResult())) { |
|
|
|
try { // 发送邮件 |
|
|
|
sendMail(data, "IPQC"); |
|
|
|
} catch (Exception e) { |
|
|
|
//logger.info(e.getMessage()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -3697,7 +3775,7 @@ public class QcServiceImpl implements QcService { |
|
|
|
//设置邮件内容 |
|
|
|
String text = "<!DOCTYPE>" + |
|
|
|
"<div>" + |
|
|
|
"单据号:"+ data.getPoOrderNo() + ",行号:" + data.getPoItemNo() + ",物料编码:" + data.getPartNo() + ",SKU:" + data.getSku() + "发生不合格,不合格项:" + collect + " (此邮件为自动提示发送,无需回复!)<br/><br/>" + |
|
|
|
"单据号:"+ data.getPoOrderNo() + ",行号:" + data.getPoItemNo() + ",物料编码:" + data.getPartNo() + ",物料名称:" + data.getPartDesc() + ",SKU:" + data.getSku() + ",发生不合格,不合格项:" + collect + " (此邮件为自动提示发送,无需回复!)<br/><br/>" + |
|
|
|
"</div>"; |
|
|
|
//发送邮件 |
|
|
|
JavaMailSenderImpl sender = new JavaMailSenderImpl(); |
|
|
|
@ -3717,13 +3795,13 @@ public class QcServiceImpl implements QcService { |
|
|
|
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); |
|
|
|
messageHelper.setFrom(mailSendData.getEmailForm(), mailSendData.getPersonal()); |
|
|
|
//判断是否存在分号 |
|
|
|
if(qc.getMailAddress().contains(";")){ |
|
|
|
if (qc.getMailAddress().contains(";")) { |
|
|
|
String[] toAddress = qc.getMailAddress().split(";"); |
|
|
|
messageHelper.setTo(toAddress[0]); |
|
|
|
String[] arr2 = new String[toAddress.length-1]; |
|
|
|
System.arraycopy(toAddress, 1, arr2, 0, toAddress.length-1); |
|
|
|
messageHelper.setCc(arr2); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
messageHelper.setTo(qc.getMailAddress()); |
|
|
|
} |
|
|
|
messageHelper.setSubject("IQC"+"质量检验结果"); //标题 |
|
|
|
|