class AlertServiceImpl implements AlertService {

    @Autowired
    private AlertDao alertDao;
    
    @Autowired
    private AlarmCommonReduce alarmCommonReduce;

    @Override
    public void addAlert(Alert alert) throws RuntimeException {
        alertDao.save(alert);
    }

    @Override
    public Page<Alert> getAlerts(Specification<Alert> specification, PageRequest pageRequest) {
        return alertDao.findAll(specification, pageRequest);
    }

    @Override
    public void deleteAlerts(HashSet<Long> ids) {
        alertDao.deleteAlertsByIdIn(ids);
    }

    @Override
    public void clearAlerts() {
        alertDao.deleteAll();
    }

    @Override
    public void editAlertStatus(Byte status, List<Long> ids) {
        alertDao.updateAlertsStatus(status, ids);
    }

    @Override
    public AlertSummary getAlertsSummary() {<FILL_FUNCTION_BODY>}

    @Override
    public void addNewAlertReport(AlertReport alertReport) {
        alarmCommonReduce.reduceAndSendAlarm(buildAlertData(alertReport));
    }

    @Override
    public List<Alert> getAlerts(Specification<Alert> specification) {

        return alertDao.findAll(specification);
    }

    /**
     * The external alarm information is converted to Alert  
     * @param alertReport alarm body
     * @return Alert entity
     */
    private Alert buildAlertData(AlertReport alertReport){
        Map<String, String> annotations = alertReport.getAnnotations();
        StringBuilder sb = new StringBuilder();
        if (alertReport.getContent() == null || alertReport.getContent().length() <= 0){
            StringBuilder finalSb = sb;
            annotations.forEach((k, v) -> {
                finalSb.append(k).append(":").append(v).append("\n");
            });
        }else {
            sb = new StringBuilder(alertReport.getContent());
        }
        LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(alertReport.getAlertTime()), 
                ZoneId.systemDefault());
        return Alert.builder()
                .content("Alert Center\n" + sb)
                .priority(alertReport.getPriority().byteValue())
                .status(CommonConstants.ALERT_STATUS_CODE_PENDING)
                .tags(alertReport.getLabels())
                .target(alertReport.getAlertName())
                .triggerTimes(1)
                .firstAlarmTime(alertReport.getAlertTime())
                .lastAlarmTime(alertReport.getAlertTime())
                .gmtCreate(dateTime)
                .gmtUpdate(dateTime)
                .build();
    }



}

        AlertSummary alertSummary = new AlertSummary();
        // Statistics on the alarm information in the alarm state
        List<AlertPriorityNum> priorityNums = alertDao.findAlertPriorityNum();
        if (priorityNums != null) {
            for (AlertPriorityNum priorityNum : priorityNums) {
                switch (priorityNum.getPriority()) {
                    case CommonConstants
                            .ALERT_PRIORITY_CODE_WARNING:
                        alertSummary.setPriorityWarningNum(priorityNum.getNum());
                        break;
                    case CommonConstants.ALERT_PRIORITY_CODE_CRITICAL:
                        alertSummary.setPriorityCriticalNum(priorityNum.getNum());
                        break;
                    case CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY:
                        alertSummary.setPriorityEmergencyNum(priorityNum.getNum());
                        break;
                    default:
                        break;
                }
            }
        }
        long total = alertDao.count();
        alertSummary.setTotal(total);
        long dealNum = total - alertSummary.getPriorityCriticalNum()
                - alertSummary.getPriorityEmergencyNum() - alertSummary.getPriorityWarningNum();
        alertSummary.setDealNum(dealNum);
        try {
            if (total == 0) {
                alertSummary.setRate(100);
            } else {
                float rate = BigDecimal.valueOf(100 * (float) dealNum / total)
                        .setScale(2, RoundingMode.HALF_UP)
                        .floatValue();
                alertSummary.setRate(rate);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return alertSummary;
    
<no_super_class>