可配置网关采集信息功能与数据接口接收采集卡配置信息更新
This commit is contained in:
parent
aa91bf9e92
commit
ca37310b18
@ -39,7 +39,8 @@ public class MqttAutoStart implements ApplicationRunner {
|
|||||||
@Value("${imt.data.mqtt.Qos}")
|
@Value("${imt.data.mqtt.Qos}")
|
||||||
private int Qos;
|
private int Qos;
|
||||||
|
|
||||||
private static final boolean START = false;
|
@Value("${imt.data.mqtt.start}")
|
||||||
|
private boolean START;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws MqttException {
|
public void run(ApplicationArguments args) throws MqttException {
|
||||||
|
@ -90,9 +90,9 @@ public class MyMqttCallback implements MqttCallback {
|
|||||||
String deviceType = (String) map.get("deviceType");
|
String deviceType = (String) map.get("deviceType");
|
||||||
String gatewayCode = deviceName.substring(0,17);
|
String gatewayCode = deviceName.substring(0,17);
|
||||||
Map<String,Object> mapping = getGatewayMapping(gatewayCode);
|
Map<String,Object> mapping = getGatewayMapping(gatewayCode);
|
||||||
String msgType = (String) mapping.get("msgType");
|
String msgType = (String) mapping.get(deviceType + "MsgType");
|
||||||
if(map.get("msgType") != null && msgType.equals(map.get("msgType"))){
|
if(map.get("msgType") != null && msgType.equals(map.get("msgType"))){
|
||||||
process((String)mapping.get(deviceType),(String)mapping.get("equipId"),(Map<String,String>)mapping.get(deviceType + "_msg"),(Map<String,Object>)map.get("msg"));
|
process((String)mapping.get(deviceType),(String)mapping.get("equipId"),(Map<String,String>)mapping.get(deviceType + "Params"),(Map<String,Object>)map.get("msg"));
|
||||||
}else{
|
}else{
|
||||||
logger.info("数据未存储!");
|
logger.info("数据未存储!");
|
||||||
}
|
}
|
||||||
@ -136,75 +136,78 @@ public class MyMqttCallback implements MqttCallback {
|
|||||||
private Map<String, Object> getGatewayMapping(String gatewayCode) {
|
private Map<String, Object> getGatewayMapping(String gatewayCode) {
|
||||||
GatewayInfoService gatewayInfoService = SpringUtils.getBean(GatewayInfoService.class);
|
GatewayInfoService gatewayInfoService = SpringUtils.getBean(GatewayInfoService.class);
|
||||||
GatewayInfoDO gatewayInfo = gatewayInfoService.getGatewayInfoByGatewayCode(gatewayCode);
|
GatewayInfoDO gatewayInfo = gatewayInfoService.getGatewayInfoByGatewayCode(gatewayCode);
|
||||||
//TODO 通过网关信息查询采集卡映射和参数映射
|
//通过配置获取
|
||||||
|
Map<String, Object> cardMapping = gatewayInfoService.getGatewayCardAndParamByCatch(gatewayInfo.getGatewayId());
|
||||||
|
cardMapping.put("equipId", gatewayInfo.getEquipId());
|
||||||
|
cardMapping.put("gatewayId", gatewayInfo.getGatewayId());
|
||||||
|
|
||||||
Map<String,Object> cardMapping = new HashMap<>();
|
// Map<String,Object> cardMapping = new HashMap<>();
|
||||||
cardMapping.put("equipId",gatewayInfo.getEquipId());
|
// cardMapping.put("equipId",gatewayInfo.getEquipId());
|
||||||
cardMapping.put("msgType","POST_TELEMETRY_REQUEST");
|
// cardMapping.put("msgType","POST_TELEMETRY_REQUEST");
|
||||||
cardMapping.put("JCka1","gateway_current_data");
|
// cardMapping.put("JCka1","gateway_current_data");
|
||||||
cardMapping.put("JCka2","gateway_hy_data");
|
// cardMapping.put("JCka2","gateway_hy_data");
|
||||||
cardMapping.put("PT100T16","gateway_temp_data");
|
// cardMapping.put("PT100T16","gateway_temp_data");
|
||||||
cardMapping.put("JCZ163R","gateway_aclr_data");
|
// cardMapping.put("JCZ163R","gateway_aclr_data");
|
||||||
cardMapping.put("FANUC","gateway_fanuc_data");
|
// cardMapping.put("FANUC","gateway_fanuc_data");
|
||||||
|
//
|
||||||
|
//
|
||||||
Map<String,String> paramMapping1 = new HashMap<>();
|
// Map<String,String> paramMapping1 = new HashMap<>();
|
||||||
paramMapping1.put("CH0","chip_removal_1");
|
// paramMapping1.put("CH0","chip_removal_1");
|
||||||
paramMapping1.put("Ch1","chip_removal_2");
|
// paramMapping1.put("Ch1","chip_removal_2");
|
||||||
|
//
|
||||||
cardMapping.put("JCka1_msg",paramMapping1);
|
// cardMapping.put("JCka1_msg",paramMapping1);
|
||||||
|
//
|
||||||
Map<String,String> paramMapping2 = new HashMap<>();
|
// Map<String,String> paramMapping2 = new HashMap<>();
|
||||||
paramMapping2.put("CH0","hy_1");
|
// paramMapping2.put("CH0","hy_1");
|
||||||
paramMapping2.put("Ch1","hy_2");
|
// paramMapping2.put("Ch1","hy_2");
|
||||||
paramMapping2.put("Ch2","hy_3");
|
// paramMapping2.put("Ch2","hy_3");
|
||||||
|
//
|
||||||
cardMapping.put("JCka2_msg",paramMapping2);
|
// cardMapping.put("JCka2_msg",paramMapping2);
|
||||||
|
//
|
||||||
Map<String,String> paramMapping3 = new HashMap<>();
|
// Map<String,String> paramMapping3 = new HashMap<>();
|
||||||
paramMapping3.put("T1","zn_temp");
|
// paramMapping3.put("T1","zn_temp");
|
||||||
paramMapping3.put("T2","z0_temp");
|
// paramMapping3.put("T2","z0_temp");
|
||||||
paramMapping3.put("T3","zp_temp");
|
// paramMapping3.put("T3","zp_temp");
|
||||||
paramMapping3.put("T4","cr1_temp");
|
// paramMapping3.put("T4","cr1_temp");
|
||||||
paramMapping3.put("T5","cr2_temp");
|
// paramMapping3.put("T5","cr2_temp");
|
||||||
paramMapping3.put("T6","xn_temp");
|
// paramMapping3.put("T6","xn_temp");
|
||||||
paramMapping3.put("T7","x0_temp");
|
// paramMapping3.put("T7","x0_temp");
|
||||||
paramMapping3.put("T8","xp_temp");
|
// paramMapping3.put("T8","xp_temp");
|
||||||
paramMapping3.put("T9","yn_temp");
|
// paramMapping3.put("T9","yn_temp");
|
||||||
paramMapping3.put("T10","y0_temp");
|
// paramMapping3.put("T10","y0_temp");
|
||||||
paramMapping3.put("T11","yp_temp");
|
// paramMapping3.put("T11","yp_temp");
|
||||||
|
//
|
||||||
cardMapping.put("PT100T16_msg",paramMapping3);
|
// cardMapping.put("PT100T16_msg",paramMapping3);
|
||||||
|
//
|
||||||
Map<String,String> paramMapping4 = new HashMap<>();
|
// Map<String,String> paramMapping4 = new HashMap<>();
|
||||||
paramMapping4.put("XaR","x_aclr_rms");
|
// paramMapping4.put("XaR","x_aclr_rms");
|
||||||
paramMapping4.put("YaR","y_aclr_rms");
|
// paramMapping4.put("YaR","y_aclr_rms");
|
||||||
paramMapping4.put("ZaR","z_aclr_rms");
|
// paramMapping4.put("ZaR","z_aclr_rms");
|
||||||
paramMapping4.put("XvR","x_speed_rms");
|
// paramMapping4.put("XvR","x_speed_rms");
|
||||||
paramMapping4.put("YvR","y_speed_rms");
|
// paramMapping4.put("YvR","y_speed_rms");
|
||||||
paramMapping4.put("ZvR","z_speed_rms");
|
// paramMapping4.put("ZvR","z_speed_rms");
|
||||||
paramMapping4.put("XdR","x_dis_rms");
|
// paramMapping4.put("XdR","x_dis_rms");
|
||||||
paramMapping4.put("YdR","y_dis_rms");
|
// paramMapping4.put("YdR","y_dis_rms");
|
||||||
paramMapping4.put("ZdR","z_dis_rms");
|
// paramMapping4.put("ZdR","z_dis_rms");
|
||||||
paramMapping4.put("XaP","x_aclr_peak");
|
// paramMapping4.put("XaP","x_aclr_peak");
|
||||||
paramMapping4.put("YaP","y_aclr_peak");
|
// paramMapping4.put("YaP","y_aclr_peak");
|
||||||
paramMapping4.put("ZaP","z_aclr_peak");
|
// paramMapping4.put("ZaP","z_aclr_peak");
|
||||||
paramMapping4.put("XvP","x_speed_peak");
|
// paramMapping4.put("XvP","x_speed_peak");
|
||||||
paramMapping4.put("YvP","y_speed_peak");
|
// paramMapping4.put("YvP","y_speed_peak");
|
||||||
paramMapping4.put("ZvP","z_speed_peak");
|
// paramMapping4.put("ZvP","z_speed_peak");
|
||||||
paramMapping4.put("XdPP","x_dis_peak");
|
// paramMapping4.put("XdPP","x_dis_peak");
|
||||||
paramMapping4.put("YdPP","y_dis_peak");
|
// paramMapping4.put("YdPP","y_dis_peak");
|
||||||
paramMapping4.put("ZdPP","z_dis_peak");
|
// paramMapping4.put("ZdPP","z_dis_peak");
|
||||||
|
//
|
||||||
cardMapping.put("JCZ163R_msg",paramMapping4);
|
// cardMapping.put("JCZ163R_msg",paramMapping4);
|
||||||
|
//
|
||||||
Map<String,String> paramMapping5 = new HashMap<>();
|
// Map<String,String> paramMapping5 = new HashMap<>();
|
||||||
paramMapping5.put("WorkTime","work_time");
|
// paramMapping5.put("WorkTime","work_time");
|
||||||
paramMapping5.put("PowerTime","power_time");
|
// paramMapping5.put("PowerTime","power_time");
|
||||||
paramMapping5.put("TotalProcess","total_process");
|
// paramMapping5.put("TotalProcess","total_process");
|
||||||
paramMapping5.put("ProcessNum","process_num");
|
// paramMapping5.put("ProcessNum","process_num");
|
||||||
|
//
|
||||||
cardMapping.put("FANUC_msg",paramMapping5);
|
// cardMapping.put("FANUC_msg",paramMapping5);
|
||||||
|
|
||||||
return cardMapping;
|
return cardMapping;
|
||||||
}
|
}
|
||||||
|
@ -23,45 +23,45 @@ public class DataProducerTask implements ApplicationRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
Timer timer1 = new Timer();
|
// Timer timer1 = new Timer();
|
||||||
timer1.schedule(new TimerTask() {
|
// timer1.schedule(new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
threadPoolTaskExecutor.execute(new Channel1DataProcess());
|
// threadPoolTaskExecutor.execute(new Channel1DataProcess());
|
||||||
}
|
// }
|
||||||
},1000,10000);
|
// },1000,10000);
|
||||||
|
//
|
||||||
Timer timer2 = new Timer();
|
// Timer timer2 = new Timer();
|
||||||
timer2.schedule(new TimerTask() {
|
// timer2.schedule(new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
threadPoolTaskExecutor.execute(new Channel2DataProcess());
|
// threadPoolTaskExecutor.execute(new Channel2DataProcess());
|
||||||
}
|
// }
|
||||||
},5000,10000);
|
// },5000,10000);
|
||||||
|
//
|
||||||
Timer timer3 = new Timer();
|
// Timer timer3 = new Timer();
|
||||||
timer3.schedule(new TimerTask() {
|
// timer3.schedule(new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
threadPoolTaskExecutor.execute(new Channel3DataProcess());
|
// threadPoolTaskExecutor.execute(new Channel3DataProcess());
|
||||||
}
|
// }
|
||||||
},10000,10000);
|
// },10000,10000);
|
||||||
|
//
|
||||||
Timer timer4 = new Timer();
|
// Timer timer4 = new Timer();
|
||||||
timer4.schedule(new TimerTask() {
|
// timer4.schedule(new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
threadPoolTaskExecutor.execute(new Channel4DataProcess());
|
// threadPoolTaskExecutor.execute(new Channel4DataProcess());
|
||||||
}
|
// }
|
||||||
},14000,10000);
|
// },14000,10000);
|
||||||
|
//
|
||||||
Timer timer5 = new Timer();
|
// Timer timer5 = new Timer();
|
||||||
timer5.schedule(new TimerTask() {
|
// timer5.schedule(new TimerTask() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
threadPoolTaskExecutor.execute(new Channel5DataProcess());
|
// threadPoolTaskExecutor.execute(new Channel5DataProcess());
|
||||||
}
|
// }
|
||||||
},19000,10000);
|
// },19000,10000);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,8 @@ public interface GatewayCardInfoService {
|
|||||||
*/
|
*/
|
||||||
PageResult<GatewayCardInfoDO> getGatewayCardInfoPage(GatewayCardInfoPageReqVO pageReqVO);
|
PageResult<GatewayCardInfoDO> getGatewayCardInfoPage(GatewayCardInfoPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过网关id获取采集卡列表
|
||||||
|
*/
|
||||||
|
List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId);
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.inspur.module.system.service.gatewayinfo;
|
package com.inspur.module.system.service.gatewayinfo;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -71,4 +72,11 @@ public class GatewayCardInfoServiceImpl implements GatewayCardInfoService {
|
|||||||
return gatewayCardInfoMapper.selectPage(pageReqVO);
|
return gatewayCardInfoMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过网关id获取采集卡列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<GatewayCardInfoDO> getGatewayCardInfoListByGatewayId(String gatewayId){
|
||||||
|
return gatewayCardInfoMapper.selectList(GatewayCardInfoDO::getGatewayId, gatewayId);
|
||||||
|
}
|
||||||
}
|
}
|
@ -66,4 +66,9 @@ public interface GatewayCardParamsService {
|
|||||||
* 根据采集卡id查询参数列表
|
* 根据采集卡id查询参数列表
|
||||||
*/
|
*/
|
||||||
List<GatewayCardParamsDO> getGatewayCardParamsByCardId(String cardId);
|
List<GatewayCardParamsDO> getGatewayCardParamsByCardId(String cardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据网关id查询采集卡参数列表
|
||||||
|
*/
|
||||||
|
List<GatewayCardParamsDO> getGatewayCardParamsByGatewayId(String gatewayId);
|
||||||
}
|
}
|
@ -102,4 +102,11 @@ public class GatewayCardParamsServiceImpl implements GatewayCardParamsService {
|
|||||||
return gatewayCardParamsMapper.selectList(cardId);
|
return gatewayCardParamsMapper.selectList(cardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据网关id查询采集卡参数列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<GatewayCardParamsDO> getGatewayCardParamsByGatewayId(String gatewayId){
|
||||||
|
return gatewayCardParamsMapper.selectList(GatewayCardParamsDO::getGatewayId, gatewayId);
|
||||||
|
}
|
||||||
}
|
}
|
@ -57,4 +57,9 @@ public interface GatewayInfoService {
|
|||||||
* 根据机床网关编号获取机床网关信息
|
* 根据机床网关编号获取机床网关信息
|
||||||
*/
|
*/
|
||||||
GatewayInfoDO getGatewayInfoByGatewayCode(String gatewayCode);
|
GatewayInfoDO getGatewayInfoByGatewayCode(String gatewayCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据网关id获取机床网关网卡信息和参数信息
|
||||||
|
*/
|
||||||
|
Map<String, Object> getGatewayCardAndParamByCatch(String gatewayId);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,12 @@ package com.inspur.module.system.service.gatewayinfo;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.inspur.framework.common.util.json.JsonUtils;
|
||||||
import com.inspur.framework.tenant.core.aop.TenantIgnore;
|
import com.inspur.framework.tenant.core.aop.TenantIgnore;
|
||||||
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO;
|
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO;
|
||||||
|
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardInfoDO;
|
||||||
|
import com.inspur.module.system.dal.dataobject.gatewayinfo.GatewayCardParamsDO;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -36,6 +40,15 @@ public class GatewayInfoServiceImpl implements GatewayInfoService {
|
|||||||
@Resource
|
@Resource
|
||||||
private GatewayInfoMapper gatewayInfoMapper;
|
private GatewayInfoMapper gatewayInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GatewayCardInfoService gatewayCardInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GatewayCardParamsService gatewayCardParamsService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
public String createGatewayInfo(GatewayInfoSaveReqVO createReqVO) {
|
public String createGatewayInfo(GatewayInfoSaveReqVO createReqVO) {
|
||||||
@ -96,4 +109,49 @@ public class GatewayInfoServiceImpl implements GatewayInfoService {
|
|||||||
return gatewayInfoMapper.selectGatewayByGatewayCode(gatewayCode);
|
return gatewayInfoMapper.selectGatewayByGatewayCode(gatewayCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据网关id获取机床网关网卡信息和参数信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@TenantIgnore
|
||||||
|
public Map<String, Object> getGatewayCardAndParamByCatch(String gatewayId){
|
||||||
|
//先从缓存中获取
|
||||||
|
if(Boolean.TRUE.equals(stringRedisTemplate.hasKey("cardmapping_" + gatewayId))){
|
||||||
|
return JsonUtils.parseObject(stringRedisTemplate.opsForValue().get("gateway_" + gatewayId), Map.class);
|
||||||
|
}
|
||||||
|
//获取网卡信息
|
||||||
|
List<GatewayCardInfoDO> cardList = gatewayCardInfoService.getGatewayCardInfoListByGatewayId(gatewayId);
|
||||||
|
//获取参数信息
|
||||||
|
List<GatewayCardParamsDO> paramsList = gatewayCardParamsService.getGatewayCardParamsByCardId(gatewayId);
|
||||||
|
if(cardList.size() == 0 || paramsList.size() == 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = getGatewayCardAndParamMapping(cardList, paramsList);
|
||||||
|
stringRedisTemplate.opsForValue().set("cardmapping_" + gatewayId, JsonUtils.toJsonString(resultMap));
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据采集卡列表和参数列表产生网关卡映射
|
||||||
|
*/
|
||||||
|
private Map<String, Object> getGatewayCardAndParamMapping(List<GatewayCardInfoDO> cardList, List<GatewayCardParamsDO> paramsList){
|
||||||
|
Map<String, Object> cardMap = new HashMap<>();
|
||||||
|
for (GatewayCardInfoDO gatewayCardInfoDO : cardList) {
|
||||||
|
Map<String,String> paramsMap = new HashMap<>();
|
||||||
|
//获取网卡的名称、类型、消息类型
|
||||||
|
//String cardName = gatewayCardInfoDO.getCardName();//对应网关deviceName
|
||||||
|
String cardType = gatewayCardInfoDO.getCardType();//对应网关deviceType
|
||||||
|
String msgType = gatewayCardInfoDO.getMsgType();//对应网关msgType
|
||||||
|
String cardId = gatewayCardInfoDO.getCardId();
|
||||||
|
cardMap.put(cardType, "gateway_" + gatewayCardInfoDO.getCardTableMapping() + "_data");//表名
|
||||||
|
cardMap.put(cardType + "MsgType", msgType);
|
||||||
|
paramsList.stream().filter(params -> params.getCardId().equals(cardId)).forEach(params -> paramsMap.put(params.getChannelName(), params.getParamMappingName()));
|
||||||
|
cardMap.put(cardType + "Params", paramsMap);
|
||||||
|
}
|
||||||
|
return cardMap;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -324,4 +324,5 @@ imt:
|
|||||||
timeOut: 10
|
timeOut: 10
|
||||||
keepAlive: 20
|
keepAlive: 20
|
||||||
Qos: 1
|
Qos: 1
|
||||||
|
start: true
|
||||||
debug: false
|
debug: false
|
BIN
imt-ui/dist.zip
Normal file
BIN
imt-ui/dist.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user