Commit 63b5f3d0 by 叶立庆

发送企微应用消息优化

1 parent 45351223
......@@ -79,8 +79,12 @@ public class StaffMonthSalaryJob implements SimpleJob {
// 发送企微消息
executor.execute(() -> {
// 保存发送信息
Integer id = saveSendMsg(monthSalary);
sendMessage(monthSalary, id);
try {
StaffMonthSalarySlipSend slipSend = saveSendMsg(monthSalary);
sendMessage(monthSalary, slipSend);
} catch (Exception e) {
log.error("员工:{},手机号:{} 发送企微消息异常:{}", staffBaseInfo.getStaffName(), staffBaseInfo.getStaffPhone(), e.getMessage(), e);
}
});
} catch (Exception e) {
......@@ -95,7 +99,7 @@ public class StaffMonthSalaryJob implements SimpleJob {
}
}
private Integer saveSendMsg(StaffMonthSalarySlip monthSalary) {
private StaffMonthSalarySlipSend saveSendMsg(StaffMonthSalarySlip monthSalary) {
StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend();
staffMonthSalarySlipSend.setStaffName(monthSalary.getStaffName());
staffMonthSalarySlipSend.setStaffPhone(monthSalary.getStaffPhone());
......@@ -125,7 +129,7 @@ public class StaffMonthSalaryJob implements SimpleJob {
// 封装入职日期
staffMonthSalarySlipSend.setEntryDate(buildEntryDate(monthSalary));
staffMonthSalarySlipSendMapper.insertUseGeneratedKeys(staffMonthSalarySlipSend);
return staffMonthSalarySlipSend.getId();
return staffMonthSalarySlipSend;
}
public static String parsePerformanceLevelString(Integer performanceLevel) {
......@@ -171,15 +175,15 @@ public class StaffMonthSalaryJob implements SimpleJob {
* 发送
*
* @param monthSalary 工资条
* @param id 消息id
* @param slipSend 消息
*/
private void sendMessage(StaffMonthSalarySlip monthSalary, Integer id) {
private void sendMessage(StaffMonthSalarySlip monthSalary, StaffMonthSalarySlipSend slipSend) {
log.info("发送员工:{},手机号:{} 工资计算结果", monthSalary.getStaffName(), monthSalary.getStaffPhone());
// 获取企微员工标识门店号
Integer merchantId = env.getProperty("staff.month.salary.send.qw.notice.merchantId", Integer.class, 44202977);
// 发送自建应用消息对应(wechat-build-server)配置门店号
Integer sendConfigMerchantId = env.getProperty("staff.month.salary.send.qw.config.merchantId", Integer.class, 442029771);
String agentId = env.getProperty("staff.month.salary.send.qw.notice.agentId", String.class,"1000024");
String agentId = env.getProperty("staff.month.salary.send.qw.notice.agentId", String.class, "1000024");
String titleEnv = env.getProperty("staff.month.salary.send.qw.notice.title", String.class, "%s工资条系统数据");
String descriptionEvn = env.getProperty("staff.month.salary.send.qw.notice.description", String.class, "您好!感谢您这一月的辛勤工作,以下是您%s月的系统数据工资条,请查收!如有疑问请联系您的管辖上级处理。");
String urlEvn = env.getProperty("staff.month.salary.send.qw.notice.url", String.class);
......@@ -187,7 +191,7 @@ public class StaffMonthSalaryJob implements SimpleJob {
if (StringUtils.isBlank(userId)) {
log.info("员工:{},手机号:{} 获取企微员工标识失败", monthSalary.getStaffName(), monthSalary.getStaffPhone());
StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend();
staffMonthSalarySlipSend.setId(id);
staffMonthSalarySlipSend.setId(slipSend.getId());
staffMonthSalarySlipSend.setStatus(3);
staffMonthSalarySlipSend.setErrMsg("获取企微员工标识失败");
staffMonthSalarySlipSendMapper.updateByPrimaryKeySelective(staffMonthSalarySlipSend);
......@@ -203,7 +207,7 @@ public class StaffMonthSalaryJob implements SimpleJob {
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setUrl(urlEvn);
textCard.setUrl(urlEvn + "?uuid=" + slipSend.getUuid());
requestDTO.setTextCard(textCard);
SendWorkWechatMessageResponseDTO responseDTO = null;
try {
......@@ -214,15 +218,15 @@ public class StaffMonthSalaryJob implements SimpleJob {
if (responseDTO != null && responseDTO.isSuccess()) {
log.info("员工:{},手机号:{} 获取企微员工标识成功", monthSalary.getStaffName(), monthSalary.getStaffPhone());
StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend();
staffMonthSalarySlipSend.setId(id);
staffMonthSalarySlipSend.setId(slipSend.getId());
staffMonthSalarySlipSend.setStatus(2);
staffMonthSalarySlipSendMapper.updateByPrimaryKeySelective(staffMonthSalarySlipSend);
} else {
log.info("员工:{},手机号:{} 获取企微员工标识失败:{}", monthSalary.getStaffName(), monthSalary.getStaffPhone(), JSON.toJSONString(responseDTO));
StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend();
staffMonthSalarySlipSend.setId(id);
staffMonthSalarySlipSend.setId(slipSend.getId());
staffMonthSalarySlipSend.setStatus(3);
staffMonthSalarySlipSend.setErrMsg(responseDTO.getErrMsg());
staffMonthSalarySlipSend.setErrMsg(responseDTO != null ? responseDTO.getErrMsg() : "发送企微应用消息异常");
staffMonthSalarySlipSendMapper.updateByPrimaryKeySelective(staffMonthSalarySlipSend);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!