|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.modules.item.controller; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.elink.esua.epdc.commons.tools.annotation.MaskResponse; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
@ -27,6 +28,10 @@ import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|
|
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.elink.esua.epdc.dto.GEOPolygon; |
|
|
|
import com.elink.esua.epdc.dto.LocalDTO; |
|
|
|
import com.elink.esua.epdc.dto.Poly; |
|
|
|
import com.elink.esua.epdc.dto.PolygonsDTO; |
|
|
|
import com.elink.esua.epdc.dto.events.EpdcEventsCommentsDTO; |
|
|
|
import com.elink.esua.epdc.dto.events.form.EventDeleteCommentsFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.form.KpiMetaDataOfEventsFormDTO; |
|
|
@ -42,12 +47,21 @@ import com.elink.esua.epdc.modules.item.excel.StayItemExcel; |
|
|
|
import com.elink.esua.epdc.modules.item.redis.ItemAutoProcessRedis; |
|
|
|
import com.elink.esua.epdc.modules.item.service.ItemService; |
|
|
|
import com.elink.esua.epdc.modules.item.service.ItemTimeoutService; |
|
|
|
import com.mongodb.client.model.geojson.MultiPolygon; |
|
|
|
import com.mongodb.client.model.geojson.Polygon; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import net.coobird.thumbnailator.geometry.Coordinate; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.geo.Point; |
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate; |
|
|
|
import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
|
|
|
import org.springframework.data.mongodb.core.geo.GeoJsonPolygon; |
|
|
|
import org.springframework.data.mongodb.core.query.Criteria; |
|
|
|
import org.springframework.data.mongodb.core.query.Query; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -89,14 +103,106 @@ public class ItemController { |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("test/test") |
|
|
|
public Result test() { |
|
|
|
// 保存对象到mongodb
|
|
|
|
ItemPendingHandleDTO user = new ItemPendingHandleDTO(); |
|
|
|
user.setId("1123123"); |
|
|
|
mongoTemplate.save(user); |
|
|
|
return new Result(); |
|
|
|
public List<JSONObject> test() { |
|
|
|
|
|
|
|
|
|
|
|
// mongoTemplate.save(loc);
|
|
|
|
// String[] polygonPointArr=new String[]{"113.314882, 23.163055","113.355845, 23.167042","113.370289, 23.149564","113.356779, 23.129758","113.338238, 23.13913","113.330979, 23.124706","113.313588, 23.140858","113.323865, 23.158204","113.314882, 23.163055"};
|
|
|
|
|
|
|
|
LocalDTO.LocDTO test2 =test2(); |
|
|
|
|
|
|
|
String jsonObject = JSON.toJSONString(test2); |
|
|
|
Query query = new Query(); |
|
|
|
PolygonsDTO geoPolygon = JSONObject.parseObject(jsonObject, PolygonsDTO.class); |
|
|
|
List<Point> points = new ArrayList<>(); |
|
|
|
List<List<List<Double>>> coordinates = geoPolygon.getCoordinates(); |
|
|
|
List<List<Double>> coordinate = coordinates.get(0); |
|
|
|
for (List<Double> doubles : coordinate) { |
|
|
|
Point point = new Point(doubles.get(0), doubles.get(1)); |
|
|
|
points.add(point); |
|
|
|
} |
|
|
|
GeoJsonPolygon geoJsonPolygon = new GeoJsonPolygon(points); |
|
|
|
query.addCriteria(Criteria.where("loc").intersects(geoJsonPolygon)); |
|
|
|
List<JSONObject> list = mongoTemplate.find(query, JSONObject.class, "polygonCol"); |
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private LocalDTO.LocDTO test2 (){ |
|
|
|
// 保存对象到mongodb
|
|
|
|
LocalDTO loc = new LocalDTO(); |
|
|
|
|
|
|
|
loc.setName("1123123"); |
|
|
|
LocalDTO.LocDTO locDTO = new LocalDTO.LocDTO(); |
|
|
|
locDTO.setType("Polygon"); |
|
|
|
|
|
|
|
List<List<List<Integer>>> a = new ArrayList<>(); |
|
|
|
List<List<Integer>> b = new ArrayList<>(); |
|
|
|
List<Integer> c = new ArrayList<>(); |
|
|
|
c.add(2); |
|
|
|
c.add(2); |
|
|
|
List<Integer> d = new ArrayList<>(); |
|
|
|
d.add(2); |
|
|
|
d.add(4); |
|
|
|
List<Integer> e = new ArrayList<>(); |
|
|
|
e.add(5); |
|
|
|
e.add(1); |
|
|
|
List<Integer> f = new ArrayList<>(); |
|
|
|
f.add(2); |
|
|
|
f.add(2); |
|
|
|
b.add(c); |
|
|
|
b.add(d); |
|
|
|
b.add(e); |
|
|
|
b.add(f); |
|
|
|
a.add(b); |
|
|
|
locDTO.setCoordinates(a); |
|
|
|
|
|
|
|
|
|
|
|
loc.setLoc(locDTO); |
|
|
|
return locDTO; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("test/test4") |
|
|
|
public List<Poly> test4() { |
|
|
|
Poly poly =new Poly(); |
|
|
|
List<Point> points = new ArrayList<>(); |
|
|
|
Point a1 = new Point(113.314882,23.163055); |
|
|
|
Point a2 = new Point(113.355845,23.167042); |
|
|
|
Point a3 = new Point(113.370289, 23.149564); |
|
|
|
Point a4 = new Point(113.356779,23.129758); |
|
|
|
Point a5 = new Point(113.338238,23.13913); |
|
|
|
Point a6 = new Point(113.330979,23.124706); |
|
|
|
Point a7 = new Point(113.313588,23.140858); |
|
|
|
Point a8 = new Point(113.323865,23.158204); |
|
|
|
Point a9 = new Point(113.314882,23.163055); |
|
|
|
points.add(a1); |
|
|
|
points.add(a2); |
|
|
|
points.add(a3); |
|
|
|
points.add(a4); |
|
|
|
points.add(a5); |
|
|
|
points.add(a6); |
|
|
|
points.add(a7); |
|
|
|
points.add(a8); |
|
|
|
points.add(a9); |
|
|
|
|
|
|
|
GeoJsonPolygon geoJsonPolygon = new GeoJsonPolygon(points); |
|
|
|
poly.setPolygons(geoJsonPolygon); |
|
|
|
mongoTemplate.save(poly,"polygons"); |
|
|
|
|
|
|
|
|
|
|
|
List<Poly> dbList = mongoTemplate.findAll(Poly.class,"polygons"); |
|
|
|
return dbList; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("test/test3") |
|
|
|
public List<Poly> test3() { |
|
|
|
Query query = new Query(Criteria.where("coordinates"). |
|
|
|
intersects(new GeoJsonPoint(113.330908, 23.155678))); |
|
|
|
List<Poly> dbList = mongoTemplate.find(query, Poly.class,"polygons"); |
|
|
|
return dbList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 初审项目列表 |
|
|
|
* |
|
|
|