From e67870fff62635cd14beb0d5988f08aeef4b22fa Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 21:27:06 +0800
Subject: [PATCH] 添加远程关阀式终止灌溉计划,未测试

---
 pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java |  149 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 149 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java
new file mode 100644
index 0000000..64d7d15
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/fm/FmCtrl.java
@@ -0,0 +1,149 @@
+package com.dy.pipIrrWebFile.fm;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 鍒嗗竷寮弚eb鏂囦欢绯荤粺绠$悊绯荤粺
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="fm")
+@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked")
+public class FmCtrl {
+
+    /**
+     * 鐢熸垚鏂囦欢鍚嶏紝骞朵笖璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬�
+     * 鏂囦欢鍚嶇О鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg锛屾枃浠跺悕涓笉鑳芥湁鈥�/鈥濇垨鈥淺鈥濆瓧绗�
+     * @param fileExtName 鏂囦欢鎵╁睍鍚�
+     * @return
+     */
+    @PostMapping(path = "create")
+    public FileRestVo create(String fileExtName){
+        FileRestVo rvo = new FileRestVo() ;
+        if(fileExtName != null && !fileExtName.trim().equals("")){
+            try {
+                String id = new FileNameIdUtil().generate();
+                if(id != null){
+                    rvo.fileName = FileName.createFileName(false, id, fileExtName) ;
+                    rvo = new RestHashDeal().fileTransRest(rvo.fileName, rvo) ;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return rvo ;
+    }
+
+    /**
+     * 瑙f瀽鏂囦欢鍚嶏紙甯︽垨涓嶅甫鐩稿璺緞锛夛紝璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬�
+     * 鏂囦欢鍚嶇О鍙互鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg
+     * 鏂囦欢鍚嶇О鍙互鏄甫璺緞鐨勫悕绉帮紝渚嬪锛歸ebFile/photo/20170818153254_100000007.jpg
+     * @param filePath
+     * @return
+     */
+    @PostMapping(path = "parsePath")
+    public FileRestVo parsePath(String filePath){
+        FileRestVo rvo = new FileRestVo() ;
+        if(filePath != null && !filePath.trim().equals("")){
+            try {
+                int index = filePath.lastIndexOf("\\") ;
+                if(index > 0){
+                    filePath = filePath.substring(index + 1);
+                }
+                index = filePath.lastIndexOf("/") ;
+                if(index > 0){
+                    filePath = filePath.substring(index + 1);
+                }
+                index = filePath.lastIndexOf("?") ;
+                if(index > 0){
+                    filePath = filePath.substring(0, index);
+                }
+                rvo.fileName = filePath ;
+                rvo = new RestHashDeal().fileTransRest(filePath, rvo) ;
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return rvo ;
+    }
+    /**
+     * 瑙f瀽鏂囦欢鍚嶏紝骞朵笖璁$畻鍑鸿鏂囦欢鍚嶅搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬�
+     * 鏂囦欢鍚嶇О鍙互鏄笉甯﹁矾寰勭殑鍚嶇О锛屼緥濡傦細20170818153254_100000007.jpg
+     * 鏂囦欢鍚嶇О鍙互鏄甫璺緞鐨勫悕绉帮紝渚嬪锛歸ebFile/photo/20170818153254_100000007.jpg
+     * @param filePaths
+     * @return
+     */
+    @PostMapping(path = "parsePathList", consumes = MediaType.APPLICATION_JSON_VALUE)//鍓嶇鎻愪氦json鏁版嵁
+    public FileRestVo[] parsePathList(List<String> filePaths){
+        List<FileRestVo> rList = new ArrayList<FileRestVo>() ;
+        if(filePaths != null && filePaths.size() > 0){
+            try {
+                for(String filePath : filePaths){
+                    FileRestVo rvo = new FileRestVo() ;
+                    int index = filePath.lastIndexOf("\\") ;
+                    if(index > 0){
+                        filePath = filePath.substring(index + 1);
+                    }
+                    index = filePath.lastIndexOf("/") ;
+                    if(index > 0){
+                        filePath = filePath.substring(index + 1);
+                    }
+                    index = filePath.lastIndexOf("?") ;
+                    if(index > 0){
+                        filePath = filePath.substring(0, index);
+                    }
+                    rvo.fileName = filePath ;
+                    rvo = new RestHashDeal().fileTransRest(filePath, rvo) ;
+                    rList.add(rvo) ;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return rList.toArray(new FileRestVo[0]) ;
+    }
+
+    /**
+     * 瑙f瀽鍝堝笇鍊硷紝璁$畻鍑鸿鍝堝笇鍊煎搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬�
+     * @param hashCode
+     * @return
+     */
+    @PostMapping(path = "parseHashcode")
+    public FileRestVo parseHashcode(Integer hashCode){
+        FileRestVo rvo = new FileRestVo() ;
+        if(hashCode != null){
+            try {
+                rvo.fileName = null ;
+                rvo = new RestHashDeal().fileTransRest(hashCode, rvo) ;
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return rvo ;
+    }
+
+    /**
+     * 瑙f瀽鍝堝笇鍊奸泦鍚堬紝璁$畻鍑鸿杩欎簺鍝堝笇鍊煎搴旂殑鏂囦欢鏈嶅姟鍣ㄥ睘鎬�
+     * @param hashCodes
+     * @return 鏂囦欢鏈嶅姟鍣ㄥ睘鎬у璞¢泦鍚�
+     */
+    @PostMapping(path = "parseHashcodeList")
+    public FileRestVo[] parseHashcodeList(List<Integer> hashCodes){
+        List<FileRestVo> reList = new ArrayList<>() ;
+        if(hashCodes != null && hashCodes.size() > 0){
+            for(Integer hashCode : hashCodes){
+                reList.add(parseHashcode(hashCode)) ;
+            }
+        }
+        return reList.toArray(new FileRestVo[0]) ;
+    }
+
+
+}

--
Gitblit v1.8.0