|
@@ -1,6 +1,7 @@
|
|
|
package com.usky.iot.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -59,6 +60,14 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
|
|
|
.eq(DmpProductInfo::getTenantId,SecurityUtils.getTenantId());
|
|
|
List<DmpProductInfo> list1 = dmpProductInfoService.list(queryWrapper);
|
|
|
if(CollectionUtils.isNotEmpty(list1)){
|
|
|
+ QueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.query();
|
|
|
+ queryWrapper1.select("product_code as productCode","count(*) as count")
|
|
|
+ .in("service_status",1,2)
|
|
|
+ .eq("delete_flag",0)
|
|
|
+ .eq("tenant_id",SecurityUtils.getTenantId())
|
|
|
+ .groupBy("product_code");
|
|
|
+ List<Map<String,Object>> mapList= dmpDeviceInfoService.listMaps(queryWrapper1);
|
|
|
+
|
|
|
for(int i=0;i<list1.size();i++){
|
|
|
BaseAlarmResponeVO responeVO = new BaseAlarmResponeVO();
|
|
|
responeVO.setProductCode(list1.get(i).getProductCode());
|
|
@@ -85,17 +94,16 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
|
|
|
responeVO.setProcessRate(processRate);
|
|
|
|
|
|
//设备总数
|
|
|
- int deviceCount = 0;
|
|
|
- List<Integer> serviceStatusList = new ArrayList<>();
|
|
|
- serviceStatusList.add(1);
|
|
|
- serviceStatusList.add(2);
|
|
|
- LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
- queryWrapper1.in(DmpDeviceInfo::getServiceStatus,serviceStatusList)
|
|
|
- .eq(DmpDeviceInfo::getProductCode,list1.get(i).getProductCode())
|
|
|
- .eq(DmpDeviceInfo::getDeleteFlag,0)
|
|
|
- .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId());
|
|
|
- deviceCount = dmpDeviceInfoService.count(queryWrapper1);
|
|
|
- responeVO.setDeviceCount(deviceCount);
|
|
|
+ responeVO.setDeviceCount(0);
|
|
|
+ if(CollectionUtils.isNotEmpty(mapList)){
|
|
|
+ for(int j=0;j<mapList.size();j++){
|
|
|
+ if(list1.get(i).getProductCode().equals(mapList.get(j).get("productCode"))){
|
|
|
+ responeVO.setDeviceCount(Integer.parseInt(String.valueOf(mapList.get(j).get("count"))));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//离线告警统计
|
|
|
//离线告警未处理
|
|
|
int offLineUntreated = 0;
|
|
@@ -146,16 +154,31 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
|
|
|
.orderByDesc(BaseAlarm::getId);
|
|
|
List<BaseAlarm> records = this.list(queryWrapper);
|
|
|
if(records.size()>0){
|
|
|
+ List<String> devList = new ArrayList<>();
|
|
|
for(int i=0;i<records.size();i++){
|
|
|
+ devList.add(records.get(i).getDeviceId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(devList.size() > 0){
|
|
|
LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
- queryWrapper1.eq(DmpDeviceInfo::getDeviceId,records.get(i).getDeviceId())
|
|
|
+ queryWrapper1.in(DmpDeviceInfo::getDeviceId,devList)
|
|
|
.eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
.eq(DmpDeviceInfo::getDeleteFlag,0);
|
|
|
- DmpDeviceInfo deviceInfo = dmpDeviceInfoService.getOne(queryWrapper1);
|
|
|
- if(deviceInfo != null){
|
|
|
- records.get(i).setDeviceName(deviceInfo.getDeviceName());
|
|
|
+ List<DmpDeviceInfo> deviceInfo = dmpDeviceInfoService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isNotEmpty(deviceInfo)){
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
+ for(int j=0;j<deviceInfo.size();j++){
|
|
|
+ if(records.get(i).getDeviceId().equals(deviceInfo.get(j).getDeviceId())){
|
|
|
+ records.get(i).setDeviceName(deviceInfo.get(j).getDeviceName());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
BaseAlarmType baseAlarmType = baseMapper.getAlarmTypeOne(records.get(i).getAlarmType());
|
|
|
if(baseAlarmType != null){
|
|
|
records.get(i).setTypeImg(baseAlarmType.getTypeImg());
|
|
@@ -190,6 +213,49 @@ public class BaseAlarmServiceImpl extends AbstractCrudService<BaseAlarmMapper, B
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public List<BaseAlarm> getScreenAlarmList(){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BaseAlarm> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper
|
|
|
+ .eq(BaseAlarm::getTenantId,SecurityUtils.getTenantId())
|
|
|
+ .orderByDesc(BaseAlarm::getId).last("limit 6");
|
|
|
+ List<BaseAlarm> records = this.list(queryWrapper);
|
|
|
+ if(records.size()>0){
|
|
|
+ List<String> devList = new ArrayList<>();
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
+ devList.add(records.get(i).getDeviceId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(devList.size() > 0){
|
|
|
+ LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.in(DmpDeviceInfo::getDeviceId,devList)
|
|
|
+ .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
|
|
|
+ .eq(DmpDeviceInfo::getDeleteFlag,0);
|
|
|
+ List<DmpDeviceInfo> deviceInfo = dmpDeviceInfoService.list(queryWrapper1);
|
|
|
+ if(CollectionUtils.isNotEmpty(deviceInfo)){
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
+ for(int j=0;j<deviceInfo.size();j++){
|
|
|
+ if(records.get(i).getDeviceId().equals(deviceInfo.get(j).getDeviceId())){
|
|
|
+ records.get(i).setDeviceName(deviceInfo.get(j).getDeviceName());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i=0;i<records.size();i++){
|
|
|
+ BaseAlarmType baseAlarmType = baseMapper.getAlarmTypeOne(records.get(i).getAlarmType());
|
|
|
+ if(baseAlarmType != null){
|
|
|
+ records.get(i).setTypeImg(baseAlarmType.getTypeImg());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
public void update(BaseAlarm baseAlarm){
|
|
|
int handleRange = baseAlarm.getHandleRange();
|
|
|
if(handleRange == 0){ //批量
|