¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.se.simu.domain.R; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | | |
| | | /** |
| | | * åºç¡æ§å¶å¨ |
| | | * |
| | | * @author WWW |
| | | * @date 2024-07-30 |
| | | */ |
| | | @Slf4j |
| | | public class BaseController { |
| | | public <T> R<T> success(T data) { |
| | | return new R<T>(HttpStatus.OK, data); |
| | | } |
| | | |
| | | public <T> R<T> success(T data, String msg) { |
| | | return new R<T>(HttpStatus.OK, data, msg); |
| | | } |
| | | |
| | | public <T> R<T> success(T data, long count) { |
| | | return new R<T>(HttpStatus.OK, data, count); |
| | | } |
| | | |
| | | public <T> R<T> success(T data, long count, String msg) { |
| | | return new R<T>(HttpStatus.OK, data, count, msg); |
| | | } |
| | | |
| | | public <T> R<T> fail(T data) { |
| | | return new R<T>(HttpStatus.INTERNAL_SERVER_ERROR, data); |
| | | } |
| | | |
| | | public <T> R<T> fail(String msg, T data) { |
| | | return new R<T>(HttpStatus.INTERNAL_SERVER_ERROR, data, msg); |
| | | } |
| | | |
| | | public <T> R<T> fail(Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return new R<T>(HttpStatus.INTERNAL_SERVER_ERROR, null, ex.getMessage()); |
| | | } |
| | | |
| | | public <T> R<T> fail(Exception ex, T data) { |
| | | log.error(ex.getMessage(), ex); |
| | | return new R<T>(HttpStatus.INTERNAL_SERVER_ERROR, data, ex.getMessage()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.se.simu.domain.R; |
| | | import com.se.simu.service.SedbService; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ä»»å¡ç®¡ç |
| | | * |
| | | * @author WWW |
| | | * @date 2024-09-13 |
| | | */ |
| | | @Api(tags = "ä»»å¡ç®¡ç") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/task") |
| | | @SuppressWarnings("ALL") |
| | | public class TaskController extends BaseController { |
| | | @Resource |
| | | SedbService sedbService; |
| | | |
| | | @ApiOperation(value = "å建任å¡") |
| | | @PostMapping(value = "/createTask", produces = "application/json; charset=UTF-8") |
| | | public R<Object> createTask() { |
| | | try { |
| | | String rs = sedbService.test(); |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åä»»å¡") |
| | | @GetMapping("/getTask") |
| | | public R<Object> getTask(@ApiParam("ä»»å¡è§å¾ç±»") Object vo) { |
| | | try { |
| | | // |
| | | |
| | | return success(null, 0); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤ä»»å¡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "ids", value = "ä»»å¡ID", dataType = "Integer", paramType = "query", allowMultiple = true, example = "2") |
| | | }) |
| | | @GetMapping(value = "/delTask") |
| | | public R<Object> delTask(@RequestParam List<Integer> ids) { |
| | | try { |
| | | // |
| | | |
| | | return success(0); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.se.simu.helper.WebHelper; |
| | | import com.se.simu.service.SedbService; |
| | | import com.se.simu.service.WaterService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * å
æ¶æ§å¶å¨ |
| | | * å
æ¶ç®¡ç |
| | | * |
| | | * @author WWW |
| | | * @date 2024-07-16 |
| | | */ |
| | | @Api(tags = "å
æ¶æ§å¶å¨") |
| | | @Api(tags = "å
æ¶ç®¡ç") |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/waterlogging") |
| | | public class WaterController { |
| | | @Resource |
| | | SedbService sedbService; |
| | | |
| | | @Resource |
| | | WaterService waterService; |
| | | |
| | |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | @ApiOperation(value = "* æµè¯ *") |
| | | @GetMapping("/test") |
| | | public Object test() { |
| | | try { |
| | | return sedbService.test(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return ex.getMessage(); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.se.simu.domain; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.http.HttpStatus; |
| | | |
| | | /** |
| | | * ååºè§å¾ç±» |
| | | * |
| | | * @author WWW |
| | | * @date 2024-07-30 |
| | | */ |
| | | @SuppressWarnings("ALL") |
| | | public class R<T> { |
| | | @ApiModelProperty("ç¶æç ï¼200-æ£å¸¸ï¼400-请æ±é误ï¼500-æå¡å¨é误") |
| | | private int code; |
| | | |
| | | @ApiModelProperty("æ¶æ¯") |
| | | private String msg; |
| | | |
| | | @ApiModelProperty("è¡æ°") |
| | | private long count; |
| | | |
| | | @ApiModelProperty("æ°æ®") |
| | | private T data; |
| | | |
| | | @ApiModelProperty("æ¶é´") |
| | | private long time; |
| | | |
| | | public R() { |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public R(HttpStatus code, T data) { |
| | | this.data = data; |
| | | this.code = code.value(); |
| | | this.time = System.currentTimeMillis(); |
| | | this.msg = this.code == 200 ? "æå" : "失败"; |
| | | } |
| | | |
| | | public R(HttpStatus code, T data, String msg) { |
| | | this.msg = msg; |
| | | this.data = data; |
| | | this.code = code.value(); |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public R(HttpStatus code, T data, long count) { |
| | | this.count = count; |
| | | this.data = data; |
| | | this.code = code.value(); |
| | | this.time = System.currentTimeMillis(); |
| | | this.msg = this.code == 200 ? "æå" : "失败"; |
| | | } |
| | | |
| | | public R(HttpStatus code, T data, long count, String msg) { |
| | | this.msg = msg; |
| | | this.data = data; |
| | | this.count = count; |
| | | this.code = code.value(); |
| | | this.time = System.currentTimeMillis(); |
| | | } |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(int code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public long getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(long count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public T getData() { |
| | | return data; |
| | | } |
| | | |
| | | public void setData(T data) { |
| | | this.data = data; |
| | | } |
| | | |
| | | public long getTime() { |
| | | return time; |
| | | } |
| | | |
| | | public void setTime(long time) { |
| | | this.time = time; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public int getCount(String token, SeDb db, SeLayer layer) { |
| | | Map<String, Object> map = new HashMap<>(4); |
| | | Map<String, Object> map = new HashMap<>(6); |
| | | map.put("token", token); |
| | | map.put("dbid", db.getDbid()); |
| | | map.put("bbox", db.getBbox()); |
| | | map.put("layerid", layer.getId()); |
| | | map.put("returnCountOnly", true); |
| | | map.put("inSR", 4326); |
| | | |
| | | JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class); |
| | | if (null == obj || 200 != obj.getInt("code")) return 0; |
| | |
| | | } |
| | | |
| | | public JSONArray query(String token, SeDb db, SeLayer layer, int start, int count) { |
| | | Map<String, Object> map = new HashMap<>(8); |
| | | Map<String, Object> map = new HashMap<>(9); |
| | | map.put("token", token); |
| | | map.put("start", start); |
| | | map.put("count", count); |
| | |
| | | map.put("containCount", false); |
| | | map.put("layerid", layer.getId()); |
| | | map.put("querytype", layer.getQueryType()); |
| | | map.put("inSR", 4326); |
| | | |
| | | JSONObject obj = restTemplate.postForObject(host + "geo-service/entitydbdata/layer/query", map, JSONObject.class); |
| | | if (null == obj || 200 != obj.getInt("code")) return null; |
| | | |
| | | JSONObject data = obj.getJSONObject("data"); |
| | | |
| | | return data.getJSONArray("items"); |
| | | return data.getJSONArray("features"); |
| | | } |
| | | } |