Commit d8b9cf7c by 284718418@qq.com

招聘管理-发送Offer

parent 0e0acbd6
package cn.timer.api.bean.zpgl;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.util.Date;
/**
* Offer发送记录表
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-04-14 10:14:40
*/
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "zpgl_rcxx_offer")
@Data
public class ZpglRcxxOffer extends Model<ZpglRcxxOffer> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
/**
* 人才信息ID
*/
@ApiModelProperty(value = "人才信息ID")
private Integer zpglRcxxId;
/**
* 邮件标题
*/
@ApiModelProperty(value = "邮件标题")
private String title;
/**
* 部门
*/
@ApiModelProperty(value = "部门")
private String bumen;
/**
* 岗位
*/
@ApiModelProperty(value = "岗位")
private String gangwei;
/**
* 姓名
*/
@ApiModelProperty(value = "姓名")
private String rcxxName;
/**
* 企业名称
*/
@ApiModelProperty(value = "企业名称")
private String companyName;
/**
* 联系人
*/
@ApiModelProperty(value = "联系人")
private String linkName;
/**
* 联系人电话
*/
@ApiModelProperty(value = "联系人电话")
private String linkPhone;
/**
* 联系人邮箱
*/
@ApiModelProperty(value = "联系人邮箱")
private String linkEmail;
/**
* 入职日期
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JSONField(format = "yyyy-MM-dd")
@ApiModelProperty(value = "入职日期")
private Date rzTime;
/**
* 组织机构代码
*/
@ApiModelProperty(value = "组织机构代码")
private Integer orgCode;
/**
* 逻辑删除标记0.未删除 1.删除
*/
@ApiModelProperty(value = "逻辑删除标记0.未删除 1.删除")
private String deleteFlag;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 收件人邮箱
*/
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "收件人邮箱")
private String receiverEmail;
/**
* 发件人邮箱
*/
@Transient
@TableField(exist = false)
@ApiModelProperty(value = "发件人邮箱")
private String senderEmail;
}
...@@ -512,13 +512,17 @@ public class ZpglController { ...@@ -512,13 +512,17 @@ public class ZpglController {
// FPA性格测评数据 // FPA性格测评数据
ZpglDtk zpglDtk = ZpglDtk.builder().build().selectOne(new QueryWrapper<ZpglDtk>().lambda().eq(ZpglDtk::getZpglRcxxId, zpglRcxxId)); ZpglDtk zpglDtk = ZpglDtk.builder().build().selectOne(new QueryWrapper<ZpglDtk>().lambda().eq(ZpglDtk::getZpglRcxxId, zpglRcxxId));
Map<String, Object> map = new HashMap<>(4); // offer
ZpglRcxxOffer zpglRcxxOffer = ZpglRcxxOffer.builder().build().selectOne(new QueryWrapper<ZpglRcxxOffer>().lambda().eq(ZpglRcxxOffer::getZpglRcxxId, zpglRcxxId).eq(ZpglRcxxOffer::getDeleteFlag, 0));
Map<String, Object> map = new HashMap<>(7);
map.put("zpglRcxx", zpglRcxx); map.put("zpglRcxx", zpglRcxx);
map.put("zpglRcxxExperiences", zpglRcxxExperiences); map.put("zpglRcxxExperiences", zpglRcxxExperiences);
map.put("zpglRcxxStudys", zpglRcxxStudys); map.put("zpglRcxxStudys", zpglRcxxStudys);
map.put("zpglRcxxProjects", zpglRcxxProjects); map.put("zpglRcxxProjects", zpglRcxxProjects);
map.put("zpglRcxxTrains", zpglRcxxTrains); map.put("zpglRcxxTrains", zpglRcxxTrains);
map.put("zpglDtk", zpglDtk); map.put("zpglDtk", zpglDtk);
map.put("zpglRcxxOffer", zpglRcxxOffer);
return ResultUtil.data(map,"搜索成功"); return ResultUtil.data(map,"搜索成功");
} catch (Exception e) { } catch (Exception e) {
......
package cn.timer.api.controller.zpgl.sevice; package cn.timer.api.controller.zpgl.sevice;
import cn.timer.api.bean.email.SendMessage; import cn.timer.api.bean.email.SendMessage;
import cn.timer.api.dto.email.SendMessageDto; import cn.timer.api.bean.zpgl.ZpglRcxxOffer;
import cn.timer.api.utils.DateFormatUtils;
import cn.timer.api.utils.ZpglMessageTemplate;
import cn.timer.api.utils.email.EmailUtils; import cn.timer.api.utils.email.EmailUtils;
import com.aliyun.tea.utils.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class ZpglSendMessageThread implements Runnable{
public class ZpglSendMessageThread implements Runnable {
private JavaMailSender mailSender;
private SendMessageDto sendMessageDto; public JavaMailSender mailSender;
public ZpglSendMessageThread(JavaMailSender mailSender, SendMessageDto sendMessageDto){ private ZpglRcxxOffer zpglRcxxOffer;
this.mailSender = mailSender;
this.sendMessageDto = sendMessageDto; public ZpglSendMessageThread(JavaMailSender mailSender, ZpglRcxxOffer zpglRcxxOffer) {
this.mailSender = mailSender;
this.zpglRcxxOffer = zpglRcxxOffer;
} }
@Override @Override
public void run() { public void run() {
try { try {
Map<String, Object> map = new HashMap<>(8); EmailUtils.sendThymeleafMail(
map.put("rcxxName","吴庆军"); mailSender,
map.put("bumen","部门"); ZpglMessageTemplate.print(ZpglMessageTemplate.OFFER_TEMPLATE, new String[]{
map.put("gangwei","岗位"); zpglRcxxOffer.getRcxxName(),
map.put("rzTime","2022-04-13"); zpglRcxxOffer.getCompanyName(),
map.put("name","幽狼"); zpglRcxxOffer.getBumen(),
map.put("username",sendMessageDto.getSenderEmail()); zpglRcxxOffer.getGangwei(),
map.put("phone","13560267595"); DateFormatUtils.tranDate(zpglRcxxOffer.getRzTime(), DateFormatUtils.YYYYMMDD),
map.put("companyName","广东优领科技服务有限公司"); zpglRcxxOffer.getLinkName(),
EmailUtils.sendThymeleafMail(mailSender, map, sendMessageDto.getSubject(), new String[]{sendMessageDto.getReceiverEmail()}); StringUtils.isEmpty(zpglRcxxOffer.getLinkEmail()) ? "" : zpglRcxxOffer.getLinkEmail(),
StringUtils.isEmpty(zpglRcxxOffer.getLinkPhone()) ? "" : zpglRcxxOffer.getLinkPhone()}),
zpglRcxxOffer.getTitle(),
new String[]{zpglRcxxOffer.getReceiverEmail()});
SendMessage sendMessage = SendMessage.builder().build(); SendMessage sendMessage = SendMessage.builder().build();
BeanUtils.copyProperties(sendMessageDto, sendMessage); BeanUtils.copyProperties(zpglRcxxOffer, sendMessage);
sendMessage.setCreatedTime(new Date()); sendMessage.setCreatedTime(new Date());
sendMessage.insert(); sendMessage.insert();
......
...@@ -7,7 +7,6 @@ import cn.timer.api.dto.zpgl.ImportCandidateDto; ...@@ -7,7 +7,6 @@ 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
......
package cn.timer.api.controller.zpgl.sevice; package cn.timer.api.controller.zpgl.sevice;
import cn.timer.api.bean.clazz.SysRegion; import cn.timer.api.bean.clazz.SysRegion;
import cn.timer.api.bean.qyzx.QyzxEmpLogin;
import cn.timer.api.bean.yggl.YgglMainEmp; import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.bean.zpgl.*; import cn.timer.api.bean.zpgl.*;
import cn.timer.api.bean.zzgl.ZzglBmgwM;
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.controller.kqgl.ClockInTool; import cn.timer.api.controller.kqgl.ClockInTool;
...@@ -27,8 +29,6 @@ import org.springframework.mail.javamail.JavaMailSender; ...@@ -27,8 +29,6 @@ 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;
...@@ -62,6 +62,10 @@ public class ZpglServiceImpl implements ZpglService { ...@@ -62,6 +62,10 @@ public class ZpglServiceImpl implements ZpglService {
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 zpglRcxxEntity = ZpglRcxx.builder().id(zpglRcxxDto.getId()).build().selectById();
if(StringUtils.isEmpty(zpglRcxxEntity)){
return count;
}
zpglRcxxDto.setName(zpglRcxxEntity.getName());
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());
...@@ -105,7 +109,7 @@ public class ZpglServiceImpl implements ZpglService { ...@@ -105,7 +109,7 @@ public class ZpglServiceImpl implements ZpglService {
case 4: case 4:
zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType(); zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
detail = ZpglMessageTemplate.print(ZpglMessageTemplate.INTERVIEWED, new String[]{ detail = ZpglMessageTemplate.print(ZpglMessageTemplate.INTERVIEWED, new String[]{
userBean.getQyzxEmpLogin().getUsername(), zpglRcxxDto.getInterviewNum().toString()}); userBean.getQyzxEmpLogin().getUsername(), zpglRcxxEntity.getInterviewNum().toString()});
break; break;
case 5: case 5:
zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType(); zpglRcxxStatus = JxglEnumInterface.MslcLogStatus.INTERVIEW.getType();
...@@ -126,8 +130,8 @@ public class ZpglServiceImpl implements ZpglService { ...@@ -126,8 +130,8 @@ 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(); ZpglRcxxOffer zpglRcxxOffer = this.insertZpglRcxxOffer(userBean,zpglRcxxDto);
Thread pthread=new Thread(new ZpglSendMessageThread(mailSender, sendMessage)); Thread pthread=new Thread(new ZpglSendMessageThread(mailSender, zpglRcxxOffer));
pthread.start(); pthread.start();
break; break;
case 8: case 8:
...@@ -410,4 +414,49 @@ public class ZpglServiceImpl implements ZpglService { ...@@ -410,4 +414,49 @@ public class ZpglServiceImpl implements ZpglService {
} }
return education; return education;
} }
/**
* 添加offer记录
* @param userBean
* @param zpglRcxxDto
* @return
*/
private ZpglRcxxOffer insertZpglRcxxOffer(UserBean userBean,ZpglRcxxDto zpglRcxxDto){
Integer orgCode = userBean.getOrgCode();
ZpglRcxxOffer zpglRcxxOffer = ZpglRcxxOffer.builder().build();
zpglRcxxOffer.setOrgCode(orgCode);
zpglRcxxOffer.setRcxxName(zpglRcxxDto.getName());
zpglRcxxOffer.setZpglRcxxId(zpglRcxxDto.getId());
zpglRcxxOffer.setRzTime(zpglRcxxDto.getYjrzTime());
// 所在部门
ZzglBmgwM zzglBmgwM = ZzglBmgwM.builder().build().selectOne(
new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getId, zpglRcxxDto.getBmgwId()));
Integer bmid = null;
if (!StringUtils.isEmpty(zzglBmgwM)) {
zpglRcxxOffer.setGangwei(zzglBmgwM.getName());
bmid = zzglBmgwM.getUpId();
}
// 所在职位
ZzglBmgwM z = ZzglBmgwM.builder().build().selectOne(
new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getId, bmid));
if (!StringUtils.isEmpty(z)) {
zpglRcxxOffer.setBumen( z.getName());
}
// 所在公司
ZzglBmgwM company = ZzglBmgwM.builder().build().selectOne(
new QueryWrapper<ZzglBmgwM>().select("name").lambda().eq(ZzglBmgwM::getOrgCode, orgCode).eq(ZzglBmgwM::getUpId, 0));
if(!StringUtils.isEmpty(company)){
zpglRcxxOffer.setTitle(company.getName()+"录用函");
zpglRcxxOffer.setCompanyName(company.getName());
}
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().select("phone","name","work_email").lambda()
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, zpglRcxxDto.getLinkId()));
if(!StringUtils.isEmpty(ygglMainEmp)){
zpglRcxxOffer.setLinkName(ygglMainEmp.getName());
zpglRcxxOffer.setLinkPhone(ygglMainEmp.getPhone());
zpglRcxxOffer.setLinkEmail(ygglMainEmp.getWorkEmail());
}
zpglRcxxOffer.insert();
return zpglRcxxOffer;
}
} }
package cn.timer.api.dao.zpgl;
import cn.timer.api.bean.zpgl.ZpglRcxxOffer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* Offer发送记录
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-04-14 15:14:40
*/
@Repository
public interface ZpglRcxxOfferMapper extends BaseMapper<ZpglRcxxOffer> {
}
...@@ -55,6 +55,11 @@ public class ZpglRcxxDto implements Serializable{ ...@@ -55,6 +55,11 @@ public class ZpglRcxxDto implements Serializable{
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remarks; private String remarks;
/** /**
* 姓名
*/
@ApiModelProperty(value = "姓名")
private String name;
/**
* 附加操作:0无,1加入人才库 * 附加操作:0无,1加入人才库
*/ */
@ApiModelProperty(value = "附加操作:0无,1加入人才库") @ApiModelProperty(value = "附加操作:0无,1加入人才库")
...@@ -103,5 +108,10 @@ public class ZpglRcxxDto implements Serializable{ ...@@ -103,5 +108,10 @@ public class ZpglRcxxDto implements Serializable{
@ApiModelProperty(value = "预计入职日期") @ApiModelProperty(value = "预计入职日期")
private Date yjrzTime; private Date yjrzTime;
/**
* 联系人id
*/
@ApiModelProperty(value = "联系人id")
private Integer linkId;
} }
...@@ -16,6 +16,8 @@ import java.util.GregorianCalendar; ...@@ -16,6 +16,8 @@ import java.util.GregorianCalendar;
* *
*/ */
public class DateFormatUtils { public class DateFormatUtils {
public static final String YYYYMMDD = "yyyy-MM-dd";
/** /**
...@@ -511,7 +513,7 @@ public class DateFormatUtils { ...@@ -511,7 +513,7 @@ public class DateFormatUtils {
} }
public static void main(String[] args) throws ParseException { public static void main(String[] args) throws ParseException {
System.out.println(tranDate(new Date(),YYYYMMDD));
} }
} }
\ No newline at end of file
...@@ -22,11 +22,11 @@ public class ZpglMessageTemplate { ...@@ -22,11 +22,11 @@ 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>"+ 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>{0}</span></p>"+
"<p style=\" line-height: 1.5;\"><br></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>{1}</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的部门:<span>人事部</span></p>"+ "<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的部门:<span>{2}</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的岗位:<span>结算岗</span></p>"+ "<p style=\"text-indent: 2em; line-height: 1.5;\">您所入职的岗位:<span>{3}</span></p>"+
"<p style=\" line-height: 1.5;\"><br></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;\">入职所需的材料和证件</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">1. 原单位离职证明(加盖原单位公章)1份</p>"+ "<p style=\"text-indent: 2em; line-height: 1.5;\">1. 原单位离职证明(加盖原单位公章)1份</p>"+
...@@ -35,13 +35,13 @@ public class ZpglMessageTemplate { ...@@ -35,13 +35,13 @@ public class ZpglMessageTemplate {
"<p style=\"text-indent: 2em; line-height: 1.5;\">4. 相关资格证书原件</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;\">5. 入职体检证明</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></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;\">请您于<span>{4}</span>带以上材料,进行报到</p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></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>{5}</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>{6}</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\">联系人邮箱:<span></span></p>"+ "<p style=\"text-indent: 2em; line-height: 1.5;\">联系人邮箱:<span>{7}</span></p>"+
"<p style=\"text-indent: 2em; line-height: 1.5;\"><br></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>{1}</span>!</p>"+
"<p style=\" line-height: 1.5;\"><br></p></div>"+ "<p style=\" line-height: 1.5;\"><br></p></div>"+
"</body></html>"; "</body></html>";
......
package cn.timer.api.utils.email; package cn.timer.api.utils.email;
import cn.timer.api.utils.ZpglMessageTemplate;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.thymeleaf.context.Context; import org.springframework.util.StringUtils;
import org.thymeleaf.util.MapUtils;
import org.thymeleaf.util.StringUtils;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import java.util.Map;
/** /**
* @author wuqingjun * @author wuqingjun
...@@ -34,17 +30,6 @@ public class EmailUtils { ...@@ -34,17 +30,6 @@ public class EmailUtils {
} }
/** /**
* 解析页
*/
private static String html;
@Value("${spring.mail.thymeleaf-html}")
private void setHtml(String html) {
EmailUtils.html = html;
}
/**
* 普通发送邮件 * 普通发送邮件
* *
* @param text * @param text
...@@ -52,7 +37,6 @@ public class EmailUtils { ...@@ -52,7 +37,6 @@ public class EmailUtils {
* @throws MessagingException * @throws MessagingException
*/ */
public static int sendSimpleMail(JavaMailSender javaMailSender,String text,String subject, String... toMails) { public static int sendSimpleMail(JavaMailSender javaMailSender,String text,String subject, String... toMails) {
// text or toMails is null
if (StringUtils.isEmpty(text) || ArrayUtils.isEmpty(toMails)) { if (StringUtils.isEmpty(text) || ArrayUtils.isEmpty(toMails)) {
return 0; return 0;
} }
...@@ -71,51 +55,18 @@ public class EmailUtils { ...@@ -71,51 +55,18 @@ public class EmailUtils {
return 1; 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 页面邮件 - 最终执行 * 发送 thymeleaf 页面邮件
* *
* @param map * @param javaMailSender
* @param text
* @param toMails * @param toMails
* @param subject * @param subject
* @throws MessagingException * @throws MessagingException
*/ */
private static int sendThymeleafMail(JavaMailSender javaMailSender, Map<String, Object> map, String goldCoinCode,String subject, String... toMails) { public static int sendThymeleafMail(JavaMailSender javaMailSender, String text,String subject, String... toMails) {
// toMails is null if (StringUtils.isEmpty(text) || ArrayUtils.isEmpty(toMails)) {
if (ArrayUtils.isEmpty(toMails)) {
return 0; return 0;
} }
try { try {
...@@ -125,15 +76,7 @@ public class EmailUtils { ...@@ -125,15 +76,7 @@ public class EmailUtils {
helper.setFrom(from); helper.setFrom(from);
helper.setBcc(from); helper.setBcc(from);
helper.setTo(toMails); helper.setTo(toMails);
Context context = new Context(); helper.setText(text,true);
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); javaMailSender.send(mimeMessage);
} catch (MessagingException e) { } catch (MessagingException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -103,7 +103,6 @@ spring: ...@@ -103,7 +103,6 @@ spring:
username: youlingrc123@163.com username: youlingrc123@163.com
password: RIMBNJJQNKYNVUWL password: RIMBNJJQNKYNVUWL
default-encoding: utf-8 default-encoding: utf-8
thymeleaf-html: /static/8timer/offer.html
properties: properties:
mail: mail:
smtp: smtp:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.timer.api.dao.zpgl.ZpglRcxxOfferMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.zpgl.ZpglRcxxOffer" id="zpglRcxxOfferMap">
<result property="id" column="id"/>
<result property="zpglRcxxId" column="zpgl_rcxx_id"/>
<result property="title" column="title"/>
<result property="bumen" column="bumen"/>
<result property="gangwei" column="gangwei"/>
<result property="rcxxName" column="rcxx_name"/>
<result property="companyName" column="company_name"/>
<result property="linkName" column="link_name"/>
<result property="linkPhone" column="link_phone"/>
<result property="linkEmail" column="link_email"/>
<result property="rzTime" column="rz_time"/>
<result property="orgCode" column="org_code"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
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