From f63535115eff538f30b1004faf90a428ebdca963 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期三, 31 七月 2024 11:55:00 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ycl-server/src/main/java/com/ycl/calculate/FaceSiteOnlineCalculation.java | 149 +++++ ycl-server/src/main/java/com/ycl/calculate/CalculationStrategy.java | 7 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDelayMonitorResult.java | 7 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceSamplingResult.java | 5 ycl-server/src/main/java/com/ycl/calculate/IndexCalculationUtils.java | 30 + ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java | 3 ycl-server/src/main/java/com/ycl/calculate/CarSiteOnlineCalculation.java | 146 +++++ ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/VideoQualityParam.java | 31 + ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java | 1 ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/RecordMetaDSumResult.java | 3 ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexCarService.java | 5 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexFaceServiceImpl.java | 37 ycl-pojo/src/main/java/com/ycl/platform/domain/result/BaseResult.java | 2 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitorResourceResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/PicAccessResult.java | 5 ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml | 16 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/OrganizationTreeResult.java | 5 ycl-server/src/main/java/com/ycl/factory/IndexCalculationFactory.java | 19 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java | 43 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CarDetectResult.java | 5 ycl-server/src/main/java/com/ycl/task/UYTask.java | 14 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDetectResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDataMonitorResult.java | 8 ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml | 11 ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/QueryVqdResult.java | 246 ++++++++ ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java | 14 ycl-server/src/main/java/com/ycl/feign/UYClient.java | 26 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CrossDetailResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/excel/CalculateExport.java | 51 + ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitoringDetailResult.java | 5 ycl-server/src/main/java/com/ycl/utils/DateUtils.java | 31 + ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OnlineResult.java | 2 ycl-server/src/main/java/com/ycl/platform/mapper/CheckIndexFaceMapper.java | 20 ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java | 11 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceInspectionResult.java | 3 ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java | 59 + ycl-server/src/main/java/com/ycl/platform/controller/VehicleDataMonitorController.java | 10 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CodeByAreaResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceSamplingResult.java | 5 ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java | 8 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/AttrRecognitionMonitorResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/VideoQualityResult.java | 66 ++ ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexCarServiceImpl.java | 130 ---- ycl-server/src/main/java/com/ycl/task/HKTask.java | 240 ++++++- ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java | 26 ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexFaceService.java | 10 ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/QueryVqdParam.java | 136 ++++ ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/DataIntegrityMonitoringResult.java | 7 ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml | 19 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CoordinateByAreaResult.java | 5 ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CriteriaResult.java | 5 51 files changed, 1,392 insertions(+), 320 deletions(-) diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java index 030bc2c..cf3e0a7 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java @@ -6,14 +6,9 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.ycl.system.entity.BaseEntity; import lombok.Data; -import lombok.experimental.Accessors; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.util.Date; -import java.util.Map; /** * 鑰冩牳绉垎鏄庣粏瀵硅薄 t_check_score @@ -69,4 +64,10 @@ @TableField(exist = false) private String date; + @TableField(exist = false) + private Date startDate; + + @TableField(exist = false) + private Date endDate; + } diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/CalculateExport.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/CalculateExport.java new file mode 100644 index 0000000..7f7e84e --- /dev/null +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/excel/CalculateExport.java @@ -0,0 +1,51 @@ +package com.ycl.platform.domain.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.*; +import com.alibaba.excel.enums.BooleanEnum; +import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; +import com.alibaba.excel.enums.poi.VerticalAlignmentEnum; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author gonghl + * @since 2024/7/30 涓婂崍 10:01 + */ +@Data +@ColumnWidth(20) +@HeadRowHeight(30) +@ContentRowHeight(30) +@HeadStyle(fillForegroundColor = 64) +@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER) +@ContentFontStyle(fontHeightInPoints = 18, bold = BooleanEnum.TRUE, fontName = "瀹嬩綋") +@HeadFontStyle(fontHeightInPoints = 18, bold = BooleanEnum.TRUE, fontName = "瀹嬩綋") +public class CalculateExport { + + /** + * 瑙勫垯鍚嶇О + */ + @ExcelProperty({"鑷础甯傚叕鍏辫棰戠洃鎺х郴缁熺画缁村悎鍚�", "瑙勫垯鍚嶇О"}) + @ColumnWidth(40) + private String ruleName; + + /** + * 鏁伴噺 + */ + @ExcelProperty({"鑷础甯傚叕鍏辫棰戠洃鎺х郴缁熺画缁村悎鍚�", "鏁伴噺"}) + private Integer num; + + /** + * 鍒嗘暟 + */ + @ExcelProperty({"鑷础甯傚叕鍏辫棰戠洃鎺х郴缁熺画缁村悎鍚�", "鍒嗘暟"}) + private Integer score; + + /** + * 閲戦 + */ + @ExcelProperty({"鑷础甯傚叕鍏辫棰戠洃鎺х郴缁熺画缁村悎鍚�", "閲戦"}) + private BigDecimal money; + +} diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/QueryVqdParam.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/QueryVqdParam.java new file mode 100644 index 0000000..2357dc2 --- /dev/null +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/QueryVqdParam.java @@ -0,0 +1,136 @@ +package com.ycl.platform.domain.param.UY; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 鍥惧儚妫�娴嬭瘖鏂粨鏋� + */ +@Data +@Accessors(chain = true) +public class QueryVqdParam { + /** + * 绉熸埛id + */ + private String tenantId; + /** + * 琛屾斂鍖哄煙缂栫爜 + */ + private String arealayerno; + /** + * 妯$硦 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String blur; + /** + * 棰滆壊 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String color; + /** + * 鎽勫儚鏈哄浗鏍嘔D + */ + private String deviceId; + /** + * 鎽勫儚鏈哄悕绉� + */ + private String deviceName; + /** + * 鎺掑簭鏂瑰紡 鍙�夊�间负 desc锛氬�掑簭鎺掑簭 asc锛氭搴忔帓搴� 榛樿鍊掑簭鎺掑簭 + */ + private String direction; + /** + * 0锛氬疄鏃剁爜娴佽瘖鏂� 1锛氬巻鍙茬爜娴佽瘖鏂� + */ + private Integer groupFlag; + /** + * 璇婃柇鍒嗙粍ID + */ + private String groupId; + /** + * 鍥惧儚璐ㄩ噺鐘舵�� 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String imgStatus; + /** + * 浜害 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String light; + /** + * 鍦ㄧ嚎鐘舵�� 1:鍦ㄧ嚎 0锛氭湭鐭� -1锛氱绾� + */ + private String onlineStatus; + /** + * 鍒嗛〉椤电爜,榛樿浠�1寮�濮� + */ + private Integer pageNum; + /** + * 鍒嗛〉澶у皬,榛樿1000 + */ + private Integer pageSize; + /** + * 鍥芥爣骞冲彴ID + */ + private String platId; + /** + * 閬尅 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String shade; + /** + * 鎶栧姩 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String shake; + /** + * 鏃犱俊鍙� 1:鏈変俊鍙� 0锛氭湭鐭� -1锛氭棤淇″彿 + */ + private String signal; + /** + * 淇″彿鐘舵�� 1:鏈変俊鍙� 0锛氭湭鐭� -1锛氭棤淇″彿 + */ + private String signalStatus; + /** + * 闆姳 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String snow; + /** + * 鎺掑簭鐨勫瓧娈� 鎸夋寚瀹氬瓧娈垫帓搴� 榛樿鎸夋媺鐮佹祦鏃堕棿鎺掑簭 + */ + private String sortedField; + /** + * 鏉$汗 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private String stripe; + /** + * 璇婃柇浠诲姟鍒涘缓鏃堕棿 + */ + private String taskCreateTime; + /** + * 璇婃柇浠诲姟澶嶆牳鏃堕棿 + */ + private String taskRecheckTime; + /** + * 瑙嗛璇婃柇鐘舵�� + */ + private String videoDiagStatus; + /** + * 瑙嗛娴佽瘖鏂紑濮嬫椂闂� + */ + private String videoDiagTimeBegin; + /** + * 瑙嗛娴佽瘖鏂粨鏉熸椂闂� + */ + private String videoDiagTimeEnd; + /** + * 鑾峰彇瑙嗛娴佺姸鎬� + */ + private String videoGetStatus; + /** + * 瑙嗛娴佽幏鍙栨椂闂村紑濮嬫椂闂� + */ + private String videoGetTimeBegin; + /** + * 瑙嗛娴佽幏鍙栨椂闂寸粨鏉熸椂闂� + */ + private String videoGetTimeEnd; + /** + * 鏄惁闇�瑕佸垎椤佃繑鍥炵粨鏋滐紝褰撲负true鏃秔ageSize鍜宲ageNum鍙傛暟澶辨晥 + */ + private Boolean withOutPaging; +} diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/VideoQualityParam.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/VideoQualityParam.java new file mode 100644 index 0000000..dcd9db6 --- /dev/null +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/param/UY/VideoQualityParam.java @@ -0,0 +1,31 @@ +package com.ycl.platform.domain.param.UY; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 瑙嗛鍥惧儚璐ㄩ噺 + */ +@Data +@Accessors(chain = true) +public class VideoQualityParam { + /** 鍖哄煙缂栫爜 */ + private String arealayerno; + private Object[] dbConditionItems; + /** 璁惧 ID */ + private String deviceId; + /** 璁惧鍚嶇О */ + private String deviceName; + /** 鍔ㄦ�佹潯浠� */ + private String dynamicConditionJson; + /** 鎺掑簭瀛楁 */ + private String field; + /** 鎺掑簭鏂瑰紡锛宒esc: 闄嶅簭, asc: 鍗囧簭 */ + private String order; + /** 鍒嗛〉椤电爜 */ + private Integer pageNum; + /** 鍒嗛〉澶у皬 */ + private Integer pageSize; + /** 鐘舵�� */ + private Integer status; +} diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/BaseResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/BaseResult.java similarity index 85% rename from ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/BaseResult.java rename to ycl-pojo/src/main/java/com/ycl/platform/domain/result/BaseResult.java index 48d2cae..9680e21 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/BaseResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/BaseResult.java @@ -1,4 +1,4 @@ -package com.ycl.platform.domain.result.HK; +package com.ycl.platform.domain.result; import lombok.Data; import org.bson.types.ObjectId; diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/AttrRecognitionMonitorResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/AttrRecognitionMonitorResult.java index 7357db3..e376fad 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/AttrRecognitionMonitorResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/AttrRecognitionMonitorResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 灞炴�ц瘑鍒噯纭洃娴嬬粨鏋� @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class AttrRecognitionMonitorResult { +@Document(collection = "attr_recognition_monitor") +public class AttrRecognitionMonitorResult extends BaseResult { /** * 鍗″彛鍐呯爜鎴栭噰闆嗚澶囧唴鐮侊紝dataType涓�1鏃惰〃绀哄崱鍙e唴鐮侊紝dataType涓�11鏃惰〃绀洪噰闆嗚澶囧唴鐮� diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CarDetectResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CarDetectResult.java index 8b0994a..448e475 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CarDetectResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CarDetectResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎸夊尯鍩熺粺璁¤溅杈嗘暟鎹洃娴嬫寚鏍囬」锛�2.3.0鏂板锛� @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class CarDetectResult { +@Document(collection = "car_detect") +public class CarDetectResult extends BaseResult { /** * 缁勭粐缂栧彿 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CodeByAreaResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CodeByAreaResult.java index 6618159..f87a3e9 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CodeByAreaResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CodeByAreaResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎸夊尯鍩熺粺璁$紪鐮佸紓甯歌澶囨垨鍗″彛 @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class CodeByAreaResult { +@Document(collection = "code_by_area") +public class CodeByAreaResult extends BaseResult { /** * 缁勭粐缂栧彿 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CoordinateByAreaResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CoordinateByAreaResult.java index cf9078a..42dc94b 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CoordinateByAreaResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CoordinateByAreaResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎸夊尯鍩熺粺璁$粡绾害寮傚父璁惧鎴栧崱鍙� @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class CoordinateByAreaResult { +@Document(collection = "coordinate_by_area") +public class CoordinateByAreaResult extends BaseResult { /** * 缁勭粐缂栧彿 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CriteriaResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CriteriaResult.java index c8b9614..81287fd 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CriteriaResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CriteriaResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎸囨爣閰嶇疆淇℃伅鏌ヨ @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class CriteriaResult { +@Document(collection = "criteria") +public class CriteriaResult extends BaseResult { /** * 浜鸿劯璇勫垎浣庢爣鍑嗭紝渚嬪锛�0.4 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CrossDetailResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CrossDetailResult.java index f8867c8..e954bbf 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CrossDetailResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/CrossDetailResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鍗″彛灞炴�х洃娴嬬粨鏋滐紙璋冩暣锛屽彲鏌ュ巻鍙诧級 @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class CrossDetailResult { +@Document(collection = "cross_detail") +public class CrossDetailResult extends BaseResult { /** * 缁勭粐缂栧彿锛岀敤浜庢煡璇㈣缁勭粐鍙婂叾鎵�鏈変笅绾х粍缁囧崱鍙e紓甯告儏鍐点�傝嫢涓嶄紶锛岃繑鍥炴墍鏈夊崱鍙e紓甯歌鎯呫�� diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/DataIntegrityMonitoringResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/DataIntegrityMonitoringResult.java index fbfc517..f48fab5 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/DataIntegrityMonitoringResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/DataIntegrityMonitoringResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋滐紝2.2.0鐗堟湰鏂板 @@ -8,14 +10,15 @@ * @author gonghl */ @Data -public class DataIntegrityMonitoringResult { +@Document(collection = "data_integrity_monitoring") +public class DataIntegrityMonitoringResult extends BaseResult { /** * 鍗″彛鍐呯爜鎴栭噰闆嗚澶囧唴鐮侊紝dataType涓�1鏃惰〃绀哄崱鍙e唴鐮侊紝dataType涓�11鏃惰〃绀洪噰闆嗚澶囧唴鐮� */ private String indexCode; - /** + /** * 璁惧鎴栧崱鍙e浗鏍囩紪鐮� */ private String externalIndexCode; diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDetectResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDetectResult.java index 373c796..5bded9b 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDetectResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDetectResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎸夊尯鍩熺粺璁′汉鑴告暟鎹洃娴嬫寚鏍囬」锛�2.3.0鏂板锛� @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class FaceDetectResult { +@Document(collection = "face_detect") +public class FaceDetectResult extends BaseResult { /** * 缁勭粐缂栧彿 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java index fd2b8e6..6bf7b78 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java @@ -1,5 +1,6 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; import org.springframework.data.mongodb.core.mapping.Document; @@ -10,7 +11,7 @@ */ @Data @Document(collection = "face_device_inspection") -public class FaceDeviceInspectionResult extends BaseResult{ +public class FaceDeviceInspectionResult extends BaseResult { /** * 璁惧鍚嶇О diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceSamplingResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceSamplingResult.java index bf3f498..be04912 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceSamplingResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceSamplingResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉锛�2.3.0鐗堟湰鏂板 @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class FaceDeviceSamplingResult { +@Document(collection = "face_device_sampling") +public class FaceDeviceSamplingResult extends BaseResult { /** * 璁惧鍚嶇О diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitorResourceResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitorResourceResult.java index bfc6c6f..69e5211 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitorResourceResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitorResourceResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; import java.util.List; @@ -9,7 +11,8 @@ * @author gonghl */ @Data -public class MonitorResourceResult { +@Document(collection = "monitor_resource") +public class MonitorResourceResult extends BaseResult { /** * 鍏虫敞璧勬簮鍒楄〃 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitoringDetailResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitoringDetailResult.java index d0b7a5b..11bf95c 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitoringDetailResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/MonitoringDetailResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 閲囬泦璁惧灞炴�х洃娴嬬粨鏋� @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class MonitoringDetailResult { +@Document(collection = "monitoring_detail") +public class MonitoringDetailResult extends BaseResult { /** * 缁勭粐缂栧彿 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/OrganizationTreeResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/OrganizationTreeResult.java index 7a53baf..1530159 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/OrganizationTreeResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/OrganizationTreeResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; import java.util.List; @@ -10,7 +12,8 @@ * @author gonghl */ @Data -public class OrganizationTreeResult { +@Document(collection = "organization_tree") +public class OrganizationTreeResult extends BaseResult { /** * 缁勭粐鍒楄〃 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/PicAccessResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/PicAccessResult.java index 3dbce4c..198895e 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/PicAccessResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/PicAccessResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鍥剧墖璁块棶鐩戞祴缁撴灉 @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class PicAccessResult { +@Document(collection = "pic_access") +public class PicAccessResult extends BaseResult { /** * 鏁版嵁绫诲瀷涓�1鏃惰〃绀哄崱鍙e唴鐮侊紝鏁版嵁绫诲瀷涓�2鎴�11鏃惰〃绀轰汉鑴搁噰闆嗚澶囧唴鐮� diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDataMonitorResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDataMonitorResult.java index 91b6c63..20f8da0 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDataMonitorResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDataMonitorResult.java @@ -1,5 +1,6 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; import org.springframework.data.mongodb.core.mapping.Document; @@ -10,8 +11,11 @@ */ @Data @Document(collection = "snapshot_data_monitor") -public class SnapshotDataMonitorResult extends BaseResult{ - +public class SnapshotDataMonitorResult extends BaseResult { + /** + * 鏁版嵁绫诲瀷 + */ + private Integer dataType; /** * dataType涓�1锛氬崱鍙e唴鐮� dataType涓�2鎴�11锛氶噰闆嗚澶囧唴鐮� */ diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDelayMonitorResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDelayMonitorResult.java index c114e9c..3c826f5 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDelayMonitorResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/SnapshotDelayMonitorResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉 @@ -8,8 +10,9 @@ * @author gonghl */ @Data -public class SnapshotDelayMonitorResult { - +@Document(collection = "snapshop_delay_monitor") +public class SnapshotDelayMonitorResult extends BaseResult { + private Integer dataType; /** * dataType涓�1锛氬崱鍙e唴鐮� dataType涓�2鎴�11锛氶噰闆嗚澶囧唴鐮� */ diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceInspectionResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceInspectionResult.java index fdb3827..0f87d90 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceInspectionResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceInspectionResult.java @@ -1,5 +1,6 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; import org.springframework.data.mongodb.core.mapping.Document; @@ -10,7 +11,7 @@ */ @Data @Document(collection = "vehicle_device_inspection") -public class VehicleDeviceInspectionResult extends BaseResult{ +public class VehicleDeviceInspectionResult extends BaseResult { /** * 璁惧缂栧彿锛宒ataType涓�1鏃惰〃绀哄崱鍙e唴鐮侊紝dataType涓�11鏃惰〃绀洪噰闆嗚澶囧唴鐮� diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceSamplingResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceSamplingResult.java index eaf9529..349f687 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceSamplingResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/VehicleDeviceSamplingResult.java @@ -1,6 +1,8 @@ package com.ycl.platform.domain.result.HK; +import com.ycl.platform.domain.result.BaseResult; import lombok.Data; +import org.springframework.data.mongodb.core.mapping.Document; /** * 杞﹁締璁惧鎶芥鎸囨爣鐩戞祴缁撴灉锛�2.3.0鐗堟湰鏂板 @@ -8,7 +10,8 @@ * @author gonghl */ @Data -public class VehicleDeviceSamplingResult { +@Document(collection = "vehicle_device_sampling") +public class VehicleDeviceSamplingResult extends BaseResult { /** * 鍗″彛鍐呯爜鎴栭噰闆嗚澶囧唴鐮侊紝dataType涓�1鏃惰〃绀哄崱鍙e唴鐮侊紝dataType涓�11鏃惰〃绀洪噰闆嗚澶囧唴鐮� diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OnlineResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OnlineResult.java index 8e6f1b1..c5884ff 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OnlineResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/OnlineResult.java @@ -9,7 +9,7 @@ * @since 2024-4-19 11:37:30 */ @Data -public class OnlineResult { +public class OnlineResult{ /** * 琛屾斂鍖哄垝缂栫爜 diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/QueryVqdResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/QueryVqdResult.java new file mode 100644 index 0000000..d076629 --- /dev/null +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/QueryVqdResult.java @@ -0,0 +1,246 @@ +package com.ycl.platform.domain.result.UY; + +import lombok.Data; + +/** + * 鍥惧儚鐩戞祴璇婃柇缁撴灉 + */ +@Data +public class QueryVqdResult { + /** + * + */ + private String arealayerPath; + /** + * 琛屾斂鍖哄垝缂栫爜 + */ + private String arealayernoCode; + /** + * 琛屾斂鍖哄垝鍚嶇О + */ + private String arealayernoName; + /** + * + */ + private String binaryTenantId; + /** + * 妯$硦 + */ + private Integer blur; + /** + * 妯$硦鍘熷鍒嗗�� + */ + private Integer blurRaw; + /** + * 妯$硦闃堝�� + */ + private Integer blurThreshold; + /** + * 棰滆壊 + */ + private Integer color; + /** + * 棰滆壊鍘熷鍒嗗�� + */ + private Integer colorRaw; + /** + * 棰滆壊闃堝�� + */ + private Integer colorThreshold; + /** + * + */ + private String decodeInfo; + /** + * 璁惧 ID + */ + private String deviceId; + /** + * 璁惧 IP + */ + private String deviceIp; + /** + * 璁惧鍚嶇О + */ + private String deviceName; + /** + * + */ + private String extJson; + /** + * + */ + private String frameLostRate; + /** + * + */ + private String groupId; + /** + * + */ + private String id; + /** + * + */ + private Integer ifmDelay; + /** + * 鍥惧儚鍦板潃 + */ + private String imagePath; + /** + * 鍥惧儚璐ㄩ噺鐘舵�� 1:姝e父 0锛氭湭鐭� -1锛氬紓甯� + */ + private Integer imgStatus; + /** + * + */ + private Boolean inTime; + /** + * 缁村害 + */ + private String latitude; + /** + * 浜害 + */ + private Integer light; + /** + * 浜害鍘熷鍒嗗�� + */ + private Integer lightRaw; + /** + * 浜害闃堝�� + */ + private Integer lightThreshold; + /** + * 缁忓害 + */ + private String longitude; + /** + * 鍦ㄧ嚎鐘舵�� 1:鍦ㄧ嚎 0锛氭湭鐭� -1锛氱绾� + */ + private Integer onlineStatus; + /** + * + */ + private String originalPlatId; + /** + * + */ + private String payloadType; + /** + * + */ + private String pixelInfo; + /** + * 鍥芥爣骞冲彴ID + */ + private String platId; + /** + * 閬尅 + */ + private Integer shade; + /** + * 閬尅鍘熷鍒嗗�� + */ + private Integer shadeRaw; + /** + * 閬尅闃堝�� + */ + private Integer shadeThreshold; + /** + * 鎶栧姩 + */ + private Integer shake; + /** + * 鎶栧姩鍘熷鍒嗗�� + */ + private Integer shakeRaw; + /** + * 鎶栧姩闃堝�� + */ + private Integer shakeThreshold; + /** + * 淇″彿 + */ + private Integer signal; + /** + * 淇″彿鍘熷鍒嗗�� + */ + private Integer signalRaw; + /** + * 淇″彿鐘舵�� 鏃犱俊鍙� 1:鏈変俊鍙� 0锛氭湭鐭� -1锛氭棤淇″彿 + */ + private Integer signalStatus; + /** + * 淇″彿闃堝�� + */ + private Integer signalThreshold; + /** + * + */ + private Integer sipDelay; + /** + * 闆姳 + */ + private Integer snow; + /** + * 闆姳鍘熷鍒嗗�� + */ + private Integer snowRaw; + /** + * 闆姳闃堝�� + */ + private Integer snowThreshold; + /** + * 鏉$汗 + */ + private Integer stripe; + /** + * 鏉$汗鍘熷鍒嗗�� + */ + private Integer stripeRaw; + /** + * 鏉$汗闃堝�� + */ + private Integer stripeThreshold; + /** + * + */ + private String tags; + /** + * + */ + private String taskCreateTime; + /** + * + */ + private String taskRecheckTime; + /** + * + */ + private String tenantId; + /** + * + */ + private Integer videoDelay; + /** + * + */ + private Integer videoDiagStatus; + /** + * + */ + private String videoDiagTime; + /** + * + */ + private Integer videoGetStatus; + /** + * + */ + private String videoGetTime; + /** + * + */ + private Integer vqdAtNight; +} diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/RecordMetaDSumResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/RecordMetaDSumResult.java index 94819a5..86f5770 100644 --- a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/RecordMetaDSumResult.java +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/RecordMetaDSumResult.java @@ -6,10 +6,11 @@ /** * 褰曞儚鍙敤鎬� + * * @author gonghl */ @Data -public class RecordMetaDSumResult { +public class RecordMetaDSumResult{ /** * 琛屾斂鍖哄煙鍚嶇О diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/VideoQualityResult.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/VideoQualityResult.java new file mode 100644 index 0000000..0a16fc4 --- /dev/null +++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/result/UY/VideoQualityResult.java @@ -0,0 +1,66 @@ +package com.ycl.platform.domain.result.UY; + +import lombok.Data; + +/** + * 瑙嗛鍥惧儚璐ㄩ噺 + */ +@Data +public class VideoQualityResult { + /** 琛屾斂鍖哄垝缂栫爜 */ + private String arealayernoCode; + /** 琛屾斂鍖哄垝鍚嶇О */ + private String arealayernoName; + /** 妯$硦 */ + private Integer blur; + /** 妯$硦鍘熷鍒嗗�� */ + private Integer blurRaw; + /** 棰滆壊 */ + private Integer color; + /** 棰滆壊鍘熷鍒嗗�� */ + private Integer colorRaw; + /** 鎽勫儚鏈�-鍥芥爣id */ + private String deviceId; + /** 鎽勫儚鏈篿p */ + private String deviceIp; + /** 鎽勫儚鏈鸿澶囧悕绉� */ + private String deviceName; + /** 缁熻绾害 */ + private String dim; + /** 鍥惧儚鏄惁姝e父 -1锛氬紓甯革紝1姝e父锛�0锛氭湭璇婃柇*/ + private Integer isImgAbnormal; + /** 淇″彿鏄惁涓㈠け -1锛氬紓甯革紝1姝e父锛�0锛氭湭璇婃柇*/ + private Integer isSignalMiss; + /** 浜害 */ + private Integer light; + /** 浜害鍘熷鍒嗗�� */ + private Integer lightRaw; + /** 閬尅 */ + private Integer shade; + /** 閬尅鍘熷鍒嗗�� */ + private Integer shadeRaw; + /** 鎶栧姩 */ + private Integer shake; + /** 鎶栧姩鍘熷鍒嗗�� */ + private Integer shakeRaw; + /** 鏃犱俊鍙� */ + private Integer signal; + /** 鏃犱俊鍙峰師濮嬪垎鍊� */ + private Integer signalRaw; + /** 闆姳 */ + private Integer snow; + /** 闆姳鍘熷鍒嗗�� */ + private Integer snowRaw; + /** 鎺掑簭灞炴�� */ + private String sortFiled; + /** 璇婃柇鐘舵�佺紪鐮� -1锛氬紓甯革紝1锛氭甯革紝0锛氭湭璇婃柇 */ + private String status; + /** 璇婃柇鐘舵�佸悕绉� */ + private String statusName; + /** 鏉$汗 */ + private Integer stripe; + /** 鏉$汗鍘熷鍒嗗�� */ + private Integer stripeRaw; + /** 璇婃柇鏃堕棿 */ + private String vqdTime; +} diff --git a/ycl-server/src/main/java/com/ycl/calculate/CalculationStrategy.java b/ycl-server/src/main/java/com/ycl/calculate/CalculationStrategy.java new file mode 100644 index 0000000..3595ad4 --- /dev/null +++ b/ycl-server/src/main/java/com/ycl/calculate/CalculationStrategy.java @@ -0,0 +1,7 @@ +package com.ycl.calculate; + +import java.util.List; + +public interface CalculationStrategy<T> { + void calculate(List<T> list); +} diff --git a/ycl-server/src/main/java/com/ycl/calculate/CarSiteOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/CarSiteOnlineCalculation.java new file mode 100644 index 0000000..9cf047a --- /dev/null +++ b/ycl-server/src/main/java/com/ycl/calculate/CarSiteOnlineCalculation.java @@ -0,0 +1,146 @@ +package com.ycl.calculate; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ycl.platform.domain.entity.CheckIndexCar; +import com.ycl.platform.domain.entity.TMonitor; +import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; +import com.ycl.platform.mapper.CheckIndexCarMapper; +import com.ycl.platform.service.ICheckIndexCarService; +import com.ycl.platform.service.ITMonitorService; +import com.ycl.system.mapper.SysConfigMapper; +import constant.ApiConstants; +import constant.CheckConstants; +import constant.CheckSnapCountConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import utils.DateUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 璁$畻杞﹁締銆佷汉鑴哥偣浣嶅湪绾跨巼銆佽鍥惧簱瀵规帴绋冲畾鎬� + * 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId + * 寰幆map璁$畻鐐逛綅鍦ㄧ嚎鐜� + * 鏇存柊鎴栨柊澧� + */ +@Component +public class CarSiteOnlineCalculation implements CalculationStrategy<SnapshotDataMonitorResult> { + @Autowired + private CheckIndexCarMapper checkIndexCarMapper; + @Autowired + private SysConfigMapper sysConfigMapper; + @Autowired + private ITMonitorService monitorService; + @Autowired + private ICheckIndexCarService checkIndexCarService; + + //鍖哄煙杞﹁締鐐逛綅鍦ㄧ嚎鎸囨爣鐨勫唴閮ㄧ被 + private static class AreaStats { + int totalSites = 0; + int offlineSites = 0; + int totalDataSum = 0; + } + + @Override + public void calculate(List<SnapshotDataMonitorResult> list) { + if (CollectionUtils.isEmpty(list)) { + return; + } + Map<String, AreaStats> areaStatsMap = new HashMap<>(); + Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() + .in("serial_number", list.stream().map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList()))) + .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); + + // TODO: 鍒嗙渷鍘呭競灞� 闇�瑕佽ˉ鍏呴泦鍚堟暟鎹� + List<String> provinceIds = new ArrayList<>(); // 杩欓噷闇�瑕佹牴鎹偣浣嶈ˉ鍏� + + for (SnapshotDataMonitorResult result : list) { + TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); + if (monitor == null) continue; + + String deptId = monitor.getDeptId().toString(); + updateAreaStats(areaStatsMap, deptId, result); + + // 澶勭悊鐪佸巺鏁版嵁 + if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { + String provinceKey = "Province_" + deptId; + updateAreaStats(areaStatsMap, provinceKey, result); + } + } + + //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� 鐪佸巺銆佸競灞� + BigDecimal cityCountAvg = getAverageCount(CheckSnapCountConstants.City); + BigDecimal countyCountAvg = getAverageCount(CheckSnapCountConstants.County); + + // 鏌ヨ浠婃棩鏁版嵁 + List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate()); + List<CheckIndexCar> checkIndexCars = new ArrayList<>(); + areaStatsMap.forEach((deptId, stats) -> { + if (stats.totalSites > 0) { + CheckIndexCar checkIndexCar = createOrUpdateCheckIndexCar(deptId, stats, cityCountAvg, countyCountAvg, checkIndexCarList); + checkIndexCars.add(checkIndexCar); + } + }); + + checkIndexCarService.saveOrUpdateBatch(checkIndexCars); + } + + //绱鎬荤偣浣嶆暟銆佺绾挎暟銆佹�绘姄鎷嶉噺 + private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, SnapshotDataMonitorResult result) { + //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value + AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); + stats.totalSites++; + if (ApiConstants.HK_SnapCount_ResultType_Null == result.getResultType()) { + stats.offlineSites++; + } else { + stats.totalDataSum += result.getDataCount(); + } + } + + //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� + private BigDecimal getAverageCount(String configKey) { + String count = sysConfigMapper.checkConfigKeyUnique(configKey).getConfigValue(); + return new BigDecimal(count).multiply(new BigDecimal(CheckSnapCountConstants.Multiply)) + .divide(new BigDecimal(CheckSnapCountConstants.CountyNum), 0, RoundingMode.HALF_UP); + } + + //杞﹁締鐐逛綅鍦ㄧ嚎鐜囧拰瑙嗗浘搴撳鎺ョǔ瀹氭�� + private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, BigDecimal cityCountAvg, BigDecimal countyCountAvg, List<CheckIndexCar> checkIndexCarList) { + CheckIndexCar checkIndexCar; + + // 妫�鏌ユ槸鍚﹀凡瀛樺湪浠婃棩鏁版嵁 + Optional<CheckIndexCar> existingCar = checkIndexCarList.stream() + .filter(car -> key.equals(car.getDeptId().toString()) && + (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(car.getExamineTag()) + : CheckConstants.Examine_Tag_County.equals(car.getExamineTag()))) + .findFirst(); + + if (existingCar.isPresent()) { + checkIndexCar = existingCar.get(); + } else { + checkIndexCar = new CheckIndexCar(); + checkIndexCar.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); + checkIndexCar.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); + checkIndexCar.setCreateTime(new Date()); + } + //璋冪敤鐐逛綅鍦ㄧ嚎璁$畻鏂规硶 + Map<String, Object> siteOnlineParam = new HashMap<>(); + siteOnlineParam.put("totalSites", stats.totalSites); + siteOnlineParam.put("offlineSites", stats.offlineSites); + BigDecimal siteOnline = IndexCalculationUtils.siteOnline(siteOnlineParam); + checkIndexCar.setSiteOnline(siteOnline); + //瑙嗗浘搴撳鎺ョǔ瀹氭�� + BigDecimal avgCount = key.startsWith("Province_") ? cityCountAvg : countyCountAvg; + Map<String, Object> viewConnectParam = new HashMap<>(); + viewConnectParam.put("totalDataSum", stats.totalDataSum); + viewConnectParam.put("avgCount", avgCount); + BigDecimal viewConnectStability = IndexCalculationUtils.viewConnectStability(viewConnectParam); + checkIndexCar.setViewConnectStability(viewConnectStability); + return checkIndexCar; + } +} diff --git a/ycl-server/src/main/java/com/ycl/calculate/FaceSiteOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/FaceSiteOnlineCalculation.java new file mode 100644 index 0000000..4d625dd --- /dev/null +++ b/ycl-server/src/main/java/com/ycl/calculate/FaceSiteOnlineCalculation.java @@ -0,0 +1,149 @@ +package com.ycl.calculate; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ycl.platform.domain.entity.CheckIndexCar; +import com.ycl.platform.domain.entity.CheckIndexFace; +import com.ycl.platform.domain.entity.TMonitor; +import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; +import com.ycl.platform.mapper.CheckIndexCarMapper; +import com.ycl.platform.mapper.CheckIndexFaceMapper; +import com.ycl.platform.service.ICheckIndexCarService; +import com.ycl.platform.service.ICheckIndexFaceService; +import com.ycl.platform.service.ITMonitorService; +import com.ycl.platform.service.impl.CheckIndexFaceServiceImpl; +import com.ycl.system.mapper.SysConfigMapper; +import com.ycl.system.mapper.SysDeptMapper; +import constant.ApiConstants; +import constant.CheckConstants; +import constant.CheckSnapCountConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import utils.DateUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 璁$畻浜鸿劯鐐逛綅鍦ㄧ嚎鐜囥�佽鍥惧簱瀵规帴绋冲畾鎬� + * 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId + * 寰幆map璁$畻鐐逛綅鍦ㄧ嚎鐜� + * 鏇存柊鎴栨柊澧� + */ +@Component +public class FaceSiteOnlineCalculation implements CalculationStrategy<SnapshotDataMonitorResult> { + @Autowired + private CheckIndexFaceMapper checkIndexFaceMapper; + @Autowired + private ICheckIndexFaceService checkIndexFaceService; + @Autowired + private SysConfigMapper sysConfigMapper; + @Autowired + private ITMonitorService monitorService; + + //鍖哄煙浜鸿劯鐐逛綅鍦ㄧ嚎鎸囨爣鐨勫唴閮ㄧ被 + private static class AreaStats { + int totalSites = 0; + int offlineSites = 0; + int totalDataSum = 0; + } + + @Override + public void calculate(List<SnapshotDataMonitorResult> list) { + if (CollectionUtils.isEmpty(list)) { + return; + } + + Map<String, AreaStats> areaStatsMap = new HashMap<>(); + Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() + .in("serial_number", list.stream().map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList()))) + .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); + + // TODO: 鍒嗙渷鍘呭競灞� 闇�瑕佽ˉ鍏呴泦鍚堟暟鎹� + List<String> provinceIds = new ArrayList<>(); // 杩欓噷闇�瑕佹牴鎹偣浣嶈ˉ鍏� + + for (SnapshotDataMonitorResult result : list) { + TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); + if (monitor == null) continue; + + String deptId = monitor.getDeptId().toString(); + updateAreaStats(areaStatsMap, deptId, result); + + // 澶勭悊鐪佸巺鏁版嵁 + if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { + String provinceKey = "Province_" + deptId; + updateAreaStats(areaStatsMap, provinceKey, result); + } + } + + //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� 鐪佸巺銆佸競灞� + BigDecimal cityCountAvg = getAverageCount(CheckSnapCountConstants.City); + BigDecimal countyCountAvg = getAverageCount(CheckSnapCountConstants.County); + + // 鏌ヨ浠婃棩鏁版嵁 + List<CheckIndexFace> checkIndexFaceList = checkIndexFaceMapper.selectToday(DateUtils.getDate()); + List<CheckIndexFace> checkIndexFaces = new ArrayList<>(); + areaStatsMap.forEach((deptId, stats) -> { + if (stats.totalSites > 0) { + CheckIndexFace checkIndexFace = createOrUpdateCheckIndexFace(deptId, stats, cityCountAvg, countyCountAvg, checkIndexFaceList); + checkIndexFaces.add(checkIndexFace); + } + }); + + checkIndexFaceService.saveOrUpdateBatch(checkIndexFaces); + } + + //绱鎬荤偣浣嶆暟銆佺绾挎暟銆佹�绘姄鎷嶉噺 + private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, SnapshotDataMonitorResult result) { + //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value + AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); + stats.totalSites++; + if (ApiConstants.HK_SnapCount_ResultType_Null == result.getResultType()) { + stats.offlineSites++; + } else { + stats.totalDataSum += result.getDataCount(); + } + } + + //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� + private BigDecimal getAverageCount(String configKey) { + String count = sysConfigMapper.checkConfigKeyUnique(configKey).getConfigValue(); + return new BigDecimal(count).multiply(new BigDecimal(CheckSnapCountConstants.Multiply)) + .divide(new BigDecimal(CheckSnapCountConstants.CountyNum), 0, RoundingMode.HALF_UP); + } + + //杞﹁締鐐逛綅鍦ㄧ嚎鐜囧拰瑙嗗浘搴撳鎺ョǔ瀹氭�� + private CheckIndexFace createOrUpdateCheckIndexFace(String key, AreaStats stats, BigDecimal cityCountAvg, BigDecimal countyCountAvg, List<CheckIndexFace> checkIndexFaceList) { + CheckIndexFace checkIndexFace; + + // 妫�鏌ユ槸鍚﹀凡瀛樺湪浠婃棩鏁版嵁 + Optional<CheckIndexFace> existingFace = checkIndexFaceList.stream() + .filter(face -> key.equals(face.getDeptId().toString()) && + (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(face.getExamineTag()) + : CheckConstants.Examine_Tag_County.equals(face.getExamineTag()))) + .findFirst(); + + if (existingFace.isPresent()) { + checkIndexFace = existingFace.get(); + } else { + checkIndexFace = new CheckIndexFace(); + checkIndexFace.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); + checkIndexFace.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); + checkIndexFace.setCreateTime(new Date()); + } + + // 鐐逛綅鍦ㄧ嚎鐜� + BigDecimal totalSitesBd = new BigDecimal(stats.totalSites); + BigDecimal offlineSitesBd = new BigDecimal(stats.offlineSites); + BigDecimal onlineSitesBd = totalSitesBd.subtract(offlineSitesBd); + checkIndexFace.setSiteOnline(onlineSitesBd.divide(totalSitesBd, 4, RoundingMode.HALF_UP)); + //瑙嗗浘搴撳鎺ョǔ瀹氭�� + BigDecimal avgCount = key.startsWith("Province_") ? cityCountAvg : countyCountAvg; + checkIndexFace.setViewConnectStability(new BigDecimal(stats.totalDataSum).divide(avgCount, 4, RoundingMode.HALF_UP)); + + return checkIndexFace; + } +} diff --git a/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationUtils.java b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationUtils.java new file mode 100644 index 0000000..919e9c1 --- /dev/null +++ b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationUtils.java @@ -0,0 +1,30 @@ +package com.ycl.calculate; + + +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Map; + +/** + * 璁$畻鍏紡 + */ +public class IndexCalculationUtils { + + //鐐逛綅鍦ㄧ嚎鐜� + public static BigDecimal siteOnline(Map<String, Object> param) { + BigDecimal totalSitesBd = new BigDecimal((Integer) param.get("totalSites")); + BigDecimal offlineSitesBd = new BigDecimal((Integer) param.get("offlineSites")); + BigDecimal onlineSitesBd = totalSitesBd.subtract(offlineSitesBd); + return onlineSitesBd.divide(totalSitesBd, 4, RoundingMode.HALF_UP); + } + + //瑙嗗浘搴撳鎺ョǔ瀹氭�� + public static BigDecimal viewConnectStability(Map<String, Object> param){ + BigDecimal totalDataSum = new BigDecimal((Integer) param.get("totalDataSum")); + BigDecimal avgCount = new BigDecimal((Integer) param.get("avgCount")); + return totalDataSum.divide(avgCount, 4, RoundingMode.HALF_UP); + } + +} diff --git a/ycl-server/src/main/java/com/ycl/factory/IndexCalculationFactory.java b/ycl-server/src/main/java/com/ycl/factory/IndexCalculationFactory.java new file mode 100644 index 0000000..1b638dc --- /dev/null +++ b/ycl-server/src/main/java/com/ycl/factory/IndexCalculationFactory.java @@ -0,0 +1,19 @@ +package com.ycl.factory; + +import com.ycl.calculate.CalculationStrategy; +import com.ycl.calculate.CarSiteOnlineCalculation; + +import java.util.HashMap; +import java.util.Map; + +public class IndexCalculationFactory { + private static final Map<String, CalculationStrategy> calculators = new HashMap<>(); + + static { + calculators.put("siteOnline", new CarSiteOnlineCalculation()); + } + + public static CalculationStrategy getCalculator(String indexName) { + return calculators.get(indexName); + } +} diff --git a/ycl-server/src/main/java/com/ycl/feign/UYClient.java b/ycl-server/src/main/java/com/ycl/feign/UYClient.java index 5cb01dc..5286b2a 100644 --- a/ycl-server/src/main/java/com/ycl/feign/UYClient.java +++ b/ycl-server/src/main/java/com/ycl/feign/UYClient.java @@ -1,10 +1,9 @@ package com.ycl.feign; import com.alibaba.fastjson2.JSONObject; -import com.ycl.platform.domain.param.UY.CameraParam; -import com.ycl.platform.domain.param.UY.OnlineParam; -import com.ycl.platform.domain.param.UY.RecordMetaDSumParam; +import com.ycl.platform.domain.param.UY.*; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -27,7 +26,7 @@ * @return 鏌ヨ鎽勫儚鏈烘竻鍗曢泦鍚� */ @GetMapping("/VIID/Cameras") - JSONObject cameraList(@RequestParam CameraParam cameraParam); + JSONObject cameraList(@SpringQueryMap CameraParam cameraParam); /** * 鐐逛綅鍦ㄧ嚎 @@ -36,7 +35,7 @@ * @return 鏌ヨ鍦ㄧ嚎缁熻鍒楄〃 */ @GetMapping("/openapi/v1/report/online/list") - JSONObject onlineList(@RequestParam OnlineParam onlineParam); + JSONObject onlineList(@SpringQueryMap OnlineParam onlineParam); /** * 褰曞儚鍙敤 @@ -50,4 +49,21 @@ @GetMapping("/api/v1/app/osdMonitor/list") JSONObject osdMonitorList(); + /** + * 鍥惧儚妫�娴嬭瘖鏂粨鏋� + * + * @param param + * @return + */ + @GetMapping("/openapi/v1/vqdMonitor/queryVqdResult") + JSONObject queryVqdResult(@SpringQueryMap QueryVqdParam param); + + /** + * 瑙嗛鍥惧儚璐ㄩ噺 + * + * @param param + * @return + */ + @GetMapping("/api/v1/app/report/vqd/detail/list") + JSONObject queryVqdResult(@SpringQueryMap VideoQualityParam param); } diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java b/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java index f6049ca..7c23eea 100644 --- a/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java +++ b/ycl-server/src/main/java/com/ycl/platform/controller/CalculateReportController.java @@ -1,22 +1,15 @@ package com.ycl.platform.controller; import com.ycl.platform.domain.form.CalculateReportBackfillForm; -import com.ycl.platform.domain.param.HK.CoordinateByAreaParam; -import com.ycl.system.domain.group.Update; -import com.ycl.system.domain.group.Add; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import lombok.RequiredArgsConstructor; -import java.util.List; -import org.springframework.validation.annotation.Validated; -import jakarta.validation.constraints.NotEmpty; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import com.ycl.platform.domain.query.CalculateReportQuery; import com.ycl.platform.service.CalculateReportService; import com.ycl.system.Result; -import com.ycl.platform.domain.form.CalculateReportForm; -import com.ycl.platform.domain.query.CalculateReportQuery; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** @@ -62,4 +55,11 @@ return calculateReportService.updatePublishStatus(reportId); } + @PostMapping("/export") + @ApiOperation(value = "瀵煎嚭", notes = "瀵煎嚭") + @PreAuthorize("@ss.hasPermi('system:calculate:report:export')") + public void export(Integer contractId, HttpServletResponse response) { + calculateReportService.export(contractId, response); + } + } diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/VehicleDataMonitorController.java b/ycl-server/src/main/java/com/ycl/platform/controller/VehicleDataMonitorController.java index c52fd50..744c8ae 100644 --- a/ycl-server/src/main/java/com/ycl/platform/controller/VehicleDataMonitorController.java +++ b/ycl-server/src/main/java/com/ycl/platform/controller/VehicleDataMonitorController.java @@ -30,7 +30,7 @@ /** * 鏌ヨ鍗″彛杩囪溅鏁版嵁涓�鑷存�у垪琛� */ - @PreAuthorize("@ss.hasPermi('platform:platform:list')") + @PreAuthorize("@ss.hasPermi('platform:platform:list')") @GetMapping("/list") public TableDataInfo list(VehicleDataMonitor vehicleDataMonitor) { startPage(); @@ -53,7 +53,7 @@ /** * 鑾峰彇鍗″彛杩囪溅鏁版嵁涓�鑷存�ц缁嗕俊鎭� */ - @PreAuthorize("@ss.hasPermi('platform:platform:query')") + @PreAuthorize("@ss.hasPermi('platform:platform:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Integer id) { return success(vehicleDataMonitorService.selectVehicleDataMonitorById(id)); @@ -62,7 +62,7 @@ /** * 鏂板鍗″彛杩囪溅鏁版嵁涓�鑷存�� */ - @PreAuthorize("@ss.hasPermi('platform:platform:add')") + @PreAuthorize("@ss.hasPermi('platform:platform:add')") @Log(title = "鍗″彛杩囪溅鏁版嵁涓�鑷存��", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody VehicleDataMonitor vehicleDataMonitor) { @@ -72,7 +72,7 @@ /** * 淇敼鍗″彛杩囪溅鏁版嵁涓�鑷存�� */ - @PreAuthorize("@ss.hasPermi('platform:platform:edit')") + @PreAuthorize("@ss.hasPermi('platform:platform:edit')") @Log(title = "鍗″彛杩囪溅鏁版嵁涓�鑷存��", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody VehicleDataMonitor vehicleDataMonitor) { @@ -82,7 +82,7 @@ /** * 鍒犻櫎鍗″彛杩囪溅鏁版嵁涓�鑷存�� */ - @PreAuthorize("@ss.hasPermi('platform:platform:remove')") + @PreAuthorize("@ss.hasPermi('platform:platform:remove')") @Log(title = "鍗″彛杩囪溅鏁版嵁涓�鑷存��", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Integer[] ids) { diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java index b8d17a4..8b5e223 100644 --- a/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java +++ b/ycl-server/src/main/java/com/ycl/platform/mapper/CalculateReportMapper.java @@ -1,16 +1,16 @@ package com.ycl.platform.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.platform.domain.entity.CalculateReport; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ycl.platform.domain.excel.CalculateExport; import com.ycl.platform.domain.query.CalculateReportQuery; -import com.ycl.platform.domain.vo.CalculateRecordVO; import com.ycl.platform.domain.vo.CalculateReportDetailVO; import com.ycl.platform.domain.vo.CalculateReportVO; -import com.ycl.platform.domain.form.CalculateReportForm; -import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 鏍哥畻鎶ュ憡 Mapper 鎺ュ彛 @@ -37,4 +37,10 @@ * @return */ CalculateReportDetailVO getById(@Param("id") Long id); + + /** + * 瀵煎嚭鏁版嵁 + * @return 鏁版嵁 + */ + List<CalculateExport> exportData(Integer contractId); } diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/CheckIndexFaceMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/CheckIndexFaceMapper.java index 6fb00bf..2e12b8c 100644 --- a/ycl-server/src/main/java/com/ycl/platform/mapper/CheckIndexFaceMapper.java +++ b/ycl-server/src/main/java/com/ycl/platform/mapper/CheckIndexFaceMapper.java @@ -1,20 +1,21 @@ package com.ycl.platform.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.platform.domain.entity.CheckIndexFace; import java.util.List; /** * 浜鸿劯鎸囨爣姒傜巼鏁版嵁Mapper鎺ュ彛 - * + * * @author ruoyi * @date 2024-04-29 */ -public interface CheckIndexFaceMapper +public interface CheckIndexFaceMapper extends BaseMapper<CheckIndexFace> { /** * 鏌ヨ浜鸿劯鎸囨爣姒傜巼鏁版嵁 - * + * * @param id 浜鸿劯鎸囨爣姒傜巼鏁版嵁涓婚敭 * @return 浜鸿劯鎸囨爣姒傜巼鏁版嵁 */ @@ -22,7 +23,7 @@ /** * 鏌ヨ浜鸿劯鎸囨爣姒傜巼鏁版嵁鍒楄〃 - * + * * @param checkIndexFace 浜鸿劯鎸囨爣姒傜巼鏁版嵁 * @return 浜鸿劯鎸囨爣姒傜巼鏁版嵁闆嗗悎 */ @@ -30,7 +31,7 @@ /** * 鏂板浜鸿劯鎸囨爣姒傜巼鏁版嵁 - * + * * @param checkIndexFace 浜鸿劯鎸囨爣姒傜巼鏁版嵁 * @return 缁撴灉 */ @@ -38,7 +39,7 @@ /** * 淇敼浜鸿劯鎸囨爣姒傜巼鏁版嵁 - * + * * @param checkIndexFace 浜鸿劯鎸囨爣姒傜巼鏁版嵁 * @return 缁撴灉 */ @@ -46,7 +47,7 @@ /** * 鍒犻櫎浜鸿劯鎸囨爣姒傜巼鏁版嵁 - * + * * @param id 浜鸿劯鎸囨爣姒傜巼鏁版嵁涓婚敭 * @return 缁撴灉 */ @@ -54,9 +55,12 @@ /** * 鎵归噺鍒犻櫎浜鸿劯鎸囨爣姒傜巼鏁版嵁 - * + * * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎 * @return 缁撴灉 */ public int deleteCheckIndexFaceByIds(Long[] ids); + + List<CheckIndexFace> selectToday(String date); + } diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java index 526a05d..aaf2b40 100644 --- a/ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java +++ b/ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java @@ -73,4 +73,5 @@ void saveBatch(List<CheckScore> scoreList); + List<CheckScore> selectCheckScoreMap(CheckScore checkScore); } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java b/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java index 2281a39..96d9dd8 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/CalculateReportService.java @@ -6,6 +6,8 @@ import com.ycl.system.Result; import com.ycl.platform.domain.form.CalculateReportForm; import com.ycl.platform.domain.query.CalculateReportQuery; +import jakarta.servlet.http.HttpServletResponse; + import java.util.List; /** @@ -79,4 +81,10 @@ * @return */ Result updatePublishStatus(Long reportId); + + /** + * 瀵煎嚭 + * @param response 鍝嶅簲 + */ + void export(Integer contractId, HttpServletResponse response); } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexCarService.java b/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexCarService.java index f5cb235..24ecc0c 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexCarService.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexCarService.java @@ -62,9 +62,4 @@ */ public int deleteCheckIndexCarById(Long id); - /** - * 璁$畻杞﹁締鐐逛綅鍦ㄧ嚎鐜� - * @param list - */ - void siteOnline(List<SnapshotDataMonitorResult> list); } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexFaceService.java b/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexFaceService.java index 860f25c..8b0eb91 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexFaceService.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/ICheckIndexFaceService.java @@ -1,5 +1,7 @@ package com.ycl.platform.service; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ycl.platform.domain.entity.CheckIndexCar; import com.ycl.platform.domain.entity.CheckIndexFace; import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; @@ -11,7 +13,7 @@ * @author ruoyi * @date 2024-04-29 */ -public interface ICheckIndexFaceService +public interface ICheckIndexFaceService extends IService<CheckIndexFace> { /** * 鏌ヨ浜鸿劯鎸囨爣姒傜巼鏁版嵁 @@ -60,11 +62,5 @@ * @return 缁撴灉 */ public int deleteCheckIndexFaceById(Long id); - - /** - * 璁$畻浜鸿劯鐐逛綅鍦ㄧ嚎鐜� - * @param list - */ - void siteOnline(List<SnapshotDataMonitorResult> list); } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java index 8943806..e603c06 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java @@ -1,40 +1,37 @@ package com.ycl.platform.service.impl; -import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.platform.domain.entity.CalculateRecord; import com.ycl.platform.domain.entity.CalculateReport; +import com.ycl.platform.domain.excel.CalculateExport; import com.ycl.platform.domain.form.CalculateReportBackfillForm; -import com.ycl.platform.domain.vo.CalculateRecordVO; +import com.ycl.platform.domain.form.CalculateReportForm; +import com.ycl.platform.domain.query.CalculateReportQuery; import com.ycl.platform.domain.vo.CalculateReportDetailVO; +import com.ycl.platform.domain.vo.CalculateReportVO; import com.ycl.platform.mapper.CalculateRecordMapper; import com.ycl.platform.mapper.CalculateReportMapper; import com.ycl.platform.service.CalculateReportService; import com.ycl.system.Result; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.platform.domain.form.CalculateReportForm; -import com.ycl.platform.domain.vo.CalculateReportVO; -import com.ycl.platform.domain.query.CalculateReportQuery; - -import java.math.BigDecimal; -import java.util.List; - -import com.ycl.utils.SecurityUtils; -import enumeration.general.CalculateReportStatusEnum; -import org.apache.commons.lang3.StringUtils; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.system.page.PageUtil; -import org.springframework.stereotype.Service; -import org.springframework.security.core.context.SecurityContextHolder; +import enumeration.general.CalculateReportStatusEnum; +import jakarta.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; -import java.util.ArrayList; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; -import lombok.RequiredArgsConstructor; -import org.springframework.util.CollectionUtils; /** * 鏍哥畻鎶ュ憡 鏈嶅姟瀹炵幇绫� @@ -198,4 +195,24 @@ baseMapper.updateById(report); return Result.ok("鎿嶄綔鎴愬姛"); } + + @Override + @SneakyThrows + public void export(Integer contractId, HttpServletResponse response) { + // 鑾峰彇鏁版嵁 + List<CalculateExport> list = baseMapper.exportData(contractId); + CalculateExport calculateExport = new CalculateExport(); + calculateExport.setRuleName("鍚堣"); + calculateExport.setNum(list.stream().mapToInt(CalculateExport::getNum).sum()); + calculateExport.setScore(list.stream().mapToInt(CalculateExport::getScore).sum()); + list.add(calculateExport); + // 杈撳嚭鏂囦欢 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + String fileName = URLEncoder.encode("鏍哥畻鎶ュ憡", StandardCharsets.UTF_8).replace("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), CalculateExport.class) + .sheet("鏍哥畻鎶ュ憡") + .doWrite(list); + } } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexCarServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexCarServiceImpl.java index bbc61e8..45313ed 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexCarServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexCarServiceImpl.java @@ -1,34 +1,19 @@ package com.ycl.platform.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.platform.domain.entity.CalculateReport; +import com.ycl.calculate.IndexCalculationUtils; import com.ycl.platform.domain.entity.CheckIndexCar; -import com.ycl.platform.domain.entity.TMonitor; -import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; -import com.ycl.platform.mapper.CalculateReportMapper; import com.ycl.platform.mapper.CheckIndexCarMapper; import com.ycl.platform.service.ICheckIndexCarService; import com.ycl.platform.service.ITMonitorService; -import com.ycl.system.domain.SysConfig; -import com.ycl.system.entity.SysDept; import com.ycl.system.mapper.SysConfigMapper; import com.ycl.system.mapper.SysDeptMapper; -import constant.ApiConstants; -import constant.CheckConstants; -import constant.CheckSnapCountConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import utils.DateUtils; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.SimpleDateFormat; import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; /** * 杞﹁締鎸囨爣姒傜巼鏁版嵁Service涓氬姟灞傚鐞� @@ -47,7 +32,6 @@ private ITMonitorService monitorService; @Autowired private SysDeptMapper deptMapper; - /** * 鏌ヨ杞﹁締鎸囨爣姒傜巼鏁版嵁 * @@ -114,116 +98,4 @@ public int deleteCheckIndexCarById(Long id) { return checkIndexCarMapper.deleteCheckIndexCarById(id); } - - /** - * 璁$畻杞﹁締鐐逛綅鍦ㄧ嚎鐜囥�佽鍥惧簱瀵规帴绋冲畾鎬� - * 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId - * 寰幆map璁$畻鐐逛綅鍦ㄧ嚎鐜� - * 鏇存柊鎴栨柊澧� - * - * @param list - */ - //TODO锛氫换鍔¢『搴忛渶瑕佹帓鍦ㄤ竴鏈轰竴妗d箣鍚� - @Override - public void siteOnline(List<SnapshotDataMonitorResult> list) { - if (CollectionUtils.isEmpty(list)) { - return; - } - - Map<String, AreaStats> areaStatsMap = new HashMap<>(); - Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() - .in("serial_number", list.stream().map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList()))) - .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); - - // TODO: 鍒嗙渷鍘呭競灞� 闇�瑕佽ˉ鍏呴泦鍚堟暟鎹� - List<String> provinceIds = new ArrayList<>(); // 杩欓噷闇�瑕佹牴鎹偣浣嶈ˉ鍏� - - for (SnapshotDataMonitorResult result : list) { - TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); - if (monitor == null) continue; - - String deptId = monitor.getDeptId().toString(); - updateAreaStats(areaStatsMap, deptId, result); - - // 澶勭悊鐪佸巺鏁版嵁 - if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { - String provinceKey = "Province_" + deptId; - updateAreaStats(areaStatsMap, provinceKey, result); - } - } - - //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� 鐪佸巺銆佸競灞� - BigDecimal cityCountAvg = getAverageCount(CheckSnapCountConstants.City); - BigDecimal countyCountAvg = getAverageCount(CheckSnapCountConstants.County); - - // 鏌ヨ浠婃棩鏁版嵁 - List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate()); - List<CheckIndexCar> checkIndexCars = new ArrayList<>(); - areaStatsMap.forEach((deptId, stats) -> { - if (stats.totalSites > 0) { - CheckIndexCar checkIndexCar = createOrUpdateCheckIndexCar(deptId, stats, cityCountAvg, countyCountAvg, checkIndexCarList); - checkIndexCars.add(checkIndexCar); - } - }); - - saveOrUpdateBatch(checkIndexCars); - } - - //绱鎬荤偣浣嶆暟銆佺绾挎暟銆佹�绘姄鎷嶉噺 - private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, SnapshotDataMonitorResult result) { - //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value - AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); - stats.totalSites++; - if (ApiConstants.HK_SnapCount_ResultType_Null == result.getResultType()) { - stats.offlineSites++; - } else { - stats.totalDataSum += result.getDataCount(); - } - } - - //鑾峰彇2022鍚屾湡鎶撴媿骞冲潎鍊� - private BigDecimal getAverageCount(String configKey) { - String count = sysConfigMapper.checkConfigKeyUnique(configKey).getConfigValue(); - return new BigDecimal(count).multiply(new BigDecimal(CheckSnapCountConstants.Multiply)) - .divide(new BigDecimal(CheckSnapCountConstants.CountyNum), 0, RoundingMode.HALF_UP); - } - //杞﹁締鐐逛綅鍦ㄧ嚎鐜囧拰瑙嗗浘搴撳鎺ョǔ瀹氭�� - private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, BigDecimal cityCountAvg, BigDecimal countyCountAvg, List<CheckIndexCar> checkIndexCarList) { - CheckIndexCar checkIndexCar; - - // 妫�鏌ユ槸鍚﹀凡瀛樺湪浠婃棩鏁版嵁 - Optional<CheckIndexCar> existingCar = checkIndexCarList.stream() - .filter(car -> key.equals(car.getDeptId().toString()) && - (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(car.getExamineTag()) - : CheckConstants.Examine_Tag_County.equals(car.getExamineTag()))) - .findFirst(); - - if (existingCar.isPresent()) { - checkIndexCar = existingCar.get(); - } else { - checkIndexCar = new CheckIndexCar(); - checkIndexCar.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); - checkIndexCar.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); - checkIndexCar.setCreateTime(new Date()); - } - - // 鐐逛綅鍦ㄧ嚎鐜� - BigDecimal totalSitesBd = new BigDecimal(stats.totalSites); - BigDecimal offlineSitesBd = new BigDecimal(stats.offlineSites); - BigDecimal onlineSitesBd = totalSitesBd.subtract(offlineSitesBd); - checkIndexCar.setSiteOnline(onlineSitesBd.divide(totalSitesBd, 4, RoundingMode.HALF_UP)); - //瑙嗗浘搴撳鎺ョǔ瀹氭�� - BigDecimal avgCount = key.startsWith("Province_") ? cityCountAvg : countyCountAvg; - checkIndexCar.setViewConnectStability(new BigDecimal(stats.totalDataSum).divide(avgCount, 4, RoundingMode.HALF_UP)); - - return checkIndexCar; - } - - //鍖哄煙杞﹁締鐐逛綅鍦ㄧ嚎鎸囨爣鐨勫唴閮ㄧ被 - private static class AreaStats { - int totalSites = 0; - int offlineSites = 0; - int totalDataSum = 0; - } - } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexFaceServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexFaceServiceImpl.java index e23ab19..6f4a5e9 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexFaceServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckIndexFaceServiceImpl.java @@ -1,14 +1,30 @@ package com.ycl.platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ycl.platform.domain.entity.CheckIndexCar; import com.ycl.platform.domain.entity.CheckIndexFace; +import com.ycl.platform.domain.entity.TMonitor; import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; +import com.ycl.platform.mapper.CheckIndexCarMapper; import com.ycl.platform.mapper.CheckIndexFaceMapper; import com.ycl.platform.service.ICheckIndexFaceService; +import com.ycl.platform.service.ITMonitorService; +import com.ycl.system.mapper.SysConfigMapper; +import com.ycl.system.mapper.SysDeptMapper; +import constant.ApiConstants; +import constant.CheckConstants; +import constant.CheckSnapCountConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import utils.DateUtils; -import java.util.List; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 浜鸿劯鎸囨爣姒傜巼鏁版嵁Service涓氬姟灞傚鐞� @@ -17,10 +33,15 @@ * @date 2024-04-29 */ @Service -public class CheckIndexFaceServiceImpl implements ICheckIndexFaceService { +public class CheckIndexFaceServiceImpl extends ServiceImpl<CheckIndexFaceMapper, CheckIndexFace> implements ICheckIndexFaceService { @Autowired private CheckIndexFaceMapper checkIndexFaceMapper; - + @Autowired + private SysConfigMapper sysConfigMapper; + @Autowired + private ITMonitorService monitorService; + @Autowired + private SysDeptMapper deptMapper; /** * 鏌ヨ浜鸿劯鎸囨爣姒傜巼鏁版嵁 * @@ -88,13 +109,7 @@ return checkIndexFaceMapper.deleteCheckIndexFaceById(id); } - /** - * 璁$畻浜鸿劯鐐逛綅鍦ㄧ嚎鐜� - * - * @param list - */ - @Override - public void siteOnline(List<SnapshotDataMonitorResult> list) { - } + + } diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java index 4993e48..4767a29 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java @@ -2,8 +2,6 @@ import annotation.DataScope; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ycl.platform.base.BaseSelect; -import com.ycl.platform.base.CheckIndex; import com.ycl.platform.domain.dto.CheckScoreDTO; import com.ycl.platform.domain.dto.CheckScoreIndexDTO; import com.ycl.platform.domain.dto.ScoreIndexDTO; @@ -17,14 +15,11 @@ import com.ycl.platform.service.ICheckIndexFaceService; import com.ycl.platform.service.ICheckIndexVideoService; import com.ycl.platform.service.ICheckScoreService; -import com.ycl.system.Result; import com.ycl.system.entity.SysRole; import com.ycl.system.service.ISysDeptService; +import com.ycl.utils.DateUtils; import com.ycl.utils.SecurityUtils; import com.ycl.utils.StringUtils; -import com.ycl.utils.poi.ExcelUtil; -import constant.CheckConstants; -import enumeration.general.CheckScoreType; import enumeration.general.PublishType; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; @@ -32,16 +27,13 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import pojo.ExcelExp; -import utils.DateUtils; import utils.poi.ExcelUtilManySheet; import java.io.IOException; import java.text.SimpleDateFormat; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * 鑰冩牳绉垎鏄庣粏Service涓氬姟灞傚鐞� @@ -137,21 +129,24 @@ //鍖哄幙鍙兘鐪嬪凡鍙戝竷 roleControl(checkScore); - //鏌ヨ鎴愮哗 - String date = checkScore.getDate(); - if(StringUtils.isEmpty(date)){ - //濡傛灉涓虹┖鏌ユ湰鏈堢殑鏁版嵁 - Calendar now = Calendar.getInstance(); - //鍙栨槰澶� - now.add(Calendar.DATE, -1); - Date yesterday = now.getTime(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM"); - date = simpleDateFormat.format(yesterday); - checkScore.setDate(date); + // 鑾峰彇鏁版嵁鏃ユ湡鏃堕棿 + Calendar calendar = Calendar.getInstance(); + // 涓�鍙锋煡璇箣鍓嶇殑鏁版嵁 + if (LocalDateTime.now().getDayOfMonth() == 1) { calendar.add(Calendar.DAY_OF_MONTH, -1); } + // 0 鐪佸巺鏈堝害 1 甯傚眬鏈堝害 2 鐪佸巺瀛e害 3 甯傚眬瀛e害 + switch (checkScore.getExamineTag()) { + case 0, 1: + checkScore.setEndDate(calendar.getTime()); + calendar.set(Calendar.DAY_OF_MONTH, 1); + checkScore.setStartDate(calendar.getTime()); + break; + case 2, 3: + checkScore.setStartDate(DateUtils.getQuarterStart(calendar).getTime()); + checkScore.setEndDate(DateUtils.getQuarterEnd(calendar).getTime()); + checkScore.setExamineTag(checkScore.getExamineTag() == 2 ? 0 : 1); + break; } - List<CheckScore> checkScores = scoreMapper.selectCheckScoreList(checkScore); - Map<Long, List<CheckScore>> deptMap = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); - return deptMap; + return scoreMapper.selectCheckScoreMap(checkScore).stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); } diff --git a/ycl-server/src/main/java/com/ycl/task/HKTask.java b/ycl-server/src/main/java/com/ycl/task/HKTask.java index 5424408..69e7a29 100644 --- a/ycl-server/src/main/java/com/ycl/task/HKTask.java +++ b/ycl-server/src/main/java/com/ycl/task/HKTask.java @@ -1,26 +1,25 @@ package com.ycl.task; import com.alibaba.fastjson2.JSONObject; -import com.ycl.platform.domain.param.HK.FaceDeviceInspectionParam; -import com.ycl.platform.domain.param.HK.SnapshotDataMonitorParam; -import com.ycl.platform.domain.param.HK.VehicleDeviceInspectionParam; -import com.ycl.platform.domain.result.HK.BaseResult; -import com.ycl.platform.domain.result.HK.FaceDeviceInspectionResult; -import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; -import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult; +import com.mongodb.client.result.DeleteResult; +import com.ycl.platform.domain.param.HK.*; +import com.ycl.platform.domain.result.BaseResult; +import com.ycl.platform.domain.result.HK.*; import com.ycl.platform.service.ICheckIndexCarService; import com.ycl.platform.service.ICheckIndexFaceService; import com.ycl.platform.service.ICheckIndexVideoService; import com.ycl.platform.service.IYwThresholdService; +import com.ycl.utils.DateUtils; import constant.ApiConstants; import com.ycl.feign.HKClient; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -43,13 +42,16 @@ private ICheckIndexVideoService checkIndexVideoService; //杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉 - public void VehicleDeviceInspectionTask() { + public void vehicleDeviceInspectionTask() { log.info("寮�濮嬫墽琛岃溅杈嗚澶囧叏妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); VehicleDeviceInspectionParam param = new VehicleDeviceInspectionParam(); - param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); JSONObject jsonObject = hkClient.VehicleDeviceInspection(param); List<VehicleDeviceInspectionResult> list = getDataList(jsonObject, VehicleDeviceInspectionResult.class, "杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉鏁版嵁涓虹┖"); if (!CollectionUtils.isEmpty(list)) { + //濡傛灉瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria.where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, VehicleDeviceInspectionResult.class); //瀛樻斁鍦╩ongo涓� mongoTemplate.insert(list); //鍚屾鐨勬暟鎹繘琛屽伐鍗曢槇鍊煎鐞� @@ -59,16 +61,20 @@ } //浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉 - public void FaceDeviceInspectionTask() { + public void faceDeviceInspectionTask() { log.info("寮�濮嬫墽琛屼汉鑴歌澶囧叏妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); FaceDeviceInspectionParam param = new FaceDeviceInspectionParam(); - param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); JSONObject jsonObject = hkClient.FaceDeviceInspection(param); List<FaceDeviceInspectionResult> list = getDataList(jsonObject, FaceDeviceInspectionResult.class, "浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉鏁版嵁涓虹┖"); if (!CollectionUtils.isEmpty(list)) { + //濡傛灉瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria.where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, FaceDeviceInspectionResult.class); //瀛樻斁鍦╩ongo涓� mongoTemplate.insert(list); //鍚屾鐨勬暟鎹繘琛屽伐鍗曢槇鍊煎鐞� + //TODO:鍙兘鏈夐噸澶嶅伐鍗� ywThresholdService.faceCheck(list); } log.info("缁撴潫浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); @@ -76,79 +82,221 @@ //鎶撴媿鏁版嵁閲忕洃娴嬬粨鏋� - public void SnapshotDataMonitorTask() { + public void snapshotDataMonitorTask() { log.info("寮�濮嬫墽琛屾姄鎷嶆暟鎹噺妫�娴嬬粨鏋滄暟鎹悓姝�"); /** 杞﹁締鏁版嵁 */ SnapshotDataMonitorParam carParam = new SnapshotDataMonitorParam(); - carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()).setDataType(ApiConstants.HK_DATATYPE_CAR); + carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); JSONObject carJsonObject = hkClient.SnapshotDataMonitor(carParam); List<SnapshotDataMonitorResult> carList = getDataList(carJsonObject, SnapshotDataMonitorResult.class, "杞﹁締鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹�"); if (!CollectionUtils.isEmpty(carList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) + .and("dataType").is(ApiConstants.HK_DATATYPE_CAR)); + DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); //瀛樻斁鍦╩ongo涓� + carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_CAR)); mongoTemplate.insert(carList); - //TODO:杞﹁締鐐逛綅鍦ㄧ嚎鐜� - checkIndexCarService.siteOnline(carList); } /** 浜鸿劯鏁版嵁 */ SnapshotDataMonitorParam faceParam = new SnapshotDataMonitorParam(); - faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()).setDataType(ApiConstants.HK_DATATYPE_FACE); + faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_FACE); JSONObject faceJsonObject = hkClient.SnapshotDataMonitor(carParam); - List list = getDataList(faceJsonObject, SnapshotDataMonitorResult.class, "浜鸿劯鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹负绌�"); - if (!CollectionUtils.isEmpty(list)) { + List<SnapshotDataMonitorResult> faceList = getDataList(faceJsonObject, SnapshotDataMonitorResult.class, "浜鸿劯鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) + .and("dataType").is(ApiConstants.HK_DATATYPE_FACE)); + DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); //瀛樻斁鍦╩ongo涓� - mongoTemplate.insert(list); - //TODO:浜鸿劯鐐逛綅鍦ㄧ嚎鐜� - checkIndexFaceService.siteOnline(list); + carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_FACE)); + mongoTemplate.insert(faceList); } - + //TODO:宸ュ崟 log.info("缁撴潫鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹悓姝�"); } - - //涓�鏈轰竴妗� - public void task2() { - //鑱旂綉鍗″彛璁惧鐩綍涓�鑷寸巼 + //閲囬泦璁惧灞炴�х洃娴嬬粨鏋�(浜鸿劯) + public void monitorDetailTask() { + log.info("寮�濮嬫墽琛岄噰闆嗚澶囧睘鎬х洃娴嬬粨鏋滄暟鎹悓姝�"); + //浜鸿劯鍗″彛淇℃伅閲囬泦鍑嗙‘鐜� + MonitoringDetailParam param = new MonitoringDetailParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); + JSONObject jsonObject = hkClient.monitorDetail(param); + List<MonitoringDetailResult> faceList = getDataList(jsonObject, MonitoringDetailResult.class, "閲囬泦璁惧灞炴�х洃娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, MonitoringDetailResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫閲囬泦璁惧灞炴�х洃娴嬬粨鏋滄暟鎹悓姝�"); } //鍗″彛灞炴�х洃娴嬬粨鏋� - public void task3() { + public void crossDetailTask() { + log.info("寮�濮嬫墽琛屽崱鍙e睘鎬х洃娴嬬粨鏋滄暟鎹悓姝�"); //杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜� + CrossDetailParam param = new CrossDetailParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); + JSONObject jsonObject = hkClient.crossDetail(param); + List<CrossDetailResult> faceList = getDataList(jsonObject, CrossDetailResult.class, "鍗″彛灞炴�х洃娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, CrossDetailResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫鍗″彛灞炴�х洃娴嬬粨鏋滄暟鎹悓姝�"); } //鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋� - public void task4() { + public void dataIntegrityMonitoringTask() { + log.info("寮�濮嬫墽琛屾暟鎹畬鏁存�х洃娴嬬粨鏋滄暟鎹悓姝�"); //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁瀹屾暣鎬� + DataIntegrityMonitoringParam param = new DataIntegrityMonitoringParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); + JSONObject jsonObject = hkClient.DataIntegrityMonitoring(param); + List<DataIntegrityMonitoringResult> faceList = getDataList(jsonObject, DataIntegrityMonitoringResult.class, "鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, DataIntegrityMonitoringResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋滄暟鎹悓姝�"); } //灞炴�ц瘑鍒噯纭洃娴嬬粨鏋� - public void task5() { - //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁瀹屾暣鎬� - } + public void attrRecognitionMonitorTask() { + log.info("寮�濮嬫墽琛屽睘鎬ц瘑鍒噯纭洃娴嬬粨鏋滄暟鎹悓姝�"); + //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁鍑嗙‘鎬� + AttrRecognitionParam param = new AttrRecognitionParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); + JSONObject jsonObject = hkClient.AttrRecognitionMonitor(param); + List<AttrRecognitionMonitorResult> faceList = getDataList(jsonObject, AttrRecognitionMonitorResult.class, "灞炴�ц瘑鍒噯纭洃娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, AttrRecognitionMonitorResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫灞炴�ц瘑鍒噯纭洃娴嬬粨鏋滄暟鎹悓姝�"); - //杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉 - public void task6() { - //杞﹁締鍗″彛璁惧鏃堕挓鍑嗙‘鎬� } //鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉 - public void task7() { + public void snapshopDelayMonitorTask() { + log.info("寮�濮嬫墽琛屾姄鎷嶆暟鎹椂寤剁洃娴嬬粨鏋滄暟鎹悓姝�"); //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁涓婁紶鍙婃椂鎬� + /** 杞﹁締鏁版嵁 */ + SnapshotDelayMonitorParam carParam = new SnapshotDelayMonitorParam(); + carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); + JSONObject carJsonObject = hkClient.SnapshotDelayMonitor(carParam); + List<SnapshotDelayMonitorResult> carList = getDataList(carJsonObject, SnapshotDelayMonitorResult.class, "杞﹁締鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹�"); + if (!CollectionUtils.isEmpty(carList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) + .and("dataType").is(ApiConstants.HK_DATATYPE_CAR)); + DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); + //瀛樻斁鍦╩ongo涓� + carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_CAR)); + mongoTemplate.insert(carList); + } + + /** 浜鸿劯鏁版嵁 */ + SnapshotDelayMonitorParam faceParam = new SnapshotDelayMonitorParam(); + faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_FACE); + JSONObject faceJsonObject = hkClient.SnapshotDelayMonitor(faceParam); + List<SnapshotDelayMonitorParam> faceList = getDataList(faceJsonObject, SnapshotDelayMonitorParam.class, "浜鸿劯鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹负绌�"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) + .and("dataType").is(ApiConstants.HK_DATATYPE_FACE)); + DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); + //瀛樻斁鍦╩ongo涓� + carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_FACE)); + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟 + log.info("缁撴潫鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉鏁版嵁鍚屾"); } //鍥剧墖璁块棶鐩戞祴缁撴灉 - public void task8() { - //杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜� - - //杞﹁締鍗″彛璁惧url鍙敤鎬� + public void PicAccessTask() { + log.info("寮�濮嬫墽琛屽浘鐗囪闂洃娴嬬粨鏋滄暟鎹悓姝�"); + //杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜囥�佽溅杈嗗崱鍙h澶噓rl鍙敤鎬� + PicAccessParam param = new PicAccessParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); + JSONObject jsonObject = hkClient.PicAccessMonitor(param); + List<PicAccessResult> faceList = getDataList(jsonObject, PicAccessResult.class, "鍥剧墖璁块棶鐩戞祴缁撴灉鏁版嵁涓虹┖"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫鍥剧墖璁块棶鐩戞祴缁撴灉鏁版嵁鍚屾"); } - //鑾峰彇褰撳墠鏃ユ湡 - private String getToday() { - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String today = sdf.format(date); - return today; + //浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉 + public void Face() { + log.info("寮�濮嬫墽琛屼汉鑴歌澶囨娊妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); + //杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜囥�佽溅杈嗗崱鍙h澶噓rl鍙敤鎬� + FaceDeviceSamplingParam param = new FaceDeviceSamplingParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); + JSONObject jsonObject = hkClient.FaceDeviceSampling(param); + List<FaceDeviceSamplingResult> faceList = getDataList(jsonObject, FaceDeviceSamplingResult.class, "浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁涓虹┖"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); + } + + //杞﹁締璁惧鎶芥鎸囨爣鐩戞祴缁撴灉 + public void FaceDeviceSamplingTask() { + log.info("寮�濮嬫墽琛岃溅杈嗚澶囨娊妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); + //杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜囥�佽溅杈嗗崱鍙h澶噓rl鍙敤鎬� + FaceDeviceSamplingParam param = new FaceDeviceSamplingParam(); + param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); + JSONObject jsonObject = hkClient.FaceDeviceSampling(param); + List<FaceDeviceSamplingResult> faceList = getDataList(jsonObject, FaceDeviceSamplingResult.class, "浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁涓虹┖"); + if (!CollectionUtils.isEmpty(faceList)) { + //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 + Query query = new Query(Criteria + .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); + DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); + //瀛樻斁鍦╩ongo涓� + mongoTemplate.insert(faceList); + } + //TODO:宸ュ崟澶勭悊 + log.info("缁撴潫浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾"); } //瑙f瀽鏁版嵁 diff --git a/ycl-server/src/main/java/com/ycl/task/UYTask.java b/ycl-server/src/main/java/com/ycl/task/UYTask.java index 4d94bba..be50d01 100644 --- a/ycl-server/src/main/java/com/ycl/task/UYTask.java +++ b/ycl-server/src/main/java/com/ycl/task/UYTask.java @@ -1,5 +1,6 @@ package com.ycl.task; +import com.ycl.platform.domain.param.UY.OnlineParam; import com.ycl.platform.service.IYwThresholdService; import com.ycl.feign.UYClient; import lombok.extern.slf4j.Slf4j; @@ -49,8 +50,12 @@ } //鍥惧儚鐩戞祴璇婃柇缁撴灉 - public void task2() { + public void queryVqdResultTask() { //鐐逛綅鍦ㄧ嚎鐜� + log.info("寮�濮嬫墽琛屽浘鍍忕洃娴嬭瘖鏂粨鏋滄暟鎹悓姝�"); + + + log.info("缁撴潫鎵ц鍥惧儚鐩戞祴璇婃柇缁撴灉鏁版嵁鍚屾"); } //褰曞儚鍙敤 @@ -58,10 +63,5 @@ //褰曞儚鍙敤鐜� } - private String getToday() { - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String today = sdf.format(date); - return today; - } + } diff --git a/ycl-server/src/main/java/com/ycl/utils/DateUtils.java b/ycl-server/src/main/java/com/ycl/utils/DateUtils.java index 0be7f5f..a27708e 100644 --- a/ycl-server/src/main/java/com/ycl/utils/DateUtils.java +++ b/ycl-server/src/main/java/com/ycl/utils/DateUtils.java @@ -8,6 +8,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.*; +import java.util.Calendar; import java.util.Date; import java.util.Objects; @@ -227,4 +228,34 @@ LocalDateTime of = LocalDateTime.of(localDateTime.getYear(), localDateTime.getMonth(), localDateTime.getDayOfMonth(), 23, 59, 59); return Timestamp.valueOf(of); } + + /** + * 鑾峰彇鎸囧畾Calendar鐨勫搴﹀紑濮嬫棩鏈� + * @param calendar 鏃ュ巻 + * @return 瀛e害绗竴澶� + */ + public static Calendar getQuarterStart(Calendar calendar) { + Calendar quarterStart = (Calendar) calendar.clone(); + // 璁剧疆涓哄綋鍓嶅搴︾殑绗竴涓湀鐨勭涓�澶� + quarterStart.set(Calendar.DAY_OF_MONTH, 1); + int month = quarterStart.get(Calendar.MONTH); + quarterStart.set(Calendar.MONTH, (month / 3) * 3); + return quarterStart; + } + + /** + * 鑾峰彇鎸囧畾Calendar鐨勫搴︾粨鏉熸棩鏈� + * @param calendar 鏃ュ巻 + * @return 瀛e害鏈�鍚庝竴澶� + */ + public static Calendar getQuarterEnd(Calendar calendar) { + Calendar quarterEnd = getQuarterStart(calendar); + // 灏嗘湀浠借缃负涓嬩竴涓搴︾殑绗竴涓湀 + quarterEnd.add(Calendar.MONTH, 3); + // 璁剧疆涓洪偅涓湀鐨勬渶鍚庝竴澶� + quarterEnd.add(Calendar.DAY_OF_MONTH, -1); + return quarterEnd; + } + + } diff --git a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml index 21c56ba..a3c9adf 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml @@ -20,6 +20,7 @@ <select id="page" resultMap="BaseResultMap"> SELECT + tcr.contract_id, tyu.unit_name, tc.name, tcr.id, @@ -99,4 +100,14 @@ WHERE tcr.id = #{id} </select> + <select id="exportData" resultType="com.ycl.platform.domain.excel.CalculateExport"> + SELECT + SUBSTRING_INDEX(rule_name, '/', 1) AS rule_name, + COUNT(*) AS num, + -SUM(score) AS score + FROM t_contract_score + WHERE contract_id = #{contractId} AND auditing_status = 'PASS' AND deleted = 0 + GROUP BY SUBSTRING_INDEX(rule_name, '/', 1) + </select> + </mapper> diff --git a/ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml index 7c73d45..43aaf4d 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ycl.platform.mapper.CheckIndexFaceMapper"> - + <resultMap type="com.ycl.platform.domain.entity.CheckIndexFace" id="CheckIndexFaceResult"> <result property="id" column="id" /> <result property="deptId" column="dept_id" /> @@ -26,7 +26,7 @@ <select id="selectCheckIndexFaceList" resultMap="CheckIndexFaceResult"> select tcif.*,sd.dept_name from t_check_index_face tcif left join sys_dept sd on tcif.dept_id = sd.dept_id - <where> + <where> <if test="deptId != null "> and tcif.dept_id = #{deptId}</if> <if test="examineTag != null "> and examine_tag = #{examineTag}</if> <if test="date != null "> and date_format(tcif.create_time,'%Y-%m') = #{date}</if> @@ -46,12 +46,12 @@ </if> </where> </select> - + <select id="selectCheckIndexFaceById" resultMap="CheckIndexFaceResult"> <include refid="selectCheckIndexFaceVo"/> where id = #{id} </select> - + <insert id="insertCheckIndexFace" useGeneratedKeys="true" keyProperty="id"> insert into t_check_index_face <trim prefix="(" suffix=")" suffixOverrides=","> @@ -105,9 +105,13 @@ </delete> <delete id="deleteCheckIndexFaceByIds" > - delete from t_check_index_face where id in + delete from t_check_index_face where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> -</mapper> \ No newline at end of file + + <select id="selectToday"> + select * from t_check_index_car where DATE(create_time) = #{today} + </select> +</mapper> diff --git a/ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml index 45fc2ec..12fb02b 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml @@ -114,4 +114,23 @@ (#{score.score},#{score.deptId},#{score.templateId},#{score.examineTag},#{score.examineCategory},#{score.createTime}) </foreach> </insert> + + <select id="selectCheckScoreMap" resultType="com.ycl.platform.domain.entity.CheckScore"> + SELECT + tcs.dept_id, + examine_category, + AVG(score) AS score, + #{startDate} AS startDate, + #{endDate} AS endDate + FROM + t_check_score tcs + LEFT JOIN sys_dept d ON tcs.dept_id = d.dept_id + WHERE + examine_tag = #{examineTag} + AND tcs.create_time BETWEEN #{startDate} AND #{endDate} + GROUP BY + tcs.dept_id, + examine_category + </select> + </mapper> \ No newline at end of file -- Gitblit v1.8.0