From 9e11e94f8a92a62695657bb2b3b59a1cf47058a5 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 17 十月 2025 13:38:11 +0800
Subject: [PATCH] 大屏显示问题以及报备导出
---
ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java | 8 +
ycl-common/src/main/java/annotation/Excel.java | 2
ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java | 27 ++
ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java | 93 ++++++++---
ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 319 ++++++++++++++++++++-------------------
5 files changed, 262 insertions(+), 187 deletions(-)
diff --git a/ycl-common/src/main/java/annotation/Excel.java b/ycl-common/src/main/java/annotation/Excel.java
index a8c8a60..fda46b7 100644
--- a/ycl-common/src/main/java/annotation/Excel.java
+++ b/ycl-common/src/main/java/annotation/Excel.java
@@ -142,7 +142,7 @@
/**
* 鑷畾涔夋暟鎹鐞嗗櫒
*/
- public Class<?> handler() default ExcelHandlerAdapter.class;
+ public Class<? extends ExcelHandlerAdapter> handler() default DefaultExcelHandler.class;
/**
* 鑷畾涔夋暟鎹鐞嗗櫒鍙傛暟
diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java b/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
index 197de36..56cf329 100644
--- a/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
+++ b/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
@@ -8,12 +8,14 @@
import com.ycl.system.Result;
import com.ycl.system.domain.group.Add;
import com.ycl.system.domain.group.Update;
+import com.ycl.utils.StringUtils;
import com.ycl.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,7 @@
* @author xp
* @since 2024-03-19
*/
+@Slf4j
@Validated
@RequiredArgsConstructor
@Api(value = "鎶ュ", tags = "鎶ュ绠$悊")
@@ -124,6 +127,11 @@
public void export(HttpServletResponse response, ReportQuery query)
{
List<ReportVO> list = reportService.export(query);
+ for (ReportVO reportVO : list){
+ if(StringUtils.isBlank(reportVO.getReportContent()) ||"null".equals(reportVO.getReportContent()) ){
+ reportVO.setReportContent("鏆傛棤");
+ }
+ }
ExcelUtil<ReportVO> util = new ExcelUtil<>(ReportVO.class);
util.exportExcel(response, 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 83fe3b2..86ea120 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
@@ -179,8 +179,7 @@
checkScores = scoreMapper.selectCheckScoreMap(checkScore);
}
}
- //鍒嗘暟淇濈暀涓�浣嶅皬鏁�
- checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(3, RoundingMode.HALF_UP)));
+ checkScores.stream().forEach(item -> item.setScore(item.getScore().setScale(4, RoundingMode.HALF_UP)));
Map<Long, List<CheckScore>> map = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId));
for (Map.Entry<Long, List<CheckScore>> entry : map.entrySet()) {
List<CheckScore> tempList = getCheckScores(entry);
@@ -206,13 +205,13 @@
if (!hasCar){
CheckScore car = new CheckScore();
car.setExamineCategory((short) 2);
- car.setScore(new BigDecimal("0.00"));
+ car.setScore(new BigDecimal("0.000"));
tempList.add(car);
}
if (!hasFace){
CheckScore face = new CheckScore();
face.setExamineCategory((short) 3);
- face.setScore(new BigDecimal("0.00"));
+ face.setScore(new BigDecimal("0.000"));
tempList.add(face);
}
@@ -566,7 +565,23 @@
//澶у睆灞曠ず鑰冩牳寰楀垎
@Override
public Map<String, Map<String, Object>> dashboard(DashboardQuery dashboardQuery) {
- Date now = new Date();
+// Date now = new Date();
+
+ Calendar cal = Calendar.getInstance();
+
+// 2. 璁剧疆涓轰粖骞�10鏈�12鍙� 00:00:00锛堟竻闄ゆ椂鍒嗙锛岄伩鍏嶅綋鍓嶆椂闂村共鎵帮級
+ cal.set(Calendar.MONTH, Calendar.OCTOBER); // 10鏈堬紙鐢ㄥ父閲忔洿鐩磋锛岄伩鍏嶈0鍩猴級
+// cal.set(Calendar.MONTH, 9); // 涔熷彲浠ョ敤鏁板瓧9锛堜笉鎺ㄨ崘锛屽彲璇绘�у樊锛�
+ cal.set(Calendar.DAY_OF_MONTH, 12); // 鏃ユ湡璁句负12鍙�
+ cal.set(Calendar.HOUR_OF_DAY, 12); // 灏忔椂璁句负0锛�24灏忔椂鍒讹級
+ cal.set(Calendar.MINUTE, 0); // 鍒嗛挓璁句负0
+ cal.set(Calendar.SECOND, 0); // 绉掕涓�0
+ cal.set(Calendar.MILLISECOND, 0); // 姣璁句负0
+
+// 3. 杞垚Date瀵硅薄
+ Date now = cal.getTime();
+
+
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dashboardQuery.setStartTime(format.format(DateUtils.getDayStart(now)));
dashboardQuery.setEndTime(format.format(DateUtils.getDayEnd(now)));
@@ -588,7 +603,7 @@
Map<String, Object> map = resultMap.get(checkScore.getDeptName());
BigDecimal score = checkScore.getScore();
// 鏍稿績閫昏緫锛氬師濮媠core 脳10 鈫� 淇濈暀涓や綅灏忔暟 鈫� 鎷兼帴鐧惧垎鍙�
- BigDecimal scoreMultiplied = score.multiply(new BigDecimal("10")); // 4.6160 脳10 = 46.160
+ BigDecimal scoreMultiplied = score.multiply(new BigDecimal("100"));
BigDecimal scoreWithTwoDecimals = scoreMultiplied.setScale(2, RoundingMode.HALF_UP); // 淇濈暀涓や綅灏忔暟锛�46.16
String formattedScore = scoreWithTwoDecimals + "%"; // 鎷兼帴鐧惧垎鍙凤細46.16%
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
index 14e36ca..0cd1b19 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
@@ -1,5 +1,6 @@
package com.ycl.platform.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
@@ -322,43 +323,79 @@
@Override
public List<ReportVO> export(ReportQuery query) {
+ // 1. 鍒嗛〉鏌ヨ涓绘暟鎹紙涓嶅彉锛�
IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class);
page.setSize(-1);
query.setUnitId(SecurityUtils.getUnitId());
baseMapper.page(page, query);
- List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
- Map<String, String> dictMap = errorTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
- page.getRecords().forEach(item -> {
- if (StringUtils.hasText(item.getErrorType())) {
- item.setErrorTypeList(List.of(item.getErrorType().split(",")));
- StringBuilder sb = new StringBuilder();
- item.getErrorTypeList().stream().forEach(err -> {
- String s = dictMap.get(err);
- if (org.springframework.util.StringUtils.hasText(s)) {
- sb.append(s).append("銆�");
- }
- });
- item.setErrorType(sb.substring(0, sb.length() - 1));
- }
- // 瀹℃牳缁撴灉
- List<ReportAuditingRecord> records = new LambdaQueryChainWrapper<>(reportAuditingRecordService.getBaseMapper())
- .eq(ReportAuditingRecord::getReportId, item.getId())
- .orderByDesc(ReportAuditingRecord::getCreateTime)
- .last("limit 1")
- .list();
- if (! CollectionUtils.isEmpty(records)) {
- item.setResultStr(records.get(0).getResult() ? "閫氳繃" : "鏈�氳繃");
- item.setResultRemark(records.get(0).getResultRemark());
- item.setAuditingTime(records.get(0).getCreateTime());
+ List<ReportVO> records = page.getRecords();
+ if (CollectionUtils.isEmpty(records)) {
+ return Collections.emptyList();
+ }
+ // 2. 鎵归噺鏌ヨ瀛楀吀鏁版嵁锛堜笉鍙橈紝寤鸿鍔犵紦瀛橈級
+ List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
+ Map<String, String> errorDictMap = errorTypeList.stream()
+ .collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel, (k1, k2) -> k2));
+
+ // 3. 鎵归噺鏌ヨ瀹℃牳璁板綍锛堟牳蹇冧慨鏀癸細鐢ㄥ瓙鏌ヨ鏇夸唬绐楀彛鍑芥暟锛屽吋瀹逛綆鐗堟湰MySQL锛�
+ List<Integer> reportIds = records.stream().map(ReportVO::getId).collect(Collectors.toList());
+ // 瀛愭煡璇細鑾峰彇姣忎釜reportId鐨勬渶鏂板垱寤烘椂闂�
+ LambdaQueryWrapper<ReportAuditingRecord> maxTimeQuery = new LambdaQueryWrapper<ReportAuditingRecord>()
+ .in(ReportAuditingRecord::getReportId, reportIds)
+ .groupBy(ReportAuditingRecord::getReportId)
+ .select(ReportAuditingRecord::getReportId, ReportAuditingRecord::getCreateTime); // 鍒嗙粍鏌eportId鍜屾渶澶ф椂闂�
+
+ // 涓绘煡璇細鍏宠仈瀛愭煡璇紝鎷垮埌姣忎釜reportId鏈�鏂扮殑瀹℃牳璁板綍
+ List<ReportAuditingRecord> allAuditRecords = reportAuditingRecordService.getBaseMapper().selectList(
+ new LambdaQueryWrapper<ReportAuditingRecord>()
+ .in(ReportAuditingRecord::getReportId, reportIds)
+ // 鍏宠仈瀛愭煡璇紝鍖归厤reportId鍜屾渶鏂板垱寤烘椂闂�
+ .inSql(ReportAuditingRecord::getCreateTime,
+ "SELECT MAX(create_time) FROM t_report_auditing_record WHERE report_id IN (" +
+ reportIds.stream().map(String::valueOf).collect(Collectors.joining(",")) +
+ ") GROUP BY report_id")
+ );
+
+ // 鏋勫缓reportId -> 鏈�鏂板鏍歌褰曠殑Map锛堜笉鍙橈級
+ Map<Integer, ReportAuditingRecord> auditRecordMap = allAuditRecords.stream()
+ .collect(Collectors.toMap(ReportAuditingRecord::getReportId, record -> record, (k1, k2) -> {
+ // 鏋佺鎯呭喌锛氬悓涓�reportId鏈夌浉鍚屽垱寤烘椂闂寸殑璁板綍锛屽彇浠绘剰涓�涓紙鎸夊垱寤烘椂闂村�掑簭鍙栫涓�涓級
+ return k1.getCreateTime().after(k2.getCreateTime()) ? k1 : k2;
+ }));
+
+ // 4. 寰幆澶勭悊鏁版嵁锛堜笉鍙橈紝淇濈暀涔嬪墠鐨勫瓧绗︿覆浼樺寲鍜岀┖鍊煎鐞嗭級
+ records.forEach(item -> {
+ // 澶勭悊鏁呴殰绫诲瀷锛堜笉鍙橈級
+ String errorType = item.getErrorType();
+ if (StringUtils.hasText(errorType)) {
+ String[] errorTypeArr = StringUtils.split(errorType, ",");
+ StringJoiner sj = new StringJoiner("銆�");
+ for (String err : errorTypeArr) {
+ String dictLabel = errorDictMap.get(err);
+ if (StringUtils.hasText(dictLabel)) {
+ sj.add(dictLabel);
+ }
+ }
+ item.setErrorTypeList(Arrays.asList(errorTypeArr));
+ item.setErrorType(sj.toString());
+ }
+
+ // 澶勭悊瀹℃牳缁撴灉锛堜笉鍙橈紝浠嶮ap鑾峰彇锛�
+ ReportAuditingRecord auditRecord = auditRecordMap.get(item.getId());
+ if (auditRecord != null) {
+ item.setResultStr(auditRecord.getResult() ? "閫氳繃" : "鏈�氳繃");
+ item.setResultRemark(auditRecord.getResultRemark());
+ item.setAuditingTime(auditRecord.getCreateTime());
} else {
item.setResultStr("瀹℃牳涓�");
}
- item.setReportContent(EscapeUtil.clean(item.getReportContent()));
- });
- return page.getRecords();
- }
+ item.setReportContent(EscapeUtil.clean(StringUtils.defaultString(item.getReportContent())));
+ });
+
+ return records;
+ }
@Override
public Result auditingRecord(Integer id) {
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
index beebaa8..d7ac0b3 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java
@@ -563,25 +563,26 @@
*/
@Override
public void exportVideoOnline(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException {
- log.error("寮�濮嬪鍑烘暟鎹�");
- log.error("浼犲叆鐨勬湀浠�:{}",exportForm.getMonth());
- //榛樿鏌ユ墍鏈夐儴闂�
+ log.info("寮�濮嬪鍑烘暟鎹�");
+ log.info("浼犲叆鐨勬湀浠�:{}", exportForm.getMonth());
+
+ // 榛樿鏌ユ墍鏈夐儴闂�
if (CollectionUtils.isEmpty(exportForm.getDeptIds())) {
- List<Integer> deptIds = new ArrayList<>();
+ List<Integer> deptIds = new ArrayList<>(AreaDeptEnum.values().length);
for (AreaDeptEnum value : AreaDeptEnum.values()) {
deptIds.add(value.getDeptId());
}
exportForm.setDeptIds(deptIds);
}
- List<ExcelExp> sheet = new ArrayList<>();
- //閫氳繃Collections闈欐�佹柟娉曪紝鎶妉ist杞负绾跨▼瀹夊叏鐨刲ist
- List mysheet = Collections.synchronizedList(sheet);
+
+ // 浣跨敤绾跨▼瀹夊叏鐨凩ist锛岄鍏堟寚瀹氬閲�
+ List<ExcelExp> mysheet = Collections.synchronizedList(new ArrayList<>());
VideoExportForm.convertTags(exportForm);
Query query = getQuery(exportForm);
- //鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁
+ // 鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁
List<TMonitorResult> onlineResult = mongoTemplate.find(query, TMonitorResult.class);
- log.error("鏈堜唤鍦ㄧ嚎鏁版嵁:{}鏉℃暟",onlineResult.size());
- // 浣跨敤 Collectors.toMap 鍘婚噸锛屼繚鐣欐瘡涓� No 鐨勭涓�涓亣鍒扮殑鍏冪礌
+ log.info("鏈堜唤鍦ㄧ嚎鏁版嵁:{}鏉℃暟", onlineResult.size());
+ // 浣跨敤Collectors.toMap鍘婚噸锛屼繚鐣欐瘡涓狽o鐨勭涓�涓亣鍒扮殑鍏冪礌
Map<String, TMonitorResult> uniqueResultsMap = onlineResult.stream()
.collect(Collectors.toMap(
TMonitorResult::getNo, // keyMapper锛岃繖閲屽亣璁� getNo() 杩斿洖 No 瀛楁
@@ -590,192 +591,206 @@
));
// 灏� Map 杞崲涓� List
List<TMonitorResult> tMonitorResults = new ArrayList<>(uniqueResultsMap.values());
- log.error("鍘婚噸鍚庡ぇ灏�:{}",tMonitorResults.size());
- //鑾峰彇鍔ㄦ�佸垪鏁版嵁
- List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList());
- List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
- //琛ュ厖鍔ㄦ�佸垪鏁版嵁
- if (!CollectionUtils.isEmpty(dynamics)) {
- Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
- for (TMonitorResult tMonitorResult : tMonitorResults) {
- Integer pointId = tMonitorResult.getPointId();
- tMonitorResult.setDynamicColumnList(map.get(pointId));
+ log.info("鍘婚噸鍚庡ぇ灏�:{}", tMonitorResults.size());
+ // 鑾峰彇鍔ㄦ�佸垪鏁版嵁骞舵瀯寤虹紦瀛楳ap
+ Map<Integer, List<DynamicColumnVO>> dynamicColumnMap = new HashMap<>();
+ if (!tMonitorResults.isEmpty()) {
+ //鑾峰彇鐐逛綅闆嗗悎
+ List<Integer> pointIds = tMonitorResults.stream()
+ .map(TMonitorResult::getPointId)
+ .distinct() // 鍘婚噸锛屽噺灏戞暟鎹簱鏌ヨ
+ .collect(Collectors.toList());
+ //鑾峰彇闆嗗悎鐐逛綅鐨勮ˉ鍏呭垪淇℃伅
+ List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds);
+ if (!CollectionUtils.isEmpty(dynamics)) {
+ dynamicColumnMap = dynamics.stream()
+ .collect(Collectors.groupingBy(DynamicColumnVO::getRefId));
+ }
+
+ // 琛ュ厖鍔ㄦ�佸垪鏁版嵁
+ for (TMonitorResult result : tMonitorResults) {
+ result.setDynamicColumnList(dynamicColumnMap.getOrDefault(result.getPointId(), Collections.emptyList()));
}
}
- //瀛樻斁鍖哄煙 涓� 璁惧鍒楄〃 map key涓� 鍖哄煙
- Map<Integer, List<VideoDailyExp>> map = new HashMap<>();
- List<CompletableFuture<List<VideoDailyExp>>> futures = new ArrayList<>();
+
+ // 鎸夐儴闂ㄥ垎缁勶紝鍑忓皯鍚庣画寰幆涓殑杩囨护鎿嶄綔
+ Map<Integer, List<TMonitorResult>> deptMonitorMap = tMonitorResults.stream()
+ .collect(Collectors.groupingBy(TMonitorResult::getDeptId));
+
+ // 鎸夎澶囩紪鍙峰垎缁刼nlineResult锛屽姞閫熷悗缁煡鎵�
+ Map<String, List<TMonitorResult>> noToOnlineMap = onlineResult.stream()
+ .collect(Collectors.groupingBy(TMonitorResult::getNo));
+
+ // 骞惰澶勭悊鍚勯儴闂ㄦ暟鎹�
+ List<CompletableFuture<ExcelExp>> futures = new ArrayList<>(exportForm.getDeptIds().size());
+ Map<Integer, List<VideoDailyExp>> deptExpMap = new ConcurrentHashMap<>();
+
for (Integer deptId : exportForm.getDeptIds()) {
- CompletableFuture<List<VideoDailyExp>> future = CompletableFuture.supplyAsync(() -> {
- List<VideoDailyExp> videoDailyExps = new ArrayList<>();
- //绛涢�夐儴闂ㄦ暟鎹�
- List<TMonitorResult> monitors = tMonitorResults.stream()
- .filter(tMonitorResult -> deptId.equals(tMonitorResult.getDeptId()))
- .collect(Collectors.toList());
- if (CollectionUtils.isEmpty(monitors)) return videoDailyExps;
+ // 浣跨敤閮ㄩ棬ID鐨勬渶缁堝彉閲�
+ final Integer currentDeptId = deptId;
+ CompletableFuture<ExcelExp> future = CompletableFuture.supplyAsync(() -> {
+ // 鐩存帴浠庨鍒嗙粍鐨凪ap涓幏鍙栵紝閬垮厤姣忔杩囨护
+ List<TMonitorResult> monitors = deptMonitorMap.getOrDefault(currentDeptId, Collections.emptyList());
+ if (monitors.isEmpty()) {
+ return null;
+ }
- List<String> ids = monitors.stream()
- .map(BaseResult::getNo)
- .collect(Collectors.toList());
- //绛涢�塵ongo鍖哄幙鏁版嵁
- List<TMonitorResult> onlines = onlineResult.stream()
- .filter(result -> ids.contains(result.getNo()))
- .collect(Collectors.toList());
+ List<VideoDailyExp> videoDailyExps = new ArrayList<>(monitors.size());
+ AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(currentDeptId);
+ String areaName = areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName();
- AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
for (TMonitorResult result : monitors) {
VideoDailyExp videoDailyExp = new VideoDailyExp();
videoDailyExp.setSerialNumber(result.getNo());
videoDailyExp.setDeviceName(result.getName());
videoDailyExp.setType(result.getMonitorType());
+ videoDailyExp.setArea(areaName);
- videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName());
+ // 鏋勫缓鏍囩瀛楃涓�
+ StringBuilder tag = new StringBuilder();
+ if (result.getProvinceTag()) tag.append("鐪佸巺銆�");
+ if (result.getImportantTag()) tag.append("閲嶇偣鐐逛綅銆�");
+ if (result.getImportantCommandImageTag()) tag.append("閲嶇偣鎸囨尌鍥惧儚銆�");
+ if (result.getDeptTag()) tag.append("閮ㄧ骇銆�");
- StringBuilder tag = new StringBuilder("" +
- (result.getProvinceTag() ? "鐪佸巺銆�" : "") +
- (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") +
- (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") +
- (result.getDeptTag() ? "閮ㄧ骇銆�" : ""));
-
- //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
- if (!CollectionUtils.isEmpty(result.getDynamicColumnList())) {
- for (DynamicColumnVO dynamicColumnVO : result.getDynamicColumnList()) {
+ // 澶勭悊鍔ㄦ�佸垪
+ List<DynamicColumnVO> dynamicColumns = result.getDynamicColumnList();
+ if (!dynamicColumns.isEmpty()) {
+ for (DynamicColumnVO dynamicColumnVO : dynamicColumns) {
tag.append(dynamicColumnVO.getColumnValue()).append("銆�");
}
}
- // 鍒犻櫎瀛楃涓叉湯灏剧殑"銆�"
- if (tag.toString().endsWith("銆�")) {
- tag = new StringBuilder(tag.substring(0, tag.length() - 1));
+
+ // 绉婚櫎鏈熬鐨�"銆�"
+ if (tag.length() > 0) {
+ tag.setLength(tag.length() - 1);
}
videoDailyExp.setTag(tag.toString());
+ // 璁剧疆鍦ㄧ嚎鏁版嵁
try {
+ // 浠庨鏋勫缓鐨凪ap涓幏鍙栵紝閬垮厤姣忔杩囨护
+ List<TMonitorResult> onlines = noToOnlineMap.getOrDefault(result.getNo(), Collections.emptyList());
setOnlineDaily(videoDailyExp, result, onlines);
} catch (Exception e) {
- log.error(e.getMessage());
+ log.error("璁剧疆鍦ㄧ嚎鏁版嵁寮傚父", e);
}
+
videoDailyExps.add(videoDailyExp);
}
- ExcelExp excelExp = new ExcelExp(
- areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName(),
- videoDailyExps,
- VideoDailyExp.class
- );
- mysheet.add(excelExp);
+ // 瀛樺偍缁撴灉鍒扮嚎绋嬪畨鍏ㄧ殑Map
+ deptExpMap.put(currentDeptId, videoDailyExps);
-
- return videoDailyExps;
+ return new ExcelExp(areaName, videoDailyExps, VideoDailyExp.class);
}, threadPoolTaskExecutor);
+
futures.add(future);
- map.put(deptId,future.join());
}
- // 鑾峰彇鍏ㄩ噺鏁版嵁
- List<VideoDailyExp> totalExps = futures.stream()
- .map(CompletableFuture::join)
+
+ // 绛夊緟鎵�鏈夊苟琛屼换鍔″畬鎴�
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+
+ // 鏀堕泦鎵�鏈夐儴闂ㄧ殑ExcelExp缁撴灉
+ for (CompletableFuture<ExcelExp> future : futures) {
+ ExcelExp excelExp = future.join();
+ if (excelExp != null) {
+ mysheet.add(excelExp);
+ }
+ }
+
+ // 鑾峰彇鍏ㄩ噺鏁版嵁骞舵坊鍔�"鍏ㄩ噺"sheet
+ List<VideoDailyExp> totalExps = deptExpMap.values().stream()
.flatMap(List::stream)
.collect(Collectors.toList());
- ExcelExp excelExp = new ExcelExp("鍏ㄩ噺", totalExps, VideoDailyExp.class);
- mysheet.add(excelExp);
- long face = totalExps.stream().filter(item -> item.getType().contains("1")).count();
- long car = totalExps.stream().filter(item -> item.getType().contains("2")).count();
- long video = totalExps.stream().filter(item -> item.getType().contains("3")).count();
- log.error("浜鸿劯鏁�:{}",face);
- log.error("car鏁�:{}",car);
- log.error("video鏁�:{}",video);
- //娣诲姞鏂扮殑sheet 绂荤嚎鏁扮粺璁¤〃
- List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>();
+ mysheet.add(new ExcelExp("鍏ㄩ噺", totalExps, VideoDailyExp.class));
- //鍦ㄧ嚎鐜囩粺璁¤〃
- List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>();
-
- for (Integer deptId : map.keySet()){
- List<VideoDailyExp> list = map.get(deptId);
- AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
- // 娣诲姞绂荤嚎琛ㄨ褰�
- //璁惧绫诲瀷 1浜鸿劯 2杞﹁締 3瑙嗛
- //浜鸿劯
- log.error("浼犲叆閮ㄩ棬闆嗗悎澶у皬:{} + 閮ㄩ棬id:{}" ,list.size(),deptId);
- VideoTypeOffOnlineExp faceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum);
- //鍗″彛
- VideoTypeOffOnlineExp carVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum);
- //瑙嗛
- VideoTypeOffOnlineExp videoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum);
-
- VideoOnlineRateExp faceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum);
- //鍗″彛
- VideoOnlineRateExp carVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum);
- //瑙嗛
- VideoOnlineRateExp VideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum);
-
-
- //灏嗚鍖哄煙绫讳笁绉嶈澶囩被鍨嬬殑 淇℃伅 鏀惧叆 excel瀵硅薄鍐�
- //鏀惧叆褰撳墠鍖哄煙鐨勪汉鑴歌澶囩浉鍏宠缁�
- videoTypeOffOnlineExps.add(faceVideoTypeOffOnlineExp);
- //鏀惧叆褰撳墠鍖哄煙鐨勮溅杈嗚澶囩浉鍏宠缁�
- videoTypeOffOnlineExps.add(carVideoTypeOffOnlineExp);
- //鏀惧叆褰撳墠鍖哄煙鐨勮棰戣澶囩浉鍏宠缁�
- videoTypeOffOnlineExps.add(videoTypeOffOnlineExp);
-
- videoOnlineRateExps.add(faceVideoOnlineRateExp);
- videoOnlineRateExps.add(carVideoOnlineRateExp);
- videoOnlineRateExps.add(VideoOnlineRateExp);
+ // 缁熻鍚勭被鍨嬭澶囨暟閲�
+ long face = 0, car = 0, video = 0;
+ for (VideoDailyExp exp : totalExps) {
+ String type = exp.getType();
+ if (type.contains("1")) face++;
+ if (type.contains("2")) car++;
+ if (type.contains("3")) video++;
}
- //璁$畻鑷础甯傚悎璁�
- //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚�
- List<VideoTypeOffOnlineExp> allVideoTypeOffOnlineExps = new ArrayList<>();
- //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚�
- List<VideoOnlineRateExp> allVideoOnlineRateExps = new ArrayList<>();
+ log.info("浜鸿劯鏁�:{}", face);
+ log.info("car鏁�:{}", car);
+ log.info("video鏁�:{}", video);
- //鎵�鏈夌绾挎暟鎹腑锛屽悇鍖鸿澶囦负浜鸿劯鐨勫璞� 鍚堣瑁呴厤瀵硅薄
- VideoTypeOffOnlineExp allFaceVideosOffline = new VideoTypeOffOnlineExp();
- setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allFaceVideosOffline,"浜鸿劯");
+ // 澶勭悊绂荤嚎鏁扮粺璁″拰鍦ㄧ嚎鐜囩粺璁�
+ List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>();
+ List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>();
- VideoTypeOffOnlineExp allCarVideosOffline = new VideoTypeOffOnlineExp();
- setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allCarVideosOffline,"鍗″彛");
+ for (Map.Entry<Integer, List<VideoDailyExp>> entry : deptExpMap.entrySet()) {
+ Integer deptId = entry.getKey();
+ List<VideoDailyExp> list = entry.getValue();
+ AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromDept(deptId);
- VideoTypeOffOnlineExp allVideosOffline = new VideoTypeOffOnlineExp();
- setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allVideosOffline,"瑙嗛");
+ // 鎵归噺澶勭悊涓夌璁惧绫诲瀷
+ addDeviceStats(list, areaDeptEnum, "1", "浜鸿劯", videoTypeOffOnlineExps, videoOnlineRateExps);
+ addDeviceStats(list, areaDeptEnum, "2", "鍗″彛", videoTypeOffOnlineExps, videoOnlineRateExps);
+ addDeviceStats(list, areaDeptEnum, "3", "瑙嗛", videoTypeOffOnlineExps, videoOnlineRateExps);
+ }
- allVideoTypeOffOnlineExps.add(allFaceVideosOffline);
- allVideoTypeOffOnlineExps.add(allCarVideosOffline);
- allVideoTypeOffOnlineExps.add(allVideosOffline);
+ // 璁$畻鍚堣鏁版嵁
+ addTotalStats(videoTypeOffOnlineExps, videoOnlineRateExps, face, car, video);
- //鎵�鏈夊湪绾挎暟鎹� 鍚堣瑁呴厤瀵硅薄
- VideoOnlineRateExp allFaceVideosOnline = new VideoOnlineRateExp();
- setAllVideoTypeOnlineExpCount(face,videoOnlineRateExps,allFaceVideosOnline,"浜鸿劯");
+ // 娣诲姞缁熻sheet
+ mysheet.add(new ExcelExp("绂荤嚎鏁扮粺璁�", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class));
+ mysheet.add(new ExcelExp("鍦ㄧ嚎鐜囩粺璁�", videoOnlineRateExps, VideoOnlineRateExp.class));
-
- VideoOnlineRateExp allCarVideosOnline = new VideoOnlineRateExp();
- setAllVideoTypeOnlineExpCount(car,videoOnlineRateExps,allCarVideosOnline,"鍗″彛");
-
- VideoOnlineRateExp allVideosOnline = new VideoOnlineRateExp();
- setAllVideoTypeOnlineExpCount(video,videoOnlineRateExps,allVideosOnline,"瑙嗛");
-
-
- allVideoOnlineRateExps.add(allFaceVideosOnline);
- allVideoOnlineRateExps.add(allCarVideosOnline);
- allVideoOnlineRateExps.add(allVideosOnline);
-
- videoTypeOffOnlineExps.addAll(allVideoTypeOffOnlineExps);
- videoOnlineRateExps.addAll(allVideoOnlineRateExps);
- log.error("鎵撳嵃璁$畻绂荤嚎鐨勪俊鎭�:{}" ,videoTypeOffOnlineExps );
- log.error("鎵撳嵃鍦ㄧ嚎鐨勪俊鎭�:{}" ,videoOnlineRateExps );
- //娣诲姞鍚堣鏁版嵁
-
- ExcelExp excelTypeOffLineExp = new ExcelExp("绂荤嚎鏁扮粺璁�", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class);
- mysheet.add(excelTypeOffLineExp);
-
- //娣诲姞鍦ㄧ嚎鐜囪〃
- ExcelExp excelOnlineRateExp = new ExcelExp("鍦ㄧ嚎鐜囩粺璁�",videoOnlineRateExps, VideoOnlineRateExp.class);
- mysheet.add(excelOnlineRateExp);
-
+ // 瀵煎嚭Excel
ExcelUtilManySheet<List<ExcelExp>> util = new ExcelUtilManySheet<>(mysheet);
util.exportExcelManySheet(response, mysheet);
- log.error("瀵煎嚭缁撴潫");
+ log.info("瀵煎嚭缁撴潫");
}
+
+ // 鏂板杈呭姪鏂规硶锛氭壒閲忔坊鍔犺澶囩粺璁′俊鎭�
+ private void addDeviceStats(List<VideoDailyExp> list, AreaDeptEnum areaDeptEnum,
+ String typeCode, String typeName,
+ List<VideoTypeOffOnlineExp> offLineList,
+ List<VideoOnlineRateExp> onlineList) {
+ offLineList.add(getListOfflineCountInfo(list, typeCode, areaDeptEnum));
+ onlineList.add(getListOnLineCountInfo(list, typeCode, areaDeptEnum));
+ }
+
+ // 鏂板杈呭姪鏂规硶锛氭坊鍔犲悎璁$粺璁�
+ private void addTotalStats(List<VideoTypeOffOnlineExp> offLineList,
+ List<VideoOnlineRateExp> onlineList,
+ long face, long car, long video) throws NoSuchFieldException, IllegalAccessException {
+ // 绂荤嚎缁熻鍚堣
+ VideoTypeOffOnlineExp allFaceVideosOffline = new VideoTypeOffOnlineExp();
+ setAllVideoTypeOffOnlineExpCount(offLineList, allFaceVideosOffline, "浜鸿劯");
+
+ VideoTypeOffOnlineExp allCarVideosOffline = new VideoTypeOffOnlineExp();
+ setAllVideoTypeOffOnlineExpCount(offLineList, allCarVideosOffline, "鍗″彛");
+
+ VideoTypeOffOnlineExp allVideosOffline = new VideoTypeOffOnlineExp();
+ setAllVideoTypeOffOnlineExpCount(offLineList, allVideosOffline, "瑙嗛");
+
+ offLineList.add(allFaceVideosOffline);
+ offLineList.add(allCarVideosOffline);
+ offLineList.add(allVideosOffline);
+
+ // 鍦ㄧ嚎缁熻鍚堣
+ VideoOnlineRateExp allFaceVideosOnline = new VideoOnlineRateExp();
+ setAllVideoTypeOnlineExpCount(face, onlineList, allFaceVideosOnline, "浜鸿劯");
+
+ VideoOnlineRateExp allCarVideosOnline = new VideoOnlineRateExp();
+ setAllVideoTypeOnlineExpCount(car, onlineList, allCarVideosOnline, "鍗″彛");
+
+ VideoOnlineRateExp allVideosOnline = new VideoOnlineRateExp();
+ setAllVideoTypeOnlineExpCount(video, onlineList, allVideosOnline, "瑙嗛");
+
+ onlineList.add(allFaceVideosOnline);
+ onlineList.add(allCarVideosOnline);
+ onlineList.add(allVideosOnline);
+ }
+
+
+
//绂荤嚎璁惧鏁版嵁锛屽悎璁″璞★紝淇℃伅瑁呴厤
public void setAllVideoTypeOffOnlineExpCount(List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps,
VideoTypeOffOnlineExp videoTypeOffOnlineExp,
--
Gitblit v1.8.0