songhuangfeng123
2022-08-08 2f71d2a6f77277766f81ecfcfc1df19a4784e897
事故rpc接口
已重命名2个文件
已修改13个文件
已添加5个文件
425 ■■■■■ 文件已修改
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/EmergencyDrillExecuteCountData.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyDrillExecuteCountDataRespDTO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyDrillExecuteCountRespDTO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencyDrillExecuteInfoRepository.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencyDrillExecuteInfoService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyDrillExecuteInfoServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyDrillExecuteServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/resource/config/mapper/emergency/EmergencyDrillExecuteInfoMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentReportController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCount.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentReportCountRespDTO.java 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/query/AccidentReportRPCQuery.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/query/db/AccidentReportRPCDBQuery.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/utils/TimeUtils.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/EmergencyDrillExecuteCountData.java
文件名从 emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/entity/EmergencyDrillExecuteCountChart.java 修改
@@ -1,7 +1,7 @@
package com.gkhy.safePlatform.emergency.entity;
public class EmergencyDrillExecuteCountChart {
public class EmergencyDrillExecuteCountData {
    private Integer num ;
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyDrillExecuteCountDataRespDTO.java
文件名从 emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyDrillExecuteCountChartRespDTO.java 修改
@@ -1,7 +1,7 @@
package com.gkhy.safePlatform.emergency.model.dto.resp;
public class EmergencyDrillExecuteCountChartRespDTO {
public class EmergencyDrillExecuteCountDataRespDTO {
    private Integer num ;
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/model/dto/resp/EmergencyDrillExecuteCountRespDTO.java
@@ -7,7 +7,7 @@
    private Integer days;
    private List<EmergencyDrillExecuteCountChartRespDTO> dataList;
    private List<EmergencyDrillExecuteCountDataRespDTO> dataList;
    public Integer getDays() {
        return days;
@@ -17,11 +17,11 @@
        this.days = days;
    }
    public List<EmergencyDrillExecuteCountChartRespDTO> getDataList() {
    public List<EmergencyDrillExecuteCountDataRespDTO> getDataList() {
        return dataList;
    }
    public void setDataList(List<EmergencyDrillExecuteCountChartRespDTO> dataList) {
    public void setDataList(List<EmergencyDrillExecuteCountDataRespDTO> dataList) {
        this.dataList = dataList;
    }
}
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/repository/EmergencyDrillExecuteInfoRepository.java
@@ -2,11 +2,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountChart;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoDetailDO;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoPageDO;
import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteRPCQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteDBQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteRPCDBQuery;
import org.apache.ibatis.annotations.Param;
@@ -31,7 +30,7 @@
    Integer selectEmergencyDrillExecuteIntervalTime();
    List<EmergencyDrillExecuteCountChart> selectByMouthTimeAndType(@Param("query")EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountData> selectByMouthTimeAndType(@Param("query")EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountChart> selectByYearTimeAndType(@Param("query")EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountData> selectByYearTimeAndType(@Param("query")EmergencyDrillExecuteRPCDBQuery dbQuery);
}
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/EmergencyDrillExecuteInfoService.java
@@ -2,11 +2,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountChart;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoDetailDO;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoPageDO;
import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteRPCQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteDBQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteRPCDBQuery;
@@ -29,7 +28,7 @@
    Integer selectEmergencyDrillExecuteIntervalTime();
    List<EmergencyDrillExecuteCountChart> selectByMouthTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountData> selectByMouthTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountChart> selectByYearTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery);
    List<EmergencyDrillExecuteCountData> selectByYearTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery);
}
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/baseService/impl/EmergencyDrillExecuteInfoServiceImpl.java
@@ -2,11 +2,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountChart;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfo;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoDetailDO;
import com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteInfoPageDO;
import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteRPCQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteDBQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencyDrillExecuteRPCDBQuery;
import com.gkhy.safePlatform.emergency.repository.EmergencyDrillExecuteInfoRepository;
@@ -58,12 +57,12 @@
    }
    @Override
    public List<EmergencyDrillExecuteCountChart> selectByMouthTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery) {
    public List<EmergencyDrillExecuteCountData> selectByMouthTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery) {
        return emergencyDrillExecuteInfoRepository.selectByMouthTimeAndType(dbQuery);
    }
    @Override
    public List<EmergencyDrillExecuteCountChart> selectByYearTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery) {
    public List<EmergencyDrillExecuteCountData> selectByYearTimeAndType(EmergencyDrillExecuteRPCDBQuery dbQuery) {
        return emergencyDrillExecuteInfoRepository.selectByYearTimeAndType(dbQuery);
    }
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyDrillExecuteServiceImpl.java
@@ -1,11 +1,9 @@
package com.gkhy.safePlatform.emergency.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import com.gkhy.safePlatform.commons.utils.StringUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.emergency.entity.*;
@@ -30,7 +28,6 @@
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -244,12 +241,10 @@
        Integer days = emergencyDrillExecuteInfoService.selectEmergencyDrillExecuteIntervalTime();
        emergencyDrillExecuteCountRespDTO.setDays(days);
        List<EmergencyDrillExecuteCountChart> list = new ArrayList<>();
        // 根据时间、级别获取统计
        List<EmergencyDrillExecuteCountData> list = new ArrayList<>();
        EmergencyDrillExecuteRPCDBQuery dbQuery = new EmergencyDrillExecuteRPCDBQuery();
        dbQuery.setLevel(query.getLevel());
        // 根据时间、级别获取统计
        if (query.getType()==1){
            // 月
            int year = query.getYear();
@@ -267,7 +262,7 @@
        }
        if (!CollectionUtils.isEmpty(list)){
            List<EmergencyDrillExecuteCountChartRespDTO> dataList = BeanCopyUtils.copyBeanList(list,EmergencyDrillExecuteCountChartRespDTO.class);
            List<EmergencyDrillExecuteCountDataRespDTO> dataList = BeanCopyUtils.copyBeanList(list,EmergencyDrillExecuteCountDataRespDTO.class);
            emergencyDrillExecuteCountRespDTO.setDataList(dataList);
        }else{
            emergencyDrillExecuteCountRespDTO.setDataList(new ArrayList<>());
emergency/emergency-service/src/main/resource/config/mapper/emergency/EmergencyDrillExecuteInfoMapper.xml
@@ -125,7 +125,7 @@
        SELECT datediff( now( ), ( SELECT max( gmt_create ) FROM `emergency_drill_execute` ) )
    </select>
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountChart"
    <resultMap type="com.gkhy.safePlatform.emergency.entity.EmergencyDrillExecuteCountData"
               id="emergencyDrillExecuteCountChart">
        <result column="num" property="num"/>
        <result column="name" property="name"/>
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/controller/AccidentReportController.java
@@ -5,9 +5,11 @@
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportRPCQuery;
import com.gkhy.safePlatform.incidentManage.service.AccidentReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
@@ -65,4 +67,11 @@
        return accidentReportService.batchDeleteAccidentReport(ids);
    }
    /**
     * 事故报告统计的rpc接口
     */
    @RequestMapping(value = "/count",method = RequestMethod.POST)
    public ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(@RequestBody AccidentReportRPCQuery query){
        return accidentReportService.countAccidentReport(query);
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/entity/AccidentReportCount.java
对比新文件
@@ -0,0 +1,67 @@
package com.gkhy.safePlatform.incidentManage.entity;
import java.math.BigDecimal;
public class AccidentReportCount {
    private String name ;
    private Integer num ;
    private int minorInjuryNum;
    private int seriousInjuryNum;
    private int deathNum;
    private BigDecimal economicLoss;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public int getMinorInjuryNum() {
        return minorInjuryNum;
    }
    public void setMinorInjuryNum(int minorInjuryNum) {
        this.minorInjuryNum = minorInjuryNum;
    }
    public int getSeriousInjuryNum() {
        return seriousInjuryNum;
    }
    public void setSeriousInjuryNum(int seriousInjuryNum) {
        this.seriousInjuryNum = seriousInjuryNum;
    }
    public int getDeathNum() {
        return deathNum;
    }
    public void setDeathNum(int deathNum) {
        this.deathNum = deathNum;
    }
    public BigDecimal getEconomicLoss() {
        return economicLoss;
    }
    public void setEconomicLoss(BigDecimal economicLoss) {
        this.economicLoss = economicLoss;
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/model/dto/resp/AccidentReportCountRespDTO.java
对比新文件
@@ -0,0 +1,67 @@
package com.gkhy.safePlatform.incidentManage.model.dto.resp;
import java.math.BigDecimal;
public class AccidentReportCountRespDTO {
    private String name ;
    private Integer num ;
    private int minorInjuryNum;
    private int seriousInjuryNum;
    private int deathNum;
    private BigDecimal economicLoss;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public int getMinorInjuryNum() {
        return minorInjuryNum;
    }
    public void setMinorInjuryNum(int minorInjuryNum) {
        this.minorInjuryNum = minorInjuryNum;
    }
    public int getSeriousInjuryNum() {
        return seriousInjuryNum;
    }
    public void setSeriousInjuryNum(int seriousInjuryNum) {
        this.seriousInjuryNum = seriousInjuryNum;
    }
    public int getDeathNum() {
        return deathNum;
    }
    public void setDeathNum(int deathNum) {
        this.deathNum = deathNum;
    }
    public BigDecimal getEconomicLoss() {
        return economicLoss;
    }
    public void setEconomicLoss(BigDecimal economicLoss) {
        this.economicLoss = economicLoss;
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/query/AccidentReportRPCQuery.java
对比新文件
@@ -0,0 +1,45 @@
package com.gkhy.safePlatform.incidentManage.query;
public class AccidentReportRPCQuery {
    private String level;
    // type=1:月  type=2:年
    private Integer type;
    private int year;
    private int month;
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public int getYear() {
        return year;
    }
    public void setYear(int year) {
        this.year = year;
    }
    public int getMonth() {
        return month;
    }
    public void setMonth(int month) {
        this.month = month;
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/query/db/AccidentReportRPCDBQuery.java
对比新文件
@@ -0,0 +1,34 @@
package com.gkhy.safePlatform.incidentManage.query.db;
public class AccidentReportRPCDBQuery {
    private String level;
    private String startTime;
    private String endTime;
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    public String getStartTime() {
        return startTime;
    }
    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }
    public String getEndTime() {
        return endTime;
    }
    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/repository/AccidentReportInfoRepository.java
@@ -2,10 +2,12 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -23,4 +25,6 @@
    void updateAccidentReport(AccidentReportInfo accidentReportInfo);
    void deleteAccidentReportById(@Param("id") Long id);
    List<AccidentReportCount> selectByTimeAndType(@Param("query")AccidentReportRPCDBQuery dbQuery);
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/AccidentReportService.java
@@ -4,9 +4,11 @@
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportRPCQuery;
import java.util.List;
@@ -21,4 +23,6 @@
    ResultVO updateAccidentReport(Long uid, AccidentReportReqDTO AccidentReportReqDTO);
    ResultVO batchDeleteAccidentReport(Long[] ids);
    ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportRPCQuery query);
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/AccidentReportInfoService.java
@@ -2,10 +2,12 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery;
import java.util.List;
@@ -21,4 +23,7 @@
    void updateAccidentReport(AccidentReportInfo AccidentReportInfo);
    void deleteAccidentReportById(Long teamId);
    List<AccidentReportCount> selectByTimeAndType(AccidentReportRPCDBQuery dbQuery);
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/baseService/impl/AccidentReportInfoServiceImpl.java
@@ -2,10 +2,12 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfo;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoDetailDO;
import com.gkhy.safePlatform.incidentManage.entity.AccidentReportInfoPageDO;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery;
import com.gkhy.safePlatform.incidentManage.repository.AccidentReportInfoRepository;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,5 +46,9 @@
        accidentReportInfoRepository.deleteAccidentReportById(teamId);
    }
    @Override
    public List<AccidentReportCount> selectByTimeAndType(AccidentReportRPCDBQuery dbQuery) {
        return accidentReportInfoRepository.selectByTimeAndType(dbQuery);
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java
@@ -14,16 +14,21 @@
import com.gkhy.safePlatform.incidentManage.exception.AccidentException;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportFileReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportFileRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery;
import com.gkhy.safePlatform.incidentManage.query.AccidentReportRPCQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery;
import com.gkhy.safePlatform.incidentManage.service.AccidentReportService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportFileInfoService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService;
import com.gkhy.safePlatform.incidentManage.utils.TimeUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -219,6 +224,7 @@
        }
    }
    private void deleteAccidentReport(Long id) {
        //查询是否存在
        AccidentReportInfoDetailDO AccidentReportInfoDetailDO = accidentReportInfoService.selectAccidentReportById(id);
@@ -297,4 +303,29 @@
        }
    }
    @Override
    public ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportRPCQuery query) {
        List<AccidentReportCount> list = new ArrayList<>();
        AccidentReportRPCDBQuery dbQuery = new AccidentReportRPCDBQuery();
        if (query.getType()==1){
            // 月
            int year = query.getYear();
            int 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);
    }
}
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/utils/TimeUtils.java
对比新文件
@@ -0,0 +1,80 @@
package com.gkhy.safePlatform.incidentManage.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TimeUtils {
    public static String formatDate(Date date){
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        String sDate = f.format(date);
        return sDate;
    }
    /**
     * 获取某年第一天日期
     * @param year 年份
     * @return Date
     */
    public static String getYearFirst(int year){
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        Date currYearFirst = calendar.getTime();
        return formatDate(currYearFirst);
    }
    /**
     * 获取某年最后一天日期
     * @param year 年份
     * @return Date
     */
    public static String getYearLast(int year){
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.roll(Calendar.DAY_OF_YEAR, -1);
        Date currYearLast = calendar.getTime();
        return formatDate(currYearLast);
    }
    /**
     * 获取某月第一天日期
     * @param month 年份
     * @return Date
     */
    public static String getMonthFirst(int year ,int month){
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month-1);
        Date currYearFirst = calendar.getTime();
        return formatDate(currYearFirst);
    }
    /**
     * 获取某月最后一天日期
     * @param month 年份
     * @return Date
     */
    public static String getMonthLast(int year ,int month){
        Calendar calendar = Calendar.getInstance();
        calendar.clear();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month-1);
        calendar.roll(Calendar.DAY_OF_MONTH, -1);
        Date currYearLast = calendar.getTime();
        return formatDate(currYearLast);
    }
    public static void main(String[] args) {
        Calendar date = Calendar.getInstance();
        int year = date.get(Calendar.YEAR);
        int month = date.get(Calendar.MONTH);
        System.out.println(getMonthLast(year,2));
    }
}
incident-manage/incident-manage-service/src/main/resources/config/mapper/incidentManage/AccidentReportInfoMapper.xml
@@ -190,4 +190,33 @@
    <update id="deleteAccidentReportById">
        update accident_report set del_flag = 1 where id = #{id}
    </update>
    <resultMap type="com.gkhy.safePlatform.incidentManage.entity.AccidentReportCount"
               id="emergencyDrillExecuteCountChart">
        <result column="num" property="num"/>
        <result column="name" property="name"/>
        <result column="minorInjuryNum" property="minorInjuryNum"/>
        <result column="seriousInjuryNum" property="seriousInjuryNum"/>
        <result column="deathNum" property="deathNum"/>
        <result column="economicLoss" property="economicLoss"/>
    </resultMap>
    <select id="selectByTimeAndType" resultMap="emergencyDrillExecuteCountChart">
        SELECT
        a.accident_level AS `name`,
        count( 0 ) AS num,
        sum( economic_loss ) AS economicLoss,
        sum( minor_injury_num ) AS minorInjuryNum,
        sum( serious_injury_num ) AS seriousInjuryNum,
        sum( death_num ) AS deathNum
        FROM
        `accident_report` a
        WHERE
        del_flag = 0
        AND a.gmt_create <![CDATA[ >= ]]> #{query.startTime}
        AND a.gmt_create <![CDATA[ <= ]]> #{query.endTime}
        <if test="query.level != null and query.level != ''" >and b.drill_level = #{query.level}</if>
        GROUP BY
        accident_level
    </select>
</mapper>