|
@@ -1,17 +1,29 @@
|
|
package com.jpsoft.smart.modules.base.service.impl;
|
|
package com.jpsoft.smart.modules.base.service.impl;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
+import com.jpsoft.smart.config.OSSConfig;
|
|
import com.jpsoft.smart.modules.base.dao.AlarmInfoDAO;
|
|
import com.jpsoft.smart.modules.base.dao.AlarmInfoDAO;
|
|
import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
|
|
import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
|
|
import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
|
|
import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
|
|
|
|
+import com.jpsoft.smart.modules.common.utils.BASE64DecodedMultipartFile;
|
|
|
|
+import com.jpsoft.smart.modules.common.utils.Base64;
|
|
import com.jpsoft.smart.modules.common.utils.IApiUtil;
|
|
import com.jpsoft.smart.modules.common.utils.IApiUtil;
|
|
|
|
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
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.multipart.MultipartFile;
|
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.xml.crypto.Data;
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
+import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -22,11 +34,14 @@ import java.util.UUID;
|
|
@Component(value="personDeviceLogService")
|
|
@Component(value="personDeviceLogService")
|
|
public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
+
|
|
@Resource(name="personDeviceLogDAO")
|
|
@Resource(name="personDeviceLogDAO")
|
|
private PersonDeviceLogDAO personDeviceLogDAO;
|
|
private PersonDeviceLogDAO personDeviceLogDAO;
|
|
|
|
|
|
- @Override
|
|
|
|
- public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo) {
|
|
|
|
|
|
+ /*@Override
|
|
|
|
+ public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Data data) {
|
|
PersonDeviceLog personDeviceLog = new PersonDeviceLog();
|
|
PersonDeviceLog personDeviceLog = new PersonDeviceLog();
|
|
personDeviceLog.setId(UUID.randomUUID().toString());
|
|
personDeviceLog.setId(UUID.randomUUID().toString());
|
|
personDeviceLog.setDeviceNo(deviceNo);
|
|
personDeviceLog.setDeviceNo(deviceNo);
|
|
@@ -35,10 +50,60 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
|
|
personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
|
+ personDeviceLog.setRecordTime(data);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
|
|
|
|
+ String retFileUrl = "";
|
|
|
|
+ try{
|
|
|
|
+
|
|
|
|
+ BASE64Decoder decoder = new BASE64Decoder();
|
|
|
|
+
|
|
|
|
+ byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < imgData.length; ++i) {
|
|
|
|
+ if (imgData[i] < 0) {// 调整异常数据
|
|
|
|
+ imgData[i] += 256;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- // long timestamp = jsonObject.getLong("Timestamp");
|
|
|
|
- // personDeviceLog.setRecordTime();
|
|
|
|
|
|
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+ retFileUrl = OSSUtil.upload(ossConfig,"/devicePersonLog",faceImageJson.getStr("Name"), inputStream);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PersonDeviceLog personDeviceLog = new PersonDeviceLog();
|
|
|
|
+ personDeviceLog.setId(UUID.randomUUID().toString());
|
|
|
|
+ personDeviceLog.setDeviceNo(deviceNo);
|
|
|
|
+ if (!StringUtils.isBlank(matchPersonInfo.getStr("PersonCode"))){
|
|
|
|
+ personDeviceLog.setPersonId(matchPersonInfo.getInt("PersonCode"));
|
|
|
|
+ }else {
|
|
|
|
+ personDeviceLog.setPersonId(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ personDeviceLog.setTemperature(temperature);
|
|
|
|
+ if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))){
|
|
|
|
+ System.out.println();
|
|
|
|
+ personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
|
|
|
|
+ personDeviceLog.setMatchMsg(IApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
|
|
|
|
+ personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
|
|
|
|
+ }else {
|
|
|
|
+ personDeviceLog.setMatchStatus(0);
|
|
|
|
+ personDeviceLog.setMatchFaceId(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ personDeviceLog.setRecordTime(date);
|
|
|
|
+ personDeviceLog.setDelFlag(false);
|
|
|
|
+ personDeviceLog.setCreateTime(new Date());
|
|
|
|
+ personDeviceLog.setFaceImage(retFileUrl);
|
|
|
|
+ personDeviceLogDAO.insert(personDeviceLog);
|
|
}
|
|
}
|
|
}
|
|
}
|