优化逻辑
This commit is contained in:
parent
bd0cbc1711
commit
da1c45f4c6
@ -25,7 +25,7 @@ public class WebSocketServer {
|
|||||||
webSocketSet.add(this);//加入set中
|
webSocketSet.add(this);//加入set中
|
||||||
addOnlineCount();
|
addOnlineCount();
|
||||||
log.info("有新连接加入!当前在线人数为"+getOnlineCount());
|
log.info("有新连接加入!当前在线人数为"+getOnlineCount());
|
||||||
allCurrentOnline();
|
// allCurrentOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClose
|
@OnClose
|
||||||
@ -33,7 +33,7 @@ public class WebSocketServer {
|
|||||||
webSocketSet.remove(this);
|
webSocketSet.remove(this);
|
||||||
subOnlineCount();
|
subOnlineCount();
|
||||||
log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
|
log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
|
||||||
allCurrentOnline();
|
// allCurrentOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnMessage
|
@OnMessage
|
||||||
|
@ -43,8 +43,8 @@ public class AlgorithmClassController {
|
|||||||
|
|
||||||
@GetMapping("/getAlgorithmClassTree")
|
@GetMapping("/getAlgorithmClassTree")
|
||||||
@ApiOperation("获取算法分类树")
|
@ApiOperation("获取算法分类树")
|
||||||
public ResponseResult getAlgorithmClassTree(String algorithmClassName) {
|
public ResponseResult getAlgorithmClassTree(String stationCode,String algorithmClassName) {
|
||||||
List<TreeNode> treeNodes = algorithmClassService.getAlgorithmComponentTree(algorithmClassName);
|
List<TreeNode> treeNodes = algorithmClassService.getAlgorithmComponentTree(stationCode,algorithmClassName);
|
||||||
return ResponseResult.successData(treeNodes);
|
return ResponseResult.successData(treeNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,5 +16,5 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public interface AlgorithmClassComponentMapper extends BaseMapper<AlgorithmClassComponent> {
|
public interface AlgorithmClassComponentMapper extends BaseMapper<AlgorithmClassComponent> {
|
||||||
|
|
||||||
List<Map<String, Object>> getAlgorithmComponentList(String algorithmClassName);
|
List<Map<String, Object>> getAlgorithmComponentList(String stationCode,String algorithmClassName);
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,6 @@ public interface AlgorithmDeviceMapper extends BaseMapper<AlgorithmDevice> {
|
|||||||
List<Map<String, Object>> getAlgorithmDeviceParams(String algorithmId, String componentId);
|
List<Map<String, Object>> getAlgorithmDeviceParams(String algorithmId, String componentId);
|
||||||
|
|
||||||
List<Map<String, Object>> getAlgorithmDeviceType(String algorithmId, String componentId);
|
List<Map<String, Object>> getAlgorithmDeviceType(String algorithmId, String componentId);
|
||||||
|
|
||||||
|
String getReturnDesc(String componentId);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,6 @@ public interface IAlgorithmClassService extends IService<AlgorithmClass> {
|
|||||||
* 参数说明 algorithmClassName
|
* 参数说明 algorithmClassName
|
||||||
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
||||||
***********************************/
|
***********************************/
|
||||||
List<TreeNode> getAlgorithmComponentTree(String algorithmClassName);
|
List<TreeNode> getAlgorithmComponentTree(String stationCode,String algorithmClassName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,9 @@ public class AlgorithmClassServiceImpl extends ServiceImpl<AlgorithmClassMapper,
|
|||||||
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
* 返回值说明: java.util.List<com.yfd.platform.modules.basedata.domain.TreeNode>
|
||||||
***********************************/
|
***********************************/
|
||||||
@Override
|
@Override
|
||||||
public List<TreeNode> getAlgorithmComponentTree(String algorithmClassName) {
|
public List<TreeNode> getAlgorithmComponentTree(String stationCode,String algorithmClassName) {
|
||||||
List<Map<String, Object>> dataList =
|
List<Map<String, Object>> dataList =
|
||||||
algorithmClassComponentMapper.getAlgorithmComponentList(algorithmClassName);
|
algorithmClassComponentMapper.getAlgorithmComponentList(stationCode,algorithmClassName);
|
||||||
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
|
List<TreeNode> treeNodes = this.buildSignalTree(dataList);
|
||||||
if (treeNodes.size() <= 0) {
|
if (treeNodes.size() <= 0) {
|
||||||
return treeNodes;
|
return treeNodes;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yfd.platform.modules.algorithm.service.impl;
|
package com.yfd.platform.modules.algorithm.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.net.NetUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -12,10 +13,13 @@ import com.yfd.platform.modules.algorithm.mapper.AlgorithmDeviceMapper;
|
|||||||
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
import com.yfd.platform.modules.algorithm.mapper.AlgorithmParamsMapper;
|
||||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
import com.yfd.platform.modules.algorithm.service.IAlgorithmParamsService;
|
||||||
import com.yfd.platform.utils.HttpRESTfulUtils;
|
import com.yfd.platform.utils.HttpRESTfulUtils;
|
||||||
|
import com.yfd.platform.utils.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -115,6 +119,10 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
|||||||
if (algorithmClass == null) {
|
if (algorithmClass == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
String serviceAddress = algorithmClass.getServiceAddress();
|
||||||
|
if (!StringUtils.isHttpOrHttps(serviceAddress)) {
|
||||||
|
throw new RuntimeException("当前算法请求分析的url不是标准请求");
|
||||||
|
}
|
||||||
// 固定参数就是固定参数,点位数据是默认最新点位,信号也是找最新数据
|
// 固定参数就是固定参数,点位数据是默认最新点位,信号也是找最新数据
|
||||||
List<Map<String, String>> mapList = algorithmParamsMapper.getAnalyseParams(id, componentId);
|
List<Map<String, String>> mapList = algorithmParamsMapper.getAnalyseParams(id, componentId);
|
||||||
if (mapList.size() <= 0) {
|
if (mapList.size() <= 0) {
|
||||||
@ -126,9 +134,10 @@ public class AlgorithmParamsServiceImpl extends ServiceImpl<AlgorithmParamsMappe
|
|||||||
}
|
}
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("param", senData);
|
param.put("param", senData);
|
||||||
JSONObject jsonObject = httpRESTfulUtils.sendHttpUrlPost("json",
|
JSONObject jsonObject = httpRESTfulUtils.sendHttpUrlPost("json", serviceAddress, "", param, null);
|
||||||
algorithmClass.getServiceAddress(), "", param, null);
|
String desc = algorithmDeviceMapper.getReturnDesc(componentId);
|
||||||
jsonObject.put("mapList", mapList);
|
jsonObject.put("mapList", mapList);
|
||||||
|
jsonObject.put("desc", desc);
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ public class DeviceWorkDataController {
|
|||||||
@ApiOperation("分页查询变电站设备运行记录")
|
@ApiOperation("分页查询变电站设备运行记录")
|
||||||
public ResponseResult getDeviceWorkDataPage(Page<DeviceWorkData> page, String signalId, String startDate,
|
public ResponseResult getDeviceWorkDataPage(Page<DeviceWorkData> page, String signalId, String startDate,
|
||||||
String endDate) {
|
String endDate) {
|
||||||
|
if(StrUtil.isBlank(signalId)){
|
||||||
|
return ResponseResult.successData(page);
|
||||||
|
}
|
||||||
Page<DeviceWorkData> deviceWorkDataPage = deviceWorkDataService.getDeviceWorkDataPage(page, signalId,
|
Page<DeviceWorkData> deviceWorkDataPage = deviceWorkDataService.getDeviceWorkDataPage(page, signalId,
|
||||||
startDate, endDate);
|
startDate, endDate);
|
||||||
return ResponseResult.successData(deviceWorkDataPage);
|
return ResponseResult.successData(deviceWorkDataPage);
|
||||||
|
@ -33,9 +33,7 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.*;
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@ -283,6 +281,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return weekDays[w];
|
return weekDays[w];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isHttpOrHttps(String url) {
|
||||||
|
try {
|
||||||
|
URI uri = new URI(url);
|
||||||
|
String scheme = uri.getScheme();
|
||||||
|
return "http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme);
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
// 非法 URL 格式
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前机器的IP
|
* 获取当前机器的IP
|
||||||
*
|
*
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
iis_algorithm_class ac
|
iis_algorithm_class ac
|
||||||
INNER JOIN iis_algorithm_class_component acc ON ac.id = acc.algorithm_id
|
INNER JOIN iis_algorithm_class_component acc ON ac.id = acc.algorithm_id
|
||||||
WHERE
|
WHERE
|
||||||
1 =1
|
acc.station_code=#{stationCode}
|
||||||
<if test="algorithmClassName != null and algorithmClassName != ''">
|
<if test="algorithmClassName != null and algorithmClassName != ''">
|
||||||
AND ac.algorithm_class_name LIKE CONCAT('%',#{algorithmClassName},'%')
|
AND ac.algorithm_class_name LIKE CONCAT('%',#{algorithmClassName},'%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -36,4 +36,13 @@
|
|||||||
AND ad.component_id =#{componentId}
|
AND ad.component_id =#{componentId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getReturnDesc" resultType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
CONCAT( station_name, '-', area_name, '-', bay_name, '-', dictname )
|
||||||
|
FROM
|
||||||
|
`iis_substation_component`
|
||||||
|
LEFT JOIN ( SELECT itemcode, dictname FROM sys_dictionary_items WHERE dictid = 'adb174a6fcd3aa83b58c050215c3136a' ) a ON a.itemcode = device_type
|
||||||
|
WHERE
|
||||||
|
component_id = #{componentId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user