访客&&大屏
This commit is contained in:
@@ -123,17 +123,23 @@
|
||||
<artifactId>examples</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.hik</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>4.5.2_1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.hik</groupId>-->
|
||||
<!-- <artifactId>jna</artifactId>-->
|
||||
<!-- <version>4.5.2_1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ghgande</groupId>
|
||||
<artifactId>j2mod</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>5.17.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@@ -0,0 +1,35 @@
|
||||
package org.dromara.sis.dubbo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.sis.api.RemotePrecautionary;
|
||||
import org.dromara.sis.api.domain.RemotePrecautionaryVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class RemotePrecautionaryImpl implements RemotePrecautionary {
|
||||
private final PrecautionaryMapper precautionaryMapper;
|
||||
|
||||
@Override
|
||||
public List<RemotePrecautionaryVo> getList() {
|
||||
Page<Precautionary> Page = new Page<>(1, 10);
|
||||
QueryWrapper<Precautionary> wrapper = new QueryWrapper<>();
|
||||
wrapper.orderByAsc("time");
|
||||
return precautionaryMapper.selectVoPage(Page, wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map count() {
|
||||
List<Precautionary> precautionaries = precautionaryMapper.selectList();
|
||||
Stream<Long> longStream = precautionaries.stream().map(Precautionary::getType);
|
||||
return Map.of();
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package org.dromara.sis.dubbo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.sis.api.RemoteSos;
|
||||
import org.dromara.sis.api.domain.RemoteAlarmRecord;
|
||||
import org.dromara.sis.domain.AlarmRecord;
|
||||
import org.dromara.sis.service.AlarmRecordService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@DubboService
|
||||
@RequiredArgsConstructor
|
||||
public class RemoteSosImpl implements RemoteSos {
|
||||
private final AlarmRecordService alarmRecordService;
|
||||
|
||||
@Override
|
||||
public List<RemoteAlarmRecord> getSoslist() {
|
||||
QueryWrapper<AlarmRecord> startTime = new QueryWrapper<AlarmRecord>();
|
||||
Page<AlarmRecord> page = alarmRecordService.page(new Page<>(1, 10));
|
||||
List<AlarmRecord> records = page.getRecords();
|
||||
List<RemoteAlarmRecord> remoteAlarmRecordList = new ArrayList<>();
|
||||
records.forEach(alarmRecord -> {
|
||||
RemoteAlarmRecord remoteAlarmRecord = new RemoteAlarmRecord();
|
||||
BeanUtils.copyProperties(alarmRecord, remoteAlarmRecord);
|
||||
remoteAlarmRecordList.add(remoteAlarmRecord);
|
||||
});
|
||||
return remoteAlarmRecordList;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Map sosCount() {
|
||||
List<AlarmRecord> list = alarmRecordService.list();
|
||||
//进行中
|
||||
long inprogress = list.stream().filter(alarmRecord -> alarmRecord.getState().equals("inprogress")).count();
|
||||
//已结束
|
||||
long finished = list.stream().filter(alarmRecord -> alarmRecord.getState().equals("finished")).count();
|
||||
//未接通
|
||||
long noAnswer = list.stream().filter(alarmRecord -> alarmRecord.getState().equals("noAnswer")).count();
|
||||
return Map.of("进行中", inprogress, "已结束", finished, "未接通", noAnswer,"总计", list.size());
|
||||
}
|
||||
}
|
@@ -29,5 +29,5 @@ public interface AlarmRecordService extends IService<AlarmRecord> {
|
||||
* @param operatorMap 操作记录映射,键为报警记录ID,值为对应操作记录列表
|
||||
* @return 成功保存的记录数
|
||||
*/
|
||||
int saveNewRecords(List<AlarmRecord> records, Map<Long, List<Map<String, Object>>> operatorMap);
|
||||
// int saveNewRecords(List<AlarmRecord> records, Map<Long, List<Map<String, Object>>> operatorMap);
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
||||
|
||||
@Autowired
|
||||
private AlarmTaskOperatorService taskOperatorService;
|
||||
@Autowired
|
||||
private PrecautionaryMapper precautionaryMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
@@ -46,10 +48,20 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
||||
|
||||
List<AlarmRecord> newRecords = new ArrayList<>();
|
||||
List<AlarmRecord> updateRecords = new ArrayList<>();
|
||||
List<Precautionary> newList=new ArrayList<>();
|
||||
|
||||
|
||||
// 分类处理记录
|
||||
for (AlarmRecord record : records) {
|
||||
if (existingRecordMap.containsKey(record.getId())) {
|
||||
Precautionary precautionary = new Precautionary();
|
||||
precautionary.setType(1L);
|
||||
precautionary.setTime(record.getCallTime());
|
||||
precautionary.setAddress(record.getDeviceName());
|
||||
precautionary.setMsg("SOS终端接警");
|
||||
precautionary.setStatus(0L);
|
||||
precautionary.setTaskId(record.getId());
|
||||
newList.add(precautionary);
|
||||
// 如果记录已存在,检查是否需要更新
|
||||
AlarmRecord existing = existingRecordMap.get(record.getId());
|
||||
if (hasRecordChanges(existing, record)) {
|
||||
@@ -58,6 +70,7 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
||||
} else {
|
||||
// 新记录
|
||||
newRecords.add(record);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,9 +81,12 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
||||
if (this.saveBatch(newRecords)) {
|
||||
result += newRecords.size();
|
||||
// 保存关联的操作记录
|
||||
saveRelatedOperators(newRecords, operatorMap);
|
||||
}
|
||||
}
|
||||
// 批量插入主表记录
|
||||
if (!newList.isEmpty()) {
|
||||
precautionaryMapper.insertOrUpdateBatch(newList);
|
||||
}
|
||||
|
||||
// 批量更新修改过的记录
|
||||
if (!updateRecords.isEmpty()) {
|
||||
@@ -125,38 +141,38 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int saveNewRecords(List<AlarmRecord> records, Map<Long, List<Map<String, Object>>> operatorMap) {
|
||||
if (records == null || records.isEmpty()) return 0;
|
||||
|
||||
// 提取待插入记录的ID列表
|
||||
List<Long> ids = records.stream().map(AlarmRecord::getId).collect(Collectors.toList());
|
||||
|
||||
// 查询数据库中已存在的记录
|
||||
LambdaQueryWrapper<AlarmRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(AlarmRecord::getId, ids);
|
||||
List<AlarmRecord> existingRecords = this.list(queryWrapper);
|
||||
List<Long> existingIds = existingRecords.stream().map(AlarmRecord::getId).collect(Collectors.toList());
|
||||
|
||||
// 过滤出新增记录
|
||||
List<AlarmRecord> newRecords = records.stream()
|
||||
.filter(record -> !existingIds.contains(record.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量插入新记录
|
||||
int savedCount = 0;
|
||||
if (!newRecords.isEmpty()) {
|
||||
if (this.saveBatch(newRecords)) {
|
||||
savedCount = newRecords.size();
|
||||
|
||||
// 保存关联的操作记录
|
||||
saveRelatedOperators(newRecords, operatorMap);
|
||||
}
|
||||
}
|
||||
return savedCount;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public int saveNewRecords(List<AlarmRecord> records, Map<Long, List<Map<String, Object>>> operatorMap) {
|
||||
// if (records == null || records.isEmpty()) return 0;
|
||||
//
|
||||
// // 提取待插入记录的ID列表
|
||||
// List<Long> ids = records.stream().map(AlarmRecord::getId).collect(Collectors.toList());
|
||||
//
|
||||
// // 查询数据库中已存在的记录
|
||||
// LambdaQueryWrapper<AlarmRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.in(AlarmRecord::getId, ids);
|
||||
// List<AlarmRecord> existingRecords = this.list(queryWrapper);
|
||||
// List<Long> existingIds = existingRecords.stream().map(AlarmRecord::getId).collect(Collectors.toList());
|
||||
//
|
||||
// // 过滤出新增记录
|
||||
// List<AlarmRecord> newRecords = records.stream()
|
||||
// .filter(record -> !existingIds.contains(record.getId()))
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// // 批量插入新记录
|
||||
// int savedCount = 0;
|
||||
// if (!newRecords.isEmpty()) {
|
||||
// if (this.saveBatch(newRecords)) {
|
||||
// savedCount = newRecords.size();
|
||||
//
|
||||
// // 保存关联的操作记录
|
||||
// saveRelatedOperators(newRecords, operatorMap);
|
||||
// }
|
||||
// }
|
||||
// return savedCount;
|
||||
// }
|
||||
|
||||
private void saveRelatedOperators(List<AlarmRecord> newRecords, Map<Long, List<Map<String, Object>>> operatorMap) {
|
||||
if (operatorMap == null || operatorMap.isEmpty()) return;
|
||||
|
Reference in New Issue
Block a user