提价代码
parent
54734a4d70
commit
1e59a862ef
|
@ -0,0 +1,488 @@
|
|||
package com.ruoyi.iot.api;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.domain.TowerReqVo;
|
||||
import com.ruoyi.iot.enums.TowerTypeEnums;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 塔吊监测APIController
|
||||
*
|
||||
* @author JiangYuQi
|
||||
* @date 2024-01-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/towerCrane")
|
||||
public class TowerCraneApiController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(TowerCraneApiController.class);
|
||||
|
||||
private final String HOST = "https://aqzg.makalu.cc";
|
||||
private final String DEVSOURCE = "YF";
|
||||
|
||||
private Map<String, Object> cacheMap;
|
||||
|
||||
{
|
||||
cacheMap = new HashMap<>();
|
||||
}
|
||||
/**
|
||||
* 塔吊监测++
|
||||
* 限流规则[60秒内最多请求10次,限流策略IP]
|
||||
* @param req 请求信息
|
||||
* @author JiangYuQi
|
||||
* @date 2024-01-13
|
||||
*/
|
||||
@PostMapping("/v1/push")
|
||||
public AjaxResult pushData(@Validated @RequestBody TowerReqVo req) {
|
||||
if(req.getType() == TowerTypeEnums.BASE.getCode()){
|
||||
this.pushConfigData(req);
|
||||
}else if(req.getType() == TowerTypeEnums.RUN.getCode()){
|
||||
this.pushRunData(req);
|
||||
}else if(req.getType() == TowerTypeEnums.ROUND.getCode()){
|
||||
this.pushRoundData(req);
|
||||
}else if(req.getType() == TowerTypeEnums.COLLIDE.getCode()){
|
||||
this.pushCollideData(req);
|
||||
}else if(req.getType() == TowerTypeEnums.LIMIT.getCode()){
|
||||
this.pushLimitData(req);
|
||||
}else if(req.getType() == TowerTypeEnums.LOCAL.getCode()){
|
||||
this.pushLocalData(req);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报基本信息
|
||||
* @param req
|
||||
*/
|
||||
private void pushConfigData(TowerReqVo req){
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
Map<String, Object> dataContent = req.getContent().getDataContent();
|
||||
|
||||
//将数据同步至马卡鲁安管平台
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("data_source",DEVSOURCE);
|
||||
dataMap.put("device_sn",sn);
|
||||
double rate = Convert.toInt(cacheMap.get("rate_"+sn),2);
|
||||
dataMap.put("base",rate);
|
||||
dataMap.put("coordX",dataContent.get("coordinateX"));
|
||||
dataMap.put("coordY",dataContent.get("coordinateY"));
|
||||
dataMap.put("foreArmLength",dataContent.get("frontBrachium"));
|
||||
dataMap.put("postArmLength",dataContent.get("afterBrachium"));
|
||||
dataMap.put("hatHeight",dataContent.get("towerCapHeight"));
|
||||
double remotePullRod = Convert.toDouble(cacheMap.get("remotePullRod_"+sn),0.00);
|
||||
double nearPullRod = Convert.toDouble(cacheMap.get("nearPullRod_"+sn),0.00);
|
||||
double postPullRod = Convert.toDouble(cacheMap.get("postPullRod_"+sn),0.00);
|
||||
dataMap.put("remotePullRod",remotePullRod);
|
||||
dataMap.put("nearPullRod",nearPullRod);
|
||||
dataMap.put("postPullRod",postPullRod);
|
||||
dataMap.put("downHeight",dataContent.get("towerSectionHeight"));
|
||||
dataMap.put("updateTime", DateUtils.getTime());
|
||||
|
||||
HttpUtil.post(HOST+"/api/device/baseInfo",dataMap,-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报实时数据
|
||||
* @param req
|
||||
*/
|
||||
private void pushRunData(TowerReqVo req){
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
Map<String, Object> dataContent = req.getContent().getDataContent();
|
||||
|
||||
// 将数据同步至马卡鲁安管平台
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("data_source",DEVSOURCE);
|
||||
dataMap.put("deviceSn",sn);
|
||||
dataMap.put("thisTime",System.currentTimeMillis());
|
||||
dataMap.put("weightData",dataContent.get("load"));
|
||||
dataMap.put("tiltData",dataContent.get("leanAngleY"));
|
||||
dataMap.put("windSpeedData",dataContent.get("windSpeed"));
|
||||
String height = Convert.toStr(dataContent.get("height"));
|
||||
dataMap.put("heightData",height);
|
||||
dataMap.put("ampData",dataContent.get("range"));
|
||||
dataMap.put("torqueData",dataContent.get("momentPercent"));
|
||||
dataMap.put("angleData",dataContent.get("rotation"));
|
||||
String dingShengData = Convert.toStr(cacheMap.get("highLimitWarning_"+sn),height);
|
||||
dataMap.put("dingShengData",dingShengData);
|
||||
dataMap.put("walkData",dataContent.get("range"));
|
||||
|
||||
// 将报警数据同步至马卡鲁安管平台
|
||||
if(dataContent.get("warnings")!=null){
|
||||
this.pushWarnData(req);
|
||||
}
|
||||
HttpUtil.post(HOST+"/api/device/runInfo",dataMap,-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报循环数据
|
||||
* @param req
|
||||
*/
|
||||
private void pushRoundData(TowerReqVo req){
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
Map<String, Object> dataContent = req.getContent().getDataContent();
|
||||
|
||||
// 将数据同步至马卡鲁安管平台
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("data_source",DEVSOURCE);
|
||||
dataMap.put("deviceSn",sn);
|
||||
dataMap.put("dataId",System.currentTimeMillis());
|
||||
dataMap.put("startTime",dataContent.get("workStartTime"));
|
||||
dataMap.put("endTime",dataContent.get("workEndTime"));
|
||||
dataMap.put("maxWeight",dataContent.get("maxLoad"));
|
||||
dataMap.put("maxTorque",dataContent.get("maxMomentPercent"));
|
||||
dataMap.put("maxHeight",dataContent.get("maxHeight"));
|
||||
dataMap.put("minHeight",dataContent.get("minHeight"));
|
||||
dataMap.put("maxAmptitude",dataContent.get("maxRange"));
|
||||
dataMap.put("minAmptitude",dataContent.get("minRange"));
|
||||
dataMap.put("maxRotateAngle",dataContent.get("endRotation"));
|
||||
dataMap.put("minRotateAngle",dataContent.get("startRotation"));
|
||||
dataMap.put("createTime",System.currentTimeMillis());
|
||||
|
||||
HttpUtil.post(HOST+"/api/device/roundInfo",dataMap,-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报碰撞信息
|
||||
* @param req
|
||||
*/
|
||||
private void pushCollideData(TowerReqVo req){
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
|
||||
// 将数据同步至马卡鲁安管平台
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("data_source",DEVSOURCE);
|
||||
dataMap.put("deviceSn",sn);
|
||||
dataMap.put("warn_name","none");
|
||||
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","注意碰撞!注意碰撞!");
|
||||
dataMap.put("warn_note","注意碰撞!注意碰撞!");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("collisionAngleAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("collisionAngleAlarm_"+sn),"0"));
|
||||
dataMap.put("warn_time",DateUtils.getTime());
|
||||
|
||||
HttpUtil.post(HOST+"/api/device/warnRecord",dataMap,-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机推送预警信息
|
||||
* @param req
|
||||
*/
|
||||
private void pushWarnData(TowerReqVo req){
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
Map<String, Object> dataContent = req.getContent().getDataContent();
|
||||
|
||||
// 将数据同步至马卡鲁安管平台
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("data_source",DEVSOURCE);
|
||||
dataMap.put("deviceSn",sn);
|
||||
dataMap.put("warn_name","none");
|
||||
if(dataContent.get("warnings")!=null){
|
||||
List<String> warnings = (List<String>)dataContent.get("warnings");
|
||||
for(String warning:warnings){
|
||||
switch (warning){
|
||||
case "1":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","高限位");
|
||||
dataMap.put("warn_note","高限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("highLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("highLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "2":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","低限位");
|
||||
dataMap.put("warn_note","低限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("lowLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("lowLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "3":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","远方限位");
|
||||
dataMap.put("warn_note","远方限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("frontLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("frontLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "4":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","近方限位");
|
||||
dataMap.put("warn_note","近方限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("backLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("backLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "5":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","左转限位");
|
||||
dataMap.put("warn_note","左转限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("leftLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("leftLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "6":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","右转限位");
|
||||
dataMap.put("warn_note","右转限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("rightLimitWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("rightLimitWarning_"+sn),"0"));
|
||||
break;
|
||||
case "7":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","重量预警 1");
|
||||
dataMap.put("warn_note","重量预警 1");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
break;
|
||||
case "8":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","重量预警 2");
|
||||
dataMap.put("warn_note","重量预警 2");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
break;
|
||||
case "9":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","重量预警 3");
|
||||
dataMap.put("warn_note","重量预警 3");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("loadWarning_"+sn),"0"));
|
||||
break;
|
||||
case "10":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","力矩预警 1");
|
||||
dataMap.put("warn_note","力矩预警 1");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
break;
|
||||
case "11":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","力矩预警 2");
|
||||
dataMap.put("warn_note","力矩预警 2");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
break;
|
||||
case "12":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","力矩预警 3");
|
||||
dataMap.put("warn_note","力矩预警 3");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("momentWarning_"+sn),"0"));
|
||||
break;
|
||||
case "13":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","风速过大");
|
||||
dataMap.put("warn_note","风速过大");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("windSpeedWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("windSpeedWarning_"+sn),"0"));
|
||||
break;
|
||||
case "14":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","倾角过大");
|
||||
dataMap.put("warn_note","倾角过大");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("leanWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("leanWarning_"+sn),"0"));
|
||||
break;
|
||||
case "15":
|
||||
dataMap.put("warn_type","1");
|
||||
dataMap.put("warn_context","碰撞预警");
|
||||
dataMap.put("warn_note","碰撞预警");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("collisionDistanceWarning_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("collisionDistanceWarning_"+sn),"0"));
|
||||
break;
|
||||
case "101":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","高限位");
|
||||
dataMap.put("warn_note","高限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("highLimitAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("highLimitAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "102":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","远方限位");
|
||||
dataMap.put("warn_note","远方限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("frontLimitAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("frontLimitAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "103":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","近方限位");
|
||||
dataMap.put("warn_note","近方限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("backLimitAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("backLimitAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "104":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","左转限位");
|
||||
dataMap.put("warn_note","左转限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("leftLimitAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("leftLimitAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "105":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","右转限位");
|
||||
dataMap.put("warn_note","右转限位");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("rightLimitAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("rightLimitAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "106":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","重量超重!重量限制最大值");
|
||||
dataMap.put("warn_note","重量超重!重量限制最大值");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("loadAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("loadAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "107":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","力矩超载!力矩限制最大值");
|
||||
dataMap.put("warn_note","力矩超载!力矩限制最大值");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("momentAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("momentAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "108":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","风速过大");
|
||||
dataMap.put("warn_note","风速过大");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("windSpeedAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("windSpeedAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "109":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","倾角过大");
|
||||
dataMap.put("warn_note","倾角过大");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("leanAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("leanAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "110":
|
||||
dataMap.put("warn_type","2");
|
||||
dataMap.put("warn_context","碰撞报警");
|
||||
dataMap.put("warn_note","碰撞报警");
|
||||
dataMap.put("warn_data",Convert.toStr(cacheMap.get("collisionDistanceAlarm_"+sn),"0"));
|
||||
dataMap.put("real_data",Convert.toStr(cacheMap.get("collisionDistanceAlarm_"+sn),"0"));
|
||||
break;
|
||||
case "201":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","风速仪数据异常");
|
||||
dataMap.put("warn_note","风速仪数据异常");
|
||||
break;
|
||||
case "202":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","高度数据异常");
|
||||
dataMap.put("warn_note","高度数据异常");
|
||||
break;
|
||||
case "203":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","幅度数据异常");
|
||||
dataMap.put("warn_note","幅度数据异常");
|
||||
break;
|
||||
case "204":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","回转数据异常");
|
||||
dataMap.put("warn_note","回转数据异常");
|
||||
break;
|
||||
case "205":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","重量数据异常");
|
||||
dataMap.put("warn_note","重量数据异常");
|
||||
break;
|
||||
case "207":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","力矩数据异常");
|
||||
dataMap.put("warn_note","力矩数据异常");
|
||||
break;
|
||||
case "208":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","人脸识别摄像头异常");
|
||||
dataMap.put("warn_note","人脸识别摄像头异常");
|
||||
break;
|
||||
case "301":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","抽烟警报");
|
||||
dataMap.put("warn_note","抽烟警报");
|
||||
break;
|
||||
case "302":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","打电话警报");
|
||||
dataMap.put("warn_note","打电话警报");
|
||||
break;
|
||||
case "303":
|
||||
dataMap.put("warn_type","3");
|
||||
dataMap.put("warn_context","疲劳警报");
|
||||
dataMap.put("warn_note","疲劳警报");
|
||||
break;
|
||||
default:
|
||||
dataMap.put("warn_type",null);
|
||||
break;
|
||||
}
|
||||
dataMap.put("warn_time",DateUtils.getTime());
|
||||
|
||||
if(Objects.nonNull(dataMap.get("warn_type"))){
|
||||
HttpUtil.post(HOST+"/api/device/warnRecord",dataMap,-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报限位信息
|
||||
* @param req
|
||||
*/
|
||||
private void pushLimitData(TowerReqVo req){
|
||||
System.out.println("d3==>pushLimitData");
|
||||
String sn = req.getContent().getDeviceKey();
|
||||
Map<String, Object> dataContent = req.getContent().getDataContent();
|
||||
|
||||
cacheMap.put("loadWarning_"+sn,dataContent.get("loadWarning"));
|
||||
cacheMap.put("highLimitWarning_"+sn,dataContent.get("highLimitWarning"));
|
||||
cacheMap.put("windSpeedWarning_"+sn,dataContent.get("windSpeedWarning"));
|
||||
cacheMap.put("windSpeedAlarm_"+sn,dataContent.get("windSpeedAlarm"));
|
||||
cacheMap.put("loadAlarm_"+sn,dataContent.get("loadAlarm"));
|
||||
cacheMap.put("momentWarning_"+sn,dataContent.get("momentWarning"));
|
||||
cacheMap.put("momentAlarm_"+sn,dataContent.get("momentAlarm"));
|
||||
cacheMap.put("highLimitAlarm_"+sn,dataContent.get("highLimitAlarm"));
|
||||
cacheMap.put("lowLimitWarning_"+sn,dataContent.get("lowLimitWarning"));
|
||||
cacheMap.put("lowLimitAlarm_"+sn,dataContent.get("lowLimitAlarm"));
|
||||
cacheMap.put("leftLimitWarning_"+sn,dataContent.get("leftLimitWarning"));
|
||||
cacheMap.put("leftLimitAlarm_"+sn,dataContent.get("leftLimitAlarm"));
|
||||
cacheMap.put("rightLimitWarning_"+sn,dataContent.get("rightLimitWarning"));
|
||||
cacheMap.put("rightLimitAlarm_"+sn,dataContent.get("rightLimitAlarm"));
|
||||
cacheMap.put("frontLimitWarning_"+sn,dataContent.get("frontLimitWarning"));
|
||||
cacheMap.put("frontLimitAlarm_"+sn,dataContent.get("frontLimitAlarm"));
|
||||
cacheMap.put("backLimitWarning_"+sn,dataContent.get("backLimitWarning"));
|
||||
cacheMap.put("backLimitAlarm_"+sn,dataContent.get("backLimitAlarm"));
|
||||
cacheMap.put("collisionAngleWarning_"+sn,dataContent.get("collisionAngleWarning"));
|
||||
cacheMap.put("collisionAngleAlarm_"+sn,dataContent.get("collisionAngleAlarm"));
|
||||
cacheMap.put("collisionDistanceWarning_"+sn,dataContent.get("collisionDistanceWarning"));
|
||||
cacheMap.put("collisionDistanceAlarm_"+sn,dataContent.get("collisionDistanceAlarm"));
|
||||
cacheMap.put("hDistanceWarning_"+sn,dataContent.get("hDistanceWarning"));
|
||||
cacheMap.put("hDistanceAlarm_"+sn,dataContent.get("hDistanceAlarm"));
|
||||
cacheMap.put("vDistanceWarning_"+sn,dataContent.get("vDistanceWarning"));
|
||||
cacheMap.put("vDistanceAlarm_"+sn,dataContent.get("vDistanceAlarm"));
|
||||
cacheMap.put("leanWarning_"+sn,dataContent.get("leanWarning"));
|
||||
cacheMap.put("leanAlarm_"+sn,dataContent.get("leanAlarm"));
|
||||
cacheMap.put("rangeLimitStart_"+sn,dataContent.get("rangeLimitStart"));
|
||||
cacheMap.put("rangeLimitEnd_"+sn,dataContent.get("rangeLimitEnd"));
|
||||
cacheMap.put("heightLimitStart_"+sn,dataContent.get("heightLimitStart"));
|
||||
cacheMap.put("heightLimitEnd_"+sn,dataContent.get("heightLimitEnd"));
|
||||
cacheMap.put("rotationLimitStart_"+sn,dataContent.get("rotationLimitStart"));
|
||||
cacheMap.put("rotationLimitEnd_"+sn,dataContent.get("rotationLimitEnd"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 塔机上报标定位信息
|
||||
* @param req
|
||||
*/
|
||||
private void pushLocalData(TowerReqVo req){
|
||||
log.info("pushLocalData...");
|
||||
}
|
||||
}
|
|
@ -14,6 +14,12 @@ public class HzApiConf {
|
|||
* IOT配电箱数据获取HOST
|
||||
*/
|
||||
public static String IOT_POWER_HOST = "http://api.1357.cn/hz-condition-monitor";
|
||||
|
||||
/**
|
||||
* IOT配电箱数据获取HOST&&萨达
|
||||
*/
|
||||
public static String SD_IOT_POWER_HOST = "https://api.e.v1.i-sada.net";
|
||||
|
||||
/**
|
||||
* 标养室获取数据HOST
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,10 @@ public class IotDeviceInfo extends BaseEntity
|
|||
|
||||
private String hzTenantId;
|
||||
private String hzProjectId;
|
||||
|
||||
private String factoryName;
|
||||
private String companyName;
|
||||
private String projectName;
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
@ -121,6 +125,30 @@ public class IotDeviceInfo extends BaseEntity
|
|||
this.hzProjectId = hzProjectId;
|
||||
}
|
||||
|
||||
public String getFactoryName() {
|
||||
return factoryName;
|
||||
}
|
||||
|
||||
public void setFactoryName(String factoryName) {
|
||||
this.factoryName = factoryName;
|
||||
}
|
||||
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public void setCompanyName(String companyName) {
|
||||
this.companyName = companyName;
|
||||
}
|
||||
|
||||
public String getProjectName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.ruoyi.iot.domain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 塔吊检测推送信息 请求内容
|
||||
*
|
||||
* @author: JiangYuQi
|
||||
* @date: 2024/01/13 12:21
|
||||
*/
|
||||
public class TowerContentReqVo {
|
||||
|
||||
/**
|
||||
* 数据产生的时间戳
|
||||
*/
|
||||
private Long time;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 设备序列号,唯一标识 84E0*****
|
||||
*/
|
||||
private String deviceKey;
|
||||
|
||||
/**
|
||||
* 上报内容
|
||||
*/
|
||||
private Map<String, Object> dataContent;
|
||||
|
||||
/**
|
||||
* 碰撞信息
|
||||
*/
|
||||
private Map<String, Object> localDeviceInfo;
|
||||
|
||||
/**
|
||||
* 碰撞塔吊设备信息
|
||||
*/
|
||||
private List<Map<String, Object>> collideTowers;
|
||||
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(String dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public String getDeviceKey() {
|
||||
return deviceKey;
|
||||
}
|
||||
|
||||
public void setDeviceKey(String deviceKey) {
|
||||
this.deviceKey = deviceKey;
|
||||
}
|
||||
|
||||
public Map<String, Object> getDataContent() {
|
||||
return dataContent;
|
||||
}
|
||||
|
||||
public void setDataContent(Map<String, Object> dataContent) {
|
||||
this.dataContent = dataContent;
|
||||
}
|
||||
|
||||
public Map<String, Object> getLocalDeviceInfo() {
|
||||
return localDeviceInfo;
|
||||
}
|
||||
|
||||
public void setLocalDeviceInfo(Map<String, Object> localDeviceInfo) {
|
||||
this.localDeviceInfo = localDeviceInfo;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getCollideTowers() {
|
||||
return collideTowers;
|
||||
}
|
||||
|
||||
public void setCollideTowers(List<Map<String, Object>> collideTowers) {
|
||||
this.collideTowers = collideTowers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ruoyi.iot.domain;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 塔吊检测推送信息 请求参数
|
||||
*
|
||||
* @author: JiangYuQi
|
||||
* @date: 2024/01/13 12:21
|
||||
*/
|
||||
public class TowerReqVo {
|
||||
|
||||
/**
|
||||
* 上报类型
|
||||
*/
|
||||
@NotNull(message = "上报类型不能为空")
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 上报内容
|
||||
*/
|
||||
@NotNull(message = "上报内容不能为空")
|
||||
private TowerContentReqVo content;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TowerContentReqVo getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(TowerContentReqVo content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.ruoyi.iot.enums;
|
||||
|
||||
/**
|
||||
* 塔吊数据类型
|
||||
*/
|
||||
public enum TowerTypeEnums {
|
||||
|
||||
BASE(118,"塔机上报基本信息"),
|
||||
RUN(111,"塔机上报实时数据"),
|
||||
ROUND(119,"塔机上报工作循环数据"),
|
||||
COLLIDE(116,"塔机上报碰撞信息"),
|
||||
LIMIT(120,"塔机上报限位信息"),
|
||||
LOCAL(121,"塔机上报标定位信息");
|
||||
|
||||
private final int code;
|
||||
private final String info;
|
||||
|
||||
TowerTypeEnums(int code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
|
@ -85,6 +85,7 @@ public class GainHzDataTask {
|
|||
|
||||
IotDeviceInfo iotDeviceInfo = new IotDeviceInfo();
|
||||
iotDeviceInfo.setDeviceName("配电箱");
|
||||
iotDeviceInfo.setFactoryName("华筑");
|
||||
List<IotDeviceInfo> iotDeviceInfos = iIotDeviceInfoService.selectIotDeviceInfoList(iotDeviceInfo);
|
||||
iotDeviceInfos.forEach(item -> {
|
||||
if(item.getHzTenantId() != null && item.getHzProjectId() != null) {
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
package com.ruoyi.iot.task;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.conf.HzApiConf;
|
||||
import com.ruoyi.iot.domain.IotDeviceInfo;
|
||||
import com.ruoyi.iot.domain.IotPower;
|
||||
import com.ruoyi.iot.domain.IotWarningInfo;
|
||||
import com.ruoyi.iot.service.IIotDeviceInfoService;
|
||||
import com.ruoyi.iot.service.IIotPowerService;
|
||||
import com.ruoyi.iot.service.IIotWarningInfoService;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 萨达配电箱数据定时任务
|
||||
* @Title: SadaHzDataTask
|
||||
* @Package com.yanzhu.xd.system.task
|
||||
* @Author: JiangYuQi
|
||||
* @Copyright 版权归"陕西马卡鲁信息技术有限公司(或个⼈)"所有
|
||||
* @CreateTime: 2024/10/26 17:05
|
||||
*/
|
||||
@Component("sadaHzDataTask")
|
||||
public class SadaHzDataTask {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SadaHzDataTask.class);
|
||||
|
||||
@Autowired
|
||||
private IIotPowerService iotPowerService;
|
||||
|
||||
@Autowired
|
||||
private IIotWarningInfoService iotWarningInfoService;
|
||||
|
||||
@Autowired
|
||||
private IIotDeviceInfoService iIotDeviceInfoService;
|
||||
|
||||
public static Boolean[] warrning_power_sd = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
||||
|
||||
@Test
|
||||
public void getPowerData() {
|
||||
//获取当前时间是否需要预警两小时预警一次0,2,4,6,8,10,12,14,16,18,20,22
|
||||
Integer t = Integer.valueOf(new SimpleDateFormat("HH").format(new Date()));
|
||||
|
||||
//1.通过接口获取数据
|
||||
Long endTime = System.currentTimeMillis();
|
||||
Long startTime = endTime - HzApiConf.INTERVAL_TIME;
|
||||
|
||||
IotDeviceInfo iotDeviceInfo = new IotDeviceInfo();
|
||||
iotDeviceInfo.setDeviceName("配电箱");
|
||||
iotDeviceInfo.setFactoryName("萨达");
|
||||
List<IotDeviceInfo> iotDeviceInfos = iIotDeviceInfoService.selectIotDeviceInfoList(iotDeviceInfo);
|
||||
iotDeviceInfos.forEach(item -> {
|
||||
String res_str = HttpRequest.get(HzApiConf.SD_IOT_POWER_HOST + "/metric/box/"+item.getDeviceId())
|
||||
.execute().body();
|
||||
JSONObject res = JSONObject.parseObject(res_str).getJSONObject("result");
|
||||
// 电能检测数据
|
||||
JSONObject metric = res.getJSONObject("metric");
|
||||
// 温度检测数据
|
||||
JSONArray temperatures = res.getJSONArray("temperatures");
|
||||
// 漏电检测数据
|
||||
JSONArray leakages = res.getJSONArray("leakages");
|
||||
// 报警数据
|
||||
JSONObject ticketStatus = res.getJSONObject("ticketStatus");
|
||||
List<IotPower> iotPowers = new ArrayList<>(16);
|
||||
List<IotWarningInfo> iotWarningInfos = new ArrayList<>(16);
|
||||
IotPower iotPower = new IotPower();
|
||||
iotPower.setUid(item.getDeviceId());
|
||||
iotPower.setTime(DateUtils.getNowDate());
|
||||
BigDecimal power = metric.getBigDecimal("power_a").add(metric.getBigDecimal("power_b")).add(metric.getBigDecimal("power_c"));
|
||||
iotPower.setPower(power.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP));
|
||||
int leak = 0;
|
||||
for (int i = 0; i < leakages.size(); i++) {
|
||||
JSONObject leakage = leakages.getJSONObject(i);
|
||||
if(Convert.toInt(leakage.get("leakage"),0)>leak){
|
||||
leak = leakage.getInteger("leakage");
|
||||
}
|
||||
}
|
||||
iotPower.setLeak(BigDecimal.valueOf(leak));
|
||||
iotPower.setC1(BigDecimal.valueOf(metric.getFloat("current_a")));
|
||||
iotPower.setC2(BigDecimal.valueOf(metric.getFloat("current_b")));
|
||||
iotPower.setC3(BigDecimal.valueOf(metric.getFloat("current_c")));
|
||||
iotPower.setV1(BigDecimal.valueOf(metric.getFloat("voltage_a")));
|
||||
iotPower.setV2(BigDecimal.valueOf(metric.getFloat("voltage_b")));
|
||||
iotPower.setV3(BigDecimal.valueOf(metric.getFloat("voltage_c")));
|
||||
BigDecimal data = temperatures.getJSONObject(0).getBigDecimal("temperature");
|
||||
iotPower.setT1(data);
|
||||
iotPower.setT2(data);
|
||||
iotPower.setT3(data);
|
||||
iotPower.setT4(data);
|
||||
|
||||
// 预警数据
|
||||
if (t % 2 == 0 && !warrning_power_sd[t]) {
|
||||
warrning_power_sd = new Boolean[]{false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
|
||||
warrning_power_sd[t] = true;
|
||||
|
||||
if(ticketStatus.getInteger("is_blackout")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType("断电预警");
|
||||
iotWarningInfo.setContent("设备触发断电,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
if(ticketStatus.getInteger("is_smoke")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType("烟感报警");
|
||||
iotWarningInfo.setContent("设备烟感报警,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
if(ticketStatus.getInteger("is_overload")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType("过载报警");
|
||||
iotWarningInfo.setContent("设备过载报警,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
if(ticketStatus.getInteger("is_disconnect")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType("断开报警");
|
||||
iotWarningInfo.setContent("设备断开报警,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
if(ticketStatus.getInteger("is_overheat")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType(" 高温报警");
|
||||
iotWarningInfo.setContent("设备高温报警,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
if(ticketStatus.getInteger("is_leakage")>0){
|
||||
IotWarningInfo iotWarningInfo = new IotWarningInfo();
|
||||
iotWarningInfo.setDeviceId(iotPower.getUid());
|
||||
iotWarningInfo.setType(" 漏电报警");
|
||||
iotWarningInfo.setContent("设备漏电报警,请排查异常情况");
|
||||
iotWarningInfo.setCreateTime(new Date());
|
||||
iotWarningInfos.add(iotWarningInfo);
|
||||
}
|
||||
}
|
||||
|
||||
iotPowers.add(iotPower);
|
||||
|
||||
if (iotPowers.size() > 0) {
|
||||
iotPowerService.batchInsertPower(iotPowers);
|
||||
}
|
||||
if (iotWarningInfos.size() > 0) {
|
||||
iotWarningInfoService.batchInsertWarning(iotWarningInfos);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -14,10 +14,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="typeName" column="type_name" />
|
||||
<result property="hzTenantId" column="hz_tenant_id" />
|
||||
<result property="hzProjectId" column="hz_project_id" />
|
||||
<result property="factoryName" column="factory_name" />
|
||||
<result property="companyName" column="company_name" />
|
||||
<result property="projectName" column="project_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectIotDeviceInfoVo">
|
||||
select id, device_id, device_name, state, project_id, points,type_name,hz_tenant_id,hz_project_id from iot_device_info
|
||||
select id, device_id, device_name, state, project_id, points, type_name, hz_tenant_id, hz_project_id, factory_name, company_name, project_name from iot_device_info
|
||||
</sql>
|
||||
|
||||
<select id="selectIotDeviceInfoList" parameterType="IotDeviceInfo" resultMap="IotDeviceInfoResult">
|
||||
|
@ -29,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="projectId != null "> and project_id = #{projectId}</if>
|
||||
<if test="points != null "> and points = #{points}</if>
|
||||
<if test="typeName != null "> and type_name = #{typeName}</if>
|
||||
<if test="factoryName != null and factoryName != ''"> and factory_name = #{factoryName}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
|
|
@ -2,15 +2,14 @@ package com.ruoyi.api.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.api.service.ApiService;
|
||||
import com.sun.org.apache.xpath.internal.operations.Mod;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @ClassName:ApiController
|
||||
|
|
Loading…
Reference in New Issue