|
@@ -10,6 +10,7 @@ import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
|
import com.sckw.core.model.enums.DictEnum;
|
|
import com.sckw.core.model.enums.DictEnum;
|
|
|
import com.sckw.core.model.enums.DictItemEnum;
|
|
import com.sckw.core.model.enums.DictItemEnum;
|
|
|
|
|
+import com.sckw.core.model.enums.MessageLogEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.RegularUtils;
|
|
import com.sckw.core.utils.RegularUtils;
|
|
@@ -37,8 +38,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.ZoneOffset;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -65,6 +67,9 @@ public class ProjectService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwsIntegrationMapper integrationMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsDeviceMapper deviceMapper;
|
|
KwsDeviceMapper deviceMapper;
|
|
|
|
|
|
|
@@ -77,6 +82,9 @@ public class ProjectService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsDeviceReferenceMapper deviceReferenceMapper;
|
|
KwsDeviceReferenceMapper deviceReferenceMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwsThresholdMapper thresholdMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsMountainCompanyMapper mountainCompanyMapper;
|
|
KwsMountainCompanyMapper mountainCompanyMapper;
|
|
|
|
|
|
|
@@ -137,6 +145,10 @@ public class ProjectService {
|
|
|
company.setMountainId(headerData.getMountainId());
|
|
company.setMountainId(headerData.getMountainId());
|
|
|
company.setCompanyId(headerData.getCompanyId());
|
|
company.setCompanyId(headerData.getCompanyId());
|
|
|
mountainCompanyMapper.insert(company);
|
|
mountainCompanyMapper.insert(company);
|
|
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ logMap.put("projectName", projectAddDto.getName());
|
|
|
|
|
+ logMap.put("mountainName", projectAddDto.getMountainName());
|
|
|
|
|
+ commonService.insertLog(MessageLogEnum.ADD_PROJECT, headerData, logMap, headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -176,13 +188,14 @@ public class ProjectService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public HttpResult update(ProjectUpdateDTO projectAddDto, HttpServletRequest response) {
|
|
|
|
|
|
|
+ public HttpResult update(ProjectUpdateDTO projectAddDto, HttpServletRequest request) {
|
|
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
KwsProject project = new KwsProject();
|
|
KwsProject project = new KwsProject();
|
|
|
BeanUtils.copyProperties(projectAddDto, project);
|
|
BeanUtils.copyProperties(projectAddDto, project);
|
|
|
project.setId(Long.parseLong(projectAddDto.getId()));
|
|
project.setId(Long.parseLong(projectAddDto.getId()));
|
|
|
project.setStatus(NumberConstant.ZERO);
|
|
project.setStatus(NumberConstant.ZERO);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- project.setUpdateBy(Long.parseLong(commonService.getHeaderData(response).getUpdateBy()));
|
|
|
|
|
|
|
+ project.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
project.setUpdateTime(now);
|
|
project.setUpdateTime(now);
|
|
|
projectMapper.updateById(project);
|
|
projectMapper.updateById(project);
|
|
|
String fence = projectAddDto.getFence();
|
|
String fence = projectAddDto.getFence();
|
|
@@ -191,13 +204,27 @@ public class ProjectService {
|
|
|
.set(KwsProjectArea::getFence, fence)
|
|
.set(KwsProjectArea::getFence, fence)
|
|
|
.set(KwsProjectArea::getArea, projectAddDto.getArea())
|
|
.set(KwsProjectArea::getArea, projectAddDto.getArea())
|
|
|
);
|
|
);
|
|
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ logMap.put("projectName", projectAddDto.getName());
|
|
|
|
|
+ logMap.put("mountainName", projectAddDto.getMountainName());
|
|
|
|
|
+ commonService.insertLog(MessageLogEnum.UPDATE_PROJECT, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public HttpResult dels(String ids, HttpServletRequest request) {
|
|
public HttpResult dels(String ids, HttpServletRequest request) {
|
|
|
|
|
+ HeaderData headerData = commonService.getHeaderData(request);
|
|
|
List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
List<Long> list = StringUtils.splitStrToList(ids, Long.class);
|
|
|
|
|
+ KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
|
|
|
|
|
+ .eq(KwsProject::getId, list.get(0)));
|
|
|
|
|
+ if (project == null) {
|
|
|
|
|
+ throw new BusinessException("要删除的项目不存在");
|
|
|
|
|
+ }
|
|
|
int update = projectMapper.update(null, new LambdaUpdateWrapper<KwsProject>().in(KwsProject::getId, list).set(KwsProject::getDelFlag, "1"));
|
|
int update = projectMapper.update(null, new LambdaUpdateWrapper<KwsProject>().in(KwsProject::getId, list).set(KwsProject::getDelFlag, "1"));
|
|
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ logMap.put("projectName", project.getName());
|
|
|
|
|
+ logMap.put("mountainName", project.getMountainName());
|
|
|
|
|
+ commonService.insertLog(MessageLogEnum.DELETE_PROJECT, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
if (update < 1) {
|
|
if (update < 1) {
|
|
|
throw new BusinessException("删除失败");
|
|
throw new BusinessException("删除失败");
|
|
|
}
|
|
}
|
|
@@ -254,6 +281,20 @@ public class ProjectService {
|
|
|
String bindDeviceId = bindDevice.getBindDeviceId();
|
|
String bindDeviceId = bindDevice.getBindDeviceId();
|
|
|
//设备主从绑定
|
|
//设备主从绑定
|
|
|
List<KwsDeviceRelation> saveList = new ArrayList<>();
|
|
List<KwsDeviceRelation> saveList = new ArrayList<>();
|
|
|
|
|
+ StringBuilder deviceName = new StringBuilder();
|
|
|
|
|
+ List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>()
|
|
|
|
|
+ .eq(KwsDevice::getDelFlag, 0)
|
|
|
|
|
+ .in(KwsDevice::getId, list));
|
|
|
|
|
+ if (CollectionUtils.isEmpty(kwsDevices)) {
|
|
|
|
|
+ throw new BusinessException("需要关联设备不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = 0; i < kwsDevices.size(); i++) {
|
|
|
|
|
+ if (i != kwsDevices.size() - 1) {
|
|
|
|
|
+ deviceName.append(kwsDevices.get(i).getName()).append(",");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ deviceName.append(kwsDevices.get(i).getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
list.forEach(id -> {
|
|
list.forEach(id -> {
|
|
|
String deviceId = "";
|
|
String deviceId = "";
|
|
|
if (bindDeviceId == null) {
|
|
if (bindDeviceId == null) {
|
|
@@ -320,6 +361,10 @@ public class ProjectService {
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ logMap.put("projectName", project.getName());
|
|
|
|
|
+ logMap.put("deviceName", deviceName.toString());
|
|
|
|
|
+ commonService.insertLog(MessageLogEnum.ADD_NETWORKING_DEVICE, headerData, logMap, headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -364,11 +409,8 @@ public class ProjectService {
|
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
HeaderData headerData = commonService.getHeaderData(request);
|
|
|
String latitude = param.getLatitude();
|
|
String latitude = param.getLatitude();
|
|
|
String projectId = param.getProjectId();
|
|
String projectId = param.getProjectId();
|
|
|
|
|
+ String type = param.getType();
|
|
|
if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
|
|
if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
|
|
|
- Map<String, SystemDict> dictList = commonService.getDictList(null, new HashMap<String, String>() {{
|
|
|
|
|
- put("code", DictEnum.MODEL_PART.getCodeType());
|
|
|
|
|
- put("type", "1");
|
|
|
|
|
- }});
|
|
|
|
|
String deviceId = param.getDeviceId();
|
|
String deviceId = param.getDeviceId();
|
|
|
String mountainId = headerData.getMountainId();
|
|
String mountainId = headerData.getMountainId();
|
|
|
KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
@@ -379,47 +421,279 @@ public class ProjectService {
|
|
|
if (kwsDevice == null) {
|
|
if (kwsDevice == null) {
|
|
|
return HttpResult.ok();
|
|
return HttpResult.ok();
|
|
|
}
|
|
}
|
|
|
- //集成要素
|
|
|
|
|
- List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
|
|
|
|
|
- mountainId, null, Long.parseLong(deviceId));
|
|
|
|
|
- //集成要素
|
|
|
|
|
- List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
|
|
- .eq(KwsDeviceIntegration::getMountainId, mountainId)
|
|
|
|
|
- .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
|
|
|
|
+ List<Map<String, ProjectCatLogVO>> returnList = new ArrayList<>();
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = new HashMap<>();
|
|
|
|
|
+ if (Objects.nonNull(type)) {
|
|
|
|
|
+ dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
|
|
+ if (dictByDictCode.get(type) != null) {
|
|
|
|
|
+ //当前设备下的所有基本要素
|
|
|
|
|
+ basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //集成要素 折线图
|
|
|
|
|
+ //集成要素-测量值计算
|
|
|
|
|
+ integrationItem(headerData, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //当前设备下的所有基本要素
|
|
|
|
|
+ basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ //集成要素 折线图
|
|
|
|
|
+ //集成要素-测量值计算
|
|
|
|
|
+ integrationItem(headerData, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
|
|
+ } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
|
|
|
|
|
+ String deviceId = param.getDeviceId();
|
|
|
|
|
+ String mountainId = headerData.getMountainId();
|
|
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
|
|
+ .eq(KwsDevice::getId, Long.parseLong(deviceId))
|
|
|
|
|
+ .eq(KwsDevice::getMountainId, mountainId)
|
|
|
|
|
+ .eq(KwsDevice::getDelFlag, NumberConstant.ZERO)
|
|
|
);
|
|
);
|
|
|
|
|
+ if (kwsDevice == null) {
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Map<String, ProjectCatLogVO>> returnList = new ArrayList<>();
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = new HashMap<>();
|
|
|
|
|
+ if (Objects.nonNull(type)) {
|
|
|
|
|
+ dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
|
|
+ if (dictByDictCode.get(type) != null) {
|
|
|
|
|
+ List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<>());
|
|
|
|
|
+ //当前设备下的所有基本要素
|
|
|
|
|
+ basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTimeDay, type);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //集成要素-测量值计算
|
|
|
|
|
+ integrationItemWeek(headerData, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<>());
|
|
|
|
|
+ //当前设备下的所有基本要素
|
|
|
|
|
+ basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTimeDay, type);
|
|
|
|
|
+ integrationItemWeek(headerData, deviceId, kwsDevice, returnList, type);
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
|
|
+ } else if (String.valueOf(NumberConstant.TWO).equals(latitude)) {
|
|
|
|
|
+ } else if (String.valueOf(NumberConstant.ONE).equals(latitude)) {
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new BusinessException("数据传输异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ return HttpResult.ok();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //当前设备下的所有基本要素
|
|
|
|
|
- List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
|
|
|
|
|
- if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
|
|
- for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
|
|
- String partName = projectDeviceVO.getPartName();
|
|
|
|
|
- //设置过阈值的基本要素
|
|
|
|
|
- List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
|
|
- .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
|
|
- .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
|
|
- .eq(KwsDeviceReference::getType, 1)
|
|
|
|
|
- .eq(KwsDeviceReference::getItem, partName)
|
|
|
|
|
- .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
|
|
+ private void integrationItemWeek(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
|
|
|
|
|
+ List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
|
|
+ .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ List<Long> longList = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deviceIntegrations)) {
|
|
|
|
|
+ longList = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(longList)) {
|
|
|
|
|
+ List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
|
|
|
|
|
+ .in(KwsIntegration::getId, longList)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
|
|
|
|
|
+ kwsIntegrations.forEach(integration -> {
|
|
|
|
|
+ Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ ProjectCatLogVO projectCatLogVO = new ProjectCatLogVO();
|
|
|
|
|
+ String integrationName = integration.getIntegrationName();
|
|
|
|
|
+ String partNames = integration.getPartNames();
|
|
|
|
|
+ List<KwsDeviceReference> referenceList = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
|
|
+ .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, Long.parseLong(deviceId))
|
|
|
|
|
+ .eq(KwsDeviceReference::getItem, integrationName)
|
|
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsDeviceReference::getType, 2)
|
|
|
);
|
|
);
|
|
|
- KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
|
|
- if (!CollectionUtils.isEmpty(references)) {
|
|
|
|
|
- deviceReference = references.get(0);
|
|
|
|
|
|
|
+ //当前基准值
|
|
|
|
|
+ projectCatLogVO.setReference(CollectionUtils.isEmpty(referenceList) ? null :
|
|
|
|
|
+ (referenceList.get(0).getCurrentValue() == null ? null : referenceList.get(0).getCurrentValue()));
|
|
|
|
|
+ //当前要素阈值
|
|
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsThreshold::getItemName, integrationName)
|
|
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
|
|
+ }
|
|
|
|
|
+ //阈值等级map
|
|
|
|
|
+// Map<String, Map<String, String>> thresholdMap = new HashMap<>();
|
|
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
|
|
+ String thresholdMax = "";
|
|
|
|
|
+ String thresholdMin = "";
|
|
|
|
|
+ if (listMap.get(1) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(1).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("oneLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ if (listMap.get(2) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(2).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("twoLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+
|
|
|
|
|
+ if (listMap.get(3) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(3).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("threeLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+
|
|
|
|
|
+ //当前测量值-TD获取
|
|
|
|
|
+ String formula = integration.getFormula();
|
|
|
|
|
+ List<String> stringList = StringUtils.splitStrToList(partNames, String.class);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(stringList)) {
|
|
|
|
|
+ for (String item : stringList) {
|
|
|
|
|
+ //当前仅有加速度
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal("0.00");
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), item, dateStart, dateEnd);
|
|
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
|
|
+ for (int i = 0; i < selected.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ SlopeData currSlopeData = selected.get(i);
|
|
|
|
|
+ String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
|
|
+ SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
|
|
+ LocalDateTime localDateTime = currSlopeData.getTs();
|
|
|
|
|
+ long epochMilli1 = 0L;
|
|
|
|
|
+ String val2 = "0";
|
|
|
|
|
+ LocalDateTime localDateTime1 = lastSlopeData.getTs();
|
|
|
|
|
+ if (lastSlopeData != null) {
|
|
|
|
|
+ epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ val2 = lastSlopeData.getVal();
|
|
|
|
|
+ }
|
|
|
|
|
+ long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ String val1 = currSlopeData.getVal();
|
|
|
|
|
+ long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
|
|
+ long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
|
|
+ decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
|
|
|
|
|
+ map.put(key, decimal);
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ projectCatLogVO.setType(integrationName);
|
|
|
|
|
+ projectCatLogVO.setMonitor(mapList);
|
|
|
|
|
+ returnMap.put(integrationName, projectCatLogVO);
|
|
|
|
|
+ returnList.add(returnMap);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- SlopeData slopeData = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), partName);
|
|
|
|
|
- String val = slopeData == null ? null : slopeData.getVal();
|
|
|
|
|
- //基准值
|
|
|
|
|
- BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
|
|
- BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
|
|
- if (currentValue != null) {
|
|
|
|
|
- /**存在经纬度海拔值的需要公式计算*/
|
|
|
|
|
- List<String> itemList = new ArrayList<>();
|
|
|
|
|
- itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
|
|
- Date date = new Date();
|
|
|
|
|
- String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 周为纬度 折线图计算
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param mountainId 所属企业
|
|
|
|
|
+ * @param projectId 所属项目
|
|
|
|
|
+ * @param deviceId 所属设备
|
|
|
|
|
+ * @param kwsDevice 设备信息
|
|
|
|
|
+ * @param returnList 返回数据
|
|
|
|
|
+ * @param dateList 时间范围
|
|
|
|
|
+ */
|
|
|
|
|
+ private void basicItemByWeek(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, List<Date> dateList, String type) {
|
|
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId), type);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
|
|
+ for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
|
|
+ Map<String, ProjectCatLogVO> returnMap = new HashMap<>();
|
|
|
|
|
+ ProjectCatLogVO returnVO = new ProjectCatLogVO();
|
|
|
|
|
+ String partName = projectDeviceVO.getPartName();
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
|
|
+ String itemName = dictByDictCode.get(partName) == null ? partName : dictByDictCode.get(partName).getLabel();
|
|
|
|
|
+ //设置过阈值的基本要素
|
|
|
|
|
+ List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
|
|
+ .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
|
|
+ .eq(KwsDeviceReference::getType, 1)
|
|
|
|
|
+ .eq(KwsDeviceReference::getItem, partName)
|
|
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(references)) {
|
|
|
|
|
+ deviceReference = references.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ //基准值
|
|
|
|
|
+ BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsThreshold::getItemName, partName)
|
|
|
|
|
+ .eq(KwsThreshold::getMountainId, mountainId)
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
|
|
+ }
|
|
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
|
|
+ String thresholdMax = "";
|
|
|
|
|
+ String thresholdMin = "";
|
|
|
|
|
+ if (listMap.get(1) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(1).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+ returnVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ if (listMap.get(2) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(2).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+ returnVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ if (listMap.get(3) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(3).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+ returnVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ //时间统计轴(当前数据检测值)
|
|
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
|
|
+ if (currentValue != null) {
|
|
|
|
|
+ /**存在经纬度海拔值的需要公式计算*/
|
|
|
|
|
+ List<String> itemList = new ArrayList<>();
|
|
|
|
|
+ itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
|
|
+// Date date = new Date();
|
|
|
|
|
+ for (int i = 0; i < dateList.size(); i++) {
|
|
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(dateList.get(i), 24);
|
|
|
String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
- if (!CollectionUtils.isEmpty(selected)){
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
for (SlopeData message : selected) {
|
|
for (SlopeData message : selected) {
|
|
|
|
|
+ BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
|
|
+ Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ LocalDateTime createTime = message.getCreateTime();
|
|
|
|
|
+ String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
String line = message.getLine();
|
|
String line = message.getLine();
|
|
|
String val1 = message.getVal();
|
|
String val1 = message.getVal();
|
|
|
if (itemList.contains(partName)) {
|
|
if (itemList.contains(partName)) {
|
|
@@ -427,8 +701,8 @@ public class ProjectService {
|
|
|
SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
|
|
SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
|
|
|
double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
|
double cosValue = Math.cos(angleInRadians);
|
|
double cosValue = Math.cos(angleInRadians);
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
|
|
- double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
|
|
|
|
|
+ double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).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));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -436,8 +710,8 @@ public class ProjectService {
|
|
|
itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
if (itemList.contains(partName)) {
|
|
if (itemList.contains(partName)) {
|
|
|
if (Objects.nonNull(currentValue)) {
|
|
if (Objects.nonNull(currentValue)) {
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
|
|
- offsetValue = new BigDecimal(val).subtract(currentValue);
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
|
|
+ offsetValue = new BigDecimal(line).subtract(currentValue);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -445,51 +719,290 @@ public class ProjectService {
|
|
|
itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
if (itemList.contains(partName)) {
|
|
if (itemList.contains(partName)) {
|
|
|
if (Objects.nonNull(currentValue)) {
|
|
if (Objects.nonNull(currentValue)) {
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
|
|
- offsetValue = new BigDecimal(val).divide(new BigDecimal(1000));
|
|
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ datemap.put(key, offsetValue);
|
|
|
|
|
+ mapList.add(datemap);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ returnVO.setType(partName);
|
|
|
|
|
+ returnVO.setMonitor(mapList);
|
|
|
|
|
+ returnMap.put(itemName, returnVO);
|
|
|
|
|
+ returnList.add(returnMap);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- LocalDateTime localDateTime = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
|
|
|
|
|
- } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
|
|
|
|
|
-// //开始时间
|
|
|
|
|
-// dateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
|
|
|
|
|
-// //结束时间
|
|
|
|
|
-// dateEnd = DateUtil.getLastWeekDateEndToString(0);
|
|
|
|
|
- List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
|
|
|
|
|
- for (String dateTime : dateTimeDay) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- /**下面是查询当天每小时数据总量的代码示例:
|
|
|
|
|
-
|
|
|
|
|
- SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
|
|
|
|
|
- COUNT(*) AS count
|
|
|
|
|
- FROM data
|
|
|
|
|
- WHERE DATE(timestamp) = CURDATE()
|
|
|
|
|
- GROUP BY hour;*/
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 集成要素折线图计算
|
|
|
|
|
+ */
|
|
|
|
|
+ private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
|
|
|
|
|
+ List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
|
|
+ .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ List<Long> longList = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deviceIntegrations)) {
|
|
|
|
|
+ longList = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(longList)) {
|
|
|
|
|
+ List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
|
|
|
|
|
+ .in(KwsIntegration::getId, longList)
|
|
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
|
|
|
|
|
+ kwsIntegrations.forEach(integration -> {
|
|
|
|
|
+ Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ ProjectCatLogVO projectCatLogVO = new ProjectCatLogVO();
|
|
|
|
|
+ String integrationName = integration.getIntegrationName();
|
|
|
|
|
+ String partNames = integration.getPartNames();
|
|
|
|
|
+ List<KwsDeviceReference> referenceList = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
|
|
+ .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, Long.parseLong(deviceId))
|
|
|
|
|
+ .eq(KwsDeviceReference::getItem, integrationName)
|
|
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsDeviceReference::getType, 2)
|
|
|
|
|
+ );
|
|
|
|
|
+ //当前基准值
|
|
|
|
|
+ projectCatLogVO.setReference(CollectionUtils.isEmpty(referenceList) ? null :
|
|
|
|
|
+ (referenceList.get(0).getCurrentValue() == null ? null : referenceList.get(0).getCurrentValue()));
|
|
|
|
|
+ //当前要素阈值
|
|
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsThreshold::getItemName, integrationName)
|
|
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
|
|
+ }
|
|
|
|
|
+ //阈值等级map
|
|
|
|
|
+// Map<String, Map<String, String>> thresholdMap = new HashMap<>();
|
|
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
|
|
+ String thresholdMax = "";
|
|
|
|
|
+ String thresholdMin = "";
|
|
|
|
|
+ if (listMap.get(1) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(1).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("oneLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ if (listMap.get(2) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(2).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("twoLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
|
|
|
|
|
- /** 下面是查询当天每小时某个字段平均值的代码示例:
|
|
|
|
|
|
|
+ if (listMap.get(3) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(3).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("threeLevelAlarm", map);
|
|
|
|
|
+ projectCatLogVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
|
|
|
|
|
|
|
+ //当前测量值-TD获取
|
|
|
|
|
+ String formula = integration.getFormula();
|
|
|
|
|
+ List<String> stringList = StringUtils.splitStrToList(partNames, String.class);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(stringList)) {
|
|
|
|
|
+ for (String item : stringList) {
|
|
|
|
|
+ //当前仅有加速度
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal("0.00");
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), item, dateStart, dateEnd);
|
|
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
|
|
+ for (int i = 0; i < selected.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ SlopeData currSlopeData = selected.get(i);
|
|
|
|
|
+ String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
|
|
+ SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
|
|
+ LocalDateTime localDateTime = currSlopeData.getTs();
|
|
|
|
|
+ long epochMilli1 = 0L;
|
|
|
|
|
+ String val2 = "0";
|
|
|
|
|
+ LocalDateTime localDateTime1 = lastSlopeData.getTs();
|
|
|
|
|
+ if (lastSlopeData != null) {
|
|
|
|
|
+ epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ val2 = lastSlopeData.getVal();
|
|
|
|
|
+ }
|
|
|
|
|
+ long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
|
|
+ String val1 = currSlopeData.getVal();
|
|
|
|
|
+ long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
|
|
+ long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
|
|
+ decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
|
|
|
|
|
+ map.put(key, decimal);
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ projectCatLogVO.setType(integrationName);
|
|
|
|
|
+ projectCatLogVO.setMonitor(mapList);
|
|
|
|
|
+ returnMap.put(integrationName, projectCatLogVO);
|
|
|
|
|
+ returnList.add(returnMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
|
|
|
|
|
- AVG(value) AS average
|
|
|
|
|
- FROM data
|
|
|
|
|
- WHERE DATE(timestamp) = CURDATE()
|
|
|
|
|
- GROUP BY hour;*/
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 折线图 基本要素
|
|
|
|
|
+ */
|
|
|
|
|
+ private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
|
|
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId), type);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
|
|
+ for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
|
|
+ Map<String, ProjectCatLogVO> returnMap = new HashMap<>();
|
|
|
|
|
+ ProjectCatLogVO returnVO = new ProjectCatLogVO();
|
|
|
|
|
+ String partName = projectDeviceVO.getPartName();
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
|
|
+ String itemName = dictByDictCode.get(partName) == null ? partName : dictByDictCode.get(partName).getLabel();
|
|
|
|
|
+ //设置过阈值的基本要素
|
|
|
|
|
+ List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
|
|
+ .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
|
|
+ .eq(KwsDeviceReference::getType, 1)
|
|
|
|
|
+ .eq(KwsDeviceReference::getItem, partName)
|
|
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(references)) {
|
|
|
|
|
+ deviceReference = references.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ //基准值
|
|
|
|
|
+ BigDecimal currentValue = deviceReference == null ? null : deviceReference.getCurrentValue();
|
|
|
|
|
+ returnVO.setReference(currentValue);
|
|
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
|
|
+ .eq(KwsThreshold::getItemName, partName)
|
|
|
|
|
+ .eq(KwsThreshold::getMountainId, mountainId)
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
|
|
+ );
|
|
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
|
|
+ }
|
|
|
|
|
+ //阈值等级map
|
|
|
|
|
+// Map<String, Map<String, String>> thresholdMap = new HashMap<>();
|
|
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
|
|
+ String thresholdMax = "";
|
|
|
|
|
+ String thresholdMin = "";
|
|
|
|
|
+ if (listMap.get(1) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(1).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("oneLevelAlarm", map);
|
|
|
|
|
+ returnVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ if (listMap.get(2) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(2).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("twoLevelAlarm", map);
|
|
|
|
|
+ returnVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
|
|
|
|
|
- } else if (String.valueOf(NumberConstant.TWO).equals(latitude)) {
|
|
|
|
|
- } else if (String.valueOf(NumberConstant.ONE).equals(latitude)) {
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new BusinessException("数据传输异常");
|
|
|
|
|
|
|
+ if (listMap.get(3) != null) {
|
|
|
|
|
+ KwsThreshold kwsThreshold = listMap.get(3).get(0);
|
|
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
|
|
+ }
|
|
|
|
|
+// thresholdMap.put("threeLevelAlarm", map);
|
|
|
|
|
+ returnVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
|
|
+ //时间统计轴(当前数据检测值)
|
|
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
|
|
+ if (currentValue != null) {
|
|
|
|
|
+ /**存在经纬度海拔值的需要公式计算*/
|
|
|
|
|
+ List<String> itemList = new ArrayList<>();
|
|
|
|
|
+ itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
|
|
+ for (SlopeData message : selected) {
|
|
|
|
|
+ BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
|
|
+ Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ LocalDateTime createTime = message.getCreateTime();
|
|
|
|
|
+ String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
|
|
+ String line = message.getLine();
|
|
|
|
|
+ String val1 = message.getVal();
|
|
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
|
|
+ SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
|
|
|
|
|
+ double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
|
|
|
+ double cosValue = Math.cos(angleInRadians);
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
|
|
|
|
|
+ double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
|
|
+ offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
|
|
+ offsetValue = new BigDecimal(line).subtract(currentValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ itemList.clear();
|
|
|
|
|
+ itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ datemap.put(key, offsetValue);
|
|
|
|
|
+ mapList.add(datemap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ returnVO.setType(partName);
|
|
|
|
|
+ returnVO.setMonitor(mapList);
|
|
|
|
|
+ returnMap.put(itemName, returnVO);
|
|
|
|
|
+ returnList.add(returnMap);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return null;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -571,6 +1084,23 @@ public class ProjectService {
|
|
|
.set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
|
|
.set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
|
|
+ List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>().in(KwsDevice::getId, deleteList).eq(KwsDevice::getDelFlag, 0));
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsDevices)) {
|
|
|
|
|
+ StringBuilder deviceName = new StringBuilder();
|
|
|
|
|
+ for (int i = 0; i < kwsDevices.size(); i++) {
|
|
|
|
|
+ if (i != kwsDevices.size() - 1) {
|
|
|
|
|
+ deviceName.append(kwsDevices.get(i).getName()).append(",");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ deviceName.append(kwsDevices.get(i).getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
|
|
+ logMap.put("projectName", project.getName());
|
|
|
|
|
+ logMap.put("deviceName", deviceName.toString());
|
|
|
|
|
+ commonService.insertLog(MessageLogEnum.DELETE_NETWORKING_DEVICE, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return HttpResult.ok("删除关联设备成功!");
|
|
return HttpResult.ok("删除关联设备成功!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|