|
@@ -16,6 +16,7 @@ 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;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsIntegration;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsIntegration;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsThreshold;
|
|
import com.sckw.slope.detection.model.dos.mysql.KwsThreshold;
|
|
|
|
|
+import com.sckw.slope.detection.model.dos.tdengine.InsTables;
|
|
|
import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
import com.sckw.slope.detection.model.dto.DeviceDataDTO;
|
|
import com.sckw.slope.detection.model.dto.DeviceDataDTO;
|
|
|
import com.sckw.slope.detection.model.dto.HeaderData;
|
|
import com.sckw.slope.detection.model.dto.HeaderData;
|
|
@@ -28,7 +29,7 @@ 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.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -66,12 +67,18 @@ public class BackTrackService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsIntegrationMapper integrationMapper;
|
|
KwsIntegrationMapper integrationMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ InsTablesMapper insTablesMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
public HttpResult getParts(String projectId) {
|
|
public HttpResult getParts(String projectId) {
|
|
|
//首先获取项目中全部设备
|
|
//首先获取项目中全部设备
|
|
|
List<DeviceDataDTO> list = deviceMapper.selectDeviceAllNotDeviceRelation(projectId);
|
|
List<DeviceDataDTO> list = deviceMapper.selectDeviceAllNotDeviceRelation(projectId);
|
|
|
List<String> devicesId = list.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
List<String> devicesId = list.stream().map(DeviceDataDTO::getDeviceId).toList();
|
|
|
|
|
+ if(devicesId.size() == 0){
|
|
|
|
|
+ return HttpResult.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
//在获取设备的要素
|
|
//在获取设备的要素
|
|
|
List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
.in(KwsDeviceReference::getDeviceId, devicesId)
|
|
.in(KwsDeviceReference::getDeviceId, devicesId)
|
|
@@ -111,7 +118,15 @@ public class BackTrackService {
|
|
|
.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 {
|
|
|
|
|
+ InsTables insTables = insTablesMapper.selectTableIsExit("device_" + snCode);
|
|
|
|
|
+ if (insTables == null) {
|
|
|
|
|
+ insTablesMapper.createTable("device_" + snCode);
|
|
|
|
|
+ return HttpResult.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return HttpResult.ok(Collections.emptyList());
|
|
|
|
|
+ }
|
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByArray(snCode, arr, dateStart, dateEnd);
|
|
List<SlopeData> selectedData = slopeDataMapper.selectLineListByArray(snCode, arr, dateStart, dateEnd);
|
|
|
if (CollectionUtils.isEmpty(selectedData)) {
|
|
if (CollectionUtils.isEmpty(selectedData)) {
|
|
|
return HttpResult.ok(Collections.emptyList());
|
|
return HttpResult.ok(Collections.emptyList());
|