| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.ogr.Geometry; |
| | | import org.gdal.ogr.ogr; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | if (null == data) return fail("data数据格式(JSON)不正确"); |
| | | if (StringUtils.isEmpty(simu.getGeom())) return fail("geom字符串不是WKT格式"); |
| | | |
| | | Geometry geom = Geometry.CreateFromWkt(simu.getGeom()); |
| | | if (!(geom.GetGeometryType() == ogr.wkbMultiPolygon || geom.GetGeometryType() == ogr.wkbPolygon)) |
| | | return fail("geom对象不是多边形"); |
| | | |
| | | int rows = simuService.insert(simu); |
| | | if (rows > 0 && (null == data.getRainfalls() || data.getRainfalls().size() < 2)) { |
| | | resolveService.createRainfall(simu); |
| | | simuService.updateById(simu); |
| | | } |
| | | |
| | | return success(rows); |
| | | } catch (Exception ex) { |
| | |
| | | @PutMapping(value = "/updateById", produces = "application/json; charset=UTF-8") |
| | | public R<Object> updateById(@RequestBody Simu simu) { |
| | | try { |
| | | if (StringUtils.isEmpty(simu.getData())) return fail("data为空"); |
| | | |
| | | SimuData data = JSON.parseObject(simu.getData(), SimuData.class); |
| | | if (null == data) return fail("data数据格式(JSON)不正确"); |
| | | if (StringUtils.isEmpty(simu.getGeom())) return fail("geom字符串不是WKT格式"); |
| | | |
| | | Geometry geom = Geometry.CreateFromWkt(simu.getGeom()); |
| | | if (!(geom.GetGeometryType() == ogr.wkbMultiPolygon || geom.GetGeometryType() == ogr.wkbPolygon)) |
| | | return fail("geom对象不是多边形"); |
| | | |
| | | if (null == data.getRainfalls() || data.getRainfalls().size() < 2) resolveService.createRainfall(simu); |
| | | |
| | | return success(simuService.updateById(simu)); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |