|
@@ -0,0 +1,109 @@
|
|
1
|
+package com.eitc.web.controller.saomiaoyi;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson2.JSONObject;
|
|
4
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
5
|
+import com.eitc.common.config.EitcConfig;
|
|
6
|
+import com.eitc.common.core.domain.AjaxResult;
|
|
7
|
+import com.eitc.common.utils.InterfaceVerificationUtil;
|
|
8
|
+import com.eitc.common.utils.file.FileUploadUtils;
|
|
9
|
+import com.eitc.framework.config.ServerConfig;
|
|
10
|
+import com.eitc.patient.domain.ImageRecord;
|
|
11
|
+import com.eitc.patient.service.IImageRecordService;
|
|
12
|
+import io.swagger.annotations.ApiOperation;
|
|
13
|
+import org.apache.commons.lang3.StringUtils;
|
|
14
|
+import org.springframework.beans.factory.annotation.Value;
|
|
15
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
16
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
17
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
18
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
19
|
+import org.springframework.web.bind.annotation.RestController;
|
|
20
|
+import org.springframework.web.client.RestTemplate;
|
|
21
|
+import org.springframework.web.multipart.MultipartFile;
|
|
22
|
+
|
|
23
|
+import javax.annotation.Resource;
|
|
24
|
+import java.util.ArrayList;
|
|
25
|
+import java.util.Arrays;
|
|
26
|
+import java.util.HashMap;
|
|
27
|
+import java.util.List;
|
|
28
|
+
|
|
29
|
+/**
|
|
30
|
+ * SaoMiaoYiController
|
|
31
|
+ *
|
|
32
|
+ * @author mtx
|
|
33
|
+ * @date: 2024/09/11 14:37
|
|
34
|
+ */
|
|
35
|
+@RestController
|
|
36
|
+@RequestMapping("/pc/api/scanner")
|
|
37
|
+public class SaoMiaoYiController {
|
|
38
|
+
|
|
39
|
+ @Resource
|
|
40
|
+ private RestTemplate restTemplate;
|
|
41
|
+ @Value("${Total.ip}")
|
|
42
|
+ private String fileUrl;
|
|
43
|
+ @Resource
|
|
44
|
+ private IImageRecordService imageRecordService;
|
|
45
|
+ @Resource
|
|
46
|
+ private ServerConfig serverConfig;
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * 慧视口腔-诊所列表
|
|
50
|
+ *
|
|
51
|
+ */
|
|
52
|
+ @GetMapping(value = "/clinicList")
|
|
53
|
+ @ApiOperation("慧视健康-诊所列表")
|
|
54
|
+ public JSONObject clinicList() {
|
|
55
|
+ // 这个是为了防止恶意请求来做的参数增加
|
|
56
|
+ String saSignStr = InterfaceVerificationUtil.getSaSignStr(new HashMap<>());
|
|
57
|
+ String url = fileUrl + "api/sys/clinict/appGetClinictList?" + saSignStr;
|
|
58
|
+ String object = restTemplate.getForObject(url, String.class);
|
|
59
|
+ return JSONObject.parseObject(object);
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+ @PostMapping("/uploads")
|
|
64
|
+ @ApiOperation("上传影像")
|
|
65
|
+ public AjaxResult uploadFiles(String identificationCard, List<MultipartFile> files) {
|
|
66
|
+ if (StringUtils.isBlank(identificationCard)) {
|
|
67
|
+ return AjaxResult.warn("请输入身份证号");
|
|
68
|
+ }
|
|
69
|
+ try {
|
|
70
|
+ List<ImageRecord> list = new ArrayList<>();
|
|
71
|
+ // 上传文件路径
|
|
72
|
+ String filePath = EitcConfig.getUploadPath();
|
|
73
|
+ // 上传并返回新文件名称
|
|
74
|
+ for (MultipartFile file : files) {
|
|
75
|
+ // 上传并返回新文件名称
|
|
76
|
+ String fileName = FileUploadUtils.upload(filePath, file);
|
|
77
|
+ ImageRecord imageRecord = new ImageRecord();
|
|
78
|
+ imageRecord.setImageUrl(fileName);
|
|
79
|
+ String url = serverConfig.getUrl() + fileName;
|
|
80
|
+ imageRecord.setFullImageUrl(url);
|
|
81
|
+ imageRecord.setIdentificationCard(identificationCard);
|
|
82
|
+ list.add(imageRecord);
|
|
83
|
+ }
|
|
84
|
+ return toAjax(imageRecordService.saveBatch(list));
|
|
85
|
+ } catch (Exception e) {
|
|
86
|
+ return AjaxResult.error(e.getMessage());
|
|
87
|
+ }
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ @GetMapping("/list")
|
|
91
|
+ @ApiOperation("查询影像")
|
|
92
|
+ public AjaxResult list(ImageRecord imageRecord) {
|
|
93
|
+ List<ImageRecord> list = imageRecordService.list(Wrappers.<ImageRecord>lambdaQuery()
|
|
94
|
+ .eq(StringUtils.isNotBlank(imageRecord.getIdentificationCard()), ImageRecord::getIdentificationCard, imageRecord.getIdentificationCard()));
|
|
95
|
+ return AjaxResult.success(list);
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ @DeleteMapping("/remove")
|
|
99
|
+ @ApiOperation("删除影像")
|
|
100
|
+ public AjaxResult remove(String ids) {
|
|
101
|
+ List<String> idList = Arrays.asList(ids.split(","));
|
|
102
|
+ return toAjax(imageRecordService.removeBatchByIds(idList));
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ private AjaxResult toAjax(boolean result) {
|
|
106
|
+ return result ? AjaxResult.success() : AjaxResult.error();
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+}
|