添加员工入驻审核消息通知
This commit is contained in:
parent
e68914bd65
commit
05d5fdc117
|
|
@ -1,5 +1,6 @@
|
|||
package com.nu.modules.employees.service;
|
||||
|
||||
import com.nu.dto.EmployeesStatusMQDto;
|
||||
import com.nu.modules.employees.entity.NuEmployeesAdvisoryInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
|
@ -11,4 +12,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface INuEmployeesAdvisoryInfoService extends IService<NuEmployeesAdvisoryInfo> {
|
||||
|
||||
void sendYgrz(EmployeesStatusMQDto dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,31 @@
|
|||
package com.nu.modules.employees.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.dto.EmployeesStatusMQDto;
|
||||
import com.nu.modules.EmployessInfo.api.IEmployessAdvisioryInfoApi;
|
||||
import com.nu.modules.EmployessInfo.entity.EmployeesAdvisoryInfoEntity;
|
||||
import com.nu.modules.employees.entity.NuEmployeesAdvisoryInfo;
|
||||
import com.nu.modules.employees.mapper.NuEmployeesAdvisoryInfoMapper;
|
||||
import com.nu.modules.employees.service.INuEmployeesAdvisoryInfoService;
|
||||
import com.nu.modules.weixin.utils.TemplateMessageSender;
|
||||
import com.nu.modules.weixin.utils.WechatMiniProgramUtils;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -24,6 +37,11 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class NuEmployeesAdvisoryInfoServiceImpl extends ServiceImpl<NuEmployeesAdvisoryInfoMapper, NuEmployeesAdvisoryInfo> implements INuEmployeesAdvisoryInfoService, IEmployessAdvisioryInfoApi {
|
||||
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
@Override
|
||||
public EmployeesAdvisoryInfoEntity insert(EmployeesAdvisoryInfoEntity EmployeesAdvisoryInfoEntity) {
|
||||
NuEmployeesAdvisoryInfo NuEmployeesAdvisoryInfo = new NuEmployeesAdvisoryInfo();
|
||||
|
|
@ -68,4 +86,48 @@ public class NuEmployeesAdvisoryInfoServiceImpl extends ServiceImpl<NuEmployeesA
|
|||
public int updateByOpenId(EmployeesAdvisoryInfoEntity employeesAdvisoryInfoEntity) {
|
||||
return baseMapper.updateByOpenId(employeesAdvisoryInfoEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendYgrz(EmployeesStatusMQDto dto) {
|
||||
try {
|
||||
|
||||
// 1. 获取access token
|
||||
String accessToken = WechatMiniProgramUtils.getAccessToken();
|
||||
|
||||
// 2. 准备模板消息数据
|
||||
String templateId = "CJ6NDNV4mTTyOdYhbksyA_YjDORVemJRmzEVAUZMBis";
|
||||
String page = "pages/index/index"; // 点击消息跳转的页面
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
com.alibaba.fastjson.JSONObject orgInfo = sysBaseAPI.getOrgInfo(dto.getOrgCode());
|
||||
String companyName = orgInfo.getString("departName");
|
||||
String content = companyName + "员工入驻审核结果";
|
||||
String auditStatus = "";
|
||||
if (StringUtils.equals("2", dto.getAuditStatus())) {
|
||||
auditStatus = "审核通过";
|
||||
} else if (StringUtils.equals("3", dto.getAuditStatus())) {
|
||||
auditStatus = "审核驳回";
|
||||
}
|
||||
data.put("thing5", content); // 对应模板中的字段
|
||||
data.put("phrase6", auditStatus);
|
||||
data.put("date2", DateUtils.now());
|
||||
|
||||
// 3. 发送模板消息
|
||||
String resInfo = TemplateMessageSender.sendTemplateMessage(accessToken, dto.getOpenId(), templateId, page, data);
|
||||
if (com.alibaba.cloud.commons.lang.StringUtils.equals(resInfo, "error")) {
|
||||
baseCommonService.addLog("员工入驻审核,发送通知失败-发送消息异常112 " + resInfo, CommonConstant.LOG_TYPE_2, 1);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject(resInfo);
|
||||
boolean success = jsonObject.getInt("errcode") == 0;
|
||||
if (success) {
|
||||
System.out.println("模板消息发送成功");
|
||||
baseCommonService.addLog("员工入驻审核,发送通知成功 ", CommonConstant.LOG_TYPE_2, 1);
|
||||
} else {
|
||||
baseCommonService.addLog("员工入驻审核,发送通知失败-发送消息异常120 " + resInfo, CommonConstant.LOG_TYPE_2, 1);
|
||||
System.out.println("模板消息发送失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ public class EmployeesMQListener {
|
|||
employeesAd.setIzEntry("0");
|
||||
employeesAdvisoryInfoService.updateById(employeesAd);
|
||||
}
|
||||
employeesAdvisoryInfoService.sendYgrz(dto);
|
||||
|
||||
UpdateWrapper<EmployeesOrg> uw = new UpdateWrapper<>();
|
||||
uw.eq("employees_id", dto.getEmployeeId());
|
||||
uw.eq("org_code", dto.getOrgCode());
|
||||
|
|
|
|||
Loading…
Reference in New Issue