From eb8c2e062f554aa250d660ac798cdb1de7eeeb99 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 12 十二月 2024 00:14:15 +0800
Subject: [PATCH] 首页抓拍量按钮
---
ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 352 +++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 262 insertions(+), 90 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
index 78ff3c8..3f09bc6 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
@@ -7,6 +7,7 @@
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.ycl.platform.domain.entity.TMonitor;
+import com.ycl.platform.domain.excel.TMonitorExp;
import com.ycl.platform.domain.excel.VideoDailyExp;
import com.ycl.platform.domain.excel.VideoTotalExp;
import com.ycl.platform.domain.form.VideoExportForm;
@@ -14,14 +15,12 @@
import com.ycl.platform.domain.query.DataCenterQuery;
import com.ycl.platform.domain.query.HomeQuery;
import com.ycl.platform.domain.result.BaseResult;
-import com.ycl.platform.domain.result.HK.FaceDeviceInspectionResult;
-import com.ycl.platform.domain.result.HK.FaceDeviceSamplingResult;
-import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult;
-import com.ycl.platform.domain.result.HK.VehicleDeviceSamplingResult;
+import com.ycl.platform.domain.result.HK.*;
import com.ycl.platform.domain.result.SYS.TMonitorResult;
import com.ycl.platform.domain.result.UY.MonitorQualifyResult;
import com.ycl.platform.domain.result.UY.OsdCheckResult;
import com.ycl.platform.domain.result.UY.RecordMetaDSumResult;
+import com.ycl.platform.domain.vo.DynamicColumnVO;
import com.ycl.platform.domain.vo.TMonitorVO;
import com.ycl.platform.domain.vo.WorkOrderVO;
import com.ycl.platform.domain.vo.home.BaseHomeVO;
@@ -30,6 +29,7 @@
import com.ycl.platform.domain.vo.home.HomeVideoVO;
import com.ycl.platform.domain.vo.screen.MonitorRateVO;
import com.ycl.platform.domain.vo.screen.MonitorTotalVO;
+import com.ycl.platform.mapper.DynamicColumnMapper;
import com.ycl.platform.mapper.TMonitorMapper;
import com.ycl.platform.mapper.WorkOrderMapper;
import com.ycl.platform.service.ITMonitorService;
@@ -41,6 +41,7 @@
import com.ycl.system.service.ISysConfigService;
import com.ycl.utils.DateUtils;
import com.ycl.utils.StringUtils;
+import com.ycl.utils.poi.ExcelUtil;
import constant.ApiConstants;
import constant.CheckConstants;
import enumeration.general.AreaDeptEnum;
@@ -91,6 +92,8 @@
private WorkOrderMapper workOrderMapper;
@Autowired
private SysDictDataMapper dictDataMapper;
+ @Autowired
+ private DynamicColumnMapper dynamicColumnMapper;
/**
* 鏌ヨ璁惧璧勪骇
@@ -133,7 +136,7 @@
for (TMonitorVO monitor : monitors) {
if (!CollectionUtils.isEmpty(voList)) {
for (WorkOrderVO workOrderVO : voList) {
- if (monitor.getWorkOrderNo().equals(workOrderVO.getWorkOrderNo())) {
+ if (monitor.getWorkOrderNo() != null && monitor.getWorkOrderNo().equals(workOrderVO.getWorkOrderNo())) {
monitor.setUnitContact(workOrderVO.getUnitContact());
monitor.setUnitContactPhone(workOrderVO.getUnitContactPhone());
monitor.setYwPeopleName(workOrderVO.getYwPeopleName());
@@ -185,21 +188,30 @@
}
// 杞﹁締鐩戞帶璁惧
if (Objects.equals(tMonitor.getCameraFunType(), "2")) {
- //灞炴�т竴鑷寸巼銆佸ぇ鍥俱�乽rl
+ //灞炴�т竴鑷寸巼銆佸ぇ鍥�
List<VehicleDeviceSamplingResult> sampleResults = mongoTemplate.find(query, VehicleDeviceSamplingResult.class);
+ List<PicAccessResult> picAccessResults = mongoTemplate.find(query, PicAccessResult.class);
//鎶撴媿閲忋�佹椂閽熴�佷笂浼�
List<VehicleDeviceInspectionResult> inspectResults = mongoTemplate.find(query, VehicleDeviceInspectionResult.class);
for (TMonitorVO monitor : monitors) {
monitor.setMongoCreateTime(now);
//涓�鏈轰竴妗�
setOneFile(monitorQualifyResults, monitor);
- //灞炴�т竴鑷寸巼銆佸ぇ鍥俱�乽rl
+ //url
+ if (!CollectionUtils.isEmpty(sampleResults)) {
+ for (PicAccessResult picAccessResult : picAccessResults) {
+ if (monitor.getSerialNumber().equals(picAccessResult.getNo())) {
+ BigDecimal bigDecimal = PicAccessResult.calUrl(picAccessResult);
+ monitor.setUrlPercent(bigDecimal);
+ }
+ }
+ }
+ //灞炴�т竴鑷寸巼銆佸ぇ鍥�
if (!CollectionUtils.isEmpty(sampleResults)) {
for (VehicleDeviceSamplingResult sampleResult : sampleResults) {
if (monitor.getSerialNumber().equals(sampleResult.getNo())) {
if (sampleResult.getBigUseful() != null) {
monitor.setBigUsefulPercent(sampleResult.getBigUseful().getBigUsefulPercent());
- monitor.setUrlPercent(VehicleDeviceSamplingResult.BigUsefulness.calUrl(sampleResult.getBigUseful()));
}
if (sampleResult.getVehDiff() != null) {
monitor.setImportantConPercent(sampleResult.getVehDiff().getImportantConPercent());
@@ -233,13 +245,12 @@
monitor.setMongoCreateTime(now);
//涓�鏈轰竴妗�
setOneFile(monitorQualifyResults, monitor);
- //浜鸿劯鍚堟牸銆佸ぇ鍥俱�乽rl璁块棶寮傚父
+ //浜鸿劯鍚堟牸銆佸ぇ鍥�
if (!CollectionUtils.isEmpty(sampleResults)) {
for (FaceDeviceSamplingResult sampleResult : sampleResults) {
if (monitor.getSerialNumber().equals(sampleResult.getNo())) {
if (sampleResult.getBigUseful() != null) {
monitor.setBigUsefulPercent(sampleResult.getBigUseful().getBigUsefulPercent());
- monitor.setUrlPercent(FaceDeviceSamplingResult.BigUsefulness.calUrl(sampleResult.getBigUseful()));
}
if (sampleResult.getFaceEligibility() != null)
monitor.setFacePercent(sampleResult.getFaceEligibility().getFaceEligPercent());
@@ -406,6 +417,14 @@
*/
@Override
public void exportVideoTotal(HttpServletResponse response, VideoExportForm exportForm) throws IOException {
+ //榛樿鏌ユ墍鏈夐儴闂�
+ if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
+ List<Integer> deptIds = new ArrayList<>();
+ for (AreaDeptEnum value : AreaDeptEnum.values()) {
+ deptIds.add(value.getDeptId());
+ }
+ exportForm.setDeptIds(deptIds);
+ }
List<ExcelExp> mysheet = new ArrayList<>();
exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + ""));
VideoExportForm.convertTags(exportForm);
@@ -444,9 +463,10 @@
List<TMonitorResult> onlines = onlineList.stream().filter(tMonitorResult -> tMonitorResult.getMongoCreateTime().minusDays(1).equals(parseTime)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(onlines)) {
videoExp.setTotal(onlines.size());
- videoExp.setOnline(Integer.valueOf(onlines.stream()
- .filter(TMonitorResult::getOnline)
- .count() + ""));
+ long count = onlines.stream()
+ .filter(item -> ApiConstants.UY_OnlineSite_Online.equals(item.getOnline()))
+ .count();
+ videoExp.setOnline(Integer.valueOf(count + ""));
videoExp.setOffline(videoExp.getTotal() - videoExp.getOnline());
}
//璁剧疆瀛樺偍鎯呭喌
@@ -490,10 +510,29 @@
*/
@Override
public void exportVideoOnline(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException {
+ //榛樿鏌ユ墍鏈夐儴闂�
+ if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
+ List<Integer> deptIds = new ArrayList<>();
+ for (AreaDeptEnum value : AreaDeptEnum.values()) {
+ deptIds.add(value.getDeptId());
+ }
+ exportForm.setDeptIds(deptIds);
+ }
List<ExcelExp> mysheet = new ArrayList<>();
exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + ""));
VideoExportForm.convertTags(exportForm);
List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm);
+ //鑾峰彇鍔ㄦ�佸垪鏁版嵁
+ List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
+ List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
+ //琛ュ厖鍔ㄦ�佸垪鏁版嵁
+ if (!CollectionUtils.isEmpty(dynamics)) {
+ Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
+ for (TMonitorResult tMonitorResult : tMonitorResults) {
+ Integer pointId = tMonitorResult.getPointId();
+ tMonitorResult.setDynamicColumnList(map.get(pointId));
+ }
+ }
List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList());
Query query = getQuery(deviceIds, exportForm.getMonth());
//鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁
@@ -514,12 +553,19 @@
videoDailyExp.setSerialNumber(result.getNo());
videoDailyExp.setDeviceName(result.getName());
videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
- String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "");
- // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
- if (tag.endsWith("銆�")) {
- tag = tag.substring(0, tag.length() - 1);
+ StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""));
+ //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
+ if (!CollectionUtils.isEmpty(result.getDynamicColumnList())) {
+ List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList();
+ for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) {
+ tag.append(dynamicColumnVO.getColumnValue()).append("銆�");
+ }
}
- videoDailyExp.setTag(tag);
+ // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
+ if (tag.toString().endsWith("銆�")) {
+ tag = new StringBuilder(tag.substring(0, tag.length() - 1));
+ }
+ videoDailyExp.setTag(tag.toString());
setOnlineDaily(videoDailyExp, result, onlines);
videoDailyExps.add(videoDailyExp);
//鍏ㄩ噺琛�
@@ -540,12 +586,40 @@
*/
@Override
public void exportVideoRecord(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException {
+ //榛樿鏌ユ墍鏈夐儴闂�
+ if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
+ List<Integer> deptIds = new ArrayList<>();
+ for (AreaDeptEnum value : AreaDeptEnum.values()) {
+ deptIds.add(value.getDeptId());
+ }
+ exportForm.setDeptIds(deptIds);
+ }
List<ExcelExp> mysheet = new ArrayList<>();
exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + ""));
VideoExportForm.convertTags(exportForm);
List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm);
+ //鑾峰彇鍔ㄦ�佸垪鏁版嵁
+ List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
+ List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
+ //琛ュ厖鍔ㄦ�佸垪鏁版嵁
+ if (!CollectionUtils.isEmpty(dynamics)) {
+ Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
+ for (TMonitorResult tMonitorResult : tMonitorResults) {
+ Integer pointId = tMonitorResult.getPointId();
+ tMonitorResult.setDynamicColumnList(map.get(pointId));
+ }
+ }
List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList());
- Query query = getQuery(deviceIds, exportForm.getMonth());
+ // 灏嗗勾鏈堝瓧绗︿覆瑙f瀽涓篩earMonth瀵硅薄
+ YearMonth yearMonth = YearMonth.parse(exportForm.getMonth());
+ // 鑾峰彇褰撴湀鐨勭涓�澶�
+ LocalDate start = yearMonth.atDay(1);
+ // 鑾峰彇涓嬩釜鏈堢殑绗竴澶╋紙閫氳繃鍔犱笂1涓湀骞惰缃棩涓�1锛�
+ YearMonth nextMonth = yearMonth.plusMonths(1);
+ LocalDate end = nextMonth.atDay(1);
+ //鑾峰彇杩欎釜鏈堜唤鐨勯儴闂ㄦ暟鎹紝褰曞儚鐢变簬鏄墠涓�澶╃殑鎵�浠ヤ笉鐢╟reateTime瀛楁
+ Query query = new Query(Criteria.where("statTime").gte(start).lt(end));
+ query.addCriteria(Criteria.where("no").in(deviceIds));
//鏈堜唤姣忔棩褰曞儚绾挎暟鎹�
List<RecordMetaDSumResult> recordResult = mongoTemplate.find(query, RecordMetaDSumResult.class);
//鍏ㄩ噺琛�
@@ -564,12 +638,19 @@
videoDailyExp.setSerialNumber(result.getNo());
videoDailyExp.setDeviceName(result.getName());
videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
- String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "");
- // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
- if (tag.endsWith("銆�")) {
- tag = tag.substring(0, tag.length() - 1);
+ StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""));
+ //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
+ if (!CollectionUtils.isEmpty(result.getDynamicColumnList())) {
+ List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList();
+ for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) {
+ tag.append(dynamicColumnVO.getColumnValue()).append("銆�");
+ }
}
- videoDailyExp.setTag(tag);
+ // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
+ if (tag.toString().endsWith("銆�")) {
+ tag = new StringBuilder(tag.substring(0, tag.length() - 1));
+ }
+ videoDailyExp.setTag(tag.toString());
setRecordDaily(videoDailyExp, result, records);
//鍖哄幙琛�
videoDailyExps.add(videoDailyExp);
@@ -590,12 +671,40 @@
*/
@Override
public void exportVideoLoseTime(HttpServletResponse response, VideoExportForm exportForm) throws NoSuchFieldException, IllegalAccessException, IOException {
+ //榛樿鏌ユ墍鏈夐儴闂�
+ if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
+ List<Integer> deptIds = new ArrayList<>();
+ for (AreaDeptEnum value : AreaDeptEnum.values()) {
+ deptIds.add(value.getDeptId());
+ }
+ exportForm.setDeptIds(deptIds);
+ }
List<ExcelExp> mysheet = new ArrayList<>();
exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + ""));
VideoExportForm.convertTags(exportForm);
List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm);
+ //鑾峰彇鍔ㄦ�佸垪鏁版嵁
+ List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
+ List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
+ //琛ュ厖鍔ㄦ�佸垪鏁版嵁
+ if (!CollectionUtils.isEmpty(dynamics)) {
+ Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
+ for (TMonitorResult tMonitorResult : tMonitorResults) {
+ Integer pointId = tMonitorResult.getPointId();
+ tMonitorResult.setDynamicColumnList(map.get(pointId));
+ }
+ }
List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList());
- Query query = getQuery(deviceIds, exportForm.getMonth());
+ // 灏嗗勾鏈堝瓧绗︿覆瑙f瀽涓篩earMonth瀵硅薄
+ YearMonth yearMonth = YearMonth.parse(exportForm.getMonth());
+ // 鑾峰彇褰撴湀鐨勭涓�澶�
+ LocalDate start = yearMonth.atDay(1);
+ // 鑾峰彇涓嬩釜鏈堢殑绗竴澶╋紙閫氳繃鍔犱笂1涓湀骞惰缃棩涓�1锛�
+ YearMonth nextMonth = yearMonth.plusMonths(1);
+ LocalDate end = nextMonth.atDay(1);
+ //鑾峰彇杩欎釜鏈堜唤鐨勯儴闂ㄦ暟鎹紝褰曞儚鐢变簬鏄墠涓�澶╃殑鎵�浠ヤ笉鐢╟reateTime瀛楁
+ Query query = new Query(Criteria.where("statTime").gte(start).lt(end));
+ query.addCriteria(Criteria.where("no").in(deviceIds));
//鏈堜唤姣忔棩褰曞儚绾挎暟鎹�
List<RecordMetaDSumResult> recordResult = mongoTemplate.find(query, RecordMetaDSumResult.class);
//鍏ㄩ噺琛�
@@ -614,12 +723,19 @@
videoDailyExp.setSerialNumber(result.getNo());
videoDailyExp.setDeviceName(result.getName());
videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
- String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "");
- // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
- if (tag.endsWith("銆�")) {
- tag = tag.substring(0, tag.length() - 1);
+ StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""));
+ //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
+ if (!CollectionUtils.isEmpty(result.getDynamicColumnList())) {
+ List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList();
+ for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) {
+ tag.append(dynamicColumnVO.getColumnValue()).append("銆�");
+ }
}
- videoDailyExp.setTag(tag);
+ // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
+ if (tag.toString().endsWith("銆�")) {
+ tag = new StringBuilder(tag.substring(0, tag.length() - 1));
+ }
+ videoDailyExp.setTag(tag.toString());
setLoseDaily(videoDailyExp, result, records);
videoDailyExps.add(videoDailyExp);
//鍏ㄩ噺琛�
@@ -664,7 +780,7 @@
MongoDatabase database = mongoTemplate.getDb();
MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
Integer examineTag = monitorQuery.getExamineTag();
- Document matchConditions = new Document("mongoCreateTime", new Document("$gte", startDate).append("$lte", endDate));
+ Document matchConditions = new Document("statTime", new Document("$gte", startDate).append("$lte", endDate));
// 鏍规嵁examineTag鐨勫�煎姩鎬佹坊鍔犻澶栫殑鏉′欢
if (examineTag != null && examineTag.equals(1)) {
matchConditions.append("provinceTag", true);
@@ -674,7 +790,7 @@
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
new Document("$match", matchConditions),
- new Document("$group", new Document("_id", "$mongoCreateTime")
+ new Document("$group", new Document("_id", "$statTime")
.append("normalCount", new Document("$sum",
new Document("$cond", Arrays.asList(
new Document("$eq", Arrays.asList("$recordStatus", 1)),
@@ -719,7 +835,7 @@
new Document("$group", new Document("_id", "$mongoCreateTime")
.append("onlineCount", new Document("$sum",
new Document("$cond", Arrays.asList(
- new Document("$eq", Arrays.asList("$online", Boolean.TRUE)),
+ new Document("$eq", Arrays.asList("$online", ApiConstants.UY_OnlineSite_Online)),
1,
0
))
@@ -751,6 +867,60 @@
resultMap.put("baseLine", Integer.valueOf(sysDictData.getDictValue()));
}
return resultMap;
+ }
+
+ /**
+ * 鍒楄〃瀵煎嚭
+ *
+ * @param response
+ * @param tMonitor
+ */
+ @Override
+ public void export(HttpServletResponse response, TMonitorVO tMonitor) {
+ List<TMonitorExp> monitors = tMonitorMapper.exportTMonitorList(tMonitor);
+ //鑾峰彇鍔ㄦ�佸垪鏁版嵁
+ List<Integer> pointIds = monitors.stream().map(TMonitorExp::getPointId).collect(Collectors.toList());
+ List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
+ //琛ュ厖鍔ㄦ�佸垪鏁版嵁
+ if (!CollectionUtils.isEmpty(dynamics)) {
+ Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
+ for (TMonitorExp tMonitorResult : monitors) {
+ Integer pointId = tMonitorResult.getPointId();
+ tMonitorResult.setDynamicColumnList(map.get(pointId));
+ }
+ }
+ monitors.forEach(monitor -> {
+ String cameraFunType = monitor.getCameraFunType();
+ if (!StringUtils.isEmpty(cameraFunType)) {
+ String video = cameraFunType.replaceAll("1", "瑙嗛");
+ String car = video.replaceAll("2", "杞﹁締");
+ String type = car.replaceAll("3", "浜鸿劯");
+ monitor.setCameraFunType(type);
+ }
+ StringBuilder tag = new StringBuilder("" + (monitor.getProvinceTagVideo() ? "鐪佸巺瑙嗛銆�" : "") + (monitor.getProvinceTagCar() ? "鐪佸巺杞﹁締銆�" : "")+ (monitor.getProvinceTagFace() ? "鐪佸巺浜鸿劯銆�" : "")+ (monitor.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (monitor.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (monitor.getDeptTag() ? "閮ㄧ骇銆�" : ""));
+ //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
+ if (!CollectionUtils.isEmpty(monitor.getDynamicColumnList())) {
+ List<DynamicColumnVO> dynamicColumnList = monitor.getDynamicColumnList();
+ for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) {
+ tag.append(dynamicColumnVO.getColumnValue()).append("銆�");
+ }
+ }
+ // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲��
+ if (tag.toString().endsWith("銆�")) {
+ tag = new StringBuilder(tag.substring(0, tag.length() - 1));
+ }
+ monitor.setTag(tag.toString());
+ });
+ ExcelUtil<TMonitorExp> util = new ExcelUtil<>(TMonitorExp.class);
+ String sheetName = "";
+ if("1".equals(tMonitor.getCameraFunType())){
+ sheetName = "瑙嗛";
+ }else if("2".equals(tMonitor.getCameraFunType())){
+ sheetName = "杞﹁締";
+ }else if("3".equals(tMonitor.getCameraFunType())){
+ sheetName = "浜鸿劯";
+ }
+ util.exportExcel(response, monitors,sheetName);
}
@@ -789,8 +959,6 @@
matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR)));
if (examineTag != null && examineTag.equals(1)) {
matchConditions.add(new Document("provinceTag", true));
- } else if (examineTag != null && examineTag.equals(2)) {
- matchConditions.add(new Document("deptTag", true));
}
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
@@ -799,7 +967,6 @@
.append("dataCount", new Document("$sum", "$dataCount"))
)
);
-
// 鎵ц鑱氬悎鏌ヨ骞惰幏鍙栫粨鏋�
AggregateIterable<Document> result = collection.aggregate(pipeline);
for (Document doc : result) {
@@ -809,7 +976,6 @@
results.add(homecarVO);
}
- //mongo鏌ョ偣浣嶅湪绾�
MongoCollection<Document> onlineCollection = database.getCollection("t_monitor_online");
// 鏋勫缓鍩烘湰鐨�$match鏉′欢
List<Document> onlineMatch = new ArrayList<>();
@@ -817,8 +983,6 @@
onlineMatch.add(new Document("monitorType", new Document("$regex", "2")));
if (examineTag != null && examineTag.equals(1)) {
onlineMatch.add(new Document("provinceTag", true));
- } else if (examineTag != null && examineTag.equals(2)) {
- onlineMatch.add(new Document("deptTag", true));
}
// 鏋勫缓鑱氬悎绠¢亾
List<Document> onlinePipeline = Arrays.asList(
@@ -826,7 +990,7 @@
new Document("$group", new Document("_id", "$mongoCreateTime")
.append("onlineCount", new Document("$sum",
new Document("$cond", Arrays.asList(
- new Document("$eq", Arrays.asList("$online", Boolean.TRUE)),
+ new Document("$eq", Arrays.asList("$online", ApiConstants.UY_OnlineSite_Online)),
1,
0
))
@@ -842,30 +1006,33 @@
Map<String, Object> resultMap = new HashMap<>();
//鎸夋椂闂存帓搴�
results = results.stream().sorted(Comparator.comparing(BaseHomeVO::getCreateDate)).collect(Collectors.toList());
- int snapCount = 0;
- for (HomeCarVO vo : results) {
- if (vo.getSnapCount() != null) {
- snapCount += vo.getSnapCount();
+ //濡傛灉鏄粯璁ゆ垨绱拰鍒欒繘琛岀疮鍜屼互鍙婅幏鍙栧熀鍑嗙嚎
+ if(monitorQuery.getCategory() == null || monitorQuery.getCategory().equals(1)) {
+ int snapCount = 0;
+ for (HomeCarVO vo : results) {
+ if (vo.getSnapCount() != null) {
+ snapCount += vo.getSnapCount();
+ }
+ vo.setSnapCount(snapCount);
}
- vo.setSnapCount(snapCount);
+ //浠庡瓧鍏歌幏鍙栧熀鍑嗙嚎
+ List<SysDictData> baseLines = dictDataMapper.selectDictDataByType("home_baseLine");
+ String condition;
+ if (examineTag != null && examineTag == 1) {
+ condition = "car_province_baseLine";
+ } else if (examineTag != null && examineTag == 2) {
+ condition = "car_dept_baseLine";
+ } else {
+ condition = "car_all_baseLine";
+ }
+
+ Optional<SysDictData> first = baseLines.stream().filter(sysDictData -> condition.equals(sysDictData.getDictLabel())).findFirst();
+ if (first.isPresent()) {
+ SysDictData sysDictData = first.get();
+ resultMap.put("baseLine", Integer.valueOf(sysDictData.getDictValue()));
+ }
}
resultMap.put("list", results);
- //浠庡瓧鍏歌幏鍙栧熀鍑嗙嚎
- List<SysDictData> baseLines = dictDataMapper.selectDictDataByType("home_baseLine");
- String condition;
- if (examineTag != null && examineTag == 1) {
- condition = "car_province_baseLine";
- } else if (examineTag != null && examineTag == 2) {
- condition = "car_dept_baseLine";
- } else {
- condition = "car_all_baseLine";
- }
-
- Optional<SysDictData> first = baseLines.stream().filter(sysDictData -> condition.equals(sysDictData.getDictLabel())).findFirst();
- if (first.isPresent()) {
- SysDictData sysDictData = first.get();
- resultMap.put("baseLine", Integer.valueOf(sysDictData.getDictValue()));
- }
return resultMap;
}
@@ -904,8 +1071,6 @@
matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE)));
if (examineTag != null && examineTag.equals(1)) {
matchConditions.add(new Document("provinceTag", true));
- } else if (examineTag != null && examineTag.equals(2)) {
- matchConditions.add(new Document("deptTag", true));
}
// 鏋勫缓鑱氬悎绠¢亾
List<Document> pipeline = Arrays.asList(
@@ -932,8 +1097,6 @@
onlineMatch.add(new Document("monitorType", new Document("$regex", "3")));
if (examineTag != null && examineTag.equals(1)) {
onlineMatch.add(new Document("provinceTag", true));
- } else if (examineTag != null && examineTag.equals(2)) {
- onlineMatch.add(new Document("deptTag", true));
}
// 鏋勫缓鑱氬悎绠¢亾
List<Document> onlinePipeline = Arrays.asList(
@@ -941,7 +1104,7 @@
new Document("$group", new Document("_id", "$mongoCreateTime")
.append("onlineCount", new Document("$sum",
new Document("$cond", Arrays.asList(
- new Document("$eq", Arrays.asList("$online", Boolean.TRUE)),
+ new Document("$eq", Arrays.asList("$online", ApiConstants.UY_OnlineSite_Online)),
1,
0
))
@@ -954,32 +1117,35 @@
HomeFaceVO vo = findOrCreateVO(doc, results, HomeFaceVO.class);
vo.setOnline(doc.getInteger("onlineCount"));
}
+ Map<String, Object> resultMap = new HashMap<>();
//鎸夋椂闂存帓搴�
results = results.stream().sorted(Comparator.comparing(BaseHomeVO::getCreateDate)).collect(Collectors.toList());
- int snapCount = 0;
- for (HomeFaceVO vo : results) {
- if (vo.getSnapCount() != null) {
- snapCount += vo.getSnapCount();
+ //濡傛灉鏄粯璁ゆ垨绱拰鍒欒繘琛岀疮鍜屼互鍙婅幏鍙栧熀鍑嗙嚎
+ if(monitorQuery.getCategory() == null || monitorQuery.getCategory().equals(1)) {
+ int snapCount = 0;
+ for (HomeFaceVO vo : results) {
+ if (vo.getSnapCount() != null) {
+ snapCount += vo.getSnapCount();
+ }
+ vo.setSnapCount(snapCount);
}
- vo.setSnapCount(snapCount);
+ //浠庡瓧鍏歌幏鍙栧熀鍑嗙嚎
+ List<SysDictData> baseLines = dictDataMapper.selectDictDataByType("home_baseLine");
+ String condition;
+ if (examineTag != null && examineTag == 1) {
+ condition = "face_province_baseLine";
+ } else if (examineTag != null && examineTag == 2) {
+ condition = "face_dept_baseLine";
+ } else {
+ condition = "face_all_baseLine";
+ }
+ Optional<SysDictData> first = baseLines.stream().filter(sysDictData -> condition.equals(sysDictData.getDictLabel())).findFirst();
+ if (first.isPresent()) {
+ SysDictData sysDictData = first.get();
+ resultMap.put("baseLine", Integer.valueOf(sysDictData.getDictValue()));
+ }
}
- Map<String, Object> resultMap = new HashMap<>();
resultMap.put("list", results);
- //浠庡瓧鍏歌幏鍙栧熀鍑嗙嚎
- List<SysDictData> baseLines = dictDataMapper.selectDictDataByType("home_baseLine");
- String condition;
- if (examineTag != null && examineTag == 1) {
- condition = "face_province_baseLine";
- } else if (examineTag != null && examineTag == 2) {
- condition = "face_dept_baseLine";
- } else {
- condition = "face_all_baseLine";
- }
- Optional<SysDictData> first = baseLines.stream().filter(sysDictData -> condition.equals(sysDictData.getDictLabel())).findFirst();
- if (first.isPresent()) {
- SysDictData sysDictData = first.get();
- resultMap.put("baseLine", Integer.valueOf(sysDictData.getDictValue()));
- }
return resultMap;
}
@@ -1018,7 +1184,13 @@
for (TMonitorResult monitorResult : onlineResult) {
int dayOfMonth = monitorResult.getMongoCreateTime().getDayOfMonth();
String online = "";
- online += monitorResult.getOnline() ? "鍦ㄧ嚎" : "绂荤嚎";
+ if (ApiConstants.UY_OnlineSite_Online.equals(monitorResult.getOnline())) {
+ online += "鍦ㄧ嚎";
+ } else if (ApiConstants.UY_OnlineSite_Offline.equals(monitorResult.getOnline())) {
+ online += "绂荤嚎";
+ } else {
+ online += "鏈煡";
+ }
//鍙嶅皠璧嬪�硷紝瀛楁缁熶竴瀹氫箟涓篸ay+1锛�2锛�3...
Field field = videoDailyExp.getClass().getDeclaredField("day" + dayOfMonth);
field.setAccessible(true);
@@ -1031,7 +1203,7 @@
//涓�涓澶囧綋鏈堝湪绾挎儏鍐�
List<RecordMetaDSumResult> recordResults = records.stream().filter(online -> online.getNo().equals(result.getNo())).collect(Collectors.toList());
for (RecordMetaDSumResult recordResult : recordResults) {
- int dayOfMonth = recordResult.getMongoCreateTime().getDayOfMonth();
+ int dayOfMonth = DateUtils.getDayOfMonth(recordResult.getStatTime());
Integer status = recordResult.getRecordStatus();
String text = "";
if (ApiConstants.UY_RecordStatus_Interval.equals(status)) {
@@ -1053,7 +1225,7 @@
//涓�涓澶囧綋鏈堝湪绾挎儏鍐�
List<RecordMetaDSumResult> recordResults = records.stream().filter(online -> online.getNo().equals(result.getNo())).collect(Collectors.toList());
for (RecordMetaDSumResult recordResult : recordResults) {
- int dayOfMonth = recordResult.getMongoCreateTime().getDayOfMonth();
+ int dayOfMonth = DateUtils.getDayOfMonth(recordResult.getStatTime());
//鍙嶅皠璧嬪�硷紝瀛楁缁熶竴瀹氫箟涓篸ay+1锛�2锛�3...
Field field = videoDailyExp.getClass().getDeclaredField("day" + dayOfMonth);
field.setAccessible(true);
--
Gitblit v1.8.0