|
|
@@ -1,5 +1,6 @@
|
|
|
package com.goafanti.admin.service.impl;
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
@@ -7,9 +8,12 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
+import javax.mail.MessagingException;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.goafanti.admin.bo.AdminListBo;
|
|
|
import com.goafanti.admin.bo.InputPublicDtails;
|
|
|
import com.goafanti.admin.bo.InputPublicRelease;
|
|
|
import com.goafanti.admin.bo.InputPublicReleaseList;
|
|
|
@@ -20,6 +24,7 @@ import com.goafanti.admin.bo.OutPublicReleaseList;
|
|
|
import com.goafanti.admin.bo.OutPublicStatistics;
|
|
|
import com.goafanti.admin.bo.outPublicReleaseLog;
|
|
|
import com.goafanti.admin.service.PublicReleaseService;
|
|
|
+import com.goafanti.common.bo.EmailBo;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.PublicReleaseLogMapper;
|
|
|
@@ -28,7 +33,9 @@ import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.PublicRelease;
|
|
|
import com.goafanti.common.model.PublicReleaseLog;
|
|
|
+import com.goafanti.common.utils.AsyncUtils;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
+import com.goafanti.common.utils.SendEmailUtil;
|
|
|
import com.goafanti.common.utils.WeChatUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
@@ -50,6 +57,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
private WeChatUtils weChatUtils;
|
|
|
@Autowired
|
|
|
private AdminMapper adminMapper;
|
|
|
+ @Autowired
|
|
|
+ private AsyncUtils asyncUtils;
|
|
|
|
|
|
@Override
|
|
|
public int addPublicRelease(InputPublicRelease in) {
|
|
|
@@ -65,18 +74,43 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
throw new BusinessException("转换异常");
|
|
|
}
|
|
|
publicReleaseMapper.insertSelectiveGetId(in);
|
|
|
- Admin my=adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
|
|
|
+ AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
Admin a=adminMapper.selectByPrimaryKey(my.getSuperiorId());
|
|
|
PublicReleaseLog log=new PublicReleaseLog(in.getId(),TokenManager.getAdminId(),1,"发起外出申请",new Date());
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
String openid=a.getOpenId();
|
|
|
if (openid!=null) {
|
|
|
- return weChatUtils.addNotice(openid, in.getStatus(),date,my.getName(),"["+my.getName()+"]发起外出审核");
|
|
|
+ Integer res= weChatUtils.addNotice(openid, in.getStatus(),date,my.getName(),"["+my.getName()+"]发起外出审核");
|
|
|
+ if (res!=0) {
|
|
|
+ senEmail(my, a,1);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
}else {
|
|
|
//成功但是对方收不到消息
|
|
|
return 2;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void senEmail(AdminListBo my, Admin a,Integer type) {
|
|
|
+ String title="外出申请提醒";
|
|
|
+ if (type==0) title="外出申请驳回提醒";
|
|
|
+ else if (type==2) title="外出申请同意提醒";
|
|
|
+ if (SendEmailUtil.isEmail(a.getEmail())) {
|
|
|
+ EmailBo email=new EmailBo(title,a.getEmail() , my.getDepartmentName(), my.getName(),"详情请登录微信打卡小程序查看,谢谢!") ;
|
|
|
+ try {
|
|
|
+ asyncUtils.send(email);
|
|
|
+ } catch (UnsupportedEncodingException | MessagingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -124,11 +158,14 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
|
|
|
publicReleaseMapper.updateByPrimaryKeySelective(p);
|
|
|
PublicReleaseLog log=new PublicReleaseLog(id,TokenManager.getAdminId(),status,remarks,new Date());
|
|
|
publicReleaseLogMapper.insertSelective(log);
|
|
|
- Admin my=adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
|
|
|
- Admin s=adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
+ AdminListBo my = adminMapper.getDeptNameByAid(TokenManager.getAdminId());
|
|
|
+ Admin a=adminMapper.selectByPrimaryKey(use.getAid());
|
|
|
if (my.getOpenId()!=null) {
|
|
|
- return weChatUtils.addNotice(s.getOpenId(),p.getStatus(),date,my.getName(),
|
|
|
- remarks);
|
|
|
+ Integer res=weChatUtils.addNotice(a.getOpenId(),p.getStatus(),date,my.getName(),remarks);
|
|
|
+ if (res!=0) {
|
|
|
+ senEmail( my, a, status);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
}
|
|
|
return 1;
|
|
|
}
|