Преглед изворни кода

Merge branch 'master' of https://gitee.com/antai-wuliu/ANTAI-API

dengpan пре 1 година
родитељ
комит
4da5de84ed

+ 0 - 1
.gitignore

@@ -6,7 +6,6 @@ rebel.xml
 out/artifacts/
 dil-api.iml
 src/test
-
 # Compiled class file
 *.class
 

+ 5 - 1
pom.xml

@@ -70,7 +70,11 @@
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.4.2</version>
         </dependency>
-
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.11.0</version>
+        </dependency>
 <!--        <dependency>-->
 <!--            <groupId>org.springframework.boot</groupId>-->
 <!--            <artifactId>spring-boot-starter-security</artifactId>-->

+ 1 - 1
src/main/java/com/steerinfo/dil/annotaion/RequestLimit.java

@@ -10,5 +10,5 @@ import java.lang.annotation.*;
 @Documented
 public @interface RequestLimit {
     int seconds() default 1;//秒
-    int maxCount() default 1;//最大访问次数
+    int maxCount() default 100;//最大访问次数
 }

+ 1 - 1
src/main/java/com/steerinfo/dil/config/RepeatRequestIntercept.java

@@ -44,7 +44,7 @@ public class RepeatRequestIntercept extends HandlerInterceptorAdapter {
                 //判断是否超过最大限定请求次数
                 if (requestCount < max) {
                     //未超过则请求次数+1
-                    redisUtils.incr(key, 1);
+                    redisUtils.incr(key, 100);
                 } else {
                     //否则拒绝请求并返回信息
                     refuse(response);

+ 1 - 1
src/main/java/com/steerinfo/dil/controller/EMSController.java

@@ -148,7 +148,7 @@ public class EMSController extends BaseRESTfulController {
                                              Integer pageNum,
                                              Integer pageSize
     ) {
-        return emsFeign.emsdetailsordersList(mapValue == null ? new HashMap<>() : mapValue, apiId, pageNum, pageSize);
+        return emsFeign.emssalarydetailsList(mapValue == null ? new HashMap<>() : mapValue, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "新增详单明细")

+ 117 - 28
src/main/java/com/steerinfo/dil/controller/SystemFileController.java

@@ -16,16 +16,23 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.MultiValueMap;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
 
 import javax.annotation.Resource;
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * SystemFile RESTful接口:
@@ -157,11 +164,11 @@ public class SystemFileController extends BaseRESTfulController {
     public RESTfulResult insertFiles(String[] fileUuids, String[] fileNames, String[] fileTypes, Map<Object, MultipartFile> FileList, MultipartRequest request) throws Exception {
 
 
-        List<MultipartFile> files  = new ArrayList<>();
-        int index=-1;
-        for(int j = 0 ; j < fileTypes.length ; j ++ ) {
-            for(int i=0;i<21;i++) {
-                MultipartFile file = request.getFile("file" +j +"" + i);
+        List<MultipartFile> files = new ArrayList<>();
+        int index = -1;
+        for (int j = 0; j < fileTypes.length; j++) {
+            for (int i = 0; i < 21; i++) {
+                MultipartFile file = request.getFile("file" + j + "" + i);
                 if (file != null) {
                     files.add(file);
                     if (index < 0) {
@@ -171,7 +178,7 @@ public class SystemFileController extends BaseRESTfulController {
             }
         }
 
-        if(files.size() == 0) {
+        if (files.size() == 0) {
             return failed("传输失败");
         }
         for (int i = 0; i < fileUuids.length; i++) {
@@ -233,22 +240,22 @@ public class SystemFileController extends BaseRESTfulController {
 
         SystemFile value = systemFileMapper.selectByPrimaryKey(parmas.get("id").toString());
 
-            String fileName = value.getFilename();
-            String filepath = value.getFilepath();
-            if (fileName == null || fileName.isEmpty()) {
-                return failed("该图片不存在!");
-            }
-            if (filepath == null || filepath.isEmpty()) {
-                return failed("该图片地址不存在!");
-            }
+        String fileName = value.getFilename();
+        String filepath = value.getFilepath();
+        if (fileName == null || fileName.isEmpty()) {
+            return failed("该图片不存在!");
+        }
+        if (filepath == null || filepath.isEmpty()) {
+            return failed("该图片地址不存在!");
+        }
 
-            try {
-                String result = ftpFileUtil.downloadFile(fileName, filepath);
-                return success(result);
-            } catch (IOException e) {
-                e.getMessage();
-                return failed();
-            }
+        try {
+            String result = ftpFileUtil.downloadFile(fileName, filepath);
+            return success(result);
+        } catch (IOException e) {
+            e.getMessage();
+            return failed();
+        }
 
     }
 
@@ -303,22 +310,24 @@ public class SystemFileController extends BaseRESTfulController {
 
     @PostMapping("/previewfileList")
     public RESTfulResult previewfileList(@RequestBody HashMap map) {
-        String uuid =  map.get("uuid").toString();
+        String uuid = map.get("uuid").toString();
         String[] uuidList = uuid.split(";");
         //遍历数组,去找文件名称和路径
-        List<Map<String,Object>> mapList = systemFileMapper.getFileInfo(uuidList);
-        List<Map<String,Object>> resultList = new ArrayList<>();
-        for (Map<String,Object> parmas : mapList) {
+        List<Map<String, Object>> mapList = systemFileMapper.getFileInfo(uuidList);
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        for (Map<String, Object> parmas : mapList) {
             String filename = parmas.get("FILENAME").toString();
             String filepath = parmas.get("FILEPATH").toString();
-            if (filename == null ||filename.isEmpty()) {
+            if (filename == null || filename.isEmpty()) {
                 return failed("该图片不存在!");
             }
-            if (filepath == null ||filepath.isEmpty()) {
+            if (filepath == null || filepath.isEmpty()) {
                 return failed("该图片地址不存在!");
             }
             try {
-                Map<String,Object> result = ftpFileUtil.downloadFileNew(filename, filepath);
+                Map<String, Object> result = ftpFileUtil.downloadFileNew(filename, filepath);
+                //如果是返回base64,则给这个;网络路径则给netUrl
+                result.put("dataType","base");
                 resultList.add(result);
             } catch (IOException e) {
                 e.getMessage();
@@ -330,4 +339,84 @@ public class SystemFileController extends BaseRESTfulController {
     }
 
 
+    @PostMapping("/insertFilesReal")
+    public RESTfulResult insertFilesReal(MultipartRequest request, String[] uuidTypes) throws Exception {
+        //List<MultipartFile> files  = new ArrayList<>();
+        //获取多个文件
+        MultiValueMap<String, MultipartFile> multiFileMap = request.getMultiFileMap();
+        List<MultipartFile> files = multiFileMap.get("file");
+        System.out.println(uuidTypes + "uuidTypes");
+        System.out.println(request);
+        if (files.size() == 0) {
+            return failed("传输失败");
+        }
+        int index = 0;
+        for (MultipartFile file : files) {
+            String uuidType = uuidTypes[index];
+            String fileMediaType = file.getContentType();
+            String newName = uuidType.split(";")[0];
+
+            String uuid = uuidType.split(";")[0];
+            String fileType = uuidType.split(";")[1];
+            InputStream inputStream = file.getInputStream();
+            if (fileMediaType != null && fileMediaType.contains("image")) {
+                newName = uuidType.split(";")[0] + "." +fileMediaType.split("/")[1];
+                ////如果是图片
+                //BufferedImage originalImage = ImageIO.read(inputStream);
+                //// 确保原始图片有效且可以读取
+                //if (originalImage != null) {
+                //    // 添加水印逻辑
+                //    inputStream = addWatermark(originalImage);
+                //    // 保存或返回带有水印的图片
+                //    // ...
+                //}
+            }
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
+            String filePath = simpleDateFormat.format(new Date()) + "/" + fileType;
+            boolean result = ftpFileUtil.uploadToFtp(inputStream, filePath, newName, false);
+            inputStream.close();
+            if (result) {
+                SystemFile uploadFile = new SystemFile();
+                uploadFile.setFilename(newName);
+                uploadFile.setFilepath(filePath + "/" + newName);
+                uploadFile.setId(uuid);
+                SystemFile modela = systemFileService.add(uploadFile);
+                if (modela != null) {
+                    uuid += "," + modela.getId();
+                }
+            } else {
+                return failed(null, "上传文件失败");
+            }
+            index++;
+        }
+        return success();
+}
+
+    //private InputStream addWatermark(BufferedImage originalImage) {
+    //    int width = originalImage.getWidth();
+    //    int height = originalImage.getHeight();
+    //
+    //    //BufferedImage watermarkedImage = Scalr.resize(originalImage, width, height, Scalr.Mode.FIT_EXACT);
+    //
+    //    Graphics2D graphics = watermarkedImage.createGraphics();
+    //
+    //    // 设置水印样式
+    //    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+    //    Font font = new Font("Arial", Font.BOLD, 30);
+    //    graphics.setFont(font);
+    //    Color color = new Color(255, 0, 0, 128);
+    //    graphics.setColor(color);
+    //
+    //    // 添加水印文字
+    //    graphics.drawString("Your Watermark Text", 10, height - 40); // 示例位置
+    //
+    //    graphics.dispose();
+    //
+    //    // 将带水印的图片转为InputStream
+    //    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    //    ImageIO.write(watermarkedImage, "jpg", baos);
+    //    InputStream watermarkedStream = new ByteArrayInputStream(baos.toByteArray());
+    //
+    //    return watermarkedStream;
+    //}
 }

+ 1 - 0
src/main/java/com/steerinfo/dil/controller/TMSController.java

@@ -190,6 +190,7 @@ public class TMSController extends BaseRESTfulController {
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/startend")
     @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"计时"})
+    @RequestLimit
     public Map<String, Object> start(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.startend(map);
     }

+ 2 - 0
src/main/java/com/steerinfo/dil/controller/UniversalController.java

@@ -65,6 +65,8 @@ public class UniversalController extends BaseRESTfulController {
         return success(list);
     }
 
+
+
     @ApiModelProperty(value = "边输边查运力类型")
     @PostMapping("/getCapacityTypeByLike")
     public RESTfulResult getCapacityTypeByLike(@RequestBody(required = false) Map<String,Object> map) {

+ 5 - 0
src/main/java/com/steerinfo/dil/controller/WebSocketController.java

@@ -45,4 +45,9 @@ public class WebSocketController {
     public RESTfulResult getBaseWebsocketPush(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
         return webSocketFeign.basewebsocketpushsList(parmas,pageNum,pageSize);
     }
+
+    @GetMapping(value = "/getUserByOrgCode/{orgCode}")//String
+    public RESTfulResult getUserByOrgCode(@PathVariable("orgCode") String orgCode){
+        return webSocketFeign.getUserByOrgCode(orgCode);
+    }
 }

+ 4 - 0
src/main/java/com/steerinfo/dil/feign/WebSocketFeign.java

@@ -30,4 +30,8 @@ public interface WebSocketFeign {
     RESTfulResult noPage(@RequestParam HashMap<String,Object> parmas);
     @GetMapping("api/v1/websocket/basewebsocketpushs/{id}")
     RESTfulResult get(@PathVariable String id);
+    @GetMapping("api/v1/websocket/basewebsocketpushs/getUserByOrgCode/{orgCode}")//String
+    RESTfulResult getUserByOrgCode(@PathVariable("orgCode") String orgCode);
+    @PostMapping("/sendWebsocketByIds/{ids}")
+    RESTfulResult sendWebsocketByIds(@PathVariable("ids") String webSocketIds, @RequestBody HashMap<String,Object> map);
 }

+ 1 - 1
src/main/java/com/steerinfo/dil/util/poiutil.java

@@ -15,7 +15,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 
-//导excle工具类
+//导excle工具类
 
 public class poiutil {
     private final static String xls = "xls";

+ 1 - 1
src/main/resources/application-dev.yml

@@ -51,7 +51,7 @@ openfeign:
   OMSFeign:
     url: ${OMSFEIGN_URL:172.16.90.214:8095}
   RmsFeign:
-    url: ${RMSFEIGN_URL:172.16.90.214:8060}
+    url: ${RMSFEIGN_URL:localhost:8060}
   IntegrationFeign:
     url: ${INTEGRATIONFEIGN_URL:localhost:8066}
   OTMSFeign: