济南拓兴添加高支模数据
This commit is contained in:
parent
6223e3fdd7
commit
2a06c95f3b
@ -5,15 +5,19 @@ import com.zhgd.netty.tcp.constant.HighFormworkSupport;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.*;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.vo.HighFormworkMeasureCurrentDataAlarmStateEnum;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.*;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkAlarmDataService;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkMeasureCurrentDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -36,6 +40,9 @@ public class HighFormworkSupportService {
|
||||
private HighFormworkAlarmDataMapper highFormworkAlarmDataMapper;
|
||||
@Autowired
|
||||
private HighFormworkMeasurePointThresholdMapper highFormworkMeasurePointThresholdMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IHighFormworkAlarmDataService highFormworkAlarmDataService;
|
||||
|
||||
public void saveTcpData(String msg) throws ParseException {
|
||||
/*
|
||||
@ -214,7 +221,7 @@ public class HighFormworkSupportService {
|
||||
HighFormworkMeasureCurrentData currentData = getAndSaveHighFormworkMeasureCurrentData(dataMap, no, no2, no3, no4, no5, no6, point);
|
||||
|
||||
//插入报警/预警数据
|
||||
addAlarmData(point, currentData);
|
||||
highFormworkAlarmDataService.addAlarmData(point, currentData);
|
||||
|
||||
}
|
||||
|
||||
@ -310,97 +317,6 @@ public class HighFormworkSupportService {
|
||||
currentData.setAlarmState(alarmState);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入报警/预警数据
|
||||
*
|
||||
* @param point
|
||||
* @param currentData
|
||||
*/
|
||||
private void addAlarmData(HighFormworkMeasurePoint point, HighFormworkMeasureCurrentData currentData) {
|
||||
boolean isAlarm = false;
|
||||
boolean isWarn = false;
|
||||
List<HighFormworkMeasurePointThreshold> thresholds = highFormworkMeasurePointThresholdMapper.selectList(new LambdaQueryWrapper<HighFormworkMeasurePointThreshold>()
|
||||
.eq(HighFormworkMeasurePointThreshold::getMeasurePointId, point.getId()));
|
||||
if (CollectionUtils.isNotEmpty(thresholds)) {
|
||||
for (HighFormworkMeasurePointThreshold threshold : thresholds) {
|
||||
Integer type = threshold.getType();
|
||||
Double alarmValue = StringUtils.isNotBlank(threshold.getAlarmValue()) ? Double.valueOf(threshold.getAlarmValue()) : null;
|
||||
Double warningValue = StringUtils.isNotBlank(threshold.getWarningValue()) ? Double.valueOf(threshold.getWarningValue()) : null;
|
||||
//类型:1立杆轴力2水平位移3模板沉降4立杆倾斜5地基沉降
|
||||
if (type == 1) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getPoleAxialForce()) ? Double.valueOf(currentData.getPoleAxialForce()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 1, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 1, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getHorizontalDisplacement()) ? Double.valueOf(currentData.getHorizontalDisplacement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 2, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 2, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 3) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getFormworkSettlement()) ? Double.valueOf(currentData.getFormworkSettlement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 3, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 3, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 4) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getPoleTilt()) ? Double.valueOf(currentData.getPoleTilt()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 4, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 4, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 5) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getFoundationSettlement()) ? Double.valueOf(currentData.getFoundationSettlement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 5, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 5, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HighFormworkMeasurePoint tempHighFormworkMeasurePoint = new HighFormworkMeasurePoint();
|
||||
tempHighFormworkMeasurePoint.setId(point.getId());
|
||||
tempHighFormworkMeasurePoint.setRealTime(new Date());
|
||||
tempHighFormworkMeasurePoint.setAlarmState(isAlarm ? 3 : (isWarn ? 2 : 1));
|
||||
highFormworkMeasurePointMapper.updateById(tempHighFormworkMeasurePoint);
|
||||
}
|
||||
|
||||
private void insertHighFormworkAlarmData(HighFormworkMeasurePoint point, Double electricPower, Integer type, Integer warningValue) {
|
||||
HighFormworkAlarmData highFormworkAlarmData = new HighFormworkAlarmData();
|
||||
highFormworkAlarmData.setType(type);
|
||||
highFormworkAlarmData.setMeasurePointId(point.getId());
|
||||
highFormworkAlarmData.setAlarmValue(String.valueOf(electricPower));
|
||||
highFormworkAlarmData.setAlarmType(warningValue);
|
||||
highFormworkAlarmData.setProjectSn(point.getProjectSn());
|
||||
highFormworkAlarmDataMapper.insert(highFormworkAlarmData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取测点状态
|
||||
|
||||
@ -2,12 +2,10 @@ package com.zhgd.xmgl.modules.highformwork.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasureCurrentData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.vo.BigScreenHighFormworkVo;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.vo.DataPerHourForTheLastDayVo;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkMeasureCurrentDataService;
|
||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -46,7 +44,7 @@ public class HighFormworkMeasureCurrentDataController {
|
||||
@ApiOperation(value = "分页列表查询高支模-测量点实时数据信息", notes = "分页列表查询高支模-测量点实时数据信息", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "measurePointNumber", value = "监测点编号", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "acquisitionInstrumentNumber", value = "采集仪编号(联瑞科-终端编号)", paramType = "query", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "acquisitionInstrumentNumber", value = "采集仪编号(联瑞科-终端编号)", paramType = "query", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "startTime", value = "开始时间,格式2021-05-08", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间,格式2021-05-08", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "alarmState", value = "报警状态,1正常,2预警,3报警", paramType = "body", required = false, dataType = "String"),
|
||||
|
||||
@ -31,10 +31,10 @@
|
||||
and hfmcd.collect_time <= CONCAT(DATE_FORMAT(#{param.endTime}, "%Y-%m-%d"), ' 23:59:59')
|
||||
</if>
|
||||
<if test="param.measurePointNumber != null and param.measurePointNumber != ''">
|
||||
and hfmcd.measure_point_number like CONCAT(CONCAT('%', #{param.measurePointNumber}), '%')
|
||||
and hfmcd.measure_point_number like #{param.measurePointNumber}
|
||||
</if>
|
||||
<if test="param.acquisitionInstrumentNumber != null and param.acquisitionInstrumentNumber != ''">
|
||||
and hfmcd.acquisition_instrument_number like CONCAT(CONCAT('%', #{param.acquisitionInstrumentNumber}), '%')
|
||||
and hfmcd.acquisition_instrument_number like #{param.acquisitionInstrumentNumber}
|
||||
</if>
|
||||
<if test="param.alarmState != null and param.alarmState != ''">
|
||||
and hfmcd.alarm_state = #{param.alarmState}
|
||||
|
||||
@ -5,6 +5,8 @@ import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkAlarmData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasureCurrentData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasurePoint;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.vo.NumberDifferentTypesAlarmsRadarChartOneMonthVo;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -24,4 +26,11 @@ public interface IHighFormworkAlarmDataService extends IService<HighFormworkAlar
|
||||
List<NumberDifferentTypesAlarmsRadarChartOneMonthVo> getNumberDifferentTypesAlarmsRadarChartOneMonth(Map<String, Object> map);
|
||||
|
||||
List<EntityMap> getAlarmCycleTrendGraph(Map<String, Object> map);
|
||||
|
||||
/**
|
||||
* 插入报警/预警数据
|
||||
* @param point
|
||||
* @param currentData
|
||||
*/
|
||||
void addAlarmData(HighFormworkMeasurePoint point, HighFormworkMeasureCurrentData currentData);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.highformwork.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -7,14 +8,23 @@ import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.modules.discharging.service.impl.DischargingPlatformAlarmServiceImpl;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkAlarmData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasureCurrentData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasurePoint;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasurePointThreshold;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.vo.NumberDifferentTypesAlarmsRadarChartOneMonthVo;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkAlarmDataMapper;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkMeasurePointMapper;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkMeasurePointThresholdMapper;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkAlarmDataService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@ -31,6 +41,12 @@ public class HighFormworkAlarmDataServiceImpl extends ServiceImpl<HighFormworkAl
|
||||
private DischargingPlatformAlarmServiceImpl dischargingPlatformAlarmService;
|
||||
@Autowired
|
||||
private HighFormworkAlarmDataMapper highFormworkAlarmDataMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private HighFormworkMeasurePointMapper highFormworkMeasurePointMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private HighFormworkMeasurePointThresholdMapper highFormworkMeasurePointThresholdMapper;
|
||||
|
||||
@Override
|
||||
public Result<IPage<HighFormworkAlarmData>> queryPageList(HighFormworkAlarmData highFormworkAlarmData, Integer pageNo, Integer pageSize, HttpServletRequest req) {
|
||||
@ -57,6 +73,93 @@ public class HighFormworkAlarmDataServiceImpl extends ServiceImpl<HighFormworkAl
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAlarmData(HighFormworkMeasurePoint point, HighFormworkMeasureCurrentData currentData) {
|
||||
boolean isAlarm = false;
|
||||
boolean isWarn = false;
|
||||
List<HighFormworkMeasurePointThreshold> thresholds = highFormworkMeasurePointThresholdMapper.selectList(new LambdaQueryWrapper<HighFormworkMeasurePointThreshold>()
|
||||
.eq(HighFormworkMeasurePointThreshold::getMeasurePointId, point.getId()));
|
||||
if (CollectionUtils.isNotEmpty(thresholds)) {
|
||||
for (HighFormworkMeasurePointThreshold threshold : thresholds) {
|
||||
Integer type = threshold.getType();
|
||||
Double alarmValue = StringUtils.isNotBlank(threshold.getAlarmValue()) ? Double.valueOf(threshold.getAlarmValue()) : null;
|
||||
Double warningValue = StringUtils.isNotBlank(threshold.getWarningValue()) ? Double.valueOf(threshold.getWarningValue()) : null;
|
||||
//类型:1立杆轴力2水平位移3模板沉降4立杆倾斜5地基沉降
|
||||
if (type == 1) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getPoleAxialForce()) ? Double.valueOf(currentData.getPoleAxialForce()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 1, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 1, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getHorizontalDisplacement()) ? Double.valueOf(currentData.getHorizontalDisplacement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 2, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 2, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 3) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getFormworkSettlement()) ? Double.valueOf(currentData.getFormworkSettlement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 3, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 3, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 4) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getPoleTilt()) ? Double.valueOf(currentData.getPoleTilt()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 4, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 4, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
} else if (type == 5) {
|
||||
Double subside = StringUtils.isNotBlank(currentData.getFoundationSettlement()) ? Double.valueOf(currentData.getFoundationSettlement()) : null;
|
||||
if (subside != null && alarmValue != null && alarmValue < subside) {
|
||||
//报警
|
||||
insertHighFormworkAlarmData(point, subside, 5, 1);
|
||||
isAlarm = true;
|
||||
} else if (subside != null && warningValue != null && warningValue < subside) {
|
||||
//预警
|
||||
insertHighFormworkAlarmData(point, subside, 5, 2);
|
||||
isWarn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HighFormworkMeasurePoint tempHighFormworkMeasurePoint = new HighFormworkMeasurePoint();
|
||||
tempHighFormworkMeasurePoint.setId(point.getId());
|
||||
tempHighFormworkMeasurePoint.setRealTime(new Date());
|
||||
tempHighFormworkMeasurePoint.setAlarmState(isAlarm ? 3 : (isWarn ? 2 : 1));
|
||||
highFormworkMeasurePointMapper.updateById(tempHighFormworkMeasurePoint);
|
||||
}
|
||||
|
||||
private void insertHighFormworkAlarmData(HighFormworkMeasurePoint point, Double electricPower, Integer type, Integer warningValue) {
|
||||
HighFormworkAlarmData highFormworkAlarmData = new HighFormworkAlarmData();
|
||||
highFormworkAlarmData.setType(type);
|
||||
highFormworkAlarmData.setMeasurePointId(point.getId());
|
||||
highFormworkAlarmData.setAlarmValue(String.valueOf(electricPower));
|
||||
highFormworkAlarmData.setAlarmType(warningValue);
|
||||
highFormworkAlarmData.setProjectSn(point.getProjectSn());
|
||||
baseMapper.insert(highFormworkAlarmData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补全数据
|
||||
*
|
||||
|
||||
@ -353,6 +353,10 @@ public class Project implements Serializable {
|
||||
/**位置json*/
|
||||
@ApiModelProperty(value="位置json")
|
||||
private java.lang.String positionJson ;
|
||||
@ApiModelProperty(value = "济南拓兴appKey")
|
||||
private String jntxAppKey;
|
||||
@ApiModelProperty(value = "济南拓兴appSecret")
|
||||
private String jntxAppSecret;
|
||||
/**
|
||||
* runde平台token
|
||||
*/
|
||||
|
||||
@ -1,20 +1,36 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.base.Objects;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkDeviceCurrentData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasureCurrentData;
|
||||
import com.zhgd.xmgl.modules.highformwork.entity.HighFormworkMeasurePoint;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkDeviceCurrentDataMapper;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkMeasureCurrentDataMapper;
|
||||
import com.zhgd.xmgl.modules.highformwork.mapper.HighFormworkMeasurePointMapper;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkAlarmDataService;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkMeasureCurrentDataService;
|
||||
import com.zhgd.xmgl.modules.highformwork.service.IHighFormworkMeasurePointService;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.util.JntxUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @program: wisdomSite
|
||||
@ -25,53 +41,64 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HighFormworkTask {
|
||||
@Lazy
|
||||
@Autowired
|
||||
IProjectService projectService;
|
||||
@Autowired
|
||||
private HighFormworkMeasureCurrentDataMapper highFormworkMeasureCurrentDataMapper;
|
||||
@Autowired
|
||||
private HighFormworkDeviceCurrentDataMapper highFormworkDeviceCurrentDataMapper;
|
||||
@Autowired
|
||||
private HighFormworkMeasurePointMapper highFormworkMeasurePointMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IHighFormworkMeasurePointService highFormworkMeasurePointService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IHighFormworkAlarmDataService highFormworkAlarmDataService;
|
||||
@Autowired
|
||||
private IHighFormworkMeasureCurrentDataService dataService;
|
||||
|
||||
/**
|
||||
* 1小时报警推送
|
||||
*/
|
||||
@Scheduled(cron = "0 0 */5 * * ?")
|
||||
@SchedulerLock(name = "measureCurrentDataTask", lockAtMostFor = 1000*60*30, lockAtLeastFor = 1000*60*5)
|
||||
@SchedulerLock(name = "measureCurrentDataTask", lockAtMostFor = 1000 * 60 * 30, lockAtLeastFor = 1000 * 60 * 5)
|
||||
public void measureCurrentDataTask() {
|
||||
try {
|
||||
QueryWrapper<HighFormworkMeasurePoint> queryWrapper=new QueryWrapper<>();
|
||||
List<HighFormworkMeasurePoint> list=highFormworkMeasurePointMapper.selectList(queryWrapper);
|
||||
if(list!=null&&list.size()>0){
|
||||
for(HighFormworkMeasurePoint point:list){
|
||||
QueryWrapper<HighFormworkMeasurePoint> queryWrapper = new QueryWrapper<>();
|
||||
List<HighFormworkMeasurePoint> list = highFormworkMeasurePointMapper.selectList(queryWrapper);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (HighFormworkMeasurePoint point : list) {
|
||||
//倾角
|
||||
HighFormworkDeviceCurrentData data1=highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(),1);
|
||||
HighFormworkDeviceCurrentData data1 = highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(), 1);
|
||||
//压力
|
||||
HighFormworkDeviceCurrentData data2=highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(),2);
|
||||
HighFormworkDeviceCurrentData data2 = highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(), 2);
|
||||
//沉降
|
||||
HighFormworkDeviceCurrentData data3=highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(),3);
|
||||
if(data1!=null||data2!=null||data3!=null){
|
||||
HighFormworkMeasureCurrentData highFormworkMeasureCurrentData=new HighFormworkMeasureCurrentData();
|
||||
HighFormworkDeviceCurrentData data3 = highFormworkDeviceCurrentDataMapper.getNewMeasureCurrentDataByType(point.getId(), 3);
|
||||
if (data1 != null || data2 != null || data3 != null) {
|
||||
HighFormworkMeasureCurrentData highFormworkMeasureCurrentData = new HighFormworkMeasureCurrentData();
|
||||
highFormworkMeasureCurrentData.setProjectSn(point.getProjectSn());
|
||||
highFormworkMeasureCurrentData.setMeasurePointNumber(point.getMeasurePointNumber());
|
||||
highFormworkMeasureCurrentData.setAcquisitionInstrumentNumber(point.getAcquisitionInstrumentNumber());
|
||||
Integer alarmState=1;
|
||||
if(data1!=null){
|
||||
Integer alarmState = 1;
|
||||
if (data1 != null) {
|
||||
highFormworkMeasureCurrentData.setAngleXAxis(data1.getDataValue());
|
||||
alarmState=data1.getAlarmState();
|
||||
alarmState = data1.getAlarmState();
|
||||
}
|
||||
if(data2!=null){
|
||||
if (data2 != null) {
|
||||
highFormworkMeasureCurrentData.setPressure(data2.getDataValue());
|
||||
if(alarmState!=3){
|
||||
if(data2.getAlarmState()!=1){
|
||||
alarmState=data2.getAlarmState();
|
||||
if (alarmState != 3) {
|
||||
if (data2.getAlarmState() != 1) {
|
||||
alarmState = data2.getAlarmState();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data3!=null){
|
||||
if (data3 != null) {
|
||||
highFormworkMeasureCurrentData.setSubside(data3.getDataValue());
|
||||
if(alarmState!=3){
|
||||
if(data3.getAlarmState()!=1){
|
||||
alarmState=data3.getAlarmState();
|
||||
if (alarmState != 3) {
|
||||
if (data3.getAlarmState() != 1) {
|
||||
alarmState = data3.getAlarmState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,4 +112,63 @@ public class HighFormworkTask {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 济南拓兴获取高支模数据
|
||||
*/
|
||||
@Scheduled(cron = "* */5 * * * ?")
|
||||
@SchedulerLock(name = "getHighFormworkDatas", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60)
|
||||
public void getHighFormworkDatas() {
|
||||
List<Project> projectList = projectService.list(new LambdaQueryWrapper<Project>().isNotNull(Project::getJntxAppKey).isNotNull(Project::getJntxAppSecret).ne(Project::getJntxAppKey, "").ne(Project::getJntxAppSecret, ""));
|
||||
for (Project project : projectList) {
|
||||
List<HighFormworkMeasurePoint> measurePoints = highFormworkMeasurePointService.list(new LambdaQueryWrapper<HighFormworkMeasurePoint>()
|
||||
.eq(HighFormworkMeasurePoint::getProjectSn, project.getProjectSn()));
|
||||
if (CollUtil.isNotEmpty(measurePoints)) {
|
||||
String devsns = measurePoints.stream().map(HighFormworkMeasurePoint::getAcquisitionInstrumentNumber).filter(StrUtil::isNotBlank).collect(Collectors.joining(","));
|
||||
if (StrUtil.isBlank(devsns)) {
|
||||
continue;
|
||||
}
|
||||
JSONObject jo = JntxUtil.sendHttpToGetHighFormworkDatas(project.getJntxAppKey(), project.getJntxAppSecret(), devsns);
|
||||
if (!Objects.equal(jo.getInteger("code"), 0)) {
|
||||
log.error("济南拓兴获取高支模数据错误:项目:{},错误:{}", project.getProjectName(), JSONArray.toJSONString(jo));
|
||||
continue;
|
||||
}
|
||||
JSONArray datas = jo.getJSONArray("data");
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
JSONObject data = datas.getJSONObject(i);
|
||||
addHighFormworkData(measurePoints, data, "1");
|
||||
addHighFormworkData(measurePoints, data, "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加高支模数据
|
||||
*
|
||||
* @param measurePoints
|
||||
* @param data
|
||||
* @param no 1路或2路
|
||||
*/
|
||||
private void addHighFormworkData(List<HighFormworkMeasurePoint> measurePoints, JSONObject data, String no) {
|
||||
Optional<HighFormworkMeasurePoint> op1 = measurePoints.stream().filter(h -> Objects.equal(h.getAcquisitionInstrumentNumber(), data.getString("sn")) && Objects.equal(h.getMeasurePointNumber(), no)).findFirst();
|
||||
if (op1.isPresent()) {
|
||||
HighFormworkMeasureCurrentData currentData = new HighFormworkMeasureCurrentData();
|
||||
HighFormworkMeasurePoint point = op1.get();
|
||||
currentData.setMeasurePointNumber(point.getMeasurePointNumber());
|
||||
currentData.setProjectSn(point.getProjectSn());
|
||||
currentData.setCollectTime(DateUtil.parseDateTime(data.getString("updateTime")));
|
||||
currentData.setAngleXAxis(data.getString("dipX" + no));
|
||||
currentData.setAngleYAxis(data.getString("dipY" + no));
|
||||
Double poleAxialForce = data.getDouble("weight" + no);
|
||||
if (poleAxialForce != null) {
|
||||
poleAxialForce = poleAxialForce * 1000;
|
||||
}
|
||||
currentData.setPoleAxialForce(Convert.toStr(poleAxialForce));
|
||||
currentData.setHorizontalDisplacement(data.getString("spanX" + no));
|
||||
currentData.setFormworkSettlement(data.getString("down" + no));
|
||||
currentData.setAcquisitionInstrumentNumber(point.getAcquisitionInstrumentNumber());
|
||||
dataService.save(currentData);
|
||||
highFormworkAlarmDataService.addAlarmData(point, currentData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
src/main/java/com/zhgd/xmgl/util/JntxUtil.java
Normal file
78
src/main/java/com/zhgd/xmgl/util/JntxUtil.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhgd.jeecg.common.util.pass.HttpUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* 济南拓兴工具类
|
||||
*/
|
||||
public class JntxUtil {
|
||||
/**
|
||||
* 生成签名
|
||||
*
|
||||
* @param appSecret 应用密钥
|
||||
* @param deviceCode 设备编号
|
||||
* @param timestamp 时间戳
|
||||
* @return 32位MD5签名
|
||||
*/
|
||||
public static String getSignature(String appSecret, String deviceCode, long timestamp) {
|
||||
try {
|
||||
// 拼接字符串:AppSecret + 设备编号 + 时间戳
|
||||
String signStr = appSecret + deviceCode + timestamp;
|
||||
|
||||
// 生成MD5签名
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md.digest(signStr.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 转换为32位十六进制字符串
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : digest) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException("MD5算法不支持", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载方法:使用当前时间戳
|
||||
*/
|
||||
public static String getSignature(String appSecret, String deviceCode) {
|
||||
return getSignature(appSecret, deviceCode, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long l = System.currentTimeMillis();
|
||||
System.out.println("timestamp:" + l);
|
||||
System.out.println(getSignature("84D462DE6D624031B17CA671AE00EF05", "7000021", l));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送http获取高支模数据
|
||||
*
|
||||
* @param jntxAppKey
|
||||
* @param jntxAppSecret
|
||||
* @param devsns
|
||||
* @return
|
||||
*/
|
||||
public static JSONObject sendHttpToGetHighFormworkDatas(String jntxAppKey, String jntxAppSecret, String devsns) {
|
||||
long l = System.currentTimeMillis();
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("appKey", jntxAppKey);
|
||||
body.put("devSns", devsns);
|
||||
body.put("signature", getSignature(jntxAppSecret, devsns, l));
|
||||
body.put("timeStemp", l);
|
||||
JSONObject jsonObject = HttpUtils.sendPostBodyRtJo("请求济南拓兴获取高支模数据", "http://api.tuoxing888.com/api/v1/gaozhimo/realdata", body, 1000 * 10, null);
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user