| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * 内涝控制器 |
| | |
| | | |
| | | 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; |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getTerraMap(serviceName, width, height); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getWaterMap(serviceName, width, height); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getFlowMap(serviceName, width, height, timestamp); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return validate(serviceName, width, height, Y2000, res); |
| | | } |
| | | |
| | | /** |
| | | * 验证 |
| | | */ |
| | | private boolean validate(String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { |
| | | if (StringHelper.isEmpty(serviceName)) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 写文件 |
| | | */ |
| | | private boolean writeFile(String path, HttpServletResponse res) throws Exception { |
| | | if (StringHelper.isEmpty(path)) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "生成PNG失败"); |
| | | } |
| | | File file = new File(path); |
| | | if (!file.exists() || file.isDirectory()) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "PNG文件找不到"); |
| | | } |
| | | |
| | | WebHelper.download(path, file.getName(), res); |
| | | |
| | | return true; |
| | | } |
| | | } |