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("暂时无法保存短信设置,请稍后再试!");
}
};
}
}
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<li v-for='item in menu' :key='item.id'> <li v-for='item in menu' :key='item.id'>
<router-link :to="item.path" :active='submenu.path === item.path' :title="item.name"> <router-link :to="item.path" :active='submenu.path === item.path' :title="item.name">
<i :class="'el-icon-'+item.icon"></i> <i :class="'el-icon-'+item.icon"></i>
{{item.name}} {{item.name}}
</router-link> </router-link>
</li> </li>
</ul> </ul>
...@@ -228,9 +228,8 @@ export default { ...@@ -228,9 +228,8 @@ export default {
//background: #1890ff; //background: #1890ff;
color: #fff; color: #fff;
list-style-type:none; list-style-type:none;
border-bottom:3px solid #fff; border-bottom:3px solid #fff;
padding-bottom: 2px; padding-bottom: 2px;
} }
} }
} }
......
...@@ -3,9 +3,13 @@ package com.mortals.xhx.base.framework.listener; ...@@ -3,9 +3,13 @@ package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.UuidUtil; import com.mortals.framework.util.UuidUtil;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.RedisKey; 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.AlarmConfigEntity;
import com.mortals.xhx.module.alarm.model.AlarmConfigQuery; import com.mortals.xhx.module.alarm.model.AlarmConfigQuery;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity; import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
...@@ -28,6 +32,7 @@ import org.springframework.stereotype.Component; ...@@ -28,6 +32,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 离线通知 * 离线通知
...@@ -52,6 +57,8 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -52,6 +57,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
private DeviceAlarmInfoService deviceAlarmInfoService; private DeviceAlarmInfoService deviceAlarmInfoService;
@Autowired @Autowired
private AlarmSmsSendService alarmSmsSendService; private AlarmSmsSendService alarmSmsSendService;
@Autowired
private ISmsSetFeign smsSetFeign;
@Override @Override
...@@ -78,18 +85,31 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -78,18 +85,31 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (!ObjectUtils.isEmpty(alarmConfigEntity)) { if (!ObjectUtils.isEmpty(alarmConfigEntity)) {
if(alarmConfigEntity.getAlarmPusW1ay()== AlarmPusW1ayEnum.短信.getValue()){ if(alarmConfigEntity.getAlarmPusW1ay()== AlarmPusW1ayEnum.短信.getValue()){
// TODO: 2022/7/4 发送短信 // TODO: 2022/7/4 发送短信
DeviceAlarmInfoEntity deviceAlarmInfoEntity = deviceAlarmInfoService.selectOne(new DeviceAlarmInfoQuery().alarmDevice(deviceEntity.getId()));
if(!ObjectUtils.isEmpty(deviceAlarmInfoEntity)){
AlarmSmsSendEntity alarmSmsSendEntity = new AlarmSmsSendEntity();
alarmSmsSendEntity.initAttrValue();
alarmSmsSendEntity.setId(IdUtil.getSnowflake().nextId());
alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone());
alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel());
alarmSmsSendEntity.setSendMess(deviceAlarmInfoEntity.getAlarmContent());
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity,null);
}
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();
alarmSmsSendEntity.initAttrValue();
alarmSmsSendEntity.setId(IdUtil.getSnowflake().nextId());
alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone());
alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel());
alarmSmsSendEntity.setSendMess(deviceAlarmInfoEntity.getAlarmContent());
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity,null);
}
}else{
}
}
}
} }
} }
} }
......
package com.mortals.xhx.module.alarm.service.impl; 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.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.alarm.dao.AlarmSmsSendDao; import com.mortals.xhx.module.alarm.dao.AlarmSmsSendDao;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity; import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
import com.mortals.xhx.module.alarm.service.AlarmSmsSendService; import com.mortals.xhx.module.alarm.service.AlarmSmsSendService;
import org.springframework.stereotype.Service;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue; 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