Commit 70d2fc07 authored by 赵啸非's avatar 赵啸非

短信发送查询基础服务开关添加

parent aad3037a
package com.mortals.xhx.feign.sms;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.sms.SmsSetPdu;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 短信设置 Feign接口
* @author zxfei
* @date 2022-07-28
*/
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = SmsSetFeignFallbackFactory.class)
public interface ISmsSetFeign extends IFeign {
/**
* 查看短信设置列表
*
* @param smsSetPdu
* @return
*/
@PostMapping(value = "/sms/set/list")
Rest<RespData<List<SmsSetPdu>>> list(@RequestBody SmsSetPdu smsSetPdu);
/**
* 查看短信设置
*
* @param id
* @return
*/
@GetMapping(value = "/sms/set/info")
Rest<SmsSetPdu> info(@RequestParam(value = "id") Long id);
/**
* 删除短信设置
*
* @param ids
* @return
*/
@GetMapping(value = "/sms/set/delete")
Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);
/**
* 短信设置保存更新
*
* @param smsSetPdu
* @return
*/
@PostMapping(value = "/sms/set/save")
Rest<RespData<SmsSetPdu>> save(@RequestBody SmsSetPdu smsSetPdu,@RequestHeader("Authorization") String authorization);
}
@Slf4j
@Component
class SmsSetFeignFallbackFactory implements FallbackFactory<ISmsSetFeign> {
@Override
public ISmsSetFeign create(Throwable t) {
return new ISmsSetFeign() {
@Override
public Rest<RespData<List<SmsSetPdu>>> list(SmsSetPdu smsSetPdu) {
return Rest.fail("暂时无法获取短信设置列表,请稍后再试!");
}
@Override
public Rest<SmsSetPdu> info(Long id) {
return Rest.fail("暂时无法获取短信设置详细,请稍后再试!");
}
@Override
public Rest<Void> delete(Long[] ids, String authorization) {
return Rest.fail("暂时无法删除短信设置,请稍后再试!");
}
@Override
public Rest<RespData<SmsSetPdu>> save(SmsSetPdu smsSetPdu, String authorization) {
return Rest.fail("暂时无法保存短信设置,请稍后再试!");
}
};
}
}
......@@ -230,7 +230,6 @@ export default {
list-style-type:none;
border-bottom:3px solid #fff;
padding-bottom: 2px;
}
}
}
......
......@@ -3,9 +3,13 @@ package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.UuidUtil;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.sms.SmsSetPdu;
import com.mortals.xhx.feign.sms.ISmsSetFeign;
import com.mortals.xhx.module.alarm.model.AlarmConfigEntity;
import com.mortals.xhx.module.alarm.model.AlarmConfigQuery;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
......@@ -28,6 +32,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
/**
* 离线通知
......@@ -52,6 +57,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
private DeviceAlarmInfoService deviceAlarmInfoService;
@Autowired
private AlarmSmsSendService alarmSmsSendService;
@Autowired
private ISmsSetFeign smsSetFeign;
@Override
......@@ -78,6 +85,15 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (!ObjectUtils.isEmpty(alarmConfigEntity)) {
if(alarmConfigEntity.getAlarmPusW1ay()== AlarmPusW1ayEnum.短信.getValue()){
// TODO: 2022/7/4 发送短信
Rest<RespData<List<SmsSetPdu>>> respDataRest = smsSetFeign.list(new SmsSetPdu().siteId(deviceEntity.getSiteId()));
if(respDataRest.getCode()==YesNoEnum.YES.getValue()){
List<SmsSetPdu> data = respDataRest.getData().getData();
if(!ObjectUtils.isEmpty(data)){
Integer messageoff = data.get(0).getMessageoff();
if(messageoff==YesNoEnum.YES.getValue()){
// todo 发送短信
DeviceAlarmInfoEntity deviceAlarmInfoEntity = deviceAlarmInfoService.selectOne(new DeviceAlarmInfoQuery().alarmDevice(deviceEntity.getId()));
if(!ObjectUtils.isEmpty(deviceAlarmInfoEntity)){
AlarmSmsSendEntity alarmSmsSendEntity = new AlarmSmsSendEntity();
......@@ -89,12 +105,16 @@ public class CustomerKeyExpirationListener implements MessageListener {
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity,null);
}
}else{
}
}
}
}
}
}
}
}
log.info("监听到key:" + key + "过期");
}
}
\ No newline at end of file
package com.mortals.xhx.module.alarm.service.impl;
import com.mortals.xhx.queue.TbQueueMsg;
import lombok.Getter;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.alarm.dao.AlarmSmsSendDao;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
import com.mortals.xhx.module.alarm.service.AlarmSmsSendService;
import org.springframework.stereotype.Service;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment