| | |
| | | |
| | | //上传产品验收信息 |
| | | public Response uploadBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack |
| | | ,MultipartFile agreement, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException { |
| | | ,MultipartFile agreement,MultipartFile bomManual,MultipartFile testReport |
| | | ,MultipartFile icdFile,MultipartFile cadPicpart,MultipartFile namePlate |
| | | , List<MultipartFile> multipartFileList,List<MultipartFile> installCasePics |
| | | , BomAcceptance bomAcceptance) throws IOException { |
| | | Date date = new Date(); |
| | | bomAcceptance.setCreateTime(date); |
| | | long time = date.getTime(); |
| | |
| | | } |
| | | bomAcceptance.setSparePicpart(spareDirSuffix); |
| | | } |
| | | //现场安装案例照片 |
| | | if(installCasePics!=null && installCasePics.size()!=0){ |
| | | String installCasePicDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "install" + File.separator; |
| | | String installCasePicDir = rootFile + installCasePicDirSuffix; |
| | | File fileDir = new File(installCasePicDir); |
| | | if (!fileDir.exists()) { |
| | | fileDir.mkdirs(); |
| | | } |
| | | for (int i = 0; i < installCasePics.size(); i++) { |
| | | MultipartFile multipartFile = installCasePics.get(i); |
| | | //存储文件 |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String sparePath = installCasePicDir + fileName + suffix; |
| | | File file = new File(sparePath); |
| | | multipartFile.transferTo(file); |
| | | } |
| | | bomAcceptance.setInstallPic(installCasePicDirSuffix); |
| | | } |
| | | |
| | | String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "dev" + File.separator; |
| | | String devDir = rootFile + devDirSuffix; |
| | | //左视图 |
| | |
| | | agreement.transferTo(new File(path)); |
| | | bomAcceptance.setBomAgreement("doc_file" + File.separator + agreeDirSuffix+originalFilename); |
| | | } |
| | | String bomManualDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "bomManual" + File.separator; |
| | | String bomManualDir = rootFile + bomManualDirSuffix; |
| | | //说明书(文件) |
| | | if(bomManual!=null){ |
| | | //存储文件 |
| | | String originalFilename = bomManual.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String path = bomManualDir + fileName + suffix; |
| | | createFilefolderIFNotExist(path); |
| | | bomManual.transferTo(new File(path)); |
| | | bomAcceptance.setBomManual("doc_file" + File.separator + bomManualDirSuffix+originalFilename); |
| | | } |
| | | String testReportDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "testReport" + File.separator; |
| | | String testReportDir = rootFile + testReportDirSuffix; |
| | | //检测报告(文件) |
| | | if(testReport!=null){ |
| | | //存储文件 |
| | | String originalFilename = testReport.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String path = testReportDir + fileName + suffix; |
| | | createFilefolderIFNotExist(path); |
| | | testReport.transferTo(new File(path)); |
| | | bomAcceptance.setTestReport("doc_file" + File.separator + testReportDirSuffix+originalFilename); |
| | | } |
| | | String icdFileDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "icdFile" + File.separator; |
| | | String icdFileDir = rootFile + icdFileDirSuffix; |
| | | //ICD文件 |
| | | if(icdFile!=null){ |
| | | //存储文件 |
| | | String originalFilename = icdFile.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String path = icdFileDir + fileName + suffix; |
| | | createFilefolderIFNotExist(path); |
| | | icdFile.transferTo(new File(path)); |
| | | bomAcceptance.setIcdFile("doc_file" + File.separator + icdFileDirSuffix+originalFilename); |
| | | } |
| | | String cadPicpartDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "cadPicpart" + File.separator; |
| | | String cadPicpartDir = rootFile + cadPicpartDirSuffix; |
| | | //施工图纸(文件) |
| | | if(cadPicpart!=null){ |
| | | //存储文件 |
| | | String originalFilename = cadPicpart.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String path = cadPicpartDir + fileName + suffix; |
| | | createFilefolderIFNotExist(path); |
| | | cadPicpart.transferTo(new File(path)); |
| | | bomAcceptance.setCadPicpart("doc_file" + File.separator + cadPicpartDirSuffix+originalFilename); |
| | | } |
| | | String namePlateDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "namePlate" + File.separator; |
| | | String namePlateDir = rootFile + namePlateDirSuffix; |
| | | //铭牌信息(文件) |
| | | if(namePlate!=null){ |
| | | //存储文件 |
| | | String originalFilename = namePlate.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String path = namePlateDir + fileName + suffix; |
| | | createFilefolderIFNotExist(path); |
| | | namePlate.transferTo(new File(path)); |
| | | bomAcceptance.setNamePlate("doc_file" + File.separator + namePlateDirSuffix+originalFilename); |
| | | } |
| | | mapper.insert(bomAcceptance); |
| | | return new Response().set(1,true,"上传成功"); |
| | | } |
| | |
| | | if(bomAcceptance.getCreateTime1()!=null){ |
| | | wrapper.le("create_time",bomAcceptance.getCreateTime1()); |
| | | } |
| | | wrapper.orderByDesc("create_time"); |
| | | List<BomAcceptance> list = mapper.selectList(wrapper); |
| | | String rootFile = CommonUtil.getRootFile();//主路径 |
| | | if(list!=null&&list.size()>0){ |
| | | for (BomAcceptance acceptance:list) { |
| | | String filePath=rootFile+acceptance.getSparePicpart(); |
| | | String sparefilePath=rootFile+acceptance.getSparePicpart(); |
| | | acceptance.setSparePicpart("doc_file"+File.separator+acceptance.getSparePicpart()); |
| | | //获取文件夹下所有的图片名 |
| | | acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); |
| | | acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath)); |
| | | |
| | | String installfilePath=rootFile+acceptance.getInstallPic(); |
| | | acceptance.setInstallPic("doc_file"+File.separator+acceptance.getInstallPic()); |
| | | //获取文件夹下所有的图片名 |
| | | acceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath)); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | |
| | | } |
| | | //删除图 |
| | | public void delPic(int num, int picNum,String picUrl,String newPicUrl) { |
| | | String rootFile = CommonUtil.getRootFile();//主路径 |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("num",num); |
| | | if(picNum==1){ |
| | |
| | | if(picNum==5){ |
| | | wrapper.set("spare_picpart",newPicUrl); |
| | | } |
| | | if(picNum==6){ |
| | | /*if(picNum==6){ |
| | | wrapper.set("bom_agreement",newPicUrl); |
| | | }*/ |
| | | if(picNum==7){ |
| | | wrapper.set("bom_manual",newPicUrl); |
| | | } |
| | | if(picNum==8){ |
| | | wrapper.set("test_report",newPicUrl); |
| | | } |
| | | if(picNum==9){ |
| | | wrapper.set("icd_file",newPicUrl); |
| | | } |
| | | if(picNum==10){ |
| | | wrapper.set("cad_picpart",newPicUrl); |
| | | } |
| | | if(picNum==11){ |
| | | wrapper.set("name_plate",newPicUrl); |
| | | } |
| | | /*if(picNum==12){ |
| | | wrapper.set("install_pic",newPicUrl); |
| | | }*/ |
| | | int flag=mapper.update(null,wrapper); |
| | | if(flag>0){ |
| | | rootFile=rootFile.replace("doc_file",""); |
| | | if(flag>0&&picUrl.length()>0){ |
| | | String rootFile = CommonUtil.getRootFile();//主路径 |
| | | picUrl=picUrl.replace("doc_file",""); |
| | | //删除图片 |
| | | FileUtil.deleteFile(new File(rootFile+picUrl)); |
| | | } |
| | |
| | | if(picNum==6){ |
| | | picUrl=bomAcceptance.getBomAgreement(); |
| | | } |
| | | //后面图 |
| | | if(picNum==7){ |
| | | picUrl=bomAcceptance.getBomManual(); |
| | | } |
| | | if(picNum==8){ |
| | | picUrl=bomAcceptance.getTestReport(); |
| | | } |
| | | if(picNum==9){ |
| | | picUrl=bomAcceptance.getIcdFile(); |
| | | } |
| | | if(picNum==10){ |
| | | picUrl=bomAcceptance.getCadPicpart(); |
| | | } |
| | | if(picNum==11){ |
| | | picUrl=bomAcceptance.getNamePlate(); |
| | | } |
| | | if(filePic!=null){ |
| | | //存储文件 |
| | | String originalFilename = filePic.getOriginalFilename(); |
| | |
| | | //编辑多个图片上传 |
| | | public Response updatePartPic(List<MultipartFile> multipartFileList, int num) throws IOException { |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | rootFile=rootFile.replace("doc_file",""); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("num",num); |
| | | wrapper.last("limit 1"); |
| | |
| | | return new Response().set(1,false,"图片不存在"); |
| | | } |
| | | } |
| | | //编辑现场安装图片多个图片上传 |
| | | public Response updateInstallPic(List<MultipartFile> multipartFileList, int num) throws IOException { |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("num",num); |
| | | wrapper.last("limit 1"); |
| | | BomAcceptance bomAcceptance=mapper.selectOne(wrapper); |
| | | String picUrl=bomAcceptance.getInstallPic(); |
| | | //配件存储 |
| | | if(multipartFileList!=null && multipartFileList.size()!=0){ |
| | | for (int i = 0; i < multipartFileList.size(); i++) { |
| | | MultipartFile multipartFile = multipartFileList.get(i); |
| | | //存储文件 |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String fileName = originalFilename.substring(0, originalFilename.lastIndexOf(".")); |
| | | String suffix = originalFilename.substring(originalFilename.lastIndexOf(".")); |
| | | String installPath = rootFile+picUrl + fileName + suffix; |
| | | File file = new File(installPath); |
| | | multipartFile.transferTo(file); |
| | | } |
| | | return new Response().set(1,true,"上传成功"); |
| | | }else{ |
| | | return new Response().set(1,false,"图片不存在"); |
| | | } |
| | | } |
| | | |
| | | //导出产品验收信息 |
| | | public void downloadBomAcceptance(HttpServletRequest req, HttpServletResponse resp, int num) { |
| | | //读取产品信息 |
| | |
| | | //获取文件夹下所有的图片名 |
| | | sparePicList=FileUtil.getFileNameWithOutDirectory(filePath); |
| | | } |
| | | List<String> installPicList=new ArrayList<>(); |
| | | if(bomAcceptance.getInstallPic()!=null||!bomAcceptance.getInstallPic().isEmpty()){ |
| | | String filePath=rootFile+bomAcceptance.getInstallPic(); |
| | | //获取文件夹下所有的图片名 |
| | | installPicList=FileUtil.getFileNameWithOutDirectory(filePath); |
| | | } |
| | | |
| | | String devRoot=rootFile.replace("doc_file", ""); |
| | | List<String> devPicList=new ArrayList<>(); |
| | | if(bomAcceptance.getDevPicleft()!=null||!bomAcceptance.getDevPicleft().isEmpty()){ |
| | | devPicList.add(bomAcceptance.getDevPicleft()); |
| | | } |
| | | if(bomAcceptance.getDevPicright()!=null||!bomAcceptance.getDevPicright().isEmpty()){ |
| | | devPicList.add(bomAcceptance.getDevPicright()); |
| | | } |
| | | if(bomAcceptance.getDevPicfront()!=null||!bomAcceptance.getDevPicfront().isEmpty()){ |
| | | devPicList.add(bomAcceptance.getDevPicfront()); |
| | | } |
| | | if(bomAcceptance.getDevPicback()!=null||!bomAcceptance.getDevPicback().isEmpty()){ |
| | | devPicList.add(bomAcceptance.getDevPicback()); |
| | | } |
| | | devPicList.add(bomAcceptance.getDevPicleft()); |
| | | devPicList.add(bomAcceptance.getDevPicfront()); |
| | | devPicList.add(bomAcceptance.getDevPicright()); |
| | | devPicList.add(bomAcceptance.getDevPicback()); |
| | | |
| | | String fileName="产品验收信息记录"; |
| | | //创建单个sheet |
| | |
| | | ByteArrayOutputStream byteArrayOut = null; |
| | | for(int i=0;i<devPicList.size();i++){ |
| | | String picUrl=devPicList.get(i); |
| | | if(picUrl.length()==0){ |
| | | continue; |
| | | } |
| | | try { |
| | | byteArrayOut = new ByteArrayOutputStream(); |
| | | String path=devRoot+File.separator+picUrl; |
| | |
| | | cell.setCellValue("端口协议文本"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getBomAgreement()!=null||!bomAcceptance.getBomAgreement().equals("")){ |
| | | if(bomAcceptance.getBomAgreement()!=null&&bomAcceptance.getBomAgreement().length()>0){ |
| | | String agreement=bomAcceptance.getBomAgreement(); |
| | | String agreementName = agreement.substring(agreement.lastIndexOf(".")+1); |
| | | String agreementName = agreement.substring(agreement.lastIndexOf(File.separator)+1); |
| | | agreementName = agreementName.substring(0,agreementName.lastIndexOf(".")); |
| | | cell.setCellValue(agreementName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("说明书"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getBomManual()!=null&&bomAcceptance.getBomManual().length()>0){ |
| | | String bomManual=bomAcceptance.getBomManual(); |
| | | String bomManualName = bomManual.substring(bomManual.lastIndexOf(File.separator)+1); |
| | | bomManualName = bomManualName.substring(0,bomManualName.lastIndexOf(".")); |
| | | cell.setCellValue(bomManualName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("检测报告"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getTestReport()!=null&&bomAcceptance.getTestReport().length()>0){ |
| | | String testReport=bomAcceptance.getTestReport(); |
| | | String testReportName = testReport.substring(testReport.lastIndexOf(File.separator)+1); |
| | | testReportName = testReportName.substring(0,testReportName.lastIndexOf(".")); |
| | | cell.setCellValue(testReportName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("ICD文件"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getIcdFile()!=null&&bomAcceptance.getIcdFile().length()>0){ |
| | | String icdFile=bomAcceptance.getTestReport(); |
| | | String icdFileName = icdFile.substring(icdFile.lastIndexOf(File.separator)+1); |
| | | icdFileName = icdFileName.substring(0,icdFileName.lastIndexOf(".")); |
| | | cell.setCellValue(icdFileName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("施工图纸"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getCadPicpart()!=null&&bomAcceptance.getCadPicpart().length()>0){ |
| | | String cadPicpart=bomAcceptance.getCadPicpart(); |
| | | String cadPicpartName = cadPicpart.substring(cadPicpart.lastIndexOf(File.separator)+1); |
| | | cadPicpartName = cadPicpartName.substring(0,cadPicpartName.lastIndexOf(".")); |
| | | cell.setCellValue(cadPicpartName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("铭牌信息"); |
| | | cell.setCellStyle(cellStyle); |
| | | cell=row.createCell(1); |
| | | if(bomAcceptance.getNamePlate()!=null&&bomAcceptance.getNamePlate().length()>0){ |
| | | String namePlate=bomAcceptance.getNamePlate(); |
| | | String namePlateName = namePlate.substring(namePlate.lastIndexOf(File.separator)+1); |
| | | namePlateName = namePlateName.substring(0,namePlateName.lastIndexOf(".")); |
| | | cell.setCellValue(namePlateName); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | rowNum++; |
| | | row=sheet.createRow(rowNum); |
| | | cell=row.createCell(0); |
| | | cell.setCellValue("现场安装案例照片"); |
| | | cell.setCellStyle(cellStyle); |
| | | if(installPicList!=null&&installPicList.size()>0){ |
| | | ByteArrayOutputStream byteArrayOut = null; |
| | | for(int i=0;i<installPicList.size();i++){ |
| | | String picUrl=installPicList.get(i); |
| | | try { |
| | | byteArrayOut = new ByteArrayOutputStream(); |
| | | String path=rootFile+File.separator+bomAcceptance.getInstallPic()+File.separator+picUrl; |
| | | BufferedImage bufferImg = ImageIO.read(new FileInputStream(new File(path))); |
| | | ImageIO.write(bufferImg, "png", byteArrayOut); |
| | | //anchor主要用于设置图片的属性 |
| | | HSSFClientAnchor anchor = new HSSFClientAnchor(50, 20, 1000, 230,(short) (i+1), rowNum, (short) (i+1), rowNum); |
| | | anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE); |
| | | //插入图片 |
| | | patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | if (byteArrayOut != null) { |
| | | try { |
| | | byteArrayOut.close(); |
| | | } catch (IOException e) { |
| | | System.out.println("关闭ByteArrayOutputStream失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //将文件存到指定位置 |
| | |
| | | wrapper.eq("num",num); |
| | | wrapper.last("limit 1"); |
| | | BomAcceptance bomAcceptance=mapper.selectOne(wrapper); |
| | | String filePath=rootFile+bomAcceptance.getSparePicpart(); |
| | | String sparefilePath=rootFile+bomAcceptance.getSparePicpart(); |
| | | bomAcceptance.setSparePicpart("doc_file"+File.separator+bomAcceptance.getSparePicpart()); |
| | | //获取文件夹下所有的图片名 |
| | | bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath)); |
| | | bomAcceptance.setNameList(FileUtil.getFileNameWithOutDirectory(sparefilePath)); |
| | | |
| | | String installfilePath=rootFile+bomAcceptance.getInstallPic(); |
| | | bomAcceptance.setInstallPic("doc_file"+File.separator+bomAcceptance.getInstallPic()); |
| | | //获取文件夹下所有的图片名 |
| | | bomAcceptance.setInstallList(FileUtil.getFileNameWithOutDirectory(installfilePath)); |
| | | return new Response().set(1,bomAcceptance,"跳转详情"); |
| | | } |
| | | |
| | | } |