尚医通-OSS存储+预约统计+定时任务
该模块需要开通阿里云的OSS服务,并在application.properties中进行配置,在本项目中主要用于用户进行实名认证时上传身份证等
上传文件到阿里云oss
前端请求:
1
| @PostMapping("fileUpload")
|
后端处理:
1 2 3 4 5
| public Result fileUpload(MultipartFile file) { String url = fileService.upload(file); return Result.ok(url); }
|
upload方法具体实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| public String upload(MultipartFile file) { String endpoint = ConstantOssPropertiesUtils.EDNPOINT; String accessKeyId = ConstantOssPropertiesUtils.ACCESS_KEY_ID; String accessKeySecret = ConstantOssPropertiesUtils.SECRECT; String bucketName = ConstantOssPropertiesUtils.BUCKET; try { OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); InputStream inputStream = file.getInputStream(); String fileName = file.getOriginalFilename(); String uuid = UUID.randomUUID().toString().replaceAll("-",""); fileName = uuid+fileName;
String timeUrl = new DateTime().toString("yyyy/MM/dd"); fileName = timeUrl+"/"+fileName;
ossClient.putObject(bucketName, fileName, inputStream); ossClient.shutdown(); String url = "https://"+bucketName+"."+endpoint+"/"+fileName; return url; } catch (IOException e) { e.printStackTrace(); return null; } }
|
获取预约统计数据
前端请求:
1
| @GetMapping("getCountMap")
|
后端处理:
1 2 3 4
| public Result getCountMap(OrderCountQueryVo orderCountQueryVo) { Map<String, Object> countMap = orderFeignClient.getCountMap(orderCountQueryVo); return Result.ok(countMap); }
|
每天执行就医提醒
前端请求:
1
| @Scheduled(cron = "0/30 * * * * ?")
|
后端处理:
1 2 3
| public void taskPatient() { rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,""); }
|