| | |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import constant.CheckConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | * 计算公式 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class IndexCalculationServe { |
| | | |
| | | //点位在线率 |
| | |
| | | return result.setScale(4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //数据完整性 |
| | | public BigDecimal dataIntegrity(Map<String, Object> param){ |
| | | //车辆数据完整性 |
| | | public BigDecimal dataIntegrity(Map<String, Object> param) { |
| | | BigDecimal totalSites = new BigDecimal((Integer) param.get("totalSites")); |
| | | BigDecimal importantTotalSites = new BigDecimal((Integer) param.get("importantTotalSites")); |
| | | BigDecimal integritySites = new BigDecimal((Integer) param.get("integritySites")); |
| | |
| | | .add(importantIntegritySites.divide(importantTotalSites, 10, RoundingMode.HALF_UP)); |
| | | return result.setScale(4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //车辆数据完整性 |
| | | public BigDecimal dataAccuracy(Map<String, Object> param) { |
| | | BigDecimal totalSites = new BigDecimal((Integer) param.get("totalSites")); |
| | | BigDecimal importantTotalSites = new BigDecimal((Integer) param.get("importantTotalSites")); |
| | | BigDecimal accuracySites = new BigDecimal((Integer) param.get("accuracySites")); |
| | | BigDecimal importantAccuracySites = new BigDecimal((Integer) param.get("importantAccuracySites")); |
| | | BigDecimal result = accuracySites.divide(totalSites, 10, RoundingMode.HALF_UP) |
| | | .add(importantAccuracySites.divide(importantTotalSites, 10, RoundingMode.HALF_UP)); |
| | | return result.setScale(4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //时钟准确性 |
| | | public BigDecimal clockAccuracy(Map<String, Object> param) { |
| | | BigDecimal totalSitesCount = new BigDecimal((Integer) param.get("totalSites")); |
| | | BigDecimal accuracySites = new BigDecimal((Integer) param.get("accuracySites")); |
| | | return accuracySites.divide(totalSitesCount, 4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //url可用性 |
| | | public BigDecimal urlUsability(Map<String, Object> param) { |
| | | BigDecimal totalSitesCount = new BigDecimal((Integer) param.get("totalSites")); |
| | | BigDecimal urlQualifySites = new BigDecimal((Integer) param.get("urlQualifySites")); |
| | | return urlQualifySites.divide(totalSitesCount, 4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //大图可用性 |
| | | public BigDecimal picUsability(Map<String, Object> param) { |
| | | BigDecimal totalSitesCount = new BigDecimal((Integer) param.get("totalSites")); |
| | | BigDecimal picUsabilitySites = new BigDecimal((Integer) param.get("picUsabilitySites")); |
| | | return picUsabilitySites.divide(totalSitesCount, 4, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | |
| | | //返回省厅国标码集合 |
| | | public List<String> getProvince() { |
| | |
| | | } |
| | | |
| | | //检查是否存在当日数据 |
| | | public <T extends CheckIndex> T getCheckIndex(String key, List<T> checkIndexList) { |
| | | public <T extends CheckIndex> T getCheckIndex(String key, List<T> checkIndexList, Class<T> clazz) { |
| | | T checkIndex; |
| | | |
| | | // 检查是否已存在今日数据 |
| | |
| | | checkIndex = existingIndex.get(); |
| | | } else { |
| | | try { |
| | | checkIndex = (T) CheckIndexCar.class.getDeclaredConstructor().newInstance(); |
| | | checkIndex = clazz.getDeclaredConstructor().newInstance(); |
| | | checkIndex.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); |
| | | checkIndex.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); |
| | | checkIndex.setCreateTime(new Date()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("无法创建 CheckIndexCar 实例", e); |
| | | checkIndex = null; |
| | | log.error("无法创建 checkIndex 实例", e); |
| | | } |
| | | } |
| | | return checkIndex; |