package com.gyee.healthmodel.service; import com.gyee.healthmodel.model.auto.Alarmcount; import com.gyee.healthmodel.service.auto.IAlarmcountService; import com.gyee.healthmodel.util.DateUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; /** * @ClassName : AlarmcountsService * @Description : 自定义报警统计service */ @Service public class AlarmcountsService { private final int DIGIT=2; @Resource private IAlarmcountService alarmcountService; public String findAlarmcount(Long snapid, Date beginDate,Date endDate) { List alarmlist = alarmcountService.findAlarmcount(snapid, DateUtils.truncate(beginDate),DateUtils.truncate(endDate)); if (!alarmlist.isEmpty()) { for (int i = 0; i < alarmlist.size() - 1; i++) { for (int j = alarmlist.size() - 1; j > i; j--) { if (alarmlist.get(i).getAlarmdate() .equals(alarmlist.get(j).getAlarmdate()) && alarmlist.get(i).getSnapid() .equals(alarmlist.get(j).getSnapid())) { alarmlist.remove(j); } } } double sumCount = 0; double count = 0; for (Alarmcount ac : alarmlist) { sumCount += ac.getCount(); count++; } return sumCount + "," + count; } return "0.0,0.0"; } public Double findyearstodayAlarmcount(Long snapid, Date beginDate,Date endDate) { List alarmlist = alarmcountService.findAlarmcount(snapid, DateUtils.truncate(beginDate),DateUtils.truncate(endDate)); if (!alarmlist.isEmpty()) { for (int i = 0; i < alarmlist.size() - 1; i++) { for (int j = alarmlist.size() - 1; j > i; j--) { if (alarmlist.get(i).getAlarmdate() .equals(alarmlist.get(j).getAlarmdate()) && alarmlist.get(i).getSnapid() .equals(alarmlist.get(j).getSnapid())) { alarmlist.remove(j); } } } double sumCount = 0; for (Alarmcount ac : alarmlist) { sumCount += ac.getCount(); } return sumCount; } return 0.0; } }