| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService; |
| | | import com.gkhy.safePlatform.equipment.entity.*; |
| | | import com.gkhy.safePlatform.equipment.excepiton.EquipmentException; |
| | | import com.gkhy.safePlatform.equipment.model.dto.req.*; |
| | | import com.gkhy.safePlatform.equipment.model.dto.resp.KeypointEquipmentInfoExcel; |
| | | import com.gkhy.safePlatform.equipment.repository.EquipmentTypeMngRepository; |
| | | import com.gkhy.safePlatform.equipment.repository.KeypointEquipmentInfoRepository; |
| | | import com.gkhy.safePlatform.equipment.service.*; |
| | | import com.gkhy.safePlatform.equipment.service.baseService.*; |
| | | import com.gkhy.safePlatform.equipment.utils.DateUtils; |
| | | import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelLogs; |
| | | import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelUtil; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.dubbo.config.annotation.DubboReference; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.gkhy.safePlatform.equipment.utils.QueryHelpPlus; |
| | | import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.Serializable; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * @since 2022-07-19 13:36:27 |
| | | */ |
| | | @Service("keypointEquipmentInfoService") |
| | | public class KeypointEquipmentInfoServiceImpl extends ServiceImpl<KeypointEquipmentInfoRepository, KeypointEquipmentInfo> implements KeypointEquipmentInfoService { |
| | | public class KeypointEquipmentInfoServiceImpl implements KeypointEquipmentInfoService { |
| | | |
| | | @Autowired |
| | | private KeypointEquipmentInfoRepository keypointEquipmentInfoRepository; |
| | | private KeypointEquipmentInfoBaseService keypointEquipmentInfoBaseService; |
| | | |
| | | |
| | | @Autowired |
| | | private EquipmentTakecareDetailService equipmentTakecareDetailService; |
| | | private EquipmentTakecareDetailBaseService equipmentTakecareDetailBaseService; |
| | | |
| | | @Autowired |
| | | private EquipmentTestDetailService equipmentTestDetailService; |
| | | private EquipmentTestDetailBaseService equipmentTestDetailBaseService; |
| | | |
| | | @Autowired |
| | | private EquipmentRepairDetailService equipmentRepairDetailService; |
| | | private EquipmentRepairDetailBaseService equipmentRepairDetailBaseService; |
| | | |
| | | @Autowired |
| | | private EquipmentTakecareStardardDetailService equipmentTakecareStardardDetailService; |
| | | private EquipmentTakecareStardardDetailBaseService equipmentTakecareStardardDetailBaseService; |
| | | |
| | | @Autowired |
| | | private EquipmentCheckStandardDetailService equipmentCheckStandardDetailService; |
| | | private EquipmentCheckStandardDetailBaseService equipmentCheckStandardDetailBaseService; |
| | | |
| | | @DubboReference(check = false) |
| | | private AccountDepartmentService accountDepartmentService; |
| | |
| | | |
| | | @Autowired |
| | | private EquipmentTypeMngRepository equipmentTypeMngRepository; |
| | | |
| | | @Autowired |
| | | public HttpServletResponse response; |
| | | |
| | | @Override |
| | | public ResultVO queryAll(PageQuery<KeypointEquipmentInfoQueryCriteria> pageQuery) { |
| | |
| | | Long pageSize = pageQuery.getPageSize(); |
| | | IPage<KeypointEquipmentInfo> page = new Page<>(pageIndex, pageSize); |
| | | |
| | | page = baseMapper.selectPage(page, |
| | | page = keypointEquipmentInfoBaseService.selectPage(page, |
| | | QueryHelpPlus.getPredicate(KeypointEquipmentInfo.class, pageQuery.getSearchParams())); |
| | | List<KeypointEquipmentInfoDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), KeypointEquipmentInfoDto.class); |
| | | |
| | |
| | | EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria(); |
| | | criteria.setEquipmentId(f.getId()); |
| | | criteria.setInfoTpe(3); |
| | | List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailService.queryAll(criteria); |
| | | List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria); |
| | | f.setTakecareDetailList(takecareDetailList); |
| | | |
| | | //设备检测 |
| | | EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria(); |
| | | criteria1.setEquipmentId(f.getId()); |
| | | criteria1.setInfoTpe(3); |
| | | List<EquipmentTestDetail> checkDetailList = equipmentTestDetailService.queryAll(criteria1); |
| | | List<EquipmentTestDetail> checkDetailList = equipmentTestDetailBaseService.queryAll(criteria1); |
| | | f.setCheckDetailList(checkDetailList); |
| | | |
| | | //设备检查 TODO |
| | |
| | | EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria(); |
| | | criteria2.setEquipmentId(f.getId()); |
| | | criteria2.setInfoTpe(3); |
| | | List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailService.queryAll(criteria2); |
| | | List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2); |
| | | f.setRepaireDetailList(repairDetailList); |
| | | |
| | | // --------------------------- 获取设备设施类型管理ID----------------------- |
| | |
| | | |
| | | @Override |
| | | public List<KeypointEquipmentInfo> queryAll(KeypointEquipmentInfoQueryCriteria criteria) { |
| | | return baseMapper.selectList(QueryHelpPlus.getPredicate(KeypointEquipmentInfo.class, criteria)); |
| | | return keypointEquipmentInfoBaseService.queryAll( criteria); |
| | | } |
| | | |
| | | @Override |
| | | public KeypointEquipmentInfoDto selectOne(Serializable id) { |
| | | KeypointEquipmentInfo keypointEquipmentInfo = baseMapper.selectById(id); |
| | | KeypointEquipmentInfo keypointEquipmentInfo = keypointEquipmentInfoBaseService.getById(id); |
| | | if(keypointEquipmentInfo == null){ |
| | | return null; |
| | | } |
| | |
| | | EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria(); |
| | | criteria.setEquipmentId(infoDto.getId()); |
| | | criteria.setInfoTpe(3); |
| | | List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailService.queryAll(criteria); |
| | | List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria); |
| | | infoDto.setTakecareDetailList(takecareDetailList); |
| | | |
| | | //设备检测 |
| | | EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria(); |
| | | criteria1.setEquipmentId(infoDto.getId()); |
| | | criteria1.setInfoTpe(3); |
| | | List<EquipmentTestDetail> checkDetailList = equipmentTestDetailService.queryAll(criteria1); |
| | | List<EquipmentTestDetail> checkDetailList = equipmentTestDetailBaseService.queryAll(criteria1); |
| | | infoDto.setCheckDetailList(checkDetailList); |
| | | |
| | | //设备检查 TODO |
| | |
| | | EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria(); |
| | | criteria2.setEquipmentId(infoDto.getId()); |
| | | criteria2.setInfoTpe(3); |
| | | List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailService.queryAll(criteria2); |
| | | List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2); |
| | | infoDto.setRepaireDetailList(repairDetailList); |
| | | |
| | | //检查标准 |
| | | EquipmentCheckStandardDetailQueryCriteria criteria3 = new EquipmentCheckStandardDetailQueryCriteria(); |
| | | criteria3.setEquipmentId(infoDto.getId()); |
| | | criteria3.setInfoTpe(3); |
| | | List<EquipmentCheckStandardDetail> checkStandardDetailList = equipmentCheckStandardDetailService.queryAll(criteria3); |
| | | List<EquipmentCheckStandardDetail> checkStandardDetailList = equipmentCheckStandardDetailBaseService.queryAll(criteria3); |
| | | infoDto.setCheckStandardeDetailList(checkStandardDetailList); |
| | | |
| | | //保养标准 |
| | | EquipmentTakecareStardardDetailQueryCriteria criteria4 = new EquipmentTakecareStardardDetailQueryCriteria(); |
| | | criteria4.setEquipmentId(infoDto.getId()); |
| | | criteria4.setInfoTpe(3); |
| | | List<EquipmentTakecareStardardDetail> takecareStardardDetailList = equipmentTakecareStardardDetailService.queryAll(criteria4); |
| | | List<EquipmentTakecareStardardDetail> takecareStardardDetailList = equipmentTakecareStardardDetailBaseService.queryAll(criteria4); |
| | | infoDto.setTakecareStardardeDetailList(takecareStardardDetailList); |
| | | |
| | | // --------------------------- 获取部门信息----------------------- |
| | |
| | | KeypointEquipmentInfo equipmentInfo = BeanCopyUtils.copyBean(infoDto, KeypointEquipmentInfo.class); |
| | | //保存主数据 |
| | | if (infoDto.getId() == null) { //新增 |
| | | this.save(equipmentInfo); |
| | | keypointEquipmentInfoBaseService.save(equipmentInfo); |
| | | } else { |
| | | this.update(equipmentInfo,new UpdateWrapper<KeypointEquipmentInfo>().eq("id",infoDto.getId())); |
| | | keypointEquipmentInfoBaseService.update(equipmentInfo,new UpdateWrapper<KeypointEquipmentInfo>().eq("id",infoDto.getId())); |
| | | } |
| | | |
| | | |
| | |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(3); |
| | | }); |
| | | equipmentTakecareDetailService.saveOrUpdateBatch(takecareDetailList); |
| | | equipmentTakecareDetailBaseService.saveOrUpdateBatch(takecareDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTakecareDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTakecareDetailService.updateBatchById(delList); |
| | | equipmentTakecareDetailBaseService.updateBatchById(delList); |
| | | } |
| | | |
| | | //保存设备检测 |
| | |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(3); |
| | | }); |
| | | equipmentTestDetailService.saveOrUpdateBatch(testDetailList); |
| | | equipmentTestDetailBaseService.saveOrUpdateBatch(testDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTestDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTestDetailService.updateBatchById(delList); |
| | | equipmentTestDetailBaseService.updateBatchById(delList); |
| | | |
| | | } |
| | | //设备检查 TODO |
| | |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(3); |
| | | }); |
| | | equipmentRepairDetailService.saveOrUpdateBatch(repaireDetailList); |
| | | equipmentRepairDetailBaseService.saveOrUpdateBatch(repaireDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelRepaireDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentRepairDetailService.updateBatchById(delList); |
| | | equipmentRepairDetailBaseService.updateBatchById(delList); |
| | | |
| | | } |
| | | //保存检查标准 |
| | |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(3); |
| | | }); |
| | | equipmentCheckStandardDetailService.saveOrUpdateBatch(checkStandardeDetailList); |
| | | equipmentCheckStandardDetailBaseService.saveOrUpdateBatch(checkStandardeDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentCheckStandardDetailService.updateBatchById(delList); |
| | | equipmentCheckStandardDetailBaseService.updateBatchById(delList); |
| | | |
| | | } |
| | | //保存保养标准 |
| | |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(3); |
| | | }); |
| | | equipmentTakecareStardardDetailService.saveOrUpdateBatch(takecareStardardeDetailList); |
| | | equipmentTakecareStardardDetailBaseService.saveOrUpdateBatch(takecareStardardeDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTakecareStardardDetailService.updateBatchById(delList); |
| | | equipmentTakecareStardardDetailBaseService.updateBatchById(delList); |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void importData(MultipartFile file) throws IOException { |
| | | String contentType = file.getContentType(); |
| | | if(!"application/vnd.ms-excel".equals(contentType) |
| | | && !"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) { |
| | | throw new EquipmentException("上传的excel格式错误"); |
| | | } |
| | | |
| | | Collection<KeypointEquipmentInfoImportExcel> importExcel = ExcelUtil.importExcel(KeypointEquipmentInfoImportExcel.class, file.getInputStream(), "yyyy-MM-dd HH:mm:ss", new ExcelLogs() , 0); |
| | | |
| | | if (CollectionUtils.isEmpty(importExcel)) { |
| | | return ; |
| | | } |
| | | |
| | | List<KeypointEquipmentInfo> respList = BeanCopyUtils.copyBeanList((List<KeypointEquipmentInfoImportExcel>)importExcel, KeypointEquipmentInfo.class); |
| | | |
| | | keypointEquipmentInfoBaseService.saveBatch(respList); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Long[] ids) { |
| | | if(ids == null){ |
| | | throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL); |
| | | } |
| | | List<Long> idList = Arrays.asList(ids); |
| | | |
| | | List<KeypointEquipmentInfo> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | KeypointEquipmentInfo info = new KeypointEquipmentInfo(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | keypointEquipmentInfoBaseService.updateBatchById(delList); |
| | | } |
| | | |
| | | @Override |
| | | public void exportTemplate() throws IOException { |
| | | Map<String,String> map = new LinkedHashMap<>(); |
| | | map.put("1","类型/类别外键 "); |
| | | map.put("2","装置/部位名称"); |
| | | map.put("3","所属单位部门/外键"); |
| | | map.put("4","具体位置"); |
| | | map.put("5","负责人姓名"); |
| | | map.put("6","联系人/外键"); |
| | | map.put("7","录入人/外键"); |
| | | map.put("8","责任人/外键"); |
| | | map.put("9","装置部位分类 1:关键装置 2:重点部位"); |
| | | map.put("10","检查周期"); |
| | | map.put("11","应急预案/外键"); |
| | | map.put("12","主要危险有害因素"); |
| | | map.put("13","易导致风险"); |
| | | map.put("14","应急处置措施"); |
| | | map.put("15","现场图片地址路径"); |
| | | |
| | | |
| | | String fileName = URLEncoder.encode("重点监管装置设备数据导入模板.xls", "UTF-8"); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | |
| | | ExcelUtil.exportExcel(map,new ArrayList<>() , response.getOutputStream()); |
| | | response.getOutputStream().close(); |
| | | } |
| | | |
| | | @Override |
| | | public void exportData(KeypointEquipmentInfoQueryCriteria queryCriteria) throws IOException { |
| | | Map<String,String> map = new LinkedHashMap<>(); |
| | | map.put("0","ID"); |
| | | map.put("1","类型/类别外键"); |
| | | map.put("2","装置/部位名称"); |
| | | map.put("3","所属单位部门/外键"); |
| | | map.put("4","具体位置"); |
| | | map.put("5","负责人姓名"); |
| | | map.put("6","联系人/外键"); |
| | | map.put("7","录入人/外键"); |
| | | map.put("8","责任人/外键"); |
| | | map.put("9","装置部位分类 1:关键装置 2:重点部位"); |
| | | map.put("10","检查周期"); |
| | | map.put("11","应急预案/外键"); |
| | | map.put("12","主要危险有害因素"); |
| | | map.put("13","易导致风险"); |
| | | map.put("14","应急处置措施"); |
| | | map.put("15","现场图片地址路径"); |
| | | |
| | | String key = DateUtils.date2String(new Date(), DateUtils.PATTERN_ALLTIME_NOSIGN) ; |
| | | String fileName = URLEncoder.encode("重点监管装置设备"+key+".xls", "UTF-8"); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); |
| | | |
| | | |
| | | List<KeypointEquipmentInfoExcel> respList = BeanCopyUtils.copyBeanList(this.queryAll(queryCriteria), KeypointEquipmentInfoExcel.class); |
| | | |
| | | ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD); |
| | | response.getOutputStream().close(); |
| | | } |
| | | } |