Compare commits

..

No commits in common. "9beacb963cf87b72f365ffdf4e1c787edb7d8d22" and "a811302b1b57e01b04f43e1a9efc7b3b0a1017e2" have entirely different histories.

13 changed files with 29 additions and 61 deletions

View File

@ -15,7 +15,7 @@ CONNECTION_STRING = (
"SERVER=10.77.77.10;"
"DATABASE=GINSENG;"
"UID=supginseng;"
"PWD=Ginseng@;"
"PWD=Iphone2513@;"
"PORT=1433;"
"TrustServerCertificate=yes"
)
@ -427,29 +427,6 @@ def worker_inserir_banco(fila, conn_string, stats, stop_event):
conn.close()
def deletar_dados_existentes(data_venda):
"""Deleta dados existentes para a data especificada antes de inserir novos"""
try:
conn = pyodbc.connect(CONNECTION_STRING)
cursor = conn.cursor()
# Deletar da tabela principal (itens e pagamentos são deletados automaticamente pelo CASCADE)
cursor.execute("DELETE FROM Grgb_sales_receipts WHERE sale_date = ?", data_venda)
deleted_count = cursor.rowcount
conn.commit()
if deleted_count > 0:
print(f" 🗑️ Deletados: {deleted_count} registros existentes")
cursor.close()
conn.close()
return deleted_count
except Exception as e:
print(f" ⚠ Erro ao deletar dados existentes: {e}")
return 0
def processar_dia(data_venda, fila, stats):
"""Processa um dia específico - busca da API e coloca na fila"""
@ -460,12 +437,7 @@ def processar_dia(data_venda, fila, stats):
print(f" {data_venda}: Nenhum registro")
return True # Sucesso, apenas não tem dados
print(f" {data_venda}: {total} registros encontrados na API")
# Deletar dados existentes para esta data antes de inserir os novos
deletar_dados_existentes(data_venda)
print(f" {data_venda}: Buscando dados da API...")
print(f" {data_venda}: {total} registros, buscando...")
# Calcular páginas
paginas = list(range(0, total, PAGE_SIZE))
@ -585,10 +557,9 @@ def processar_periodo(data_inicio_str, data_fim_str):
if __name__ == "__main__":
# Configuração do período - sempre pega o dia anterior (ontem)
ONTEM = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
DATA_INICIO = ONTEM
DATA_FIM = ONTEM
# Configuração do período
DATA_INICIO = "2025-09-24"
DATA_FIM = datetime.now().strftime('%Y-%m-%d') # Hoje
# Permite passar datas como argumentos: python script.py 2025-09-24 2025-12-31
if len(sys.argv) >= 3:

View File

@ -71,7 +71,7 @@ def get_db_connection():
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -39,7 +39,7 @@ DB_CONNECTION_STRING = (
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes;'
'Encrypt=yes'

View File

@ -37,9 +37,9 @@ store_codes = [
"20991", "20992", "20993", "20994", "20995", "20996", "20997", "20998", "20999",
"21000", "21001", "21068", "21277", "21278", "21296", "21375", "21381", "21383",
"21495", "21624", "21647", "22541", "3546", "4560", "5699", "910173", "910291",
"21007", "23665", "23712", "23711", "23702", "23703",
"23713", "23708", "23701", "23709","23475","23156","14668", "24253",
"24254", "24255", "24258", "24257", "24268", "24269", "24293", "23813", "24449", "24450", "24455", "24458", "24454", "24447", "24448", "24451", "24456", "24457", "24453", "24452"
"21007", "23665", "23712", "23705", "23711", "23704", "23707", "23702", "23703",
"23713", "23708", "23706", "23701", "23709","23475","23156","14668", "24253",
"24254", "24255", "24258", "24257", "24268", "24269", "24293", "23813", "24449", "24450", "24455", "24458"
]
# Mapeamento de códigos para nomes de categorias
@ -133,7 +133,7 @@ conn = pyodbc.connect(
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -47,19 +47,19 @@ HEADERS_API = {
# Configurações dos dois grupos de lojas
LOJAS_GRUPO_1 = [
"24268", "24258", "24454", "23702", "24455", "24450", "23665", "24448", "24447",
"23713", "24449", "23156", "24254", "24253", "23813", "20056", "23475", "3546",
"24268", "24258", "23701", "23702", "23705", "23706", "23665", "23709", "23708",
"23713", "23707", "23156", "24254", "24253", "23813", "20056", "23475", "3546",
"21647", "12824", "14617", "4560", "21068", "21277", "21296", "21381", "13427",
"21624", "19103", "14668", "20006", "20057", "20005", "20009", "5699",
"12522", "12817", "12820", "12829", "12818", "12823", "12826", "12828",
"12830", "12838", "20441", "20858", "21007", "910173", "910291", "24455"
"12830", "12838", "20441", "20858", "21007", "910173", "910291"
]
LOJAS_GRUPO_2 = [
"20992", "21383", "24458", "23703", "20986", "24293", "24451", "20994", "23711",
"20992", "21383", "23704", "23703", "20986", "24293", "23712", "20994", "23711",
"24269", "21000", "21001", "21375", "20970", "20989", "22541", "20988", "20993",
"20999", "24255", "24257", "20991", "20969", "20998", "20996", "20997", "20995",
"21495", "20968", "21278", "24458"
"21495", "20968", "21278"
]
@ -291,7 +291,7 @@ def conectar_banco():
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -326,10 +326,7 @@ def main():
from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.key_down(Keys.CONTROL).send_keys('k').key_up(Keys.CONTROL).perform()
# Aguardar a página carregar completamente
print("Aguardando 10 segundos para a página carregar...")
time.sleep(10)
time.sleep(1)
# Apertar TAB 3 vezes
print("Apertando TAB 3 vezes...")
@ -607,7 +604,7 @@ def main():
f'SERVER=10.77.77.10;'
f'DATABASE=GINSENG;'
f'UID=supginseng;'
f'PWD=Ginseng@;'
f'PWD=Iphone2513@;'
f'PORT=1433;'
f'TrustServerCertificate=yes;'
f'Encrypt=yes'

View File

@ -200,7 +200,7 @@ def insert_token_to_db(token):
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -9,7 +9,7 @@ DB_CONNECTION_STRING = (
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -32,7 +32,7 @@ class RGBFiscalInvoicesExtractor:
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes;'
'Encrypt=yes'

View File

@ -14,7 +14,7 @@ DB_CONNECTION_STRING = (
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)

View File

@ -328,7 +328,7 @@ class BoticarioAPI:
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes;'
'Encrypt=yes'
@ -352,7 +352,7 @@ class BoticarioAPI:
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433'
)
@ -1174,7 +1174,7 @@ def get_bearer_token_from_database():
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes;'
'Encrypt=yes'
@ -1211,7 +1211,7 @@ def get_bearer_token_from_database():
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433'
)

View File

@ -19,7 +19,7 @@ class RGBTokenClient:
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes;'
'Encrypt=yes'

View File

@ -277,7 +277,7 @@ def get_db_connection():
'SERVER=10.77.77.10;'
'DATABASE=GINSENG;'
'UID=supginseng;'
'PWD=Ginseng@;'
'PWD=Iphone2513@;'
'PORT=1433;'
'TrustServerCertificate=yes'
)