| | |
| | | } |
| | | } |
| | | if (!signUserId && !signDeptId){ |
| | | wrapper.eq("user_id", getUserId()); |
| | | if (getRole().getId()==1){ |
| | | wrapper.or().eq("host_id",1); |
| | | }else if (getRole().getId()==2){ |
| | | wrapper.eq("dept_id",getDeptId()); |
| | | }else { |
| | | wrapper.eq("user_id", getUserId()); |
| | | } |
| | | } |
| | | if (signHostId){ |
| | | wrapper.or().eq("host_id",1); |
| | |
| | | /////////////////////////生成Tab表格数据///////////////////////// |
| | | |
| | | String fileName = this.getClass().getClassLoader().getResource("contractTemplate/" + contractTemplate + ".docx").getPath();//获取文件路径 |
| | | return WordUtils.generate(fileName, map, tabParam); |
| | | |
| | | // String outPdfPath = fileName.split("\\.")[0]+".pdf"; |
| | | ResponseEntity<InputStreamResource> generate = WordUtils.generate(fileName, map, tabParam); |
| | | // WordUtils.documents4jWordToPdf(fileName,outPdfPath); |
| | | return generate; |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | |
| | | //文件后缀名 |
| | | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | //上传文件名 |
| | | String filename = format.format(new Date()) + suffix; |
| | | String filename = format.format(new Date()) + "_" + file.getOriginalFilename(); |
| | | //最终文件路径 |
| | | String filepath = path + "/" + filename; |
| | | //OSS文件存储路径 |
| | |
| | | |
| | | @RequestMapping(value = "/contract/download/auth") |
| | | @ManagerAuth(memo = "下载合同") |
| | | public ResponseEntity<InputStreamResource> download(@RequestParam("id") Integer id) { |
| | | public R download(@RequestParam("id") Integer id) { |
| | | Contract contract = contractService.selectById(id); |
| | | if (contract == null) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | if (Cools.isEmpty(contract.getFilepath())) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | |
| | | try { |
| | | return ossService.downloadFile(contract.getFilepath());//从OSS中下载文件 |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | String download = ossService.download(contract.getFilepath());//获取OSS临时下载URL |
| | | return R.ok().add(download); |
| | | } |
| | | |
| | | @RequestMapping(value = "/contract/export/auth") |