Commit b7f0da7c authored by 赵啸非's avatar 赵啸非

添加服务追踪

parent d2af209a
...@@ -35,7 +35,7 @@ import static java.util.stream.Collectors.toList; ...@@ -35,7 +35,7 @@ import static java.util.stream.Collectors.toList;
* 人流图片下载 * 人流图片下载
*/ */
@Slf4j @Slf4j
@Service("RealTimeDownloadImgTask") //@Service("RealTimeDownloadImgTask")
public class RealTimeDownloadImgTaskImpl implements ITaskExcuteService { public class RealTimeDownloadImgTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
......
...@@ -96,12 +96,15 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService { ...@@ -96,12 +96,15 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
if (restTotal.getCode() == YesNoEnum.YES.getValue()) { if (restTotal.getCode() == YesNoEnum.YES.getValue()) {
//同步所有用户 //同步所有用户
List<DataItem> userList = restTotal.getData().getData(); List<DataItem> userList = restTotal.getData().getData();
log.info("注册用户新增数量:{}", userList.size()); log.info("注册用户数量:{}", userList.size());
if (!ObjectUtils.isEmpty(userList)) { if (!ObjectUtils.isEmpty(userList)) {
List<PersonEntity> newUserList = userList.stream().map(user -> { List<PersonEntity> newUserList = userList.stream().map(user -> {
if (ObjectUtils.isEmpty(user.getIdcardIDCardNo())) { if (ObjectUtils.isEmpty(user.getIdcardIDCardNo())) {
return null; return null;
} }
if (!ObjectUtils.isEmpty(user.getIdcardDataPhotoFileName())) {
log.info("注册用户名称:{} ,idCard:{},照片路径:{}", user.getIdcardName(), user.getIdcardIDCardNo(), user.getIdcardDataPhotoFileName());
}
PersonEntity personEntity = new PersonEntity(); PersonEntity personEntity = new PersonEntity();
personEntity.initAttrValue(); personEntity.initAttrValue();
personEntity.setName(user.getIdcardName()); personEntity.setName(user.getIdcardName());
...@@ -127,6 +130,7 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService { ...@@ -127,6 +130,7 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
if (oldUserMap.containsKey(item.getIdCard())) { if (oldUserMap.containsKey(item.getIdCard())) {
PersonEntity personEntity = oldUserMap.get(item.getIdCard()); PersonEntity personEntity = oldUserMap.get(item.getIdCard());
//校验 如果参数都一样 则不添加更新 //校验 如果参数都一样 则不添加更新
//if(!ObjectUtils.isEmpty(item.getSourcePhotoUri()))
Boolean bool = checkFieldSame(item, personEntity); Boolean bool = checkFieldSame(item, personEntity);
if (bool) return null; if (bool) return null;
personEntity.setName(item.getName()); personEntity.setName(item.getName());
......
package com.mortals.xhx.module.hik.event.service.impl; package com.mortals.xhx.module.hik.event.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.HikEventTypeEnum; import com.mortals.xhx.common.code.HikEventTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.EventData; import com.mortals.xhx.module.hik.event.model.req.callback.recognition.EventData;
import com.mortals.xhx.module.hik.event.model.req.callback.EventsItem; import com.mortals.xhx.module.hik.event.model.req.callback.EventsItem;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.FaceRecognitionResult; import com.mortals.xhx.module.hik.event.model.req.callback.recognition.FaceRecognitionResult;
import com.mortals.xhx.module.hik.event.model.req.callback.recognition.Snap; import com.mortals.xhx.module.hik.event.model.req.callback.recognition.Snap;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowEntity; import com.mortals.xhx.module.realtime.model.RealtimeDataflowEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowService; import com.mortals.xhx.module.realtime.service.RealtimeDataflowService;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Date; import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -26,9 +38,15 @@ public class StrangerRecoginze extends EventTypeAbstract { ...@@ -26,9 +38,15 @@ public class StrangerRecoginze extends EventTypeAbstract {
private RealtimeDataflowService dataflowService; private RealtimeDataflowService dataflowService;
private IHikFaceService faceService;
private UploadService uploadService;
public StrangerRecoginze(int type) { public StrangerRecoginze(int type) {
super(type); super(type);
this.dataflowService = SpringUtils.getBean(RealtimeDataflowService.class); this.dataflowService = SpringUtils.getBean(RealtimeDataflowService.class);
this.faceService = SpringUtils.getBean(IHikFaceService.class);
this.uploadService = SpringUtils.getBean(UploadService.class);
} }
...@@ -57,6 +75,20 @@ public class StrangerRecoginze extends EventTypeAbstract { ...@@ -57,6 +75,20 @@ public class StrangerRecoginze extends EventTypeAbstract {
if (!ObjectUtils.isEmpty(eventData.getResInfo())) { if (!ObjectUtils.isEmpty(eventData.getResInfo())) {
realtimeDataflowEntity.setLocation(eventData.getResInfo().get(0).getCn()); realtimeDataflowEntity.setLocation(eventData.getResInfo().get(0).getCn());
} }
ImgReq imgReq = new ImgReq();
imgReq.setUrl(realtimeDataflowEntity.getPicUri());
Rest<String> rest = faceService.downloadPicture(imgReq);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
byte[] bytes = Base64.decode(rest.getData());
if (!ObjectUtils.isEmpty(bytes)) {
InputStream inputStream = new ByteArrayInputStream(bytes);
MultipartFile file = ServletUtils.getMultipartFile(inputStream, "snap.jpg");
String filePath = uploadService.saveFileUpload(file, "file/fileupload/snap/" + DateUtil.today(), null);
realtimeDataflowEntity.setPicture(filePath);
}
}
realtimeDataflowEntity.setEventId(event.getEventId()); realtimeDataflowEntity.setEventId(event.getEventId());
realtimeDataflowEntity.setEventType(HikEventTypeEnum.陌生人员识别事件.getValue().longValue()); realtimeDataflowEntity.setEventType(HikEventTypeEnum.陌生人员识别事件.getValue().longValue());
realtimeDataflowEntity.setCreateUserId(1L); realtimeDataflowEntity.setCreateUserId(1L);
......
...@@ -85,15 +85,16 @@ public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<Rea ...@@ -85,15 +85,16 @@ public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<Rea
query.setSiteId(siteId); query.setSiteId(siteId);
if (datePattern == TimeUnitEnum.HOUR.getValue()) { if (datePattern == TimeUnitEnum.HOUR.getValue()) {
query.setGroupList(Arrays.asList("hour")); query.setGroupList(Arrays.asList("hour"));
query.setOrderColList(Arrays.asList(new OrderCol("hour", OrderCol.DESCENDING), new OrderCol("createTime"))); query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("day", OrderCol.DESCENDING), new OrderCol("hour", OrderCol.DESCENDING)
, new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo); statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.DAY.getValue()) { } else if (datePattern == TimeUnitEnum.DAY.getValue()) {
query.setGroupList(Arrays.asList("day")); query.setGroupList(Arrays.asList("day"));
query.setOrderColList(Arrays.asList(new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime"))); query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo); statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.MONTH.getValue()) { } else if (datePattern == TimeUnitEnum.MONTH.getValue()) {
query.setGroupList(Arrays.asList("month")); query.setGroupList(Arrays.asList("month"));
query.setOrderColList(Arrays.asList(new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime"))); query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo); statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.YEAR.getValue()) { } else if (datePattern == TimeUnitEnum.YEAR.getValue()) {
query.setGroupList(Arrays.asList("year")); query.setGroupList(Arrays.asList("year"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment