Commit 0e0acbd6 by 284718418@qq.com

招聘管理-发送Offer

parent a6d85baa
...@@ -21,20 +21,14 @@ import cn.timer.api.dao.kqmk.KqglAssoKqzdkfsMapper; ...@@ -21,20 +21,14 @@ import cn.timer.api.dao.kqmk.KqglAssoKqzdkfsMapper;
import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper; import cn.timer.api.dao.qyzx.QyzxEmpLoginMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper; import cn.timer.api.dao.yggl.YgglMainEmpMapper;
import cn.timer.api.dao.zpgl.ZpglRcxxMapper; import cn.timer.api.dao.zpgl.ZpglRcxxMapper;
import cn.timer.api.dto.baidu.BaiduTicResumeDto;
import cn.timer.api.dto.baidu.ProjectInfo;
import cn.timer.api.dto.baidu.ResumeExtract;
import cn.timer.api.dto.zpgl.ImportCandidateDto; import cn.timer.api.dto.zpgl.ImportCandidateDto;
import cn.timer.api.dto.zpgl.ZpglRcxxDto; import cn.timer.api.dto.zpgl.ZpglRcxxDto;
import cn.timer.api.dto.zpgl.ZpglRcxxEntryDto; import cn.timer.api.dto.zpgl.ZpglRcxxEntryDto;
import cn.timer.api.utils.Md5; import cn.timer.api.utils.Md5;
import cn.timer.api.utils.Result; import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil; import cn.timer.api.utils.ResultUtil;
import cn.timer.api.utils.baidu.BaiduTicUtil;
import cn.timer.api.utils.baidu.Base64;
import cn.timer.api.utils.query.BaseQuery; import cn.timer.api.utils.query.BaseQuery;
import cn.timer.api.config.enuminterface.YgEnumInterface.jobStatus; import cn.timer.api.config.enuminterface.YgEnumInterface.jobStatus;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
......
package cn.timer.api.controller.zpgl.sevice;
import cn.timer.api.bean.email.SendMessage;
import cn.timer.api.dto.email.SendMessageDto;
import cn.timer.api.utils.email.EmailUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.mail.javamail.JavaMailSender;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class ZpglSendMessageThread implements Runnable{
private JavaMailSender mailSender;
private SendMessageDto sendMessageDto;
public ZpglSendMessageThread(JavaMailSender mailSender, SendMessageDto sendMessageDto){
this.mailSender = mailSender;
this.sendMessageDto = sendMessageDto;
}
@Override
public void run() {
try {
Map<String, Object> map = new HashMap<>(8);
map.put("rcxxName","吴庆军");
map.put("bumen","部门");
map.put("gangwei","岗位");
map.put("rzTime","2022-04-13");
map.put("name","幽狼");
map.put("username",sendMessageDto.getSenderEmail());
map.put("phone","13560267595");
map.put("companyName","广东优领科技服务有限公司");
EmailUtils.sendThymeleafMail(mailSender, map, sendMessageDto.getSubject(), new String[]{sendMessageDto.getReceiverEmail()});
SendMessage sendMessage = SendMessage.builder().build();
BeanUtils.copyProperties(sendMessageDto, sendMessage);
sendMessage.setCreatedTime(new Date());
sendMessage.insert();
} catch (Exception e) {
e.printStackTrace();
}
}
}
...@@ -7,6 +7,7 @@ import cn.timer.api.dto.zpgl.ImportCandidateDto; ...@@ -7,6 +7,7 @@ import cn.timer.api.dto.zpgl.ImportCandidateDto;
import cn.timer.api.dto.zpgl.ZpglRcxxDto; import cn.timer.api.dto.zpgl.ZpglRcxxDto;
import cn.timer.api.utils.Result; import cn.timer.api.utils.Result;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.thymeleaf.TemplateEngine;
/** /**
* @author wuqingjun * @author wuqingjun
......
...@@ -5,10 +5,10 @@ import cn.timer.api.bean.yggl.YgglMainEmp; ...@@ -5,10 +5,10 @@ import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.bean.zpgl.*; import cn.timer.api.bean.zpgl.*;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enuminterface.JxglEnumInterface; import cn.timer.api.config.enuminterface.JxglEnumInterface;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.controller.kqgl.ClockInTool; import cn.timer.api.controller.kqgl.ClockInTool;
import cn.timer.api.dto.baidu.*; import cn.timer.api.dto.baidu.*;
import cn.timer.api.bean.clazz.NationClass; import cn.timer.api.bean.clazz.NationClass;
import cn.timer.api.dto.email.SendMessageDto;
import cn.timer.api.dto.zpgl.ImportCandidateDto; import cn.timer.api.dto.zpgl.ImportCandidateDto;
import cn.timer.api.dto.zpgl.ZpglRcxxDto; import cn.timer.api.dto.zpgl.ZpglRcxxDto;
import cn.timer.api.utils.Result; import cn.timer.api.utils.Result;
...@@ -21,10 +21,14 @@ import com.alibaba.fastjson.JSONObject; ...@@ -21,10 +21,14 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.thymeleaf.ITemplateEngine;
import org.thymeleaf.TemplateEngine;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -41,16 +45,23 @@ import java.util.List; ...@@ -41,16 +45,23 @@ import java.util.List;
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
public class ZpglServiceImpl implements ZpglService { public class ZpglServiceImpl implements ZpglService {
@Value("${spring.mail.username}")
private String username;
@Autowired @Autowired
private BaiduTicUtil baiduTicUtil; private BaiduTicUtil baiduTicUtil;
@Autowired @Autowired
private JavaMailSender mailSender;
@Autowired
private ZpglMslcLogService zpglMslcLogService; private ZpglMslcLogService zpglMslcLogService;
@Override @Override
public boolean updateZpglRcxx(UserBean userBean, ZpglRcxxDto zpglRcxxDto) { public boolean updateZpglRcxx(UserBean userBean, ZpglRcxxDto zpglRcxxDto) {
boolean count = false; boolean count = false;
ZpglRcxx zpglRcxxEntity = ZpglRcxx.builder().id(zpglRcxxDto.getId()).build().selectById();
ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).status(zpglRcxxDto.getStatus()).build(); ZpglRcxx zpglRcxx = ZpglRcxx.builder().id(zpglRcxxDto.getId()).status(zpglRcxxDto.getStatus()).build();
ZpglMslcLog zpglMslcLog = new ZpglMslcLog(); ZpglMslcLog zpglMslcLog = new ZpglMslcLog();
zpglMslcLog.setZpglRcxxId(zpglRcxxDto.getId()); zpglMslcLog.setZpglRcxxId(zpglRcxxDto.getId());
...@@ -115,6 +126,9 @@ public class ZpglServiceImpl implements ZpglService { ...@@ -115,6 +126,9 @@ public class ZpglServiceImpl implements ZpglService {
detail = ZpglMessageTemplate.print(ZpglMessageTemplate.OFFER, new String[]{ detail = ZpglMessageTemplate.print(ZpglMessageTemplate.OFFER, new String[]{
userBean.getQyzxEmpLogin().getUsername()}); userBean.getQyzxEmpLogin().getUsername()});
//发送offer //发送offer
SendMessageDto sendMessage = SendMessageDto.builder().senderEmail(username).subject("广东优领科技服务有限公司录用函").createdUser(userBean.getEmpNum()).content("邮件内容").receiverEmail(zpglRcxxEntity.getMail()).build();
Thread pthread=new Thread(new ZpglSendMessageThread(mailSender, sendMessage));
pthread.start();
break; break;
case 8: case 8:
zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType(); zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.OTHER.getType();
......
package cn.timer.api.dto.email;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-4-13 10:05:49
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SendMessageDto implements Serializable {
private static final long serialVersionUID = -1599962875587367209L;
@ApiModelProperty(value = "创建id")
private Integer createdUser;
@ApiModelProperty(value = "创建时间")
private Date createdTime;
@ApiModelProperty(value = "邮件主题")
private String subject;
@ApiModelProperty(value = "邮件内容")
private String content;
@ApiModelProperty(value = "收件人邮箱")
private String receiverEmail;
@ApiModelProperty(value = "发件人邮箱")
private String senderEmail;
}
...@@ -22,6 +22,29 @@ public class ZpglMessageTemplate { ...@@ -22,6 +22,29 @@ public class ZpglMessageTemplate {
public static final String INTERVIEWED_ENTRYING ="{0} 将候选人状态从[{3}]更改为[面试淘汰], 淘汰原因:{1},备注:{2}"; public static final String INTERVIEWED_ENTRYING ="{0} 将候选人状态从[{3}]更改为[面试淘汰], 淘汰原因:{1},备注:{2}";
public static final String OFFER_ENTRYING ="{0} 将候选人状态从[{3}}]更改为[录用淘汰], 淘汰原因:{1},备注:{2}"; public static final String OFFER_ENTRYING ="{0} 将候选人状态从[{3}}]更改为[录用淘汰], 淘汰原因:{1},备注:{2}";
public static final String OFFER_TEMPLATE = "<!DOCTYPE html><html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:th=\"http://www.thymeleaf.org\"><body><div><p style=\" line-height: 1.5;\">尊敬的<span>曾业龙</span></p>"+
"<p style=\" line-height: 1.5;\"><br></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">感谢您对公司的认可,非常荣幸地通知您,您已被我司正式录用,欢迎您加入<span>广东黑猫信息科技有限公司</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的部门:<span>人事部</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的岗位:<span>结算岗</span></p>"+
"<p style=\" line-height: 1.5;\"><br></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">入职所需的材料和证件</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">1. 原单位离职证明(加盖原单位公章)1份</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">2. 身份证原件</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">3. 学位证、毕业证原件</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">4. 相关资格证书原件</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">5. 入职体检证明</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">请您于<span>2018-08-06</span>带以上材料,进行报到</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">联系人:<span>陶湘宇</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">联系电话:<span>18665645253</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">联系人邮箱:<span></span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">收到此通知后,请您点击底部按钮进行回复确认,再次欢迎您加入!<span>广东黑猫信息科技有限公司</span>!</p>"+
"<p style=\" line-height: 1.5;\"><br></p></div>"+
"</body></html>";
public static String print(String template, String[] values) { public static String print(String template, String[] values) {
if (null == values || values.length == 0) { if (null == values || values.length == 0) {
return template; return template;
......
package cn.timer.api.utils.email;
import cn.timer.api.utils.ZpglMessageTemplate;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import org.thymeleaf.context.Context;
import org.thymeleaf.util.MapUtils;
import org.thymeleaf.util.StringUtils;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.Map;
/**
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022/4/13
*/
@Component
public class EmailUtils {
/**
* 发送人邮箱
*/
private static String from;
@Value("${spring.mail.username}")
private void setFrom(String from) {
EmailUtils.from = from;
}
/**
* 解析页
*/
private static String html;
@Value("${spring.mail.thymeleaf-html}")
private void setHtml(String html) {
EmailUtils.html = html;
}
/**
* 普通发送邮件
*
* @param text
* @param toMails
* @throws MessagingException
*/
public static int sendSimpleMail(JavaMailSender javaMailSender,String text,String subject, String... toMails) {
// text or toMails is null
if (StringUtils.isEmpty(text) || ArrayUtils.isEmpty(toMails)) {
return 0;
}
try {
SimpleMailMessage message = new SimpleMailMessage();
message.setSubject(subject);
message.setFrom(from);
message.setBcc(from);
message.setTo(toMails);
message.setText(text);
javaMailSender.send(message);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
return 1;
}
/**
* 发送 thymeleaf 页面邮件 - 单参数
*
* @param goldCoinCode
* @param toMails
* @param subject
* @throws MessagingException
*/
public static int sendThymeleafMail(JavaMailSender javaMailSender,String goldCoinCode, String subject, String... toMails) {
// goldCoinCode is null
if (StringUtils.isEmpty(goldCoinCode)) {
return 0;
}
// 发送邮件
return sendThymeleafMail(javaMailSender,null, goldCoinCode, subject, toMails);
}
/**
* 发送 thymeleaf 页面邮件 - 多参数
*
* @param map
* @param toMails
* @param subject
* @throws MessagingException
*/
public static int sendThymeleafMail(JavaMailSender javaMailSender,Map<String, Object> map,String subject, String... toMails) {
// map is null
if (MapUtils.isEmpty(map)) {
return 0;
}
// 发送邮件
return sendThymeleafMail(javaMailSender,map, null, subject, toMails);
}
/**
* 发送 thymeleaf 页面邮件 - 最终执行
*
* @param map
* @param toMails
* @param subject
* @throws MessagingException
*/
private static int sendThymeleafMail(JavaMailSender javaMailSender, Map<String, Object> map, String goldCoinCode,String subject, String... toMails) {
// toMails is null
if (ArrayUtils.isEmpty(toMails)) {
return 0;
}
try {
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setSubject(subject);
helper.setFrom(from);
helper.setBcc(from);
helper.setTo(toMails);
Context context = new Context();
if (!MapUtils.isEmpty(map)) {
context.setVariables(map);
} else {
context.setVariable("GoldCoinCode", goldCoinCode);
}
//String process = templateEngine.process(html, context);
helper.setText(ZpglMessageTemplate.OFFER_TEMPLATE,true);
javaMailSender.send(mimeMessage);
} catch (MessagingException e) {
e.printStackTrace();
return 0;
}
return 1;
}
}
...@@ -97,10 +97,13 @@ spring: ...@@ -97,10 +97,13 @@ spring:
invert: false # Whether images should be inverted for dark terminal themes. invert: false # Whether images should be inverted for dark terminal themes.
mail: mail:
port: 465 port: 465
host: smtp.youlingrc.com protocol: smtp
username: postmaster@youlingrc.com #host: smtp.163.com
password: YoulingRC2020 host: 220.181.15.161
username: youlingrc123@163.com
password: RIMBNJJQNKYNVUWL
default-encoding: utf-8 default-encoding: utf-8
thymeleaf-html: /static/8timer/offer.html
properties: properties:
mail: mail:
smtp: smtp:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment