92 lines
4.6 KiB
Java
92 lines
4.6 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.ThirdPartyPlatformService;
|
||
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.GantryCrane;
|
||
import com.zhgd.xmgl.modules.bigdevice.entity.GantryCraneCurrentData;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
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.Map;
|
||
|
||
/**
|
||
* @program: wisdomSite
|
||
* @description: 龙门吊异步任务
|
||
* @author: Mr.Peng
|
||
* @create: 2021-08-10 18:47
|
||
**/
|
||
@Slf4j
|
||
@Component
|
||
public class AsyncGantryCrane {
|
||
@Autowired
|
||
private ProjectUfaceConfigMapper projectUfaceConfigMapper;
|
||
@Autowired
|
||
private ThirdPartyPlatformServiceMapper thirdPartyPlatformServiceMapper;
|
||
|
||
/**
|
||
* 发送龙门吊设备数据
|
||
*/
|
||
@Async("gantryCraneExecutor")
|
||
public void sendGantryCraneDev(GantryCrane gantryCrane) {
|
||
try {
|
||
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, gantryCrane.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",gantryCrane.getProjectSn());
|
||
data.put("gantryCrane",gantryCrane);
|
||
for (String housingId : arr) {
|
||
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getGantryCraneSystem()==1) {
|
||
log.info("-----开始执行龙门吊设备数据下发----" + dictionariesRecord.getServiceName());
|
||
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveGantryCraneDev", JSONUtil.toJsonStr(data));
|
||
log.info("-----下发执行龙门吊设备数据结果----" + result);
|
||
}
|
||
}
|
||
}
|
||
}catch (Exception e){
|
||
log.error("error:", e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 转发龙门吊实时数据
|
||
*/
|
||
@Async("gantryCraneExecutor")
|
||
public void sendGantryCraneCurrentData(GantryCraneCurrentData gantryCraneCurrentData, GantryCrane gantryCrane) {
|
||
try {
|
||
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, gantryCrane.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",gantryCrane.getProjectSn());
|
||
data.put("gantryCraneCurrentData",gantryCraneCurrentData);
|
||
data.put("gantryCrane",gantryCrane);
|
||
for (String housingId : arr) {
|
||
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getGantryCraneSystem()==1) {
|
||
log.info("-----开始执行龙门吊实时数据下发----" + dictionariesRecord.getServiceName());
|
||
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveGantryCraneCurrentData", JSONUtil.toJsonStr(data));
|
||
log.info("-----下发执行龙门吊实时数据结果----" + result);
|
||
}
|
||
}
|
||
}
|
||
}catch (Exception e){
|
||
log.error("error:", e);
|
||
}
|
||
}
|
||
}
|