Browse Source

Merge branch 'dev-V1.2' of http://146.56.199.25:3000/zhuibobo/EnforcementCode-2.0 into dev-V1.2

dev-V1.2
parent
commit
011d69467f
  1. 30
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/quartz/job/CpNoticeExpiryReminderJob.java
  2. 8
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/IEfcodeCpNoticeService.java
  3. 70
      zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/EfcodeCpNoticeServiceImpl.java

30
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/quartz/job/CpNoticeExpiryReminderJob.java

@ -0,0 +1,30 @@
package com.zdxt.enforcementcode.quartz.job;
import com.zdxt.enforcementcode.service.IEfcodeCpNoticeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 预告到期短信预警 - 定时任务
* <p>扫描已发布且执法日期为明天的预告,向企业联系人发送到期预警短信,
* 提醒企业提前做好迎检准备。</p>
*
* @author zrb
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class CpNoticeExpiryReminderJob {
private final IEfcodeCpNoticeService cpNoticeService;
/**
* 任务执行入口(public,供 JobInvokeUtil 通过反射调用)
*/
public void execute() {
log.info("[CpNoticeExpiryReminderJob] 定时任务触发:即将到期的预告发送短信预警");
int count = cpNoticeService.notifyExpiryReminder();
log.info("[CpNoticeExpiryReminderJob] 执行完成:共发送{}条预告的预警短信", count);
}
}

8
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/IEfcodeCpNoticeService.java

@ -98,6 +98,14 @@ public interface IEfcodeCpNoticeService {
*/
int markExpiredNoticesAsExecuted();
/**
* 明天到期的预告发送短信预警
* <p>查询执法日期为明天、已发布且未删除的预告,向企业联系人发送到期预警短信。</p>
*
* @return 发送预警短信的预告数量
*/
int notifyExpiryReminder();
/**
* 预告消息查看后置已读
*/

70
zdxt-modules/zdxt-enforcement-code/src/main/java/com/zdxt/enforcementcode/service/impl/EfcodeCpNoticeServiceImpl.java

@ -364,6 +364,7 @@ public class EfcodeCpNoticeServiceImpl implements IEfcodeCpNoticeService {
.like(EfcodeCpNotice::getBureauDeptName, sv)
.or().like(EfcodeCpNotice::getEnterpriseName, sv)
.or().like(EfcodeCpNotice::getEnforceContent, sv)
.or().like(EfcodeCpNotice::getEnforceUserNames, sv)
);
}
@ -462,6 +463,75 @@ public class EfcodeCpNoticeServiceImpl implements IEfcodeCpNoticeService {
return expiredList.size();
}
/**
* 明天到期的预告发送短信预警
* <p>仅查询过滤,不修改预告数据;短信由 ZwSmsClient 异步发送,
* 单条失败仅记日志,不影响其余预告的发送。</p>
*/
@Override
public int notifyExpiryReminder() {
// 发送前校验系统参数开关
if (!isSnsSendEnabled()) {
log.info("系统参数[sns.send]未开启,跳过预告到期预警短信发送");
return 0;
}
// 明天日期(enforce_date 为 yyyy-MM-dd 格式字符串)
String tomorrow = java.time.LocalDate.now().plusDays(1).toString();
// 查询已发布且执法日期为明天、未删除的预告
LambdaQueryWrapper<EfcodeCpNotice> lqw = Wrappers.lambdaQuery();
lqw.eq(EfcodeCpNotice::getStatus, 1L);
lqw.eq(EfcodeCpNotice::getIsDelete, 0L);
lqw.eq(EfcodeCpNotice::getEnforceDate, tomorrow);
List<EfcodeCpNotice> noticeList = baseMapper.selectList(lqw);
if (noticeList.isEmpty()) {
log.info("[notifyTomorrowExpiringNotices] 无明天到期的预告需要预警,明天日期={}", tomorrow);
return 0;
}
log.info("[notifyTomorrowExpiringNotices] 找到{}条明天到期的预告,开始发送预警短信", noticeList.size());
int notifyCount = 0;
for (EfcodeCpNotice notice : noticeList) {
try {
if (StringUtils.isBlank(notice.getContactPhone())) {
log.info("[notifyTomorrowExpiringNotices] 预告[{}]无企业联系电话,跳过短信发送,企业={}",
notice.getId(), notice.getEnterpriseName());
continue;
}
sendExpiryWarnSms(notice);
notifyCount++;
} catch (Exception e) {
log.error("[notifyTomorrowExpiringNotices] 预告[{}]预警短信发送异常:{}",
notice.getId(), e.getMessage(), e);
}
}
log.info("[notifyTomorrowExpiringNotices] 预警短信分发完毕,共发送{}条预告", notifyCount);
return notifyCount;
}
/**
* 异步发送预告到期预警短信,提醒企业联系人
*/
private void sendExpiryWarnSms(EfcodeCpNotice notice) {
String enforceTimeText = switch (notice.getEnforceTime() == null ? 0 : notice.getEnforceTime().intValue()) {
case 1 -> "上午";
case 2 -> "下午";
case 3 -> "其他";
default -> "";
};
String checkTime = notice.getEnforceDate() + (StringUtils.isBlank(enforceTimeText) ? "" : " " + enforceTimeText);
String contactPerson = StringUtils.isNotBlank(notice.getContactPerson()) ? notice.getContactPerson() : "";
String content =
"【深圳政务短信平台】尊敬的" + contactPerson + "(先生/女士),您好!您收到一则行政检查预告到期提醒。信息内容如下:"
+ "企业名称:" + notice.getEnterpriseName()
+ ";执法单位:" + notice.getBureauDeptName()
+ ";检查时间:" + checkTime
+ "。该预告将于明天到期执行,请提前做好相关准备,如需了解预告详情,请登录深政易,进入“执法监督码”查看,感谢您的理解!";
zwSmsClient.asyncSendSms("13560561199", content);
}
/**
* 修改预告消息已读状态
*

Loading…
Cancel
Save