Kaynağa Gözat

调整消息

Administrator 4 yıl önce
ebeveyn
işleme
7f11c5e906

+ 10 - 0
src/main/java/com/goafanti/admin/bo/AdminListBo.java

@@ -97,6 +97,8 @@ public class AdminListBo {
 	
 	private String contactId;
 	
+	private String openId;
+	
 	public List<String> getRolesId() {
 		return rolesId;
 	}
@@ -286,4 +288,12 @@ public class AdminListBo {
 		this.contactId = contactId;
 	}
 
+	public String getOpenId() {
+		return openId;
+	}
+
+	public void setOpenId(String openId) {
+		this.openId = openId;
+	}
+
 }

+ 43 - 6
src/main/java/com/goafanti/admin/service/impl/PublicReleaseServiceImpl.java

@@ -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;
 	}

+ 2 - 2
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -990,8 +990,8 @@
   </select>
   <!-- 获得当前登录人的名字和部门名 -->
   <select id="getDeptNameByAid" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
-  	select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email from admin a
-  		left join department d on a.department_id = d.id
+  	select a.id,a.name, d.name as departmentName,a.department_id departmentId,a.email,a.superior_id superiorId 
+   from admin a left join department d on a.department_id = d.id
   		where a.id = #{_parameter,jdbcType=VARCHAR}
   </select>
   

+ 1 - 1
src/main/java/com/goafanti/common/mapper/PaymentNodeMapper.xml

@@ -467,7 +467,7 @@
    </if>
   </select>
   <select id="selectByStatus" resultType="com.goafanti.organization.bo.OutPaymentNode">
-  select id,tid,cid,company_name companyName,unit_price unitPrice,quantity,total_amount totalAmount,
+  select id,tid,cid,company_name companyName,unit_price unitPrice,quantity,total_amount totalAmount,create_time createTime ,
    party_amount partyAmount, date_format(party_time,'%Y-%m-%d')partyTimes,project_type projectType,dun_type dunType
    from payment_node where dun_status = #{status}
   </select>

+ 0 - 24
src/main/java/com/goafanti/common/utils/WeChatUtils.java

@@ -1,24 +1,17 @@
 package com.goafanti.common.utils;
 
-import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.mail.MessagingException;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import com.alibaba.fastjson.JSONObject;
-import com.goafanti.admin.bo.AdminListBo;
-import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.error.BusinessException;
-import com.goafanti.common.model.Admin;
-import com.goafanti.core.shiro.token.TokenManager;
 
 
 @Component
@@ -31,10 +24,6 @@ public class WeChatUtils {
 	private String appSecret;
 	@Autowired
 	private RedisUtil redisUtil;
-	@Autowired
-	private	AsyncUtils asyncUtils;
-	@Autowired
-	private AdminMapper	adminMapper;
 	
 	//待审核通知
 	private static final String sptz="j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I";
@@ -69,19 +58,6 @@ public class WeChatUtils {
 		JSONObject res=HttpUtils.httpPost(url, map);
 		System.out.println("res="+JSONObject.toJSONString(res));
 		if (res.get("errcode")!=null) {
-			Admin a=adminMapper.selectByOpeid(openid);
-			AdminListBo my=adminMapper.getDeptNameByAid(TokenManager.getAdminId());
-			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();
-				}
-			}
 			return res.getInteger("errcode");
 		}else {
 			return 1;