| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | |
| | | private final CheckIndexVideoMapper checkIndexVideoMapper; |
| | | private final ImageResourceSecurityDetailMapper imageResourceSecurityDetailMapper; |
| | | |
| | | private static final BigDecimal NUM = new BigDecimal("0.15"); |
| | | |
| | | /** |
| | | * 每天晚上1点执行 |
| | | */ |
| | | @Transactional |
| | | @Scheduled(cron = "0 0 1 * * ?") |
| | | public void calc() { |
| | | ArrayList<ImageResourceSecurity> imageResourceSecurities = new ArrayList<>(); |
| | |
| | | for (ImageResourceSecurityDetail imageResourceSecurityDetail : detailList) { |
| | | // 扣除分数 |
| | | score -= imageResourceSecurityDetail.getAlarmCategory().getScore(); |
| | | imageResourceSecurity.setWeakPassword(BigDecimal.valueOf(score)); |
| | | // 统计数量 |
| | | if (Integer.parseInt(imageResourceSecurityDetail.getAlarmLevel().getValue()) > 1) { |
| | | count++; |
| | | } |
| | | } |
| | | imageResourceSecurity.setWeakPassword(BigDecimal.valueOf(score)); |
| | | // 获取字典值-总数 |
| | | int onlineAssetsTotal = Integer.parseInt(DictUtils.getDictValue("online_assets_total", checkIndexVideo.getDeptName())); |
| | | imageResourceSecurity.setRiskProperty(BigDecimal.valueOf(count / onlineAssetsTotal)); |
| | | imageResourceSecurity.setCreateTime(DateUtils.getNowDate()); |
| | | imageResourceSecurities.add(imageResourceSecurity); |
| | | // 更新指标数据 |
| | | checkIndexVideo.setImageResourceSecurity(imageResourceSecurity.getPlatformOnline().add(imageResourceSecurity.getPropertyAccuracy().add(imageResourceSecurity.getWeakPassword().add(imageResourceSecurity.getRiskProperty()))).multiply(NUM)); |
| | | checkIndexVideoMapper.updateById(checkIndexVideo); |
| | | } |
| | | imageResourceSecurityService.saveBatch(imageResourceSecurities); |
| | | |