songhuangfeng123
2022-08-08 2f71d2a6f77277766f81ecfcfc1df19a4784e897
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencyDrillExecuteServiceImpl.java
@@ -4,7 +4,6 @@
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.*;
@@ -12,15 +11,17 @@
import com.gkhy.safePlatform.emergency.excepiton.EmergencyException;
import com.gkhy.safePlatform.emergency.model.dto.req.EmergencyDrillExecuteReqDTO;
import com.gkhy.safePlatform.emergency.model.dto.req.EmergencyDrillExecuteUserReqDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyDrillExecuteDetailRespDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyDrillExecutePageRespDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.EmergencyDrillExecuteUserRespDTO;
import com.gkhy.safePlatform.emergency.model.dto.resp.*;
import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteQuery;
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.service.EmergencyDrillExecuteService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillEvaluationInfoService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillExecuteInfoService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillExecuteUserInfoService;
import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillPlanInfoService;
import com.gkhy.safePlatform.emergency.utils.TimeUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -42,6 +43,9 @@
    @Autowired
    private EmergencyDrillPlanInfoService emergencyDrillPlanInfoService;
    @Autowired
    private EmergencyDrillEvaluationInfoService emergencyDrillEvaluationInfoService;
    @Override
@@ -85,7 +89,7 @@
                emergencyDrillExecuteInfo.setDelFlag(false);
                emergencyDrillExecuteInfo.setCreateUid(uid);
                emergencyDrillExecuteInfo.setGmtCreate(nowDate);
                emergencyDrillExecuteInfo.setStatus(true);
                emergencyDrillExecuteInfo.setStatus(false);
                emergencyDrillExecuteInfoService.addEmergencyDrillExecute(emergencyDrillExecuteInfo);
                // 新增应急演练计划实施实际到场人员表
@@ -93,6 +97,14 @@
                    addEmergencyDrillExecuteUser(uid, emergencyDrillExecuteInfo.getId(), nowDate, emergencyDrillExecuteReqDTO.getUserList());
                }
                // 新增评价表一行数据
                EmergencyDrillEvaluationInfo emergencyDrillEvaluationInfo = new EmergencyDrillEvaluationInfo();
                emergencyDrillEvaluationInfo.setDelFlag(false);
                emergencyDrillEvaluationInfo.setCreateUid(uid);
                emergencyDrillEvaluationInfo.setGmtCreate(nowDate);
                emergencyDrillEvaluationInfo.setDrillExecuteId(emergencyDrillExecuteInfo.getId());
                emergencyDrillEvaluationInfoService.addEmergencyDrillEvaluation(emergencyDrillEvaluationInfo);
                return new ResultVO<>(ResultCodes.OK);
            }
        }
@@ -219,4 +231,43 @@
            emergencyDrillExecuteUserInfoService.deleteEmergencyDrillExecuteUserByDrillExecuteId(DrillExecuteId);
        }
    }
    @Override
    public ResultVO<EmergencyDrillExecuteCountRespDTO> countEmergencyDrillExecute(EmergencyDrillExecuteRPCQuery query) {
        EmergencyDrillExecuteCountRespDTO emergencyDrillExecuteCountRespDTO = new EmergencyDrillExecuteCountRespDTO();
        // 根据应急演练实施的创建时间与当前时间  获取间隔天数
        Integer days = emergencyDrillExecuteInfoService.selectEmergencyDrillExecuteIntervalTime();
        emergencyDrillExecuteCountRespDTO.setDays(days);
        // 根据时间、级别获取统计
        List<EmergencyDrillExecuteCountData> list = new ArrayList<>();
        EmergencyDrillExecuteRPCDBQuery dbQuery = new EmergencyDrillExecuteRPCDBQuery();
        dbQuery.setLevel(query.getLevel());
        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 = emergencyDrillExecuteInfoService.selectByMouthTimeAndType(dbQuery);
        }
        if (query.getType()==2){
            // 年
            int year = query.getYear();
            dbQuery.setStartTime(TimeUtils.getYearFirst(year));
            dbQuery.setEndTime(TimeUtils.getYearLast(year));
            list = emergencyDrillExecuteInfoService.selectByYearTimeAndType(dbQuery);
        }
        if (!CollectionUtils.isEmpty(list)){
            List<EmergencyDrillExecuteCountDataRespDTO> dataList = BeanCopyUtils.copyBeanList(list,EmergencyDrillExecuteCountDataRespDTO.class);
            emergencyDrillExecuteCountRespDTO.setDataList(dataList);
        }else{
            emergencyDrillExecuteCountRespDTO.setDataList(new ArrayList<>());
        }
        return new ResultVO<>(ResultCodes.OK,emergencyDrillExecuteCountRespDTO);
    }
}