| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.util.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | import com.ltkj.common.core.domain.entity.SysDictData; |
| | | import com.ltkj.common.utils.SnowFlake; |
| | | import com.ltkj.common.utils.uuid.UUID; |
| | | import com.ltkj.db.DataSourceContextHolder; |
| | | import com.ltkj.hosp.domain.SysAttachment; |
| | | import com.ltkj.hosp.service.ISysAttachmentService; |
| | | import com.ltkj.system.service.ISysDictDataService; |
| | |
| | | |
| | | @Autowired |
| | | private ServerConfig serverConfig; |
| | | |
| | | @Value("${path.xdtfilePath}") |
| | | private String value; |
| | | |
| | | private static final String FILE_DELIMETER = ","; |
| | | |
| | |
| | | } |
| | | return AjaxResult.success("删除成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 心电图报告上传图片方法 |
| | | */ |
| | | @PostMapping("/uploadXdtFile") |
| | | @ApiOperation(value = "心电图报告上传图片方法") |
| | | public AjaxResult uploadXdtFile(@ApiParam("文件") @RequestPart("file") MultipartFile file, |
| | | @ApiParam("体检号") String tjh,@ApiParam("项目id") String proId) throws Exception { |
| | | try { |
| | | // 上传文件路径 |
| | | // 第一步:生成文件并保存 |
| | | String key = DataSourceContextHolder.getDataSourceKey(); |
| | | key = key.replace("ltkjpeis10_",""); |
| | | String filePath = value + File.separator + key + File.separator; |
| | | String outputFileName = tjh +"_" +proId; |
| | | // 上传并返回新文件名称 |
| | | String fileName = FileUploadUtils.upload(filePath,outputFileName, file); |
| | | String url = filePath + fileName; |
| | | Path path = Paths.get(url); |
| | | byte[] data = Files.readAllBytes(path); |
| | | String base64 = Base64.getEncoder().encodeToString(data); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("url", url); |
| | | ajax.put("fileName", fileName); |
| | | ajax.put("base64", base64); |
| | | return ajax; |
| | | } catch (Exception e) { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | } |