This commit is contained in:
geting 2024-12-05 16:27:30 +08:00
commit 4611011d34
19 changed files with 384 additions and 67 deletions

View File

@ -247,6 +247,7 @@ int main(int argc, char** argv)
i++; uid++;
#endif
snprintf(config.processes[i].name, sizeof(config.processes[i].name), "%s", "本地调试");
config.processes[i].irn = 0;
config.processes[i].state = TRUE;
config.processes[i].time_accept = FALSE;
config.processes[i].proto = PROTOCOL_LOCAL_DEBUG;

View File

@ -2249,6 +2249,7 @@ bool CRYDevice::dealConfigFile(const Json::Value jsonRoot)
}
}
config_config.units[uid].irn = strtoll(id.c_str(), NULL, 10);
config_config.units[uid].value = SPI_ON;
config_config.units[uid].softdog = UNIT_WATCHDOG_TIME;
config_config.units[uid].state = TRUE;
@ -2756,11 +2757,13 @@ void CRYDevice::heart_beat(int status)
payload["status"] = status;
if (status == 1) {
Json::Value jsonItem;
Json::Value jsonLink;
Json::Value jsonDevice;
Json::Value jsonValue;
for (int i = 0; i < PROCESSES_NUM - 1; i++) {
for (int i = 0; i < PROCESSES_NUM; i++) {
if (config.processes[i].state == TRUE) {
char linkId[32];
if (config.processes[i].irn == 0) continue;
#ifdef NOPOLL_64BIT_PLATFORM
snprintf(linkId, sizeof(linkId), "%ld", config.processes[i].irn);
#else
@ -2768,11 +2771,30 @@ void CRYDevice::heart_beat(int status)
#endif
jsonValue["linkId"] = linkId;
jsonValue["online"] = (config.processes[i].softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
jsonItem.append(jsonValue);
jsonLink.append(jsonValue);
}
}
if (jsonItem.size() > 0) {
payload["links"] = jsonItem;
if (jsonLink.size() > 0) {
vLog(LOG_DEBUG, "link is: %d\n", jsonLink.size());
payload["links"] = jsonLink;
}
for (int i = 0; i < UNIT_NUM; i++) {
if (config.units[i].state == TRUE) {
char deviceId[32];
if (config.units[i].irn == 0) continue;
#ifdef NOPOLL_64BIT_PLATFORM
snprintf(deviceId, sizeof(deviceId), "%ld", config.units[i].irn);
#else
snprintf(deviceId, sizeof(deviceId), "%lld", config.units[i].irn);
#endif
jsonValue["deviceId"] = deviceId;
jsonValue["online"] = (config.units[i].softdog >= PROCESS_WATCHDOG_TIME) ? false : true;
jsonDevice.append(jsonValue);
}
}
if (jsonLink.size() > 0) {
vLog(LOG_DEBUG, "device is: %d\n", jsonDevice.size());
payload["devices"] = jsonDevice;
}
}

View File

@ -379,14 +379,14 @@ static void* ryftp_process(void* param)
//获取此协议配置里面的ftp信息
char remote[512];
char name[512];
//char name[512];
//默认参数,或是通过协议配置获取
char user[128] = "administrator";
char password[128] = "123456";
char ipaddress[128] = "127.0.0.1";
char remotePath[128] = "Hard Disk2/data/rtdatalog";
char pathName[128] = "./";
//char pathName[128] = "./";
char processName[128];
snprintf(processName, sizeof(processName), "%s", mbt->GetCurProcessName());
@ -701,7 +701,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
ymcount = GetUnitYMCount(uid);
yxcount = GetUnitYXCount(uid);
vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
//vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
BYTE params[MAX_UNIT_POINT_PARAM_SIZE];
BYTE* pData = params;
@ -720,7 +720,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
if (m_adsDatas[0].adsDataBlocks.find(registerAddr) == m_adsDatas[0].adsDataBlocks.end()) {
m_adsDatas[0].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YC));
} else {
vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
//vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
}
}
else
@ -730,7 +730,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
if (m_adsDatas[1].adsDataBlocks.find(registerAddr) == m_adsDatas[1].adsDataBlocks.end()) {
m_adsDatas[1].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YC));
} else {
vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
//vLog(LOG_WARN, "遥测测点配置了相同的寄存器地址\n");
}
}
}
@ -747,7 +747,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
if (m_adsDatas[0].adsDataBlocks.find(registerAddr) == m_adsDatas[0].adsDataBlocks.end()) {
m_adsDatas[0].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YM));
} else {
vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
//vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
}
}
else
@ -757,7 +757,7 @@ BOOLEAN CHostADSBFProcess::calc(void)
if (m_adsDatas[1].adsDataBlocks.find(registerAddr) == m_adsDatas[1].adsDataBlocks.end()) {
m_adsDatas[1].adsDataBlocks.insert(register2typemap::value_type(registerAddr, REGISTER_DATA_TYPE_YM));
} else {
vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
//vLog(LOG_WARN, "遥脉测点配置了相同的寄存器地址\n");
}
}
}
@ -826,25 +826,12 @@ BOOLEAN CHostADSBFProcess::OnPreCreate(int id)
//SetLocalAmsNetId(AmsNetId(m_localNetId));
try {
SetLocalAddress(AmsNetId(m_localNetId));
//192.168.0.231 addroute --addr=192.168.0.1 --netid=192.168.0.1.1.1 --password=1 --username=guest --routename=Testroute
//AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("guest"), std::string("1"));
//m_remotePort
//m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), AMSPORT_R0_PLC_RTS1};
m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
//if (m_turbine->IsConnected())
{
if (!readDeviceState(*m_turbine))
{
// delete m_turbine;
// m_turbine = NULL;
// m_turbine = new AdsDevice{m_remoteIp, AmsNetId(m_remoteNetId), m_remotePort};
}
}
//readDeviceState(*m_turbine);
} catch (const AdsException& ex) {
vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
vLog(LOG_ERROR, "AdsException message: %s\n", ex.what());
vLog(LOG_DEBUG, "try to add a route to remote device.\n");
AddRemoteRoute(m_remoteIp, m_localNetId, m_localIp, std::string("isoftstone"), std::string("guest"), std::string("1"));
} catch (const std::runtime_error& ex) {
vLog(LOG_ERROR, "%s\n", ex.what());
}
@ -930,8 +917,8 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
}
readRealData();
} catch (const AdsException& ex) {
vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
vLog(LOG_ERROR, "AdsException message: %s\n", ex.what());
//vLog(LOG_ERROR, "Error: %d\n", ex.errorCode);
vLog(LOG_ERROR, "%s AdsException message: %s\n", GetCurProcessName(), ex.what());
} catch (const std::runtime_error& ex) {
vLog(LOG_ERROR, "%s\n", ex.what());
}

View File

@ -406,14 +406,14 @@ static void* ryftp_process(void* param)
//获取此协议配置里面的ftp信息
char remote[512];
char name[512];
//char name[512];
//默认参数,或是通过协议配置获取
char user[128] = "administrator";
char password[128] = "123456";
char ipaddress[128] = "127.0.0.1";
char remotePath[128] = "/data/rtdatalog";
char pathName[128] = "./";
//char pathName[128] = "./";
char processName[128];
snprintf(processName, sizeof(processName), "%s", mbt->GetCurProcessName());
@ -941,7 +941,7 @@ void CHostModbusTcpBFProcess::calc2(void)
ymcount = GetUnitYMCount(uid);
yxcount = GetUnitYXCount(uid);
vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
//vLog(LOG_DEBUG, "unit %d, yc count is: %d, and yx count is: %d\n", uid, yccount, yxcount);
STRUCT_PARAM *ycparam = NULL, *ymparam = NULL, *yxparam = NULL;
if (yccount) ycparam = new STRUCT_PARAM[yccount];

View File

@ -0,0 +1,76 @@
package com.das.modules.calc.functions;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.das.modules.cache.domain.DeviceInfoCache;
import com.das.modules.cache.service.CacheService;
import com.das.modules.data.service.DataService;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.AviatorNil;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.Map;
/**
* Aviator扩展函数 - 获取时间维度内平均
* 函数格式: avg(deviceId, attr, timedim)
* timedim: day - month - year -
* 返回值数值 nil - 获取错误
*/
@Slf4j
public class FunctionAvgValue extends AbstractFunction {
private DataService dataService = null;
private CacheService cacheService = null;
public FunctionAvgValue(DataService dataService, CacheService cacheService) {
this.dataService = dataService;
this.cacheService = cacheService;
}
@Override
public String getName() {
return "avgv";
}
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject deviceCode, AviatorObject attr) {
//设备Code
String code = (String)deviceCode.getValue(env);
String attrName = (String)attr.getValue(env);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code);
if (deviceInfoCache == null) {
return AviatorNil.NIL;
}
Double value = dataService.getTimeAvgValue(deviceInfoCache.getDeviceId(), attrName, null, null);
if (value == null){
return AviatorNil.NIL;
}
//未找到缓存查询时序API获取数据
return AviatorRuntimeJavaType.valueOf(value);
}
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject deviceCode, AviatorObject attr, AviatorObject startTimeData, AviatorObject endTimeData) {
//设备Code
String code = (String)deviceCode.getValue(env);
String attrName = (String)attr.getValue(env);
Date startTime = (Date)startTimeData.getValue(env);
Date endTime = (Date)endTimeData.getValue(env);
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheByCode(code);
if (deviceInfoCache == null) {
return AviatorNil.NIL;
}
Double value = dataService.getTimeSumValue(deviceInfoCache.getDeviceId(), attrName, startTime.getTime(), endTime.getTime());
if (value == null){
return AviatorNil.NIL;
}
//未找到缓存查询时序API获取数据
return AviatorRuntimeJavaType.valueOf(value);
}
}

View File

@ -0,0 +1,60 @@
package com.das.modules.calc.functions;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorRuntimeJavaType;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.Map;
/**
* Aviator扩展函数 - 获取时间维度的起始时间
* 函数格式: beginOf(Date, TimeDim)
*
*/
@Slf4j
public class FunctionOffsetDate extends AbstractFunction {
public FunctionOffsetDate() {
}
@Override
public String getName() {
return "offsetDate";
}
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject dateData, AviatorObject dimData, AviatorObject offsetData) {
Date date = (Date) dateData.getValue(env);
String dim = (String) dimData.getValue(env);
Integer offset = (Integer) offsetData.getValue(env);
Date result = null;
switch (dim) {
case "day":
result = DateUtil.offset(date, DateField.DAY_OF_MONTH, offset);
break;
case "month":
result = DateUtil.offset(date, DateField.MONTH, offset);
break;
case "year":
result = DateUtil.offset(date, DateField.YEAR, offset);
break;
case "hour":
result = DateUtil.offset(date, DateField.HOUR, offset);
break;
case "minute":
result = DateUtil.offset(date, DateField.MINUTE, offset);
break;
case "second":
result = DateUtil.offset(date, DateField.SECOND, offset);
break;
default:
log.error("不支持的维度: {}", dim);
}
return AviatorRuntimeJavaType.valueOf(result);
}
}

View File

@ -128,6 +128,12 @@ public class CalcService {
FunctionEndOfDate endOfDate = new FunctionEndOfDate();
aviator.addFunction(endOfDate);
FunctionAvgValue avgValue = new FunctionAvgValue(dataService, cacheService);
aviator.addFunction(avgValue);
FunctionOffsetDate offsetDate = new FunctionOffsetDate();
aviator.addFunction(offsetDate);
}
/**

View File

@ -17,6 +17,8 @@ public interface DataService {
void updateCalFieldData(List<CalculateRTData> values);
Double getTimeTopValue(Long devcieId, String attr, Long startTime, Long endTime);
Double getTimeSumValue(Long devcieId, String attr, Long startTime, Long endTime);
Double getTimeTopValue(Long deviceId, String attr, Long startTime, Long endTime);
Double getTimeSumValue(Long deviceId, String attr, Long startTime, Long endTime);
Double getTimeAvgValue(Long deviceId, String attrName, Long startTime, Long endTime);
}

View File

@ -905,4 +905,52 @@ public class TDEngineService {
}
return result;
}
public Double getTimeAvgValue(String tableName, String attr, Long startTime, Long endTime) {
StringBuffer sb = new StringBuffer(256);
sb.append("select ");
sb.append("avg(");
sb.append(attr);
sb.append(")");
sb.append(" from ");
sb.append(tableName);
if (startTime != null && endTime != null) {
sb.append(" where ");
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime, endTime));
}
Double result = 0.0;
try (Connection conn = hikariDataSource.getConnection();
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sb.toString())) {
if (rs.next()) {
result = rs.getDouble(1);
}
} catch (Exception e) {
log.error("获取数据异常",e);
}
return result;
}
public Double getTimeAvgCalcValue(String tableName, String attr, Long startTime, Long endTime) {
StringBuffer sb = new StringBuffer(256);
sb.append("select ");
sb.append("avg(datavalue)");
sb.append(" from ");
sb.append(tableName);
if (startTime != null && endTime != null) {
sb.append(" where ");
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime, endTime));
}
Double result = 0.0;
try (Connection conn = hikariDataSource.getConnection();
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sb.toString())) {
if (rs.next()) {
result = rs.getDouble(1);
}
} catch (Exception e) {
log.error("获取数据异常",e);
}
return result;
}
}

View File

@ -268,8 +268,8 @@ public class DataServiceImpl implements DataService {
* @return
*/
@Override
public Double getTimeTopValue(Long devcieId, String attr, Long startTime, Long endTime){
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(devcieId);
public Double getTimeTopValue(Long deviceId, String attr, Long startTime, Long endTime){
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
if (deviceInfoCache == null) {
return null;
}
@ -285,8 +285,8 @@ public class DataServiceImpl implements DataService {
}
@Override
public Double getTimeSumValue(Long devcieId, String attr, Long startTime, Long endTime) {
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(devcieId);
public Double getTimeSumValue(Long deviceId, String attr, Long startTime, Long endTime) {
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
if (deviceInfoCache == null) {
return null;
}
@ -301,4 +301,22 @@ public class DataServiceImpl implements DataService {
}
return tdEngineService.getTimeSumValue(tableName, attr, startTime, endTime);
}
@Override
public Double getTimeAvgValue(Long deviceId, String attr, Long startTime, Long endTime) {
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
if (deviceInfoCache == null) {
return null;
}
String tableName = "";
if (cacheService.getIotModelCache().isCalculate(deviceInfoCache.getIotModelId(), attr)){
tableName = String.format("c_%s_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase());
return tdEngineService.getTimeAvgCalcValue(tableName, attr, startTime, endTime);
} else if (cacheService.getIotModelCache().isHighSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){
tableName = String.format("h_%s", deviceInfoCache.getDeviceId());
} else if (cacheService.getIotModelCache().isLowSpeed(deviceInfoCache.getIotModelId(), attr.toLowerCase())){
tableName = String.format("l_%s", deviceInfoCache.getDeviceId(), attr.toLowerCase());
}
return tdEngineService.getTimeAvgValue(tableName, attr, startTime, endTime);
}
}

View File

@ -19,7 +19,7 @@ public interface SysIotModelMapper extends BaseMapper<SysIotModel> {
List<SysIotModelServiceExcel> queryServiceByModelId(Long id);
Long queryIotModelIdByName(String code);
Long queryIotModelIdByCode(String code);
List<SysIotModelVo> getSysIotModelByType(Integer objectType);

View File

@ -2,12 +2,14 @@ package com.das.modules.equipment.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.das.common.config.SessionUtil;
import com.das.common.constant.EquipmentTypeIds;
import com.das.common.exceptions.ServiceException;
import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.PageDataInfo;
@ -41,6 +43,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.rmi.ServerException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -249,10 +252,19 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
List<SysEquipment> delSysEquipmentList = new ArrayList<>();
// 遍历
for (List<Object> row : list) {
if (ObjectUtil.isAllNotEmpty(row.get(4),row.get(1),row.get(5))){
throw new ServerException("请检查必填参数:"+row);
}
if (!Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG) && !Integer.valueOf(row.get(1).toString()).equals(EquipmentTypeIds.EQUIPMENT_TYPE_WIND_FARM)){
throw new ServerException("设备类型编码错误"+ row.get(1));
}
SysEquipment field = new SysEquipment();
// 根据编码获取物模型id
if (StringUtils.hasText(row.get(2).toString())) {
Long iotModelId = sysIotModelMapper.queryIotModelIdByName(row.get(3).toString());
Long iotModelId = sysIotModelMapper.queryIotModelIdByCode(row.get(2).toString());
if (iotModelId == null){
throw new ServerException("物模型编码错误,错误编码:"+ row.get(2).toString());
}
field.setIotModelId(iotModelId);
}
if (StringUtils.hasText(row.get(13).toString())) {
@ -263,9 +275,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
field.setObjectType(Integer.valueOf(row.get(1).toString()));
field.setCode(row.get(4).toString());
field.setName(row.get(5).toString());
field.setMadeinFactory(row.get(6).toString());
field.setModel(row.get(7).toString());
field.setLocation(row.get(8).toString());
field.setMadeinFactory(ObjectUtil.isEmpty(row.get(6)) ? null : row.get(6).toString());
field.setModel(ObjectUtil.isEmpty(row.get(7)) ? null : row.get(7).toString());
field.setLocation(ObjectUtil.isEmpty(row.get(8)) ? null : row.get(8).toString());
if (StringUtils.hasText(row.get(9).toString())) {
field.setLongitude(Double.valueOf(row.get(9).toString()));
}
@ -276,9 +288,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
if (StringUtils.hasText(row.get(11).toString())) {
field.setInstallDate(sf.parse(row.get(11).toString()));
}
field.setRemarks(row.get(12).toString());
field.setBelongLine(row.get(17).toString());
field.setStandard(Integer.valueOf(row.get(18).toString()));
field.setRemarks(ObjectUtil.isEmpty(row.get(12)) ? null : row.get(12).toString());
field.setBelongLine(ObjectUtil.isEmpty(row.get(17)) ? null : row.get(17).toString());
field.setStandard(ObjectUtil.isEmpty(row.get(18)) ? null : Integer.valueOf(row.get(18).toString()));
if (StringUtils.hasText(row.get(19).toString())) {
field.setNominalCapacity(Double.valueOf(row.get(19).toString()));
}

View File

@ -1,7 +1,10 @@
package com.das.modules.node.command;
import com.das.common.constant.EquipmentTypeIds;
import com.das.common.utils.AdminRedisTemplate;
import com.das.common.utils.StringUtils;
import com.das.modules.cache.domain.DeviceInfoCache;
import com.das.modules.cache.service.CacheService;
import com.das.modules.node.constant.NodeConstant;
import com.das.modules.node.domain.bo.TerminalMessage;
import com.fasterxml.jackson.databind.JsonNode;
@ -17,6 +20,9 @@ public class HeartbeatCommand implements BaseCommand{
@Autowired
AdminRedisTemplate adminRedisTemplate;
@Autowired
CacheService cacheService;
@Override
public void doCommand(TerminalMessage data) {
JsonNode dataInfo = data.getData();
@ -39,6 +45,27 @@ public class HeartbeatCommand implements BaseCommand{
adminRedisTemplate.expire(key, 300L);
}
}
JsonNode devices = data.getData().get("devices");
if (devices != null && devices.isArray()) {
for (JsonNode device : devices) {
Long deviceId = device.get("deviceId").asLong();
Boolean online = device.get("online").asBoolean();
DeviceInfoCache deviceInfoCacheById = cacheService.getEquipmentCache().getDeviceInfoCacheById(deviceId);
if (deviceInfoCacheById == null || !deviceInfoCacheById.getObjectType().equals(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG)) {
continue;
}
//判断是不是风机
String keyPLCDeviceStatus = String.format("RT:%d:iturbineoperationmode", deviceId);
String keyCommFaultState = String.format("RT:%d:commfaultstate");
Integer plcDeviceStatus = adminRedisTemplate.get(keyPLCDeviceStatus);
if (plcDeviceStatus == null){
adminRedisTemplate.set(keyCommFaultState, online ? 0 : 1);
}
else{
adminRedisTemplate.set(keyCommFaultState, online && plcDeviceStatus != 0 ? 0 : 1);
}
}
}
}
}
}

View File

@ -23,25 +23,25 @@ import java.text.ParseException;
public class WindSpeedCorrectController {
@Autowired
private WindSpeedCorrectService sysEquipmentService;
private WindSpeedCorrectService windSpeedCorrectService;
/** 导入 */
@PostMapping("/import")
public R<Void> importWindSpeedCorrect( @RequestParam("file") MultipartFile file) throws IOException, ParseException {
sysEquipmentService.importWindSpeedCorrect( file);
windSpeedCorrectService.importWindSpeedCorrect( file);
return R.success("导入成功");
}
/** 获取风机风速功率修正系数列表 */
@PostMapping("/getList")
public R<PageDataInfo<SysPowerCurveFactorVo>> getList(@RequestBody SysPowerCurveFactorDto dto) {
PageDataInfo<SysPowerCurveFactorVo> list = sysEquipmentService.getList(dto);
PageDataInfo<SysPowerCurveFactorVo> list = windSpeedCorrectService.getList(dto);
return R.success(list);
}
/** 导出 */
@PostMapping("/export")
public void exportWindSpeedCorrect(@RequestBody SysPowerCurveFactorDto dto, HttpServletRequest request, HttpServletResponse response) {
sysEquipmentService.exportWindSpeedCorrect(dto,request, response);
windSpeedCorrectService.exportWindSpeedCorrect(dto,request, response);
}

View File

@ -45,7 +45,7 @@
where sims.iot_model_id = #{id} order by sims.porder asc
</select>
<select id="queryIotModelIdByName" resultType="java.lang.Long">
<select id="queryIotModelIdByCode" resultType="java.lang.Long">
select id from sys_iot_model where iot_model_code = #{code}
</select>

View File

@ -349,7 +349,15 @@ PS: 同一节点只允许建立一条连接。
"linkId": "123",
"online": false
}
]
],
//设备监控信息
"devices": [
{
//设备ID
"deviceId": "1123451235464",
//设备状态
"online": true
}]
}
```

View File

@ -422,10 +422,6 @@ const createScroll = () => {
if (scrollRef.value.clientWidth + scrollRef.value.scrollLeft == scrollRef.value.scrollWidth) {
scrollRef.value.scrollLeft = 0
}
//scrollRef.value.scrollTop += 1
/* if (scrollRef.value.clientHeight + scrollRef.value.scrollTop == scrollRef.value.scrollHeight) {
scrollRef.value.scrollTop = 0
}*/
}, 30);
}
@ -520,7 +516,7 @@ $labelHeight: 30px;
}
.content-number {
color: #333333;
font-size: 28px;
font-size: 24px;
}
.homelabel {
font-family: PingFangSC-Semibold;

View File

@ -118,12 +118,26 @@
<el-row>
<el-col :span="12">
<el-form-item label="生产厂家:">
<el-input v-model="editDeviceData.madeinFactory" placeholder="请输入生产厂家" clearable />
<el-input
:disabled="hasShowSelect"
v-model="editDeviceData.madeinFactory"
:placeholder="hasShowSelect ? '请选择规格型号' : '请输入生产厂家'"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格型号:">
<el-input v-model="editDeviceData.model" style="width: 200px" placeholder="请输入规格型号" clearable />
<el-select
v-if="hasShowSelect"
v-model="editDeviceData.model"
placeholder="请选择规格型号"
style="width: 200px"
@change="selectEditModel"
>
<el-option v-for="item in modelList" :key="item.model" :value="item.model"></el-option>
</el-select>
<el-input v-else v-model="editDeviceData.model" style="width: 200px" placeholder="请输入规格型号" clearable />
</el-form-item>
</el-col>
</el-row>
@ -241,7 +255,7 @@
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="saveData">保存</el-button>
<el-button @click="editDeviceDialog = false">取消</el-button>
<el-button @click="editDeviceDialog = false">取消</el-button>
</div>
</template>
</el-dialog>
@ -284,12 +298,26 @@
<el-row>
<el-col :span="12">
<el-form-item label="生产厂家:">
<el-input v-model="editAddDeviceData.madeinFactory" placeholder="请输入生产厂家" clearable />
<el-input
:disabled="hasShowSelect"
v-model="editAddDeviceData.madeinFactory"
:placeholder="hasShowSelect ? '请选择规格型号' : '请输入生产厂家'"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格型号:">
<el-input v-model="editAddDeviceData.model" style="width: 200px" placeholder="请输入规格型号" clearable />
<el-select
v-if="hasShowSelect"
v-model="editAddDeviceData.model"
placeholder="请选择规格型号"
style="width: 200px"
@change="selectAddModel"
>
<el-option v-for="item in modelList" :key="item.model" :value="item.model"></el-option>
</el-select>
<el-input v-else v-model="editAddDeviceData.model" placeholder="请输入规格型号" style="width: 200px"></el-input>
</el-form-item>
</el-col>
</el-row>
@ -412,7 +440,7 @@
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="saveAddData">保存</el-button>
<el-button @click="editAddDeviceDialog = false">取消</el-button>
<el-button @click="editAddDeviceDialog = false">取消</el-button>
</div>
</template>
</el-dialog>
@ -466,7 +494,7 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, nextTick, watch } from 'vue'
import { ref, reactive, computed, onMounted, nextTick, watch } from 'vue'
import { Search, CirclePlusFilled, Upload, Download } from '@element-plus/icons-vue'
import {
equipTree,
@ -486,6 +514,7 @@ import { encrypt_aes, generateRandomNumber } from '/@/utils/crypto'
import ControlPage from './control.vue'
import MeasurementPage from './measurement.vue'
import { ModelAttributeType } from '/@/views/backend/auth/model/type'
import { theoreticalpowerCurveList } from '/@/api/backend/theoreticalpowerCurve/request'
const adminInfo = useAdminInfo()
interface Tree {
@ -728,6 +757,31 @@ const editDeviceData = reactive({
nominalCapacity: null,
})
const hasShowSelect = computed(() => {
return queryParameter.value.equipmentTypeId === 10002
})
const modelList = ref<{ model: string; madeinFactory: string }[]>([])
const getModelList = () => {
theoreticalpowerCurveList().then((res) => {
if (res.rows) {
console.log(res)
modelList.value = (res.rows as any[]).map((item: any) => {
return {
model: item.model,
madeinFactory: item.madeinfactory,
}
})
}
})
}
const selectEditModel = (value: string) => {
editDeviceData.madeinFactory = modelList.value.find((item) => item.model == value)?.madeinFactory || ''
}
const selectAddModel = (value: string) => {
editAddDeviceData.madeinFactory = modelList.value.find((item) => item.model == value)?.madeinFactory || ''
}
const size = ref<'default' | 'large' | 'small'>('default')
const handleCloseEditDevice = () => {
@ -1026,6 +1080,8 @@ const openMeasure = (data: any) => {
watch(showMeasure, (newVal: boolean) => {
!newVal && (measureData.autoUpdate = false)
})
getModelList()
</script>
<style scoped lang="scss">

View File

@ -323,8 +323,6 @@ const pageSetting = reactive({
const changePageSetting = () => {}
const getListForAirBlower = () => {
console.log(activeName.value)
const data = {
deviceCode: curTreeData.value.code,
startTime: dayjs(searchData.date[0]).format('YYYY-MM'),