112 lines
5.3 KiB
Java
112 lines
5.3 KiB
Java
|
|
package com.zhgd.xmgl.async;
|
||
|
|
|
||
|
|
import cn.hutool.http.HttpUtil;
|
||
|
|
import cn.hutool.json.JSONUtil;
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.entity.ThirdPartyPlatformService;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||
|
|
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectUfaceConfigMapper;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.mapper.ThirdPartyPlatformServiceMapper;
|
||
|
|
import com.zhgd.xmgl.modules.bigdevice.entity.Tower;
|
||
|
|
import com.zhgd.xmgl.modules.bigdevice.entity.TowerCurrentData;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.apache.commons.collections.CollectionUtils;
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.scheduling.annotation.Async;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @program: wisdomSite
|
||
|
|
* @description: 异步转发塔机数据
|
||
|
|
* @author: Mr.Peng
|
||
|
|
* @create: 2021-07-29 11:29
|
||
|
|
**/
|
||
|
|
@Slf4j
|
||
|
|
@Component
|
||
|
|
public class AsyncTower {
|
||
|
|
|
||
|
|
@Autowired
|
||
|
|
private ProjectUfaceConfigMapper projectUfaceConfigMapper;
|
||
|
|
@Autowired
|
||
|
|
private ThirdPartyPlatformServiceMapper thirdPartyPlatformServiceMapper;
|
||
|
|
@Autowired
|
||
|
|
private INoticeService noticeService;
|
||
|
|
@Autowired
|
||
|
|
private AsyncAiAnalyse asyncAiAnalyse;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 发送塔机设备数据
|
||
|
|
*/
|
||
|
|
@Async("towerExecutor")
|
||
|
|
public void sendTowerDev(Tower tower) {
|
||
|
|
try {
|
||
|
|
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
|
|
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, tower.getProjectSn());
|
||
|
|
ProjectUfaceConfig tempProjectUfaceConfig=projectUfaceConfigMapper.selectOne(queryWrapper);
|
||
|
|
if(tempProjectUfaceConfig!=null&& StringUtils.isNotEmpty(tempProjectUfaceConfig.getHousing())&&!"0".equals(tempProjectUfaceConfig.getHousing())) {
|
||
|
|
String[] arr = tempProjectUfaceConfig.getHousing().split(",");
|
||
|
|
Map<String,Object> data=new HashMap<>();
|
||
|
|
data.put("projectSn",tower.getProjectSn());
|
||
|
|
data.put("tower",tower);
|
||
|
|
for (String housingId : arr) {
|
||
|
|
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
|
|
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getTowerSystem()==1) {
|
||
|
|
log.info("-----开始执行塔机设备数据下发----" + dictionariesRecord.getServiceName());
|
||
|
|
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveTowerDev", JSONUtil.toJsonStr(data));
|
||
|
|
log.info("-----下发执行塔机设备数据结果----" + result);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}catch (Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 转发塔机实时数据
|
||
|
|
*/
|
||
|
|
@Async("towerExecutor")
|
||
|
|
public void sendTowerCurrentData(TowerCurrentData towerCurrentData, Tower tower) {
|
||
|
|
try {
|
||
|
|
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
|
|
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, tower.getProjectSn());
|
||
|
|
ProjectUfaceConfig tempProjectUfaceConfig=projectUfaceConfigMapper.selectOne(queryWrapper);
|
||
|
|
if(tempProjectUfaceConfig!=null&& StringUtils.isNotEmpty(tempProjectUfaceConfig.getHousing())&&!"0".equals(tempProjectUfaceConfig.getHousing())) {
|
||
|
|
String[] arr = tempProjectUfaceConfig.getHousing().split(",");
|
||
|
|
Map<String,Object> data=new HashMap<>();
|
||
|
|
data.put("projectSn",tower.getProjectSn());
|
||
|
|
data.put("towerCurrentData",towerCurrentData);
|
||
|
|
data.put("tower",tower);
|
||
|
|
for (String housingId : arr) {
|
||
|
|
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
|
|
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getTowerSystem()==1) {
|
||
|
|
log.info("-----开始执行塔机实时数据下发----" + dictionariesRecord.getServiceName());
|
||
|
|
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveTowerCurrentData", JSONUtil.toJsonStr(data));
|
||
|
|
log.info("-----下发执行塔机实时数据结果----" + result);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}catch (Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Async("towerExecutor")
|
||
|
|
public void sendOfflineAlarm(List<SystemUser> systemUserList, Tower offlineTower,String msg ,String title,String payload) {
|
||
|
|
if(CollectionUtils.isNotEmpty(systemUserList)){
|
||
|
|
for (SystemUser systemUser:systemUserList){
|
||
|
|
log.info(systemUser.getAccount()+"收消息:"+msg);
|
||
|
|
noticeService.addUserNotice(systemUser.getUserId(),msg,title,"12");
|
||
|
|
asyncAiAnalyse.sendAppNotice(offlineTower.getProjectSn(),title,msg,systemUserList,payload);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|