package com.gkhy.safePlatform.incidentManage.service.impl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.incidentManage.entity.*; import com.gkhy.safePlatform.incidentManage.model.dto.resp.*; import com.gkhy.safePlatform.incidentManage.query.AccidentReportCountQuery; import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery; import com.gkhy.safePlatform.incidentManage.service.AccidentCountService; import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService; import com.gkhy.safePlatform.incidentManage.utils.TimeUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; @Service("accidentCountService") public class AccidentCountServiceImpl implements AccidentCountService { @Autowired private AccidentReportInfoService accidentReportInfoService; @Override public ResultVO> countAccidentReport(AccidentReportCountQuery query) { List list = new ArrayList<>(); AccidentReportRPCDBQuery dbQuery = new AccidentReportRPCDBQuery(); if (query.getType() == 1) { // 月 int year = query.getYear(); int month; if (query.getMonth() == 0) { Calendar date = Calendar.getInstance(); month = date.get(Calendar.MONTH) + 1; } else { month = query.getMonth(); } dbQuery.setStartTime(TimeUtils.getMonthFirst(year, month)); dbQuery.setEndTime(TimeUtils.getMonthLast(year, month)); list = accidentReportInfoService.selectByTimeAndType(dbQuery); } if (query.getType() == 2) { // 年 int year = query.getYear(); dbQuery.setStartTime(TimeUtils.getYearFirst(year)); dbQuery.setEndTime(TimeUtils.getYearLast(year)); list = accidentReportInfoService.selectByTimeAndType(dbQuery); } List accidentReportCountRespDTOList = BeanCopyUtils.copyBeanList(list, AccidentReportCountRespDTO.class); return new ResultVO<>(ResultCodes.OK, accidentReportCountRespDTOList); } }