|
|
@@ -6,10 +6,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
-import com.sckw.core.model.enums.DeviceEnum;
|
|
|
-import com.sckw.core.model.enums.DictEnum;
|
|
|
-import com.sckw.core.model.enums.MessageLogEnum;
|
|
|
-import com.sckw.core.model.enums.ThresholdEnum;
|
|
|
+import com.sckw.core.model.enums.*;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.RegularUtils;
|
|
|
@@ -17,7 +14,9 @@ import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
|
+import com.sckw.slope.detection.dao.tdengine.DevicesMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.*;
|
|
|
+import com.sckw.slope.detection.model.dos.tdengine.Devices;
|
|
|
import com.sckw.slope.detection.model.dto.*;
|
|
|
import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
|
|
|
import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
|
|
|
@@ -34,10 +33,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -62,6 +58,9 @@ public class ThresholdService {
|
|
|
@Autowired
|
|
|
KwsProjectMapper projectMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DevicesMapper devicesMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
|
|
|
@@ -657,10 +656,8 @@ public class ThresholdService {
|
|
|
KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>()
|
|
|
.eq(KwsProjectArea::getProjectId, Long.parseLong(projectId))
|
|
|
.eq(KwsProjectArea::getDelFlag, 0));
|
|
|
- if (area != null) {
|
|
|
-
|
|
|
- }
|
|
|
ProjectAndDeviceVo vo = new ProjectAndDeviceVo();
|
|
|
+ vo.setFence(area == null ? null : area.getFence());
|
|
|
KwsDevice kwsDevice = deviceMapper.selectById(Long.parseLong(deviceId));
|
|
|
if (kwsDevice != null) {
|
|
|
vo.setLogicLng(kwsDevice.getLogicLng());
|
|
|
@@ -671,6 +668,44 @@ public class ThresholdService {
|
|
|
vo.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
|
|
|
vo.setProjectId(projectId);
|
|
|
vo.setProjectName(project == null ? null : project.getName());
|
|
|
+ Devices devices = null;
|
|
|
+ String itemName = param.getItemName();
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ list.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
+ list.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
+ list.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
+ if (Objects.nonNull(itemName)) {
|
|
|
+ if (list.contains(itemName)) {
|
|
|
+ try {
|
|
|
+ devices = devicesMapper.selectLastDataByCodeAndItemName(kwsDevice.getSnCode(), itemName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备查询td异常:{}", e.getMessage(), e);
|
|
|
+ }
|
|
|
+ BigDecimal offset = null;
|
|
|
+ KwsDeviceReference deviceRelation = null;
|
|
|
+ if (Objects.nonNull(itemName)) {
|
|
|
+ if (devices != null) {
|
|
|
+ deviceRelation = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
+ .eq(KwsDeviceReference::getType, "1")
|
|
|
+ .eq(KwsDeviceReference::getItem, itemName)
|
|
|
+ );
|
|
|
+ offset = commonService.computeOffset(devices.getVal(), itemName, deviceRelation);
|
|
|
+ vo.setCurrentValue(devices.getVal());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setOffset(offset == null ? null : offset.toString());
|
|
|
+ } else if (dictByDictCode != null && (dictByDictCode.get(itemName) != null)) {
|
|
|
+ try {
|
|
|
+ devices = devicesMapper.selectLastDataByCodeAndItemName(kwsDevice.getSnCode(), itemName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设备查询td异常:{}", e.getMessage(), e);
|
|
|
+ }
|
|
|
+ vo.setCurrentValue(devices == null ? null : devices.getVal());
|
|
|
+ }
|
|
|
+ }
|
|
|
return HttpResult.ok(vo);
|
|
|
}
|
|
|
}
|