增加事件自动指派操作
This commit is contained in:
@@ -18,6 +18,15 @@ public interface RemoteAttendanceService {
|
||||
* @param date 查询时间
|
||||
* @return 返回排班人员信息
|
||||
*/
|
||||
public List<RemoteAttendanceUserGroupVo> queryAttendPersonInfo(Date date);
|
||||
List<RemoteAttendanceUserGroupVo> queryAttendPersonInfo(Date date);
|
||||
|
||||
/**
|
||||
* 根据时间和设备ip查询当前设备所处区域的排班人员信息
|
||||
*
|
||||
* @param date 查询时间
|
||||
* @param deviceIp 设备ip
|
||||
* @return 返回排班人员信息
|
||||
*/
|
||||
List<RemoteAttendanceUserGroupVo> queryAttendByCurrDateAndDeviceIp(Date date, String deviceIp);
|
||||
|
||||
}
|
||||
|
@@ -49,5 +49,4 @@ public class RemoteAttendanceUserGroupVo implements Serializable {
|
||||
*/
|
||||
private LocalDate endDate;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -6,7 +6,9 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.property.api.RemoteAttendanceService;
|
||||
import org.dromara.property.api.domain.vo.RemoteAttendanceUserGroupVo;
|
||||
import org.dromara.property.domain.vo.attendanceVo.AttendanceAreaDeviceVo;
|
||||
import org.dromara.property.domain.vo.attendanceVo.AttendanceUserGroupVo;
|
||||
import org.dromara.property.service.attendanceService.IAttendanceAreaDeviceService;
|
||||
import org.dromara.property.service.attendanceService.IAttendanceUserGroupService;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -23,6 +25,7 @@ public class RemoteAttendanceServiceImpl implements RemoteAttendanceService {
|
||||
|
||||
|
||||
private final IAttendanceUserGroupService attendanceUserGroupService;
|
||||
private final IAttendanceAreaDeviceService attendanceAreaDeviceService;
|
||||
|
||||
|
||||
public List<RemoteAttendanceUserGroupVo> queryAttendPersonInfo(Date date) {
|
||||
@@ -33,4 +36,12 @@ public class RemoteAttendanceServiceImpl implements RemoteAttendanceService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RemoteAttendanceUserGroupVo> queryAttendByCurrDateAndDeviceIp(Date date, String deviceIp) {
|
||||
List<AttendanceUserGroupVo> ls = attendanceUserGroupService.queryAttendByCurrDateAndDeviceIp(date, deviceIp);
|
||||
if (CollUtil.isNotEmpty(ls)) {
|
||||
return BeanUtil.copyToList(ls, RemoteAttendanceUserGroupVo.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,12 @@
|
||||
package org.dromara.property.mapper.attendanceMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.property.domain.AttendanceUserGroup;
|
||||
import org.dromara.property.domain.vo.attendanceVo.AttendanceUserGroupVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 排班明细Mapper接口
|
||||
@@ -12,4 +16,12 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface AttendanceUserGroupMapper extends BaseMapperPlus<AttendanceUserGroup, AttendanceUserGroupVo> {
|
||||
|
||||
/**
|
||||
* 根据日期和设备ip 查询当前设备所在区域的排班人员信息
|
||||
*
|
||||
* @param date 查询日期
|
||||
* @param deviceIp 设备ip
|
||||
* @return 返回排班人员列表
|
||||
*/
|
||||
List<AttendanceUserGroupVo> queryAttendByCurrDateAndDeviceIp(@Param("currDate") Date currDate, @Param("deviceIp") String deviceIp);
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -65,4 +66,5 @@ public interface IAttendanceAreaDeviceService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
}
|
||||
|
@@ -75,6 +75,15 @@ public interface IAttendanceUserGroupService {
|
||||
*/
|
||||
List<AttendanceUserGroupVo> queryAttendPersonInfo(Date date);
|
||||
|
||||
|
||||
TableDataInfo<AttendanceUserGroupVo> queryScheduleView(AttendanceUserGroupBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据日期和设备ip 查询当前设备所在区域的排班人员信息
|
||||
*
|
||||
* @param date 查询日期
|
||||
* @param deviceIp 设备ip
|
||||
* @return 返回排班人员列表
|
||||
*/
|
||||
List<AttendanceUserGroupVo> queryAttendByCurrDateAndDeviceIp(Date date, String deviceIp);
|
||||
}
|
||||
|
@@ -299,4 +299,9 @@ public class AttendanceUserGroupServiceImpl implements IAttendanceUserGroupServi
|
||||
return TableDataInfo.build(attendanceArrangementVoPage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttendanceUserGroupVo> queryAttendByCurrDateAndDeviceIp(Date date, String deviceIp) {
|
||||
return this.baseMapper.queryAttendByCurrDateAndDeviceIp(date, deviceIp);
|
||||
}
|
||||
}
|
||||
|
@@ -4,4 +4,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.property.mapper.attendanceMapper.AttendanceUserGroupMapper">
|
||||
|
||||
<select id="queryAttendByCurrDateAndDeviceIp"
|
||||
resultType="org.dromara.property.domain.vo.attendanceVo.AttendanceUserGroupVo">
|
||||
|
||||
SELECT
|
||||
a.*
|
||||
FROM
|
||||
attendance_user_group a
|
||||
LEFT JOIN attendance_arrangement_area b ON a.schedule_id = b.shcedule_id
|
||||
LEFT JOIN attendance_area_device c ON b.area_id = c.area_id
|
||||
LEFT JOIN sis_device_manage d ON c.device_manage_id = d.id
|
||||
WHERE
|
||||
d.device_ip = #{deviceIp}
|
||||
AND a.start_date <= #{currDate}
|
||||
AND a.end_date > #{currDate}
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
@@ -2,6 +2,7 @@ package org.dromara.sis.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.sis.domain.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.bo.SisAlarmEventsBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmAssignmentBo;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmCompleteBo;
|
||||
@@ -79,7 +80,7 @@ public interface ISisAlarmEventsService {
|
||||
/**
|
||||
* 异步生成告警记录
|
||||
*/
|
||||
void createAlarmRecord(String deviceIp, Integer level, EventSmallTypeEnum type, String msg, byte[] smallImg, byte[] bigImg);
|
||||
SisAlarmEvents createAlarmRecord(String deviceIp, Integer level, EventSmallTypeEnum type, String msg, byte[] smallImg, byte[] bigImg);
|
||||
|
||||
/**
|
||||
* 任务分配操作
|
||||
|
@@ -1,7 +1,5 @@
|
||||
package org.dromara.sis.service;
|
||||
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
|
||||
public interface IZeroSensationPassageService {
|
||||
|
||||
/**
|
||||
|
@@ -37,7 +37,6 @@ import org.dromara.sis.service.ISisAlarmEventProcessService;
|
||||
import org.dromara.sis.service.ISisAlarmEventsService;
|
||||
import org.dromara.sis.service.ISisDeviceManageService;
|
||||
import org.dromara.system.api.model.LoginUser;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -179,15 +178,14 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createAlarmRecord(String deviceIp, Integer level, EventSmallTypeEnum type, String msg, byte[] smallImg, byte[] bigImg) {
|
||||
public SisAlarmEvents createAlarmRecord(String deviceIp, Integer level, EventSmallTypeEnum type, String msg, byte[] smallImg, byte[] bigImg) {
|
||||
// 校验设备信息
|
||||
SisDeviceManage sisDeviceManage = deviceManageService.queryByDeviceIp(deviceIp);
|
||||
if (sisDeviceManage == null) {
|
||||
log.error("设备信息不存在,放弃此条告警记录。");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
// 生成时间信息
|
||||
Date now = new Date();
|
||||
@@ -223,7 +221,6 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
alarmEventProcess.setReceiveTaskTag(0L);
|
||||
alarmEventProcess.setTenantId("");
|
||||
|
||||
|
||||
// 写入附件表
|
||||
List<SisAlarmEventAttachments> ls = new ArrayList<>();
|
||||
if (smallImg != null && smallImg.length > 0) {
|
||||
@@ -234,7 +231,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
}
|
||||
Boolean flag = alarmEventAttachmentsService.batchInsert(ls);
|
||||
log.info("写入告警事件附件表完成, reslut={}, size={}", flag, ls.size());
|
||||
|
||||
return alarmEvents;
|
||||
}
|
||||
|
||||
public SisAlarmEventAttachments createEventAttachments(byte[] img, SisAlarmEvents alarmEvents, SisDeviceManage sisDeviceManage) {
|
||||
|
@@ -9,8 +9,12 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.property.api.RemoteAttendanceService;
|
||||
import org.dromara.property.api.RemoteFloorService;
|
||||
import org.dromara.property.api.domain.vo.RemoteAttendanceUserGroupVo;
|
||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||
import org.dromara.sis.domain.SisAlarmEvents;
|
||||
import org.dromara.sis.domain.bo.alarm.AlarmAssignmentBo;
|
||||
import org.dromara.sis.domain.enums.ControlTypeEnum;
|
||||
import org.dromara.sis.domain.enums.EventSmallTypeEnum;
|
||||
import org.dromara.sis.domain.enums.RosterTypeEnum;
|
||||
@@ -22,12 +26,12 @@ import org.dromara.sis.sdk.huawei.HuaWeiBoxApi;
|
||||
import org.dromara.sis.sdk.huawei.domain.HWResult;
|
||||
import org.dromara.sis.sdk.smartDevices.utils.ElevatorControlTcpUtil;
|
||||
import org.dromara.sis.service.*;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 无感通行业务服务实现
|
||||
@@ -54,8 +58,13 @@ public class ZeroSensationPassageServiceImpl implements IZeroSensationPassageSer
|
||||
|
||||
@DubboReference
|
||||
private RemoteFloorService remoteFloorService;
|
||||
@DubboReference
|
||||
private RemoteAttendanceService remoteAttendanceService;
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void pass(String deviceIp, byte[] smallImg, byte[] bigImg) {
|
||||
TimeInterval interval = new TimeInterval();
|
||||
// 抓拍小图
|
||||
@@ -64,7 +73,7 @@ public class ZeroSensationPassageServiceImpl implements IZeroSensationPassageSer
|
||||
if (result.getCode() != 200) {
|
||||
log.info("华为盒子比对失败,msg={}", result.getMessage());
|
||||
// 产生告警数据 人脸比对失败,默认为
|
||||
alarmEventsService.createAlarmRecord(deviceIp, 2, EventSmallTypeEnum.SMART_REPORT_ZJCR, "人脸比对失败", smallImg, bigImg);
|
||||
handleAlarm(deviceIp, smallImg, bigImg, 2, EventSmallTypeEnum.SMART_REPORT_ZJCR, "人脸比对失败");
|
||||
return;
|
||||
}
|
||||
log.info("人脸比对执行完成,耗时:{}ms", interval.intervalMs());
|
||||
@@ -75,20 +84,20 @@ public class ZeroSensationPassageServiceImpl implements IZeroSensationPassageSer
|
||||
if (authRecord == null) {
|
||||
log.info("人员[{}]没有授权记录,判定为陌生人", person);
|
||||
// 不是内部人员 产生紧急的告警信息
|
||||
alarmEventsService.createAlarmRecord(deviceIp, 2, EventSmallTypeEnum.SMART_REPORT_ZJCR, "陌生人员入内", smallImg, bigImg);
|
||||
handleAlarm(deviceIp, smallImg, bigImg, 2, EventSmallTypeEnum.SMART_REPORT_ZJCR, "陌生人员入内");
|
||||
return;
|
||||
} else {
|
||||
if (Objects.equals(authRecord.getRosterType(), RosterTypeEnum.BLACK_LIST.getCode())) {
|
||||
log.info("人员[{}]在黑名单中,暂不处理。", person);
|
||||
alarmEventsService.createAlarmRecord(deviceIp, 3, EventSmallTypeEnum.BLACK_PERSON, "黑名单人员入内", smallImg, bigImg);
|
||||
log.info("黑名单人员[{}]。", person);
|
||||
handleAlarm(deviceIp, smallImg, bigImg, 3, EventSmallTypeEnum.BLACK_PERSON, "黑名单人员");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
if (DateUtil.compare(now, authRecord.getEndDate()) > 0) {
|
||||
alarmEventsService.createAlarmRecord(deviceIp, 1, EventSmallTypeEnum.AUTHORIZATION_EXPIRED, "人员授权信息已过期", smallImg, bigImg);
|
||||
log.info("当前人脸已过期,暂不处理。");
|
||||
handleAlarm(deviceIp, smallImg, bigImg, 1, EventSmallTypeEnum.AUTHORIZATION_EXPIRED, "人员授权信息已过期");
|
||||
log.info("当前人脸已过期。person={}", person);
|
||||
return;
|
||||
}
|
||||
// 获取当前设备的绑定设备信息
|
||||
@@ -128,6 +137,48 @@ public class ZeroSensationPassageServiceImpl implements IZeroSensationPassageSer
|
||||
log.info("权限下发执行完成,耗时:{}ms", interval.intervalMs());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理告警信息
|
||||
*
|
||||
* @param deviceIp 设备ip
|
||||
* @param smallImg 人脸小图
|
||||
* @param bigImg 人脸大图
|
||||
* @param smallType 事件类型
|
||||
*/
|
||||
private void handleAlarm(String deviceIp, byte[] smallImg, byte[] bigImg, Integer level, EventSmallTypeEnum smallType, String desc) {
|
||||
// 生成告警记录
|
||||
SisAlarmEvents alarmRecord = alarmEventsService.createAlarmRecord(deviceIp, level, smallType, desc, smallImg, bigImg);
|
||||
SaTokenContextMockUtil.setMockContext(() -> {
|
||||
// 如果当前设备区域存在排班人员,那么惊醒自动指派操作
|
||||
List<RemoteAttendanceUserGroupVo> userGroupVos = remoteAttendanceService.queryAttendByCurrDateAndDeviceIp(new Date(), deviceIp);
|
||||
if (CollUtil.isEmpty(userGroupVos)) {
|
||||
return;
|
||||
}
|
||||
// 进行自动指派操作
|
||||
RemoteAttendanceUserGroupVo currHandlePerson = null;
|
||||
if (userGroupVos.size() == 1) {
|
||||
currHandlePerson = userGroupVos.get(0);
|
||||
} else {
|
||||
// 生成一个排班人员课表的随机数
|
||||
Random random = new Random();
|
||||
int randomIndex = random.nextInt(userGroupVos.size());
|
||||
currHandlePerson = userGroupVos.get(randomIndex);
|
||||
}
|
||||
// 获取当前指派人员的详细信息
|
||||
RemoteUserVo userInfo = remoteUserService.getUserInfoById(currHandlePerson.getEmployeeId());
|
||||
// 任务指派操作
|
||||
AlarmAssignmentBo bo = new AlarmAssignmentBo();
|
||||
bo.setAlarmId(alarmRecord.getId());
|
||||
bo.setSolveId(userInfo.getUserId());
|
||||
bo.setSolveName(userInfo.getUserName());
|
||||
bo.setSolvePhone(userInfo.getPhonenumber());
|
||||
bo.setSolveEmail(userInfo.getEmail());
|
||||
bo.setRemark("系统自动指派");
|
||||
alarmEventsService.taskAssignment(bo);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 电梯外部按键触发
|
||||
*
|
||||
|
@@ -3,20 +3,18 @@ package org.dromara.resource.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.QueryGroup;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.property.api.RemoteVisitoreGetCodeInfoService;
|
||||
import org.dromara.resource.domain.QrCodeInfo;
|
||||
import org.dromara.resource.domain.bo.SysOssBo;
|
||||
import org.dromara.resource.domain.vo.SysOssUploadVo;
|
||||
import org.dromara.resource.domain.vo.SysOssVo;
|
||||
@@ -26,8 +24,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -46,6 +42,7 @@ public class SysOssController extends BaseController {
|
||||
private final ISysOssService iSysOssService;
|
||||
@DubboReference
|
||||
private RemoteVisitoreGetCodeInfoService remoteVisitoreGetCodeInfoService;
|
||||
|
||||
/**
|
||||
* 查询OSS对象存储列表
|
||||
*/
|
||||
@@ -125,6 +122,16 @@ public class SysOssController extends BaseController {
|
||||
iSysOssService.download(ossId, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出图片到浏览器
|
||||
*
|
||||
* @param ossId OSS对象ID
|
||||
*/
|
||||
@GetMapping(value = "/preview/{ossId}", produces = {MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE})
|
||||
public byte [] preview(@PathVariable Long ossId) throws IOException {
|
||||
return iSysOssService.downloadToByteArray(ossId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除OSS对象存储
|
||||
*
|
||||
|
@@ -109,4 +109,5 @@ public interface ISysOssService {
|
||||
* @return byte[] 返回下载的字节数组
|
||||
*/
|
||||
byte[] downloadToByteArray(Long ossId) throws IOException;
|
||||
|
||||
}
|
||||
|
@@ -306,5 +306,4 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
}
|
||||
return oss;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user