|
|
@@ -28,10 +28,6 @@ import com.xueyi.system.api.organize.domain.dto.SysEnterpriseDto; |
|
|
|
import com.xueyi.system.api.sms.domain.vo.DingdingReqEntity; |
|
|
|
import com.xueyi.system.api.sms.feign.RemoteDingdingService; |
|
|
|
import com.xueyi.system.api.sms.feign.RemoteSmsService; |
|
|
|
import com.xueyi.system.api.sms.domain.vo.DingdingReqEntity; |
|
|
|
import com.xueyi.system.api.sms.domain.vo.SmsReqEntity; |
|
|
|
import com.xueyi.system.api.sms.feign.RemoteDingdingService; |
|
|
|
import com.xueyi.system.api.sms.feign.RemoteSmsService; |
|
|
|
import com.xueyi.system.device.service.IDmDeviceTenantMergeService; |
|
|
|
import com.xueyi.system.dict.service.ISysDictDataService; |
|
|
|
import com.xueyi.system.digitalmans.domain.query.DmManDeviceQuery; |
|
|
@@ -66,8 +62,10 @@ import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
|
|
import static com.xueyi.common.core.constant.digitalman.InitConstants.DEVICE_ACTIVATE_STATUS_OFFLINE; |
|
|
|
import static com.xueyi.common.core.constant.digitalman.InitConstants.DEVICE_ACTIVATE_STATUS_ONLINE; |
|
|
|
import static com.xueyi.common.core.constant.digitalman.RedisDefinitionConstants.GENERAL_CURRENT_NUMBER_OF_ONLINE; |
|
|
|
|
|
|
|
/** |
|
|
@@ -149,6 +147,7 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa |
|
|
|
@PostMapping(value = "/inner/sync") |
|
|
|
R<Integer> manDeviceListInnerSync(@RequestParam(value = "tenantId") Long tenantId) { |
|
|
|
log.info("同步设备信息开始:{}",tenantId); |
|
|
|
AtomicReference<Integer> syncCount = new AtomicReference<>(0); |
|
|
|
DmManDeviceQuery query = new DmManDeviceQuery(); |
|
|
|
query.setTId(tenantId); |
|
|
|
//根据租户id获取设备列表 |
|
|
@@ -156,13 +155,12 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa |
|
|
|
SysEnterpriseDto dto = enterpriseService.selectById(tenantId); |
|
|
|
Source source = SourceUtil.getSourceCache(dto.getStrategyId()); |
|
|
|
// 同步总体设备信息 |
|
|
|
list.stream().filter(item->!item.getOnlineStatus().equalsIgnoreCase("0")).forEach(item->{ |
|
|
|
R<Integer> syncDevices = remoteDigitalmanService.syncExtIsonline(list,tenantId,source.getMaster(), SecurityConstants.INNER); |
|
|
|
// 钉钉预警信息发送 |
|
|
|
list.stream().forEach(item->{ |
|
|
|
log.info("同步设备信息:{}",item); |
|
|
|
Integer tempCount = 0; |
|
|
|
DmManDeviceDto tempDto = (DmManDeviceDto) redisTemplate.opsForHash().get(MessageConstants.REDIS_GROUP_DEVICE_HEADER,item.getDeviceId()); |
|
|
|
if (!item.getOnlineStatus().equalsIgnoreCase(tempDto.getOnlineStatus())) { |
|
|
|
item.setOnlineStatus(tempDto.getOnlineStatus()); |
|
|
|
super.baseService.update(item); |
|
|
|
} |
|
|
|
if (tempDto.getOnlineStatus().equalsIgnoreCase(DEVICE_ACTIVATE_STATUS_OFFLINE)) { |
|
|
|
// query if the device is in the exception log |
|
|
|
DmExceptionLogQuery logQuery = new DmExceptionLogQuery(); |
|
|
@@ -189,10 +187,37 @@ public class DmManDeviceController extends BaseController<DmManDeviceQuery, DmMa |
|
|
|
entity.setText(jo); |
|
|
|
JSONObject dingdingResult = remoteDingdingService.send(token,entity); |
|
|
|
log.info("dingdingResult:{}",dingdingResult); |
|
|
|
tempCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (tempDto.getOnlineStatus().equalsIgnoreCase(DEVICE_ACTIVATE_STATUS_ONLINE)) { |
|
|
|
// query if the device is in the exception log |
|
|
|
DmExceptionLogQuery logQuery = new DmExceptionLogQuery(); |
|
|
|
logQuery.setDevId(tempDto.getDeviceId()); |
|
|
|
logQuery.setTId(tenantId); |
|
|
|
logQuery.setAlertStatus(0); |
|
|
|
logQuery.setType("heartbeat_status"); |
|
|
|
List<DmExceptionLogDto> logDtos = dmExceptionLogService.selectList(logQuery); |
|
|
|
if (logDtos != null && logDtos.size() > 0) { |
|
|
|
logDtos.stream().forEach(logDto->{ |
|
|
|
logDto.setAlertStatus(1); |
|
|
|
dmExceptionLogService.update(logDto); |
|
|
|
|
|
|
|
}); |
|
|
|
DingdingReqEntity entity = new DingdingReqEntity(); |
|
|
|
entity.setMsgtype("text"); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("content", "【解除预警】客户" + item.getTenantName() + ",设备" + item.getDeviceId() + "已恢复在线状态。"); |
|
|
|
entity.setText(jo); |
|
|
|
JSONObject dingdingResult = remoteDingdingService.send(token,entity); |
|
|
|
log.info("dingdingResult:{}",dingdingResult); |
|
|
|
tempCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
syncCount.set(tempCount); |
|
|
|
}); |
|
|
|
return remoteDigitalmanService.syncExtIsonline(list,tenantId,source.getMaster(), SecurityConstants.INNER); |
|
|
|
|
|
|
|
return R.ok(syncCount.get()); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping(value = "/inner/info") |
|
|
|