|
@@ -1,5 +1,6 @@
|
|
|
package com.yx.face.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -13,6 +14,7 @@ import com.yx.face.boot.uitls.RedisUtil;
|
|
|
import com.yx.face.dao.*;
|
|
|
import com.yx.face.model.dto.FacePassDTO;
|
|
|
import com.yx.face.model.entity.*;
|
|
|
+import com.yx.face.model.vo.SystemLongTermDocumentsVO;
|
|
|
import com.yx.face.netty_client.NettyClient;
|
|
|
import com.yx.face.service.FaceTBService;
|
|
|
//import com.yx.face.service.SuKangMaAipService;
|
|
@@ -21,6 +23,7 @@ import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -28,6 +31,7 @@ import org.springframework.util.StringUtils;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.persistence.Column;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @description: FaceTBServiceImpl <br>
|
|
@@ -47,17 +51,18 @@ public class FaceTBServiceImpl implements FaceTBService {
|
|
|
private UserInfoDao userInfoDao;
|
|
|
@Resource
|
|
|
private FaceLogDao faceLogDao;
|
|
|
-
|
|
|
@Resource
|
|
|
private SystemConfigDao systemConfigDao;
|
|
|
-// @Autowired
|
|
|
-// private SuKangMaAipService suKangMaAipService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private SystemLongTermDocumentsDao systemLongTermDocumentsDao;
|
|
|
@Autowired
|
|
|
- private RedisUtil redisUtil;
|
|
|
-
|
|
|
+ private AsyncTriggerRetryImpl asyncTriggerRetry;
|
|
|
+ @Resource
|
|
|
+ private FaceTaskDao faceTaskDao;
|
|
|
@Autowired
|
|
|
private TBDeviceFaceService tbDeviceFaceService;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
@Value("${web.address}")
|
|
|
private String address;
|
|
|
|
|
@@ -666,9 +671,9 @@ public class FaceTBServiceImpl implements FaceTBService {
|
|
|
if (verifytype == 0 || verifytype == 2) {
|
|
|
faceLogDao.insertSelective(faceLog);
|
|
|
}
|
|
|
- Map<String, String> maps = new HashMap<>(1);
|
|
|
- maps.put("face-log", JSONObject.toJSONString(faceLog));
|
|
|
- nettyClient.sendMessage(JSON.toJSONString(maps));
|
|
|
+// Map<String, String> maps = new HashMap<>(1);
|
|
|
+// maps.put("face-log", JSONObject.toJSONString(faceLog));
|
|
|
+// nettyClient.sendMessage(JSON.toJSONString(maps));
|
|
|
|
|
|
}
|
|
|
return result;
|
|
@@ -741,8 +746,114 @@ public class FaceTBServiceImpl implements FaceTBService {
|
|
|
|
|
|
@Override
|
|
|
public void pushUsersOnline(List<Map<String, String>> list) {
|
|
|
+ //获取员工通道
|
|
|
+ List<FaceDevice> faceDeviceList = faceDeviceDao.selectTypeFaceDev(2);
|
|
|
+ if (faceDeviceList.isEmpty()) {
|
|
|
+ log.info("设备为空===========");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //获取员工列表
|
|
|
+ List<SystemLongTermDocumentsVO> systemLongTermDocumentsDaoList = systemLongTermDocumentsDao.getList(42, null);
|
|
|
+ if (faceDeviceList.isEmpty()) {
|
|
|
+ log.info("获取员工列表===========");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<SystemLongTermDocumentsVO> mapList = new ArrayList<>();
|
|
|
+ for (SystemLongTermDocumentsVO vo : systemLongTermDocumentsDaoList) {
|
|
|
+ for (Map<String, String> map : list) {
|
|
|
+ String s = map.get(vo.getIdNumber());
|
|
|
+ if (StringUtils.hasText(s)) {
|
|
|
+ mapList.add(vo);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //取差集
|
|
|
+ List<SystemLongTermDocumentsVO> differenceList = systemLongTermDocumentsDaoList.stream()
|
|
|
+ .filter(item -> !mapList.stream()
|
|
|
+ .map(e -> e.getIdNumber())
|
|
|
+ .collect(Collectors.toList())
|
|
|
+ .contains(item.getIdNumber()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ String sn = list.get(0).get("SN");
|
|
|
+ FaceDevice faceDeviceBySn = faceDeviceDao.getFaceDeviceBySn(sn);
|
|
|
+ for (SystemLongTermDocumentsVO vo : differenceList) {
|
|
|
+ faceDeviceList(faceDeviceBySn, vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Async
|
|
|
+ public void faceDeviceList(FaceDevice faceDevice, SystemLongTermDocumentsVO vo) {
|
|
|
+ //天波人脸服务请求日志表
|
|
|
+ FaceRequestLog requestLog;
|
|
|
+ Date now = new Date();
|
|
|
+ //人脸下发表
|
|
|
+ FacePass facePass;
|
|
|
+ //唯一id
|
|
|
+ Long faceTaskId;
|
|
|
+ //人脸清除定时任务
|
|
|
+ FaceTask faceTask;
|
|
|
+ //人脸下发到设备里面
|
|
|
+ Map<String, Object> params = Maps.newHashMapWithExpectedSize(3);
|
|
|
+ List<Map<String, Object>> data = Lists.newArrayListWithExpectedSize(1);
|
|
|
+ Map<String, Object> dataItem = Maps.newHashMapWithExpectedSize(8);
|
|
|
+ // 下发参数
|
|
|
+ dataItem.put("pin", vo.getCardNo());
|
|
|
+ dataItem.put("name", vo.getName());
|
|
|
+ dataItem.put("validPeriodStart", DateUtil.format(vo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ dataItem.put("validPeriodEnd", DateUtil.format(vo.getExpireTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ dataItem.put("userType", 0);
|
|
|
+ dataItem.put("photo", vo.getPhoto());
|
|
|
+ dataItem.put("rightno", 105);
|
|
|
+ dataItem.put("cardid", vo.getIdNumber());
|
|
|
+ data.add(dataItem);
|
|
|
+ params.put("SN", faceDevice.getSn());
|
|
|
+ params.put("Data", data);
|
|
|
+ //天波人脸服务请求日志表
|
|
|
+ requestLog = new FaceRequestLog();
|
|
|
+ requestLog.setName("下发人脸");
|
|
|
+ requestLog.setContext("/downUser");
|
|
|
+ requestLog.setParams(JSONObject.toJSONString(params));
|
|
|
+ requestLog.setStatus(1);
|
|
|
+ requestLog.setUsedTime(0L);
|
|
|
+ requestLog.setUpdateTime(now);
|
|
|
+ requestLog.setCreateTime(now);
|
|
|
+ //人脸下发记录表
|
|
|
+ faceRequestLogDao.insertSelective(requestLog);
|
|
|
+ params.put("taskId", requestLog.getId());
|
|
|
+ //人脸下发表
|
|
|
+ facePass = new FacePass();
|
|
|
+ facePass.setUserId(Long.valueOf(vo.getCardNo()));
|
|
|
+ facePass.setDeviceSn(faceDevice.getSn());
|
|
|
+ facePass.setDeviceId(faceDevice.getId());
|
|
|
+ facePass.setStartTime(vo.getCreateTime());
|
|
|
+ facePass.setEndTime(vo.getExpireTime());
|
|
|
+ facePass.setAdminId(vo.getAdminId());
|
|
|
+ facePass.setStatus(2);
|
|
|
+ facePass.setType(2);
|
|
|
+ facePass.setTaskId(vo.getAdminId().toString());
|
|
|
+ facePass.setUpdateTime(now);
|
|
|
+ facePass.setCreateTime(now);
|
|
|
+ //人脸下发
|
|
|
+ facePassDao.insertSelective(facePass);
|
|
|
+ //数据同步
|
|
|
+ asyncTriggerRetry.send(params, facePass);
|
|
|
+
|
|
|
+ faceTaskId = faceTaskDao.getFaceTaskId(faceDevice.getSn(), Long.valueOf(vo.getCardNo()));
|
|
|
+ faceTask = new FaceTask();
|
|
|
+ faceTask.setId(faceTaskId);
|
|
|
+ faceTask.setTaskTime(facePass.getEndTime());
|
|
|
+ faceTask.setStatus(0);
|
|
|
+ faceTask.setUpdateTime(now);
|
|
|
+ if (faceTaskId == null) {
|
|
|
+ faceTask.setDeviceSn(faceDevice.getSn());
|
|
|
+ faceTask.setUserId(Long.valueOf(vo.getCardNo()));
|
|
|
+ faceTask.setCreateTime(now);
|
|
|
+ faceTaskDao.insertSelective(faceTask);
|
|
|
+ }
|
|
|
+ faceTaskDao.updateByPrimaryKeySelective(faceTask);
|
|
|
|
|
|
- redisUtil.set("1", list);
|
|
|
}
|
|
|
|
|
|
private String buildImage(String image, String phone) {
|