Commit 9804dbad authored by 赵啸非's avatar 赵啸非

添加人流统计模块

parent 0b6f034d
......@@ -4080,6 +4080,69 @@ data| object |数据对象
}
```
## 人员流量统计
### 查询人员流量统计列表
**请求URL:** realtime/dataflow/stat/list
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 查询人员流量统计
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
page|Integer|否|当前页
size|Integer|否|每页条数,值为-1,查询所有记录
**请求样例:**
```
{
"page":1,
"size":10
}
```
**响应参数:**
参数名称|参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 per_page|Integer|每页条数
 total|Integer|总条数
 last_page|Integer|总页数
 current_page|Integer|当前页
 data|array|结果集列表|数组
  id|Long|主键ID,主键,自增长
  siteId|Long|站点Id
  siteName|String|站点名称
  personSum|Integer|人流总数
  strangerSum|Integer|陌生人数量
  recoginzeSum|Integer|识别注册群众数量
  year|Integer|年
  month|Integer|月
  day|Integer|日
  hour|Integer|小时
  createTime|Date|创建时间
  createUserId|Long|创建人id
  updateTime|Date|更新时间
  updateUserId|Long|更新人id
dict|object|字典对象
**响应消息样例:**
```
{
"code":1,
"data":{
}
}
```
```
......
......@@ -26,10 +26,7 @@ import com.mortals.xhx.common.key.RedisKey;
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.care.model.CareConfigEntity;
import com.mortals.xhx.module.care.model.CareConfigQuery;
import com.mortals.xhx.module.care.model.CareRecordsEntity;
import com.mortals.xhx.module.care.model.CareRecordsQuery;
import com.mortals.xhx.module.care.model.*;
import com.mortals.xhx.module.care.service.CareConfigService;
import com.mortals.xhx.module.care.service.CareRecordsService;
import com.mortals.xhx.module.hik.person.model.rsp.person.PersonInfo;
......@@ -41,6 +38,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
......@@ -52,10 +50,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -169,7 +164,10 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
if (checkCareServiceUsed(careConfigEntity)) return;
//校验当天日期是否启用
if (checkCareServiceDay(careConfigEntity)) return;
//校验当天服务最大人数
if (checkCareServiceMaxNum(careConfigEntity)) return;
//校验当天服务时间段
if (checkServiceTimeDurion(careConfigEntity)) return;
Long serviceThreshold = careConfigEntity.getServiceThreshold();
String msgRecipients = careConfigEntity.getMsgRecipients();
......@@ -222,6 +220,36 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
}
}
private boolean checkCareServiceMaxNum(CareConfigEntity careConfigEntity) {
Integer maxServicePersonNum = careConfigEntity.getMaxServicePersonNum();
CareRecordsQuery careRecordsQuery = new CareRecordsQuery();
careRecordsQuery.setCreateTimeStart(DateUtils.getCurrStrDate());
careRecordsQuery.setCreateTimeEnd(DateUtils.getCurrStrDate());
int dayServiceNum = careRecordsService.count(careRecordsQuery, null);
if (dayServiceNum > maxServicePersonNum) {
log.info("服务人数超过最大数量!");
return true;
}
return false;
}
private boolean checkServiceTimeDurion(CareConfigEntity careConfigEntity) {
List<CareConfigTimesEntity> careConfigTimesList = careConfigEntity.getCareConfigTimesList();
if (ObjectUtils.isEmpty(careConfigTimesList)) {
Date date = new Date();
boolean isIn = careConfigTimesList.stream()
.anyMatch((tp) -> (tp.getServiceTimeStart().equals(date) || tp.getServiceTimeStart().before(date))
&& (tp.getServiceTimeEnd().equals(date) || tp.getServiceTimeEnd().after(date)));
if (!isIn) {
log.info("当前时间不在服务时间内!");
return true;
}
}
return false;
}
@Override
public void stopTask(ITask task) throws AppException {
......@@ -231,7 +259,27 @@ public class SyncAppointWaitAndFinTaskImpl implements ITaskExcuteService {
public static void main(String[] args) {
System.out.println(DateUtil.parse("19951071", "yyyyMMdd"));
Date date = new Date(); // 待判断的时间对象
List<CareConfigTimesEntity> timePeriodList = new ArrayList<>(); // 时间段列表
CareConfigTimesEntity careConfigTimesEntity = new CareConfigTimesEntity();
careConfigTimesEntity.setServiceTimeStart(DateUtil.parse("2023-04-19 09:00:00"));
careConfigTimesEntity.setServiceTimeEnd(DateUtil.parse("2023-04-19 10:00:00"));
timePeriodList.add(careConfigTimesEntity);
careConfigTimesEntity = new CareConfigTimesEntity();
careConfigTimesEntity.setServiceTimeStart(DateUtil.parse("2023-04-19 10:10:00"));
careConfigTimesEntity.setServiceTimeEnd(DateUtil.parse("2023-04-19 11:00:00"));
timePeriodList.add(careConfigTimesEntity);
boolean isIn = timePeriodList.stream()
.anyMatch((tp) -> (tp.getServiceTimeStart().equals(date) || tp.getServiceTimeStart().before(date))
&& (tp.getServiceTimeEnd().equals(date) || tp.getServiceTimeEnd().after(date)));
System.out.println(isIn);
}
......
package com.mortals.xhx.module.realtime.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import java.util.List;
/**
* 人员流量统计Dao
* 人员流量统计 DAO接口
*
* @author zxfei
* @date 2023-04-19
*/
public interface RealtimeDataflowStatDao extends ICRUDDao<RealtimeDataflowStatEntity,Long>{
}
package com.mortals.xhx.module.realtime.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.realtime.dao.RealtimeDataflowStatDao;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 人员流量统计DaoImpl DAO接口
*
* @author zxfei
* @date 2023-04-19
*/
@Repository("realtimeDataflowStatDao")
public class RealtimeDataflowStatDaoImpl extends BaseCRUDDaoMybatis<RealtimeDataflowStatEntity,Long> implements RealtimeDataflowStatDao {
}
package com.mortals.xhx.module.realtime.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.realtime.model.vo.RealtimeDataflowStatVo;
import lombok.Data;
/**
* 人员流量统计实体对象
*
* @author zxfei
* @date 2023-04-19
*/
@Data
public class RealtimeDataflowStatEntity extends RealtimeDataflowStatVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id
*/
private Long siteId;
/**
* 站点名称
*/
private String siteName;
/**
* 人流总数
*/
private Integer personSum;
/**
* 陌生人数量
*/
private Integer strangerSum;
/**
* 识别注册群众数量
*/
private Integer recoginzeSum;
/**
* 年
*/
private Integer year;
/**
* 月
*/
private Integer month;
/**
* 日
*/
private Integer day;
/**
* 小时
*/
private Integer hour;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof RealtimeDataflowStatEntity) {
RealtimeDataflowStatEntity tmp = (RealtimeDataflowStatEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.siteId = null;
this.siteName = "";
this.personSum = null;
this.strangerSum = null;
this.recoginzeSum = null;
this.year = null;
this.month = null;
this.day = null;
this.hour = null;
}
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 人员流量统计视图对象
*
* @author zxfei
* @date 2023-04-19
*/
@Data
public class RealtimeDataflowStatVo extends BaseEntityLong {
/**
* 人流总数
*/
@Excel(name = "人流总数")
private Integer personSum;
/**
* 陌生人数量
*/
@Excel(name = "陌生人数量")
private Integer strangerSum;
/**
* 识别注册群众数量
*/
@Excel(name = "识别注册群众数量")
private Integer recoginzeSum;
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
/**
* RealtimeDataflowStatService
*
* 人员流量统计 service接口
*
* @author zxfei
* @date 2023-04-19
*/
public interface RealtimeDataflowStatService extends ICRUDService<RealtimeDataflowStatEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
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;
/**
* RealtimeDataflowStatService
* 人员流量统计 service实现
*
* @author zxfei
* @date 2023-04-19
*/
@Service("realtimeDataflowStatService")
public class RealtimeDataflowStatServiceImpl extends AbstractCRUDServiceImpl<RealtimeDataflowStatDao, RealtimeDataflowStatEntity, Long> implements RealtimeDataflowStatService {
}
\ No newline at end of file
package com.mortals.xhx.module.realtime.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.realtime.model.RealtimeDataflowStatEntity;
import com.mortals.xhx.module.realtime.service.RealtimeDataflowStatService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 人员流量统计
*
* @author zxfei
* @date 2023-04-19
*/
@RestController
@RequestMapping("realtime/dataflow/stat")
public class RealtimeDataflowStatController extends BaseCRUDJsonBodyMappingController<RealtimeDataflowStatService,RealtimeDataflowStatEntity,Long> {
@Autowired
private ParamService paramService;
public RealtimeDataflowStatController(){
super.setModuleDesc( "人员流量统计");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###人员流量统计列表
POST {{baseUrl}}/realtime/dataflow/stat/list
Authorization: {{authToken}}
Content-Type: application/json
{
"page":1,
"size":10
}
###人员流量统计更新与保存
POST {{baseUrl}}/realtime/dataflow/stat/save
Authorization: {{authToken}}
Content-Type: application/json
{
"siteId":818,
"siteName":"51hmqj",
"personSum":924,
"strangerSum":704,
"recoginzeSum":196,
"year":390,
"month":201,
"day":998,
"hour":416,
}
> {%
client.global.set("RealtimeDataflowStat_id", JSON.parse(response.body).data.id);
%}
###人员流量统计查看
GET {{baseUrl}}/realtime/dataflow/stat/info?id={{RealtimeDataflowStat_id}}
Authorization: {{authToken}}
Accept: application/json
###人员流量统计编辑
GET {{baseUrl}}/realtime/dataflow/stat/edit?id={{RealtimeDataflowStat_id}}
Authorization: {{authToken}}
Accept: application/json
###人员流量统计删除
GET {{baseUrl}}/realtime/dataflow/stat/delete?id={{RealtimeDataflowStat_id}}
Authorization: {{authToken}}
Accept: application/json
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