| | |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Override |
| | | public Map<String, List<Map<String, Object>>> countEverydayAlarmAndWarning() { |
| | | Map<String, List<Map<String, Object>>> result = new HashMap<>(); |
| | | |
| | | Map<String, Object> param = new HashMap<String, Object>(); |
| | | Date now = new Date(); |
| | | Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 上周的今天 |
| | | param.put("startTime", ymdhms.format(last)); |
| | | param.put("endTime", ymdhms.format(now)); |
| | | |
| | | param.put("type", 0); |
| | | Date endTime = DateUtils.getNowDate(); |
| | | //上周的今天 |
| | | param.put("startTime", DateUtils.getAPeriodOfTime(endTime, -7, Calendar.DATE)); |
| | | param.put("endTime", endTime); |
| | | List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param); |
| | | result.put("alarmDayCount", alarmDayCount); |
| | | |
| | | param.put("type", 1); |
| | | List<Map<String, Object>> warningDayCount = warningDetailMapper.selectWarningDayCountByMap(param); |
| | | result.put("warningDayCount", warningDayCount); |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | AND date_format(create_time, '%Y%m%d%H%I%S') <= date_format(#{endTime}, '%Y%m%d%H%I%S') |
| | | AND type = #{type} |
| | | </select> |
| | | |
| | | <select id="selectWarningDayCountByMap" parameterType="java.util.Map" resultType="java.util.Map"> |
| | | SELECT date_format(create_time,'%Y%m%d') AS createTime, count(id) AS num |
| | | |
| | | <select id="selectWarningDayCountByMap_old" parameterType="java.util.Map" resultType="java.util.Map"> |
| | | SELECT date_format(create_time,'%Y%m%d') AS createTime, count(id) AS num |
| | | FROM warning_detail |
| | | WHERE date_format(create_time, '%Y%m%d%H%I%S') >= date_format(#{startTime}, '%Y%m%d%H%I%S') |
| | | AND date_format(create_time, '%Y%m%d%H%I%S') <= date_format(#{endTime}, '%Y%m%d%H%I%S') |
| | | AND type = #{type} |
| | | GROUP BY DATE_FORMAT(create_time,'%Y%m%d%') |
| | | ORDER BY create_time ASC |
| | | </select> |
| | | |
| | | <select id="selectWarningDayCountByMap" parameterType="java.util.Map" resultType="java.util.Map"> |
| | | with rs as ( |
| | | select date_format(create_time, '%Y%m%d') AS ct, id, type |
| | | from warning_detail |
| | | where create_time between #{startTime} and #{endTime} and type = #{type} |
| | | ) |
| | | select ct as createTime, count(id) as num |
| | | from rs |
| | | group by ct |
| | | order by ct asc; |
| | | </select> |
| | | |
| | | <insert id="batchInsert"> |