From 759bbb8ee99665382a689fa90277a9b2279238da Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期五, 19 八月 2022 19:04:02 +0800 Subject: [PATCH] Merge branches 'genchuang' and 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into master --- incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) diff --git a/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java new file mode 100644 index 0000000..bcadd55 --- /dev/null +++ b/incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentCountServiceImpl.java @@ -0,0 +1,56 @@ +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<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportCountQuery query) { + + List<AccidentReportCount> 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<AccidentReportCountRespDTO> accidentReportCountRespDTOList = BeanCopyUtils.copyBeanList(list, AccidentReportCountRespDTO.class); + return new ResultVO<>(ResultCodes.OK, accidentReportCountRespDTOList); + } + +} -- Gitblit v1.9.2