| | |
| | | @Override |
| | | protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception { |
| | | String clientID = httpServletRequest.getHeader(SecurityConstants.CLIENT_HEADER); |
| | | String hospitalID = httpServletRequest.getHeader(SecurityConstants.USER_HOSPITAL_ID_HEADER); |
| | | String depID = httpServletRequest.getHeader(SecurityConstants.USER_DEP_ID_HEADER); |
| | | String folderByDate = DateUtil.formatDate(new Date()); |
| | | int begin = file.getOriginalFilename().indexOf("."); |
| | | int last = file.getOriginalFilename().length(); |
| | |
| | | String fileName = UUID.randomUUID().toString().replaceAll("-", "") + fileType; |
| | | String fileFolder = ""; |
| | | if (clientID.equals("hospital")) {//医院端平台, |
| | | fileFolder = FilePath(fileInfo.getImgType(), folderByDate, null, null); |
| | | fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); |
| | | fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream()); |
| | | } else { |
| | | fileFolder = FilePath(fileInfo.getImgType(), folderByDate, null, null); |
| | | fileFolder = FilePath(fileInfo.getImgType(), folderByDate, hospitalID, depID); |
| | | fileUpLoadOss(fileInfo, fileFolder + fileName, file.getInputStream()); |
| | | } |
| | | } |
| | |
| | | * @param newFilePath 上传到的文件路径 |
| | | * @param fileStream 要上传的文件流 |
| | | */ |
| | | @Override |
| | | public void fileUpLoadOss(FileInfo fileInfo, String newFilePath, InputStream fileStream) { |
| | | ossClient.putObject(fileProperties.getOss().getBucketName(), newFilePath, fileStream); |
| | | fileInfo.setUrl(fileProperties.getOss().getDomain() + newFilePath); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public OSSObject down(String url) { |
| | | GetObjectRequest request = new GetObjectRequest(fileProperties.getOss().getBucketName(), url); |
| | | return ossClient.getObject(request); |
| | |
| | | * @param imgType |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String FilePath(String imgType, String folderByDate, String hospitalId, String departmentId) { |
| | | //返回的文件路径 |
| | | String fileFolder = OssPathEn+"/"; |
| | |
| | | if (StringUtils.isNotBlank(imgType)) { |
| | | // 光片需要按照根据医院ID,科室ID,日期进行OSS存储 |
| | | if (imgType.toLowerCase().equals("xray")) { |
| | | String hospitalID = httpServletRequest.getHeader(SecurityConstants.USER_HOSPITAL_ID_HEADER); |
| | | String depID = httpServletRequest.getHeader(SecurityConstants.USER_DEP_ID_HEADER); |
| | | if (org.apache.commons.lang3.StringUtils.isBlank(hospitalID) && |
| | | org.apache.commons.lang3.StringUtils.isBlank(depID)) { |
| | | fileFolder += "Xray/" + hospitalID + "/" + depID + "/" + folderByDate + "/"; |
| | | |
| | | if (StringUtils.isNotBlank(hospitalId) && |
| | | StringUtils.isNotBlank(departmentId)) { |
| | | fileFolder += "Xray/" + hospitalId + "/" + departmentId + "/" + folderByDate + "/"; |
| | | } else { |
| | | if (org.apache.commons.lang3.StringUtils.isBlank(hospitalId) && |
| | | org.apache.commons.lang3.StringUtils.isBlank(departmentId)) { |
| | | fileFolder += "Xray/" + hospitalId + "/" + departmentId + "/" + folderByDate + "/"; |
| | | } else { |
| | | fileFolder += "Xray/" + folderByDate + "/"; |
| | | } |
| | | fileFolder += "Xray/" + folderByDate + "/"; |
| | | } |
| | | |
| | | } else if (imgType.toLowerCase().equals("app")) { |
| | | //移动端APP上传 |
| | | if (org.apache.commons.lang3.StringUtils.isBlank(hospitalId) && |
| | | org.apache.commons.lang3.StringUtils.isBlank(departmentId)) { |
| | | if (StringUtils.isNotBlank(hospitalId) && |
| | | StringUtils.isNotBlank(departmentId)) { |
| | | fileFolder += "AppXray/" + hospitalId + "/" + departmentId + "/" + folderByDate + "/"; |
| | | } else { |
| | | fileFolder += "AppXray/" + folderByDate + "/"; |