Commit 7c591f27 by 张富康

feat(perfSalary): 增加总部运营未处理有效引荐数通知功能

- 在EffectiveReferralReviewMapper新增查询未处理有效引荐数接口queryOnlineNoHandlerCount
- 在XML映射文件中新增对应SQL语句
- 调整定时任务EffectiveReferralReviewOnLineQwNotificationJob的执行时间
- 在EffectiveReferralReviewQwService中新增qwOnLineNotification方法
- 实现总部运营有效引荐数复核提醒逻辑,定时发送企微通知消息
- 添加相关日志记录和异常捕获
- 完善区域经理和总部运营企微用户ID的获取与校验机制
1 parent fc3ef0f0
......@@ -9,7 +9,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import javax.annotation.Resource;
@Slf4j
@ElasticJobConf(name = "EffectiveReferralReviewManagerQwNotificationJob", cron = "0 0 7,19 * * ? ", description = "有效引荐数总部线上复核企微通知", overwrite = false)
@ElasticJobConf(name = "EffectiveReferralReviewManagerQwNotificationJob", cron = "0 30 7,18,19 * * ? ", description = "有效引荐数总部线上复核企微通知", overwrite = false)
public class EffectiveReferralReviewOnLineQwNotificationJob implements SimpleJob {
@Resource
......
......@@ -39,4 +39,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr
List<String> queryQwSendMobilePhoneList(@Param("date") String date);
int queryOnlineNoHandlerCount(@Param("date") String date);
}
\ No newline at end of file
......@@ -33,6 +33,9 @@ public class EffectiveReferralReviewQwService {
@Resource
private EffectiveReferralReviewMapper effectiveReferralReviewMapper;
/**
* 通知区域经理
*/
public void qwManagerNotification() {
// 判断当前时间是否在T1范围内 如果不在则return
// 校验是否在修改的时间
......@@ -51,11 +54,16 @@ public class EffectiveReferralReviewQwService {
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
List<String> mobilePhoneList = effectiveReferralReviewMapper.queryQwSendMobilePhoneList(lastMonth);
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理有效引荐书对应的区域运营手机号");
log.info("没有未处理有效引荐数对应的区域运营手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
log.info("发送给的企微用户id:{}", joinedUserIds);
if (StrUtil.isBlank(joinedUserIds)) {
log.info("未处理有效引荐数对应的区域运营企微id为空");
return;
}
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
......@@ -87,7 +95,72 @@ public class EffectiveReferralReviewQwService {
}
/**
* 通知总部运营
*/
public void qwOnLineNotification() {
// 判断当前时间是否在T1范围内 如果不在则return
// 校验是否在修改的时间
PerformanceTimeCycleDTO performanceTimeCycleDTO = performanceTimeCycleMapper.selectByCode(PerformanceTimeCycleCodeEnum.T1.getCode());
Date startDate = performanceTimeCycleDTO.getStartDate();
Date endDate = performanceTimeCycleDTO.getEndDate();
Date now = DateUtil.date();
// 判断当前时间是否在考核时间范围内 当前时间需要大于等于开始时间,小于等于结束时间
boolean judgeTime = now.compareTo(startDate) < 0 || now.compareTo(endDate) > 0;
if (judgeTime) {
return;
}
// 获取所有未处理绩效的员工的上级领导手机号
// 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
int count = effectiveReferralReviewMapper.queryOnlineNoHandlerCount(lastMonth);
if (count <= 0) {
log.info("没有需要符合的有效引荐数据");
return;
}
// 查询是否有需要待复核的数据
String mobilePhonesStr = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.onLine.mobilePhone", String.class, "15622765546");
List<String> mobilePhoneList = StrUtil.split(mobilePhonesStr, ",");
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理有效引荐数对应的区域运营手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
log.info("发送给的企微用户id:{}", joinedUserIds);
if (StrUtil.isBlank(joinedUserIds)) {
log.info("未符合有效引荐数对应的总部运营企微id为空");
return;
}
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id", Integer.class, 44202977);
// todz 带确认
String title = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.title", String.class, "有效引荐数复核提醒通知");
String btnTxt = OrePropertyConfigurer.getProperty("dj.send.work.wechat.btnTxt", String.class, "去处理");
String url = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.url", String.class, "");
String descriptionEvn = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.description", String.class,
"你好,本月的门店复核有效引荐数存在未复核的,请尽快去完成~ \n" +
"亲,超过总部配置的每月{}号,就无法复核门店有效引荐数了哦");
// 获取endDate的日期数
Integer dayDate = DateUtil.dayOfMonth(endDate);
requestDTO.setMerchantId(merchantId);
requestDTO.setToUser(joinedUserIds);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
String description = StrUtil.format(descriptionEvn, dayDate);
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setBtnTxt(btnTxt);
textCard.setUrl(url);
requestDTO.setTextCard(textCard);
try {
qWManager.sendMessage(requestDTO);
} catch (Exception e) {
log.error("发送企微应用消息异常:", e);
}
}
}
......@@ -163,4 +163,14 @@
AND dc.director_phone IS NOT NULL;
</select>
<select id="queryOnlineNoHandlerCount" resultType="java.lang.Integer">
select count(*)
from sal_effective_referral_review
where deleted_flag = 'N'
and review_month = #{date}
and status = 2
and is_need_reviewed = 1
and is_reviewed = 0;
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!