From c8ca3c42906b89c5de910ad3ff9f164e6b846a4c Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 09 八月 2024 15:41:21 +0800 Subject: [PATCH] 一机一档合格率 --- ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java index 2ae0bfb..6514277 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java +++ b/ycl-server/src/main/java/com/ycl/calculate/PlatformOnlineCalculation.java @@ -1,13 +1,67 @@ package com.ycl.calculate; +import com.ycl.platform.domain.entity.CheckIndexVideo; import com.ycl.platform.domain.result.UY.QueryVqdResult; +import com.ycl.platform.domain.vo.PlatformOnlineVO; +import com.ycl.platform.mapper.CheckIndexVideoMapper; +import com.ycl.platform.service.ICheckIndexVideoService; +import com.ycl.system.mapper.SysDeptMapper; +import constant.ApiConstants; +import constant.CheckConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import utils.DateUtils; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; -public class PlatformOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<QueryVqdResult> { +/** + * 骞冲彴鍦ㄧ嚎鐜囪绠� + * 绂荤嚎鏃堕暱姣忚秴杩�30鍒嗛挓鎵g櫨鍒嗕箣鍗� + * 涓嶅尯鍒嗗尯鍩� + */ +@Component +public class PlatformOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<PlatformOnlineVO> { + @Autowired + private SysDeptMapper deptMapper; + @Autowired + private CheckIndexVideoMapper videoMapper; + @Autowired + private ICheckIndexVideoService checkIndexVideoService; @Override - public void calculate(List<QueryVqdResult> list) { + public void calculate(List<PlatformOnlineVO> list) { + if (!CollectionUtils.isEmpty(list)) { + //鎬荤绾挎椂闀� + int time = list.stream().map(PlatformOnlineVO::getTodayOutlineSed).reduce(0, Integer::sum); + //绂荤嚎鏃堕暱杞崲浣嶅垎閽熺劧鍚庡彇妯� + int num = (time / 60) % 30; + double score = Math.max(1 - num * 0.1, 0); + //鏄惁宸茬粡瀛樺湪褰撴棩鏁版嵁 + List<CheckIndexVideo> checkIndexVideos = videoMapper.selectToday(DateUtils.getDate()); + //鎵�鏈夊尯鍩熼儴闂� + List<Long> deptIds = deptMapper.selectByParentId(207L); + List<String> keys = new ArrayList<>(); + //鍑嗗鍖哄垎鐪佸巺銆佸尯鍩熺殑deptId list + for (Long deptId : deptIds) { + keys.add(deptId + ""); + keys.add(ApiConstants.Province + deptId); + } + List<CheckIndexVideo> videos = new ArrayList<>(); + keys.forEach(key -> { + //濡傛灉涓嶅瓨鍦ㄥ氨鏂板濡傛灉瀛樺湪鍒欏鐢� + CheckIndexVideo checkIndex = getCheckIndex(key, checkIndexVideos, CheckIndexVideo.class); + if (checkIndex != null) { + checkIndex.setPlatformOnline(new BigDecimal(score)); + videos.add(checkIndex); + } + }); + checkIndexVideoService.saveOrUpdateBatch(videos); + } } } -- Gitblit v1.8.0