parent
							
								
									938d42dc80
								
							
						
					
					
						commit
						3cb37d04d0
					
				
				 5 changed files with 159 additions and 26 deletions
			
			
		@ -1,22 +0,0 @@ | 
				
			||||
from blue_forecast import dict_sort, dict_rate | 
				
			||||
 | 
				
			||||
d1 = {"01": 17, "09": 17, "03": 16, "10": 16, "14": 15, "15": 15, "11": 14, "02": 14, "07": 14, "06": 12, "12": 11, "08": 10, "16": 10, "05": 9, "13": 8, "04": 8} | 
				
			||||
d2 = {"01": 43, "09": 42, "04": 39, "15": 38, "06": 37, "08": 36, "10": 34, "16": 32, "11": 32, "05": 31, "12": 31, "03": 30, "02": 29, "14": 28, "07": 27, "13": 26} | 
				
			||||
d3 = {"15": 84, "10": 72, "06": 71, "08": 71, "16": 71, "01": 71, "05": 71, "07": 69, "11": 65, "09": 64, "13": 62, "14": 61, "04": 59, "02": 57, "12": 55, "03": 48} | 
				
			||||
d4 = {"15": 120, "11": 118, "16": 113, "05": 109, "08": 103, "09": 103, "07": 103, "12": 103, "06": 102, "14": 102, "04": 100, "02": 99, "10": 95, "03": 95, "13": 94, "01": 93} | 
				
			||||
d5 = {"15": 186, "16": 179, "11": 167, "06": 164, "07": 159, "13": 157, "12": 156, "14": 155, "02": 155, "03": 153, "05": 151, "09": 146, "04": 145, "08": 143, "01": 131, "10": 130} | 
				
			||||
 | 
				
			||||
data_list = [d1, d2, d3, d4, d5] | 
				
			||||
 | 
				
			||||
result = {} | 
				
			||||
 | 
				
			||||
for d in data_list: | 
				
			||||
    for k, v in d.items(): | 
				
			||||
        if k in result.keys(): | 
				
			||||
            result[k] += v | 
				
			||||
        else: | 
				
			||||
            result[k] = v | 
				
			||||
 | 
				
			||||
print("新算法") | 
				
			||||
for k, v in dict_rate(dict_sort(result, 'val', True)).items(): | 
				
			||||
    print(f"{k} - {v}") | 
				
			||||
@ -0,0 +1,71 @@ | 
				
			||||
from blue_forecast import dict_sort, dict_rate | 
				
			||||
import pymysql | 
				
			||||
import json | 
				
			||||
from functools import reduce | 
				
			||||
from pymysql.cursors import DictCursor | 
				
			||||
 | 
				
			||||
db = { | 
				
			||||
    'host': 'home.rogersun.online', | 
				
			||||
    'user': 'root', | 
				
			||||
    'password': 'Sxzgx1209', | 
				
			||||
    'database': 'lottery' | 
				
			||||
} | 
				
			||||
 | 
				
			||||
d1 = {"06": 18, "08": 16, "10": 15, "16": 15, "04": 13, "15": 13, "01": 13, "11": 12, "09": 11, "13": 10, "14": 10, | 
				
			||||
      "05": 10, "12": 10, "03": 8, "07": 7, "02": 6} | 
				
			||||
d2 = {"09": 45, "01": 44, "07": 43, "14": 43, "15": 42, "12": 42, "02": 38, "04": 37, "10": 37, "11": 35, "05": 31, | 
				
			||||
      "16": 31, "03": 29, "08": 28, "06": 28, "13": 24} | 
				
			||||
d3 = {"01": 93, "09": 80, "10": 75, "15": 72, "16": 71, "03": 70, "08": 65, "11": 64, "06": 63, "02": 62, "04": 62, | 
				
			||||
      "14": 61, "12": 61, "05": 61, "07": 55, "13": 55} | 
				
			||||
d4 = {"15": 126, "01": 121, "05": 116, "14": 112, "16": 112, "09": 111, "06": 108, "11": 107, "08": 106, "07": 106, | 
				
			||||
      "10": 106, "04": 103, "13": 97, "02": 96, "12": 96, "03": 83} | 
				
			||||
d5 = {"15": 185, "16": 165, "11": 165, "06": 164, "05": 160, "14": 153, "08": 152, "12": 152, "07": 149, "09": 148, | 
				
			||||
      "10": 147, "02": 145, "01": 144, "13": 142, "04": 141, "03": 131} | 
				
			||||
 | 
				
			||||
data_list = [d1, d2, d3, d4, d5] | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def get_history_date_id(): | 
				
			||||
    conn = pymysql.Connect(**db) | 
				
			||||
    cursor = conn.cursor(DictCursor) | 
				
			||||
    cursor.execute("SELECT dateId FROM lottery.blue_forecast GROUP BY dateId ") | 
				
			||||
    result = cursor.fetchall() | 
				
			||||
    date_id_list = [] | 
				
			||||
    for d in result: | 
				
			||||
        date_id_list.append(d['dateId']) | 
				
			||||
    return sorted(date_id_list, reverse=True)[0:5] | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def get_forecast_blue(_date_id_list): | 
				
			||||
    conn = pymysql.Connect(**db) | 
				
			||||
    cursor = conn.cursor(DictCursor) | 
				
			||||
    n = 1 | 
				
			||||
    _blue_list = [] | 
				
			||||
    for _id in _date_id_list: | 
				
			||||
        cursor.execute("SELECT blue FROM lottery.blue_forecast WHERE dateId = %s AND params = %s", (_id, n)) | 
				
			||||
        r = cursor.fetchone() | 
				
			||||
        _blue = json.loads(r['blue']) | 
				
			||||
        _blue_list.append(_blue) | 
				
			||||
        n += 1 | 
				
			||||
    return _blue_list | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def new_blue_forecast(_blue_list): | 
				
			||||
    result = {} | 
				
			||||
 | 
				
			||||
    for d in _blue_list: | 
				
			||||
        for k, v in d.items(): | 
				
			||||
            if k in result.keys(): | 
				
			||||
                result[k] += v | 
				
			||||
            else: | 
				
			||||
                result[k] = v | 
				
			||||
 | 
				
			||||
    print("新算法") | 
				
			||||
    for k, v in dict_rate(dict_sort(result, 'val', True)).items(): | 
				
			||||
        print(f"{k} - {v}") | 
				
			||||
 | 
				
			||||
 | 
				
			||||
if __name__ == "__main__": | 
				
			||||
    date_id_list = get_history_date_id() | 
				
			||||
    blue_list = get_forecast_blue(date_id_list) | 
				
			||||
    new_blue_forecast(blue_list) | 
				
			||||
@ -0,0 +1,72 @@ | 
				
			||||
import pymysql | 
				
			||||
import json | 
				
			||||
from functools import reduce | 
				
			||||
from pymysql.cursors import DictCursor | 
				
			||||
 | 
				
			||||
db = { | 
				
			||||
    'host': 'home.rogersun.online', | 
				
			||||
    'user': 'root', | 
				
			||||
    'password': 'Sxzgx1209', | 
				
			||||
    'database': 'lottery' | 
				
			||||
} | 
				
			||||
 | 
				
			||||
real_blue = ["01", "04", "09", "10", "20", "33"] | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def get_real_data(): | 
				
			||||
    conn = pymysql.Connect(**db) | 
				
			||||
    cursor = conn.cursor(DictCursor) | 
				
			||||
    cursor.execute("SELECT * FROM lottery.history ORDER BY id DESC LIMIT 1") | 
				
			||||
    history_data = cursor.fetchone() | 
				
			||||
    # print(history_data) | 
				
			||||
    # [{'id': 2979, 'dateId': '2023035', 'openDate': datetime.date(2023, 3, 30), 'red': '["01", "04", "09", "10", "20", "33"]', 'blue': '06'}] | 
				
			||||
    return history_data | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def general_blue_index(_history_data): | 
				
			||||
    conn = pymysql.Connect(**db) | 
				
			||||
    cursor = conn.cursor(DictCursor) | 
				
			||||
    cursor.execute("SELECT * FROM lottery.blue_forecast WHERE dateId = %s", (str(int(_history_data['dateId']) - 1)), ) | 
				
			||||
    history_blue = cursor.fetchall() | 
				
			||||
    # print(history_blue) | 
				
			||||
    for data in history_blue: | 
				
			||||
        n = 1 | 
				
			||||
        for k, v in json.loads(data['blue']).items(): | 
				
			||||
            if k == _history_data['blue']: | 
				
			||||
                real_index = {'real_blue': _history_data['blue'], 'real_index': n} | 
				
			||||
                cursor.execute("UPDATE lottery.blue_forecast SET comment = %s WHERE id = %s", | 
				
			||||
                               (json.dumps(real_index), data['id'])) | 
				
			||||
                break | 
				
			||||
            else: | 
				
			||||
                n += 1 | 
				
			||||
    conn.commit() | 
				
			||||
    cursor.close() | 
				
			||||
 | 
				
			||||
 | 
				
			||||
def general_red_index(_history_data): | 
				
			||||
    conn = pymysql.Connect(**db) | 
				
			||||
    cursor = conn.cursor(DictCursor) | 
				
			||||
    cursor.execute("SELECT * FROM lottery.red_forecast WHERE dateId = %s", (str(int(_history_data['dateId']) - 1)), ) | 
				
			||||
    history_red = cursor.fetchone() | 
				
			||||
    # print(history_red) | 
				
			||||
    real_red = json.loads(_history_data['red']) | 
				
			||||
    real_red_index = [] | 
				
			||||
    n = 1 | 
				
			||||
 | 
				
			||||
    for red, _ in json.loads(history_red['red_rate']).items(): | 
				
			||||
        if red in real_red: | 
				
			||||
            real_red_index.append(n) | 
				
			||||
            n += 1 | 
				
			||||
        else: | 
				
			||||
            n += 1 | 
				
			||||
    # print(_history_data['red'], json.dumps(real_red_index), history_red['id']) | 
				
			||||
    cursor.execute("UPDATE lottery.red_forecast SET real_result = %s, comments = %s WHERE id = %s", | 
				
			||||
                   (_history_data['red'], json.dumps(real_red_index), history_red['id'])) | 
				
			||||
    conn.commit() | 
				
			||||
    cursor.close() | 
				
			||||
 | 
				
			||||
 | 
				
			||||
if __name__ == "__main__": | 
				
			||||
    history = get_real_data() | 
				
			||||
    general_blue_index(history) | 
				
			||||
    general_red_index(history) | 
				
			||||
					Loading…
					
					
				
		Reference in new issue