From c6976365d5bfb39a32db8b541b1fe3ceb30c7826 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 14 二月 2025 10:03:17 +0800 Subject: [PATCH] Merge branch 'dev' --- ycl-server/src/main/java/com/ycl/task/ContractTask.java | 315 +++++----- ycl-server/src/main/resources/mapper/zgyw/WorkOrderErrorTypeMapper.xml | 21 ycl-server/src/main/java/com/ycl/task/PlatformTask.java | 18 ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java | 27 ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml | 1 ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java | 1093 +++++++++++++++++++++---------------- ycl-server/src/main/java/com/ycl/platform/mapper/WorkOrderErrorTypeMapper.java | 9 ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 2 ycl-pojo/src/main/java/com/ycl/platform/domain/excel/CalculateExport.java | 6 ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java | 104 +++ ycl-server/src/main/java/com/ycl/api/DH/utils/DHApi.java | 16 ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java | 5 ycl-server/src/main/java/com/ycl/task/OsdTask.java | 20 ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java | 42 + ycl-server/src/main/java/com/ycl/task/UYTask.java | 4 ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml | 2 ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 13 17 files changed, 1,018 insertions(+), 680 deletions(-) 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 index a1bd3df..e8b6847 100644 --- 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 @@ -1,5 +1,6 @@ package com.ycl.platform.domain.excel; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.*; import com.alibaba.excel.enums.BooleanEnum; @@ -54,4 +55,9 @@ @ExcelProperty({"鑷础甯傚叕鍏辫棰戠洃鎺х郴缁熺画缁村悎鍚�", "閲戦"}) private BigDecimal money; + /** + * 鎵i櫎鍒嗘暟 + */ + @ExcelIgnore + private BigDecimal calcFraction; } diff --git a/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java b/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java index 5d3b406..eb030f7 100644 --- a/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java +++ b/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java @@ -2,6 +2,7 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; +import com.sun.jna.Structure; import com.sun.jna.ptr.IntByReference; import com.ycl.api.DH.lib.NetSDKLib; import com.ycl.api.DH.lib.NetSDKLib.LLong; @@ -17,12 +18,17 @@ import java.io.File; import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.List; +import static com.ycl.api.DH.lib.NetSDKLib.CFG_CMD_VIDEOWIDGET; +import static com.ycl.api.DH.lib.NetSDKLib.NET_DEV_VIDEO_OSD_CFG; import static com.ycl.api.DH.lib.NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_CUSTOMTITLE; import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_GBMODE; @@ -153,14 +159,13 @@ return bRet; } - public static OSDResult getOsd(String serialNumber,LLong loginId) { + public static OSDResult getOsd(String serialNumber, LLong loginId) { OSDResult osdResult = new OSDResult(); NetSDKLib.NET_TIME deviceTime = new NetSDKLib.NET_TIME(); if (!netsdk.CLIENT_QueryDeviceTime(loginId, deviceTime, 3000)) { // log.error("CLIENT_QueryDeviceTime Failed!" + ToolKits.getErrorCodePrint()); return null; } - log.info("OSD鏃堕棿鍘熷鏁版嵁鏍煎紡,{},toString鏍煎紡{}",deviceTime,deviceTime.toStringTime()); Date checkTime = new Date(); osdResult.setCheckTime(checkTime); String date = deviceTime.toStringTime(); @@ -173,7 +178,6 @@ // log.error("鏃堕棿瑙f瀽澶辫触"); } NET_CFG_GBMODE_INFO reserve = new NET_CFG_GBMODE_INFO(); - NET_CFG_GBMODE_INFO osdInfo = new NET_CFG_GBMODE_INFO(); osdInfo.write(); boolean b = false; @@ -183,9 +187,9 @@ * 瀵逛簬澶у崕鏉ヨ锛� 鍥芥爣鍊�7: 0/鍏ㄦ櫙/閫氶亾1 1/缁嗚妭/閫氶亾2 * 瀹囪鍗曢�氶亾涓嶈�冭檻 */ - if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All ) { + if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) { b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); - }else if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail){ + } else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) { b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 1, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer()); } @@ -196,9 +200,8 @@ osdInfo.read(); NET_GBMODE_CUSTOMTITLE_INFO[] stuCustomTitle = osdInfo.stuCustomTitle; for (NET_GBMODE_CUSTOMTITLE_INFO title : stuCustomTitle) { - log.info("OSD鍘熷鏁版嵁鏍煎紡{}",title); String position = new String(title.szPositon, StandardCharsets.UTF_8).trim(); - if("LeftDown".equals(position)) { + if ("LeftDown".equals(position)) { NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; for (NET_TITLE_OSD_INFO osd : stuOSD) { String osdStr = null; @@ -208,7 +211,7 @@ osdResult.setOSD4(osdStr); } } - }else if("RightDown".equals(position)){ + } else if ("RightDown".equals(position)) { NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD; int num = 0; for (NET_TITLE_OSD_INFO osd : stuOSD) { @@ -216,13 +219,13 @@ osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim(); // log.info("TEXT锛�"+osdStr); if (!StringUtils.isEmpty(osdStr)) { - if(num ==0){ + if (num == 0) { osdResult.setOSD1(osdStr); - }else if(num ==1){ + } else if (num == 1) { osdResult.setOSD2(osdStr); - }else if(num ==2){ + } else if (num == 2) { osdResult.setOSD3(osdStr); - }else if(num ==3){ + } else if (num == 3) { osdResult.setName(osdStr); } } @@ -235,4 +238,81 @@ return osdResult; } + /** + * 閽堝鍒╂棫璁惧鑾峰彇OSD鐨勬柟娉� + * @param serialNumber + * @param loginId + * @return + */ + public static OSDResult getOsdOld(String serialNumber, LLong loginId) { + OSDResult result = new OSDResult(); + NetSDKLib.NET_OSD_CUSTOM_TITLE osdInfo4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); + osdInfo4.emOsdBlendType = NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN; + NetSDKLib.NET_OSD_CUSTOM_TITLE reserve4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE(); + osdInfo4.write(); + boolean e = false; + e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); + if (!e) { + log.error("e涓虹┖,灏濊瘯鍙︿竴涓�氶亾"); + e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer()); + } + if(e) { + osdInfo4.read(); + NetSDKLib.NET_CUSTOM_TITLE_INFO[] stuCustomTitle = osdInfo4.stuCustomTitle; + for (NetSDKLib.NET_CUSTOM_TITLE_INFO net_custom_title_info : stuCustomTitle) { + String name = new String(net_custom_title_info.szText, StandardCharsets.UTF_8).trim(); + log.info("name:{}",name); + if(StringUtils.isNotEmpty(name) && name.contains("|")){ + String[] osdNames = name.split("\\|"); + //鍓旈櫎鎺夌┖涓� +// List<String> nonEmptyList = new ArrayList<>(); +// for (String osd : osdNames) { +// if (StringUtils.isNotEmpty(osd)) { +// nonEmptyList.add(osd); +// } +// } + result.setOSD1(osdNames[0]); + result.setOSD2(osdNames[1]); + result.setOSD3(osdNames[2]); + result.setName(osdNames[3]); + } + } + }else { + log.error(serialNumber,"鍒╂棫osd涓虹┖"); + } + return result; + } + + /** + * 鑾峰彇鍗曚釜閰嶇疆 + * @param hLoginHandle 鐧婚檰鍙ユ焺 + * @param nChn 閫氶亾鍙凤紝-1 琛ㄧず鍏ㄩ�氶亾 + * @param strCmd 閰嶇疆鍚嶇О + * @param cmdObject 閰嶇疆瀵瑰簲鐨勭粨鏋勪綋瀵硅薄 + * @return 鎴愬姛杩斿洖 true + */ + public static boolean GetDevConfig(LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) { + boolean result = false; + IntByReference error = new IntByReference(0); + int nBufferLen = 2*1024*1024; + byte[] strBuffer = new byte[nBufferLen]; + + if(netsdk.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,3000,null)) { + cmdObject.write(); + if (netsdk.CLIENT_ParseData(strCmd, strBuffer, cmdObject.getPointer(), + cmdObject.size(), null)) { + cmdObject.read(); + result = true; + } else { + System.err.println("Parse " + strCmd + " Config Failed!" + ToolKits.getErrorCodePrint()); + result = false; + } + } else { + System.err.println("璋冪敤澶辫触"); + result = false; + } + + return result; + } + } diff --git a/ycl-server/src/main/java/com/ycl/api/DH/utils/DHApi.java b/ycl-server/src/main/java/com/ycl/api/DH/utils/DHApi.java index b53a7eb..c25df84 100644 --- a/ycl-server/src/main/java/com/ycl/api/DH/utils/DHApi.java +++ b/ycl-server/src/main/java/com/ycl/api/DH/utils/DHApi.java @@ -15,7 +15,23 @@ return null; } OSDResult osd = LoginModule.getOsd(serialNumber,loginId); + if(osd!=null && osd.getOSD1() ==null &&osd.getOSD2()==null && osd.getOSD3()==null &&osd.getName()==null) { + OSDResult osdOld = LoginModule.getOsdOld(serialNumber, loginId); + osd.setOSD1(osdOld.getOSD1()); + osd.setOSD2(osdOld.getOSD2()); + osd.setOSD3(osdOld.getOSD3()); + osd.setName(osdOld.getName()); + } LoginModule.logout(loginId); return osd; } + public static OSDResult getOsdOld(String serialNumber,String ip, String userName, String password){ + NetSDKLib.LLong loginId = LoginModule.login(ip, 80, userName, password); + if(loginId.longValue() ==0){ + return null; + } + OSDResult osdOld = LoginModule.getOsdOld(serialNumber, loginId); + LoginModule.logout(loginId); + return osdOld; + } } diff --git a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java index 9398f7d..9a8ed07 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java +++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java @@ -7,6 +7,7 @@ import com.ycl.platform.mapper.TMonitorMapper; import com.ycl.platform.service.ICheckIndexVideoService; import constant.ApiConstants; +import constant.CheckConstants; import constant.CheckThreadConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -18,6 +19,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼銆侀儴绾х偣浣嶅湪绾跨巼 @@ -65,7 +67,16 @@ } } }); - + //閲嶇偣鎸囨尌鍥惧儚鐗规畩澶勭悊锛岀粺涓�閲囩敤鍖哄幙鏁版嵁 + Map<Long, BigDecimal> keyCommandMap = checkIndexVideos.stream().filter(checkIndexVideo -> CheckConstants.Examine_Tag_County.equals(checkIndexVideo.getExamineTag())) + .collect(Collectors.toMap(checkIndexVideo -> checkIndexVideo.getDeptId(), checkIndexVideo -> checkIndexVideo.getKeyCommandImageOnline())); + for (CheckIndexVideo checkIndexVideo : checkIndexVideos) { + //鏇挎崲鐪佸巺鍜岄儴绾� 閲嶇偣鎸囨尌鍥惧儚 + if(CheckConstants.Examine_Tag_Province.equals(checkIndexVideo.getExamineTag()) || CheckConstants.Examine_Tag_Dept.equals(checkIndexVideo.getExamineTag())){ + BigDecimal keyCommand = keyCommandMap.get(checkIndexVideo.getDeptId()); + checkIndexVideo.setKeyCommandImageOnline(keyCommand); + } + } checkIndexVideoService.saveOrUpdateBatch(checkIndexVideos); } diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/WorkOrderErrorTypeMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/WorkOrderErrorTypeMapper.java index 16efe99..01b10e5 100644 --- a/ycl-server/src/main/java/com/ycl/platform/mapper/WorkOrderErrorTypeMapper.java +++ b/ycl-server/src/main/java/com/ycl/platform/mapper/WorkOrderErrorTypeMapper.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.platform.domain.entity.WorkOrderErrorType; +import com.ycl.platform.domain.vo.WorkOrderVO; import com.ycl.system.entity.SysDictData; import org.apache.ibatis.annotations.Param; import org.springframework.security.core.parameters.P; @@ -87,12 +88,12 @@ * @return */ int addMany(@Param("errorTypeList") List<WorkOrderErrorType> errorTypeList); - + List<SysDictData> getErrorList(@Param("workOrderNo") String workOrderNo); /** - * 鑾峰彇鏁呴殰绫诲瀷锛岃繛琛ㄥ瓧鍏� + * 鑾峰彇澶氫釜宸ュ崟鏁呴殰绫诲瀷 * - * @param workOrderNo + * @param workOrderNos * @return */ - List<SysDictData> getErrorList(@Param("workOrderNo") String workOrderNo); + List<WorkOrderVO> getErrorListByNumbers(@Param("workOrderNos") List<String> workOrderNos); } 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 9787572..0db7f41 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 @@ -238,6 +238,11 @@ .add(BigDecimal.valueOf(100)) // 鍔犱笂100 .setScale(1, RoundingMode.HALF_UP)); list.add(calculateExport); + list.forEach(item->{ + if("纭繚褰曞儚瀹屾暣涓嶅畾鏈熷鎵�鏈夌偣浣嶅綍鍍忓畬鏁存�ф娊鏌�".equals(item.getRuleName())){ + item.setNum(item.getScore().abs().divide(item.getCalcFraction(),0,RoundingMode.HALF_UP).intValue()); + } + }); // 鑾峰彇瑙勫垯 List<CalculateRule> ruleList = calculateRuleService.list(new LambdaQueryWrapper<CalculateRule>().eq(CalculateRule::getContractId, contractId)); // 杈撳嚭鏂囦欢 diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java index dbf36b9..f8ae9e7 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/DataCenterServiceImpl.java @@ -26,6 +26,7 @@ import com.ycl.system.page.PageUtil; import com.ycl.utils.DateUtils; import com.ycl.utils.MongoUtil; +import com.ycl.utils.StringUtils; import com.ycl.utils.bean.BeanUtils; import com.ycl.utils.poi.ExcelUtil; import constant.ApiConstants; @@ -115,10 +116,9 @@ item.setOnlineStr("鏈煡"); } List<String> offLineTime = item.getOffLineTimeStr(); - if(!CollectionUtils.isEmpty(offLineTime)) { - //鍚庣画鍙互鏀规垚閰嶇疆鐨勭绾挎鏁�(鎻愬彇鍓峮娆★紝n涓洪厤缃殑绂荤嚎娆℃暟) + if (!CollectionUtils.isEmpty(offLineTime)) { if (offLineTime.size() > 1) { - offLineTime = offLineTime.subList(0, 2); + offLineTime = offLineTime.subList(offLineTime.size() - 2, offLineTime.size()); } item.setOffLineTimeStr(offLineTime); } @@ -160,20 +160,24 @@ onlineCount = (Integer) result.getOrDefault("onlineCount", 0L); totalCount = offlineCount + unknownCount + onlineCount; } - /** 鏌ヨ褰撳ぉ鍦ㄧ嚎鐜� */ - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getSiteOnline) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// /** 鏌ヨ褰撳ぉ鍦ㄧ嚎鐜� */ +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getSiteOnline) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) +// .list(); +// +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); map.put("list", resultList); @@ -255,21 +259,24 @@ onlineCount = (Integer) result.getOrDefault("onlineCount", 0L); totalCount = offlineCount + unknownCount + onlineCount; } - - params.setDeptTag(1); - params.setDeviceType(1); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getMinistrySiteOnline) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) - .list(); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistrySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// params.setDeptTag(1); +// params.setDeviceType(1); +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getMinistrySiteOnline) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistrySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); map.put("list", resultList); @@ -353,18 +360,22 @@ onlineCount = (Integer) result.getOrDefault("onlineCount", 0L); totalCount = offlineCount + unknownCount + onlineCount; } - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getKeySiteOnline) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) - .list(); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getKeySiteOnline) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeySiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); map.put("list", resultList); @@ -449,19 +460,22 @@ onlineCount = (Integer) result.getOrDefault("onlineCount", 0L); totalCount = offlineCount + unknownCount + onlineCount; } - - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getKeyCommandImageOnline) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) - .list(); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyCommandImageOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getKeyCommandImageOnline) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, params.getStartTime(), params.getEndTime()) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyCommandImageOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); map.put("list", resultList); @@ -480,10 +494,10 @@ List<Criteria> andCriteria = MongoUtil.getAndCriteria(params, TIME_FIELD, likeFileds, null); Query query = new Query(); Criteria and = new Criteria(); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.TRUE)); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.FALSE)); } } @@ -503,12 +517,12 @@ //鎬绘暟 List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); - Document totalFilter = new Document("$and",dList1); + Document totalFilter = new Document("$and", dList1); //鏂拌澶囨暟 List<Document> dList2 = new ArrayList<>(2); setTag(params, dList2); - dList2.add(new Document("newDevice",Boolean.TRUE)); - Document newFilter = new Document("$and",dList2); + dList2.add(new Document("newDevice", Boolean.TRUE)); + Document newFilter = new Document("$and", dList2); List<Document> lists = Arrays.asList(totalFilter, newFilter); List<String> rList = lists.stream().map(filter -> { @@ -529,19 +543,23 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getMonitorRegistration) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorRegistration).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getMonitorRegistration) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorRegistration).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + BigDecimal rate = BigDecimal.ZERO; + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + rate = new BigDecimal(rList.get(0)).subtract(new BigDecimal(rList.get(1))).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } - rList.add(this.remove0(onlineRate)); + rList.add(this.remove0(rate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); map.put("list", resultVOS); @@ -562,8 +580,8 @@ Criteria and = new Criteria(); and.andOperator(andCriteria); query = Query.query(and); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("serialNumber.error").is(Boolean.FALSE)); andCriteria.add(Criteria.where("name.error").is(Boolean.FALSE)); andCriteria.add(Criteria.where("civilCode.error").is(Boolean.FALSE)); @@ -579,7 +597,7 @@ Criteria and2 = new Criteria(); and2.andOperator(andCriteria); query = Query.query(and2); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { Criteria c1 = Criteria.where("serialNumber.error").is(Boolean.TRUE); Criteria c2 = Criteria.where("name.error").is(Boolean.TRUE); Criteria c3 = Criteria.where("civilCode.error").is(Boolean.TRUE); @@ -612,26 +630,26 @@ //鎬绘暟 List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); - Document totalFilter = new Document("$and",dList1); + Document totalFilter = new Document("$and", dList1); //鍚堟牸鏁� List<Document> dList2 = new ArrayList<>(2); - dList2.add(new Document("serialNumber.error",Boolean.FALSE)); - dList2.add(new Document("name.error",Boolean.FALSE)); - dList2.add(new Document("civilCode.error",Boolean.FALSE)); - dList2.add(new Document("integrated_device.error",Boolean.FALSE)); - dList2.add(new Document("jkdwlx.error",Boolean.FALSE)); - dList2.add(new Document("latitude.error",Boolean.FALSE)); - dList2.add(new Document("longitude.error",Boolean.FALSE)); - dList2.add(new Document("macdz.error",Boolean.FALSE)); - dList2.add(new Document("name.error",Boolean.FALSE)); - dList2.add(new Document("sbzt.error",Boolean.FALSE)); - dList2.add(new Document("sxjcjqy.error",Boolean.FALSE)); - dList2.add(new Document("sxjgnlx.error",Boolean.FALSE)); - setTag(params,dList2); - Document qualifyFilter = new Document("$and",dList2); + dList2.add(new Document("serialNumber.error", Boolean.FALSE)); + dList2.add(new Document("name.error", Boolean.FALSE)); + dList2.add(new Document("civilCode.error", Boolean.FALSE)); + dList2.add(new Document("integrated_device.error", Boolean.FALSE)); + dList2.add(new Document("jkdwlx.error", Boolean.FALSE)); + dList2.add(new Document("latitude.error", Boolean.FALSE)); + dList2.add(new Document("longitude.error", Boolean.FALSE)); + dList2.add(new Document("macdz.error", Boolean.FALSE)); + dList2.add(new Document("name.error", Boolean.FALSE)); + dList2.add(new Document("sbzt.error", Boolean.FALSE)); + dList2.add(new Document("sxjcjqy.error", Boolean.FALSE)); + dList2.add(new Document("sxjgnlx.error", Boolean.FALSE)); + setTag(params, dList2); + Document qualifyFilter = new Document("$and", dList2); //涓嶅悎鏍兼暟 - List<Document> dList3 = new ArrayList<>(2); - setTag(params,dList3); + List<Document> dList3 = new ArrayList<>(2); + setTag(params, dList3); List<Document> errorConditions = new ArrayList<>(); errorConditions.add(new Document("serialNumber.error", new Document("$eq", Boolean.TRUE))); errorConditions.add(new Document("name.error", new Document("$eq", Boolean.TRUE))); @@ -667,19 +685,22 @@ } return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getMonitorQualification) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorQualification).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getMonitorQualification) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMonitorQualification).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); @@ -692,6 +713,7 @@ * 妗f鐣欏瓨鎬婚噺锛歮ongo瀛樼殑鎵�鏈夊幓閲嶅悗鐨勬。妗� * 褰撴棩妗f锛氬綋鏃ョ殑妗f * 妗f鑰冩牳姣� = 褰撴棩妗f/妗f鐣欏瓨鎬婚噺 + * * @param params * @return1 */ @@ -717,14 +739,14 @@ //鎬绘暟 List<Document> dList1 = new ArrayList<>(2); DataCenterQuery totalParams = new DataCenterQuery(); - BeanUtils.copyProperties(params,totalParams); + BeanUtils.copyProperties(params, totalParams); totalParams.setStartTime(null); setTag(totalParams, dList1); - Document totalFilter = new Document("$and",dList1); + Document totalFilter = new Document("$and", dList1); //褰撴棩妗f鏁� List<Document> dList2 = new ArrayList<>(2); setTag(params, dList2); - Document newFilter = new Document("$and",dList2); + Document newFilter = new Document("$and", dList2); List<Document> lists = Arrays.asList(totalFilter, newFilter); List<String> rList = lists.stream().map(filter -> { @@ -744,19 +766,22 @@ } return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getArchivesRate) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getArchivesRate).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getArchivesRate) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getArchivesRate).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", rList); @@ -782,10 +807,10 @@ MongoUtil.setPage(query, params, "createTime"); List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); //缈昏瘧琛屾斂鍖哄煙 - resultList.forEach(item->{ + resultList.forEach(item -> { String areaCode = item.getArealayername().substring(0, 6); AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromCode(areaCode); - if(areaDeptEnum!=null) item.setArealayername(areaDeptEnum.getName()); + if (areaDeptEnum != null) item.setArealayername(areaDeptEnum.getName()); }); // 缁熻鏁伴噺 MongoDatabase database = mongoTemplate.getDb(); @@ -812,18 +837,18 @@ } return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getVideoAvailable) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); - } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getVideoAvailable) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } //鍔犱竴涓�绘暟 int totalCount = 0; for (String s : resultCount) { @@ -831,6 +856,10 @@ } resultCount.add(0, totalCount + ""); + BigDecimal onlineRate = BigDecimal.ZERO; + if (!StringUtils.isEmpty(resultCount.get(0)) && !"0".equals(resultCount.get(0))) { + onlineRate = new BigDecimal(resultCount.get(1)).divide(new BigDecimal(resultCount.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); + } resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -857,10 +886,10 @@ MongoUtil.setPage(query, params, "createTime"); List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); //缈昏瘧琛屾斂鍖哄煙 - resultList.forEach(item->{ + resultList.forEach(item -> { String areaCode = item.getArealayername().substring(0, 6); AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromCode(areaCode); - if(areaDeptEnum!=null) item.setArealayername(areaDeptEnum.getName()); + if (areaDeptEnum != null) item.setArealayername(areaDeptEnum.getName()); }); // 缁熻鏁伴噺 MongoDatabase database = mongoTemplate.getDb(); @@ -889,24 +918,28 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getMinistryVideoAvailable) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistryVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); - } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getMinistryVideoAvailable) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getMinistryVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } //鍔犱竴涓�绘暟 int totalCount = 0; for (String s : resultCount) { totalCount += Integer.parseInt(s); } resultCount.add(0, totalCount + ""); + BigDecimal onlineRate = BigDecimal.ZERO; + if (!StringUtils.isEmpty(resultCount.get(0)) && !"0".equals(resultCount.get(0))) { + onlineRate = new BigDecimal(resultCount.get(1)).divide(new BigDecimal(resultCount.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); + } resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", resultCount); @@ -932,10 +965,10 @@ MongoUtil.setPage(query, params, "createTime"); List<RecordMetaDSumResult> resultList = mongoTemplate.find(query, RecordMetaDSumResult.class); //缈昏瘧琛屾斂鍖哄煙 - resultList.forEach(item->{ + resultList.forEach(item -> { String areaCode = item.getArealayername().substring(0, 6); AreaDeptEnum areaDeptEnum = AreaDeptEnum.fromCode(areaCode); - if(areaDeptEnum!=null) item.setArealayername(areaDeptEnum.getName()); + if (areaDeptEnum != null) item.setArealayername(areaDeptEnum.getName()); }); // 缁熻鏁伴噺 MongoDatabase database = mongoTemplate.getDb(); @@ -964,24 +997,28 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getKeyVideoAvailable) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); - } +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getKeyVideoAvailable) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyVideoAvailable).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } //鍔犱竴涓�绘暟 int totalCount = 0; for (String s : resultCount) { totalCount += Integer.parseInt(s); } resultCount.add(0, totalCount + ""); + BigDecimal onlineRate = BigDecimal.ZERO; + if (!StringUtils.isEmpty(resultCount.get(0)) && !"0".equals(resultCount.get(0))) { + onlineRate = new BigDecimal(resultCount.get(1)).divide(new BigDecimal(resultCount.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); + } resultCount.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", resultCount); @@ -1030,7 +1067,7 @@ query = Query.query(and); //涓嬫媺妗嗘爣娉ㄦ纭煡璇㈡潯浠� if (params.getOption() != null) { - if(params.getOption()==1) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("osdNameCorrect").is(1)); andCriteria.add(Criteria.where("osdTimeCorrect").is(1)); andCriteria.add(Criteria.where("osdProvinceCorrect").is(1)); @@ -1039,7 +1076,7 @@ Criteria and2 = new Criteria(); and2.andOperator(andCriteria); query = Query.query(and2); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { // 浣跨敤$or鏉′欢杩炴帴澶氫釜瀛楁妫�鏌ワ紝姣忎釜瀛楁妫�鏌ユ槸鍚︾瓑浜�-1 Criteria c1 = Criteria.where("osdNameCorrect").is(-1); Criteria c2 = Criteria.where("osdTimeCorrect").is(-1); @@ -1049,7 +1086,7 @@ Criteria orOperator = new Criteria().orOperator(c1, c2, c3, c4, c5); orOperator.andOperator(andCriteria); query = Query.query(orOperator); - }else { + } else { Criteria c1 = Criteria.where("osdNameCorrect").is(0); Criteria c2 = Criteria.where("osdTimeCorrect").is(0); Criteria c3 = Criteria.where("osdProvinceCorrect").is(0); @@ -1086,7 +1123,7 @@ Document osdCorrectFilter = new Document("$and", dList1); //寮傚父鏁� List<Document> dList2 = new ArrayList<>(2); - setTag(params,dList2); + setTag(params, dList2); Document importantTagCondition = new Document("importantTag", Boolean.TRUE); dList2.add(importantTagCondition); List<Document> errorConditions = new ArrayList<>(); @@ -1100,7 +1137,7 @@ Document osdErrorFilter = new Document("$and", dList2); //鏈煡鏁� List<Document> dList3 = new ArrayList<>(2); - setTag(params,dList3); + setTag(params, dList3); dList3.add(importantTagCondition); List<Document> unknownConditions = new ArrayList<>(); unknownConditions.add(new Document("osdNameCorrect", new Document("$eq", 0))); @@ -1113,7 +1150,7 @@ dList3.add(unknownFilter); Document osdUnknownFilter = new Document("$and", dList3); - List<Document> lists = Arrays.asList(osdFilter, osdCorrectFilter, osdErrorFilter,osdUnknownFilter); + List<Document> lists = Arrays.asList(osdFilter, osdCorrectFilter, osdErrorFilter, osdUnknownFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1132,17 +1169,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getKeyAnnotationAccuracy) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getKeyAnnotationAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyAnnotationAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyAnnotationAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1161,7 +1202,7 @@ query = Query.query(and); //涓嬫媺妗嗘爣娉ㄦ纭煡璇㈡潯浠� if (params.getOption() != null) { - if(params.getOption()==1) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("osdNameCorrect").is(1)); andCriteria.add(Criteria.where("osdTimeCorrect").is(1)); andCriteria.add(Criteria.where("osdProvinceCorrect").is(1)); @@ -1170,7 +1211,7 @@ Criteria and2 = new Criteria(); and2.andOperator(andCriteria); query = Query.query(and2); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { // 浣跨敤$or鏉′欢杩炴帴澶氫釜瀛楁妫�鏌ワ紝姣忎釜瀛楁妫�鏌ユ槸鍚︾瓑浜�-1 Criteria c1 = Criteria.where("osdNameCorrect").is(-1); Criteria c2 = Criteria.where("osdTimeCorrect").is(-1); @@ -1180,7 +1221,7 @@ Criteria orOperator = new Criteria().orOperator(c1, c2, c3, c4, c5); orOperator.andOperator(andCriteria); query = Query.query(orOperator); - }else { + } else { Criteria c1 = Criteria.where("osdNameCorrect").is(0); Criteria c2 = Criteria.where("osdTimeCorrect").is(0); Criteria c3 = Criteria.where("osdProvinceCorrect").is(0); @@ -1212,7 +1253,7 @@ } /** - * 瑙嗛锛氭牎鏃舵纭巼 + * 瑙嗛锛氭牎鏃舵纭巼(鍋滅敤) * * @param params * @return @@ -1249,11 +1290,11 @@ Query query = MongoUtil.getQuery(params, "checkTime", likeFileds, null); //涓嬫媺妗嗘爣娉ㄦ纭煡璇㈡潯浠� if (params.getOption() != null) { - if(params.getOption()==1) { - query.addCriteria(Criteria.where("osdTimeCorrect").is(1)); - }else if(params.getOption()==-1){ + if (params.getOption() == 1) { + query.addCriteria(Criteria.where("osdTimeCorrect").is(1)); + } else if (params.getOption() == -1) { query.addCriteria(Criteria.where("osdTimeCorrect").is(-1)); - }else { + } else { query.addCriteria(Criteria.where("osdTimeCorrect").is(0)); } } @@ -1285,7 +1326,7 @@ Document osdCorrectFilter = new Document("$and", dList1); //寮傚父鏁� List<Document> dList2 = new ArrayList<>(2); - setTag(params,dList2); + setTag(params, dList2); Document importantTagCondition = new Document("importantTag", Boolean.TRUE); dList2.add(importantTagCondition); List<Document> errorConditions = new ArrayList<>(); @@ -1299,7 +1340,7 @@ Document osdErrorFilter = new Document("$and", dList2); //鏈煡鏁� List<Document> dList3 = new ArrayList<>(2); - setTag(params,dList3); + setTag(params, dList3); dList3.add(importantTagCondition); List<Document> unknownConditions = new ArrayList<>(); unknownConditions.add(new Document("osdNameCorrect", new Document("$eq", 0))); @@ -1312,7 +1353,7 @@ dList3.add(unknownFilter); Document osdUnknownFilter = new Document("$and", dList3); - List<Document> lists = Arrays.asList(osdFilter, osdCorrectFilter, osdErrorFilter,osdUnknownFilter); + List<Document> lists = Arrays.asList(osdFilter, osdCorrectFilter, osdErrorFilter, osdUnknownFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1331,17 +1372,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) - .select(CheckIndexVideo::getKeyTimingAccuracy) - .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexVideo> videoList = new LambdaQueryChainWrapper<>(checkIndexVideoService.getBaseMapper()) +// .select(CheckIndexVideo::getKeyTimingAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexVideo::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexVideo::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexVideo::getKeyTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1363,21 +1408,21 @@ Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); //鍔燚ataType涓鸿溅杈� query.addCriteria(Criteria.where("dataType").is(ApiConstants.HK_DataType_CAR)); - if(params.getOption()!=null){ - if(ApiConstants.HK_SnapCount_ResultType_Normal.equals(params.getOption())) { + if (params.getOption() != null) { + if (ApiConstants.HK_SnapCount_ResultType_Normal.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Normal)); - }else if(ApiConstants.HK_SnapCount_ResultType_Null.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Null.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Null)); - }else if(ApiConstants.HK_SnapCount_ResultType_Descent.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Descent.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Descent)); - }else if(ApiConstants.HK_SnapCount_ResultType_Low.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Low.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Low)); } } long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); MongoUtil.setPage(query, params, TIME_FIELD); List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, SnapshotDataMonitorResult.class); - resultList.forEach(item ->item.setResultTypeText(item.getResultTypeText())); + resultList.forEach(item -> item.setResultTypeText(item.getResultTypeText())); // 缁熻鏁伴噺 MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor"); @@ -1390,10 +1435,19 @@ dList3.add(new Document("resultType", new Document("$eq", 2))); dList3.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); setTag(params, dList3); - - Document noDataFilter = new Document("$and", dList2); - Document trFilter = new Document("$and", dList3); - List<Document> lists = Arrays.asList(noDataFilter, trFilter); + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("resultType", new Document("$eq", 3))); + dList4.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); + setTag(params, dList4); + List<Document> dList5 = new ArrayList<>(2); + dList5.add(new Document("resultType", new Document("$eq", 4))); + dList5.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); + setTag(params, dList5); + Document normalFilter = new Document("$and", dList2); + Document noDataFilter = new Document("$and", dList3); + Document downFilter = new Document("$and", dList4); + Document lessFilter = new Document("$and", dList5); + List<Document> lists = Arrays.asList(normalFilter, noDataFilter,downFilter,lessFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1426,18 +1480,27 @@ for (Document doc : result) { dataCount = doc.getInteger("dataCount"); } - rList.add(0,dataCount+""); - List<CheckIndexCar> carList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getViewConnectStability) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); + rList.add(0, dataCount + ""); +// List<CheckIndexCar> carList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getViewConnectStability) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(carList)) { +// BigDecimal sum = carList.stream().map(CheckIndexCar::getViewConnectStability).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(carList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + BigDecimal normal = new BigDecimal(rList.get(1)); + BigDecimal noData = new BigDecimal(rList.get(2)); + BigDecimal down = new BigDecimal(rList.get(3)); + BigDecimal less = new BigDecimal(rList.get(4)); + BigDecimal totalCount = normal.add(noData).add(down).add(less); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(carList)) { - BigDecimal sum = carList.stream().map(CheckIndexCar::getViewConnectStability).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(carList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount.compareTo(BigDecimal.ZERO)>0) { + onlineRate = normal.divide(totalCount, 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1491,7 +1554,7 @@ item.setOnlineStr("鏈煡"); } List<String> offLineTime = item.getOffLineTimeStr(); - if(!CollectionUtils.isEmpty(offLineTime)) { + if (!CollectionUtils.isEmpty(offLineTime)) { //鍚庣画鍙互鏀规垚閰嶇疆鐨勭绾挎鏁�(鎻愬彇鍓峮娆★紝n涓洪厤缃殑绂荤嚎娆℃暟) if (offLineTime.size() > 1) { offLineTime = offLineTime.subList(0, 2); @@ -1536,17 +1599,21 @@ totalCount = offlineCount + unknownCount + onlineCount; } - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getSiteOnline) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getSiteOnline) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); @@ -1569,10 +1636,10 @@ andCriteria.add(Criteria.where("sxjgnlx.value").regex(pattern)); Query query = new Query(); Criteria and = new Criteria(); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.TRUE)); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.FALSE)); } } @@ -1593,13 +1660,13 @@ List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); dList1.add(new Document("sxjgnlx.value", new Document("$regex", ".*2.*"))); - Document totalFilter = new Document("$and",dList1); + Document totalFilter = new Document("$and", dList1); //鏂拌澶囨暟 List<Document> dList2 = new ArrayList<>(2); setTag(params, dList2); dList2.add(new Document("sxjgnlx.value", new Document("$regex", ".*2.*"))); - dList2.add(new Document("newDevice",Boolean.TRUE)); - Document newFilter = new Document("$and",dList2); + dList2.add(new Document("newDevice", Boolean.TRUE)); + Document newFilter = new Document("$and", dList2); List<Document> lists = Arrays.asList(totalFilter, newFilter); List<String> rList = lists.stream().map(filter -> { @@ -1620,17 +1687,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getDeviceDirectoryConsistent) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getDeviceDirectoryConsistent) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getDeviceDirectoryConsistent).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getDeviceDirectoryConsistent).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(0)).subtract(new BigDecimal(rList.get(1))).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1653,11 +1724,11 @@ Criteria and = new Criteria(); and.andOperator(andCriteria); query = Query.query(and); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("lalType").is(ApiConstants.HK_Info_LayType_Normal)); query.addCriteria(Criteria.where("gbCodeType").is(ApiConstants.HK_Info_GbCodeType_Normal)); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { Criteria lalType = Criteria.where("lalType").ne(ApiConstants.HK_Info_LayType_Normal); Criteria gbCodeType = Criteria.where("gbCodeType").ne(ApiConstants.HK_Info_GbCodeType_Normal); Criteria orOperator = new Criteria().orOperator(lalType, gbCodeType); @@ -1683,9 +1754,9 @@ List<Document> dList3 = new ArrayList<>(2); setTag(params, dList3); List<Document> errorConditions = new ArrayList<>(); - errorConditions.add(new Document("lalType",new Document("$ne",1))); - errorConditions.add(new Document("gbCodeType",new Document("$ne",1))); - Document errorDoc = new Document("$or",errorConditions); + errorConditions.add(new Document("lalType", new Document("$ne", 1))); + errorConditions.add(new Document("gbCodeType", new Document("$ne", 1))); + Document errorDoc = new Document("$or", errorConditions); dList3.add(errorDoc); Document totalFilter = new Document("$and", dList1); Document correctFilter = new Document("$and", dList2); @@ -1710,17 +1781,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehicleInformationCollectionAccuracy) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehicleInformationCollectionAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleInformationCollectionAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleInformationCollectionAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1739,11 +1814,11 @@ public Result vehicleCollectionDataIntegrity(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ + if (params.getOption() != null) { //涓昏灞炴�т笉瀹屾暣 - if(params.getOption()==1){ - query.addCriteria(Criteria.where("noIntegrityCount").gt(0)); - }else if(params.getOption()==-1){ + if (params.getOption() == 1) { + query.addCriteria(Criteria.where("noIntegrityCount").gt(0)); + } else if (params.getOption() == -1) { //灞炴�т笉瀹屾暣 query.addCriteria(Criteria.where("mainNoIntegrityCount").gt(0)); } @@ -1778,22 +1853,26 @@ mainNoIntegrityCount = doc.getInteger("mainNoIntegrityCount"); } - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehicleCaptureIntegrity) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleCaptureIntegrity).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); - } +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehicleCaptureIntegrity) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleCaptureIntegrity).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } List<String> countList = new ArrayList<>(); - countList.add(dataCount+""); - countList.add(noIntegrityCount+""); - countList.add(mainNoIntegrityCount+""); + countList.add(dataCount + ""); + countList.add(noIntegrityCount + ""); + countList.add(mainNoIntegrityCount + ""); + BigDecimal onlineRate = BigDecimal.ZERO; + if (dataCount!=0) { + onlineRate = new BigDecimal(dataCount-noIntegrityCount).divide(new BigDecimal(dataCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); + } countList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", countList); @@ -1811,11 +1890,11 @@ public Result vehicleCollectionDataCaptured(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ + if (params.getOption() != null) { //涓昏灞炴�т笉涓�鑷� - if(params.getOption()==1){ + if (params.getOption() == 1) { query.addCriteria(Criteria.where("majorDiffCount").gt(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { //閲嶈灞炴�т笉涓�鑷� query.addCriteria(Criteria.where("importantDiffCount").gt(0)); } @@ -1849,23 +1928,27 @@ importantDiffCount = doc.getInteger("importantDiffCount"); } - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehicleCaptureAccuracy) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); - BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleCaptureAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); - } +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehicleCaptureAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleCaptureAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } List<String> countList = new ArrayList<>(); - countList.add(sampleCount+""); - countList.add(majorDiffCount+""); - countList.add(importantDiffCount+""); + countList.add(sampleCount + ""); + countList.add(majorDiffCount + ""); + countList.add(importantDiffCount + ""); + BigDecimal onlineRate = BigDecimal.ZERO; + if (sampleCount!=0) { + onlineRate = new BigDecimal(sampleCount-majorDiffCount).divide(new BigDecimal(sampleCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); + } countList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", countList); @@ -1883,11 +1966,11 @@ public Result vehicleClockAccuracy(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ + if (params.getOption() != null) { //褰撴棩鏃堕挓寮傚父 - if(params.getOption()==1){ + if (params.getOption() == 1) { query.addCriteria(Criteria.where("majorDiffCount").gt(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { //鍏ㄩ儴鏃堕挓寮傚父 query.addCriteria(Criteria.where("importantDiffCount").gt(0)); } @@ -1896,7 +1979,7 @@ MongoUtil.setPage(query, params, TIME_FIELD); List<VehicleDeviceInspectionResult> resultList = mongoTemplate.find(query, VehicleDeviceInspectionResult.class); List<SnapClockVO> resultVos = new ArrayList<>(); - resultList.forEach(item->{ + resultList.forEach(item -> { SnapClockVO vo = VehicleDeviceInspectionResult.getVO(item); resultVos.add(vo); }); @@ -1922,7 +2005,7 @@ Document allFilter = new Document("$and", dList3); Document allErrFilter = new Document("$and", dList4); - List<Document> lists = Arrays.asList(todayFilter, todayErrFilter, allFilter,allErrFilter); + List<Document> lists = Arrays.asList(todayFilter, todayErrFilter, allFilter, allErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1941,17 +2024,24 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehicleTimingAccuracy) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehicleTimingAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + BigDecimal normal = new BigDecimal(rList.get(0)); + BigDecimal abnormal = new BigDecimal(rList.get(1)); + BigDecimal totalCount = normal.add(abnormal); + if (totalCount.compareTo(BigDecimal.ZERO)>0) { + onlineRate = normal.divide(totalCount, 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -1971,11 +2061,11 @@ List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); query.addCriteria(Criteria.where("dataType").is(ApiConstants.HK_DataType_CAR)); - if(params.getOption()!=null){ + if (params.getOption() != null) { //姝e父 - if(params.getOption()==1){ + if (params.getOption() == 1) { query.addCriteria(Criteria.where("delayCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { //寤惰繜 query.addCriteria(Criteria.where("delayCount").gt(0)); } @@ -1989,15 +2079,15 @@ List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); - dList1.add(new Document("dataType" ,new Document("$eq",ApiConstants.HK_DataType_CAR))); + dList1.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); Document allFilter = new Document("$and", dList1); List<Document> dList2 = new ArrayList<>(2); - dList2.add(new Document("dataType" ,new Document("$eq",ApiConstants.HK_DataType_CAR))); + dList2.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); dList2.add(new Document("delayCount", new Document("$gt", 0))); setTag(params, dList2); Document delayFilter = new Document("$and", dList2); - List<Document> lists = Arrays.asList(allFilter,delayFilter); + List<Document> lists = Arrays.asList(allFilter, delayFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -2017,17 +2107,21 @@ }).collect(Collectors.toList()); - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehicleUploadTimeliness) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehicleUploadTimeliness) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleUploadTimeliness).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehicleUploadTimeliness).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(0)).subtract(new BigDecimal(rList.get(1))).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2046,10 +2140,10 @@ public Result vehicleUrlAccuracy(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ - if(params.getOption()==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("expCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { query.addCriteria(Criteria.where("expCount").gt(0)); } } @@ -2092,8 +2186,8 @@ onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); } List<String> rList = new ArrayList<>(); - rList.add(sampleCount+""); - rList.add(expCount+""); + rList.add(sampleCount + ""); + rList.add(expCount + ""); rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2112,10 +2206,10 @@ public Result vehicleBigImgAccuracy(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ - if(params.getOption()==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("bigUseful.bigPicExpCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { query.addCriteria(Criteria.where("bigUseful.bigPicExpCount").gt(0)); } } @@ -2124,7 +2218,7 @@ query.with(Sort.by(Sort.Order.desc("bigUseful.bigPicExpCount"))); List<VehicleDeviceSamplingResult> resultList = mongoTemplate.find(query, VehicleDeviceSamplingResult.class); List<BigPicUsefulVO> voList = new ArrayList<>(); - resultList.forEach(item->{ + resultList.forEach(item -> { BigPicUsefulVO picVO = VehicleDeviceSamplingResult.getPicVO(item); voList.add(picVO); }); @@ -2149,20 +2243,24 @@ expCount = doc.getInteger("expCount"); } List<String> countList = new ArrayList<>(); - List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) - .select(CheckIndexCar::getVehiclePictureAvailability) - .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexCar> videoList = new LambdaQueryChainWrapper<>(checkIndexCarService.getBaseMapper()) +// .select(CheckIndexCar::getVehiclePictureAvailability) +// .eq(params.getDataType().equals(1), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexCar::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexCar::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehiclePictureAvailability).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + countList.add(sampleCount + ""); + countList.add(expCount + ""); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexCar::getVehiclePictureAvailability).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (sampleCount!=0) { + onlineRate = new BigDecimal(sampleCount-expCount).divide(new BigDecimal(sampleCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } - countList.add(sampleCount+""); - countList.add(expCount+""); countList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", countList); @@ -2182,21 +2280,21 @@ Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); //鍔燚ataType涓鸿溅杈� query.addCriteria(Criteria.where("dataType").is(ApiConstants.HK_DataType_FACE)); - if(params.getOption()!=null){ - if(ApiConstants.HK_SnapCount_ResultType_Normal.equals(params.getOption())) { + if (params.getOption() != null) { + if (ApiConstants.HK_SnapCount_ResultType_Normal.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Normal)); - }else if(ApiConstants.HK_SnapCount_ResultType_Null.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Null.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Null)); - }else if(ApiConstants.HK_SnapCount_ResultType_Descent.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Descent.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Descent)); - }else if(ApiConstants.HK_SnapCount_ResultType_Low.equals(params.getOption())){ + } else if (ApiConstants.HK_SnapCount_ResultType_Low.equals(params.getOption())) { query.addCriteria(Criteria.where("resultType").is(ApiConstants.HK_SnapCount_ResultType_Low)); } } long total = mongoTemplate.count(query, SnapshotDataMonitorResult.class); MongoUtil.setPage(query, params, TIME_FIELD); List<SnapshotDataMonitorResult> resultList = mongoTemplate.find(query, SnapshotDataMonitorResult.class); - resultList.forEach(item ->item.setResultTypeText(item.getResultTypeText())); + resultList.forEach(item -> item.setResultTypeText(item.getResultTypeText())); // 缁熻鏁伴噺 MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor"); @@ -2210,9 +2308,19 @@ dList3.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); setTag(params, dList3); - Document noDataFilter = new Document("$and", dList2); - Document trFilter = new Document("$and", dList3); - List<Document> lists = Arrays.asList(noDataFilter, trFilter); + List<Document> dList4 = new ArrayList<>(2); + dList4.add(new Document("resultType", new Document("$eq", 3))); + dList4.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); + setTag(params, dList4); + List<Document> dList5 = new ArrayList<>(2); + dList5.add(new Document("resultType", new Document("$eq", 4))); + dList5.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); + setTag(params, dList5); + Document normalFilter = new Document("$and", dList2); + Document noDataFilter = new Document("$and", dList3); + Document downFilter = new Document("$and", dList4); + Document lessFilter = new Document("$and", dList5); + List<Document> lists = Arrays.asList(normalFilter, noDataFilter,downFilter,lessFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -2246,18 +2354,27 @@ for (Document doc : result) { dataCount = doc.getInteger("dataCount"); } - rList.add(0,dataCount+""); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getViewConnectStability) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); + rList.add(0, dataCount + ""); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getViewConnectStability) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getViewConnectStability).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + BigDecimal normal = new BigDecimal(rList.get(1)); + BigDecimal noData = new BigDecimal(rList.get(2)); + BigDecimal down = new BigDecimal(rList.get(3)); + BigDecimal less = new BigDecimal(rList.get(4)); + BigDecimal totalCount = normal.add(noData).add(down).add(less); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getViewConnectStability).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount.compareTo(BigDecimal.ZERO)>0) { + onlineRate = normal.divide(totalCount, 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2308,7 +2425,7 @@ item.setOnlineStr("鏈煡"); } List<String> offLineTime = item.getOffLineTimeStr(); - if(!CollectionUtils.isEmpty(offLineTime)) { + if (!CollectionUtils.isEmpty(offLineTime)) { //鍚庣画鍙互鏀规垚閰嶇疆鐨勭绾挎鏁�(鎻愬彇鍓峮娆★紝n涓洪厤缃殑绂荤嚎娆℃暟) if (offLineTime.size() > 1) { offLineTime = offLineTime.subList(0, 2); @@ -2354,19 +2471,22 @@ onlineCount = (Integer) result.getOrDefault("onlineCount", 0L); totalCount = offlineCount + unknownCount + onlineCount; } - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getSiteOnline) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, params.getStartTime(), params.getEndTime()) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getSiteOnline) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, params.getStartTime(), params.getEndTime()) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getSiteOnline).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (totalCount!=0) { + onlineRate = new BigDecimal(onlineCount).divide(new BigDecimal(totalCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } - HashMap<String, Object> map = new HashMap<>(); map.put("count", Arrays.asList(totalCount + "", onlineCount + "", offlineCount + "", unknownCount + "", this.remove0(onlineRate))); map.put("list", resultList); @@ -2388,10 +2508,10 @@ andCriteria.add(Criteria.where("sxjgnlx.value").regex(pattern)); Query query = new Query(); Criteria and = new Criteria(); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.TRUE)); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { andCriteria.add(Criteria.where("newDevice").is(Boolean.FALSE)); } } @@ -2412,13 +2532,13 @@ List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); dList1.add(new Document("sxjgnlx.value", new Document("$regex", ".*3.*"))); - Document totalFilter = new Document("$and",dList1); + Document totalFilter = new Document("$and", dList1); //鏂拌澶囨暟 List<Document> dList2 = new ArrayList<>(2); setTag(params, dList2); dList2.add(new Document("sxjgnlx.value", new Document("$regex", ".*3.*"))); - dList2.add(new Document("newDevice",Boolean.TRUE)); - Document newFilter = new Document("$and",dList2); + dList2.add(new Document("newDevice", Boolean.TRUE)); + Document newFilter = new Document("$and", dList2); List<Document> lists = Arrays.asList(totalFilter, newFilter); List<String> rList = lists.stream().map(filter -> { @@ -2439,17 +2559,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getDeviceDirectoryConsistent) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getDeviceDirectoryConsistent) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getDeviceDirectoryConsistent).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getDeviceDirectoryConsistent).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(0)).subtract(new BigDecimal(rList.get(1))).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2472,11 +2596,11 @@ Criteria and = new Criteria(); and.andOperator(andCriteria); query = Query.query(and); - if(params.getOption()!=null){ - if(params.getOption() ==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("lalType").is(ApiConstants.HK_Info_LayType_Normal)); query.addCriteria(Criteria.where("gbCodeType").is(ApiConstants.HK_Info_GbCodeType_Normal)); - }else if(params.getOption() ==-1){ + } else if (params.getOption() == -1) { Criteria lalType = Criteria.where("lalType").ne(ApiConstants.HK_Info_LayType_Normal); Criteria gbCodeType = Criteria.where("gbCodeType").ne(ApiConstants.HK_Info_GbCodeType_Normal); Criteria orOperator = new Criteria().orOperator(lalType, gbCodeType); @@ -2502,9 +2626,9 @@ List<Document> dList3 = new ArrayList<>(2); setTag(params, dList3); List<Document> errorConditions = new ArrayList<>(); - errorConditions.add(new Document("lalType",new Document("$ne",1))); - errorConditions.add(new Document("gbCodeType",new Document("$ne",1))); - Document errorDoc = new Document("$or",errorConditions); + errorConditions.add(new Document("lalType", new Document("$ne", 1))); + errorConditions.add(new Document("gbCodeType", new Document("$ne", 1))); + Document errorDoc = new Document("$or", errorConditions); dList3.add(errorDoc); Document totalFilter = new Document("$and", dList1); Document correctFilter = new Document("$and", dList2); @@ -2529,17 +2653,21 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getFaceInformationCollectionAccuracy) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getFaceInformationCollectionAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceInformationCollectionAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceInformationCollectionAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(1)).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2558,10 +2686,10 @@ public Result faceImgQualification(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "cameraName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ - if(params.getOption()==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("faceEligibility.unfaceEligCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { query.addCriteria(Criteria.where("faceEligibility.unfaceEligCount").gt(0)); } } @@ -2570,7 +2698,7 @@ MongoUtil.setPage(query, params, TIME_FIELD); List<FaceDeviceSamplingResult> resultList = mongoTemplate.find(query, FaceDeviceSamplingResult.class); List<BigPicUsefulVO> voList = new ArrayList<>(); - resultList.forEach(item->{ + resultList.forEach(item -> { BigPicUsefulVO picVO = FaceDeviceSamplingResult.getEligeVO(item); voList.add(picVO); }); @@ -2597,20 +2725,24 @@ } List<String> countList = new ArrayList<>(); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getFacePictureQualification) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getFacePictureQualification) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getFacePictureQualification).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + countList.add(sampleCount + ""); + countList.add(expCount + ""); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getFacePictureQualification).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (sampleCount!=0) { + onlineRate = new BigDecimal(sampleCount-expCount).divide(new BigDecimal(sampleCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } - countList.add(sampleCount+""); - countList.add(expCount+""); countList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", countList); @@ -2628,11 +2760,11 @@ public Result faceCapturesImagesAccuracy(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ + if (params.getOption() != null) { //褰撴棩鏃堕挓寮傚父 - if(params.getOption()==1){ + if (params.getOption() == 1) { query.addCriteria(Criteria.where("majorDiffCount").gt(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { //鍏ㄩ儴鏃堕挓寮傚父 query.addCriteria(Criteria.where("importantDiffCount").gt(0)); } @@ -2641,7 +2773,7 @@ MongoUtil.setPage(query, params, TIME_FIELD); List<FaceDeviceInspectionResult> resultList = mongoTemplate.find(query, FaceDeviceInspectionResult.class); List<SnapClockVO> resultVos = new ArrayList<>(); - resultList.forEach(item->{ + resultList.forEach(item -> { SnapClockVO vo = FaceDeviceInspectionResult.getVO(item); resultVos.add(vo); }); @@ -2668,7 +2800,7 @@ Document allErrFilter = new Document("$and", dList4); - List<Document> lists = Arrays.asList(todayFilter, todayErrFilter, allFilter,allErrFilter); + List<Document> lists = Arrays.asList(todayFilter, todayErrFilter, allFilter, allErrFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -2687,17 +2819,24 @@ return uniqueDeviceIdCount + ""; }).collect(Collectors.toList()); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getFaceTimingAccuracy) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getFaceTimingAccuracy) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceTimingAccuracy).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + BigDecimal normal = new BigDecimal(rList.get(0)); + BigDecimal abnormal = new BigDecimal(rList.get(1)); + BigDecimal totalCount = normal.add(abnormal); + if (totalCount.compareTo(BigDecimal.ZERO)>0) { + onlineRate = normal.divide(totalCount, 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2717,11 +2856,11 @@ List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); query.addCriteria(Criteria.where("dataType").is(ApiConstants.HK_DataType_FACE)); - if(params.getOption()!=null){ + if (params.getOption() != null) { //姝e父 - if(params.getOption()==1){ + if (params.getOption() == 1) { query.addCriteria(Criteria.where("delayCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { //寤惰繜 query.addCriteria(Criteria.where("delayCount").gt(0)); } @@ -2735,15 +2874,15 @@ List<Document> dList1 = new ArrayList<>(2); setTag(params, dList1); - dList1.add(new Document("dataType" ,new Document("$eq",ApiConstants.HK_DataType_FACE))); + dList1.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE))); Document allFilter = new Document("$and", dList1); List<Document> dList2 = new ArrayList<>(2); - dList2.add(new Document("dataType" ,new Document("$eq",ApiConstants.HK_DataType_FACE))); + dList2.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE))); dList2.add(new Document("delayCount", new Document("$gt", 0))); setTag(params, dList2); Document delayFilter = new Document("$and", dList2); - List<Document> lists = Arrays.asList(allFilter,delayFilter); + List<Document> lists = Arrays.asList(allFilter, delayFilter); List<String> rList = lists.stream().map(filter -> { // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -2763,17 +2902,21 @@ }).collect(Collectors.toList()); - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getFaceUploadTimeliness) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getFaceUploadTimeliness) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceUploadTimeliness).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getFaceUploadTimeliness).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (!StringUtils.isEmpty(rList.get(0)) && !"0".equals(rList.get(0))) { + onlineRate = new BigDecimal(rList.get(0)).subtract(new BigDecimal(rList.get(1))).divide(new BigDecimal(rList.get(0)), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } rList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); @@ -2792,10 +2935,10 @@ public Result faceAvailabilityOfLargeImg(DataCenterQuery params) { List<String> likeFileds = Arrays.asList("externalIndexCode", "deviceName"); Query query = MongoUtil.getQuery(params, TIME_FIELD, likeFileds, null); - if(params.getOption()!=null){ - if(params.getOption()==1){ + if (params.getOption() != null) { + if (params.getOption() == 1) { query.addCriteria(Criteria.where("bigUseful.bigPicExpCount").is(0)); - }else if(params.getOption()==-1){ + } else if (params.getOption() == -1) { query.addCriteria(Criteria.where("bigUseful.bigPicExpCount").gt(0)); } } @@ -2804,7 +2947,7 @@ query.with(Sort.by(Sort.Order.desc("bigUseful.bigPicExpCount"))); List<FaceDeviceSamplingResult> resultList = mongoTemplate.find(query, FaceDeviceSamplingResult.class); List<BigPicUsefulVO> voList = new ArrayList<>(); - resultList.forEach(item->{ + resultList.forEach(item -> { BigPicUsefulVO picVO = FaceDeviceSamplingResult.getPicVO(item); voList.add(picVO); }); @@ -2831,20 +2974,24 @@ List<String> countList = new ArrayList<>(); // 缁熻鏁� - List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) - .select(CheckIndexFace::getFacePictureAvailability) - .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) - .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) - .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) - .list(); +// List<CheckIndexFace> videoList = new LambdaQueryChainWrapper<>(checkIndexFaceService.getBaseMapper()) +// .select(CheckIndexFace::getFacePictureAvailability) +// .eq(params.getDataType().equals(1), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Province) +// .eq(params.getDataType().equals(2), CheckIndexFace::getExamineTag, CheckConstants.Examine_Tag_Dept) +// .between(CheckIndexFace::getCreateTime, DateUtils.getDayStart(params.getStartTime()), DateUtils.getDayEnd(params.getEndTime())) +// .list(); +// BigDecimal onlineRate = BigDecimal.ZERO; +// if (CollectionUtils.isNotEmpty(videoList)) { +// BigDecimal sum = videoList.stream().map(CheckIndexFace::getFacePictureAvailability).reduce(BigDecimal.ZERO, BigDecimal::add); +// BigDecimal count = BigDecimal.valueOf(videoList.size()); +// onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); +// } + countList.add(sampleCount + ""); + countList.add(expCount + ""); BigDecimal onlineRate = BigDecimal.ZERO; - if (CollectionUtils.isNotEmpty(videoList)) { - BigDecimal sum = videoList.stream().map(CheckIndexFace::getFacePictureAvailability).reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal count = BigDecimal.valueOf(videoList.size()); - onlineRate = sum.divide(count, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)); + if (sampleCount!=0) { + onlineRate = new BigDecimal(sampleCount-expCount).divide(new BigDecimal(sampleCount), 3,RoundingMode.DOWN).multiply(new BigDecimal("100")); } - countList.add(sampleCount+""); - countList.add(expCount+""); countList.add(this.remove0(onlineRate)); HashMap<String, Object> map = new HashMap<>(); map.put("count", countList); @@ -2895,8 +3042,8 @@ dList.add(new Document("deptTag", new Document("$eq", Boolean.TRUE))); } Document mongoCreateTimeRange = new Document(); - if (params.getStartTime()!=null) mongoCreateTimeRange.append("$gte", params.getStartTime()); - if (params.getEndTime()!=null) mongoCreateTimeRange .append("$lt", params.getEndTime()); + if (params.getStartTime() != null) mongoCreateTimeRange.append("$gte", params.getStartTime()); + if (params.getEndTime() != null) mongoCreateTimeRange.append("$lt", params.getEndTime()); dList.add(new Document("mongoCreateTime", mongoCreateTimeRange)); } } 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 3cc7abe..c17d4ee 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 @@ -965,7 +965,7 @@ )) .append("loseCount", new Document("$sum", new Document("$cond", Arrays.asList( - new Document("$eq", Arrays.asList("$recordStatus", -1)), + new Document("$in", Arrays.asList("$recordStatus", Arrays.asList(-1, 0))), 1, 0 )) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java index c8aaf89..8a08b68 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java @@ -35,6 +35,7 @@ import com.ycl.utils.http.HttpUtils; import com.ycl.utils.redis.RedisCache; import com.ycl.utils.uuid.IdUtils; +import constant.ApiConstants; import constant.Constants; import constant.RedisConstant; import enumeration.ErrorType; @@ -471,18 +472,22 @@ UrgentLevelEnum.WARNING, workOrder.getWorkOrderNo()); notifyService.save(notify); - List<String> errorList = workOrderErrorTypeMapper.getErrorList(workOrder.getWorkOrderNo()) - .stream().map(SysDictData::getDictValue).collect(Collectors.toList()); + List<WorkOrderVO> workOrderVOS = workOrderErrorTypeMapper.getErrorListByNumbers(Arrays.asList(workOrder.getWorkOrderNo())); + // 鍚屾鐐逛綅鐘舵�� if (form.getAuditingResult() == WorkOrderStatusEnum.AUDITING_SUCCESS) { ywPointService.updateRecovery(Collections.singletonList(workOrder.getSerialNumber()), 0); //濡傛灉宸ュ崟涓虹绾垮伐鍗曢偅涔堜慨鏀圭偣浣峱ingOnline涓哄湪绾� - if(!CollectionUtils.isEmpty(errorList) && errorList.contains(ErrorType.DEVICE_OFFLINE.getValue())){ - new LambdaUpdateChainWrapper<>(ywPointMapper) - .eq(YwPoint::getSerialNumber, workOrder.getSerialNumber()) - .set(YwPoint::getUpdateTime, new Date()) - .set(YwPoint::getPingOnline, 1) - .update(); + if (!CollectionUtils.isEmpty(workOrderVOS)) { + List<String> ips = new ArrayList<>(); + for (WorkOrderVO workOrderVO : workOrderVOS) { + if(ErrorType.DEVICE_OFFLINE.getValue().equals(workOrderVO.getErrorType())){ + ips.add(workOrderVO.getIp()); + } + } + if(!CollectionUtils.isEmpty(ips)) { + monitorMapper.batchUpdateOnline(ips, new Date(), ApiConstants.UY_OnlineSite_Online); + } } } @@ -525,11 +530,30 @@ workOrder.getWorkOrderNo()); notifies.add(notify); } + notifyService.saveBatch(notifies); // 鍚屾鐐逛綅鐘舵�� if (form.getAuditingResult() == WorkOrderStatusEnum.AUDITING_SUCCESS) { ywPointService.updateRecovery(serialNumbers, 0); + //绛涢�夊嚭绂荤嚎宸ュ崟ip骞朵慨鏀瑰湪绾跨姸鎬� + if (!CollectionUtils.isEmpty(serialNumbers)) { + Map<String, List<String>> errorTypes = workOrderErrorTypeMapper.getErrorListByNumbers(workOrderNoList).stream().collect(Collectors.groupingBy( + WorkOrderVO::getIp, + Collectors.mapping( + WorkOrderVO::getErrorType, + Collectors.toList() + ) + )); + List<String> ips = new ArrayList<>(); + errorTypes.forEach((key, value) -> { + if (!CollectionUtils.isEmpty(value) && value.contains(ErrorType.DEVICE_OFFLINE.getValue())) { + ips.add(key); + } + }); + if(!CollectionUtils.isEmpty(ips)) { + monitorMapper.batchUpdateOnline(ips, new Date(), ApiConstants.UY_OnlineSite_Online); + } + } } - notifyService.saveBatch(notifies); return Result.ok("鎿嶄綔鎴愬姛"); } diff --git a/ycl-server/src/main/java/com/ycl/task/ContractTask.java b/ycl-server/src/main/java/com/ycl/task/ContractTask.java index 1d637c2..c7e7eac 100644 --- a/ycl-server/src/main/java/com/ycl/task/ContractTask.java +++ b/ycl-server/src/main/java/com/ycl/task/ContractTask.java @@ -32,6 +32,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.*; import java.util.function.Function; @@ -65,7 +66,6 @@ private static final Integer Offline = -1; private static final String AuditStatus_Pass = "1"; private static final String Remark = "绯荤粺鐢熸垚"; - private static final Integer randomSize = 30; /** * 鍚堝悓鑰冩牳 鍦ㄧ嚎鐜囨瘡鏃ヤ换鍔℃娴� @@ -80,11 +80,11 @@ .filter(calculateRuleVO -> ContractRule.CONTRACT_RULE_Online.getName().equals(calculateRuleVO.getRuleName())) .collect(Collectors.toList()); List<Integer> unitIds = ruleVos.stream().map(CalculateRuleVO::getUnitId).collect(Collectors.toList()); - List<YwPoint> ywPoints = ywPointMapper.selectList(new QueryWrapper<YwPoint>().in("unit_id", unitIds).eq("examine_status",1)); + List<YwPoint> ywPoints = ywPointMapper.selectList(new QueryWrapper<YwPoint>().in("unit_id", unitIds).eq("examine_status", 1)); //key鏄痷nitId value鏄澶囩紪鐮侀泦鍚� Map<Long, List<YwPoint>> unitMap = ywPoints.stream().filter(point -> point.getUnitId() != null) .collect(Collectors.groupingBy( - YwPoint::getUnitId + YwPoint::getUnitId ) ); //鏌ヨ鎶ュ鍒楄〃 @@ -200,7 +200,7 @@ deductErrorType.add(ErrorType.ABNORMAL_PIC.getValue()); deductErrorType.add(ErrorType.POINT_INFO_ERROR.getValue()); deductErrorType.add(ErrorType.CLOCK_SKEW.getValue()); - List<WorkOrderVO> workOrders = workOrderMapper.selectPassOrder(startTime, endTime, WorkOrderStatusEnum.AUDITING_SUCCESS.getValue(),deductErrorType,"瀹℃牳閫氳繃"); + List<WorkOrderVO> workOrders = workOrderMapper.selectPassOrder(startTime, endTime, WorkOrderStatusEnum.AUDITING_SUCCESS.getValue(), deductErrorType, "瀹℃牳閫氳繃"); //瀛樺湪鏈変袱绉嶆墸鍒嗙殑鏁呴殰 鍙墸鍑忕涓�涓晠闅� Map<String, WorkOrderVO> map = workOrders.stream() .collect(Collectors.toMap( @@ -270,12 +270,12 @@ double diffTime = (double) (passTime.getTime() - createTime.getTime() - auditDuration) / (1000 * 60 * 60); //鎵惧埌瀵瑰簲瑙勫垯銆侀�夋嫨鏃堕棿鑼冨洿鍐呯殑瑙勫垯 for (CalculateRuleVO rule : rules) { - if(ErrorType.OSD_ERROR.getValue().equals(errorType)){ - if(!rule.getRuleCondition().equals("OSD鏍囪瘑")) continue; - }else if(ErrorType.CLOCK_SKEW.getValue().equals(errorType)){ - if(!rule.getRuleCondition().equals("鏃堕挓鍚屾")) continue; - }else if( ErrorType.POINT_INFO_ERROR.getValue().equals(errorType)){ - if(!rule.getRuleCondition().equals("涓�鏈轰竴妗�")) continue; + if (ErrorType.OSD_ERROR.getValue().equals(errorType)) { + if (!rule.getRuleCondition().equals("OSD鏍囪瘑")) continue; + } else if (ErrorType.CLOCK_SKEW.getValue().equals(errorType)) { + if (!rule.getRuleCondition().equals("鏃堕挓鍚屾")) continue; + } else if (ErrorType.POINT_INFO_ERROR.getValue().equals(errorType)) { + if (!rule.getRuleCondition().equals("涓�鏈轰竴妗�")) continue; } if (checkRange(rule.getMin(), rule.getMax(), new BigDecimal(diffTime))) { @@ -304,7 +304,7 @@ long auditDuration = getAuditDuration(auditTimes, handleTimes); //瀹℃牳閫氳繃鏃堕棿 Date passTime = Collections.max(auditTimes); - double diffTime = (double) (passTime.getTime() - createTime.getTime() -auditDuration) / (1000 * 60 * 60); + double diffTime = (double) (passTime.getTime() - createTime.getTime() - auditDuration) / (1000 * 60 * 60); //閫夋嫨鏃堕棿鑼冨洿鍐呯殑瑙勫垯 for (CalculateRuleVO rule : rules) { if (checkRange(rule.getMin(), rule.getMax(), new BigDecimal(diffTime))) { @@ -346,7 +346,7 @@ Date nearestHandleTime = null; long minDifference = Long.MAX_VALUE; for (Date handleTime : handleTimes) { - if(handleTime.before(auditTime)) { + if (handleTime.before(auditTime)) { long difference = Math.abs(auditTime.getTime() - handleTime.getTime()); if (difference < minDifference) { minDifference = difference; @@ -354,7 +354,7 @@ } } } - auditDuration += auditTime.getTime()-nearestHandleTime.getTime(); + auditDuration += auditTime.getTime() - nearestHandleTime.getTime(); } return auditDuration; } @@ -362,169 +362,178 @@ /** * 涓嶅畾鏈熸鏌ユ暟鎹� 鎵i櫎绉垎 - * 姣忓ぉ涓�娆¢殢鏈烘暟鍒ゆ柇鎴愬姛灏辨墽琛� * 娴峰悍鍙栦汉鑴歌溅杈� */ public void randomDeductPic() { - Random random = new Random(); - Integer num = randomSize; - //缁欏畾闅忔満鑼冨洿 - String count = sysConfigMapper.checkConfigKeyUnique("check.contract.sample").getConfigValue(); - if (!StringUtils.isEmpty(count)) { - Integer temp = Integer.valueOf(count); - if (temp > 0) { - num = temp; - } - } - int number = random.nextInt(num); - if (number == 0) { - log.info("寮�濮嬫娊鏌ュ浘鐗囧畬鏁寸姸鎬�"); - //鍑嗗鎵归噺鎵撳垎鐨勯泦鍚� - List<ContractScore> contractScoreList = new ArrayList<>(); - //鏌ヨ鎶ュ鍒楄〃 - List<String> reportNumbers = reportMapper.selectNumberList(AuditStatus_Pass, DateUtils.getDate()); - Date date = new Date(); - //鏌ュ浘鐗囧畬鏁存�ц鍒� 鑾峰彇key涓哄悎鍚宨d锛寁alue涓鸿鍒欑殑map - Map<Integer, List<CalculateRuleVO>> contractMap = contractMapper.getCalculateRule(new Date()).stream() - .filter(calculateRuleVO -> ContractRule.CONTRACT_RULE_PicComplete.getName().equals(calculateRuleVO.getRuleName())) - .collect(Collectors.groupingBy(CalculateRuleVO::getContractId)); + log.info("寮�濮嬫娊鏌ュ浘鐗囧畬鏁寸姸鎬�"); + //杩欎釜鏈堥殢鏈烘娊鍙栦竴澶� + Date date = getRandomDate(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + //鍑嗗鎵归噺鎵撳垎鐨勯泦鍚� + List<ContractScore> contractScoreList = new ArrayList<>(); + //鏌ヨ鎶ュ鍒楄〃 + List<String> reportNumbers = reportMapper.selectNumberList(AuditStatus_Pass, DateUtils.getDate()); + //鏌ュ浘鐗囧畬鏁存�ц鍒� 鑾峰彇key涓哄悎鍚宨d锛寁alue涓鸿鍒欑殑map + Map<Integer, List<CalculateRuleVO>> contractMap = contractMapper.getCalculateRule(new Date()).stream() + .filter(calculateRuleVO -> ContractRule.CONTRACT_RULE_PicComplete.getName().equals(calculateRuleVO.getRuleName())) + .collect(Collectors.groupingBy(CalculateRuleVO::getContractId)); - //鍒ゆ柇杞﹁締銆佷汉鑴稿浘鐗囨槸鍚﹀彲鐢� - Query query = new Query(Criteria - .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); - List<PicAccessResult> picAccessResults = mongoTemplate.find(query, PicAccessResult.class); - List<String> serialNumbers = picAccessResults.stream().map(PicAccessResult::getExternalIndexCode).collect(Collectors.toList()); - QueryWrapper<YwPoint> queryWrapper = new QueryWrapper<>(); - queryWrapper.in("serial_number", serialNumbers); - //鑾峰彇鍏徃鎵�杩愮淮鐨勮澶囬泦鍚堬紝key涓簎nitId value涓鸿澶囧浗鏍囩爜闆嗗悎 - Map<Long, List<String>> unitMonitorMap = ywPointMapper.selectList(queryWrapper).stream() - .filter(ywPoint -> ywPoint.getUnitId() != null).collect(Collectors.groupingBy(YwPoint::getUnitId, - Collectors.mapping( - YwPoint::getSerialNumber, - Collectors.toList()))); - if (!CollectionUtils.isEmpty(contractMap)) { - contractMap.forEach((contractId, ruleList) -> { - boolean deduct = false; - String serialNumber = null; - //姝よ鍒欏搴旂殑unitId鍧囩浉绛� - CalculateRuleVO ruleVO = ruleList.get(0); - Integer unitId = ruleVO.getUnitId(); - List<String> monitorList = unitMonitorMap.get(Long.parseLong(unitId + "")); - for (PicAccessResult picAccessResult : picAccessResults) { - //鍒ゆ柇鏄惁鎶ュ杩� - if (!CollectionUtils.isEmpty(reportNumbers)) { - if (reportNumbers.contains(picAccessResult.getExternalIndexCode())) continue; - } - //鍒ゆ柇鏄惁鏄鍏徃杩愮淮 - if (monitorList.contains(picAccessResult.getExternalIndexCode())) { - //瀛樺湪鍥剧墖璁块棶寮傚父鏁版嵁閲忥紝闇�瑕佹墸鍑� - if (picAccessResult.getExpCount() > 0) { - deduct = true; - serialNumber = picAccessResult.getExternalIndexCode(); - break; - } + //鍒ゆ柇杞﹁締銆佷汉鑴稿浘鐗囨槸鍚﹀彲鐢� + Query query = new Query(Criteria + .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); + List<PicAccessResult> picAccessResults = mongoTemplate.find(query, PicAccessResult.class); + List<String> serialNumbers = picAccessResults.stream().map(PicAccessResult::getExternalIndexCode).collect(Collectors.toList()); + QueryWrapper<YwPoint> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("serial_number", serialNumbers); + //鑾峰彇鍏徃鎵�杩愮淮鐨勮澶囬泦鍚堬紝key涓簎nitId value涓鸿澶囧浗鏍囩爜闆嗗悎 + Map<Long, List<String>> unitMonitorMap = ywPointMapper.selectList(queryWrapper).stream() + .filter(ywPoint -> ywPoint.getUnitId() != null).collect(Collectors.groupingBy(YwPoint::getUnitId, + Collectors.mapping( + YwPoint::getSerialNumber, + Collectors.toList()))); + if (!CollectionUtils.isEmpty(contractMap)) { + contractMap.forEach((contractId, ruleList) -> { + boolean deduct = false; + String serialNumber = null; + //姝よ鍒欏搴旂殑unitId鍧囩浉绛� + CalculateRuleVO ruleVO = ruleList.get(0); + Integer unitId = ruleVO.getUnitId(); + List<String> monitorList = unitMonitorMap.get(Long.parseLong(unitId + "")); + for (PicAccessResult picAccessResult : picAccessResults) { + //鍒ゆ柇鏄惁鎶ュ杩� + if (!CollectionUtils.isEmpty(reportNumbers)) { + if (reportNumbers.contains(picAccessResult.getExternalIndexCode())) continue; + } + //鍒ゆ柇鏄惁鏄鍏徃杩愮淮 + if (monitorList.contains(picAccessResult.getExternalIndexCode())) { + //瀛樺湪鍥剧墖璁块棶寮傚父鏁版嵁閲忥紝闇�瑕佹墸鍑� + if (picAccessResult.getExpCount() > 0) { + deduct = true; + serialNumber = picAccessResult.getExternalIndexCode(); + break; } } - if (deduct) { - //闇�瑕佹墸闄ょ殑鍒嗘暟锛屾瑙勫垯鍙湁涓�鏉′笉闇�瑕佸垽鏂寖鍥� - Double deductScore = ruleVO.getCalcFraction(); - ContractScore contractScore = getContractScore(ruleVO, deductScore, "1", Remark + "鍥芥爣鐮佷负:" + serialNumber + "鏃堕棿锛�" + new Date() + "瀛樺湪澶у浘涓嶅彲鐢ㄦ暟鎹�"); - contractScoreList.add(contractScore); - } - }); - } - contractScoreService.saveBatch(contractScoreList); - log.info("缁撴潫鎶芥煡鍥剧墖瀹屾暣鐘舵��"); + } + if (deduct) { + //闇�瑕佹墸闄ょ殑鍒嗘暟锛屾瑙勫垯鍙湁涓�鏉′笉闇�瑕佸垽鏂寖鍥� + Double deductScore = ruleVO.getCalcFraction(); + ContractScore contractScore = getContractScore(ruleVO, deductScore, "1", Remark + "鍥芥爣鐮佷负:" + serialNumber + "鏃堕棿锛�" + format.format(date) + "瀛樺湪澶у浘涓嶅彲鐢ㄦ暟鎹�"); + contractScoreList.add(contractScore); + } + }); } + contractScoreService.saveBatch(contractScoreList); + log.info("缁撴潫鎶芥煡鍥剧墖瀹屾暣鐘舵��"); } /** * 涓嶅畾鏈熸鏌ユ暟鎹� 鎵i櫎绉垎 - * 姣忓ぉ涓�娆¢殢鏈烘暟鍒ゆ柇鎴愬姛灏辨墽琛� * 浼樹簯鍙栧綍鍍� */ public void randomDeductVideo() { - Random random = new Random(); - //缁欏畾闅忔満鑼冨洿 - Integer num = randomSize; - //缁欏畾闅忔満鑼冨洿 - String count = sysConfigMapper.checkConfigKeyUnique("check.contract.sample").getConfigValue(); - if (!StringUtils.isEmpty(count)) { - Integer temp = Integer.valueOf(count); - if (temp > 0) { - num = temp; - } - } - int number = random.nextInt(num); - if (number == 0) { - log.info("寮�濮嬫娊鏌ュ綍鍍忓畬鏁寸姸鎬�"); - //鍑嗗鎵归噺鎵撳垎鐨勯泦鍚� - List<ContractScore> contractScoreList = new ArrayList<>(); - //鏌ヨ鎶ュ鍒楄〃 - List<String> reportNumbers = reportMapper.selectNumberList(AuditStatus_Pass, DateUtils.getDate()); - Date date = new Date(); - //鏌ュ浘鐗囧畬鏁存�ц鍒� 鑾峰彇key涓哄悎鍚宨d锛寁alue涓鸿鍒欑殑map - Map<Integer, List<CalculateRuleVO>> contractMap = contractMapper.getCalculateRule(new Date()).stream() - .filter(calculateRuleVO -> ContractRule.CONTRACT_RULE_VideoRecord.getName().equals(calculateRuleVO.getRuleName())) - .collect(Collectors.groupingBy(CalculateRuleVO::getContractId)); + log.info("寮�濮嬫娊鏌ュ綍鍍忓畬鏁寸姸鎬�"); + //杩欎釜鏈堥殢鏈烘娊鍙栦竴澶� + Date date = getRandomDate(); +// Calendar instance = Calendar.getInstance(); +// // 璁惧畾骞淬�佹湀銆佹棩锛堟敞鎰忔湀浠戒粠0寮�濮嬶紝鍗�0浠h〃1鏈堬紝11浠h〃12鏈堬級 +// instance.set(2024, 10, 1); +// Date date = instance.getTime(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + //鍑嗗鎵归噺鎵撳垎鐨勯泦鍚� + List<ContractScore> contractScoreList = new ArrayList<>(); + //鏌ヨ鎶ュ鍒楄〃 + List<String> reportNumbers = reportMapper.selectNumberList(AuditStatus_Pass, DateUtils.getDate()); + //鏌ュ浘鐗囧畬鏁存�ц鍒� 鑾峰彇key涓哄悎鍚宨d锛寁alue涓鸿鍒欑殑map + Map<Integer, List<CalculateRuleVO>> contractMap = contractMapper.getCalculateRule(new Date()).stream() + .filter(calculateRuleVO -> ContractRule.CONTRACT_RULE_VideoRecord.getName().equals(calculateRuleVO.getRuleName())) + .collect(Collectors.groupingBy(CalculateRuleVO::getContractId)); - //鍙栧綍鍍忔暟鎹� - Query query = new Query(Criteria - .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); - List<RecordMetaDSumResult> recordMetaDSumResults = mongoTemplate.find(query, RecordMetaDSumResult.class); - List<String> serialNumbers = recordMetaDSumResults.stream().map(RecordMetaDSumResult::getDeviceId).collect(Collectors.toList()); - QueryWrapper<YwPoint> queryWrapper = new QueryWrapper<>(); - queryWrapper.in("serial_number", serialNumbers); - //鑾峰彇鍏徃鎵�杩愮淮鐨勮澶囬泦鍚堬紝key涓簎nitId value涓鸿澶囧浗鏍囩爜闆嗗悎 - Map<Long, List<String>> unitMonitorMap = ywPointMapper.selectList(queryWrapper).stream() - .filter(ywPoint -> ywPoint.getUnitId() != null).collect(Collectors.groupingBy(YwPoint::getUnitId, - Collectors.mapping( - YwPoint::getSerialNumber, - Collectors.toList()))); - if (!CollectionUtils.isEmpty(contractMap)) { - contractMap.forEach((contractId, ruleList) -> { - //姝よ鍒欏搴旂殑unitId鍧囩浉绛� - CalculateRuleVO ruleVO = ruleList.get(0); - Integer unitId = ruleVO.getUnitId(); - List<String> monitorList = unitMonitorMap.get(Long.parseLong(unitId + "")); - for (RecordMetaDSumResult result : recordMetaDSumResults) { - //鍒ゆ柇鏄惁鎶ュ杩� - if (!CollectionUtils.isEmpty(reportNumbers)) { - if (reportNumbers.contains(result.getDeviceId())) continue; - } - //鍒ゆ柇鏄惁鏄鍏徃杩愮淮 - if (monitorList.contains(result.getDeviceId())) { - //褰曞儚鐘舵�佷笉瀹屾暣 - if (!Objects.equals(result.getRecordStatus(), ApiConstants.UY_RecordStatus_Integrity)) { - for (CalculateRuleVO calculateRuleVO : ruleList) { - Double max = calculateRuleVO.getMax(); - Double min = calculateRuleVO.getMin(); - //鍒ゆ柇鑼冨洿鍦ㄥ摢涓尯闂� 鍗曚綅鏄皬鏃惰浆鎹负鍒嗛挓 - if (checkRange(min, max, BigDecimal.valueOf(result.getMissDuration() * 60))) { - if (calculateRuleVO.getNum() == null) { - calculateRuleVO.setNum(1); - } else { - calculateRuleVO.setNum(calculateRuleVO.getNum() + 1); - } + //鍙栧綍鍍忔暟鎹� + Query query = new Query(Criteria + .where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); + List<RecordMetaDSumResult> recordMetaDSumResults = mongoTemplate.find(query, RecordMetaDSumResult.class); + List<String> serialNumbers = recordMetaDSumResults.stream().map(RecordMetaDSumResult::getDeviceId).collect(Collectors.toList()); + QueryWrapper<YwPoint> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("serial_number", serialNumbers); + //鑾峰彇鍏徃鎵�杩愮淮鐨勮澶囬泦鍚堬紝key涓簎nitId value涓鸿澶囧浗鏍囩爜闆嗗悎 + Map<Long, List<String>> unitMonitorMap = ywPointMapper.selectList(queryWrapper).stream() + .filter(ywPoint -> ywPoint.getUnitId() != null).collect(Collectors.groupingBy(YwPoint::getUnitId, + Collectors.mapping( + YwPoint::getSerialNumber, + Collectors.toList()))); + if (!CollectionUtils.isEmpty(contractMap)) { + contractMap.forEach((contractId, ruleList) -> { + //姝よ鍒欏搴旂殑unitId鍧囩浉绛� + CalculateRuleVO ruleVO = ruleList.get(0); + Integer unitId = ruleVO.getUnitId(); + List<String> monitorList = unitMonitorMap.get(Long.parseLong(unitId + "")); + for (RecordMetaDSumResult result : recordMetaDSumResults) { + //鍒ゆ柇鏄惁鎶ュ杩� + if (!CollectionUtils.isEmpty(reportNumbers)) { + if (reportNumbers.contains(result.getDeviceId())) continue; + } + //鍒ゆ柇鏄惁鏄鍏徃杩愮淮 + if (monitorList.contains(result.getDeviceId())) { + //褰曞儚鐘舵�佷笉瀹屾暣 + if (!Objects.equals(result.getRecordStatus(), ApiConstants.UY_RecordStatus_Integrity)) { + for (CalculateRuleVO calculateRuleVO : ruleList) { + Double max = calculateRuleVO.getMax(); + Double min = calculateRuleVO.getMin(); + //鍒ゆ柇鑼冨洿鍦ㄥ摢涓尯闂� 鍗曚綅鏄皬鏃惰浆鎹负鍒嗛挓 + if (checkRange(min, max, BigDecimal.valueOf(result.getMissDuration() * 60))) { + if (calculateRuleVO.getNum() == null) { + calculateRuleVO.setNum(1); + } else { + calculateRuleVO.setNum(calculateRuleVO.getNum() + 1); } } } } } - for (CalculateRuleVO calculateRuleVO : ruleList) { - if (calculateRuleVO.getNum() != null && calculateRuleVO.getNum() > 0) { - //闇�瑕佹墸闄ょ殑鍒嗘暟锛屾瑙勫垯鍙湁涓�鏉′笉闇�瑕佸垽鏂寖鍥� - double deductScore = calculateRuleVO.getCalcFraction() * calculateRuleVO.getNum(); - ContractScore contractScore = getContractScore(calculateRuleVO, deductScore, calculateRuleVO.getNum() + "", Remark + calculateRuleVO.getNum() + "璺澶囪繚鍙嶈鍒�"); - contractScoreList.add(contractScore); - } + } + for (CalculateRuleVO calculateRuleVO : ruleList) { + if (calculateRuleVO.getNum() != null && calculateRuleVO.getNum() > 0) { + //闇�瑕佹墸闄ょ殑鍒嗘暟锛屾瑙勫垯鍙湁涓�鏉′笉闇�瑕佸垽鏂寖鍥� + double deductScore = calculateRuleVO.getCalcFraction() * calculateRuleVO.getNum(); + ContractScore contractScore = getContractScore(calculateRuleVO, deductScore, calculateRuleVO.getNum() + "", Remark +"鎶芥煡鏃堕棿"+format.format(date)+"瀛樺湪"+ calculateRuleVO.getNum() + "璺澶囪繚鍙嶈鍒�"); + contractScoreList.add(contractScore); } - }); - } - contractScoreService.saveBatch(contractScoreList); - log.info("缁撴潫鎶芥煡褰曞儚瀹屾暣鐘舵��"); + } + }); } + contractScoreService.saveBatch(contractScoreList); + } + + private Date getRandomDate() { + // 鑾峰彇褰撳墠鏃ュ巻瀹炰緥 + Calendar calendar = Calendar.getInstance(); + + // 鑾峰彇褰撳墠鏃ユ湡 + Date now = calendar.getTime(); + + // 璁剧疆涓哄綋鍓嶆湀浠界殑绗竴澶� + calendar.setTime(now); + calendar.set(Calendar.DAY_OF_MONTH, 1); + Date firstDayOfMonth = calendar.getTime(); + + // 璁剧疆涓哄綋鍓嶆湀浠界殑鏈�鍚庝竴澶╋紙涓嬩釜鏈堢殑绗竴澶╁噺涓�锛� + calendar.add(Calendar.MONTH, 1); + calendar.set(Calendar.DAY_OF_MONTH, 0); // Calendar.DAY_OF_MONTH璁句负0琛ㄧず涓婁釜鏈堟渶鍚庝竴澶╋紝浣嗚繖閲屾槸涓轰簡寰楀埌鏈湀鏈�鍚庝竴澶╋紝鎵�浠ュ厛鍔犱竴鏈� + Date lastDayOfMonth = calendar.getTime(); + log.info("鏈�鍚庝竴澶�" + lastDayOfMonth); + // 璁$畻澶╂暟宸紙鍔�1鍥犱负鍖呭惈璧峰鍜岀粨鏉熸棩鏈燂級 + long daysBetween = (lastDayOfMonth.getTime() - firstDayOfMonth.getTime()) / (1000 * 60 * 60 * 24) + 1; + + // 鐢熸垚闅忔満鏁� + Random random = new Random(); + int randomDayIndex = random.nextInt((int) daysBetween); + + // 鑾峰彇闅忔満鏃ユ湡 + calendar.setTime(firstDayOfMonth); + calendar.add(Calendar.DAY_OF_MONTH, randomDayIndex); + Date randomDate = calendar.getTime(); + return randomDate; } private boolean checkRange(Double min, Double max, BigDecimal index) { diff --git a/ycl-server/src/main/java/com/ycl/task/OsdTask.java b/ycl-server/src/main/java/com/ycl/task/OsdTask.java index 83c71f5..5f4f8b9 100644 --- a/ycl-server/src/main/java/com/ycl/task/OsdTask.java +++ b/ycl-server/src/main/java/com/ycl/task/OsdTask.java @@ -11,6 +11,7 @@ import com.ycl.api.HK.HKApi; import com.ycl.api.YS.YSApi; import com.ycl.platform.domain.entity.TMonitor; +import com.ycl.platform.domain.result.BaseResult; import com.ycl.platform.domain.result.OSDResult; import com.ycl.platform.domain.result.UY.MonitorQualifyResult; import com.ycl.platform.domain.result.UY.OsdCheckResult; @@ -142,8 +143,19 @@ //濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎 Query pyQuery = new Query(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); - DeleteResult result = mongoTemplate.remove(pyQuery, OsdCheckResult.class); + List<OsdCheckResult> osdCheckResults = mongoTemplate.find(pyQuery, OsdCheckResult.class); pointService.setDeviceTagByGB(checkResults, CheckConstants.Rule_Category_Video); + //娣诲姞鏃ф暟鎹繘鍘� + List<String> resultNos = checkResults.stream().map(BaseResult::getNo).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(osdCheckResults)) { + for (OsdCheckResult mongoResult : osdCheckResults) { + //濡傛灉鏂扮殑缁撴灉涓病鏈夋棫鏁版嵁閭d箞鍔犺繘鍘� + if (!resultNos.contains(mongoResult.getNo())) { + checkResults.add(mongoResult); + } + } + } + DeleteResult result = mongoTemplate.remove(pyQuery, OsdCheckResult.class); //瀛樻斁鍦╩ongo涓� mongoTemplate.insertAll(checkResults); // 宸ュ崟鐢熸垚 @@ -231,7 +243,9 @@ public void test() throws ExecutionException, InterruptedException { log.info("娴嬭瘯鑾峰彇OSD"); - OSDResult osd3 = DHApi.getOsd("51030446001320141102","51.95.68.3", DHUserName, DHPassword); - log.info("澶у崕缁撴灉鏁版嵁:{}",osd3); + OSDResult osd3 = DHApi.getOsdOld("51030340001320207201", "51.95.34.20", DHUserName, DHPassword); + log.info("osd3:{}", osd3); + OSDResult osd4 = DHApi.getOsdOld("51030342001320173201", "51.95.33.174", DHUserName, DHPassword); + log.info("osd4:{}", osd4); } } diff --git a/ycl-server/src/main/java/com/ycl/task/PlatformTask.java b/ycl-server/src/main/java/com/ycl/task/PlatformTask.java index 76a5402..f9ca8df 100644 --- a/ycl-server/src/main/java/com/ycl/task/PlatformTask.java +++ b/ycl-server/src/main/java/com/ycl/task/PlatformTask.java @@ -45,7 +45,7 @@ private static final String DICT_TYPE = "platform_online"; private static final ExecutorService executorService = new ThreadPoolExecutor(16, - 128, + 64, 5000, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), @@ -68,17 +68,17 @@ for (int tryTimes = 1; tryTimes < 3; tryTimes++) { // 涓夌鏈猵ing閫氶噸璇曚竴娆★紝濡傛灉涓嶈鎵嶆墸鍒� reachable = InetAddress.getByName(platform.getPlatformIP()).isReachable(3000); - if (! reachable && tryTimes == 0) { - continue; - } - if (! reachable) { - // 濡傛灉ping涓嶉�氾紝绂荤嚎鏃堕暱鍔�5绉� - redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5); - log.warn(platform.getPlatformName() + "骞冲彴鏈猵ing閫�"); + if (reachable) { + break; } } + if (!reachable) { + // 濡傛灉ping涓嶉�氾紝绂荤嚎鏃堕暱鍔�5绉� + redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5); + log.warn(platform.getPlatformName() + "骞冲彴鏈猵ing閫�"); + } } catch (Exception e) { - log.error("妫�鏌ュ钩鍙拌繛閫氭�ф椂鍙戠敓閿欒", e); + log.error("妫�鏌ュ钩鍙拌繛閫氭�ф椂鍙戠敓d閿欒", e); } }); } 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 d75304f..81fc81c 100644 --- a/ycl-server/src/main/java/com/ycl/task/UYTask.java +++ b/ycl-server/src/main/java/com/ycl/task/UYTask.java @@ -75,7 +75,7 @@ private String passwd; private static final ExecutorService executorService = new ThreadPoolExecutor(16, - 128, + 64, 5000, TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000), @@ -214,7 +214,7 @@ OnlineCheckThread thread = new OnlineCheckThread(monitor, checkPointUtil, time); return thread.call(); // 鍋囪 OnlineCheckThread 瀹炵幇浜� Callable 鎺ュ彛 }, executorService) - .orTimeout(60, TimeUnit.SECONDS) + .orTimeout(180, TimeUnit.SECONDS) .exceptionally(ex -> { if (ex instanceof TimeoutException) { log.error("浠诲姟鎵ц瓒呮椂:"+monitor.getIp()); diff --git a/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java b/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java index 9f873da..1ccda7a 100644 --- a/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java +++ b/ycl-server/src/main/java/com/ycl/utils/CheckPointUtil.java @@ -54,6 +54,7 @@ String prefix = "http://"; if ("127.0.0.1".equals(monitor.getIp())) { monitor.setPingOnline(Boolean.FALSE); + log.error("ip鏈夎"+monitor.getIp()); return monitor; } try { @@ -84,11 +85,7 @@ map = new HashMap<>(); } if (!monitor.getPingOnline()) { - try { - reachable = InetAddress.getByName(monitor.getIp()).isReachable(5000); - } catch (IOException e) { - e.printStackTrace(); - } + reachable = checkPing(monitor, reachable); monitor.setPingOnline(reachable); } if (!monitor.getPingOnline()) { @@ -98,19 +95,17 @@ Date now = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); offTimeList.add(dateFormat.format(now)); + monitor.setOffLineTimeStr(offTimeList); //鍒拌揪浜х敓宸ュ崟鐨勯槇鍊兼鏁� if (continueOffTimes>=times) { //浜х敓浜嗗伐鍗曟墠浼氬瓨鍌ㄧ绾挎椂闂�,瀛樺偍鏈�杩戜竴娆′骇鐢熷伐鍗曠殑杩欏嚑涓绾挎椂闂寸偣 - monitor.setOffLineTimeStr(offTimeList); monitor.setCreateWorkOrder(Boolean.TRUE); //浜х敓浜嗕竴娆″伐鍗曞垯娓呴櫎 continueOffTimes = 0; - offTimeList = new ArrayList<>(); } }else { //濡傛灉鍦ㄧ嚎浜嗭紝娓呯┖杩炵画绂荤嚎娆℃暟锛屾竻绌虹绾挎椂闂� continueOffTimes = 0; - offTimeList = new ArrayList<>(); } map.put("checkTimes", checkTimes); map.put("offLineTimes", offLineTimes); @@ -122,6 +117,22 @@ return monitor; } + private boolean checkPing(TMonitorResult monitor, boolean reachable) { + try { + int[] sleepTimes = {5000, 15000, 30000}; + for (int sleepTime : sleepTimes) { + reachable = InetAddress.getByName(monitor.getIp()).isReachable(5000); + if (reachable) { + break; + } + Thread.sleep(sleepTime); + } + } catch (Exception e) { + log.error("Ping寮傚父",e); + } + return reachable; + } + /** * 鐩戞祴鐐逛綅鍦ㄧ嚎 diff --git a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml index bbd8c77..6852b2a 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml @@ -151,6 +151,7 @@ a.rule_name as ruleName, a.rule_condition as detailName, COUNT(b.id) AS num, + a.calc_fraction as calcFraction, IFNULL(-SUM(b.score), 0) AS score FROM t_calculate_rule a LEFT JOIN t_calculate_record tcr ON a.contract_id = tcr.contract_id diff --git a/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml index cd84be6..e18e830 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/TMonitorMapper.xml @@ -396,7 +396,7 @@ IFNULL(SUM(IF((p.online = 1 and p.ping_online = 1), 1, 0)), 0) AS totalMembers, IFNULL(SUM(IF((p.online = -1 or p.ping_online = -1), 1, 0)), 0) AS postsPercentage, IFNULL(SUM(IF((p.online = 0 and p.ping_online = 0), 1, 0)), 0) AS unknownNumbers, - IFNULL(ROUND(SUM(IF((p.online = 1 and p.online= 1), 1, 0)) / count(*) * 100, 2), 0) as viewsPercentage + IFNULL(ROUND(SUM(IF((p.online = 1 and p.ping_online= 1), 1, 0)) / count(*) * 100, 2), 0) as viewsPercentage FROM t_monitor m left join t_yw_point p on m.serial_number = p.serial_number left join sys_dept d on p.dept_id = d.dept_id and d.del_flag = 0 diff --git a/ycl-server/src/main/resources/mapper/zgyw/WorkOrderErrorTypeMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/WorkOrderErrorTypeMapper.xml index d2bf388..fb0e3b3 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/WorkOrderErrorTypeMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/WorkOrderErrorTypeMapper.xml @@ -97,12 +97,25 @@ </foreach> </insert> - <select id="getErrorList" resultType="com.ycl.system.entity.SysDictData"> - SELECT da.dict_value, da.dict_label + + <select id="getErrorListByNumbers" resultType="com.ycl.platform.domain.vo.WorkOrderVO"> + SELECT m.ip,da.dict_value as errorType FROM t_work_order_error_type oer - INNER JOIN sys_dict_data da ON oer.error_name = da.dict_value - WHERE oer.work_order_no = #{workOrderNo} + INNER JOIN sys_dict_data da ON oer.error_name = da.dict_value + left join t_work_order wo on oer.work_order_no = wo.work_order_no + left join t_monitor m on m.serial_number = wo.serial_number + WHERE oer.work_order_no in + <foreach collection="workOrderNos" separator="," open="(" close=")" item="workOrderNo"> + #{workOrderNo} + </foreach> ORDER BY oer.create_time </select> + <select id="getErrorList" resultType="com.ycl.system.entity.SysDictData"> + SELECT da.dict_value, da.dict_label + FROM t_work_order_error_type oer + INNER JOIN sys_dict_data da ON oer.error_name = da.dict_value + WHERE oer.work_order_no = #{workOrderNo} + ORDER BY oer.create_time + </select> </mapper> -- Gitblit v1.8.0