|
@@ -1,8 +1,15 @@
|
|
|
package com.ruoyi.system.enterprise.base.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
import java.util.List;
|
|
|
import java.io.IOException;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.google.zxing.WriterException;
|
|
|
+import com.ruoyi.common.core.utils.uuid.UUID;
|
|
|
+import com.ruoyi.system.enterprise.base.util.QRCodeGenerator;
|
|
|
+import com.ruoyi.system.enterprise.base.util.SFTPFileUpload;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -21,6 +28,10 @@ import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 实验项目-重复存储Controller
|
|
@@ -35,6 +46,45 @@ public class TECompareobjectRepeatController extends BaseController
|
|
|
@Autowired
|
|
|
private ITECompareobjectRepeatService tECompareobjectRepeatService;
|
|
|
|
|
|
+
|
|
|
+// String base = "/usr/local/nginx/html/";
|
|
|
+String base ="C:\\Program Files\\north\\image\\";
|
|
|
+ String ip="8.130.113.97";
|
|
|
+ String port="20000";
|
|
|
+ @PostMapping(value = "/code/{id}")
|
|
|
+ public String code(@PathVariable("id") String id) throws IOException, WriterException {
|
|
|
+ System.out.println(1);
|
|
|
+ String path = base + id + ".png";
|
|
|
+
|
|
|
+// String path = "/usr/local/nginx/html/files/" + id + ".png"; // 仍然使用服务器本地路径生成图片
|
|
|
+ System.out.println(id);
|
|
|
+ QRCodeGenerator.generateQRCodeImage(id, 100, 100, path);
|
|
|
+
|
|
|
+ String remoteDir = "/usr/local/nginx/html/files/"; // 远程服务器目录
|
|
|
+ String remoteHost = "8.130.113.97"; // 远程服务器地址
|
|
|
+ String username = "root"; // 远程服务器用户名
|
|
|
+ String password = "sys200888"; // 远程服务器密码
|
|
|
+ int port = 22;
|
|
|
+ String port2 = "20000";
|
|
|
+ File localFile = new File(path);
|
|
|
+ if (!localFile.exists()) {
|
|
|
+ System.out.println("本地文件不存在: " + path);
|
|
|
+ }
|
|
|
+
|
|
|
+ try (FileInputStream fis = new FileInputStream(localFile)) {
|
|
|
+ // 调用工具类上传文件
|
|
|
+ SFTPFileUpload.uploadFile(fis, remoteDir, remoteHost, username, password, port, localFile.getName());
|
|
|
+ System.out.println("文件上传11");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ System.out.println("文件上传失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String url = "http://" + ip + ":" + port2 + "/files/files/" + id + ".png";
|
|
|
+ return url;
|
|
|
+// return base + id + ".png"; // 返回服务器可访问的URL
|
|
|
+ }
|
|
|
/**
|
|
|
* 查询实验项目-重复存储列表
|
|
|
*/
|
|
@@ -75,10 +125,25 @@ public class TECompareobjectRepeatController extends BaseController
|
|
|
*/
|
|
|
@RequiresPermissions("system.base:repeat:add")
|
|
|
@Log(title = "实验项目-重复存储", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping
|
|
|
+ @PostMapping("/add")
|
|
|
public AjaxResult add(@RequestBody TECompareobjectRepeat tECompareobjectRepeat)
|
|
|
{
|
|
|
+ SetSeq setSeq = new SetSeq();
|
|
|
+
|
|
|
+ tECompareobjectRepeat.setSeq(setSeq.createseq());
|
|
|
+ tECompareobjectRepeat.setId(UUID.fastUUID().toString());
|
|
|
+ // 使用 code 方法生成二维码路径并设置到 qcode 属性
|
|
|
+ try {
|
|
|
+ String qrCodePath = code(tECompareobjectRepeat.getId());
|
|
|
+ tECompareobjectRepeat.setQcode(qrCodePath);
|
|
|
+ } catch (IOException | WriterException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error("生成二维码失败");
|
|
|
+ }
|
|
|
+ System.out.println("测试一下"+tECompareobjectRepeat);
|
|
|
+
|
|
|
return toAjax(tECompareobjectRepeatService.insertTECompareobjectRepeat(tECompareobjectRepeat));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|