| | |
| | | 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 javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.domain.R; |
| | | import com.ltkj.common.core.domain.entity.SysDictData; |
| | | import com.ltkj.common.utils.SnowFlake; |
| | | import com.ltkj.common.utils.uuid.UUID; |
| | | import com.ltkj.hosp.domain.SysAttachment; |
| | | import com.ltkj.hosp.service.ISysAttachmentService; |
| | | import com.ltkj.system.service.ISysDictDataService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | |
| | | @Value("${ltkj.profile}") |
| | | String path; |
| | | @Autowired |
| | | private ISysAttachmentService sysAttachmentService; |
| | | @Autowired |
| | | private ISysDictDataService sysDictDataService; |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 重新写的上传图片 适用于体检套餐 |
| | | */ |
| | | // TODO: 2023/2/13 套餐图片上传 部署服务器修改路径 |
| | | @PostMapping("/packageUpload") |
| | | public AjaxResult packageUpload(@RequestBody MultipartFile file) { |
| | | String fileName = file.getOriginalFilename(); |
| | |
| | | ajax.put("originalFilename", file.getOriginalFilename()); |
| | | return ajax; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通用上传请求(单个) |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/uploadImgExe") |
| | | @ApiOperation(value = "EXE程序循环读取图片上传") |
| | | public AjaxResult uploadImgExe(@RequestPart("file") MultipartFile file,@RequestParam("val")String dictVal,@RequestParam("ip")String ip){ |
| | | try { |
| | | // 上传文件路径 |
| | | String filePath = ltkjConfig.getUploadPath(); |
| | | // 上传并返回新文件名称 |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("url", url); |
| | | //ajax.put("filePath", path+fileName); |
| | | ajax.put("fileName", fileName); |
| | | final String newFileName = FileUtils.getName(fileName); |
| | | ajax.put("newFileName", newFileName); |
| | | ajax.put("originalFilename", file.getOriginalFilename()); |
| | | SysAttachment sysAttachment = new SysAttachment(); |
| | | sysAttachment.setId(SnowFlake.getInstance().nextId()); |
| | | sysAttachment.setFileName(newFileName); |
| | | sysAttachment.setFilePath(fileName); |
| | | sysAttachment.setUrl(url); |
| | | sysAttachment.setSysDictVal(dictVal); |
| | | sysAttachment.setIp(ip); |
| | | final Map<String, String> map = FileUploadUtils.getFileSize(file); |
| | | sysAttachment.setFileSize(map.get("fileSizeBytes")); |
| | | sysAttachment.setFileSizeMb(map.get("fileSizeMB")); |
| | | sysAttachment.setFileSizeGb(map.get("fileSizeGB")); |
| | | sysAttachmentService.insertSysAttachment(sysAttachment); |
| | | return ajax; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/listExeVal") |
| | | public AjaxResult listExeDictVal(){ |
| | | LambdaQueryWrapper<SysDictData> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(SysDictData::getDictType,"sys_exe_img_type"); |
| | | final List<SysDictData> list = sysDictDataService.list(queryWrapper); |
| | | ArrayList<HashMap<String, String>> hashMaps = new ArrayList<>(); |
| | | for (SysDictData sysDictData : list) { |
| | | HashMap<String, String> hashMap = new HashMap<>(); |
| | | hashMap.put("label",sysDictData.getDictLabel()); |
| | | hashMap.put("value",sysDictData.getDictValue()); |
| | | hashMaps.add(hashMap); |
| | | } |
| | | return AjaxResult.success().put("data",hashMaps); |
| | | } |
| | | |
| | | @GetMapping("/uploadFile") |
| | | @ApiOperation(value = "通用文件上传base64") |
| | |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | @DeleteMapping("/deletedFile") |
| | | @ApiOperation(value = "通用文件删除接口") |
| | | public AjaxResult deletedFile(@RequestParam String url) { |
| | | //文件后缀 |
| | | File files=new File(url); |
| | | String name = files.getName(); |
| | | File file=new File(photoPath+name); |
| | | if (file.exists()) { |
| | | if(file.delete()){ |
| | | return AjaxResult.success("删除成功"); |
| | | } |
| | | return AjaxResult.error("删除失败"); |
| | | } |
| | | return AjaxResult.success("删除成功"); |
| | | } |
| | | } |