
from BaseDataMaintenance.dataSource.source import getConnect_ots,is_internal
from BaseDataMaintenance.common.multiThread import MultiThreadHandler
from BaseDataMaintenance.common.Utils import *
from BaseDataMaintenance.model.ots.document import *
from BaseDataMaintenance.model.ots.document_extract2 import *
from tablestore import *
from apscheduler.schedulers.blocking import BlockingScheduler
import requests
from queue import Queue
# from multiprocessing import Queue


def rollbackStatus(docids,ots_client=None):
    if ots_client is None:
        ots_client = getConnect_ots()
    for docid in docids:
        partitionkey = docid%500+1
        _dict = {document_extract2_partitionkey:partitionkey,
                 document_extract2_docid:docid,
                 document_extract2_save:1,
                 document_extract2_already_storage:1,
                 document_extract2_status:69}
        _extract2 = Document_extract2(_dict)
        _extract2.update_row(ots_client)
        log("process %d done"%docid)

def rollbackdocuments():
    import pandas as pd
    # df = pd.read_csv("select___from_bxkc_delete_document_log_w.csv")
    df = pd.read_excel("批量恢复公告.xlsx")
    rollbackStatus([int(a) for a in df["docid"]])

from BaseDataMaintenance.model.ots.document_tmp import *
def setDocumentTmpStatus(list_docid,status=1):

    ots_client = getConnect_ots()
    for docid in list_docid:
        partitionkey = int(docid)%500+1
        _dict = {document_tmp_partitionkey:partitionkey,
                 document_tmp_docid:int(docid),
                 document_tmp_status:status}
        dtmp = Document_tmp(_dict)
        dtmp.update_row(ots_client)
        log("process %d done"%docid)

if __name__ == '__main__':
    # start_eas_extract
    # rollbackStatus([228977528])
    # rollbackdocuments()
    setDocumentTmpStatus([234925191])


