提交 16b1e2cf 作者: Administrator

feat:区域人员统计,数据可视化(设备电量更新)

上级 5d66b522
...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; ...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
...@@ -25,6 +26,15 @@ public class PersonnelStatisticsQueryParam implements Serializable { ...@@ -25,6 +26,15 @@ public class PersonnelStatisticsQueryParam implements Serializable {
@Serial @Serial
private static final long serialVersionUID = -638192778218413746L; private static final long serialVersionUID = -638192778218413746L;
@ApiModelProperty(value = "区域", example = "化工区") @ApiModelProperty(value = "区域", example = "11")
String region; Long sourceId;
@ApiModelProperty(value = "部门名称", example = "11")
Long departmentId;
@ApiModelProperty(value = "开始时间")
LocalDateTime startTime;
@ApiModelProperty(value = "结束时间")
LocalDateTime endTime;
} }
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.perstatistics; package com.yiring.app.service.location.turnover;
import com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam; import com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam;
import com.yiring.app.vo.perstatistics.PersonnelStatisticsDetailVo;
import com.yiring.app.vo.perstatistics.PersonnelStatisticsVo; import com.yiring.app.vo.perstatistics.PersonnelStatisticsVo;
import com.yiring.common.core.Result; import com.yiring.common.core.Result;
import com.yiring.common.param.PageParam; import com.yiring.common.param.PageParam;
...@@ -10,30 +11,48 @@ import javax.servlet.http.HttpServletResponse; ...@@ -10,30 +11,48 @@ import javax.servlet.http.HttpServletResponse;
/** /**
* @author tzl * @author tzl
* @version 1.0 * 2022/5/15 11:41
* @description:
* @date 2022/5/15 9:27
*/ */
public interface PersonnelStatisticsService { public interface LocationTurnoverService {
/** /**
* 分页查询 * 分页区域人员统计信息
* @author tzl * @author tzl
* @date 2022/5/15 9:41 * @date 2022/5/15 11:44
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam * @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @param pageParam PageParam * @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.domain.location.LocationTurnover>>
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.perstatistics.PersonnelStatisticsVo>>
*/ */
Result<PageVo<PersonnelStatisticsVo>> pagePerSta( Result<PageVo<PersonnelStatisticsVo>> pageInfo(
PersonnelStatisticsQueryParam personnelStatisticsQueryParam, PersonnelStatisticsQueryParam personnelStatisticsQueryParam,
PageParam pageParam PageParam pageParam
); );
/**
* 下拉框
* @author tzl
* @date 2022/5/16 13:59
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.perstatistics.PersonnelStatisticsVo>>
*/
Result<PageVo<PersonnelStatisticsVo>> indexInfo(PersonnelStatisticsQueryParam personnelStatisticsQueryParam);
/** /**
* 导出人员统计 *
* @author tzl * @author tzl
* @date 2022/5/15 9:56 * @date 2022/5/16 11:57
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam * @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @param response HttpServletResponse * @param httpServletResponse HttpServletResponse
*/ */
void export(PersonnelStatisticsQueryParam personnelStatisticsQueryParam, HttpServletResponse response); void export(PersonnelStatisticsQueryParam personnelStatisticsQueryParam, HttpServletResponse httpServletResponse);
/**
*
* @author tzl
* @date 2022/5/15 17:42
* @param personnelStatisticsQueryParam PersonnelStatisticsQueryParam
* @param pageParam PageParam
* @return com.yiring.common.core.Result<com.yiring.common.vo.PageVo<com.yiring.app.vo.perstatistics.PersonnelStatisticsVo>>
*/
Result<PageVo<PersonnelStatisticsDetailVo>> selectInfo(
PersonnelStatisticsQueryParam personnelStatisticsQueryParam,
PageParam pageParam
);
} }
...@@ -13,6 +13,7 @@ import com.yiring.app.domain.log.ZyRealtimeLogRepository; ...@@ -13,6 +13,7 @@ import com.yiring.app.domain.log.ZyRealtimeLogRepository;
import com.yiring.app.param.key.KeyAlarmAddParam; import com.yiring.app.param.key.KeyAlarmAddParam;
import com.yiring.app.service.message.PositionMessageService; import com.yiring.app.service.message.PositionMessageService;
import com.yiring.app.util.GeoUtils; import com.yiring.app.util.GeoUtils;
import com.yiring.app.vo.equipment.EquipmentVo;
import com.yiring.auth.domain.dept.Department; import com.yiring.auth.domain.dept.Department;
import com.yiring.auth.domain.user.User; import com.yiring.auth.domain.user.User;
import com.yiring.auth.domain.user.UserRepository; import com.yiring.auth.domain.user.UserRepository;
...@@ -28,6 +29,7 @@ import javax.persistence.criteria.Expression; ...@@ -28,6 +29,7 @@ import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.locationtech.jts.geom.Point; import org.locationtech.jts.geom.Point;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -422,6 +424,25 @@ public class PositionMessageServiceImpl implements PositionMessageService { ...@@ -422,6 +424,25 @@ public class PositionMessageServiceImpl implements PositionMessageService {
public void processDeviceStatusMessage(JSONObject data) { public void processDeviceStatusMessage(JSONObject data) {
// TODO // TODO
log.info("DeviceStatus Message: {}", data); log.info("DeviceStatus Message: {}", data);
EquipmentVo equipmentVo = data.toJavaObject(EquipmentVo.class);
if (equipmentVo.getDeviceType().equals("BTI")) {
Optional<LocationTag> one = locationTagRepository.findOne(
Example.of(LocationTag.builder().code(equipmentVo.getDeviceId()).build())
);
if (one.isEmpty()) {
log.error("没找到该标签");
return;
}
//修改标签电量
LocationTag locationTag = LocationTag
.builder()
.code(equipmentVo.getDeviceId())
.volt(equipmentVo.getVolt())
.voltUnit(equipmentVo.getField_21())
.build();
BeanUtils.copyProperties(one.get(), locationTag);
locationTagRepository.saveAndFlush(locationTag);
}
} }
/** /**
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.perstatistics.impl;
import cn.hutool.core.util.StrUtil;
import com.github.liaochong.myexcel.core.DefaultStreamExcelBuilder;
import com.yiring.app.domain.perstatistics.PersonnelStatistics;
import com.yiring.app.domain.perstatistics.PersonnelStatisticsRepository;
import com.yiring.app.excel.perstatistics.PersonnelStatisticsExportExcel;
import com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam;
import com.yiring.app.service.perstatistics.PersonnelStatisticsService;
import com.yiring.app.vo.perstatistics.PersonnelStatisticsVo;
import com.yiring.common.core.Result;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 9:28
*/
@Slf4j
@Transactional(rollbackFor = RuntimeException.class)
@Service
public class PersonnelStatisticsServiceImpl implements PersonnelStatisticsService {
@Resource
PersonnelStatisticsRepository personnelStatisticsRepository;
@Override
public Result<PageVo<PersonnelStatisticsVo>> pagePerSta(
PersonnelStatisticsQueryParam personnelStatisticsQueryParam,
PageParam pageParam
) {
//分页
Pageable pageable = PageRequest.of(pageParam.getPageNo() - 1, pageParam.getPageSize());
Page<PersonnelStatistics> all = personnelStatisticsRepository.findAll(
condition(personnelStatisticsQueryParam),
pageable
);
List<PersonnelStatisticsVo> data = all
.get()
.map(personnelStatistics -> {
PersonnelStatisticsVo vo = new PersonnelStatisticsVo();
BeanUtils.copyProperties(personnelStatistics, vo);
return vo;
})
.collect(Collectors.toList());
PageVo<PersonnelStatisticsVo> resultVo = PageVo.build(data, all.getTotalElements());
return Result.ok(resultVo);
}
@Override
public void export(PersonnelStatisticsQueryParam personnelStatisticsQueryParam, HttpServletResponse response) {
List<PersonnelStatistics> all = personnelStatisticsRepository.findAll(condition(personnelStatisticsQueryParam));
List<PersonnelStatisticsExportExcel> visitorExportExcels = all
.stream()
.map(personnelStatistics -> {
PersonnelStatisticsExportExcel personnelStatisticsExportExcel = new PersonnelStatisticsExportExcel();
BeanUtils.copyProperties(personnelStatistics, personnelStatisticsExportExcel);
return personnelStatisticsExportExcel;
})
.toList();
try (
DefaultStreamExcelBuilder<PersonnelStatisticsExportExcel> defaultStreamExcelBuilder = DefaultStreamExcelBuilder
.of(PersonnelStatisticsExportExcel.class)
.threadPool(Executors.newFixedThreadPool(2))
.rowHeight(14)
.titleRowHeight(14)
.widths(8)
.style(
"cell->vertical-align:center;text-align:center",
"title->vertical-align:center;text-align:center;font-weight:bold;font-family:等线"
)
.start()
) {
defaultStreamExcelBuilder.append(visitorExportExcels);
String fileName = URLEncoder.encode("人员统计.xlsx", StandardCharsets.UTF_8);
response.setContentType("application/octet-stream");
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
OutputStream out = response.getOutputStream();
Workbook workbook = defaultStreamExcelBuilder.fixedTitles().build();
workbook.write(out);
workbook.close();
out.flush();
out.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException("导出访客信息失败: " + e.getMessage());
}
}
public Specification<PersonnelStatistics> condition(PersonnelStatisticsQueryParam personnelStatisticsQueryParam) {
return (root, query, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
//查询条件
if (StrUtil.isNotBlank(personnelStatisticsQueryParam.getRegion())) {
//区域查询
list.add(
criteriaBuilder.like(
root.get(PersonnelStatistics.Fields.region),
"%" + personnelStatisticsQueryParam.getRegion() + "%"
)
);
}
Order order = criteriaBuilder.desc(root.get(PersonnelStatistics.Fields.updateTime));
Predicate[] predicates = new Predicate[list.size()];
query.orderBy(order);
query.where(list.toArray(predicates));
return criteriaBuilder.and(list.toArray(predicates));
};
}
}
...@@ -158,8 +158,8 @@ public class VideoServiceImpl implements VideoService { ...@@ -158,8 +158,8 @@ public class VideoServiceImpl implements VideoService {
.mediaServerId("ZbnQN5csqxrPix7a") .mediaServerId("ZbnQN5csqxrPix7a")
.enable(true) .enable(true)
.enable_hls(true) .enable_hls(true)
.type(video.getM3u8().contains("sss") ? "ffmpeg" : "default") .type(video.getM3u8().contains("/h265") ? "ffmpeg" : "default")
.timeout_ms(video.getM3u8().contains("sss") ? 60 : null) .timeout_ms(video.getM3u8().contains("/h265") ? 60 : null)
.build(); .build();
JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie()); JSONObject jsonObject = gbClient.proxySave(streamProxyItem, gbCookie());
if (!jsonObject.get("code").equals(0)) { if (!jsonObject.get("code").equals(0)) {
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.equipment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/16 9:56
*/
@ApiModel("EquipmentVo")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EquipmentVo implements Serializable {
@Serial
private static final long serialVersionUID = -3268799901290404934L;
@ApiModelProperty(value = "设备编号", example = "1518841086628335616")
String deviceId;
@ApiModelProperty(value = "地图编号", example = "1518841086628335616")
String areaId;
@ApiModelProperty(value = "设备类型", example = "BTI:定位器 SXT:监控摄像头 GAT:闸机 LAB:指示牌 BTR:定位基站")
String deviceType;
@ApiModelProperty(value = "电量", example = "1")
Integer volt;
@ApiModelProperty(value = "电量单位(默认mV)", example = "mV")
String field_21;
@ApiModelProperty(value = "修改时间", example = "2022")
LocalDateTime updateTime;
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.perstatistics;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.*;
import lombok.experimental.FieldDefaults;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 9:15
*/
@ApiModel("PersonnelStatisticsDetailVo")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class PersonnelStatisticsDetailVo implements Serializable {
@Serial
private static final long serialVersionUID = -1591876062645939080L;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "区域id", example = "1")
Long sourceId;
@ApiModelProperty(value = "区域", example = "化工区")
String region;
@ApiModelProperty(value = "时间", example = "")
LocalDateTime time;
@ApiModelProperty(value = "是否入场")
Boolean enter;
@ApiModelProperty(value = "用户")
UserVo userVo;
@ApiModel("UserVo")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public static class UserVo implements Serializable {
@Serial
private static final long serialVersionUID = 4115779013003587949L;
@ApiModelProperty(value = "被访人姓名", example = "张三")
String realName;
String uuid;
String deptName;
}
}
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.perstatistics; package com.yiring.app.vo.perstatistics;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
...@@ -25,15 +28,22 @@ public class PersonnelStatisticsVo implements Serializable { ...@@ -25,15 +28,22 @@ public class PersonnelStatisticsVo implements Serializable {
@Serial @Serial
private static final long serialVersionUID = -5973651085056867803L; private static final long serialVersionUID = -5973651085056867803L;
@ApiModelProperty(value = "主键id", example = "1") @JsonSerialize(using = ToStringSerializer.class)
Long id; @ApiModelProperty(value = "区域id", example = "1")
Long sourceId;
@ApiModelProperty(value = "区域", example = "化工区") @ApiModelProperty(value = "区域", example = "化工区")
String region; String region;
@ApiModelProperty(value = "入场人数", example = "10") @ApiModelProperty(value = "入场人数", example = "10")
String admissionNumber; Long admissionNumber;
@ApiModelProperty(value = "出场人数", example = "5") @ApiModelProperty(value = "出场人数", example = "5")
String attendance; Long attendance;
@ApiModelProperty(value = "开始时间")
LocalDateTime startTime;
@ApiModelProperty(value = "结束时间")
LocalDateTime endTime;
} }
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.perstatistics;
import io.swagger.annotations.ApiModel;
import java.io.Serial;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.FieldDefaults;
/**
* @author tzl
* @version 1.0
* @description:
* @date 2022/5/15 14:07
*/
@ApiModel("TurnoverResultVo")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TurnoverResultVo implements Serializable {
@Serial
private static final long serialVersionUID = 4478127252599634203L;
Long num;
Long sourceId;
Boolean enter;
}
/* (C) 2022 YiRing, Inc. */ /* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.perstatistics; package com.yiring.app.web.location.turnover;
import com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam; import com.yiring.app.param.perstatistics.PersonnelStatisticsQueryParam;
import com.yiring.app.service.perstatistics.PersonnelStatisticsService; import com.yiring.app.service.location.turnover.LocationTurnoverService;
import com.yiring.app.vo.perstatistics.PersonnelStatisticsDetailVo;
import com.yiring.app.vo.perstatistics.PersonnelStatisticsVo; import com.yiring.app.vo.perstatistics.PersonnelStatisticsVo;
import com.yiring.common.core.Result; import com.yiring.common.core.Result;
import com.yiring.common.param.PageParam; import com.yiring.common.param.PageParam;
...@@ -29,21 +30,29 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -29,21 +30,29 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@Validated @Validated
@SuppressWarnings({ "deprecation" }) @SuppressWarnings({ "deprecation" })
@Api(tags = "人员统计", description = "PersonnelStatistics") @Api(tags = "人员统计", description = "LocationTurnover")
@RestController @RestController
@RequestMapping("/personnelStatistics/") @RequestMapping("/locationTurnover/")
public class PersonnelStatisticsController { public class LocationTurnoverController {
@Resource @Resource
PersonnelStatisticsService personnelStatisticsService; LocationTurnoverService locationTurnoverService;
@ApiOperation(value = "分页查询人员统计") @ApiOperation(value = "分页查询人员统计")
@GetMapping("pagePerSta") @GetMapping("pageInfo")
public Result<PageVo<PersonnelStatisticsVo>> pagePerSta( public Result<PageVo<PersonnelStatisticsVo>> pageInfo(
@Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam, @Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam,
@Valid PageParam pageParam @Valid PageParam pageParam
) { ) {
return personnelStatisticsService.pagePerSta(personnelStatisticsQueryParam, pageParam); return locationTurnoverService.pageInfo(personnelStatisticsQueryParam, pageParam);
}
@ApiOperation(value = "下拉框")
@GetMapping("indexInfo")
public Result<PageVo<PersonnelStatisticsVo>> indexInfo(
@Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam
) {
return locationTurnoverService.indexInfo(personnelStatisticsQueryParam);
} }
@ApiOperation(value = "导出", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @ApiOperation(value = "导出", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
...@@ -52,6 +61,15 @@ public class PersonnelStatisticsController { ...@@ -52,6 +61,15 @@ public class PersonnelStatisticsController {
HttpServletResponse response, HttpServletResponse response,
@Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam @Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam
) { ) {
personnelStatisticsService.export(personnelStatisticsQueryParam, response); locationTurnoverService.export(personnelStatisticsQueryParam, response);
}
@ApiOperation(value = "查询人员统计详情")
@GetMapping("selectInfo")
public Result<PageVo<PersonnelStatisticsDetailVo>> selectInfo(
@Valid PersonnelStatisticsQueryParam personnelStatisticsQueryParam,
@Valid PageParam pageParam
) {
return locationTurnoverService.selectInfo(personnelStatisticsQueryParam, pageParam);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论