Commit f71e95e8 by YG8999

添加保洁短信提醒控制开关,添加网关离线短信提醒,去掉设备操作服务中的开门和取电延时操作

parent f4c56ee8
...@@ -15,6 +15,7 @@ public enum SmsTypeEnum { ...@@ -15,6 +15,7 @@ public enum SmsTypeEnum {
SMS_ORDER_END_TEMP(5,"sms.order.end.template","订单即将结束提示短信"), SMS_ORDER_END_TEMP(5,"sms.order.end.template","订单即将结束提示短信"),
SMS_CLEAN_RECORDS_STOP_TEMP(6,"sms.clean.records.stop.template","保洁任务中断短信提醒"), SMS_CLEAN_RECORDS_STOP_TEMP(6,"sms.clean.records.stop.template","保洁任务中断短信提醒"),
SMS_DEVICE_ABNORMAL_TEMP(7,"sms.device.abnormal.template","设备状态异常变更短信提醒"), SMS_DEVICE_ABNORMAL_TEMP(7,"sms.device.abnormal.template","设备状态异常变更短信提醒"),
SMS_DEVICE_GATEWAY_TEMP(8,"sms.device.gateway.template","网关设备离线提醒短信"),
; ;
private Integer code; private Integer code;
......
...@@ -8,8 +8,8 @@ import com.alibaba.fastjson.JSONArray; ...@@ -8,8 +8,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
public enum YesNoEnum { public enum YesNoEnum {
yes(1, true, "是", "激活", "正常", "", "", "", "", "", ""), yes(1, true, "是", "激活", "正常", "Y", "", "", "", "", ""),
no(0, false, "否", "冻结", "异常", "", "", "", "", "", ""); no(0, false, "否", "冻结", "异常", "N", "", "", "", "", "");
private Integer index; private Integer index;
......
...@@ -2,9 +2,12 @@ package share.quartz.task; ...@@ -2,9 +2,12 @@ package share.quartz.task;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import share.system.domain.DeviceGateway;
import share.system.service.DeviceGatewayService; import share.system.service.DeviceGatewayService;
import share.system.service.DeviceStatusLogService; import share.system.service.DeviceStatusLogService;
import java.util.List;
/** /**
* @className: share.quartz.task.DeviceTask * @className: share.quartz.task.DeviceTask
* @description: 设备定时任务 * @description: 设备定时任务
...@@ -32,9 +35,12 @@ public class DeviceTask { ...@@ -32,9 +35,12 @@ public class DeviceTask {
*/ */
public void deviceGatewayStatusMonitor() { public void deviceGatewayStatusMonitor() {
// 更新网关状态 // 更新网关状态
boolean b = deviceGatewayService.deviceGatewayStatusMonitor(); List<DeviceGateway> list = deviceGatewayService.deviceGatewayStatusMonitor();
if (b) { if (list.size() > 0) {
// 离线网关,发送短信提醒 // 离线网关,发送短信提醒
list.forEach(deviceGateway -> {
deviceGatewayService.sendSmsByStatusOff(deviceGateway);
});
} }
} }
......
...@@ -64,9 +64,16 @@ public interface DeviceGatewayService extends IService<DeviceGateway> ...@@ -64,9 +64,16 @@ public interface DeviceGatewayService extends IService<DeviceGateway>
/** /**
* 网关状态监控 * 网关状态监控
* @return * @return 离线发送短信提醒的网关对象
*/ */
boolean deviceGatewayStatusMonitor(); List<DeviceGateway> deviceGatewayStatusMonitor();
TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto); TableDataInfo deviceGatewayPage(DeviceGatewayDto deviceGatewayDto);
/**
* 网关离线发送短信提醒
* @param deviceGateway
* @return
*/
boolean sendSmsByStatusOff(DeviceGateway deviceGateway);
} }
...@@ -2,6 +2,7 @@ package share.system.service; ...@@ -2,6 +2,7 @@ package share.system.service;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import share.system.domain.DeviceGateway;
import share.system.domain.DeviceStatusLog; import share.system.domain.DeviceStatusLog;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.domain.SStore; import share.system.domain.SStore;
...@@ -60,5 +61,11 @@ public interface SmsService { ...@@ -60,5 +61,11 @@ public interface SmsService {
*/ */
boolean sendSmsDeviceAbnormal(String phone, DeviceStatusLog deviceStatusLog, SStore store, SRoom room); boolean sendSmsDeviceAbnormal(String phone, DeviceStatusLog deviceStatusLog, SStore store, SRoom room);
/**
* 网关离线,发送短信通知
* @return
*/
boolean sendSmsByGatewayOff(String phone, DeviceGateway deviceGateway, SStore store);
} }
...@@ -17,18 +17,18 @@ import share.common.core.page.PageDomain; ...@@ -17,18 +17,18 @@ import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport; import share.common.core.page.TableSupport;
import share.common.enums.DeviceStatusEnum; import share.common.enums.DeviceStatusEnum;
import share.common.enums.YesNoEnum;
import share.common.utils.DateUtils; import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.Device; import share.system.domain.*;
import share.system.domain.DeviceGatewayDto;
import share.system.domain.SStore;
import share.system.domain.vo.DeviceGatewayVo; import share.system.domain.vo.DeviceGatewayVo;
import share.system.domain.vo.DeviceVo; import share.system.domain.vo.DeviceVo;
import share.system.mapper.DeviceGatewayMapper; import share.system.mapper.DeviceGatewayMapper;
import share.system.domain.DeviceGateway;
import share.system.mapper.SStoreMapper; import share.system.mapper.SStoreMapper;
import share.system.service.DeviceGatewayService; import share.system.service.DeviceGatewayService;
import share.system.service.ISysConfigService;
import share.system.service.SmsService;
/** /**
* 设备网关信息Service业务层处理 * 设备网关信息Service业务层处理
...@@ -46,6 +46,11 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -46,6 +46,11 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
private Integer deviceGatewayLastReportTime; private Integer deviceGatewayLastReportTime;
@Autowired @Autowired
private SStoreMapper storeMapper; private SStoreMapper storeMapper;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private SmsService smsService;
/** /**
* 查询设备网关信息 * 查询设备网关信息
...@@ -126,19 +131,29 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -126,19 +131,29 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
* @return * @return
*/ */
@Override @Override
public boolean deviceGatewayStatusMonitor() { public List<DeviceGateway> deviceGatewayStatusMonitor() {
List<DeviceGateway> list = deviceGatewayMapper.selectDeviceGatewayList(new DeviceGatewayDto()); List<DeviceGateway> list = deviceGatewayMapper.selectDeviceGatewayList(new DeviceGatewayDto());
list.stream().forEach(gateway -> { List<DeviceGateway> sendList = new ArrayList<>();
Date lastReportDate = gateway.getLastReportDate(); if (list.size() > 0) {
// 网关上报(最近10分钟内没有上报数据,网关设备离线) list.stream().forEach(gateway -> {
Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceGatewayLastReportTime); Date lastReportDate = gateway.getLastReportDate();
if (lastReportDate != null && lastReportDate.compareTo(startDate) > 0) { // 网关上报(最近10分钟内没有上报数据,网关设备离线)
gateway.setStatus(DeviceStatusEnum.DEVICE_ONLINE.getCode()); Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceGatewayLastReportTime);
} else { String status = gateway.getStatus();
gateway.setStatus(DeviceStatusEnum.DEVICE_OFFLINE.getCode()); if (lastReportDate != null && lastReportDate.compareTo(startDate) > 0) {
} gateway.setStatus(DeviceStatusEnum.DEVICE_ONLINE.getCode());
}); } else {
return this.updateBatchById(list); if (DeviceStatusEnum.DEVICE_ONLINE.getCode().equals(status)) {
// 如果网关之前在线,变更离线需要发送短信提醒
sendList.add(gateway);
}
gateway.setStatus(DeviceStatusEnum.DEVICE_OFFLINE.getCode());
}
});
// 更新数据
this.updateBatchById(list);
}
return sendList;
} }
@Override @Override
...@@ -169,6 +184,24 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D ...@@ -169,6 +184,24 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
return tableDataInfo; return tableDataInfo;
} }
/**
* 网关离线发送短信提醒
* @param deviceGateway 网关对象
* @return
*/
@Override
public boolean sendSmsByStatusOff(DeviceGateway deviceGateway) {
LambdaQueryWrapper<SStore> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(SStore::getDeviceGroup, deviceGateway.getGroup());
SStore store = storeMapper.selectOne(queryWrapper);
if (store != null) {
String phone = sysConfigService.selectConfigByKey("system.device.phone");
// 发送短信提醒
return smsService.sendSmsByGatewayOff(phone, deviceGateway, store);
}
return Boolean.FALSE;
}
private List<DeviceGatewayVo> convertDosToVos(List<DeviceGateway> deviceGateways) { private List<DeviceGatewayVo> convertDosToVos(List<DeviceGateway> deviceGateways) {
List<DeviceGatewayVo> voList = new ArrayList<>(); List<DeviceGatewayVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(deviceGateways)) { if (CollectionUtils.isNotEmpty(deviceGateways)) {
......
...@@ -131,11 +131,11 @@ public class DeviceOpServiceImpl implements DeviceOpService { ...@@ -131,11 +131,11 @@ public class DeviceOpServiceImpl implements DeviceOpService {
if (device != null) { if (device != null) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) { if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁 // 门锁
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), deviceParam.getOpType(), true, 2L); this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), deviceParam.getOpType(), false, 0);
} }
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) { if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关 // 取电开关
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), deviceParam.getOpType(), true, 2L); this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), deviceParam.getOpType(), false, 0);
} }
} }
} }
...@@ -153,11 +153,11 @@ public class DeviceOpServiceImpl implements DeviceOpService { ...@@ -153,11 +153,11 @@ public class DeviceOpServiceImpl implements DeviceOpService {
for (Device device : list) { for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) { if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁 // 门锁
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.OPEN_DOOR.getCode(), false, 0L); this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.OPEN_DOOR.getCode(), false, 0);
} }
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) { if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关 // 取电开关
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), true, 4L); this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), false, 0);
} }
} }
...@@ -182,7 +182,7 @@ public class DeviceOpServiceImpl implements DeviceOpService { ...@@ -182,7 +182,7 @@ public class DeviceOpServiceImpl implements DeviceOpService {
} }
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) { if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关 // 取电开关
this.deviceOpInit(device.getDevId(), phone, OpTypeEnum.GET_ELECTRIC.getCode(), true, 4L); this.deviceOpInit(device.getDevId(), phone, OpTypeEnum.GET_ELECTRIC.getCode(), false, 0);
} }
} }
......
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