From 0cbb814f8c00469034fc98fbd5bb71fbd3bf8dd1 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 18 九月 2024 17:43:55 +0800 Subject: [PATCH] 1 --- src/main/java/com/se/simu/controller/WaterController.java | 33 ++++++++++++++++++++------------- 1 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java index 1e50750..f391f72 100644 --- a/src/main/java/com/se/simu/controller/WaterController.java +++ b/src/main/java/com/se/simu/controller/WaterController.java @@ -1,7 +1,5 @@ package com.se.simu.controller; -import com.se.simu.domain.LayerVo; -import com.se.simu.helper.StringHelper; import com.se.simu.helper.WebHelper; import com.se.simu.service.WaterService; import io.swagger.annotations.Api; @@ -17,7 +15,7 @@ import javax.servlet.http.HttpServletResponse; /** - * 鍐呮稘鎺у埗鍣� + * 鍐呮稘绠$悊 * * @author WWW * @date 2024-07-16 @@ -32,7 +30,7 @@ private final static int MIN_SIZE = 10; - private final static int MAX_SIZE = 10000000; + private final static int MAX_SIZE = 80000; private final static long Y2000 = 949334400000L; @@ -50,9 +48,9 @@ return; } - LayerVo layer = waterService.getLayer(serviceName); + byte[] bytes = waterService.getLayerJson(serviceName); - WebHelper.writeJson2Page(res, HttpStatus.OK, layer); + WebHelper.writeBytes(bytes, res); } catch (Exception ex) { log.error(ex.getMessage(), ex); WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); @@ -67,7 +65,9 @@ return; } - // + String file = waterService.getTerraMap(serviceName, width, height); + + WebHelper.writePng(file, res); } catch (Exception ex) { log.error(ex.getMessage(), ex); WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); @@ -82,7 +82,9 @@ return; } - // + String file = waterService.getWaterMap(serviceName, width, height, timestamp); + + WebHelper.writePng(file, res); } catch (Exception ex) { log.error(ex.getMessage(), ex); WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); @@ -97,7 +99,9 @@ return; } - // + String file = waterService.getFlowMap(serviceName, width, height, timestamp); + + WebHelper.writePng(file, res); } catch (Exception ex) { log.error(ex.getMessage(), ex); WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); @@ -105,7 +109,7 @@ } private boolean validate(String serviceName, HttpServletResponse res) { - if (StringHelper.isEmpty(serviceName)) { + if (WebHelper.isEmpty(serviceName)) { return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏈嶅姟鍚嶄笉鑳戒负绌�"); } @@ -116,8 +120,11 @@ return validate(serviceName, width, height, Y2000, res); } + /** + * 楠岃瘉 + */ private boolean validate(String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { - if (StringHelper.isEmpty(serviceName)) { + if (WebHelper.isEmpty(serviceName)) { return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏈嶅姟鍚嶄笉鑳戒负绌�"); } if (null == width || width < MIN_SIZE || width > MAX_SIZE) { @@ -126,8 +133,8 @@ if (null == height || height < MIN_SIZE || height > MAX_SIZE) { return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鍥惧儚楂樺害涓嶈兘涓虹┖涓斿彇鍊艰寖鍥翠负" + MIN_SIZE + "~" + MAX_SIZE + "涔嬮棿"); } - if (null == timestamp || timestamp < Y2000) { - return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏃堕棿涓嶈兘涓虹┖涓斿ぇ浜�2000骞�"); + if (null == timestamp || timestamp < 0) { + return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "鏃堕棿涓嶈兘涓虹┖涓斿ぇ浜�0"); } return true; -- Gitblit v1.9.3