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

添加服务追踪

parent f1787db6
......@@ -74,7 +74,7 @@
},
],
columns: [
{type: "selection", width: 60},
/* {type: "selection", width: 60},*/
{type: "index",label: "序号",width: 50},
{label: "姓名", prop: "name"},
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum DaySelectEnum {
今天(0, "今天"),
近七天(1, "近七天"),
近三十天(2, "近三十天"),
近三月(3, "近三月"),
今年(4, "今年");
private Integer value;
private String desc;
DaySelectEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static DaySelectEnum getByValue(Integer value) {
for (DaySelectEnum alarmLevelEnum : DaySelectEnum.values()) {
if (alarmLevelEnum.getValue() == value) {
return alarmLevelEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (DaySelectEnum item : DaySelectEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum TimeUnitEnum {
/** 小时 */
HOUR(0, "小时"),
/** 日 */
DAY(1, "每日"),
/** 月 */
MONTH(2, "月"),
/** 年 */
YEAR(3, "年");
private int value;
private String desc;
TimeUnitEnum(int value, String desc) {
this.value = value;
this.desc = desc;
}
public int getValue() {
return this.value;
}
public String getDesc() {
return desc;
}
public static TimeUnitEnum getByValue(int value) {
for (TimeUnitEnum yesNo : TimeUnitEnum.values()) {
if (yesNo.getValue() == value) {
return yesNo;
}
}
return null;
}
public static Map<String,String> getEnumMap(int... eItem) {
Map<String,String> resultMap= new LinkedHashMap<String,String>();
for (TimeUnitEnum item : TimeUnitEnum.values()) {
try{
boolean hasE = false;
for (int e : eItem){
if(item.getValue()==e){
hasE = true;
break;
}
}
if(!hasE){
resultMap.put(item.getValue()+"", item.getDesc());
}
}catch(Exception ex){
}
}
return resultMap;
}
}
......@@ -97,6 +97,18 @@ public final class Constant {
public final static String STRANGER_PLAN = "stranger_plan";
public final static String STRANGER_PLAN_DESC = "陌生人监控计划";
/**
* 预约监控计划
*/
public final static String APPOINTMENT_PLAN = "appointment_plan";
public final static String APPOINTMENT_PLAN_DESC = "预约人监控计划";
/**
* 预约人员分组
*/
public final static String APPOINTMENT_GROUP = "appointment_group";
/**
* 预约监控计划前缀
*/
......
......@@ -38,7 +38,11 @@ import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/**
* 初始化部分计划数据等
* @author:
* @date: 2023/5/9 10:01
*/
@Component
@Slf4j
public class SubEventStartedService implements IApplicationStartedService {
......@@ -77,10 +81,8 @@ public class SubEventStartedService implements IApplicationStartedService {
log.info("get events resp==>{}", JSON.toJSONString(events));
//查询本地指定人脸分组 如果没有则添加 并更新
String groupStr = GlobalSysInfo.getParamValue(PARAM_FACE_GROUP, PARAM_FACE_GROUP_REGISTER);
String groupStr = GlobalSysInfo.getParamValue(PARAM_FACE_GROUP, "face_group_register,appointment_group");
List<String> groupList = StrUtil.split(groupStr, ",".charAt(0));
for (String group : groupList) {
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name(group));
if (ObjectUtils.isEmpty(faceGroupEntity)) {
......@@ -104,73 +106,9 @@ public class SubEventStartedService implements IApplicationStartedService {
}
//创建陌生人计划
// facePlanService.createStrangerPlanByDay();
// ImgReq imgReq = new ImgReq();
///imgReq.setUrl("http://10.12.82.102:80/picture/Streaming/tracks/703/?name=ch00007_00000004885023469721600008659&size=8659");
// Rest<String> stringRest = hikFaceService.downloadPicture(imgReq);
//log.info(stringRest.getData());
//删除重点人员计划
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
if (planRecognBlackRest.getCode() == YesNoEnum.YES.getValue()) {
List<PlanRecognInfo> delPlanList = planRecognBlackRest.getData();
if (!ObjectUtils.isEmpty(delPlanList)) {
//删除计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setRecognitionResourceIndexCodes(delPlanList.stream().map(i -> i.getIndexCode()).collect(Collectors.toList()));
Rest<Boolean> delRest = hikPlanService.planRecognBlackDel(planRecognBlackReq);
if (delRest.getCode() == YesNoEnum.YES.getValue() && delRest.getData()) {
log.info("预约计划删除成功!");
}
}
}*/
//删除创建陌生人员识别计划,todo
// String planBlackName = GlobalSysInfo.getParamValue(ParamKey.PARAM_FACE_PLAN_BLACK, "取号监控");
/*
int threshold = GlobalSysInfo.getParamIntValue(ParamKey.PARAM_FACE_THRESHOLD, 80);
FacePlanEntity facePlanEntity = facePlanService.selectOne(new FacePlanQuery().name(planBlackName));
if (ObjectUtils.isEmpty(facePlanEntity)) {
//初始化新增取号监控识别计划
PlanRecognReq planRecognBlackReq = new PlanRecognReq();
planRecognBlackReq.setName(planBlackName);
planRecognBlackReq.setDescription(planBlackName);
planRecognBlackReq.setThreshold(threshold);
//设置人脸分组
FaceGroupEntity faceGroupEntity = faceGroupService.selectOne(new FaceGroupQuery().name("注册群众"));
List<String> faceGroupIndexCodes = new ArrayList<>();
faceGroupIndexCodes.add(faceGroupEntity.getIndexCode());
planRecognBlackReq.setFaceGroupIndexCodes(faceGroupIndexCodes);
//设置监控点
List<String> cameraIndexCodes = deviceService.find(new DeviceQuery()).stream().map(DeviceEntity::getDeviceCode).collect(Collectors.toList());
planRecognBlackReq.setCameraIndexCodes(cameraIndexCodes);
//设置识别方式
planRecognBlackReq.setRecognitionResourceType(RecognitionResourceEnum.COMPARISON.getValue());
//设置时间段 默认全天候
Rest<String> planRecognBlackAddRest = hikPlanService.planRecognBlackAdd(planRecognBlackReq);
if (planRecognBlackAddRest.getCode() == YesNoEnum.YES.getValue()) {
FacePlanEntity planEntity = new FacePlanEntity();
planEntity.initAttrValue();
planEntity.setIndexCode(planRecognBlackAddRest.getData());
planEntity.setName(planBlackName);
planEntity.setDescription(planBlackName);
planEntity.setCreateTime(new Date());
planEntity.setCreateUserId(1L);
planEntity.setCreateUserName("admin");
facePlanService.save(planEntity);
}
}
*/
//创建陌生人员识别计划
facePlanService.createStrangerPlan();
//创建预约人监控计划
facePlanService.createAppointmentPlan();
}
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.GenderEnum;
import com.mortals.xhx.common.code.RecognitionResourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.appointment.model.*;
import com.mortals.xhx.module.appointment.service.AppointmentConfigService;
import com.mortals.xhx.module.appointment.service.AppointmentConfigTimesService;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.face.model.*;
import com.mortals.xhx.module.face.service.FaceGroupPersonService;
import com.mortals.xhx.module.face.service.FaceGroupService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.hik.face.model.req.face.FaceInfo;
import com.mortals.xhx.module.hik.face.model.req.face.FacePic;
import com.mortals.xhx.module.hik.face.model.req.face.FaceReq;
import com.mortals.xhx.module.hik.face.model.req.group.FaceGroupReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognListReq;
import com.mortals.xhx.module.hik.face.model.req.plan.PlanRecognReq;
import com.mortals.xhx.module.hik.face.model.req.plan.TimeBlockListItem;
import com.mortals.xhx.module.hik.face.model.req.plan.TimeRangeItem;
import com.mortals.xhx.module.hik.face.model.rsp.face.FaceDataInfo;
import com.mortals.xhx.module.hik.face.model.rsp.plan.PlanRecognInfo;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.hik.face.service.IHikPlanService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.service.PersonService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
/**
* 每日创建预约人员监控计划
......@@ -62,7 +28,7 @@ import static com.mortals.xhx.common.key.ParamKey.PARAM_FACE_GROUP_REGISTER;
* @date: 2023/4/17 17:52
*/
@Slf4j
@Service("CreateBlackPlanToHikByDayTask")
//@Service("CreateBlackPlanToHikByDayTask")
public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
@Autowired
......@@ -98,7 +64,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
log.info("{}=>创建陌生人计划任务完成", DateUtils.getCurrStrDate());
log.info("{}=>创建预约计划任务", DateUtils.getCurrStrDate());
facePlanService.createAppointmentPlanByDay();
facePlanService.createAppointmentPersonByDay();
//createAppointmentPlanByDay();
log.info("{}=>创建预约计划任务完成", DateUtils.getCurrStrDate());
}
......@@ -198,7 +164,7 @@ public class CreateBlackPlanToHikByDayTaskImpl implements ITaskExcuteService {
private void createAppointmentPlanByDay() {
facePlanService.createAppointmentPlanByDay();
facePlanService.createAppointmentPersonByDay();
/* PlanRecognListReq planRecognBlackListReq = new PlanRecognListReq();
Rest<List<PlanRecognInfo>> planRecognBlackRest = hikPlanService.findPlanRecognBlackList(planRecognBlackListReq);
......
......@@ -49,11 +49,9 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
statPeople();
donwnloadSnap();
}
private void statPeople() {
......@@ -67,7 +65,7 @@ public class RealTimePeopleStatTaskImpl implements ITaskExcuteService {
realtimeDataflowQuery.setCreateTimeStart(startTimeStr);
realtimeDataflowQuery.setCreateTimeEnd(endTimeStr);
List<RealtimeDataflowEntity> realtimeDataflowEntities = realtimeDataflowService.find(realtimeDataflowQuery, null);
if (ObjectUtils.isEmpty(realtimeDataflowEntities)) {
if (!ObjectUtils.isEmpty(realtimeDataflowEntities)) {
Long strangerCount = realtimeDataflowEntities.parallelStream().filter(f -> ObjectUtils.isEmpty(f.getIdNumber())).count();
int total = realtimeDataflowEntities.size();
Long recognizeCount = total - strangerCount;
......
......@@ -114,6 +114,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
}
cacheService.select(database);//
if (!ObjectUtils.isEmpty(waitPersonInfos)) {
log.info("waitPersonInfos:{}", JSON.toJSONString(waitPersonInfos));
List<CareRecordsEntity> recordsEntityList = waitPersonInfos.stream().map(item -> {
CareRecordsEntity careRecordsEntity = new CareRecordsEntity();
careRecordsEntity.initAttrValue();
......@@ -141,6 +142,7 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
}
}
if (!ObjectUtils.isEmpty(finPersonInfos)) {
log.info("finPersonInfos:{}", JSON.toJSONString(finPersonInfos));
List<Long> waitIdList = finPersonInfos.stream().map(item -> item.getWaitId()).collect(Collectors.toList());
Map<Long, FinPersonInfo> waitMap = finPersonInfos.stream().collect(Collectors.toMap(x -> x.getWaitId(), y -> y, (o, n) -> n));
......
......@@ -18,6 +18,7 @@ import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.appointment.model.AppointmentPersonEntity;
import com.mortals.xhx.module.appointment.model.AppointmentPersonQuery;
import com.mortals.xhx.module.appointment.service.AppointmentPersonService;
import com.mortals.xhx.module.face.service.FacePlanService;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.model.PersonQuery;
import com.mortals.xhx.module.person.service.PersonService;
......@@ -54,6 +55,8 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService {
private PersonService personService;
@Autowired
private AppointmentPersonService appointmentPersonService;
@Autowired
private FacePlanService facePlanService;
@Value("${php.host:''}")
......@@ -66,8 +69,11 @@ public class SyncAppointmentPersonTaskImpl implements ITaskExcuteService {
syncAppointmentPerson();
log.info("同步今天预约用户任务完成");
}
log.info("创建每日预约人群任务");
facePlanService.createAppointmentPersonByDay();
log.info("创建每日预约人群完成");
}
private void syncAppointmentPerson() {
//根据数量查询
......
......@@ -63,7 +63,6 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
private void syncRegisterUsersPhotos() {
String url = host.endsWith("/") ? host : host + "/";
List<PersonEntity> collect = personService.find(new PersonQuery()).stream()
.filter(item -> ObjectUtils.isEmpty(item.getPhoto()))
.filter(item -> !ObjectUtils.isEmpty(item.getSourcePhotoUri())).collect(Collectors.toList());
......@@ -84,11 +83,9 @@ public class SyncRegisterUserPicTaskImpl implements ITaskExcuteService {
List<PersonEntity> hikPerson = personService.find(new PersonQuery().source(SourceEnum.海康系统.getValue())).stream().filter(f -> ObjectUtils.isEmpty(f.getPhoto())).collect(Collectors.toList());
for (PersonEntity person : hikPerson) {
ImgReq imgReq = new ImgReq();
imgReq.setSvrIndexCode(person.getServerIndexCode());
imgReq.setPicUri(person.getPicUrl());
try {
InputStream inputStream = hikFaceService.callPostImgs(imgReq);
if (!ObjectUtils.isEmpty(inputStream)) {
......
......@@ -88,7 +88,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
private void syncRegisterUsers() {
//查询本地最大id
int count=0;
List<PersonEntity> max = personService.getDao().getMax();
if(!ObjectUtils.isEmpty(max)){
......@@ -200,13 +199,6 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
}
// Map<String, Integer> params = new HashMap<>();
// params.put("page",1);
// params.put("size",1);
//
// HttpUtil.doGet(url,params)
}
private void syncRegisterUsersPhotos() {
......
......@@ -107,17 +107,11 @@ public class SyncUserToHikTaskImpl implements ITaskExcuteService {
faceGroupPersonEntity.setCreateTime(new Date());
faceGroupPersonEntity.setCreateUserId(1L);
faceGroupPersonService.save(faceGroupPersonEntity);
//faceGroupPersonService;
}
//log.info("picBase64Data=>{}", picBase64Data);
}
}
// FileUtil.read
}
}
}
......
......@@ -17,13 +17,22 @@ import java.util.List;
*/
public interface FacePlanService extends ICRUDService<FacePlanEntity, Long> {
/**
* 创建陌生人监控计划
*/
Rest<List<PlanRecognInfo>> createStrangerPlan();
/**
* 创建陌生人监控计划
*/
Rest<List<PlanRecognInfo>> createStrangerPlanByDay();
/**
* 每日创建预约人员监控计划
*/
void createAppointmentPersonByDay();
/**
* 创建预约人员监控计划
*/
void createAppointmentPlanByDay();
Rest<String> createAppointmentPlan();
}
\ No newline at end of file
......@@ -111,16 +111,17 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
@Override
public Rest<Boolean> faceSingleDel(FaceReq faceReq) {
ArtemisConfig config = getArtemisConfig();
String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/delete";
String getCamsApi = ARTEMIS_PATH + "/api/frs/v1/face/deletion";
path.put(protocol, getCamsApi);
try {
log.info("face single delete req=>{}", JSON.toJSONString(faceReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() {
HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>{}", respJson);
log.info("face single delete error resp=>{}", respJson);
return Rest.fail(rest.getMsg());
}
} catch (Exception e) {
......@@ -136,9 +137,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<List<FaceGroupDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<FaceGroupDataInfo>>>() {
HikApiRest<List<FaceGroupDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<FaceGroupDataInfo>>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("face group list error resp=>{}", respJson);
......@@ -160,9 +161,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
log.info("face single req=>{}", JSON.toJSONString(faceGroupReq));
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
log.info("face single resp=>{}", respJson);
Rest<FaceGroupDataInfo> rest = JSON.parseObject(respJson, new TypeReference<Rest<FaceGroupDataInfo>>() {
HikApiRest<FaceGroupDataInfo> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<FaceGroupDataInfo>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
return Rest.fail(rest.getMsg());
......@@ -180,9 +181,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(faceGroupReq), null, null, "application/json");
Rest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<Rest<Boolean>>() {
HikApiRest<Boolean> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<Boolean>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("face single error resp=>{}", respJson);
......@@ -207,9 +208,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Rest<List<ResRecognDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<ResRecognDataInfo>>>() {
HikApiRest<List<ResRecognDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<ResRecognDataInfo>>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("face res list error resp=>{}", respJson);
......@@ -250,9 +251,9 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
path.put(protocol, getCamsApi);
try {
String respJson = ArtemisHttpUtil.doPostStringArtemis(config, path, JSON.toJSONString(recognReq), null, null, "application/json");
Rest<List<ResourceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<Rest<List<ResourceDataInfo>>>() {
HikApiRest<List<ResourceDataInfo>> rest = JSON.parseObject(respJson, new TypeReference<HikApiRest<List<ResourceDataInfo>>>() {
});
if (rest.getCode() == 0) {
if ("0".equals(rest.getCode())) {
return Rest.ok(rest.getData());
} else {
log.info("resource recognition list error resp=>{}", respJson);
......
package com.mortals.xhx.module.realtime.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
import java.util.List;
/**
* 人员流量统计Dao
......@@ -13,5 +16,7 @@ import java.util.List;
public interface RealtimeDataflowStatDao extends ICRUDDao<RealtimeDataflowStatEntity,Long>{
String SQLID_GET_STATLIST = "getStatList";
List<RealtimeDataflowStatEntity> getStatList(RealtimeDataflowStatQuery query, PageInfo pageInfo);
}
package com.mortals.xhx.module.realtime.dao.ibatis;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
......@@ -17,5 +21,14 @@ import java.util.List;
public class RealtimeDataflowStatDaoImpl extends BaseCRUDDaoMybatis<RealtimeDataflowStatEntity,Long> implements RealtimeDataflowStatDao {
@Override
public List<RealtimeDataflowStatEntity> getStatList(RealtimeDataflowStatQuery query, PageInfo pageInfo) {
ParamDto queryParam = super.getQueryParam(query);
if (pageInfo.getPrePageResult() == -1) {
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam);
} else {
RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
return getSqlSession().selectList(SQLID_GET_STATLIST, queryParam, rowBounds);
}
}
}
......@@ -31,4 +31,6 @@ public class RealtimeDataflowStatVo extends BaseEntityLong {
private Integer recoginzeSum;
private Integer selected;
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import java.util.List;
/**
* RealtimeDataflowStatService
*
* 人员流量统计 service接口
*
* @author zxfei
* @date 2023-04-19
*/
public interface RealtimeDataflowStatService extends ICRUDService<RealtimeDataflowStatEntity,Long>{
* RealtimeDataflowStatService
* <p>
* 人员流量统计 service接口
*
* @author zxfei
* @date 2023-04-19
*/
public interface RealtimeDataflowStatService extends ICRUDService<RealtimeDataflowStatEntity, Long> {
List<RealtimeDataflowStatEntity> getBillInfos(Long siteId, Integer datePattern, PageInfo pageInfo, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.service.impl;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.common.code.DaySelectEnum;
import com.mortals.xhx.common.code.TimeUnitEnum;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatQuery;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -6,14 +13,95 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowStatService;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* RealtimeDataflowStatService
* 人员流量统计 service实现
*
* @author zxfei
* @date 2023-04-19
*/
* RealtimeDataflowStatService
* 人员流量统计 service实现
*
* @author zxfei
* @date 2023-04-19
*/
@Service("realtimeDataflowStatService")
public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<RealtimeDataflowStatDao, RealtimeDataflowStatEntity, Long> implements RealtimeDataflowStatService {
@Override
public Result<RealtimeDataflowStatEntity> find(RealtimeDataflowStatEntity query, PageInfo pageInfo, Context context) throws AppException {
Result<RealtimeDataflowStatEntity> statEntityResult = new Result<>();
if (!ObjectUtils.isEmpty(query.getSelected())) {
PageInfo page = new PageInfo();
List<RealtimeDataflowStatEntity> billInfos;
//转换日期
switch (DaySelectEnum.getByValue(query.getSelected())) {
case 今天:
page.setPrePageResult(1);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近七天:
page.setPrePageResult(7);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近三十天:
page.setPrePageResult(30);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.DAY.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 近三月:
page.setPrePageResult(3);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.MONTH.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
case 今年:
page.setPrePageResult(1);
billInfos = this.getBillInfos(query.getSiteId(), TimeUnitEnum.YEAR.getValue(), page, context);
statEntityResult.setList(billInfos);
statEntityResult.setPageInfo(page);
break;
default:
break;
}
return statEntityResult;
} else {
return super.find(query, pageInfo, context);
}
}
@Override
public List<RealtimeDataflowStatEntity> getBillInfos(Long siteId, Integer datePattern, PageInfo pageInfo, Context context) {
List<RealtimeDataflowStatEntity> statList;
RealtimeDataflowStatQuery query = new RealtimeDataflowStatQuery();
query.setSiteId(siteId);
if (datePattern == TimeUnitEnum.HOUR.getValue()) {
query.setGroupList(Arrays.asList("hour"));
query.setOrderColList(Arrays.asList(new OrderCol("hour", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.DAY.getValue()) {
query.setGroupList(Arrays.asList("day"));
query.setOrderColList(Arrays.asList(new OrderCol("day", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.MONTH.getValue()) {
query.setGroupList(Arrays.asList("month"));
query.setOrderColList(Arrays.asList(new OrderCol("month", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else if (datePattern == TimeUnitEnum.YEAR.getValue()) {
query.setGroupList(Arrays.asList("year"));
query.setOrderColList(Arrays.asList(new OrderCol("year", OrderCol.DESCENDING), new OrderCol("createTime")));
statList = this.getDao().getStatList(query, pageInfo);
} else {
throw new AppException("不支持当前日期格式查询统计!");
}
return statList;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.realtime.dao.ibatis.RealtimeDataflowStatDaoImpl">
<!-- 获取统计列表 -->
<select id="getStatList" parameterType="paramDto" resultMap="RealtimeDataflowStatEntity-Map">
select
<!-- 获取分组字段 -->
<if test="groupList != null and !groupList.isEmpty()">
<foreach collection="groupList" open="" close="" index="index" item="item">
${item},
</foreach>
</if>
id,
siteId,
siteName,
createTime,
year,
month,
day,
hour,
sum(IFNULL(a.personSum, 0)) personSum,
sum(IFNULL(a.strangerSum, 0)) strangerSum,
sum(IFNULL(a.recoginzeSum,0)) recoginzeSum
from mortals_xhx_realtime_dataflow_stat as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
<include refid="_group_by_"/>
<include refid="_orderCols_"/>
</select>
</mapper>
\ No newline at end of file
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