Merge remote-tracking branch 'origin/master'
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
@@ -25,6 +25,8 @@ public class RemoteResidentPersonVo implements Serializable {
|
|||||||
|
|
||||||
private Long gender;
|
private Long gender;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
private String idCard;
|
private String idCard;
|
||||||
|
|
||||||
private Long authGroupId;
|
private Long authGroupId;
|
||||||
|
@@ -2,6 +2,8 @@ package org.dromara.sis.api;
|
|||||||
|
|
||||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lsm
|
* @author lsm
|
||||||
* @apiNote RemoteSisAuth
|
* @apiNote RemoteSisAuth
|
||||||
@@ -10,4 +12,8 @@ import org.dromara.sis.api.domain.RemotePersonAuth;
|
|||||||
public interface RemoteSisAuth {
|
public interface RemoteSisAuth {
|
||||||
|
|
||||||
Boolean personAuth(RemotePersonAuth personAuth);
|
Boolean personAuth(RemotePersonAuth personAuth);
|
||||||
|
|
||||||
|
Boolean updatePersonAuth(RemotePersonAuth personAuth);
|
||||||
|
|
||||||
|
Boolean deletePersonAuth(Collection<Long> personId, Collection<Long> e8Ids);
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,8 @@ public class RemotePersonAuth implements Serializable {
|
|||||||
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
private Long e8Id;
|
||||||
|
|
||||||
private Integer cardType = 1;
|
private Integer cardType = 1;
|
||||||
|
|
||||||
private String idCardNumber;
|
private String idCardNumber;
|
||||||
|
@@ -8,6 +8,7 @@ import io.github.linpeilie.annotations.AutoMapper;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import jakarta.validation.constraints.*;
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,19 +25,19 @@ public class ResidentPersonBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
@NotNull(message = "主键id不能为空", groups = {EditGroup.class})
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名称
|
* 用户名称
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "用户名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "用户名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "联系电话不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String phone;
|
private String phone;
|
||||||
/**
|
/**
|
||||||
* 人员类型
|
* 人员类型
|
||||||
@@ -46,13 +47,13 @@ public class ResidentPersonBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 性别
|
* 性别
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "性别不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotNull(message = "性别不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Long gender;
|
private Long gender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 证件号
|
* 证件号
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "证件号不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "证件号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String idCard;
|
private String idCard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +114,7 @@ public class ResidentPersonBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private Long state=1L;
|
private Long state = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package org.dromara.property.service.impl;
|
package org.dromara.property.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
@@ -28,6 +29,8 @@ import javax.annotation.Resource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入驻员工Service业务层处理
|
* 入驻员工Service业务层处理
|
||||||
@@ -159,15 +162,60 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
|||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(ResidentPersonBo bo) {
|
public Boolean updateByBo(ResidentPersonBo bo) {
|
||||||
ResidentPerson update = MapstructUtils.convert(bo, ResidentPerson.class);
|
ResidentPerson update = MapstructUtils.convert(bo, ResidentPerson.class);
|
||||||
validEntityBeforeUpdate(update);
|
assert update != null;
|
||||||
return baseMapper.updateById(update) > 0;
|
|
||||||
|
boolean flag;
|
||||||
|
// 人脸照片存在时,才同步修改授权
|
||||||
|
if (update.getAuthGroupId() != null && update.getAuthEndDate() != null && update.getImg() != null) {
|
||||||
|
ResidentPersonVo vo = queryById(update.getId());
|
||||||
|
Long e8Id = vo.getEEightId();
|
||||||
|
flag = baseMapper.updateById(update) > 0;
|
||||||
|
|
||||||
|
// 显式移除e8id
|
||||||
|
LambdaUpdateWrapper<ResidentPerson> lqw = new LambdaUpdateWrapper<>();
|
||||||
|
lqw.eq(ResidentPerson::getId, update.getId())
|
||||||
|
.set(ResidentPerson::getEEightId, null);
|
||||||
|
baseMapper.update(lqw);
|
||||||
|
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
log.info("开始修改授权记录, {}", bo.getUserName());
|
||||||
|
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||||
|
personAuth.setId(update.getId());
|
||||||
|
personAuth.setName(update.getUserName());
|
||||||
|
personAuth.setSex(update.getGender().intValue());
|
||||||
|
personAuth.setPhone(update.getPhone());
|
||||||
|
personAuth.setEmail(update.getEmail());
|
||||||
|
personAuth.setIdCardNumber(update.getIdCard());
|
||||||
|
personAuth.setOssId(update.getImg());
|
||||||
|
personAuth.setCarNumber(update.getCarNumber());
|
||||||
|
personAuth.setE8Id(e8Id);
|
||||||
|
|
||||||
|
personAuth.setAuthGroupId(update.getAuthGroupId());
|
||||||
|
personAuth.setAuthBegDate(update.getAuthBegDate());
|
||||||
|
personAuth.setAuthEndDate(update.getAuthEndDate());
|
||||||
|
|
||||||
|
Boolean auth = remoteSisAuth.updatePersonAuth(personAuth);
|
||||||
|
Assert.isTrue(auth, "修改授权记录失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
flag = baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.isTrue(flag, "修改入驻员工失败!");
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeUpdate(ResidentPerson entity) {
|
private void validEntityBeforeUpdate(ResidentPerson entity) {
|
||||||
//TODO 做一些数据校验,如唯一约束
|
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(ResidentPerson::getIdCard, entity.getIdCard())
|
||||||
|
.eq(ResidentPerson::getUnitId, entity.getUnitId());
|
||||||
|
boolean exists = baseMapper.exists(lqw);
|
||||||
|
Assert.isTrue(!exists, "当前单位,{}已存在!", entity.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -200,9 +248,12 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
|||||||
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
|
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
|
||||||
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
|
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
|
||||||
|
|
||||||
boolean hasE8 = list.stream()
|
Collection<Long> e8Ids = list.stream()
|
||||||
.anyMatch(vo -> vo.getEEightId() != null); // 遇到第一个e8人员立即返回
|
.map(ResidentPersonVo::getEEightId)
|
||||||
Assert.isTrue(!hasE8, "当前存在人员已下发权限,请删除通行权限后再试!");
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
boolean auth = remoteSisAuth.deletePersonAuth(ids, e8Ids);
|
||||||
|
Assert.isTrue(auth, "删除授权记录失败!");
|
||||||
}
|
}
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
@@ -226,7 +277,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
|||||||
* @return List<ResidentPersonVo>
|
* @return List<ResidentPersonVo>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ResidentPersonVo> queryUnAuthPerson(){
|
public List<ResidentPersonVo> queryUnAuthPerson() {
|
||||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.isNotNull(ResidentPerson::getImg)
|
lqw.isNotNull(ResidentPerson::getImg)
|
||||||
.ne(ResidentPerson::getImg, "")
|
.ne(ResidentPerson::getImg, "")
|
||||||
|
@@ -83,13 +83,13 @@ public class SisAuthRecordController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改授权记录
|
* 修改授权记录
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("sis:authRecord:edit")
|
// @SaCheckPermission("sis:authRecord:edit")
|
||||||
@Log(title = "授权记录", businessType = BusinessType.UPDATE)
|
// @Log(title = "授权记录", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
// @RepeatSubmit()
|
||||||
@PutMapping()
|
// @PutMapping()
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SisAuthRecordBo bo) {
|
// public R<Void> edit(@Validated(EditGroup.class) @RequestBody SisAuthRecordBo bo) {
|
||||||
return toAjax(sisAuthRecordService.updateByBo(bo));
|
// return toAjax(sisAuthRecordService.updateByBo(bo));
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除授权记录
|
* 删除授权记录
|
||||||
|
@@ -15,6 +15,7 @@ import org.dromara.common.log.annotation.Log;
|
|||||||
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.web.core.BaseController;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||||
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
||||||
@@ -78,8 +79,9 @@ public class SisDeviceManageController extends BaseController {
|
|||||||
@Log(title = "设备管理", businessType = BusinessType.INSERT)
|
@Log(title = "设备管理", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SisDeviceManageBo bo) {
|
public R<Boolean> add(@Validated(AddGroup.class) @RequestBody SisDeviceManageBo bo) {
|
||||||
return toAjax(sisDeviceManageService.insertByBo(bo));
|
bo.setTenantId(LoginHelper.getTenantId());
|
||||||
|
return R.ok("设备添加成功", sisDeviceManageService.insertByBo(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package org.dromara.sis.controller.zkmedia;
|
package org.dromara.sis.controller.zkmedia;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.crypto.digest.MD5;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
||||||
@@ -48,8 +50,9 @@ public class ZKLmediaController {
|
|||||||
public R<AddStreamProxyResp> alarm(@RequestBody @Validated AddStreamProxy data) {
|
public R<AddStreamProxyResp> alarm(@RequestBody @Validated AddStreamProxy data) {
|
||||||
StartStreamProxy proxy = new StartStreamProxy();
|
StartStreamProxy proxy = new StartStreamProxy();
|
||||||
proxy.setApp("realtime");
|
proxy.setApp("realtime");
|
||||||
String s = IdUtil.fastSimpleUUID();
|
// 实时流不用每次都去拉流,流不存在的情况下在拉取
|
||||||
proxy.setStream(s);
|
String streanStr = data.getVideoIp() + "_" + data.getChannelId();
|
||||||
|
proxy.setStream(SecureUtil.md5(streanStr));
|
||||||
if (FactoryNoEnum.HIK.getCode().equals(data.getFactoryNo())) {
|
if (FactoryNoEnum.HIK.getCode().equals(data.getFactoryNo())) {
|
||||||
proxy.setUrl(String.format(HIK_REALTIME_RTSP_TEMPLATE, data.getAccount(), data.getPwd(), data.getVideoIp(), data.getVideoPort(), data.getChannelId()));
|
proxy.setUrl(String.format(HIK_REALTIME_RTSP_TEMPLATE, data.getAccount(), data.getPwd(), data.getVideoIp(), data.getVideoPort(), data.getChannelId()));
|
||||||
} else if (FactoryNoEnum.DAHUA.getCode().equals(data.getFactoryNo())) {
|
} else if (FactoryNoEnum.DAHUA.getCode().equals(data.getFactoryNo())) {
|
||||||
|
@@ -74,6 +74,7 @@ public class ZkMediaHookController {
|
|||||||
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
|
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
|
||||||
public HookResult onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param) {
|
public HookResult onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param) {
|
||||||
log.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
log.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||||
|
log.info("params={}", JSONObject.toJSONString(param));
|
||||||
return HookResult.SUCCESS();
|
return HookResult.SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,5 +74,33 @@ public class SisDeviceChannel extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String channelNo;
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 设备厂商编号
|
||||||
|
*/
|
||||||
|
private String nvrFactoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr设备ip
|
||||||
|
*/
|
||||||
|
private String nvrIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 端口
|
||||||
|
*/
|
||||||
|
private Integer nvrPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 账号
|
||||||
|
*/
|
||||||
|
private String nvrAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 密码
|
||||||
|
*/
|
||||||
|
private String nvrPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 通道编号
|
||||||
|
*/
|
||||||
|
private String nvrChannelNo;
|
||||||
}
|
}
|
||||||
|
@@ -78,4 +78,9 @@ public class SisPersonLibImg extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private Long residentPersonId;
|
private Long residentPersonId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片MD5
|
||||||
|
*/
|
||||||
|
private String imgMd5Value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
package org.dromara.sis.domain.bo;
|
package org.dromara.sis.domain.bo;
|
||||||
|
|
||||||
import org.dromara.sis.domain.SisDeviceChannel;
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
||||||
import org.dromara.common.core.validate.AddGroup;
|
|
||||||
import org.dromara.common.core.validate.EditGroup;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import jakarta.validation.constraints.*;
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.sis.domain.SisDeviceChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备通道管理业务对象 sis_device_channel
|
* 设备通道管理业务对象 sis_device_channel
|
||||||
@@ -23,13 +24,13 @@ public class SisDeviceChannelBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
@NotNull(message = "主键id不能为空", groups = {EditGroup.class})
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备id
|
* 设备id
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "设备id不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotNull(message = "设备id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,31 +43,31 @@ public class SisDeviceChannelBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 通道分组组id
|
* 通道分组组id
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "通道分组组id不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotNull(message = "通道分组组id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备ip
|
* 设备ip
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "设备ip不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "设备ip不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String deviceIp;
|
private String deviceIp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备端口
|
* 设备端口
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "设备端口不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotNull(message = "设备端口不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private Integer devicePort;
|
private Integer devicePort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备账号
|
* 设备账号
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "设备账号不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "设备账号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String deviceAccount;
|
private String deviceAccount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备密码
|
* 设备密码
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "设备密码不能为空", groups = { AddGroup.class, EditGroup.class })
|
@NotBlank(message = "设备密码不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||||
private String devicePwd;
|
private String devicePwd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,5 +80,36 @@ public class SisDeviceChannelBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String channelNo;
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 设备厂商编号
|
||||||
|
*/
|
||||||
|
private String nvrFactoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr设备ip
|
||||||
|
*/
|
||||||
|
private String nvrIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 端口
|
||||||
|
*/
|
||||||
|
private Integer nvrPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 账号
|
||||||
|
*/
|
||||||
|
private String nvrAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 密码
|
||||||
|
*/
|
||||||
|
private String nvrPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 通道编号
|
||||||
|
*/
|
||||||
|
private String nvrChannelNo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import org.dromara.common.core.validate.AddGroup;
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
import org.dromara.common.core.validate.EditGroup;
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
import org.dromara.common.translation.annotation.Translation;
|
|
||||||
import org.dromara.sis.domain.SisDeviceManage;
|
import org.dromara.sis.domain.SisDeviceManage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,5 +77,6 @@ public class SisDeviceManageBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -86,4 +86,9 @@ public class SisPersonLibImgBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long residentPersonId;
|
private Long residentPersonId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片MD5
|
||||||
|
*/
|
||||||
|
private String imgMd5Value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,8 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum FactoryNoEnum {
|
public enum FactoryNoEnum {
|
||||||
|
|
||||||
HIK("DS1013"),
|
HIK("1"),
|
||||||
DAHUA("DS1014");
|
DAHUA("2");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
@@ -90,5 +90,33 @@ public class SisDeviceChannelVo implements Serializable {
|
|||||||
@ExcelProperty(value = "设备通道编号")
|
@ExcelProperty(value = "设备通道编号")
|
||||||
private String channelNo;
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 设备厂商编号
|
||||||
|
*/
|
||||||
|
private String nvrFactoryNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr设备ip
|
||||||
|
*/
|
||||||
|
private String nvrIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 端口
|
||||||
|
*/
|
||||||
|
private Integer nvrPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 账号
|
||||||
|
*/
|
||||||
|
private String nvrAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 密码
|
||||||
|
*/
|
||||||
|
private String nvrPwd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nvr 通道编号
|
||||||
|
*/
|
||||||
|
private String nvrChannelNo;
|
||||||
}
|
}
|
||||||
|
@@ -96,4 +96,10 @@ public class SisPersonLibImgVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "入驻员工id")
|
@ExcelProperty(value = "入驻员工id")
|
||||||
private Long residentPersonId;
|
private Long residentPersonId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片MD5
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "图片MD5")
|
||||||
|
private String imgMd5Value;
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,8 @@ import org.dromara.sis.api.RemoteSisAuth;
|
|||||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||||
import org.dromara.sis.service.ISisAuthRecordService;
|
import org.dromara.sis.service.ISisAuthRecordService;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lsm
|
* @author lsm
|
||||||
* @apiNote RemoteSisAuthImpl
|
* @apiNote RemoteSisAuthImpl
|
||||||
@@ -23,4 +25,14 @@ public class RemoteSisAuthImpl implements RemoteSisAuth {
|
|||||||
public Boolean personAuth(RemotePersonAuth personAuth) {
|
public Boolean personAuth(RemotePersonAuth personAuth) {
|
||||||
return sisAuthRecordService.insertByPerson(personAuth);
|
return sisAuthRecordService.insertByPerson(personAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updatePersonAuth(RemotePersonAuth personAuth) {
|
||||||
|
return sisAuthRecordService.updateByBo(personAuth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean deletePersonAuth(Collection<Long> ids, Collection<Long> e8Ids) {
|
||||||
|
return sisAuthRecordService.deleteByPersonIds(ids, e8Ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package org.dromara.sis.sdk.hik.model;
|
package org.dromara.sis.sdk.hik.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ public class DeviceInfo {
|
|||||||
*/
|
*/
|
||||||
private Integer dwStartDChan;
|
private Integer dwStartDChan;
|
||||||
|
|
||||||
|
private String factoryNo = FactoryNoEnum.HIK.getCode();
|
||||||
|
|
||||||
private List<DeviceChannelInfo> channelInfo;
|
private List<DeviceChannelInfo> channelInfo;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@@ -52,12 +52,12 @@ public interface ISisAuthRecordService {
|
|||||||
Boolean insertByPerson(RemotePersonAuth bo);
|
Boolean insertByPerson(RemotePersonAuth bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改授权记录
|
* 修改授权记录(单个)
|
||||||
*
|
*
|
||||||
* @param bo 授权记录
|
* @param bo 授权记录
|
||||||
* @return 是否修改成功
|
* @return 是否修改成功
|
||||||
*/
|
*/
|
||||||
Boolean updateByBo(SisAuthRecordBo bo);
|
Boolean updateByBo(RemotePersonAuth bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验并批量删除授权记录信息
|
* 校验并批量删除授权记录信息
|
||||||
@@ -105,4 +105,13 @@ public interface ISisAuthRecordService {
|
|||||||
* @return SisAuthRecordVo
|
* @return SisAuthRecordVo
|
||||||
*/
|
*/
|
||||||
SisAuthRecordVo queryByGroupIdAndPersonId(Long groupId, Long personId);
|
SisAuthRecordVo queryByGroupIdAndPersonId(Long groupId, Long personId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除授权记录
|
||||||
|
*
|
||||||
|
* @param ids 入驻员工ids
|
||||||
|
* @param e8Ids e8id
|
||||||
|
*/
|
||||||
|
Boolean deleteByPersonIds(Collection<Long> ids, Collection<Long> e8Ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ import org.dromara.sis.domain.SisDeviceChannel;
|
|||||||
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
||||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||||
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
||||||
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -85,13 +86,16 @@ public interface ISisDeviceChannelService {
|
|||||||
List<TreeNode<Long>> queryTree();
|
List<TreeNode<Long>> queryTree();
|
||||||
|
|
||||||
|
|
||||||
Boolean handleHikDeviceChannel(SisDeviceManageBo bo);
|
void handleHikDeviceChannel(SisDeviceManageBo bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过设备ids 删除设备通道信息
|
* 通过设备ids 删除设备通道信息
|
||||||
|
*
|
||||||
* @param deviceIds 设备ids
|
* @param deviceIds 设备ids
|
||||||
* @return 返回删除数量
|
* @return 返回删除数量
|
||||||
*/
|
*/
|
||||||
Integer deleteByDeviceIds(List<Long> deviceIds);
|
Integer deleteByDeviceIds(List<Long> deviceIds);
|
||||||
|
|
||||||
|
SisDeviceChannel queryByChannelIp(String channelIp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,23 @@ public interface ISisPersonLibImgService {
|
|||||||
*
|
*
|
||||||
* @param personId 入驻员工id
|
* @param personId 入驻员工id
|
||||||
* @param huaweiBoxId 华为盒子图像id
|
* @param huaweiBoxId 华为盒子图像id
|
||||||
|
* @param imgMd5 图片md5值
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
Boolean updateByPersonId(Long personId, Long huaweiBoxId);
|
Boolean updateByPersonId(Long personId, Long huaweiBoxId, String imgMd5);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据图片MD5,查询图片
|
||||||
|
*
|
||||||
|
* @param imgMd5 图片MD5
|
||||||
|
*/
|
||||||
|
SisPersonLibImgVo queryByImgMd5(String imgMd5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据入驻员工id,查询图片
|
||||||
|
*
|
||||||
|
* @param personId 入驻员工id
|
||||||
|
*/
|
||||||
|
SisPersonLibImgVo queryByPersonId(Long personId);
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@ package org.dromara.sis.service.impl;
|
|||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.dromara.common.core.domain.TreeNode;
|
import org.dromara.common.core.domain.TreeNode;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -13,12 +12,15 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.property.api.RemoteFloorService;
|
import org.dromara.property.api.RemoteFloorService;
|
||||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||||
|
import org.dromara.resource.api.RemoteFileService;
|
||||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||||
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
||||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||||
import org.dromara.sis.domain.bo.SisPersonLibImgBo;
|
import org.dromara.sis.domain.bo.SisPersonLibImgBo;
|
||||||
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
||||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||||
|
import org.dromara.sis.domain.vo.SisPersonLibImgVo;
|
||||||
|
import org.dromara.sis.sdk.e8.E8PlatformApi;
|
||||||
import org.dromara.sis.service.*;
|
import org.dromara.sis.service.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||||
@@ -27,6 +29,7 @@ import org.dromara.sis.domain.SisAuthRecord;
|
|||||||
import org.dromara.sis.mapper.SisAuthRecordMapper;
|
import org.dromara.sis.mapper.SisAuthRecordMapper;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +43,8 @@ import java.util.*;
|
|||||||
@Service
|
@Service
|
||||||
public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||||
|
|
||||||
|
private final E8PlatformApi e8PlatformApi;
|
||||||
|
|
||||||
private final SisAuthRecordMapper baseMapper;
|
private final SisAuthRecordMapper baseMapper;
|
||||||
private final ISisElevatorInfoService elevatorInfoService;
|
private final ISisElevatorInfoService elevatorInfoService;
|
||||||
private final ISisPersonLibImgService sisPersonLibImgService;
|
private final ISisPersonLibImgService sisPersonLibImgService;
|
||||||
@@ -48,6 +53,9 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
|||||||
@DubboReference
|
@DubboReference
|
||||||
private RemoteFloorService remoteFloorService;
|
private RemoteFloorService remoteFloorService;
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private RemoteFileService remoteFileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询授权记录
|
* 查询授权记录
|
||||||
*
|
*
|
||||||
@@ -112,30 +120,69 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
|||||||
add.setGroupId(bo.getAuthGroupId());
|
add.setGroupId(bo.getAuthGroupId());
|
||||||
add.setBegDate(bo.getAuthBegDate());
|
add.setBegDate(bo.getAuthBegDate());
|
||||||
add.setEndDate(bo.getAuthEndDate());
|
add.setEndDate(bo.getAuthEndDate());
|
||||||
|
add.setTenantId("000000");
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
Assert.isTrue(flag, "新增授权记录失败");
|
Assert.isTrue(flag, "新增授权记录失败");
|
||||||
|
|
||||||
if (flag) {
|
try {
|
||||||
|
// 记录图片md5值
|
||||||
|
byte[] imgByte = remoteFileService.downloadToByteArray(Long.parseLong(bo.getOssId()));
|
||||||
|
String md5 = calculateMD5(imgByte);
|
||||||
// 写入安防人像信息
|
// 写入安防人像信息
|
||||||
this.syncPersonImg(bo);
|
this.syncPersonImg(bo, md5);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("下载图片失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncPersonImg(RemotePersonAuth bo) {
|
private void syncPersonImg(RemotePersonAuth bo, String md5) {
|
||||||
log.info("开始写入安防人像信息");
|
log.info("开始写入安防人像信息");
|
||||||
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
||||||
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
||||||
|
personLibImg.setTel(bo.getPhone());
|
||||||
personLibImg.setImgName(bo.getName());
|
personLibImg.setImgName(bo.getName());
|
||||||
personLibImg.setSex(bo.getSex());
|
personLibImg.setSex(bo.getSex());
|
||||||
personLibImg.setCertificateType(1);
|
personLibImg.setCertificateType(1);
|
||||||
personLibImg.setCertificateNo(bo.getIdCardNumber());
|
personLibImg.setCertificateNo(bo.getIdCardNumber());
|
||||||
personLibImg.setResidentPersonId(bo.getId());
|
personLibImg.setResidentPersonId(bo.getId());
|
||||||
|
personLibImg.setImgMd5Value(md5);
|
||||||
sisPersonLibImgService.insertByBo(personLibImg);
|
sisPersonLibImgService.insertByBo(personLibImg);
|
||||||
log.info("写入安防人像信息完成");
|
log.info("写入安防人像信息完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接计算字节数组的MD5值
|
||||||
|
*
|
||||||
|
* @param data 图片的字节数组
|
||||||
|
* @return 32位小写MD5字符串
|
||||||
|
*/
|
||||||
|
private String calculateMD5(byte[] data) throws Exception {
|
||||||
|
if (data == null) {
|
||||||
|
throw new IllegalArgumentException("输入数据不能为null");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(data);
|
||||||
|
return bytesToHex(md.digest());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字节数组转十六进制字符串
|
||||||
|
*
|
||||||
|
* @param bytes 字节数组
|
||||||
|
* @return 32位十六进制字符串
|
||||||
|
*/
|
||||||
|
private String bytesToHex(byte[] bytes) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : bytes) {
|
||||||
|
// %02x 表示两位小写十六进制,不足两位补0
|
||||||
|
sb.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改授权记录
|
* 修改授权记录
|
||||||
*
|
*
|
||||||
@@ -143,10 +190,25 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
|||||||
* @return 是否修改成功
|
* @return 是否修改成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(SisAuthRecordBo bo) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
SisAuthRecord update = MapstructUtils.convert(bo, SisAuthRecord.class);
|
public Boolean updateByBo(RemotePersonAuth bo) {
|
||||||
validEntityBeforeSave(update);
|
LambdaQueryWrapper<SisAuthRecord> lqw = new LambdaQueryWrapper<>();
|
||||||
return baseMapper.updateById(update) > 0;
|
lqw.eq(SisAuthRecord::getTargetId, bo.getId());
|
||||||
|
boolean flag = baseMapper.delete(lqw) > 0;
|
||||||
|
Assert.isTrue(flag, "删除授权记录失败");
|
||||||
|
|
||||||
|
// 删除人像库图片
|
||||||
|
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByPersonId(bo.getId());
|
||||||
|
if (imgVo != null) {
|
||||||
|
flag = sisPersonLibImgService.deleteWithValidByIds(List.of(imgVo.getId()), false);
|
||||||
|
Assert.isTrue(flag, "删除人像库图片失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除e8人员
|
||||||
|
flag = e8PlatformApi.deleteCustomer(bo.getE8Id());
|
||||||
|
Assert.isTrue(flag, "删除e8人员失败");
|
||||||
|
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,4 +335,36 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
|||||||
.eq(SisAuthRecord::getTargetId, personId);
|
.eq(SisAuthRecord::getTargetId, personId);
|
||||||
return baseMapper.selectVoOne(lqw);
|
return baseMapper.selectVoOne(lqw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除授权记录
|
||||||
|
*
|
||||||
|
* @param ids 入驻员工ids
|
||||||
|
* @param e8Ids e8id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Boolean deleteByPersonIds(Collection<Long> ids, Collection<Long> e8Ids) {
|
||||||
|
LambdaQueryWrapper<SisAuthRecord> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.in(SisAuthRecord::getTargetId, ids);
|
||||||
|
boolean flag = baseMapper.delete(lqw) > 0;
|
||||||
|
Assert.isTrue(flag, "删除授权记录失败");
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
|
||||||
|
List<SisPersonLibImgVo> list = new ArrayList<>();
|
||||||
|
ids.forEach(id -> {
|
||||||
|
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByPersonId(id);
|
||||||
|
if (imgVo != null) {
|
||||||
|
list.add(imgVo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Collection<Long> imgIds = list.stream().map(SisPersonLibImgVo::getId).toList();
|
||||||
|
flag = sisPersonLibImgService.deleteWithValidByIds(imgIds, false);
|
||||||
|
Assert.isTrue(flag, "删除人像库图片失败");
|
||||||
|
|
||||||
|
e8Ids.forEach(e8PlatformApi::deleteCustomer);
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package org.dromara.sis.service.impl;
|
package org.dromara.sis.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -24,6 +25,7 @@ import org.dromara.sis.sdk.hik.HikSdkConstans;
|
|||||||
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||||
import org.dromara.sis.service.ISisDeviceChannelService;
|
import org.dromara.sis.service.ISisDeviceChannelService;
|
||||||
import org.dromara.sis.service.ISisDeviceGroupService;
|
import org.dromara.sis.service.ISisDeviceGroupService;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -194,54 +196,98 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
return TreeUtils.build(treeNodes, -1L);
|
return TreeUtils.build(treeNodes, -1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public Boolean handleHikDeviceChannel(SisDeviceManageBo bo) {
|
public void handleHikDeviceChannel(SisDeviceManageBo bo) {
|
||||||
// 调用hik sdk登录
|
// 调用hik sdk登录
|
||||||
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
|
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
|
||||||
if (!isLogin) {
|
if (!isLogin) {
|
||||||
throw new RuntimeException("海康设备添加失败.");
|
throw new RuntimeException("海康设备添加失败.");
|
||||||
}
|
}
|
||||||
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
|
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
|
||||||
// 写入设备通道信息
|
// 校验设备通道是否存在,如果存在则放弃添加
|
||||||
SisDeviceChannel channel = new SisDeviceChannel();
|
SisDeviceChannel channel1 = this.queryByChannelIp(bo.getDeviceIp());
|
||||||
channel.setDeviceId(bo.getId());
|
if (channel1 != null) {
|
||||||
channel.setChannelName(bo.getDeviceName());
|
// 写入设备通道信息
|
||||||
channel.setGroupId(bo.getGroupId());
|
SisDeviceChannel channel = new SisDeviceChannel();
|
||||||
channel.setDeviceIp(bo.getDeviceIp());
|
channel.setDeviceId(bo.getId());
|
||||||
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
channel.setChannelName(bo.getDeviceName());
|
||||||
channel.setFactoryNo(bo.getFactoryNo());
|
channel.setGroupId(bo.getGroupId());
|
||||||
channel.setDeviceAccount(bo.getDeviceAccount());
|
channel.setDeviceIp(bo.getDeviceIp());
|
||||||
channel.setDevicePwd(bo.getDevicePwd());
|
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||||
channel.setDeviceMac(bo.getDeviceMac());
|
channel.setFactoryNo(bo.getFactoryNo());
|
||||||
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
channel.setDeviceAccount(bo.getDeviceAccount());
|
||||||
this.insert(channel);
|
channel.setDevicePwd(bo.getDevicePwd());
|
||||||
return true;
|
channel.setDeviceMac(bo.getDeviceMac());
|
||||||
|
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||||
|
channel.setTenantId(bo.getTenantId());
|
||||||
|
Boolean insert = this.insert(channel);
|
||||||
|
log.info("设备[{}]通道添加完成,result={}", bo.getDeviceIp(), insert);
|
||||||
|
} else {
|
||||||
|
log.info("设备通道[{}]已存在,放弃添加通道信息", bo.getDeviceIp());
|
||||||
|
}
|
||||||
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType()) || DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
|
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType()) || DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
|
||||||
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(bo.getDeviceIp());
|
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(bo.getDeviceIp());
|
||||||
if (channelInfo != null && CollUtil.isNotEmpty(channelInfo.getChannelInfo())) {
|
if (channelInfo != null && CollUtil.isNotEmpty(channelInfo.getChannelInfo())) {
|
||||||
List<SisDeviceChannel> channels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
List<SisDeviceChannel> insertChannels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||||
|
List<SisDeviceChannel> updateChannels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||||
channelInfo.getChannelInfo().forEach(item -> {
|
channelInfo.getChannelInfo().forEach(item -> {
|
||||||
SisDeviceChannel channel = new SisDeviceChannel();
|
// 校验通道信息是否存在
|
||||||
|
SisDeviceChannel channel = queryByChannelIp(item.getChannelIp());
|
||||||
|
boolean isUpdate = true;
|
||||||
|
if (channel == null) {
|
||||||
|
channel = new SisDeviceChannel();
|
||||||
|
isUpdate = false;
|
||||||
|
}
|
||||||
|
// 通道设备信息
|
||||||
|
channel.setDeviceIp(item.getChannelIp());
|
||||||
|
channel.setDevicePort(Integer.valueOf(item.getChannelPort()));
|
||||||
|
channel.setDeviceAccount(item.getChannelAccount());
|
||||||
|
channel.setFactoryNo(channelInfo.getFactoryNo());
|
||||||
|
if (StrUtil.isNotEmpty(item.getChannelPwd())) {
|
||||||
|
channel.setDevicePwd(item.getChannelPwd());
|
||||||
|
}
|
||||||
|
// nvr 设备信息
|
||||||
|
channel.setNvrIp(bo.getDeviceIp());
|
||||||
|
channel.setNvrPort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||||
|
channel.setNvrAccount(bo.getDeviceAccount());
|
||||||
|
channel.setNvrPwd(bo.getDevicePwd());
|
||||||
|
channel.setNvrFactoryNo(bo.getFactoryNo());
|
||||||
|
channel.setNvrChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
||||||
|
|
||||||
|
// 系统设备信息
|
||||||
|
channel.setDeviceMac(bo.getDeviceMac());
|
||||||
|
// 将设备id 更改为nvr的设备id
|
||||||
channel.setDeviceId(bo.getId());
|
channel.setDeviceId(bo.getId());
|
||||||
channel.setGroupId(bo.getGroupId());
|
channel.setGroupId(bo.getGroupId());
|
||||||
channel.setDeviceIp(bo.getDeviceIp());
|
|
||||||
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
|
||||||
channel.setFactoryNo(bo.getFactoryNo());
|
|
||||||
channel.setDeviceAccount(bo.getDeviceAccount());
|
|
||||||
channel.setDevicePwd(bo.getDevicePwd());
|
|
||||||
channel.setDeviceMac(bo.getDeviceMac());
|
|
||||||
|
|
||||||
channel.setChannelName(item.getChannelName());
|
channel.setChannelName(item.getChannelName());
|
||||||
channel.setChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
channel.setChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
||||||
channels.add(channel);
|
channel.setTenantId(bo.getTenantId());
|
||||||
|
if (isUpdate) {
|
||||||
|
updateChannels.add(channel);
|
||||||
|
} else {
|
||||||
|
insertChannels.add(channel);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.baseMapper.insertBatch(channels);
|
// 更新通道信息
|
||||||
|
if (CollUtil.isNotEmpty(updateChannels)) {
|
||||||
|
this.baseMapper.updateBatchById(updateChannels);
|
||||||
|
}
|
||||||
|
// 写入新的通道信息
|
||||||
|
if (CollUtil.isNotEmpty(insertChannels)) {
|
||||||
|
this.baseMapper.insertBatch(insertChannels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
log.info("未知的设备类型,不处理。");
|
log.info("未知的设备类型,不处理。");
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SisDeviceChannel queryByChannelIp(String channelIp) {
|
||||||
|
LambdaQueryWrapper<SisDeviceChannel> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SisDeviceChannel::getDeviceIp, channelIp);
|
||||||
|
return baseMapper.selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -250,4 +296,5 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
|||||||
lqw.in(SisDeviceChannel::getDeviceId, deviceIds);
|
lqw.in(SisDeviceChannel::getDeviceId, deviceIds);
|
||||||
return baseMapper.delete(lqw);
|
return baseMapper.delete(lqw);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,8 @@ import org.dromara.sis.service.ISisDeviceManageService;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
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.web.context.request.RequestAttributes;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -104,18 +106,13 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
// 获取设备通道信息
|
// 获取设备通道信息
|
||||||
handleDeviceChannelInfo(bo);
|
if (Objects.equals(bo.getFactoryNo(), FactoryNoEnum.HIK.getCode())) {
|
||||||
|
deviceChannelService.handleHikDeviceChannel(bo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDeviceChannelInfo(SisDeviceManageBo bo) {
|
|
||||||
if (Objects.equals(bo.getFactoryNo(), FactoryNoEnum.HIK.getCode())) {
|
|
||||||
deviceChannelService.handleHikDeviceChannel(bo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备管理
|
* 修改设备管理
|
||||||
*
|
*
|
||||||
@@ -165,24 +162,16 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
|||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void deleteDeviceRef(List<SisDeviceManage> sisDeviceManages) {
|
public void deleteDeviceRef(List<SisDeviceManage> sisDeviceManages) {
|
||||||
List<Long> deviceIds = new ArrayList<>(sisDeviceManages.size());
|
List<Long> deviceIds = new ArrayList<>();
|
||||||
Map<String, List<SisDeviceManage>> factoryGroup = new HashMap<>(10);
|
sisDeviceManages.forEach(item -> {
|
||||||
sisDeviceManages.forEach(sisDeviceManage -> {
|
// 删除设备
|
||||||
deviceIds.add(sisDeviceManage.getId());
|
deviceIds.add(item.getId());
|
||||||
factoryGroup.computeIfAbsent(sisDeviceManage.getFactoryNo(), k -> new ArrayList<>()).add(sisDeviceManage);
|
if (FactoryNoEnum.HIK.getCode().equals(item.getFactoryNo())) {
|
||||||
|
HikApiService.getInstance().loginOut(item.getDeviceIp());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// 删除设备通道
|
|
||||||
int num = deviceChannelService.deleteByDeviceIds(deviceIds);
|
int num = deviceChannelService.deleteByDeviceIds(deviceIds);
|
||||||
log.info("删除设备通道完成,num={}", num);
|
log.info("删除设备通道完成,num={}", num);
|
||||||
// 设备sdk注销
|
|
||||||
for (Map.Entry<String, List<SisDeviceManage>> entry : factoryGroup.entrySet()) {
|
|
||||||
if (entry.getKey().equals(FactoryNoEnum.HIK.getCode())) {
|
|
||||||
entry.getValue().forEach(item -> {
|
|
||||||
HikApiService.getInstance().loginOut(item.getDeviceIp());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -118,6 +118,8 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean insertByBo(SisPersonLibImgBo bo) {
|
public Boolean insertByBo(SisPersonLibImgBo bo) {
|
||||||
SisPersonLibImg add = MapstructUtils.convert(bo, SisPersonLibImg.class);
|
SisPersonLibImg add = MapstructUtils.convert(bo, SisPersonLibImg.class);
|
||||||
|
assert add != null;
|
||||||
|
add.setTenantId("000000");
|
||||||
Assert.notNull(add, "数据处理失败");
|
Assert.notNull(add, "数据处理失败");
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
Assert.isTrue(flag, "新增数据失败");
|
Assert.isTrue(flag, "新增数据失败");
|
||||||
@@ -165,7 +167,7 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
|||||||
boolean flag = baseMapper.deleteByIds(ids) > 0;
|
boolean flag = baseMapper.deleteByIds(ids) > 0;
|
||||||
Assert.isTrue(flag, "删除失败");
|
Assert.isTrue(flag, "删除失败");
|
||||||
|
|
||||||
return true;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,16 +184,47 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
|||||||
/**
|
/**
|
||||||
* 根据入驻员工id,更新huaweiBoxId
|
* 根据入驻员工id,更新huaweiBoxId
|
||||||
*
|
*
|
||||||
* @param personId 入驻员工id
|
* @param personId 入驻员工id
|
||||||
* @param huaweiBoxId 华为盒子图像id
|
* @param huaweiBoxId 华为盒子图像id
|
||||||
|
* @param imgMd5 图片md5值
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateByPersonId(Long personId, Long huaweiBoxId){
|
public Boolean updateByPersonId(Long personId, Long huaweiBoxId, String imgMd5) {
|
||||||
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||||
lqw.eq(SisPersonLibImg::getResidentPersonId, personId);
|
lqw.eq(SisPersonLibImg::getResidentPersonId, personId);
|
||||||
SisPersonLibImg update = new SisPersonLibImg();
|
SisPersonLibImg update = new SisPersonLibImg();
|
||||||
update.setRemoteImgId(huaweiBoxId);
|
update.setRemoteImgId(huaweiBoxId);
|
||||||
|
update.setImgMd5Value(imgMd5);
|
||||||
return baseMapper.update(update, lqw) > 0;
|
return baseMapper.update(update, lqw) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据图片MD5,查询图片
|
||||||
|
*
|
||||||
|
* @param imgMd5 图片MD5
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SisPersonLibImgVo queryByImgMd5(String imgMd5) {
|
||||||
|
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.eq(SisPersonLibImg::getImgMd5Value, imgMd5);
|
||||||
|
List<SisPersonLibImgVo> list = baseMapper.selectVoList(lqw);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return list.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据入驻员工id,查询图片
|
||||||
|
*
|
||||||
|
* @param personId 入驻员工id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SisPersonLibImgVo queryByPersonId(Long personId) {
|
||||||
|
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||||
|
lqw.eq(SisPersonLibImg::getResidentPersonId, personId);
|
||||||
|
return baseMapper.selectVoOne(lqw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ public class AuthSyncTask {
|
|||||||
// 需要先设置模拟上下文
|
// 需要先设置模拟上下文
|
||||||
SaTokenContextMockUtil.setMockContext(() -> {
|
SaTokenContextMockUtil.setMockContext(() -> {
|
||||||
// 模拟登录
|
// 模拟登录
|
||||||
StpUtil.login(1); // 模拟登录
|
StpUtil.login(1);
|
||||||
unAuthPersonRef.set(remoteResidentPersonService.queryUnAuthPerson());
|
unAuthPersonRef.set(remoteResidentPersonService.queryUnAuthPerson());
|
||||||
List<RemoteResidentPersonVo> unAuthPerson = unAuthPersonRef.get();
|
List<RemoteResidentPersonVo> unAuthPerson = unAuthPersonRef.get();
|
||||||
|
|
||||||
@@ -89,12 +90,25 @@ public class AuthSyncTask {
|
|||||||
byte[] imgByte = imgByteRef.get();
|
byte[] imgByte = imgByteRef.get();
|
||||||
if (imgByte == null) continue;
|
if (imgByte == null) continue;
|
||||||
|
|
||||||
// 写入华为盒子
|
String nowMd5 = this.calculateMD5(imgByte);
|
||||||
Long huaweiId = syncHuaweiBox(person, imgByte);
|
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByImgMd5(nowMd5);
|
||||||
|
|
||||||
|
Long huaweiId;
|
||||||
|
Boolean update;
|
||||||
|
if (ObjectUtil.isEmpty(imgVo)) {
|
||||||
|
// 写入华为盒子
|
||||||
|
huaweiId = syncHuaweiBox(person, imgByte);
|
||||||
|
} else {
|
||||||
|
if (imgVo.getRemoteImgId() == null) {
|
||||||
|
huaweiId = syncHuaweiBox(person, imgByte);
|
||||||
|
} else {
|
||||||
|
huaweiId = imgVo.getRemoteImgId();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (huaweiId == null) continue;
|
if (huaweiId == null) continue;
|
||||||
|
|
||||||
// 更新人像信息huaweiBoxId
|
// 更新人像信息huaweiBoxId
|
||||||
Boolean update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId);
|
update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId, nowMd5);
|
||||||
if (!update) continue;
|
if (!update) continue;
|
||||||
|
|
||||||
// 同步E8平台
|
// 同步E8平台
|
||||||
@@ -105,7 +119,6 @@ public class AuthSyncTask {
|
|||||||
remoteResidentPersonService.updateE8Id(person.getId(), e8Id);
|
remoteResidentPersonService.updateE8Id(person.getId(), e8Id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.info("无待授权人员");
|
log.info("无待授权人员");
|
||||||
}
|
}
|
||||||
@@ -115,12 +128,18 @@ public class AuthSyncTask {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补录授权记录
|
||||||
|
*
|
||||||
|
* @param person bean
|
||||||
|
*/
|
||||||
private void syncAuthRecord(RemoteResidentPersonVo person) {
|
private void syncAuthRecord(RemoteResidentPersonVo person) {
|
||||||
log.info("开始补录授权记录、人像信息");
|
log.info("开始补录授权记录、人像信息");
|
||||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||||
personAuth.setId(person.getId());
|
personAuth.setId(person.getId());
|
||||||
personAuth.setOssId(person.getOssId());
|
personAuth.setOssId(person.getOssId());
|
||||||
personAuth.setName(person.getName());
|
personAuth.setName(person.getName());
|
||||||
|
personAuth.setPhone(person.getPhone());
|
||||||
personAuth.setSex(person.getGender().intValue());
|
personAuth.setSex(person.getGender().intValue());
|
||||||
personAuth.setIdCardNumber(person.getIdCard());
|
personAuth.setIdCardNumber(person.getIdCard());
|
||||||
personAuth.setAuthGroupId(person.getAuthGroupId());
|
personAuth.setAuthGroupId(person.getAuthGroupId());
|
||||||
@@ -130,6 +149,13 @@ public class AuthSyncTask {
|
|||||||
log.info("补录授权记录、人像信息完成");
|
log.info("补录授权记录、人像信息完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步华为盒子
|
||||||
|
*
|
||||||
|
* @param vo bean
|
||||||
|
* @param imgByte 图片字节
|
||||||
|
* @return Long
|
||||||
|
*/
|
||||||
private Long syncHuaweiBox(RemoteResidentPersonVo vo, byte[] imgByte) {
|
private Long syncHuaweiBox(RemoteResidentPersonVo vo, byte[] imgByte) {
|
||||||
log.info("开始写入华为平台");
|
log.info("开始写入华为平台");
|
||||||
AddHWPersonReq req = new AddHWPersonReq();
|
AddHWPersonReq req = new AddHWPersonReq();
|
||||||
@@ -149,6 +175,13 @@ public class AuthSyncTask {
|
|||||||
return pId;
|
return pId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步E8平台
|
||||||
|
*
|
||||||
|
* @param vo bean
|
||||||
|
* @param imgByte 图片字节
|
||||||
|
* @return Long
|
||||||
|
*/
|
||||||
private Long syncE8Plat(RemoteResidentPersonVo vo, byte[] imgByte) {
|
private Long syncE8Plat(RemoteResidentPersonVo vo, byte[] imgByte) {
|
||||||
|
|
||||||
log.info("e8平台上传照片");
|
log.info("e8平台上传照片");
|
||||||
@@ -205,4 +238,35 @@ public class AuthSyncTask {
|
|||||||
}
|
}
|
||||||
return e8Id;
|
return e8Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接计算字节数组的MD5值
|
||||||
|
*
|
||||||
|
* @param data 图片的字节数组
|
||||||
|
* @return 32位小写MD5字符串
|
||||||
|
*/
|
||||||
|
public String calculateMD5(byte[] data) throws Exception {
|
||||||
|
if (data == null) {
|
||||||
|
throw new IllegalArgumentException("输入数据不能为null");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
md.update(data);
|
||||||
|
return bytesToHex(md.digest());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字节数组转十六进制字符串
|
||||||
|
*
|
||||||
|
* @param bytes 字节数组
|
||||||
|
* @return 32位十六进制字符串
|
||||||
|
*/
|
||||||
|
private String bytesToHex(byte[] bytes) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (byte b : bytes) {
|
||||||
|
// %02x 表示两位小写十六进制,不足两位补0
|
||||||
|
sb.append(String.format("%02x", b));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="checkAuth" resultType="org.dromara.sis.domain.vo.SisAuthRecordVo">
|
<select id="checkAuth" resultType="org.dromara.sis.domain.vo.SisAuthRecordVo">
|
||||||
SELECT c.target_id, c.group_id, c.beg_date, c.end_date
|
SELECT c.target_id, c.group_id, c.beg_date, c.end_date
|
||||||
FROM sis_person_lib_img a
|
FROM sis_person_lib_img a
|
||||||
LEFT JOIN resident_person b ON a.resident_person_id = b.id
|
LEFT JOIN resident_person b ON a.resident_person_id = b.id and b.state = 1
|
||||||
LEFT JOIN sis_auth_record c
|
LEFT JOIN sis_auth_record c
|
||||||
ON c.target_id = b.id
|
ON c.target_id = b.id
|
||||||
AND c.group_id = b.auth_group_id
|
AND c.group_id = b.auth_group_id
|
||||||
|
Reference in New Issue
Block a user