package com.ruoyi.doublePrevention.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.github.pagehelper.Page;
|
import com.github.pagehelper.PageHelper;
|
import com.ruoyi.common.exception.BusinessException;
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
import com.ruoyi.doublePrevention.entity.PreventRiskDangerCheckLog;
|
import com.ruoyi.doublePrevention.entity.RiskAndPeopleInfo;
|
import com.ruoyi.doublePrevention.entity.dto.req.RiskAndPeopleInfoReqBO;
|
import com.ruoyi.doublePrevention.entity.dto.resp.RiskAndPeopleInfoDTO;
|
import com.ruoyi.doublePrevention.entity.dto.resp.RiskAndPeopleInfoRespDTO;
|
import com.ruoyi.doublePrevention.repository.RiskAndPeopleInfoRepository;
|
import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerCheckLogService;
|
import com.ruoyi.doublePrevention.service.baseService.RiskAndPeopleInfoService;
|
import com.ruoyi.doublePrevention.vo.ResultVO;
|
import com.ruoyi.project.tr.HiddenDangerCheckJob.domain.HiddenDangerCheckJobLog;
|
import com.ruoyi.project.tr.HiddenDangerCheckJob.service.IHiddenDangerCheckJobLogService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.ObjectUtils;
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service("RiskAndPeopleInfoService")
|
public class RiskAndPeopleInfoServiceImpl extends ServiceImpl<RiskAndPeopleInfoRepository, RiskAndPeopleInfo> implements RiskAndPeopleInfoService {
|
|
@Autowired
|
private RiskAndPeopleInfoRepository repository;
|
|
@Autowired
|
private IHiddenDangerCheckJobLogService hiddenDangerCheckJobLogService;
|
|
@Autowired
|
private PreventRiskDangerCheckLogService preventRiskDangerCheckLogService;
|
|
@Override
|
public ResultVO<RiskAndPeopleInfoRespDTO> listRiskAndPeoplePage(RiskAndPeopleInfoReqBO reqBO) {
|
|
ResultVO resultVO = new ResultVO<>();
|
|
RiskAndPeopleInfoRespDTO respDTO = new RiskAndPeopleInfoRespDTO();
|
|
if (ObjectUtils.isEmpty(reqBO.getPageSize())){
|
throw new BusinessException("分页信息不能为空");
|
}
|
if (ObjectUtils.isEmpty(reqBO.getPageNum())){
|
throw new BusinessException("分页信息不能为空");
|
}
|
|
Integer pageIndex = reqBO.getPageNum();
|
Integer pageSize = reqBO.getPageSize();
|
|
Page<RiskAndPeopleInfo> page = PageHelper.startPage(pageIndex, pageSize);
|
List<RiskAndPeopleInfo> riskOldInfo = repository.listRiskAndPeoplePage(reqBO);
|
|
List<HiddenDangerCheckJobLog> allCheckJobLogList = new ArrayList<>();
|
List<HiddenDangerCheckJobLog> completeCheckJobLogList = new ArrayList<>();
|
for (RiskAndPeopleInfo riskAndPeopleInfo : riskOldInfo) {
|
//取出操作人的id,依此为依据,查询所有的任务记录 check_user_id
|
List<HiddenDangerCheckJobLog> jobLogLists = hiddenDangerCheckJobLogService.getJobLogByCheckUserId(riskAndPeopleInfo.getHandleLiabilityPersonId());
|
if (jobLogLists.size() > 0){
|
for (HiddenDangerCheckJobLog jobLog : jobLogLists) {
|
PreventRiskDangerCheckLog preventRiskDangerCheckLog = preventRiskDangerCheckLogService.getByDangerCheckByJobId(jobLog.getJobId());
|
if (preventRiskDangerCheckLog.getCheckStatus() != 3){
|
completeCheckJobLogList.add(jobLog);
|
}
|
allCheckJobLogList.add(jobLog);
|
}
|
}
|
}
|
|
List<RiskAndPeopleInfoDTO> riskAndPeopleList = BeanCopyUtils.copyBeanList(riskOldInfo, RiskAndPeopleInfoDTO.class);
|
|
int completeRatio = 0;
|
if (allCheckJobLogList.size() > 0){
|
completeRatio = completeCheckJobLogList.size() / allCheckJobLogList.size();
|
}
|
respDTO.setRiskAndPeopleInfoDTO(riskAndPeopleList);
|
respDTO.setCount(allCheckJobLogList.size());
|
respDTO.setComplete(completeCheckJobLogList.size());
|
respDTO.setCompleteRatio(BigDecimal.valueOf(completeRatio));
|
|
resultVO.setPageSize(pageSize);
|
resultVO.setPageNum(pageIndex);
|
resultVO.setCount(riskAndPeopleList.size());
|
resultVO.setData(respDTO);
|
|
|
|
return resultVO;
|
}
|
}
|