|
|
@@ -13,12 +13,18 @@ import org.dromara.backstage.api.RemoteUserAccountService;
|
|
|
import org.dromara.backstage.api.domain.vo.RemoteUserAccountVo;
|
|
|
import org.dromara.backstage.api.domain.vo.RemoteXfTermVo;
|
|
|
import org.dromara.common.core.config.DefaultConfig;
|
|
|
+import org.dromara.common.core.constant.BusinessOperationConstants;
|
|
|
+import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.constant.DefaultConstants;
|
|
|
+import org.dromara.common.core.constant.UserConstants;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.enums.CardStatusEnum;
|
|
|
import org.dromara.common.core.enums.DeviceBrandEnum;
|
|
|
+import org.dromara.common.core.enums.UserAccountStatusEnum;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.core.utils.ValidatorUtils;
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.server.hik.constant.ErrCodeConstants;
|
|
|
import org.dromara.server.hik.constant.HikApiConstants;
|
|
|
import org.dromara.server.hik.constant.HikDefaultConstants;
|
|
|
@@ -104,7 +110,6 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
setCardToEmpInfoDto(empDto, factoryId, deleteAllCard, deleteCard);
|
|
|
|
|
|
if(uploadPhoto){
|
|
|
- // TODO 2025-05-24 因为人员照片原因,暂时不将人脸照片上传到消费机
|
|
|
// 设置用户人脸图片信息
|
|
|
String photo = accountVo.getFacePicUrl();
|
|
|
setPhotoToEmpInfoDto(empDto, photo, deleteAllFace, deleteFace);
|
|
|
@@ -149,6 +154,9 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
|
|
|
// 更新卡片
|
|
|
private static void setCardToEmpInfoDto(EmpInfoDto empDto,Long factoryId,Boolean deleteAllCard, Boolean deleteCard) {
|
|
|
+ CardListDto cardListDto = new CardListDto();
|
|
|
+ // 更新卡片时deleteAllCard为true,保证最多只有一张卡,其实固定为true就好
|
|
|
+ cardListDto.setDeleteAllCard(deleteAllCard);
|
|
|
if (ObjectUtil.isNotEmpty(factoryId) && factoryId > 0L) {
|
|
|
CardDto cardDto = new CardDto().setCardNo(factoryId.toString());
|
|
|
cardDto.setDeleteCard(deleteCard);
|
|
|
@@ -156,12 +164,9 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
List<CardDto> cardList = new ArrayList<>();
|
|
|
cardList.add(cardDto);
|
|
|
|
|
|
- CardListDto cardListDto = new CardListDto();
|
|
|
cardListDto.setList(cardList);
|
|
|
- cardListDto.setDeleteAllCard(deleteAllCard);
|
|
|
-
|
|
|
- empDto.setCardInfo(cardListDto);
|
|
|
}
|
|
|
+ empDto.setCardInfo(cardListDto);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -491,13 +496,23 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
if (CollectionUtil.isEmpty(termList)) {
|
|
|
throw new ServiceException("没有要处理的设备");
|
|
|
}
|
|
|
- termList.forEach(p -> {
|
|
|
- threadPoolTaskExecutor.execute(() -> {
|
|
|
+ List<Long> onlineDeviceList = getOnlineDeviceList();
|
|
|
+ //只给在线设备下发数据
|
|
|
+ List<RemoteXfTermVo> list = termList.stream().filter(p -> onlineDeviceList.contains(p.getTermNo())).toList();
|
|
|
+ if(CollectionUtil.isEmpty(list)){
|
|
|
+ log.info("没有在线设备");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ threadPoolTaskExecutor.execute(() -> list.forEach(p -> {
|
|
|
+ try{
|
|
|
DeviceDto deviceDto = getDeviceDto(p);
|
|
|
- R<Void> result = this.createOperatorEmpInfo(deviceDto, empDto);
|
|
|
- log.info(result.getMsg());
|
|
|
- });
|
|
|
- });
|
|
|
+ this.createOperatorEmpInfo(deviceDto, empDto);
|
|
|
+// log.info(result.getMsg());
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("下发数据失败:{}, 机号:{}",e.getMessage(), p.getTermNo());
|
|
|
+ }
|
|
|
+ }));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// endregion
|
|
|
@@ -565,13 +580,21 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
if (CollectionUtil.isEmpty(termList)) {
|
|
|
throw new ServiceException("没有要处理的设备");
|
|
|
}
|
|
|
- termList.forEach(p -> {
|
|
|
- threadPoolTaskExecutor.execute(() -> {
|
|
|
+ List<Long> onlineDeviceList = getOnlineDeviceList();
|
|
|
+ if (CollectionUtil.isEmpty(onlineDeviceList)) {
|
|
|
+ log.info("没有在线设备.");
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ List<RemoteXfTermVo> list = termList.stream().filter(p -> onlineDeviceList.contains(p.getTermNo())).toList();
|
|
|
+ list.forEach(p -> threadPoolTaskExecutor.execute(() -> {
|
|
|
+ try{
|
|
|
DeviceDto dto = getDeviceDto(p);
|
|
|
R<Void> result = syncTimeToDevice(dto);
|
|
|
log.info(result.getMsg());
|
|
|
- });
|
|
|
- });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("同步时间失败:{},机号 {}", e.getMessage(), p.getTermNo());
|
|
|
+ }
|
|
|
+ }));
|
|
|
return R.ok("处理完成");
|
|
|
}
|
|
|
|
|
|
@@ -629,7 +652,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.fail(
|
|
|
MessageFormat.format("[处理人员失败]-[设备IP:{0}, 人员Id:{1}, 错误信息:无此Id对应的人员信息", device.getDeviceIp(), userId));
|
|
|
}
|
|
|
- EmpInfoDto empInfo = getEmpInfoDto(accountVo, true, false, false, false, false, true);
|
|
|
+ EmpInfoDto empInfo = getEmpInfoDto(accountVo, true, false, false, false, false, false);
|
|
|
R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
|
|
|
log.info(result.getMsg());
|
|
|
@@ -643,7 +666,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
List<RemoteUserAccountVo> accountVoList = remoteUserAccountService.getUserAccountVoList();
|
|
|
accountVoList.forEach(p -> {
|
|
|
threadPoolTaskExecutor.execute(() -> {
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(p, true, false, false, false, false, true);
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(p, true, false, false, false, false, false);
|
|
|
R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
|
|
|
log.info(result.getMsg());
|
|
|
});
|
|
|
@@ -658,12 +681,12 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.fail(
|
|
|
MessageFormat.format("[处理人员失败]-[人员Id:{0}, 错误信息:无此Id对应的人员信息", userId));
|
|
|
}
|
|
|
- EmpInfoDto empInfo = getEmpInfoDto(accountVo, true, false, false, false, false, true);
|
|
|
|
|
|
List<RemoteXfTermVo> termList = remotePtXfTermService.queryListByBrand("hk");
|
|
|
if (CollectionUtil.isEmpty(termList)) {
|
|
|
return R.warn("没有要处理人员的设备");
|
|
|
}
|
|
|
+ EmpInfoDto empInfo = getEmpInfoDto(accountVo, true, false, false, false, false, false);
|
|
|
|
|
|
termList.forEach(p -> {
|
|
|
threadPoolTaskExecutor.execute(() -> {
|
|
|
@@ -693,7 +716,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
threadPoolTaskExecutor.execute(() -> {
|
|
|
DeviceDto device = getDeviceDto(p);
|
|
|
accountVoList.parallelStream().forEach(t -> {
|
|
|
- EmpInfoDto empInfo = getEmpInfoDto(t, true, false, false, false, false, true);
|
|
|
+ EmpInfoDto empInfo = getEmpInfoDto(t, true, false, false, false, false, false);
|
|
|
R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
log.info(result.getMsg());
|
|
|
});
|
|
|
@@ -710,7 +733,6 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
|
|
|
EmpInfoDto delEmpDto = new EmpInfoDto();
|
|
|
delEmpDto.setEmployeeNo(userNo);
|
|
|
- delEmpDto.setName("胡哲");
|
|
|
delEmpDto.setCardInfo(cardList);
|
|
|
|
|
|
R<Void> check = this.createOperatorEmpInfo(device, delEmpDto);
|
|
|
@@ -721,6 +743,30 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.ok(MessageFormat.format("[处理人员所有卡片成功]-[设备IP:{0}, 人员编号:{1}]", device.getDeviceIp(), userNo));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除所有设备上指定用户编号的所有卡片信息
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R<Void> deleteAllCardByUserId(Long userId) {
|
|
|
+ RemoteUserAccountVo byId = remoteUserAccountService.getById(userId);
|
|
|
+ if(byId == null){
|
|
|
+ return R.fail("未找到该用户");
|
|
|
+ }
|
|
|
+ // 获取所有设备
|
|
|
+ List<RemoteXfTermVo> termList = remotePtXfTermService.queryListByBrand("hk");
|
|
|
+ if (CollectionUtil.isEmpty(termList)) {
|
|
|
+ return R.warn("没有要处理人员的设备");
|
|
|
+ }
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(byId, false, false, false, true, false,false);
|
|
|
+
|
|
|
+ sendEmpToAllDevice(empDto);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public R<Void> deleteCardByUserNo(DeviceDto device, String userNo, String factoryId) {
|
|
|
return null;
|
|
|
@@ -784,8 +830,10 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
// 处理人员列表
|
|
|
accountVoList.forEach(p -> {
|
|
|
threadPoolTaskExecutor.execute(() -> {
|
|
|
- try {
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(p, false, false, false, false, false,true);
|
|
|
+ try {//如果过了有效期,则直接删除 deleteUser为true
|
|
|
+ ResultBoolean obtainBoolean = getResult(p);
|
|
|
+ // deleteAllCard为true 保证只有一张卡片
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(p, obtainBoolean.deleteUser(), obtainBoolean.deleteAllFace(), obtainBoolean.deleteFace(), obtainBoolean.deleteAllCard(), obtainBoolean.deleteCard(),true);
|
|
|
R<Void> result = createOperatorEmpInfo(deviceDto, empDto);
|
|
|
log.info(result.getMsg());
|
|
|
} catch (Exception e) {
|
|
|
@@ -796,17 +844,63 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @NotNull
|
|
|
+ private static ResultBoolean getResult(RemoteUserAccountVo p) {
|
|
|
+ boolean deleteUser = false;
|
|
|
+ if(p.getLifespan()!=null){
|
|
|
+ //如果lifespan比当前时间小或者非开户的,则设置deleteUser为true
|
|
|
+ if(p.getLifespan().getTime()<System.currentTimeMillis()){
|
|
|
+ deleteUser = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!UserAccountStatusEnum.IS_OPEN.code().toString().equals(p.getAccountStatus())) {
|
|
|
+ deleteUser = true;
|
|
|
+ }
|
|
|
+ // 如果 照片不为空,deleteAllFace为true,deleteFace为false
|
|
|
+ boolean deleteAllFace = false;
|
|
|
+ boolean deleteFace = false;
|
|
|
+ if(StringUtils.isNotBlank(p.getPhoto())){
|
|
|
+ deleteAllFace = true;
|
|
|
+ }
|
|
|
+ // 如果 factoryId 不为空且cardStatus 为 1,deleteAllCard为true,deleteCard为false,否则 deleteAllCard为false,deleteCard为true
|
|
|
+ boolean deleteAllCard = false;
|
|
|
+ boolean deleteCard = false;
|
|
|
+ Long factoryId = p.getFactoryId();
|
|
|
+ String cardStatus = p.getCardStatus();
|
|
|
+ if(Objects.nonNull(factoryId)&& factoryId!=0){
|
|
|
+ deleteAllCard = true;
|
|
|
+ if(StringUtils.isNotBlank(cardStatus) && !CardStatusEnum.NORMAL.code().toString().equals(cardStatus)){
|
|
|
+ deleteAllCard = false;
|
|
|
+ //其他状态的卡直接删除
|
|
|
+ deleteCard = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(p.getDelFlag()) && !UserConstants.USER_NORMAL.equals(p.getDelFlag())) {
|
|
|
+ //已删除用户 进行删除
|
|
|
+ deleteUser = true;
|
|
|
+ }
|
|
|
+ return new ResultBoolean(deleteUser, deleteAllFace, deleteFace, deleteAllCard, deleteCard);
|
|
|
+ }
|
|
|
+
|
|
|
+ private record ResultBoolean(boolean deleteUser, boolean deleteAllFace, boolean deleteFace, boolean deleteAllCard, boolean deleteCard) {
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public R<Void> upLoadEmpToDevice(Long termNo, Long userId) {
|
|
|
DeviceDto deviceDto = getDeviceDto(termNo);
|
|
|
|
|
|
RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoBy(userId);
|
|
|
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, false, false,true);
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, true, false,true);
|
|
|
|
|
|
return this.createOperatorEmpInfo(deviceDto, empDto);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 暂不使用,不能一次上传所有用户到所有设备上
|
|
|
+ * @param uploadPhoto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public R<Void> upLoadEmpToDevice(Boolean uploadPhoto) {
|
|
|
// 获取所有设备
|
|
|
@@ -825,7 +919,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
DeviceDto device = getDeviceDto(p);
|
|
|
accountVoList.forEach(t -> {
|
|
|
threadPoolTaskExecutor.execute(()->{
|
|
|
- EmpInfoDto empInfo = getEmpInfoDto(t, false, false, false, false, false,uploadPhoto);
|
|
|
+ EmpInfoDto empInfo = getEmpInfoDto(t, false, false, false, true, false,uploadPhoto);
|
|
|
R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
log.info(result.getMsg());
|
|
|
});
|
|
|
@@ -845,6 +939,7 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
public R<Void> upLoadEmpToDevice(String macAddress,Date startDate, Boolean uploadPhoto) {
|
|
|
List<RemoteUserAccountVo> vos = remoteUserAccountService.getUpdateUserAccountVo(startDate);
|
|
|
if (CollectionUtil.isEmpty(vos)) {
|
|
|
+ log.info("heartBeat没有要处理人员数据");
|
|
|
return R.warn("没有要处理人员数据");
|
|
|
}
|
|
|
log.info("day处理人员数据条数{}", vos.size());
|
|
|
@@ -853,18 +948,18 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.warn(MessageFormat.format("设备未找到,mac:{0}", macAddress));
|
|
|
}
|
|
|
DeviceDto device = getDeviceDto(termVo);
|
|
|
- vos.forEach(t -> {
|
|
|
- threadPoolTaskExecutor.execute(()->{
|
|
|
- try{
|
|
|
- EmpInfoDto empInfo = getEmpInfoDto(t, false, false, false, false, false,uploadPhoto);
|
|
|
- R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
- log.info(result.getMsg());
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- log.error("heartBeat处理人员{}异常: {}", t.getUserId(), e.getMessage(), e);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ threadPoolTaskExecutor.execute(()-> vos.forEach(t -> {
|
|
|
+ try{
|
|
|
+ ResultBoolean obtainBoolean = getResult(t);
|
|
|
+ EmpInfoDto empInfo = getEmpInfoDto(t, obtainBoolean.deleteUser(), obtainBoolean.deleteAllFace(),
|
|
|
+ obtainBoolean.deleteFace(), obtainBoolean.deleteAllCard(), obtainBoolean.deleteCard(),uploadPhoto);
|
|
|
+ R<Void> result = createOperatorEmpInfo(device, empInfo);
|
|
|
+ log.info(result.getMsg());
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("heartBeat下发人员{}异常: {}", t.getUserId(), e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }));
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
@@ -875,7 +970,8 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
return R.warn(MessageFormat.format("没有要处理的人员信息,userId:{0}", userId));
|
|
|
}
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, false, false,true);
|
|
|
+ //保持只有一张卡 deleteAllCard为true,deleteCard为false
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, true, false,true);
|
|
|
|
|
|
sendEmpToAllDevice(empDto);
|
|
|
|
|
|
@@ -883,13 +979,14 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R<Void> upLoadEmpToAllDeviceByUserNo(Long userNo, Date lifeSpan, Boolean deleteUser) {
|
|
|
+ public R<Void> upLoadEmpToAllDeviceByUserNo(Long userNo,String name, Date lifeSpan, Boolean deleteUser) {
|
|
|
RemoteUserAccountVo accountVo = new RemoteUserAccountVo();
|
|
|
accountVo.setUserNo(userNo);
|
|
|
accountVo.setLifespan(lifeSpan);
|
|
|
+ accountVo.setRealName(name);
|
|
|
|
|
|
// 实时下发数据不下发人脸,避免引起卡机
|
|
|
- EmpInfoDto empDto = getEmpInfoDto(accountVo, deleteUser, false, false, false, false, false);
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, deleteUser, false, false, true, false, false);
|
|
|
|
|
|
sendEmpToAllDevice(empDto);
|
|
|
|
|
|
@@ -912,6 +1009,87 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 挂失卡片时下发数据给所有消费机
|
|
|
+ *
|
|
|
+ * @param userId 用户Id,用于标识需要上传的员工信息
|
|
|
+ * @param factorId 物理卡号
|
|
|
+ * @param deleteAllCard 是否删除所有卡片 false-不删除
|
|
|
+ * @param deleteCard 是否删除物理卡号对应的卡片, false-不删除
|
|
|
+ */
|
|
|
+ public void whenLockCardSend(Long userId) {
|
|
|
+ RemoteUserAccountVo accountVo = remoteUserAccountService.getById(userId);
|
|
|
+ if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
+ R.warn(MessageFormat.format("没有要处理的人员信息,userId:{0}", userId));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 实时下发数据不下发人脸,避免引起卡机
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, true, true, false);
|
|
|
+
|
|
|
+ sendEmpToAllDevice(empDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除账户时下发数据
|
|
|
+ * @param userId
|
|
|
+ */
|
|
|
+ public void whenDeleteSend(Long userId){
|
|
|
+ RemoteUserAccountVo accountVo = remoteUserAccountService.getById(userId);
|
|
|
+ if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
+ R.warn(MessageFormat.format("没有要处理的人员信息,userId:{0}", userId));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 实时下发数据不下发人脸,避免引起卡机
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, true, false, false, true, true, false);
|
|
|
+
|
|
|
+ sendEmpToAllDevice(empDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回收卡片时下发数据
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param factoryId
|
|
|
+ */
|
|
|
+ public void whenRecycleSend(Long userId,Long factoryId){
|
|
|
+ //回收卡片,将海康设备上的这个用户vo.getUserId()的,这张卡片vo.getFactoryId()信息删除,下发时如果账号已过期,则删除账号信息,没有就删除账户的卡信息
|
|
|
+ RemoteUserAccountVo accountVo = remoteUserAccountService.getById(userId);
|
|
|
+ if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
+ R.warn(MessageFormat.format("没有要处理的人员信息,userId:{0}", userId));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ accountVo.setFactoryId(factoryId);
|
|
|
+ Date lifespan = accountVo.getLifespan();
|
|
|
+ boolean deleteUser = false;
|
|
|
+ if(lifespan!=null){
|
|
|
+ if(lifespan.getTime()<System.currentTimeMillis()){
|
|
|
+ deleteUser = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!deleteUser && factoryId == null){
|
|
|
+ // 没有卡号,不用在下发了
|
|
|
+ log.warn("消费机交易记录事件,无卡号,不进行下发,userId {}",userId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 实时下发数据不下发人脸,避免引起卡机
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, deleteUser, false, false, false, true, false);
|
|
|
+
|
|
|
+ sendEmpToAllDevice(empDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ //当新增账户、取卡、补卡、解挂时下发账户信息到所有设备上
|
|
|
+ public void whenOtherOperationSend(Long userId){
|
|
|
+ RemoteUserAccountVo accountVo = remoteUserAccountService.getUserAccountVoBy(userId);
|
|
|
+ if (ObjectUtil.isEmpty(accountVo)) {
|
|
|
+ R.warn(MessageFormat.format("没有要处理的人员信息,userId:{0}", userId));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //保持只有一张卡 deleteAllCard为true,deleteCard为false
|
|
|
+ EmpInfoDto empDto = getEmpInfoDto(accountVo, false, false, false, true, false,false);
|
|
|
+
|
|
|
+ sendEmpToAllDevice(empDto);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public R<Void> queryBatchEmpFormDevice(@NotNull QueryDto dto) {
|
|
|
DeviceDto device = dto.getDevice();
|
|
|
@@ -929,4 +1107,43 @@ public class SendDeviceServiceImpl implements ISendDeviceService {
|
|
|
}
|
|
|
return R.ok(StringUtils.format("[IP:{}的设备查询成功],结果:{}", device.getDeviceIp(), doResult.getMsg()));
|
|
|
}
|
|
|
+
|
|
|
+ public void currentDownSendUserCardInfo(Long userId,String operationType,Long factoryId){
|
|
|
+ if (userId == null) {
|
|
|
+ log.error("userId不能为null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ switch (operationType){
|
|
|
+ case BusinessOperationConstants.ADD_ACCOUNT,BusinessOperationConstants.GET_CARD,
|
|
|
+ BusinessOperationConstants.AGAIN_GET_CARD,BusinessOperationConstants.UNLOCK_CARD -> // 查询用户然后下发即可
|
|
|
+ whenOtherOperationSend(userId);
|
|
|
+ case BusinessOperationConstants.DELETE_ACCOUNT -> // 删除账户
|
|
|
+ whenDeleteSend(userId);
|
|
|
+ case BusinessOperationConstants.RECYCLE_CARD -> // 回收卡片
|
|
|
+ whenRecycleSend(userId,factoryId);
|
|
|
+ case BusinessOperationConstants.LOCK_CARD -> // 挂失
|
|
|
+ whenLockCardSend(userId);
|
|
|
+ default -> log.info("未知操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取在线设备列表
|
|
|
+ * @return 列表
|
|
|
+ */
|
|
|
+ public List<Long> getOnlineDeviceList(){
|
|
|
+ List<Long> rs = new ArrayList<>();
|
|
|
+ Map<String, Object> cacheMap = RedisUtils.getCacheMap(CacheNames.LAST_TIME_HEARTBEAT_LIST);
|
|
|
+
|
|
|
+ cacheMap.forEach((k,v)->{
|
|
|
+ if (v instanceof Long t){
|
|
|
+ long l = System.currentTimeMillis() - t;
|
|
|
+ // 正常在线的心跳时间间隔是30秒,但怕有网络延迟,这里设置60秒内都算在线
|
|
|
+ if ( l <= 60 * 1000 ){
|
|
|
+ rs.add(Long.valueOf(k));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
}
|