This commit is contained in:
zhouhuang 2024-12-24 11:37:29 +08:00
commit 7731f67041
191 changed files with 6257 additions and 2824 deletions

View File

@ -1,33 +0,0 @@
package com.das.common.log;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import java.util.concurrent.Executor;
/**
* @author chenhaojie
*
*/
@Slf4j
public class MdcExecutor implements Executor {
private final Executor executor;
public MdcExecutor(Executor executor) {
this.executor = executor;
}
@Override
public void execute(Runnable command) {
final String requestId = MDC.get("REQUEST_ID");
executor.execute(() -> {
MDC.put("REQUEST_ID", requestId);
try {
command.run();
} finally {
MDC.remove("REQUEST_ID");
}
});
}
}

View File

@ -1,32 +0,0 @@
package com.das.common.log;
import java.util.UUID;
/**
* @author chenhaojie
*
*/
public class RequestIdUtils {
private static final ThreadLocal<UUID> requestIdHolder = new ThreadLocal<>();
private RequestIdUtils() {
}
public static void generateRequestId() {
requestIdHolder.set(UUID.randomUUID());
}
public static void generateRequestId(UUID uuid) {
requestIdHolder.set(uuid);
}
public static UUID getRequestId() {
return requestIdHolder.get();
}
public static void removeRequestId() {
requestIdHolder.remove();
}
}

View File

@ -1,74 +0,0 @@
package com.das.common.log;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import java.util.UUID;
/**
* @author chenhaojie
*
*/
@Slf4j
public class RequestLogInterceptor implements HandlerInterceptor {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
String servletPath = request.getServletPath();
log.info("preHandle 后置处理----------");
log.info("servletPath:{}", servletPath);
RequestIdUtils.removeRequestId();
MDC.clear();
}
/**
* 获取RequestId
* 优先从header头获取如果没有则自己生成
* @return RequestId
*/
private String getRequestId(){
// 因为如果有网关则一般会从网关传递过来所以优先从header头获取
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if(attributes != null && StringUtils.hasText(attributes.getRequest().getHeader("x-request-id"))) {
HttpServletRequest request = attributes.getRequest();
String requestId = request.getHeader("x-request-id");
UUID uuid = UUID.fromString(requestId);
RequestIdUtils.generateRequestId(uuid);
return requestId;
}
UUID existUUID = RequestIdUtils.getRequestId();
if(existUUID != null){
return existUUID.toString();
}
RequestIdUtils.generateRequestId();
return RequestIdUtils.getRequestId().toString();
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
String servletPath = request.getServletPath();
// 生成RequestId
String requestId = this.getRequestId();
// 配置日志文件打印 REQUEST_ID
MDC.put("REQUEST_ID", requestId);
log.info("servletPath:{}", servletPath);
log.info("preHandle 前置处理----------");
return true;
}
}

View File

@ -1,5 +1,6 @@
package com.das.modules.cache.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
/**
@ -32,4 +33,14 @@ public class DeviceInfoCache {
* 物模型ID
*/
private Long iotModelId;
/**
* 制造商
*/
private String madeinFactory;
/**
* 型号规格
*/
private String model;
}

View File

@ -40,6 +40,8 @@ public class EquipmentCacheImpl implements EquipmentCache {
deviceInfoCache.setDeviceCode(equipment.getCode());
deviceInfoCache.setDeviceName(equipment.getName());
deviceInfoCache.setObjectType(equipment.getObjectType());
deviceInfoCache.setModel(equipment.getModel());
deviceInfoCache.setMadeinFactory(equipment.getMadeinFactory());
deviceInfoCache.setParentDeviceId(equipment.getParentEquipmentId());
deviceInfoCache.setIotModelId(equipment.getIotModelId());
deviceInfoCaches.add(deviceInfoCache);
@ -75,6 +77,8 @@ public class EquipmentCacheImpl implements EquipmentCache {
if (equipment != null) {
DeviceInfoCache deviceInfoCache = new DeviceInfoCache();
deviceInfoCache.setDeviceId(equipment.getId());
deviceInfoCache.setMadeinFactory(equipment.getMadeinFactory());
deviceInfoCache.setModel(equipment.getModel());
deviceInfoCache.setDeviceCode(equipment.getCode());
deviceInfoCache.setDeviceName(equipment.getName());
deviceInfoCache.setObjectType(equipment.getObjectType());

View File

@ -45,7 +45,8 @@ public class IotModelCacheImpl implements IotModelCache {
@PreDestroy
public void destroy(){
iotFieldsMap.clear();
iotModelInfoIdMap.clear();
}
@Override

View File

@ -26,7 +26,7 @@ public class CalcModule {
private Date updateTime;
private String cron;
public static final CalcModule of(String content){
public static CalcModule of(String content){
CalcModule calcModule = new CalcModule();
calcModule.setScript(content);
try(BufferedReader reader = new BufferedReader(new StringReader(content))){

View File

@ -23,12 +23,10 @@ import java.util.Map;
@Slf4j
public class FunctionWindSpeedFactor extends AbstractFunction {
private DataService dataService = null;
private CacheService cacheService = null;
public FunctionWindSpeedFactor(DataService dataService, CacheService cacheService) {
this.dataService = dataService;
public FunctionWindSpeedFactor(CacheService cacheService) {
this.cacheService = cacheService;
}

View File

@ -136,7 +136,7 @@ public class CalcService {
FunctionOffsetDate offsetDate = new FunctionOffsetDate();
aviator.addFunction(offsetDate);
FunctionWindSpeedFactor windSpeedFactor = new FunctionWindSpeedFactor(dataService,cacheService);
FunctionWindSpeedFactor windSpeedFactor = new FunctionWindSpeedFactor(cacheService);
aviator.addFunction(windSpeedFactor);
FunctionIsOnline isOnline = new FunctionIsOnline(adminRedisTemplate, cacheService);

View File

@ -4,6 +4,7 @@ import com.das.common.result.R;
import com.das.common.utils.JsonUtils;
import com.das.modules.data.domain.SnapshotValueQueryParam;
import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.data.domain.WindowValueQueryParam;
import com.das.modules.data.service.DataService;
import com.das.modules.data.service.impl.DataServiceImpl;
import jakarta.validation.Valid;
@ -36,7 +37,8 @@ public class DataController {
@PostMapping("/snapshot")
public R<Map<String,Map<String,Object>>> querySnapshotValues(@RequestBody @Valid List<SnapshotValueQueryParam> param) {
if (log.isDebugEnabled()){
log.debug("/api/rtdbsvr/snapshot is calling");
log.debug("/api/data/snapshot is calling");
log.debug("request params: {}", param);
}
return R.success(dataService.querySnapshotValues(param));
}
@ -49,8 +51,23 @@ public class DataController {
@PostMapping("/history")
public R<Map<String, Map<String, Map<String, Object>>>> queryTimeSeriesValues(@RequestBody @Valid TSValueQueryParam param) {
if (log.isDebugEnabled()){
log.debug("/api/rtdbsvr/timeseries is calling");
log.debug("/api/data/history is calling");
log.debug("request params: {}", param);
}
return R.success(dataService.queryTimeSeriesValues(param));
}
/**
* 区间聚合函数
* @param param 查询条件
* @return TD数据库数据
*/
@PostMapping("/windows")
public R<Map<String, Map<String, Map<String, Object>>>> queryWindowsValues(@RequestBody @Valid WindowValueQueryParam param) {
if (log.isDebugEnabled()){
log.debug("/api/data/windows is calling");
log.debug("request params: {}", param);
}
return R.success(dataService.queryWindowsValues(param));
}
}

View File

@ -30,4 +30,10 @@ public class DeviceEventInfo {
private String deviceCode;
private String deviceName;
private String model;
private String madeinFactory;
private Integer firstTriggeredCode;
}

View File

@ -0,0 +1,34 @@
package com.das.modules.data.domain;
import lombok.Data;
import java.util.List;
/**
* 时序数据查询实体
*/
@Data
public class WindowValueQueryParam
{
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
/**
* 间隔
*/
private String interval;
/**
* 设备属性列表
*/
private List<SnapshotValueQueryParam> devices;
private String calFunction;
}

View File

@ -2,6 +2,7 @@ package com.das.modules.data.service;
import com.das.modules.data.domain.SnapshotValueQueryParam;
import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.data.domain.WindowValueQueryParam;
import com.das.modules.node.domain.bo.CalculateRTData;
import java.util.List;
@ -13,6 +14,8 @@ public interface DataService {
Map<String, Map<String, Map<String, Object>>> queryTimeSeriesValues(TSValueQueryParam param);
Map<String, Map<String, Map<String, Object>>> queryWindowsValues(WindowValueQueryParam param);
void createTdStable();
void updateCalFieldData(List<CalculateRTData> values);

View File

@ -1,8 +1,11 @@
package com.das.modules.data.service;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.das.common.utils.PageDataInfo;
import com.das.modules.cache.domain.DeviceInfoCache;
import com.das.modules.cache.service.CacheService;
import com.das.modules.data.domain.DeviceEventInfo;
import com.das.modules.data.domain.RTValue;
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
@ -12,6 +15,7 @@ import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
@ -45,6 +49,8 @@ public class TDEngineService {
@Value("${tdengine.batch-size:10000}")
private int batchSize;
@Autowired
private CacheService cacheService;
public void init() {
if (hikariDataSource == null) {
HikariConfig config = new HikariConfig();
@ -86,7 +92,7 @@ public class TDEngineService {
log.info(sb.toString());
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("创建超级表失败,失败原因{}", e);
log.error("创建超级表失败", e);
}
}
} catch (Exception ignored) {
@ -108,7 +114,7 @@ public class TDEngineService {
log.info(sb.toString());
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("创建超级表失败,失败原因{}", e);
log.error("创建[计算量]超级表失败", e);
}
} catch (Exception ignored) {
@ -135,7 +141,7 @@ public class TDEngineService {
try {
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("新增超级表列失败:{},失败原因{}", sb, e);
log.error(String.format("新增超级表列失败:%s", sb.toString()), e);
}
}
@ -161,7 +167,7 @@ public class TDEngineService {
try {
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("删除超级表列失败:{},失败原因{}", sb, e);
log.error(String.format("删除超级表列失败:%s", sb.toString()), e);
}
} catch (Exception ignored) {
@ -183,7 +189,7 @@ public class TDEngineService {
try {
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("删除超级表失败:{},失败原因{}", sb, e);
log.error(String.format("删除超级表失败:%s", sb.toString()), e);
}
} catch (Exception ignored) {
@ -256,7 +262,7 @@ public class TDEngineService {
});
//初始化event_info
String eventInfo = "create stable IF NOT EXISTS event_info (event_time timestamp,event_id bigint primary key,attributecode varchar(64),event_type tinyint,event_level tinyint,event_text varchar(256),confirmed tinyint,confirm_account varchar(32),confirm_time timestamp) tags (device_id bigint,device_code varchar(64),device_name varchar(192))";
String eventInfo = "create stable IF NOT EXISTS event_info (event_time timestamp,event_id bigint primary key,attributecode varchar(64),event_type tinyint,event_level tinyint,event_text varchar(256),confirmed tinyint,confirm_account varchar(32),confirm_time timestamp,first_triggered_code INTEGER) tags (device_id bigint,device_code varchar(64),device_name varchar(192))";
try {
pstmt.executeUpdate(eventInfo);
} catch (SQLException ex) {
@ -414,6 +420,8 @@ public class TDEngineService {
sb.append(dv.getConfirmAccount());
sb.append(",");
sb.append(dv.getConfirmTime());
sb.append(",");
sb.append(dv.getFirstTriggeredCode());
sb.append(")");
}
try {
@ -506,6 +514,188 @@ public class TDEngineService {
return result;
}
public Map<String, Map<String, Map<String, Object>>> fetchHighWindowsCurve(Long irn, Date startTime, Date endTime, String interval, List<String> fieldList,String calFunction) {
String tbName = String.format("h%d", irn);
Date now = new Date();
if (endTime.after(now)) {
endTime = now;
}
Map<String, Map<String, Map<String, Object>>> result = new HashMap<>();
Map<String, Map<String, Object>> valueMap = new HashMap<>();
for (String item : fieldList) {
Map<String, Object> timeValueMap = new HashMap<>();
List<Long> times = new ArrayList<>();
List<Object> objects = new ArrayList<>();
timeValueMap.put("times", times);
timeValueMap.put("values", objects);
valueMap.put(item, timeValueMap);
}
StringBuffer sb = new StringBuffer(2048);
if (!(StrUtil.isNotBlank(interval) && interval.equals("NONE"))) {
String intervalStr = convertInterval(interval);
sb.append("select _WSTART, _WEND");
fieldList.forEach(field ->
sb.append(" ,").append(calFunction).append("(").append(field).append(") ").append("as ").append(field)
);
sb.append(" from ");
sb.append(tbName);
sb.append(" where ");
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime.getTime(), endTime.getTime()));
sb.append(String.format(" INTERVAL(%s)", intervalStr));
sb.append(String.format(" FILL(%s)", "NONE"));
}
log.debug(sb.toString());
try (Connection conn = hikariDataSource.getConnection();
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sb.toString())) {
while (rs.next()) {
for (int i = 0; i < fieldList.size(); i++) {
if (valueMap.get(fieldList.get(i)) == null) {
Map<String, Object> map = new HashMap<>();
List<Long> timeList = new ArrayList<>();
timeList.add(rs.getTimestamp(1).getTime());
List<Object> valueList = new ArrayList<>();
valueList.add(rs.getObject(fieldList.get(i).toLowerCase()));
map.put("times", timeList);
map.put("values", valueList);
valueMap.put(fieldList.get(i), map);
} else {
Map<String, Object> map = valueMap.get(fieldList.get(i));
List<Long> times = (List<Long>) map.get("times");
List<Object> values = (List<Object>) map.get("values");
times.add(rs.getTimestamp(1).getTime());
values.add(rs.getObject(fieldList.get(i).toLowerCase()));
}
}
}
result.put(irn.toString(), valueMap);
} catch (Exception e) {
log.error("获取数据异常", e);
return result;
}
return result;
}
public Map<String, Map<String, Map<String, Object>>> fetchLowWindowsCurve(Long irn, Date startTime, Date endTime, String interval, List<String> fieldList,String calFunction) {
String tbName = String.format("l%d", irn);
Date now = new Date();
if (endTime.after(now)) {
endTime = now;
}
Map<String, Map<String, Map<String, Object>>> result = new HashMap<>();
Map<String, Map<String, Object>> valueMap = new HashMap<>();
for (String item : fieldList) {
Map<String, Object> timeValueMap = new HashMap<>();
List<Long> times = new ArrayList<>();
List<Object> objects = new ArrayList<>();
timeValueMap.put("times", times);
timeValueMap.put("values", objects);
valueMap.put(item, timeValueMap);
}
StringBuffer sb = new StringBuffer(2048);
if (!(StrUtil.isNotBlank(interval) && interval.equals("NONE"))) {
String intervalStr = convertInterval(interval);
sb.append("select _WSTART, _WEND");
fieldList.forEach(field ->
sb.append(" ,").append(calFunction).append("(").append(field).append(") ").append("as ").append(field)
);
sb.append(" from ");
sb.append(tbName);
sb.append(" where ");
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime.getTime(), endTime.getTime()));
sb.append(String.format(" INTERVAL(%s)", intervalStr));
sb.append(String.format(" FILL(%s)", "NONE"));
}
log.debug(sb.toString());
try (Connection conn = hikariDataSource.getConnection();
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sb.toString())) {
while (rs.next()) {
for (int i = 0; i < fieldList.size(); i++) {
if (valueMap.get(fieldList.get(i)) == null) {
Map<String, Object> map = new HashMap<>();
List<Long> timeList = new ArrayList<>();
timeList.add(rs.getTimestamp(1).getTime());
List<Object> valueList = new ArrayList<>();
valueList.add(rs.getObject(fieldList.get(i).toLowerCase()));
map.put("times", timeList);
map.put("values", valueList);
valueMap.put(fieldList.get(i), map);
} else {
Map<String, Object> map = valueMap.get(fieldList.get(i));
List<Long> times = (List<Long>) map.get("times");
List<Object> values = (List<Object>) map.get("values");
times.add(rs.getTimestamp(1).getTime());
values.add(rs.getObject(fieldList.get(i).toLowerCase()));
}
}
}
result.put(irn.toString(), valueMap);
} catch (Exception e) {
log.error("获取数据异常", e);
return result;
}
return result;
}
public Map<String, Map<String, Map<String, Object>>> fetchCalWindowsCurve(Long irn, Date startTime, Date endTime, String interval, String calFieldCode,String calFunction) {
Date now = new Date();
if (endTime.after(now)) {
endTime = now;
}
Map<String, Map<String, Map<String, Object>>> result = new HashMap<>();
Map<String, Map<String, Object>> valueMap = new HashMap<>();
Map<String, Object> timeValueMap = new HashMap<>();
List<Long> times = new ArrayList<>();
List<Object> objects = new ArrayList<>();
timeValueMap.put("times", times);
timeValueMap.put("values", objects);
valueMap.put(calFieldCode, timeValueMap);
StringBuffer sb = new StringBuffer(2048);
if (!(StrUtil.isNotBlank(interval) && interval.equals("NONE"))) {
sb.append("select _WSTART, _WEND,");
sb.append(calFunction).append("(datavalue) as datavalue");
sb.append(" from c_");
sb.append(irn).append("_").append(calFieldCode);
sb.append(" where ");
sb.append(String.format(" updatetime >= %d and updatetime < %d ", startTime.getTime(), endTime.getTime()));
sb.append(String.format(" INTERVAL(%s)", interval));
sb.append(String.format(" FILL(%s)", "NONE"));
}
log.debug(sb.toString());
try (Connection conn = hikariDataSource.getConnection();
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sb.toString())) {
while (rs.next()) {
if (valueMap.get(calFieldCode) == null) {
Map<String, Object> map = new HashMap<>();
List<Long> timeList = new ArrayList<>();
timeList.add(rs.getTimestamp(1).getTime());
List<Object> valueList = new ArrayList<>();
valueList.add(rs.getObject("datavalue"));
map.put("times", timeList);
map.put("values", valueList);
valueMap.put(calFieldCode, map);
} else {
Map<String, Object> map = valueMap.get(calFieldCode);
List<Long> timeList = (List<Long>) map.get("times");
List<Object> values = (List<Object>) map.get("values");
timeList.add(rs.getTimestamp(1).getTime());
values.add(rs.getObject("datavalue"));
}
}
result.put(irn.toString(), valueMap);
} catch (Exception e) {
log.error("获取数据异常", e);
return result;
}
return result;
}
public Map<String, Map<String, Map<String, Object>>> fetchLowHistoryCurve(Long irn, Date startTime, Date endTime, String interval, List<String> fieldList) {
SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String tbName = String.format("l%d", irn);
@ -614,7 +804,6 @@ public class TDEngineService {
sb.append(" order by updatetime");
} else {
sb.append("select updatetime, datavalue");
sb.append(" from ");
sb.append(" from c_");
sb.append(irn).append("_").append(calFieldCode);
sb.append(" where ");
@ -652,7 +841,7 @@ public class TDEngineService {
return result;
}
public PageDataInfo<DeviceEventInfo> queryEvent(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList, Integer pageSize, Integer offset, Integer limit) {
public PageDataInfo<DeviceEventInfo> queryEvent(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList, Integer pageSize, Integer offset, Integer limit,Integer firstTriggeredCode) {
List<DeviceEventInfo> result = new ArrayList<>();
StringBuffer sb = new StringBuffer(2048);
Integer total = 0;
@ -661,6 +850,9 @@ public class TDEngineService {
if (eventLevel != null) {
sb.append(String.format(" and t.event_level = %d", eventLevel));
}
if (firstTriggeredCode != null){
sb.append(String.format(" and t.first_triggered_code = %d", firstTriggeredCode));
}
if (!CollectionUtils.isEmpty(deviceCodeList)) {
sb.append(" and t.device_code in (");
for (int i = 0; i < deviceCodeList.size(); i++) {
@ -683,7 +875,7 @@ public class TDEngineService {
}
if (pageSize != null) {
sb.append(" desc limit ").append(offset).append(",").append(pageSize);
total = getEventCount(eventLevel, startTime, endTime, deviceCodeList);
total = getEventCount(eventLevel, startTime, endTime, deviceCodeList,firstTriggeredCode);
}
log.debug(sb.toString());
@ -703,7 +895,11 @@ public class TDEngineService {
deviceEventInfo.setConfirmTime(rs.getLong("confirm_time"));
deviceEventInfo.setDeviceCode(rs.getString("device_code"));
deviceEventInfo.setDeviceId(rs.getString("device_id"));
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(rs.getLong("device_id"));
deviceEventInfo.setDeviceName(rs.getString("device_name"));
deviceEventInfo.setFirstTriggeredCode(ObjectUtil.isEmpty(rs.getString("first_triggered_code")) ? null : Integer.valueOf(rs.getString("first_triggered_code")));
deviceEventInfo.setMadeinFactory(deviceInfoCache.getMadeinFactory());
deviceEventInfo.setModel(deviceInfoCache.getModel());
result.add(deviceEventInfo);
}
} catch (Exception e) {
@ -713,13 +909,16 @@ public class TDEngineService {
return PageDataInfo.build(result, total);
}
private Integer getEventCount(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList) {
private Integer getEventCount(Integer eventLevel, Long startTime, Long endTime, List<String> deviceCodeList,Integer firstTriggeredCode) {
StringBuffer sb = new StringBuffer(2048);
sb.append("select count(t.*) as total from event_info t where ");
sb.append(String.format(" t.event_time >= %d and t.event_time < %d", startTime, endTime));
if (eventLevel != null) {
sb.append(String.format(" and t.event_level = %d", eventLevel));
}
if (firstTriggeredCode != null){
sb.append(String.format(" and t.first_triggered_code = %d", firstTriggeredCode));
}
if (!CollectionUtils.isEmpty(deviceCodeList)) {
sb.append(" and t.device_code in (");
for (int i = 0; i < deviceCodeList.size(); i++) {
@ -764,7 +963,7 @@ public class TDEngineService {
Statement pstmt = conn.createStatement()) {
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("新增超级表列失败:{},失败原因{}", sb, e);
log.error(String.format("新增超级表列失败:%s", sb.toString()), e);
}
}

View File

@ -4,10 +4,12 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.das.common.exceptions.ServiceException;
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.data.domain.SnapshotValueQueryParam;
import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.data.domain.WindowValueQueryParam;
import com.das.modules.data.service.DataService;
import com.das.modules.data.service.TDEngineService;
import com.das.modules.equipment.domain.vo.IotModelFieldVo;
@ -121,7 +123,7 @@ public class DataServiceImpl implements DataService {
}
});
long end = System.currentTimeMillis();
log.debug("读取快照{}个,耗时: {}秒", paramList.size(), (end - start) / 1000.0);
log.debug("querySnapshotValues {}个,耗时: {}秒", paramList.size(), (end - start) / 1000.0);
return result;
}
@ -147,7 +149,36 @@ public class DataServiceImpl implements DataService {
result.putAll(values);
}
Long end = System.currentTimeMillis();
log.debug("读取快照{}个,耗时: {}秒", param.getDevices().size(), (end-start)/ 1000.0);
log.debug("queryTimeSeriesValues {}个,耗时: {}秒", param.getDevices().size(), (end-start)/ 1000.0);
return result;
}
@Override
public Map<String, Map<String, Map<String, Object>>> queryWindowsValues(WindowValueQueryParam param) {
Long start = System.currentTimeMillis();
if (CollectionUtil.isEmpty(param.getDevices()) || (param.getStartTime() == null && param.getEndTime() == null && param.getCalFunction() == null)) {
throw new ServiceException("必要参数缺失");
}
Date startTime = new Date(Long.parseLong(param.getStartTime()));
Date endTime = new Date(Long.parseLong(param.getEndTime()));
String windowType = param.getCalFunction();
Map<String, Map<String, Map<String, Object>>> result = new HashMap<>(param.getDevices().size());
List<SnapshotValueQueryParam> deviceFieldList = param.getDevices();
String interval = param.getInterval();
Long offset = calculateRemainder(Long.parseLong(param.getStartTime()), interval);
if (offset != 0){
String offsetSecond = offset/1000 + "s";
interval = interval + ","+offsetSecond;
}
System.out.println("不能被整除的部分 (毫秒): " + result);
for (SnapshotValueQueryParam item : deviceFieldList) {
//field分为高频和低频查询
Map<String, Map<String, Map<String, Object>>> values = queryWindowsCurveValues(Long.valueOf(item.getDeviceId()), startTime, endTime, interval, item.getAttributes(),windowType);
result.putAll(values);
}
Long end = System.currentTimeMillis();
log.debug("queryTimeSeriesValues {}个,耗时: {}秒", param.getDevices().size(), (end-start)/ 1000.0);
return result;
}
@ -208,6 +239,67 @@ public class DataServiceImpl implements DataService {
return result;
}
private Map<String, Map<String, Map<String, Object>>> queryWindowsCurveValues(Long irn, Date startTime, Date endTime, String interval, List<String> attributes,String windowType) {
StopWatch stopWatch = new StopWatch();
stopWatch.start("prepare resources");
String function = mappingFunction(windowType);
if (StringUtils.isEmpty(function)){
throw new ServiceException("计算方法参数不正确,请检查参数");
}
String iotModelCode = sysIotModelFieldMapper.queryModelCodeByDeviceId(irn);
Map<String, Object> highSpeedFieldMap = highIotFieldMap.get(iotModelCode);
Map<String, Object> lowSpeedFieldMap = lowIotFieldMap.get(iotModelCode);
Map<String, String> calFieldMap = calculateIotFieldMap.get(iotModelCode);
List<String> highSpeedField = new ArrayList<>();
List<String> lowSpeedField = new ArrayList<>();
List<String> calField = new ArrayList<>();
for (String field : attributes) {
if (highSpeedFieldMap.containsKey(field)) {
highSpeedField.add(field);
}
if (lowSpeedFieldMap.containsKey(field)) {
lowSpeedField.add(field);
}
if (calFieldMap.containsKey(field)){
calField.add(field);
}
}
stopWatch.stop();
stopWatch.start("HighSpeedValues");
Map<String, Map<String, Map<String, Object>>> result = new HashMap<>();
if (!CollectionUtils.isEmpty(highSpeedField)) {
Map<String, Map<String, Map<String, Object>>> highHistoryCurve = tdEngineService.fetchHighWindowsCurve(irn, startTime, endTime, interval, highSpeedField,function);
result.putAll(highHistoryCurve);
}
stopWatch.stop();
stopWatch.start("LowSpeedValues");
if (!CollectionUtils.isEmpty(lowSpeedField)) {
Map<String, Map<String, Map<String, Object>>> lowHistoryCurve = tdEngineService.fetchLowWindowsCurve(irn, startTime, endTime, interval, lowSpeedField,function);
if (result.get(irn.toString()) == null) {
result.putAll(lowHistoryCurve);
} else {
result.get(irn.toString()).putAll(lowHistoryCurve.get(irn.toString()));
}
}
stopWatch.stop();
stopWatch.start("CalculateValues");
if (!CollectionUtils.isEmpty(calField)){
ListUtil.page(calField,COMMIT_COUNT,list -> {
for (String item : list){
Map<String, Map<String, Map<String, Object>>> calHistoryCurve = tdEngineService.fetchCalWindowsCurve(irn, startTime, endTime, interval, item,function);
if (result.get(irn.toString()) == null) {
result.putAll(calHistoryCurve);
} else {
result.get(irn.toString()).putAll(calHistoryCurve.get(irn.toString()));
}
}
});
}
stopWatch.stop();
log.debug("查询历史数据耗时: {}", stopWatch.prettyPrint());
return result;
}
@Override
public void updateCalFieldData(List<CalculateRTData> calValues) {
//更新数据至redis,TD
@ -320,4 +412,39 @@ public class DataServiceImpl implements DataService {
}
return tdEngineService.getTimeAvgValue(tableName, attr.toLowerCase(), startTime, endTime);
}
public long calculateRemainder(long startTime, String interval) {
// 解析interval的数值和单位
long intervalInMilliseconds = parseIntervalToMilliseconds(interval);
// 计算不能被整除的部分
return startTime % intervalInMilliseconds;
}
public long parseIntervalToMilliseconds(String interval) {
// 提取间隔的数字和单位
long intervalValue = Long.parseLong(interval.replaceAll("[^0-9]", ""));
char unit = interval.charAt(interval.length() - 1);
// 根据单位转换为毫秒
return switch (unit) {
case 'm' -> // 分钟
intervalValue * 60 * 1000; // 1 分钟 = 60 * 1000 毫秒
case 'h' -> // 小时
intervalValue * 60 * 60 * 1000; // 1 小时 = 60 * 60 * 1000 毫秒
case 'd' -> //
intervalValue * 24 * 60 * 60 * 1000; // 1 = 24 * 60 * 60 * 1000 毫秒
default -> throw new ServiceException("不支持的单位: " + unit);
};
}
private String mappingFunction(String calFunction){
return switch (calFunction) {
case "average" -> "AVG";
case "max" -> "MAX";
case "min" -> "MIN";
default -> "";
};
}
}

View File

@ -7,8 +7,11 @@ import com.das.common.exceptions.ServiceException;
import com.das.common.result.R;
import com.das.common.utils.PageDataInfo;
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
import com.das.modules.equipment.domain.dto.SysGenExtPropsDto;
import com.das.modules.equipment.domain.vo.EquipmentTypeVo;
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
import com.das.modules.equipment.entity.SysEquipmentDocs;
import com.das.modules.equipment.entity.SysGenExtProps;
import com.das.modules.equipment.service.SysEquipmentService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -138,4 +141,63 @@ public class EquipmentController {
sysEquipmentService.importSysEquipment(id, file);
return R.success("导入成功");
}
/**
* 新增设备附属属性
* @return 所有附属属性
*/
@PostMapping("/extProps/add")
public R<SysGenExtProps> addSysEquipmentExtProps(@RequestBody SysGenExtPropsDto sysGenExtPropsDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
return R.success(sysEquipmentService.creatSysEquipmentExtProps(sysGenExtPropsDto));
}
/**
* 更新设备附属属性
* @return 所有附属属性
*/
@PostMapping("/extProps/update")
public R<SysGenExtProps> updateSysEquipmentExtProps(@RequestBody SysGenExtPropsDto sysGenExtPropsDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
return R.success(sysEquipmentService.updateSysEquipmentExtProps(sysGenExtPropsDto));
}
/**
* 更新设备附属属性
* @return 所有附属属性
*/
@PostMapping("/extProps/query")
public R<SysGenExtProps> querySysEquipmentExtProps(@RequestBody SysGenExtPropsDto sysGenExtPropsDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
return R.success(sysEquipmentService.querySysEquipmentExtProps(sysGenExtPropsDto.getId()));
}
@PostMapping("/extProps/delete")
public R<SysGenExtProps> deleteSysEquipmentExtProps(@RequestBody SysGenExtPropsDto sysGenExtPropsDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
sysEquipmentService.deleteSysEquipmentExtProps(sysGenExtPropsDto.getId());
return R.success();
}
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
public R<SysEquipmentDocs> addFile(Long deviceId, String folderName, MultipartFile file) {
SysEquipmentDocs upload = sysEquipmentService.upload(deviceId, folderName, file);
return R.success(upload);
}
}

View File

@ -251,8 +251,12 @@ public class SysIotModelController {
/** 物模型属性修改 */
@PostMapping("/attribute/getAllSubsystem")
public R<List<String>> getAllSubsystem() {
List<String> allSubsystem = sysIotModelService.getAllSubsystem();
public R<List<String>> getAllSubsystem(@RequestBody SysIotModelFieldDto sysIotModelFieldDto) {
Long iotModelId = sysIotModelFieldDto.getIotModelId();
if (iotModelId == null){
throw new ServiceException("参数物模型id不存在");
}
List<String> allSubsystem = sysIotModelService.getAllSubsystem(iotModelId);
return R.success(allSubsystem);
}
}

View File

@ -112,4 +112,9 @@ public class SysEquipmentDto implements Serializable {
*/
private Double nominalCapacity;
/**
* 所属工程
*/
private String belongProject;
}

View File

@ -0,0 +1,106 @@
package com.das.modules.equipment.domain.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysGenExtPropsDto {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String fanName;
private String fanNumber;
private String fanType;
private String fanTypeDetails;
private String pitchSystemModel;
private String pitchSystemManufacturer;
private String pitchSystemDetails;
private String blade1Model;
private String blade1Manufacturer;
private String blade1Details;
private String blade1BearingModel;
private String blade1BearingManufacturer;
private String blade1BearingDetails;
private String blade2Model;
private String blade2Manufacturer;
private String blade2Details;
private String blade2BearingModel;
private String blade2BearingManufacturer;
private String blade2BearingDetails;
private String blade3Model;
private String blade3Manufacturer;
private String blade3Details;
private String blade3BearingModel;
private String blade3BearingManufacturer;
private String blade3BearingDetails;
private String mainBearingModel;
private String mainBearingManufacturer;
private String mainBearingDetails;
private String gearboxModel;
private String gearboxManufacturer;
private String gearboxDetails;
private String generatorModel;
private String generatorManufacturer;
private String generatorDetails;
private String converterModel;
private String converterManufacturer;
private String converterDetails;
private String mainControlSystemModel;
private String mainControlSystemManufacturer;
private String mainControlSystemSoftwareVersion;
private String mainControlSystemSoftwareVersionDetails;
private String towerBaseCabinetDetails;
private String nacelleCabinetDetails;
}

View File

@ -124,4 +124,9 @@ public class SysEquipmentVo implements Serializable {
*/
private String options;
/**
* 所属工程
*/
private String belongProject;
}

View File

@ -143,4 +143,10 @@ public class SysEquipment extends BaseEntity {
*/
@TableField(value = "options")
private String options;
/**
* 所属工程
*/
@TableField(value = "belong_project")
private String belongProject;
}

View File

@ -0,0 +1,36 @@
package com.das.modules.equipment.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@TableName("sys_equipment_docs")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysEquipmentDocs {
@TableId(value = "deviceid")
private Long deviceId;
@TableField(value = "name")
private String name;
@TableField(value = "url")
private String url;
/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("update_time")
private Date updateTime;
}

View File

@ -0,0 +1,162 @@
package com.das.modules.equipment.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@TableName("sys_gen_extprops")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysGenExtProps {
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@TableField(value = "fan_name")
private String fanName;
@TableField(value = "fan_Number")
private String fanNumber;
@TableField(value = "fan_type")
private String fanType;
@TableField(value = "fan_type_details")
private String fanTypeDetails;
// Pitch System
@TableField(value = "pitch_system_model")
private String pitchSystemModel;
@TableField(value = "pitch_system_manufacturer")
private String pitchSystemManufacturer;
@TableField(value = "pitch_system_details")
private String pitchSystemDetails;
// Blade 1
@TableField(value = "blade1_model")
private String blade1Model;
@TableField(value = "blade1_manufacturer")
private String blade1Manufacturer;
@TableField(value = "blade1_details")
private String blade1Details;
@TableField(value = "blade1_bearing_model")
private String blade1BearingModel;
@TableField(value = "blade1_bearing_manufacturer")
private String blade1BearingManufacturer;
@TableField(value = "blade1_bearing_details")
private String blade1BearingDetails;
// Blade 2
@TableField(value = "blade2_model")
private String blade2Model;
@TableField(value = "blade2_manufacturer")
private String blade2Manufacturer;
@TableField(value = "blade2_details")
private String blade2Details;
@TableField(value = "blade2_bearing_model")
private String blade2BearingModel;
@TableField(value = "blade2_bearing_manufacturer")
private String blade2BearingManufacturer;
@TableField(value = "blade2_bearing_details")
private String blade2BearingDetails;
// Blade 3
@TableField(value = "blade3_model")
private String blade3Model;
@TableField(value = "blade3_manufacturer")
private String blade3Manufacturer;
@TableField(value = "blade3_details")
private String blade3Details;
@TableField(value = "blade3_bearing_model")
private String blade3BearingModel;
@TableField(value = "blade3_bearing_manufacturer")
private String blade3BearingManufacturer;
@TableField(value = "blade3_bearing_details")
private String blade3BearingDetails;
// Main Bearing
@TableField(value = "main_bearing_model")
private String mainBearingModel;
@TableField(value = "main_bearing_manufacturer")
private String mainBearingManufacturer;
@TableField(value = "main_bearing_details")
private String mainBearingDetails;
// Gearbox
@TableField(value = "gearbox_model")
private String gearboxModel;
@TableField(value = "gearbox_manufacturer")
private String gearboxManufacturer;
@TableField(value = "gearbox_details")
private String gearboxDetails;
// Generator
@TableField(value = "generator_model")
private String generatorModel;
@TableField(value = "generator_manufacturer")
private String generatorManufacturer;
@TableField(value = "generator_details")
private String generatorDetails;
// Converter
@TableField(value = "converter_model")
private String converterModel;
@TableField(value = "converter_manufacturer")
private String converterManufacturer;
@TableField(value = "converter_details")
private String converterDetails;
// Main Control System
@TableField(value = "main_control_system_model")
private String mainControlSystemModel;
@TableField(value = "main_control_system_manufacturer")
private String mainControlSystemManufacturer;
@TableField(value = "main_control_system_software_version")
private String mainControlSystemSoftwareVersion;
@TableField(value = "main_control_system_software_version_details")
private String mainControlSystemSoftwareVersionDetails;
// Cabinet Details
@TableField(value = "tower_base_cabinet_details")
private String towerBaseCabinetDetails;
@TableField(value = "nacelle_cabinet_details")
private String nacelleCabinetDetails;
}

View File

@ -0,0 +1,10 @@
package com.das.modules.equipment.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.das.modules.equipment.entity.SysEquipmentDocs;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysEquipmentDocsMapper extends BaseMapper<SysEquipmentDocs> {
}

View File

@ -0,0 +1,10 @@
package com.das.modules.equipment.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.das.modules.equipment.entity.SysGenExtProps;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysGenExtPropsMapper extends BaseMapper<SysGenExtProps> {
}

View File

@ -33,6 +33,6 @@ public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField,
*/
List<SysIotModelFieldVo> selectModelFieldListByModelId(@Param("modelId") Long modelId);
List<String> getAllSubsystem();
List<String> getAllSubsystem(@Param("modelId") Long iotModelId);
}

View File

@ -2,7 +2,10 @@ package com.das.modules.equipment.service;
import com.das.common.utils.PageDataInfo;
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
import com.das.modules.equipment.domain.dto.SysGenExtPropsDto;
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
import com.das.modules.equipment.entity.SysEquipmentDocs;
import com.das.modules.equipment.entity.SysGenExtProps;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
@ -28,4 +31,13 @@ public interface SysEquipmentService {
void importSysEquipment(String parentEquipmentId,MultipartFile file) throws IOException, ParseException;
SysGenExtProps creatSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto);
SysGenExtProps updateSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto);
void deleteSysEquipmentExtProps(Long id);
SysGenExtProps querySysEquipmentExtProps(Long id);
SysEquipmentDocs upload(Long deviceId, String folderName, MultipartFile file);
}

View File

@ -47,6 +47,6 @@ public interface SysIotModelService {
List<SysIotModelVo> getSysIotModelByType(Integer objectType);
List<String> getAllSubsystem();
List<String> getAllSubsystem(Long iotModelId);
}

View File

@ -10,6 +10,7 @@ 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.constant.FileConstants;
import com.das.common.exceptions.ServiceException;
import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.PageDataInfo;
@ -17,16 +18,26 @@ import com.das.common.utils.PageQuery;
import com.das.common.utils.SequenceUtils;
import com.das.modules.auth.domain.vo.SysUserVo;
import com.das.modules.auth.mapper.SysOrgMapper;
import com.das.modules.cache.domain.DeviceInfoCache;
import com.das.modules.cache.service.CacheService;
import com.das.modules.cache.service.EquipmentCache;
import com.das.modules.data.service.TDEngineService;
import com.das.modules.data.service.impl.DataServiceImpl;
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
import com.das.modules.equipment.domain.dto.SysGenExtPropsDto;
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
import com.das.modules.equipment.entity.SysEquipment;
import com.das.modules.equipment.entity.SysEquipmentDocs;
import com.das.modules.equipment.entity.SysGenExtProps;
import com.das.modules.equipment.mapper.SysEquipmentDocsMapper;
import com.das.modules.equipment.mapper.SysEquipmentMapper;
import com.das.modules.equipment.mapper.SysGenExtPropsMapper;
import com.das.modules.equipment.mapper.SysIotModelMapper;
import com.das.modules.equipment.service.SysEquipmentService;
import com.das.modules.fdr.config.MinioProperties;
import com.das.modules.fdr.service.MinioViewsServcie;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@ -73,6 +84,21 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
@Autowired
private TDEngineService tdEngineService;
@Autowired
private SysGenExtPropsMapper sysGenExtPropsMapper;
@Autowired
private MinioViewsServcie minioViewsServcie;
@Resource
private MinioProperties minioAutoProperties;
@Autowired
private EquipmentCache equipmentCache;
@Autowired
private SysEquipmentDocsMapper sysEquipmentDocsMapper;
@Override
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
//去除空格
@ -358,4 +384,56 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
}
}
@Override
public SysGenExtProps creatSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto) {
if (sysGenExtPropsDto.getId() == null){
throw new ServiceException("设备id不能为空");
}
SysGenExtProps sysEquipmentExtProps = new SysGenExtProps();
BeanCopyUtils.copy(sysGenExtPropsDto, sysEquipmentExtProps);
sysGenExtPropsMapper.insert(sysEquipmentExtProps);
return sysEquipmentExtProps;
}
@Override
public SysGenExtProps updateSysEquipmentExtProps(SysGenExtPropsDto sysGenExtPropsDto) {
if (sysGenExtPropsDto.getId() == null){
throw new ServiceException("设备id不能为空");
}
SysGenExtProps sysEquipmentExtProps = new SysGenExtProps();
BeanCopyUtils.copy(sysGenExtPropsDto, sysEquipmentExtProps);
sysGenExtPropsMapper.updateById(sysEquipmentExtProps);
return sysEquipmentExtProps;
}
@Override
public void deleteSysEquipmentExtProps(Long id) {
sysGenExtPropsMapper.deleteById(id);
}
@Override
public SysGenExtProps querySysEquipmentExtProps(Long id) {
return sysGenExtPropsMapper.selectById(id);
}
@Override
public SysEquipmentDocs upload(Long deviceId, String folderName, MultipartFile file) {
DeviceInfoCache deviceInfoCache = equipmentCache.getDeviceInfoCacheById(deviceId);
String parent = FileConstants.FILE_SEPARATOR +"风机图片"+ FileConstants.FILE_SEPARATOR + deviceInfoCache.getDeviceCode();
String url = minioViewsServcie.upload(minioAutoProperties.getPublicBucket(), parent, folderName, file);
String fileName = url.substring(url.lastIndexOf("/"));
SysEquipmentDocs sysEquipmentDocs = new SysEquipmentDocs();
sysEquipmentDocs.setDeviceId(deviceId);
sysEquipmentDocs.setName(fileName);
sysEquipmentDocs.setUrl(url);
sysEquipmentDocs.setUpdateTime(new Date());
SysEquipmentDocs sysEquipmentDocsInfo = sysEquipmentDocsMapper.selectById(deviceId);
if (sysEquipmentDocsInfo == null){
sysEquipmentDocsMapper.insert(sysEquipmentDocs);
}else {
sysEquipmentDocsMapper.updateById(sysEquipmentDocs);
}
return sysEquipmentDocs;
}
}

View File

@ -146,6 +146,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
@Override
public PageDataInfo<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto) {
PageQuery pageQuery = new PageQuery();
pageQuery.setPageNum(sysIotModelFieldDto.getPageNum());
pageQuery.setPageSize(sysIotModelFieldDto.getPageSize());
@ -545,8 +546,8 @@ public class SysIotModelServiceImpl implements SysIotModelService {
}
@Override
public List<String> getAllSubsystem() {
return sysIotModelFieldMapper.getAllSubsystem();
public List<String> getAllSubsystem(Long iotModelId) {
return sysIotModelFieldMapper.getAllSubsystem(iotModelId);
}
public void createTdStableOrColumn(SysIotModelField sysIotModelField) {

View File

@ -45,4 +45,9 @@ public class EventQueryParam
* pageSize
*/
private Integer pageSize;
/**
* 首次故障码
*/
private Integer firstTriggeredCode;
}

View File

@ -34,7 +34,7 @@ public class EventServiceImpl implements EventService {
if (param.getPageNum() != null) {
offset = (param.getPageNum() - 1) * param.getPageSize();
}
PageDataInfo<DeviceEventInfo> deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), param.getStartTime(), param.getEndTime(), param.getDeviceCode(), param.getPageSize(), offset, param.getLimit());
PageDataInfo<DeviceEventInfo> deviceEventInfos = tdEngineService.queryEvent(param.getEventLevel(), param.getStartTime(), param.getEndTime(), param.getDeviceCode(), param.getPageSize(), offset, param.getLimit(),param.getFirstTriggeredCode());
return deviceEventInfos;
}

View File

@ -42,6 +42,14 @@ public class MinioConfig {
createBucket(bucketName, minioClient);
}
}
String publicBucket = minioAutoProperties.getPublicBucket();
if (!checkBucket(publicBucket, minioClient)) {
log.info("文件public桶[{}]不存在, 开始检查是否可以新建桶", publicBucket);
if (minioAutoProperties.isCreateBucket()) {
log.info("createBucket为{},开始新建public文件桶", minioAutoProperties.isCreateBucket());
createBucket(publicBucket, minioClient);
}
}
log.info("文件桶[{}]已存在, minio客户端连接成功!", bucketName);
} else {
throw new RuntimeException("桶不存在, 请检查桶名称是否正确或者将checkBucket属性改为false");

View File

@ -40,6 +40,9 @@ public class MinioProperties {
@Value("${minio.bucket}")
private String bucket;
@Value("${minio.publicBucket}")
private String publicBucket;
/**
* 桶不在的时候是否新建桶
*/

View File

@ -51,13 +51,13 @@ public class FaultRecorderController {
String code = jsonObject.getString("deviceCode");
String startTime = jsonObject.getString("startTime");
String endTime = jsonObject.getString("endTime");
List<FileNode> result = faultRecorderService.getDirOrFileList("Statuscode",code,startTime,endTime);
List<FileNode> result = faultRecorderService.getDirOrFileList("Tracelog",code,startTime,endTime);
return R.success(result);
}
@RequestMapping(value = "/parseData", method = RequestMethod.POST)
public R<Map<String, List<Object>>> parseData(@RequestBody JSONObject jsonObject) throws IOException {
Map<String, List<Object>> dataCurve = faultRecorderService.getDataCurve(jsonObject.getString("url"), jsonObject.getString("deviceCode"));
public R<Map<String, Object>> parseData(@RequestBody JSONObject jsonObject) throws IOException {
Map<String, Object> dataCurve = faultRecorderService.getDataCurve(jsonObject.getString("url"), jsonObject.getString("deviceCode"));
return R.success(dataCurve);
}

View File

@ -19,7 +19,7 @@ public interface FaultRecorderService {
void download(String path, HttpServletResponse httpServletResponse) throws IOException;
Map<String, List<Object>> getDataCurve(String url, String deviceCode);
Map<String, Object> getDataCurve(String url, String deviceCode);
void updateFdrConfig(SysEquipment sysEquipment);

View File

@ -78,7 +78,7 @@ public class MinioViewsServcie {
}
public String upload(String path, String folderName,MultipartFile file) {
public String upload(String bucketName, String path, String folderName,MultipartFile file) {
String targetFile = null;
try {
// 上传一个空对象来模拟文件夹
@ -87,14 +87,14 @@ public class MinioViewsServcie {
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
minioClient.putObject(
PutObjectArgs.builder()
.bucket(minioProperties.getBucket())
.bucket(bucketName)
.object(targetFile)
.stream(bais, 0, -1)
.build());
}
else {
targetFile= path +"/" + file.getOriginalFilename();
uploadFile(minioProperties.getBucket(), file, targetFile, "application/octet-stream");
uploadFile(bucketName, file, targetFile, "application/octet-stream");
}
} catch (Exception e) {
throw new RuntimeException(e);
@ -123,7 +123,7 @@ public class MinioViewsServcie {
.stream(inputStream, inputStream.available(), -1)
.build());
}catch (Exception e){
log.error("minio文件上传失败{}", e);
log.error("minio文件上传失败", e);
}
}

View File

@ -14,6 +14,7 @@ import com.das.modules.curve.mapper.TheoreticalPowerCurveMapper;
import com.das.modules.equipment.domain.excel.SheetInfoBean;
import com.das.modules.equipment.entity.SysEquipment;
import com.das.modules.equipment.mapper.SysEquipmentMapper;
import com.das.modules.fdr.config.MinioProperties;
import com.das.modules.fdr.domain.FileNode;
import com.das.modules.fdr.domain.SysFaultCodeDict;
import com.das.modules.fdr.domain.SysFaultRecordingDesc;
@ -26,6 +27,7 @@ import com.das.modules.fdr.service.FaultRecorderService;
import com.das.modules.fdr.service.MinioViewsServcie;
import io.micrometer.common.util.StringUtils;
import io.minio.MinioClient;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@ -52,6 +54,9 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
@Autowired
MinioClient minioClient;
@Resource
private MinioProperties minioAutoProperties;
@Autowired
private SysEquipmentMapper sysEquipmentMapper;
@ -82,7 +87,7 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
@Override
public String upload(String parent, String folderName, MultipartFile file) {
return minioViewsServcie.upload(parent, folderName, file);
return minioViewsServcie.upload(minioAutoProperties.getBucket(), parent, folderName, file);
}
@Override
@ -128,6 +133,9 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
queryWrapper.eq("madeinfactory",madeinfactory);
queryWrapper.eq("MODEL",model);
TheoreticalPowerCurveEntity theoreticalPowerCurveEntity = theoreticalPowerCurveMapper.selectOne(queryWrapper);
if (theoreticalPowerCurveEntity == null) {
return Collections.emptyList();
}
QueryWrapper<SysFaultCodeDict> sysFaultCodeDictQueryWrapper = new QueryWrapper<>();
sysFaultCodeDictQueryWrapper.eq("parent",theoreticalPowerCurveEntity.getId());
sysFaultCodeDictQueryWrapper.orderByAsc("code");
@ -168,8 +176,8 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
}
@Override
public Map<String, List<Object>> getDataCurve(String url, String deviceCode) {
Map<String, List<Object>> resultMap = null;
public Map<String, Object> getDataCurve(String url, String deviceCode) {
Map<String, Object> resultMap = null;
//根据device Code查询故障录波格式
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("CODE", deviceCode);
@ -191,8 +199,8 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
resultMap = parseFile(fileStream, fdrFormatVo.getTimeFormat(), fdrFormatVo.getDelimiter(), fdrFormatVo.getValidStartLine());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("配置解析异常");
log.error("文件解析异常",e);
throw new ServiceException("文件解析异常,请检查配置");
}
return resultMap;
}
@ -211,15 +219,20 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
sysEquipmentMapper.updateById(sysEquipment);
}
public Map<String, List<Object>> parseFile(InputStream inputStream, String timeFormat, String delimiter, int validStartLine) {
public Map<String, Object> parseFile(InputStream inputStream, String timeFormat, String delimiter, int validStartLine) {
List<List<String>> result = new ArrayList<>();
Map<String, List<Object>> stringListMap = null;
Map<String, Object> stringListMap = null;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
int lineNumber = 0;
while ((line = reader.readLine()) != null) {
lineNumber++;
if (lineNumber == 2){
List<String> lineData = Arrays.stream(line.split(":")).toList();
result.add(lineData);
}
// 忽略有效行之前的行
if (lineNumber < validStartLine) {
continue;
@ -230,24 +243,35 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
}
stringListMap = parseDataCurve(result, timeFormat);
} catch (Exception e) {
log.error("文件解析失败{}", e);
log.error("文件解析失败", e);
throw new ServiceException("文件解析失败");
}
return stringListMap;
}
public Map<String, List<Object>> parseDataCurve(List<List<String>> data, String timeFormat) throws ParseException {
public Map<String, Object> parseDataCurve(List<List<String>> data, String timeFormat) throws ParseException {
List<String> faultTimeList = data.get(0);
Long faultTime = null;
try {
faultTime = convertToTimestamp(faultTimeList.get(1).trim(), timeFormat);
} catch (Exception e) {
log.error("faultTime转换失败");
}
Map<String, Object> result = new HashMap<>();
result.put("faultTime", faultTime);
data.remove(0);
List<String> listField = data.get(0);
Map<String, List<Object>> map = new HashMap<>();
data.remove(0);
for (List<String> item : data) {
for (int i = 0; i < item.size(); i++) {
if (map.get(listField.get(i)) == null) {
if (i == 0){
if (i == 0) {
List<Object> timeList = new ArrayList<>();
long timestamp = convertToTimestamp(item.get(i), timeFormat);
timeList.add(timestamp);
map.put(listField.get(i),timeList);
}else {
map.put(listField.get(i), timeList);
} else {
List<Object> valueList = new ArrayList<>();
valueList.add(Double.valueOf(item.get(i)));
map.put(listField.get(i), valueList);
@ -255,18 +279,18 @@ public class FaultRecorderServiceImpl implements FaultRecorderService {
} else {
List<Object> valueList = map.get(listField.get(i));
if (i == 0){
valueList.add(convertToTimestamp(item.get(i),timeFormat));
if (i == 0) {
valueList.add(convertToTimestamp(item.get(i), timeFormat));
}
else {
} else {
valueList.add(Double.valueOf(item.get(i)));
}
}
}
}
return map;
result.put("dataCurve",map);
return result;
}
public long convertToTimestamp(String time, String pattern) throws ParseException {

View File

@ -358,6 +358,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
log.info("消息data转化deviceVo,{}", list);
for (DeviceEventVo item : list) {
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId()));
Integer firstTriggeredCode = adminRedisTemplate.get(String.format("RT:%s:%s", item.getDeviceId(), "FirstTriggeredCode".toLowerCase()));
DeviceEventInfo deviceEventInfo = new DeviceEventInfo();
deviceEventInfo.setEventTime(item.getEventTime());
deviceEventInfo.setEventId(IdWorker.getId());
@ -365,6 +366,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
deviceEventInfo.setDeviceId(item.getDeviceId());
deviceEventInfo.setDeviceName(deviceInfoCache.getDeviceName());
deviceEventInfo.setDeviceCode(deviceInfoCache.getDeviceCode());
deviceEventInfo.setFirstTriggeredCode(firstTriggeredCode);
String eventType = getEventType(item.getEventType());
String model = dataService.deviceModelMap.get(item.getDeviceId());
if (StringUtils.isEmpty(model)) {
@ -405,7 +407,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
try {
tdEngineService.updateDeviceEventValues(valueList);
} catch (Exception e) {
log.error("事件信息存入Td失败,失败原因{}", e);
log.error("事件信息存入Td失败,失败原因", e);
}
}

View File

@ -551,7 +551,7 @@ public class SysNodeServiceImpl implements SysNodeService {
})
.anyMatch(order -> !orderSet.add(order));
}catch (Exception e){
log.error("校验order不重复失败:{}",e);
log.error("校验order不重复失败",e);
}
return orderRepeated;
}

View File

@ -1,13 +1,16 @@
package com.das.modules.page.controller;
import com.das.common.exceptions.ServiceException;
import com.das.common.result.R;
import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.page.domian.dto.HomeWindTurbineMatrixDataDto;
import com.das.modules.page.domian.dto.WindFarmRealDataDto;
import com.das.modules.page.domian.vo.HomeWindFarmRealDataVo;
import com.das.modules.page.domian.vo.HomeWindTurbineMatrixDataVoVo;
import com.das.modules.page.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -32,8 +35,11 @@ public class HomeController {
* @return 风机矩阵数据
*/
@PostMapping("/getWindTurbineMatrixData")
public R<List<HomeWindTurbineMatrixDataVoVo>> getWindTurbineMatrixData() {
return R.success(homeService.getWindTurbineMatrixData());
public R<List<HomeWindTurbineMatrixDataVoVo>> getWindTurbineMatrixData(@RequestBody HomeWindTurbineMatrixDataDto homeWindTurbineMatrixDataDto) {
if (CollectionUtils.isEmpty(homeWindTurbineMatrixDataDto.getAttributesList())){
throw new ServiceException("属性列表不能为空");
}
return R.success(homeService.getWindTurbineMatrixData(homeWindTurbineMatrixDataDto));
}

View File

@ -0,0 +1,53 @@
package com.das.modules.page.controller;
import com.das.common.exceptions.ServiceException;
import com.das.common.result.R;
import com.das.modules.page.domian.dto.SysHomeParamSetDto;
import com.das.modules.page.domian.vo.SysHomeParamSetVo;
import com.das.modules.page.service.HomeParamSetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 首页参数设置 相关Controller
*/
@Slf4j
@RequestMapping("/api/page/home/set")
@RestController
public class HomeParamSetController {
@Autowired
private HomeParamSetService homeParamSetService;
/** 新增系统参数设置页面 */
@PostMapping("/add")
public R<SysHomeParamSetVo> add(@RequestBody SysHomeParamSetDto sysHomeParamSetDto) {
SysHomeParamSetVo sysHomeParamSetVo = homeParamSetService.add(sysHomeParamSetDto);
return R.success(sysHomeParamSetVo);
}
/** 获取系统参数设置页面 */
@PostMapping("/getList")
public R<List<SysHomeParamSetVo>> getList(@RequestBody SysHomeParamSetDto sysHomeParamSetDto) {
List<SysHomeParamSetVo> list = homeParamSetService.getList(sysHomeParamSetDto);
return R.success(list);
}
/** 更新系统参数设置页面 */
@PostMapping("/update")
public R<SysHomeParamSetVo> update(@RequestBody SysHomeParamSetDto sysHomeParamSetDto) {
if (sysHomeParamSetDto.getId() == null) {
throw new ServiceException("id不能为空");
}
SysHomeParamSetVo sysHomeParamSetVo = homeParamSetService.update(sysHomeParamSetDto);
return R.success(sysHomeParamSetVo);
}
}

View File

@ -0,0 +1,36 @@
package com.das.modules.page.domian.dto;
import lombok.Data;
import java.util.List;
/**
* 首页风机矩阵
*/
@Data
public class HomeWindTurbineMatrixDataDto {
/**
* 设备类型编码
*/
private Integer objectType;
/**
* 所属工程
*/
private String belongProject;
/**
* 制造商
*/
private String madeinFactory;
/**
* 物理模型属性
*/
private List<String> attributesList;
}

View File

@ -0,0 +1,18 @@
package com.das.modules.page.domian.dto;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
@Data
public class SysHomeParamSetDto {
private Long id;
private String paramName;
private String paramValue;
private JSONArray paramValueJson;
private String paramDesc;
}

View File

@ -35,6 +35,10 @@ public class HomeWindTurbineMatrixDataVoVo {
private Double nominalCapacity;
private String deviceCode;
/**
* 制造商
*/
private String madeinFactory;
private Map<String,Object> attributeMap;

View File

@ -0,0 +1,18 @@
package com.das.modules.page.domian.vo;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
@Data
public class SysHomeParamSetVo {
private Long id;
private String paramName;
private String paramValue;
private JSONArray paramValueJson;
private String paramDesc;
}

View File

@ -0,0 +1,32 @@
package com.das.modules.page.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.das.common.constant.BaseEntity;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serial;
@Data
@TableName("sys_home_param_set")
public class SysHomeParamSet extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String paramName;
private String paramValue;
private String paramDesc;
}

View File

@ -0,0 +1,16 @@
package com.das.modules.page.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.das.modules.page.domian.dto.SysHomeParamSetDto;
import com.das.modules.page.domian.vo.SysHomeParamSetVo;
import com.das.modules.page.entity.SysHomeParamSet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SysHomeParamSetMapper extends BaseMapper<SysHomeParamSet> {
List<SysHomeParamSetVo> getList(@Param("info") SysHomeParamSetDto sysHomeParamSetDto);
}

View File

@ -0,0 +1,15 @@
package com.das.modules.page.service;
import com.das.modules.page.domian.dto.SysHomeParamSetDto;
import com.das.modules.page.domian.vo.SysHomeParamSetVo;
import java.util.List;
public interface HomeParamSetService {
SysHomeParamSetVo add(SysHomeParamSetDto sysHomeParamSetDto);
List<SysHomeParamSetVo> getList(SysHomeParamSetDto sysHomeParamSetDto);
SysHomeParamSetVo update(SysHomeParamSetDto sysHomeParamSetDto);
}

View File

@ -1,6 +1,7 @@
package com.das.modules.page.service;
import com.das.modules.data.domain.TSValueQueryParam;
import com.das.modules.page.domian.dto.HomeWindTurbineMatrixDataDto;
import com.das.modules.page.domian.dto.WindFarmRealDataDto;
import com.das.modules.page.domian.vo.HomeWindFarmRealDataVo;
import com.das.modules.page.domian.vo.HomeWindTurbineMatrixDataVoVo;
@ -13,7 +14,7 @@ public interface HomeService {
* 接口1 首页风机矩阵数据
* @return 风机矩阵数据
*/
List<HomeWindTurbineMatrixDataVoVo> getWindTurbineMatrixData();
List<HomeWindTurbineMatrixDataVoVo> getWindTurbineMatrixData(HomeWindTurbineMatrixDataDto homeWindTurbineMatrixDataDto);

View File

@ -0,0 +1,69 @@
package com.das.modules.page.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson.JSONArray;
import com.das.common.config.SessionUtil;
import com.das.common.utils.BeanCopyUtils;
import com.das.modules.auth.domain.vo.SysUserVo;
import com.das.modules.page.domian.dto.SysHomeParamSetDto;
import com.das.modules.page.domian.vo.SysHomeParamSetVo;
import com.das.modules.page.entity.SysHomeParamSet;
import com.das.modules.page.mapper.SysHomeParamSetMapper;
import com.das.modules.page.service.HomeParamSetService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class HomeParamSetServiceImpl implements HomeParamSetService {
@Autowired
private SysHomeParamSetMapper sysHomeParamSetMapper;
@Override
public SysHomeParamSetVo add(SysHomeParamSetDto sysHomeParamSetDto) {
SysHomeParamSet sysHomeParamSet = new SysHomeParamSet();
BeanCopyUtils.copy(sysHomeParamSetDto, sysHomeParamSet);
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
sysHomeParamSet.setCreatedBy(sysUserVo.getAccount());
sysHomeParamSet.setUpdatedBy(sysUserVo.getAccount());
sysHomeParamSet.setCreatedTime(new Date());
sysHomeParamSet.setUpdatedTime(new Date());
sysHomeParamSet.setRevision(1);
if (sysHomeParamSetDto.getParamValueJson() !=null){
sysHomeParamSet.setParamValue(sysHomeParamSetDto.getParamValueJson().toString());
}
sysHomeParamSetMapper.insert(sysHomeParamSet);
SysHomeParamSetVo sysHomeParamSetVo = new SysHomeParamSetVo();
BeanCopyUtils.copy(sysHomeParamSet, sysHomeParamSetVo);
return sysHomeParamSetVo;
}
@Override
public List<SysHomeParamSetVo> getList(SysHomeParamSetDto sysHomeParamSetDto) {
List<SysHomeParamSetVo> list = sysHomeParamSetMapper.getList(sysHomeParamSetDto);
for (SysHomeParamSetVo sysHomeParamSetVo : list) {
if (StringUtils.isNotBlank(sysHomeParamSetVo.getParamValue())){
JSONArray json = JSONArray.parseArray(sysHomeParamSetVo.getParamValue());
sysHomeParamSetVo.setParamValueJson(json);
}
}
return list;
}
@Override
public SysHomeParamSetVo update(SysHomeParamSetDto sysHomeParamSetDto) {
SysHomeParamSet sysHomeParamSet = new SysHomeParamSet();
BeanCopyUtils.copy(sysHomeParamSetDto, sysHomeParamSet);
if (sysHomeParamSetDto.getParamValueJson() !=null){
sysHomeParamSet.setParamValue(sysHomeParamSetDto.getParamValueJson().toString());
}
sysHomeParamSetMapper.updateById(sysHomeParamSet);
SysHomeParamSetVo sysHomeParamSetVo = new SysHomeParamSetVo();
SysHomeParamSetVo result = BeanCopyUtils.copy(sysHomeParamSet, sysHomeParamSetVo);
return result;
}
}

View File

@ -2,6 +2,7 @@ package com.das.modules.page.service.impl;
import com.das.common.constant.EquipmentTypeIds;
import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.JsonUtils;
import com.das.modules.data.domain.SnapshotValueQueryParam;
import com.das.modules.data.domain.TSValueQueryParam;
@ -9,6 +10,7 @@ import com.das.modules.data.service.impl.DataServiceImpl;
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
import com.das.modules.equipment.mapper.SysEquipmentMapper;
import com.das.modules.page.domian.dto.HomeWindTurbineMatrixDataDto;
import com.das.modules.page.domian.dto.WindFarmRealDataDto;
import com.das.modules.page.domian.vo.HomeWindFarmRealDataVo;
import com.das.modules.page.domian.vo.HomeWindTurbineMatrixDataVoVo;
@ -42,36 +44,16 @@ public class HomeServiceImpl implements HomeService {
* @return 风机矩阵数据
*/
@Override
public List<HomeWindTurbineMatrixDataVoVo> getWindTurbineMatrixData() {
public List<HomeWindTurbineMatrixDataVoVo> getWindTurbineMatrixData(HomeWindTurbineMatrixDataDto homeWindTurbineMatrixDataDto ) {
SysEquipmentDto sysEquipmentDto = new SysEquipmentDto();
sysEquipmentDto.setObjectType(EquipmentTypeIds.EQUIPMENT_TYPE_STATION_WTG);
BeanCopyUtils.copy(homeWindTurbineMatrixDataDto ,sysEquipmentDto );
//获取所有风机设备
List<SysEquipmentVo> sysEquipmentVos = sysEquipmentMapper.queryEquipmentListInPage(sysEquipmentDto);
//风机返回数据列表
List<HomeWindTurbineMatrixDataVoVo> homeWindRealTimeVoList = new ArrayList<>();
List<SnapshotValueQueryParam> paramList = new ArrayList<>();
//构建需要查询的物模型属
List<String> attributesList = new ArrayList<>();
//风速
attributesList.add("iwindspeed");
//风机状态判断条件所需的字段iturbineoperationmodeiYPLevelGridLostDetected可能会调整
//风机状态
attributesList.add("iturbineoperationmode");
//偏航运行模式
attributesList.add("iyplevel");
//风机电网掉电
attributesList.add("gridlostdetected");
//刹车等级
attributesList.add("ibplevel");
//有功功率(MW)
attributesList.add("igenpower");
//日发电量(kwh)
attributesList.add("ikwhthisday");
//是否锁定
attributesList.add("Locked");
attributesList.add("ProcessedOperationMode");
//叶轮转速
attributesList.add("iRotorSpeed");
//构建需要查询的物模型属性
List<String> attributesList = homeWindTurbineMatrixDataDto.getAttributesList();
for (SysEquipmentVo item : sysEquipmentVos) {
//构建查询属性参数
SnapshotValueQueryParam snapshotValueQueryParam = new SnapshotValueQueryParam();
@ -88,6 +70,7 @@ public class HomeServiceImpl implements HomeService {
homeWindRealTimeVoResult.setBelongLine(item.getBelongLine());
homeWindRealTimeVoResult.setStandard(item.getStandard());
homeWindRealTimeVoResult.setNominalCapacity(item.getNominalCapacity());
homeWindRealTimeVoResult.setMadeinFactory(item.getMadeinFactory());
homeWindRealTimeVoList.add(homeWindRealTimeVoResult);
}
//获取设备测点数据

View File

@ -44,7 +44,7 @@ public class PlcLogsController {
String code = jsonObject.getString("deviceCode");
String startTime = jsonObject.getString("startTime");
String endTime = jsonObject.getString("endTime");
List<FileNode> result = plcLogService.getDirOrFileList("Tracelog",code,startTime,endTime);
List<FileNode> result = plcLogService.getDirOrFileList("Statuscode",code,startTime,endTime);
return R.success(result);
}

View File

@ -86,8 +86,8 @@ public class PlcLogsServiceImpl implements PlcLogService {
resultMap = parseFile(fileStream, fdrFormatVo.getTimeFormat(), fdrFormatVo.getDelimiter(), fdrFormatVo.getValidStartLine());
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("配置解析异常");
log.error("文件解析异常",e);
throw new ServiceException("文件解析异常,请检查配置");
}
return resultMap;
}
@ -162,7 +162,8 @@ public class PlcLogsServiceImpl implements PlcLogService {
}
stringListMap = parseDataCurve(result, timeFormat);
} catch (Exception e) {
log.error("文件解析失败{}", e);
log.error("文件解析失败", e);
throw new ServiceException("文件解析失败");
}
return stringListMap;
}

View File

@ -109,5 +109,6 @@ tdengine:
minio:
url: http://192.168.109.187:9000
bucket: das
publicBucket: das-public
accessKey: das
secretKey: zaq12WSX

View File

@ -85,6 +85,12 @@
<if test="info.objectType != null and info.objectType != ''">
and t.object_type = #{info.objectType}
</if>
<if test="info.belongProject !=null and info.belongProject !=''">
and t.belong_project = #{info.belongProject}
</if>
<if test="info.madeinFactory !=null and info.madeinFactory !=''">
and t.madein_factory = #{info.madeinFactory}
</if>
</where>
order by t.name
</select>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.das.modules.page.mapper.SysHomeParamSetMapper">
<select id="getList" resultType="com.das.modules.page.domian.vo.SysHomeParamSetVo">
SELECT
*
FROM
sys_home_param_set
<where>
<if test="info.paramName != null and info.paramName != ''">
AND param_name = #{info.paramName}
</if>
</where>
</select>
</mapper>

View File

@ -31,7 +31,7 @@
<if test="info.subSystem != null and info.subSystem != ''">
and t.subsystem = #{info.subSystem}
</if>
<if test="info.subSystem != null and info.subSystem != ''">
<if test="info.confidential != null and info.confidential != ''">
and t.confidential = #{info.confidential}
</if>
</where>
@ -65,6 +65,6 @@
select * from sys_iot_model_field where iot_model_id = #{modelId} order by porder
</select>
<select id="getAllSubsystem" resultType="java.lang.String">
select distinct simf.subsystem from sys_iot_model_field simf
select distinct simf.subsystem from sys_iot_model_field simf where simf.iot_model_id = #{modelId}
</select>
</mapper>

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

@ -0,0 +1,18 @@
import createAxios from '/@/utils/axios'
export function getParamList(params: object = {}) {
return createAxios({
url: '/api/page/home/set/getList',
method: 'POST',
data: params,
})
}
export function Paramupdate(params: object = {}) {
return createAxios({
url: '/api/page/home/set/update',
method: 'POST',
data: params,
})
}

View File

@ -180,9 +180,10 @@ export function queryfaultCodeDict(params: object = {}) {
})
}
export function getAllSubSystemReq() {
export function getAllSubSystemReq(params: { iotModelId: string }) {
return createAxios({
url: '/api/equipment/model/attribute/getAllSubsystem',
method: 'post'
method: 'post',
data: params
})
}

View File

@ -35,6 +35,9 @@ export const previewFileReq = (data: {
method: 'post',
data,
timeout: 60 * 1000
},
{
showErrorMessage: false
})
}

View File

@ -36,6 +36,8 @@ export const previewFileReq = (data: {
method: 'post',
data,
timeout: 60 * 1000
}, {
showErrorMessage: false
})
}

View File

@ -30,11 +30,12 @@ export const delInstitutionalListReq = (data: delDataType) => {
url: '/api/org/delete',
method: 'post',
data: data,
},{
showErrorMessage:false
})
}
export const getInstitutionalTreeListReq = (data: getTreeDataType) => {
console.log(data);
return createAxios<never, operateDataReturnType<getTreeDataReturnType[]>>({
url: '/api/org/list',
method: 'post',

View File

@ -16,6 +16,15 @@ export const historyReq = (data: any) => {
})
}
export const windowReq = (data: any) => {
return createAxios({
url: '/api/data/windows',
method: 'post',
data: data,
timeout: 60 * 1000,
})
}
export const runAirBlowerReq = (
data: {
deviceId: string

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Some files were not shown because too many files have changed in this diff Show More