|
@@ -15,6 +15,8 @@ import com.yx.face.model.entity.FaceDevice;
|
|
|
import com.yx.face.model.entity.FaceDeviceLogo;
|
|
|
import com.yx.face.model.entity.FaceRequestLog;
|
|
|
import com.yx.face.model.excel.FaceLogVoExcel;
|
|
|
+import com.yx.face.model.excel.UploadExcel;
|
|
|
+import com.yx.face.model.excel.UserWhitelistExcel;
|
|
|
import com.yx.face.model.query.FaceServerLogQu;
|
|
|
import com.yx.face.model.query.QueryUser;
|
|
|
import com.yx.face.model.search.FaceDeviceSearch;
|
|
@@ -32,13 +34,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -74,6 +78,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
private SystemConfigDao systemConfigDao;
|
|
|
@Resource
|
|
|
private TbDeviceWhiteListService tbDeviceWhiteListService;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean authFaceDevice(Integer deviceId) {
|
|
|
FaceDevice faceDevice = faceDeviceDao.selectByPrimaryKey(deviceId);
|
|
@@ -262,42 +267,42 @@ public class FaceServiceImpl implements FaceService {
|
|
|
|
|
|
/*1.获取所有满足条件的adminId*/
|
|
|
List<Long> adminIds = adminService.getAdminListSearch(map);
|
|
|
- map.put("adminIds",adminIds);
|
|
|
+ map.put("adminIds", adminIds);
|
|
|
/*2.获取所有满足条件的设备编号
|
|
|
- * 注:因为没有设备的相关查询条件所以不需要查询 所有满足条件的设备编号
|
|
|
- * */
|
|
|
+ * 注:因为没有设备的相关查询条件所以不需要查询 所有满足条件的设备编号
|
|
|
+ * */
|
|
|
|
|
|
/*3.通过查询回来的id值 插入map中重新查询face_log表 进行单表查询*/
|
|
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
|
|
List<FaceLogVO> list = faceLogDao.getFaceLogsNew(map);
|
|
|
/*4.查询完成之后应当对其中的数据包括进行填入
|
|
|
- * 1.对admin中的数据字段进行填入
|
|
|
- * 2.对face_device中的数据字段进行填入
|
|
|
- * */
|
|
|
+ * 1.对admin中的数据字段进行填入
|
|
|
+ * 2.对face_device中的数据字段进行填入
|
|
|
+ * */
|
|
|
|
|
|
/*4.1 获取所有adminId并把获取相关的admin*/
|
|
|
List<Long> adminList = list.stream().collect(Collectors.groupingBy(FaceLogVO::getAdminId)).keySet().stream().map(key -> key).collect(Collectors.toList());
|
|
|
List<AdminVO> adminVOList = adminService.getByAdminlist(adminList);
|
|
|
- Map<Integer, AdminVO> adminVOMap = adminVOList.stream().collect(Collectors.toMap(AdminVO::getAdminId,AdminVO->AdminVO));
|
|
|
+ Map<Integer, AdminVO> adminVOMap = adminVOList.stream().collect(Collectors.toMap(AdminVO::getAdminId, AdminVO -> AdminVO));
|
|
|
|
|
|
|
|
|
List<String> snList = list.stream().collect(Collectors.groupingBy(FaceLogVO::getDeviceSn)).keySet().stream().map(key -> key).collect(Collectors.toList());
|
|
|
List<FaceDeviceVO> faceDeviceVOList = faceDeviceDao.getBySnList(snList);
|
|
|
- Map<String, FaceDeviceVO> faceDeviceVOMap = faceDeviceVOList.stream().collect(Collectors.toMap(FaceDeviceVO::getSn,FaceDeviceVO->FaceDeviceVO));
|
|
|
+ Map<String, FaceDeviceVO> faceDeviceVOMap = faceDeviceVOList.stream().collect(Collectors.toMap(FaceDeviceVO::getSn, FaceDeviceVO -> FaceDeviceVO));
|
|
|
// PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
|
|
// List<FaceLogVO> list = faceLogDao.getFaceLogs(map);
|
|
|
for (FaceLogVO faceLog : list) {
|
|
|
AdminVO adminVO = adminVOMap.get(faceLog.getAdminId());
|
|
|
- if(Objects.nonNull(adminVO)){
|
|
|
+ if (Objects.nonNull(adminVO)) {
|
|
|
faceLog.setUsername(adminVO.getUsername());
|
|
|
}
|
|
|
FaceDeviceVO faceDeviceVO = faceDeviceVOMap.get(faceLog.getDeviceSn());
|
|
|
- if(Objects.nonNull(faceDeviceVO)){
|
|
|
+ if (Objects.nonNull(faceDeviceVO)) {
|
|
|
faceLog.setDeviceName(faceDeviceVO.getName());
|
|
|
faceLog.setOutType(faceDeviceVO.getPass());
|
|
|
}
|
|
|
|
|
|
- if(!faceLog.getJkmStatus().equals("01") && !faceLog.getJkmStatus().equals("10")){
|
|
|
+ if (!faceLog.getJkmStatus().equals("01") && !faceLog.getJkmStatus().equals("10")) {
|
|
|
if (faceLog.getPhone() != null)
|
|
|
faceLog.setPhone(SMSOrIdCardUtils.hidePhone(faceLog.getPhone()));
|
|
|
if (faceLog.getCardid() != null)
|
|
@@ -403,7 +408,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
fle.setDeviceSn(fv.getDeviceSn() == null ? null : fv.getDeviceSn());
|
|
|
fle.setDeviceName(fv.getDeviceName() == null ? null : fv.getDeviceName());
|
|
|
fle.setName(fv.getName() == null ? null : fv.getName());
|
|
|
- fle.setPhone(fv.getPhone() == null ? null : fv.getPhone());
|
|
|
+ fle.setPhoto(fv.getPhoto() == null ? null : fv.getPhoto());
|
|
|
fle.setCardid(fv.getCardid() == null ? null : fv.getCardid());
|
|
|
fle.setPhone(fv.getPhone() == null ? null : fv.getPhone());
|
|
|
if (fv.getJkmStatus() != null) {
|
|
@@ -476,9 +481,9 @@ public class FaceServiceImpl implements FaceService {
|
|
|
public List<FaceDeviceVO> getFaceDeviceList(JSONObject adminId) {
|
|
|
AdminVO info;
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- if (adminId != null && !adminId.isEmpty()){
|
|
|
+ if (adminId != null && !adminId.isEmpty()) {
|
|
|
info = adminService.getInfo(adminId.getInteger("adminId"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
info = adminService.getInfo();
|
|
|
}
|
|
|
map.put("adminVo", info);
|
|
@@ -630,6 +635,7 @@ public class FaceServiceImpl implements FaceService {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public FaceLogVO getDetails(FaceServerLogQu qu, Integer adminId) {
|
|
|
String pwd = PasswordUtils.buildPw(qu.getPassword());
|
|
@@ -646,6 +652,55 @@ public class FaceServiceImpl implements FaceService {
|
|
|
return faceLogDao.getDetails(qu.getId());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void uploadExcel(List<Object> datas) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ UploadExcel uploadExcel = (UploadExcel) datas.get(i);
|
|
|
+ if (StringUtils.isBlank(uploadExcel.getIdNumber()) || StringUtils.isBlank(uploadExcel.getPhoto())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ URL urlfile = null;
|
|
|
+ try {
|
|
|
+ urlfile = new URL(uploadExcel.getPhoto());
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ byte[] data = null;
|
|
|
+ try {
|
|
|
+ InputStream inputStream = urlfile.openStream();
|
|
|
+ ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buff = new byte[100];
|
|
|
+ int rc = 0;
|
|
|
+ while ((rc = inputStream.read(buff, 0, 100)) > 0) {
|
|
|
+ swapStream.write(buff, 0, rc);
|
|
|
+ }
|
|
|
+ data = swapStream.toByteArray();
|
|
|
+ swapStream.close();
|
|
|
+ inputStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String encode = new BASE64Encoder().encode(data);
|
|
|
+ BASE64Decoder decoder = new BASE64Decoder();
|
|
|
+ byte[] bytes1 = decoder.decodeBuffer(encode);
|
|
|
+ for (int j = 0; j < bytes1.length; ++j) {
|
|
|
+ if (bytes1[j] < 0) {// 调整异常数据
|
|
|
+ bytes1[j] += 256;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 生成jpeg图片
|
|
|
+ OutputStream out = new FileOutputStream("D:\\3\\"+uploadExcel.getIdNumber()+"-"+ (int)(Math.random()*100000)+".jpg");
|
|
|
+ out.write(bytes1);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//发送失败重试三次
|
|
|
|