diff --git a/service/tasks.py b/service/tasks.py index bf0c696..a2b088d 100644 --- a/service/tasks.py +++ b/service/tasks.py @@ -146,7 +146,8 @@ def raschet(table_name='service_placementpoint', need_time=True, task_name=STATU target_feature_coords = np.array(target_feature_coords) pts_inf['target_dist'] = pts_inf.apply( - lambda x: ((sorted(distance.cdist([[x['geometry'].x, x['geometry'].y]], target_feature_coords)[0])[0])), + lambda x: ((sorted(distance.cdist([[x['geometry'].x, x['geometry'].y]], target_feature_coords)[0])[1]) if ((x.status == 'Working') or (x.status == 'Installation')) else + (sorted(distance.cdist([[x['geometry'].x, x['geometry'].y]], target_feature_coords)[0])[0])), axis=1, ) pts_inf.loc[pts_inf.target_dist > 700, 'target_dist'] = 700 @@ -157,6 +158,7 @@ def raschet(table_name='service_placementpoint', need_time=True, task_name=STATU pts_inf = pts_inf.drop(columns=['target_post_cnt']) pts_inf = pts_inf.join(target_post.set_index('id'), on='id') pts_inf['target_post_cnt'] = pts_inf['target_post_cnt'].fillna(0) + pts_inf['target_post_cnt'] = pts_inf.apply(lambda x: ((x.target_post_cnt - 1) if ((x.status == 'Working') or (x.status == 'Installation')) else x.target_post_cnt), axis=1) pts_inf['age_day_init'] = pts_inf['age_day'] pts_inf['age_day'] = 240 X_inf = pts_inf[feats] @@ -519,4 +521,4 @@ def load_data(obj_id: int): def import_task(file_id): PointService().start_mathing(file_id) PointService().make_enrichment() - raschet('service_preplacementpoint', need_time=False, task_name=STATUS_TASK_NAME_IMPORT) \ No newline at end of file + raschet('service_preplacementpoint', need_time=False, task_name=STATUS_TASK_NAME_IMPORT)