| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.enums.SafeWordStatusEnum; |
| | | import com.panzhihua.common.model.dtos.community.ComSwDangerReportHandleDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComSwDangerReportRectifyDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComSwPatrolRecordPageDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngCarExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwDangerReportExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwDangerReportVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwSafetyWorkRecordVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComSwDangerReportDAO; |
| | | import com.panzhihua.service_community.dao.ComSwPatrolRecordDAO; |
| | | import com.panzhihua.service_community.dao.ComSwPatrolRecordReportDAO; |
| | | import com.panzhihua.service_community.model.dos.ComSwDangerReportDO; |
| | | import com.panzhihua.service_community.model.dos.ComSwPatrolRecordDO; |
| | | import com.panzhihua.service_community.model.dos.ComSwPatrolRecordReportDO; |
| | | import com.panzhihua.service_community.model.dos.ComSwSafetyWorkRecordDO; |
| | | import com.panzhihua.service_community.service.ComSwDangerReportService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @auther txb |
| | |
| | | @Service |
| | | public class ComSwDangerReportServiceImpl extends ServiceImpl<ComSwDangerReportDAO, ComSwDangerReportDO> implements ComSwDangerReportService { |
| | | |
| | | @Resource |
| | | private ComSwDangerReportDAO comSwDangerReportDAO; |
| | | |
| | | @Resource |
| | | private ComSwPatrolRecordDAO comSwPatrolRecordDAO; |
| | | |
| | | @Resource |
| | | private ComSwPatrolRecordReportDAO comSwPatrolRecordReportDAO; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Override |
| | | public R pageDangerReport(ComSwPatrolRecordPageDTO comSwPatrolRecordPageDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = comSwPatrolRecordPageDTO.getPageNum(); |
| | | Long pageSize = comSwPatrolRecordPageDTO.getPageSize(); |
| | | if (null == pageNum || 0 == pageNum) { |
| | | pageNum = 1L; |
| | | } |
| | | if (null == pageSize || 0 == pageSize) { |
| | | pageSize = 10L; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | |
| | | IPage<ComSwDangerReportVO> iPage = comSwDangerReportDAO.pageDangerReport(page, comSwPatrolRecordPageDTO); |
| | | if (!iPage.getRecords().isEmpty()) { |
| | | iPage.getRecords().forEach(comSwDangerReportVO -> { |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getAssignPerson())) { |
| | | comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.no); |
| | | }else { |
| | | comSwDangerReportVO.setIsAssign(ComSwDangerReportVO.isOk.yes); |
| | | } |
| | | List<String> patrolUserIds = Arrays.asList(comSwDangerReportVO.getPatrolPerson().split(",")); |
| | | List<String> patrolPhones = new ArrayList<>(); |
| | | for (String userId : patrolUserIds) { |
| | | LoginUserInfoVO loginUserInfoVO = userService.getUserInfoByUserId(userId).getData(); |
| | | patrolPhones.add(loginUserInfoVO.getPhone()); |
| | | } |
| | | comSwDangerReportVO.setPatrolPersonPhone(StringUtils.join(patrolPhones,",")); |
| | | |
| | | List<String> rectifyUserIds = Arrays.asList(comSwDangerReportVO.getRectifyPerson().split(",")); |
| | | List<String> rectifyPhones = new ArrayList<>(); |
| | | for (String userId : rectifyUserIds) { |
| | | LoginUserInfoVO loginUserInfoVO = userService.getUserInfoByUserId(userId).getData(); |
| | | rectifyPhones.add(loginUserInfoVO.getPhone()); |
| | | } |
| | | comSwDangerReportVO.setRectifyPersonPhone(StringUtils.join(rectifyPhones,",")); |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R detailDangerReport(Long dangerReportId) { |
| | | ComSwDangerReportDO comSwDangerReportDO = comSwDangerReportDAO.selectById(dangerReportId); |
| | | if (null == comSwDangerReportDO) { |
| | | return R.fail("该隐患报告不存在"); |
| | | } |
| | | ComSwDangerReportVO comSwDangerReportVO = new ComSwDangerReportVO(); |
| | | ComSwPatrolRecordReportDO comSwPatrolRecordReportDO = comSwPatrolRecordReportDAO.selectOne(new QueryWrapper<ComSwPatrolRecordReportDO>().lambda().eq(ComSwPatrolRecordReportDO::getReportId, dangerReportId)); |
| | | if (null != comSwPatrolRecordReportDO) { |
| | | ComSwPatrolRecordDO comSwPatrolRecordDO = comSwPatrolRecordDAO.selectById(comSwPatrolRecordReportDO.getPatrolRecordId()); |
| | | BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO); |
| | | } |
| | | BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO); |
| | | return R.ok(comSwDangerReportVO); |
| | | } |
| | | |
| | | @Override |
| | | public R detailDangerReportByPrId(Long patrolRecordId) { |
| | | ComSwPatrolRecordDO comSwPatrolRecordDO = comSwPatrolRecordDAO.selectById(patrolRecordId); |
| | | ComSwDangerReportVO comSwDangerReportVO = new ComSwDangerReportVO(); |
| | | ComSwPatrolRecordReportDO comSwPatrolRecordReportDO = comSwPatrolRecordReportDAO.selectOne(new QueryWrapper<ComSwPatrolRecordReportDO>().lambda().eq(ComSwPatrolRecordReportDO::getPatrolRecordId, patrolRecordId)); |
| | | if (null != comSwPatrolRecordReportDO) { |
| | | ComSwDangerReportDO comSwDangerReportDO = comSwDangerReportDAO.selectById(comSwPatrolRecordReportDO.getReportId()); |
| | | if (null == comSwDangerReportDO) { |
| | | return R.fail("该隐患报告不存在"); |
| | | } |
| | | BeanUtils.copyProperties(comSwDangerReportDO, comSwDangerReportVO); |
| | | } |
| | | BeanUtils.copyProperties(comSwPatrolRecordDO, comSwDangerReportVO); |
| | | return R.ok(comSwDangerReportVO); |
| | | } |
| | | |
| | | @Override |
| | | public R handleDangerReport(ComSwDangerReportHandleDTO comSwDangerReportHandleDTO) { |
| | | ComSwDangerReportDO comSwDangerReportDO = comSwDangerReportDAO.selectById(comSwDangerReportHandleDTO.getDangerReportId()); |
| | | if (null == comSwDangerReportDO) { |
| | | return R.fail("该隐患报告不存在"); |
| | | } |
| | | BeanUtils.copyProperties(comSwDangerReportHandleDTO, comSwDangerReportDO); |
| | | comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YCL.getCode())); |
| | | int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("处理失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R rectifyDangerReport(ComSwDangerReportRectifyDTO comSwDangerReportRectifyDTO) { |
| | | ComSwDangerReportDO comSwDangerReportDO = comSwDangerReportDAO.selectById(comSwDangerReportRectifyDTO.getDangerReportId()); |
| | | if (null == comSwDangerReportDO) { |
| | | return R.fail("该隐患报告不存在"); |
| | | } |
| | | BeanUtils.copyProperties(comSwDangerReportRectifyDTO, comSwDangerReportDO); |
| | | comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YZG.getCode())); |
| | | int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); |
| | | if (update > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("整改失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R exportDangerReport(List<Long> dangerReportIds) { |
| | | List<ComSwDangerReportExcelVO> list = comSwDangerReportDAO.exportDangerReport(dangerReportIds); |
| | | list.forEach(comSwDangerReportExcelVO -> { |
| | | List<String> patrolUserIds = Arrays.asList(comSwDangerReportExcelVO.getPatrolPerson().split(",")); |
| | | List<String> patrolPhones = new ArrayList<>(); |
| | | for (String userId : patrolUserIds) { |
| | | LoginUserInfoVO loginUserInfoVO = userService.getUserInfoByUserId(userId).getData(); |
| | | patrolPhones.add(loginUserInfoVO.getPhone()); |
| | | } |
| | | comSwDangerReportExcelVO.setPatrolPersonPhone(StringUtils.join(patrolPhones,",")); |
| | | }); |
| | | return R.ok(list); |
| | | } |
| | | } |