package com.gk.hotwork.doublePrevention.service.impl;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gk.hotwork.Domain.Vo.PageInfoExtension;
|
import com.gk.hotwork.doublePrevention.entity.PreventDangerCheckTaskRectifyDO;
|
import com.gk.hotwork.doublePrevention.entity.PreventProduceDevice;
|
import com.gk.hotwork.doublePrevention.entity.dto.req.StatisticsInspectionCompletedReqDTO;
|
import com.gk.hotwork.doublePrevention.entity.dto.req.StatisticsInspectionTaskReqDTO;
|
import com.gk.hotwork.doublePrevention.entity.dto.req.StatisticsInspectorReqDTO;
|
import com.gk.hotwork.doublePrevention.entity.dto.req.StatisticsPreventDangerPageReqDTO;
|
import com.gk.hotwork.doublePrevention.entity.dto.resp.PreventDangerCheckTaskRectifyRespDTO;
|
import com.gk.hotwork.doublePrevention.service.StatisticsService;
|
import com.gk.hotwork.doublePrevention.service.baseService.PreventDangerCheckTaskService;
|
import com.gk.hotwork.doublePrevention.service.baseService.PreventProduceDeviceService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDate;
|
import java.time.LocalDateTime;
|
import java.time.ZoneId;
|
import java.time.format.DateTimeFormatter;
|
import java.util.*;
|
|
|
@Service("statisticsService")
|
public class StatisticsServiceImpl implements StatisticsService {
|
|
@Autowired
|
private PreventDangerCheckTaskService preventDangerCheckTaskService;
|
@Autowired
|
private PreventProduceDeviceService preventProduceDeviceService;
|
|
@Override
|
public List<Map> selectInspectorsStatistics(StatisticsInspectorReqDTO reqDTO) {
|
LocalDateTime startTime = null;
|
LocalDateTime endTime = null;
|
if (reqDTO.getStartTime() != null) {
|
startTime = LocalDateTime.ofInstant(reqDTO.getStartTime().toInstant(), ZoneId.systemDefault());
|
}
|
if (reqDTO.getEndTime() != null) {
|
endTime = LocalDateTime.ofInstant(reqDTO.getEndTime().toInstant(), ZoneId.systemDefault());
|
}
|
Long depId = reqDTO.getDepId();
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
if (endTime == null) {
|
endTime = LocalDate.now().atTime(23, 59, 59);
|
}
|
if (startTime == null) {
|
startTime = LocalDate.now().minusDays(7).atStartOfDay();
|
}
|
List<String> list = new ArrayList<>();
|
// 解析出每天
|
LocalDateTime loopTime = startTime.plusDays(0);
|
while(loopTime.isBefore(endTime)){//当明天不在结束时间之前是终止循环
|
list.add(loopTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
loopTime = loopTime.plusDays(1L);
|
}
|
|
return preventDangerCheckTaskService.selectInspectorsStatistics(depId,list, startTime, endTime);
|
}
|
|
@Override
|
public List<Map> selectInspectionCompleted(StatisticsInspectionCompletedReqDTO reqDTO) {
|
LocalDateTime startTime = null;
|
LocalDateTime endTime = null;
|
if (reqDTO.getStartTime() != null) {
|
startTime = LocalDateTime.ofInstant(reqDTO.getStartTime().toInstant(), ZoneId.systemDefault());
|
}
|
if (reqDTO.getEndTime() != null) {
|
endTime = LocalDateTime.ofInstant(reqDTO.getEndTime().toInstant(), ZoneId.systemDefault());
|
}
|
Long depId = reqDTO.getDepId();
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
if (endTime == null) {
|
endTime = LocalDate.now().atTime(23, 59, 59);
|
}
|
if (startTime == null) {
|
startTime = LocalDate.now().minusDays(7).atStartOfDay();
|
}
|
List<String> list = new ArrayList<>();
|
// 解析出每天
|
LocalDateTime loopTime = startTime.plusDays(0);
|
while(loopTime.isBefore(endTime)){//当明天不在结束时间之前是终止循环
|
list.add(loopTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
loopTime = loopTime.plusDays(1L);
|
}
|
return preventDangerCheckTaskService.selectInspectionCompleted(depId,reqDTO.getStatus(),list, startTime, endTime);
|
}
|
|
@Override
|
public Map<String,List<Map>> selectInspectionTask(StatisticsInspectionTaskReqDTO reqDTO) {
|
LocalDateTime startTime = null;
|
LocalDateTime endTime = null;
|
if (reqDTO.getStartTime() != null) {
|
startTime = LocalDateTime.ofInstant(reqDTO.getStartTime().toInstant(), ZoneId.systemDefault());
|
}
|
if (reqDTO.getEndTime() != null) {
|
endTime = LocalDateTime.ofInstant(reqDTO.getEndTime().toInstant(), ZoneId.systemDefault());
|
}
|
Long depId = reqDTO.getDepId();
|
Calendar instance = Calendar.getInstance();
|
instance.setTime(new Date());
|
if (endTime == null) {
|
endTime = LocalDate.now().atTime(23, 59, 59);
|
}
|
if (startTime == null) {
|
startTime = LocalDate.now().minusDays(7).atStartOfDay();
|
}
|
List<String> list = new ArrayList<>();
|
// 解析出每天
|
LocalDateTime loopTime = startTime.plusDays(0);
|
while(loopTime.isBefore(endTime)){//当明天不在结束时间之前是终止循环
|
list.add(loopTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
loopTime = loopTime.plusDays(1L);
|
}
|
// 当日已认领
|
List<Map> claimedData = preventDangerCheckTaskService.selectInspectionClaimedTask(depId, list, startTime, endTime);
|
// 巡检完成数量
|
List<Map> completedData = preventDangerCheckTaskService.selectInspectionCompletedTask(depId, list, startTime, endTime);
|
// 巡检领取未完成数量
|
List<Map> uncompletedData = preventDangerCheckTaskService.selectInspectionUnCompletedTask(depId, list, startTime, endTime);
|
Map<String, List<Map>> result = new HashMap<>();
|
result.put("claimed", claimedData);
|
result.put("completed", completedData);
|
result.put("uncompleted", uncompletedData);
|
return result;
|
}
|
|
@Override
|
public PageInfoExtension<Map> selectPreventDangerPage(StatisticsPreventDangerPageReqDTO reqDTO) {
|
|
if (reqDTO.getPageIndex() == null) {
|
reqDTO.setPageIndex(0);
|
}
|
if (reqDTO.getPageSize() == null || reqDTO.getPageSize() > 500) {
|
reqDTO.setPageSize(500);
|
}
|
Page<PreventDangerCheckTaskRectifyDO> page = new Page<>(reqDTO.getPageIndex(), reqDTO.getPageSize());
|
|
Map<String, Object> params = new HashMap<>();
|
params.put("serialCode", reqDTO.getSerialCode());
|
params.put("dangerLevel", reqDTO.getDangerLevel());
|
params.put("dangerType", reqDTO.getDangerType());
|
params.put("dangerSource", reqDTO.getDangerSource());
|
params.put("dangerStatus", reqDTO.getDangerStatus());
|
params.put("acceptPersonName", reqDTO.getAcceptPersonName());
|
params.put("liablePersonName", reqDTO.getLiablePersonName());
|
params.put("registantName", reqDTO.getRegistantName());
|
List<PreventDangerCheckTaskRectifyDO> dbData = preventDangerCheckTaskService.selectPreventDangerPage(page, params);
|
List<PreventDangerCheckTaskRectifyRespDTO> result = new ArrayList<>(dbData.size());
|
if (dbData.size() > 0) {
|
for (PreventDangerCheckTaskRectifyDO rectifyDO : dbData) {
|
PreventDangerCheckTaskRectifyRespDTO respDTO = new PreventDangerCheckTaskRectifyRespDTO();
|
|
respDTO.setManageId(rectifyDO.getManageId());
|
respDTO.setManageUuid(rectifyDO.getManageUuid());
|
respDTO.setRegisterTime(rectifyDO.getRegisterTime());
|
respDTO.setDangerLevel(rectifyDO.getDangerLevel());
|
respDTO.setDangerType(rectifyDO.getDangerType());
|
respDTO.setDangerSource(rectifyDO.getDangerSource());
|
respDTO.setDangerStatus(rectifyDO.getDangerStatus());
|
respDTO.setRegistantId(rectifyDO.getRegistantId());
|
respDTO.setProduceDeviceId(rectifyDO.getProduceDeviceId());
|
respDTO.setDangerCode(rectifyDO.getDangerCode());
|
respDTO.setRegistantName(rectifyDO.getRegistantName());
|
respDTO.setDangerDesc(rectifyDO.getDangerDesc());
|
respDTO.setDangerReason(rectifyDO.getDangerReason());
|
respDTO.setDangerResult(rectifyDO.getDangerResult());
|
respDTO.setDepId(rectifyDO.getDepId());
|
respDTO.setRiskUnitId(rectifyDO.getRiskUnitId());
|
respDTO.setDangerReview(rectifyDO.getDangerReview());
|
respDTO.setDangerCloseReason(rectifyDO.getDangerCloseReason());
|
respDTO.setRectifyId(rectifyDO.getRectifyId());
|
respDTO.setRectifyType(rectifyDO.getRectifyType());
|
respDTO.setRectifyTime(rectifyDO.getRectifyTime());
|
respDTO.setLiablePersonId(rectifyDO.getLiablePersonId());
|
respDTO.setCheckAcceptTime(rectifyDO.getCheckAcceptTime());
|
respDTO.setCheckAcceptPersonId(rectifyDO.getCheckAcceptPersonId());
|
respDTO.setLiablePerson(rectifyDO.getLiablePerson());
|
respDTO.setCheckAcceptPerson(rectifyDO.getCheckAcceptPerson());
|
respDTO.setRectifyDepId(rectifyDO.getRectifyDepId());
|
respDTO.setRectifyDesc(rectifyDO.getRectifyDesc());
|
respDTO.setCost(rectifyDO.getCost());
|
respDTO.setRectifyApplyTime(rectifyDO.getRectifyApplyTime());
|
respDTO.setTimeOutDesc(rectifyDO.getTimeOutDesc());
|
respDTO.setRectifyInfo(rectifyDO.getRectifyInfo());
|
result.add(respDTO);
|
|
}
|
}
|
Page<PreventDangerCheckTaskRectifyRespDTO> resultPage = new Page<>();
|
resultPage.setRecords(result);
|
resultPage.setTotal(page.getTotal());
|
resultPage.setSize(page.getSize());
|
resultPage.setCurrent(page.getCurrent());
|
resultPage.setPages(page.getPages());
|
PageInfoExtension<Map> extension = new PageInfoExtension<>(resultPage);
|
|
// 1. 待整改数量
|
Map<String, Integer> extensionData = preventDangerCheckTaskService.selectRectifyNum();
|
extension.setExtension(extensionData);
|
return extension;
|
}
|
|
@Override
|
public Map countDeviceEveryLevel() {
|
return preventProduceDeviceService.countDeviceEveryLevel();
|
}
|
}
|