count_pvz_for_placementpoint See merge request spatial/postamates!71dev
commit
5a682af769
@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"model": "service.post_and_pvzcategory",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"name": "ПВЗ",
|
||||
"image": "",
|
||||
"visible": true,
|
||||
"inlude_in_ml": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "service.post_and_pvzcategory",
|
||||
"pk": 2,
|
||||
"fields": {
|
||||
"name": "Постамат",
|
||||
"image": "",
|
||||
"visible": true,
|
||||
"inlude_in_ml": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,25 @@
|
||||
from django.contrib.gis.measure import Distance
|
||||
from service import models
|
||||
from postamates.settings import DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS
|
||||
|
||||
|
||||
class LayerService:
|
||||
def count_post_pvz_for_placementpoint(self, obj):
|
||||
points = models.PlacementPoint.objects.filter(geometry__distance_lt=(obj.wkt, Distance(
|
||||
m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS))).all()
|
||||
for point in points:
|
||||
LayerService.count_post_pvz(point)
|
||||
|
||||
@staticmethod
|
||||
def get_post_and_pvz_categroies():
|
||||
return models.Post_and_pvzCategory.objects.all(), models.Post_and_pvzGroup.objects.all()
|
||||
|
||||
@staticmethod
|
||||
def count_post_pvz(point):
|
||||
point.rivals_post_cnt = models.Post_and_pvz.objects.filter(
|
||||
category__name="Постамат", inlude_in_ml=True,
|
||||
wkt__distance_lt=(point.geometry, Distance(m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS))).count()
|
||||
point.rivals_pvz_cnt = models.Post_and_pvz.objects.filter(
|
||||
category__name="ПВЗ", inlude_in_ml=True,
|
||||
wkt__distance_lt=(point.geometry, Distance(m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS))).count()
|
||||
point.save()
|
||||
Loading…
Reference in new issue