| | |
| | | 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.gk.hotwork.Domain.*; |
| | | import com.gk.hotwork.Domain.Do.CompanyInspectionCountDO; |
| | | import com.gk.hotwork.Domain.Do.SafetySelfInspectionItemQualifiedCountDO; |
| | | import com.gk.hotwork.Domain.Exception.BusinessException; |
| | | import com.gk.hotwork.Domain.InspectionExpert; |
| | | import com.gk.hotwork.Domain.InspectionHiddenDanger; |
| | | import com.gk.hotwork.Domain.SafetySelfInspection; |
| | | import com.gk.hotwork.Domain.UserInfo; |
| | | import com.gk.hotwork.Domain.Utils.PageInfo; |
| | | import com.gk.hotwork.Domain.Utils.StringUtils; |
| | | import com.gk.hotwork.Domain.dto.resp.InspectionHiddenDangerRespDTO; |
| | | import com.gk.hotwork.Domain.query.CountQuery; |
| | | import com.gk.hotwork.Mapper.InspectionExpertMapper; |
| | | import com.gk.hotwork.Mapper.InspectionHiddenDangerMapper; |
| | | import com.gk.hotwork.Service.AttachmentInfoService; |
| | | import com.gk.hotwork.Service.InspectionExpertService; |
| | | import com.gk.hotwork.Service.InspectionHiddenDangerService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | @Autowired |
| | | private InspectionHiddenDangerMapper inspectionHiddenDangerMapper; |
| | | |
| | | @Autowired |
| | | private AttachmentInfoService attachmentInfoService; |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param inspectionHiddenDanger |
| | |
| | | @Override |
| | | public void mod(InspectionHiddenDanger inspectionHiddenDanger, UserInfo userInfo) { |
| | | modrequiredVerification(inspectionHiddenDanger); |
| | | |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | //附件 |
| | | if(CollectionUtils.isNotEmpty(inspectionHiddenDanger.getRattachmentList())){ |
| | | for (AttachmentInfo attachmentInfo : inspectionHiddenDanger.getRattachmentList()) { |
| | | attachmentInfo.setBusinessId(inspectionHiddenDanger.getId()); |
| | | stringBuffer.append(attachmentInfo.getId().toString()).append(","); |
| | | } |
| | | stringBuffer = stringBuffer.deleteCharAt(stringBuffer.length()-1); |
| | | } |
| | | |
| | | inspectionHiddenDanger.setUpdateTime(new Date()); |
| | | inspectionHiddenDanger.setUpdateBy(userInfo.getRealname()); |
| | | inspectionHiddenDanger.setRectificationUrl(stringBuffer.toString()); |
| | | inspectionHiddenDangerMapper.updateById(inspectionHiddenDanger); |
| | | //更新附件 |
| | | if(CollectionUtils.isNotEmpty(inspectionHiddenDanger.getRattachmentList())){ |
| | | attachmentInfoService.updateBusinessIdBatch(inspectionHiddenDanger.getRattachmentList()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | inspectionHiddenDanger.setUpdateBy(userInfo.getRealname()); |
| | | inspectionHiddenDanger.setUpdateTime(new Date()); |
| | | inspectionHiddenDangerMapper.delByInspectionItemId(inspectionHiddenDanger); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | params.put("city",user.getCity()); |
| | | params.put("area",user.getCounty()); |
| | | } |
| | | IPage<SafetySelfInspection> res = inspectionHiddenDangerMapper.selectPages(page, params); |
| | | List<SafetySelfInspection> records = res.getRecords(); |
| | | if (CollectionUtils.isNotEmpty(records)){ |
| | | for (SafetySelfInspection inspection : records) { |
| | | List<InspectionHiddenDanger> dangerList = this.getBySafetySelfInspectionId(inspection.getId()); |
| | | //一般 1 |
| | | int sameasCount = 0; |
| | | //重大 2 |
| | | int majorCount = 0; |
| | | //总数 |
| | | int totalCount = 0; |
| | | //未整改数量 |
| | | int unRectifyCount = 0; |
| | | |
| | | for (InspectionHiddenDanger inspectionHiddenDanger : dangerList) { |
| | | if (inspectionHiddenDanger.getLevel().equals(1)) { |
| | | sameasCount += 1; |
| | | }else { |
| | | majorCount += 1; |
| | | } |
| | | if(inspectionHiddenDanger.getStatus().equals((byte) 0)){ |
| | | unRectifyCount += 1; |
| | | } |
| | | totalCount += 1; |
| | | } |
| | | |
| | | inspection.setSameAsCount(sameasCount); |
| | | inspection.setMajorCount(majorCount); |
| | | inspection.setHdTocalCount(totalCount); |
| | | if(unRectifyCount == 0){ |
| | | inspection.setRectificationStatus(2); |
| | | }else if(unRectifyCount == totalCount){ |
| | | inspection.setRectificationStatus(0); |
| | | }else { |
| | | inspection.setRectificationStatus(1); |
| | | } |
| | | |
| | | } |
| | | res.setRecords(records); |
| | | } |
| | | IPage<SafetySelfInspectionDO> res = inspectionHiddenDangerMapper.selectPages(page, params); |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public List<InspectionHiddenDanger> inspectionHdangerlist(Long selfInspectionId) { |
| | | return inspectionHiddenDangerMapper.inspectionHdangerlist(selfInspectionId); |
| | | |
| | | List<InspectionHiddenDanger> inspectionHiddenDangerList = inspectionHiddenDangerMapper.inspectionHdangerlist(selfInspectionId); |
| | | for (InspectionHiddenDanger inspectionHiddenDanger : inspectionHiddenDangerList) { |
| | | if(StringUtils.isNotBlank(inspectionHiddenDanger.getRectificationUrl())){ |
| | | List<Long> idList = new ArrayList<>(); |
| | | String[] split = inspectionHiddenDanger.getRectificationUrl().split(","); |
| | | for (String s : split) { |
| | | idList.add(Long.valueOf(s)); |
| | | } |
| | | List<AttachmentInfo> byIds = attachmentInfoService.findByIds(idList); |
| | | inspectionHiddenDanger.setRattachmentList(byIds); |
| | | } |
| | | if(StringUtils.isNotBlank(inspectionHiddenDanger.getUrl())){ |
| | | List<Long> idList = new ArrayList<>(); |
| | | String[] split = inspectionHiddenDanger.getUrl().split(","); |
| | | for (String s : split) { |
| | | idList.add(Long.valueOf(s)); |
| | | } |
| | | List<AttachmentInfo> byIds = attachmentInfoService.findByIds(idList); |
| | | inspectionHiddenDanger.setAttachmentList(byIds); |
| | | } |
| | | } |
| | | return inspectionHiddenDangerList; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 统计 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CompanyInspectionCountDO> getStatisticHiddenDanger(CountQuery query) { |
| | | |
| | | return inspectionHiddenDangerMapper.getStatisticHiddenDanger(query); |
| | | } |
| | | |
| | | private void modrequiredVerification(InspectionHiddenDanger inspectionHiddenDanger){ |
| | |
| | | if(danger.getStatus().equals((byte) 1)){ |
| | | throw new BusinessException("已整改不可再修改"); |
| | | } |
| | | if (StringUtils.isBlank(inspectionHiddenDanger.getInfo())) throw new BusinessException("请填写隐患描述"); |
| | | if (inspectionHiddenDanger.getLevel() == null) throw new BusinessException("请选择隐患等级"); |
| | | if (inspectionHiddenDanger.getStatus() == null) throw new BusinessException("整改状态不可为空"); |
| | | } |