|
|
|
@ -1,15 +1,18 @@ |
|
|
|
|
from db import * |
|
|
|
|
from blue_forecast import forecast_blue |
|
|
|
|
from red_forecast import red_forecast |
|
|
|
|
import json |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def general_red_index(_real_red, _forecast_data): |
|
|
|
|
index_list = [] |
|
|
|
|
for _red in _forecast_data.keys(): |
|
|
|
|
data_list = list(_forecast_data.keys()) |
|
|
|
|
for _red in data_list: |
|
|
|
|
if _red in _real_red: |
|
|
|
|
index_list.append(_forecast_data.keys().index(_red) + 1) |
|
|
|
|
index_list.append(data_list.index(_red) + 1) |
|
|
|
|
index_group = [0, 0, 0] |
|
|
|
|
for index in index_group: |
|
|
|
|
if index <= 11: |
|
|
|
|
for index in index_list: |
|
|
|
|
if 1 <= index <= 11: |
|
|
|
|
index_group[0] += 1 |
|
|
|
|
elif 11 < index <= 22: |
|
|
|
|
index_group[1] += 1 |
|
|
|
@ -24,6 +27,20 @@ def general_blue_index(_real_blue, _forecast_data): |
|
|
|
|
return list(_forecast_data.keys()).index(_real_blue) + 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def insert_index_group(_date_id, _type, _index_group): |
|
|
|
|
if _date_id not in db_index_get_last_date_id(_type): |
|
|
|
|
_data = { |
|
|
|
|
'dateId': _date_id, |
|
|
|
|
'type': _type, |
|
|
|
|
'index_group': _index_group |
|
|
|
|
} |
|
|
|
|
result = db_index_insert_index_group(_data) |
|
|
|
|
if result > 0: |
|
|
|
|
print(f'插入index_group成功 {_index_group}') |
|
|
|
|
else: |
|
|
|
|
print('插入index_group失败') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_real_data(): |
|
|
|
|
new_history_date_id, old_history_date_id = db_history_get_last_open_id() |
|
|
|
|
blue_date_id = db_blue_get_last_one_open_id() |
|
|
|
@ -40,37 +57,33 @@ def update_real_data(): |
|
|
|
|
history_index_list, history_index_group = general_red_index(real_red, json.loads(data['history'])) |
|
|
|
|
last_index_list, last_index_group = general_red_index(real_red, json.loads(data['last'])) |
|
|
|
|
update_data = { |
|
|
|
|
'real_red': real_red, |
|
|
|
|
'real_red_index_history': history_index_list, |
|
|
|
|
'real_red_index_group_history': history_index_group, |
|
|
|
|
'real_red_index_last': last_index_list, |
|
|
|
|
'real_red_index_group_last': last_index_group |
|
|
|
|
'real_red': json.dumps(real_red), |
|
|
|
|
'real_red_index_history': json.dumps(history_index_list), |
|
|
|
|
'real_red_index_group_history': json.dumps(history_index_group), |
|
|
|
|
'real_red_index_last': json.dumps(last_index_list), |
|
|
|
|
'real_red_index_group_last': json.dumps(last_index_group) |
|
|
|
|
} |
|
|
|
|
db_red_update(_id, red_date_id, update_data) |
|
|
|
|
# 插入 IndexGroup index_group |
|
|
|
|
db_index_insert_index_group({'type': 'history', 'index_group': json.dumps(history_index_group)}) |
|
|
|
|
db_index_insert_index_group({'type': 'last', 'index_group': json.dumps(last_index_group)}) |
|
|
|
|
insert_index_group( |
|
|
|
|
{'dateId': red_date_id, 'type': 'history', 'index_group': json.dumps(history_index_group)}) |
|
|
|
|
insert_index_group({'dateId': red_date_id, 'type': 'last', 'index_group': json.dumps(last_index_group)}) |
|
|
|
|
|
|
|
|
|
if blue_date_id['five'] == old_history_date_id: |
|
|
|
|
# 插入 real_blue, prv_index, post_index, history_index |
|
|
|
|
real_blue = all_data[-1]['blue'] |
|
|
|
|
forecast_blue_data = db_blue_get_data_by_date_id(blue_date_id['five'], 5) |
|
|
|
|
for data in forecast_blue_data: |
|
|
|
|
print(data) |
|
|
|
|
_id = data['id'] |
|
|
|
|
prv_index = general_blue_index(real_blue, json.loads(data['prv'])) |
|
|
|
|
post_index = general_blue_index(real_blue, json.loads(data['post'])) |
|
|
|
|
history_index = general_blue_index(real_blue, json.loads(data['history'])) |
|
|
|
|
print(prv_index) |
|
|
|
|
print(post_index) |
|
|
|
|
print(history_index) |
|
|
|
|
update_data = { |
|
|
|
|
'real_blue': real_blue, |
|
|
|
|
'prv_index': prv_index, |
|
|
|
|
'post_index': post_index, |
|
|
|
|
'history_index': history_index |
|
|
|
|
} |
|
|
|
|
print(update_data) |
|
|
|
|
db_blue_update(blue_date_id['five'], update_data, _id, 5) |
|
|
|
|
|
|
|
|
|
if blue_date_id['three'] == old_history_date_id: |
|
|
|
@ -92,9 +105,11 @@ def update_real_data(): |
|
|
|
|
|
|
|
|
|
# 插入预测数据 |
|
|
|
|
def general_forecast_data(): |
|
|
|
|
pass |
|
|
|
|
forecast_blue() |
|
|
|
|
red_forecast() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
update_real_data() |
|
|
|
|
general_forecast_data() |
|
|
|
|
# update_real_data() |
|
|
|
|
# general_forecast_data() |
|
|
|
|
pass |
|
|
|
|