|
@@ -11,6 +11,7 @@ import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
|
|
|
+import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
|
|
|
import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
|
|
@@ -25,17 +26,17 @@ import com.sckw.slope.detection.model.param.IntegrationQuery;
|
|
|
import com.sckw.slope.detection.model.vo.IntegrationVo;
|
|
import com.sckw.slope.detection.model.vo.IntegrationVo;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
|
|
|
|
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author sky
|
|
* @author sky
|
|
@@ -75,12 +76,11 @@ public class BackTrackService {
|
|
|
InsTablesMapper insTablesMapper;
|
|
InsTablesMapper insTablesMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
public HttpResult getParts(String projectId) {
|
|
public HttpResult getParts(String projectId) {
|
|
|
//首先获取项目中全部设备
|
|
//首先获取项目中全部设备
|
|
|
List<DeviceDataDTO> list = deviceMapper.selectAllDeviceByProject(projectId);
|
|
List<DeviceDataDTO> list = deviceMapper.selectAllDeviceByProject(projectId);
|
|
|
List<String> devicesId = list.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
List<String> devicesId = list.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
|
- if(devicesId.size() == 0){
|
|
|
|
|
|
|
+ if (devicesId.size() == 0) {
|
|
|
return HttpResult.ok(Collections.emptyList());
|
|
return HttpResult.ok(Collections.emptyList());
|
|
|
}
|
|
}
|
|
|
//在获取设备的要素
|
|
//在获取设备的要素
|
|
@@ -93,13 +93,13 @@ public class BackTrackService {
|
|
|
put("code", DictEnum.MODEL_PART.getCodeType());
|
|
put("code", DictEnum.MODEL_PART.getCodeType());
|
|
|
put("type", "1");
|
|
put("type", "1");
|
|
|
}});
|
|
}});
|
|
|
- for (KwsDeviceReference re : references){
|
|
|
|
|
|
|
+ for (KwsDeviceReference re : references) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
return HttpResult.ok(references);
|
|
return HttpResult.ok(references);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public HttpResult getDeviceByParts(String parts,String projectId) {
|
|
|
|
|
|
|
+ public HttpResult getDeviceByParts(String parts, String projectId) {
|
|
|
//获取项目中的设备
|
|
//获取项目中的设备
|
|
|
List<DeviceDataDTO> listDevice = deviceMapper.selectAllDeviceByProject(projectId);
|
|
List<DeviceDataDTO> listDevice = deviceMapper.selectAllDeviceByProject(projectId);
|
|
|
List<String> devicesId = listDevice.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
List<String> devicesId = listDevice.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
@@ -113,7 +113,7 @@ public class BackTrackService {
|
|
|
);
|
|
);
|
|
|
//获取对应的设备
|
|
//获取对应的设备
|
|
|
List<Long> devicesIds = references.stream().map(KwsDeviceReference::getDeviceId).toList();
|
|
List<Long> devicesIds = references.stream().map(KwsDeviceReference::getDeviceId).toList();
|
|
|
- if(Objects.isNull(devicesIds)){
|
|
|
|
|
|
|
+ if (Objects.isNull(devicesIds)) {
|
|
|
return HttpResult.ok(Collections.emptyList());
|
|
return HttpResult.ok(Collections.emptyList());
|
|
|
}
|
|
}
|
|
|
List<KwsDevice> devices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>()
|
|
List<KwsDevice> devices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>()
|
|
@@ -123,12 +123,12 @@ public class BackTrackService {
|
|
|
return HttpResult.ok(devices);
|
|
return HttpResult.ok(devices);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public HttpResult getDeviceChart(String devicesId,String snCode, String parts, String dateStart,String dateEnd,Integer original) throws ParseException {
|
|
|
|
|
|
|
+ public HttpResult getDeviceChart(String devicesId, String snCode, String parts, String dateStart, String dateEnd, Integer original) throws ParseException {
|
|
|
//先查询设备
|
|
//先查询设备
|
|
|
KwsDevice deviceHas = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
KwsDevice deviceHas = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
.eq(KwsDevice::getSnCode, snCode));
|
|
.eq(KwsDevice::getSnCode, snCode));
|
|
|
String[] arr = parts.split(",");
|
|
String[] arr = parts.split(",");
|
|
|
- if(!DeviceEnum.ALREADY_REFERRED_TO.getStatus().equals(deviceHas.getStatus().toString())){//未基准
|
|
|
|
|
|
|
+ if (!DeviceEnum.ALREADY_REFERRED_TO.getStatus().equals(deviceHas.getStatus().toString())) {//未基准
|
|
|
try {
|
|
try {
|
|
|
InsTables insTables = insTablesMapper.selectTableIsExit("device_" + snCode);
|
|
InsTables insTables = insTablesMapper.selectTableIsExit("device_" + snCode);
|
|
|
if (insTables == null) {
|
|
if (insTables == null) {
|
|
@@ -139,21 +139,21 @@ public class BackTrackService {
|
|
|
return HttpResult.ok(Collections.emptyList());
|
|
return HttpResult.ok(Collections.emptyList());
|
|
|
}
|
|
}
|
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByArray(snCode, arr, dateStart, dateEnd);
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByArray(snCode, arr, dateStart, dateEnd);
|
|
|
- Map<String,List<Object>> map = new HashMap<>();
|
|
|
|
|
|
|
+ Map<String, List<Object>> map = new HashMap<>();
|
|
|
|
|
|
|
|
if (Objects.isNull(selectedData)) {
|
|
if (Objects.isNull(selectedData)) {
|
|
|
- map = commonService.getDateByNull(dateStart,dateEnd,arr);
|
|
|
|
|
|
|
+ map = commonService.getDateByNull(dateStart, dateEnd, arr);
|
|
|
return HttpResult.ok(map);
|
|
return HttpResult.ok(map);
|
|
|
}
|
|
}
|
|
|
Collections.reverse(selectedData);
|
|
Collections.reverse(selectedData);
|
|
|
- for(SlopeData slop : selectedData){
|
|
|
|
|
- if(slop.getLine().equals(DictItemEnum.getData(slop.getLine()).getValue())){
|
|
|
|
|
|
|
+ for (SlopeData slop : selectedData) {
|
|
|
|
|
+ if (slop.getLine().equals(DictItemEnum.getData(slop.getLine()).getValue())) {
|
|
|
List<Object> list = new ArrayList<>();
|
|
List<Object> list = new ArrayList<>();
|
|
|
list.add(slop);
|
|
list.add(slop);
|
|
|
- if(map.containsKey(slop.getLine())){
|
|
|
|
|
|
|
+ if (map.containsKey(slop.getLine())) {
|
|
|
map.get(slop.getLine()).add(slop);
|
|
map.get(slop.getLine()).add(slop);
|
|
|
- }else{
|
|
|
|
|
- map.put(slop.getLine(),list);
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ map.put(slop.getLine(), list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -169,9 +169,9 @@ public class BackTrackService {
|
|
|
);
|
|
);
|
|
|
//获取基准值的纬度,X轴偏移量需要
|
|
//获取基准值的纬度,X轴偏移量需要
|
|
|
double angleInRadians = 0;
|
|
double angleInRadians = 0;
|
|
|
- for(KwsDeviceReference element : references) {
|
|
|
|
|
|
|
+ for (KwsDeviceReference element : references) {
|
|
|
if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {
|
|
if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {
|
|
|
- if(!Objects.isNull(element.getValue())){
|
|
|
|
|
|
|
+ if (!Objects.isNull(element.getValue())) {
|
|
|
angleInRadians = element.getValue().doubleValue();
|
|
angleInRadians = element.getValue().doubleValue();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -186,19 +186,19 @@ public class BackTrackService {
|
|
|
|
|
|
|
|
//获取偏移量
|
|
//获取偏移量
|
|
|
Map<String, Object> mapList = new HashMap<>();
|
|
Map<String, Object> mapList = new HashMap<>();
|
|
|
- for (String st : arr){
|
|
|
|
|
- mapList.put(st,"");
|
|
|
|
|
|
|
+ for (String st : arr) {
|
|
|
|
|
+ mapList.put(st, "");
|
|
|
}
|
|
}
|
|
|
- for(KwsDeviceReference element : references) {
|
|
|
|
|
- int index = Arrays.binarySearch(arr,element.getItem());
|
|
|
|
|
- if(index<=0){
|
|
|
|
|
|
|
+ for (KwsDeviceReference element : references) {
|
|
|
|
|
+ int index = Arrays.binarySearch(arr, element.getItem());
|
|
|
|
|
+ if (index <= 0) {
|
|
|
//continue;
|
|
//continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- BigDecimal currentValue = new BigDecimal("0.00");
|
|
|
|
|
- if(original == 1){
|
|
|
|
|
|
|
+ BigDecimal currentValue = new BigDecimal("0.00");
|
|
|
|
|
+ if (original == 1) {
|
|
|
currentValue = element.getOriginalValue();//以原始基准参考
|
|
currentValue = element.getOriginalValue();//以原始基准参考
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
currentValue = element.getCurrentValue();//以当前基准参考
|
|
currentValue = element.getCurrentValue();//以当前基准参考
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -206,7 +206,7 @@ public class BackTrackService {
|
|
|
List<Object> datemap = new ArrayList<>();
|
|
List<Object> datemap = new ArrayList<>();
|
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
|
List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, element.getItem(), dateStart, dateEnd);
|
|
List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, element.getItem(), dateStart, dateEnd);
|
|
|
- if(!Objects.isNull((selected))) {
|
|
|
|
|
|
|
+ if (!Objects.isNull((selected))) {
|
|
|
for (SlopeData message : selected) {
|
|
for (SlopeData message : selected) {
|
|
|
String line = message.getLine();
|
|
String line = message.getLine();
|
|
|
String val1 = message.getVal();
|
|
String val1 = message.getVal();
|
|
@@ -217,25 +217,25 @@ public class BackTrackService {
|
|
|
double cosValue = Math.cos(angleInRadians);
|
|
double cosValue = Math.cos(angleInRadians);
|
|
|
double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
- }else if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {//如果是Y轴
|
|
|
|
|
|
|
+ } else if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {//如果是Y轴
|
|
|
offsetValue = new BigDecimal(LATITUDE_REFERENCE).multiply(subtract);
|
|
offsetValue = new BigDecimal(LATITUDE_REFERENCE).multiply(subtract);
|
|
|
} else if (DictItemEnum.ALTITUDE_Z.getValue().equals(element.getItem())) {//如果是z轴
|
|
} else if (DictItemEnum.ALTITUDE_Z.getValue().equals(element.getItem())) {//如果是z轴
|
|
|
offsetValue = new BigDecimal(val1).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
|
|
offsetValue = new BigDecimal(val1).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
- }else{//如果是其他
|
|
|
|
|
|
|
+ } else {//如果是其他
|
|
|
offsetValue = subtract;
|
|
offsetValue = subtract;
|
|
|
}
|
|
}
|
|
|
Map<String, Object> temp = new HashMap<>();
|
|
Map<String, Object> temp = new HashMap<>();
|
|
|
- temp.put("time",key);
|
|
|
|
|
- temp.put("offset",offsetValue);
|
|
|
|
|
|
|
+ temp.put("time", key);
|
|
|
|
|
+ temp.put("offset", offsetValue);
|
|
|
datemap.add(temp);
|
|
datemap.add(temp);
|
|
|
}
|
|
}
|
|
|
Collections.reverse(datemap);
|
|
Collections.reverse(datemap);
|
|
|
}
|
|
}
|
|
|
mapList.put(element.getItem(), datemap);
|
|
mapList.put(element.getItem(), datemap);
|
|
|
}
|
|
}
|
|
|
- returnData.put("references",references);
|
|
|
|
|
- returnData.put("threshold",kwsThresholds);
|
|
|
|
|
- returnData.put("chart",mapList);
|
|
|
|
|
|
|
+ returnData.put("references", references);
|
|
|
|
|
+ returnData.put("threshold", kwsThresholds);
|
|
|
|
|
+ returnData.put("chart", mapList);
|
|
|
return HttpResult.ok(returnData);
|
|
return HttpResult.ok(returnData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -244,7 +244,7 @@ public class BackTrackService {
|
|
|
* 集成分析列表
|
|
* 集成分析列表
|
|
|
*
|
|
*
|
|
|
* @param integrationQuery 请求分页
|
|
* @param integrationQuery 请求分页
|
|
|
- * @param response http流
|
|
|
|
|
|
|
+ * @param response http流
|
|
|
* @return 返回值
|
|
* @return 返回值
|
|
|
*/
|
|
*/
|
|
|
public PageRes getIntegrationList(IntegrationQuery integrationQuery, HttpServletRequest response) {
|
|
public PageRes getIntegrationList(IntegrationQuery integrationQuery, HttpServletRequest response) {
|
|
@@ -256,16 +256,16 @@ public class BackTrackService {
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return PageRes.build(pageInfo, list);
|
|
return PageRes.build(pageInfo, list);
|
|
|
}
|
|
}
|
|
|
- for(IntegrationVo vo : list){
|
|
|
|
|
|
|
+ for (IntegrationVo vo : list) {
|
|
|
List<Object> stringList = new ArrayList<>();
|
|
List<Object> stringList = new ArrayList<>();
|
|
|
|
|
|
|
|
String[] partNames = vo.getPartNames().split(",");
|
|
String[] partNames = vo.getPartNames().split(",");
|
|
|
- for(int i=0;i<partNames.length;i++){
|
|
|
|
|
- Map<String,Object> strArray = new HashMap<>();
|
|
|
|
|
- if(DictItemEnum.getData(partNames[i]).getName().equals("ISNULL")){
|
|
|
|
|
- strArray.put("name",partNames[i]);
|
|
|
|
|
- }else{
|
|
|
|
|
- strArray.put("name",DictItemEnum.getData(partNames[i]).getName());
|
|
|
|
|
|
|
+ for (int i = 0; i < partNames.length; i++) {
|
|
|
|
|
+ Map<String, Object> strArray = new HashMap<>();
|
|
|
|
|
+ if (DictItemEnum.getData(partNames[i]).getName().equals("ISNULL")) {
|
|
|
|
|
+ strArray.put("name", partNames[i]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ strArray.put("name", DictItemEnum.getData(partNames[i]).getName());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
stringList.add(strArray);
|
|
stringList.add(strArray);
|
|
@@ -289,8 +289,8 @@ public class BackTrackService {
|
|
|
/**
|
|
/**
|
|
|
* 新增集成元素
|
|
* 新增集成元素
|
|
|
*
|
|
*
|
|
|
- * @param vo 请求参数
|
|
|
|
|
- * @param request http流
|
|
|
|
|
|
|
+ * @param vo 请求参数
|
|
|
|
|
+ * @param request http流
|
|
|
* @return 返回值
|
|
* @return 返回值
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -324,11 +324,12 @@ public class BackTrackService {
|
|
|
commonService.insertLog(MessageLogEnum.INTEGRATION_ADD, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
commonService.insertLog(MessageLogEnum.INTEGRATION_ADD, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 修改集成分析
|
|
* 修改集成分析
|
|
|
*
|
|
*
|
|
|
- * @param vo 请求参数
|
|
|
|
|
- * @param request http流
|
|
|
|
|
|
|
+ * @param vo 请求参数
|
|
|
|
|
+ * @param request http流
|
|
|
* @return 返回值
|
|
* @return 返回值
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
@@ -346,6 +347,7 @@ public class BackTrackService {
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
|
integration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
integration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
|
|
|
integration.setUpdateTime(now);
|
|
integration.setUpdateTime(now);
|
|
|
|
|
+ integration.setRemark(StringUtils.isBlank(vo.getRemark()) ? null : vo.getRemark());
|
|
|
integrationMapper.updateById(integration);
|
|
integrationMapper.updateById(integration);
|
|
|
Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
logMap.put("name", integration.getIntegrationName());
|
|
logMap.put("name", integration.getIntegrationName());
|