import random
import string
from datetime import datetime

import pyperclip

import base64
import json

from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5
from Crypto.PublicKey import RSA
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

def _encrpt(string, public_key):
    rsakey = RSA.importKey(public_key)  # 读取公钥
    cipher = Cipher_pksc1_v1_5.new(rsakey)
    # 因为encryptor.encrypt方法其内部就实现了加密再次Base64加密的过程,所以这里实际是通过下面的1和2完成了JSEncrypt的加密方法
    encrypt_text = cipher.encrypt(string.encode())  # 1.对账号密码组成的字符串加密
    cipher_text_tmp = base64.b64encode(encrypt_text)  # 2.对加密后的字符串base64加密
    return cipher_text_tmp.decode()


def gen_body(pwd, public_key=None):
    '''根据账号密码生成请求的body然后调用_encrpt方法加密'''
    key = '-----BEGIN PUBLIC KEY-----\n' + public_key + '\n-----END PUBLIC KEY-----'
    encrypt_res = _encrpt(pwd, key)
    return encrypt_res


# def public_key():


class Walle:
    def __init__(self, Cookies=None):
        self.Cookies = Cookies
        self.username = '18358332149'
        self.password = '123456'

    def my_decorator(func):
        def wrapper(self, *args, **kwargs):
            try:
                rs = func(self, *args, **kwargs)
                # print(rs)
                if rs["message"] == 'core.security.login.unauthorized':
                    self.login()
                    return func(self, *args, **kwargs)
                else:
                    return rs
            except Exception as e:
                print(e)
                return rs

        return wrapper

    def login(self, username=None, password=None):
        if username is None:
            username = self.username
            password = self.password
        public_key_str = self.ipublic_key()
        cookies = {
            'locale': 'zh-CN',
        }

        headers = {
            'Accept': '*/*',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            # 'Cookie': 'locale=zh-CN',
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'SECURITY-RSA-KEY': public_key_str,
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
        }

        params = ''

        pwd = gen_body(password, public_key_str)
        print(pwd)
        data = {
            'id': username,
            'password': pwd,
        }

        response = requests.post(
            'http://192.168.30.131:8090/core/module/sys/login',
            params=params,
            cookies=cookies,
            headers=headers,
            data=data,
            verify=False,
        )
        print(response.text)
        if 'Set-Cookie' in response.headers.keys():
            self.Cookies = response.headers['Set-Cookie']
            return self.Cookies
        else:
            return None

    @my_decorator
    def isearch_info(self, qf):
        """
                获取某单号信息
                :param companyId_SEQ: 公司id companyId_SEQ='819656806245760'
                :param folderNo: '23JF0328112~23JF0328115'
                :return: json
                """
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'companyId_SEQ': '819656806245760',
                    'ext$': {},
                },
                'n': 1,
                's': 1000,
                'qf': qf,
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/folders/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )
        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_info_using_folderNo(self, folderNo, companyId_SEQ='819656806245760'):
        """
        获取某单号信息
        :param companyId_SEQ: 公司id companyId_SEQ='819656806245760'
        :param folderNo: '23JF0328112~23JF0328115'
        :return: json
        """
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'companyId_SEQ': companyId_SEQ,
                    'ext$': {},
                },
                'n': 1,
                's': 1000,
                'qf': {
                    'lcFolderNo_CISC': folderNo,
                },
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/folders/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )
        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_info_using_ordNo(self, ordNo):
        """
        合同查询 样品编号
        :param ordNo:23K0329003~23K0329004
        :return:
        """
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'createdByOrgId_SC': '819656806245760',
                    'retestFlag_SEQ': '0',
                    'qcCategoryId_SEQ': 0,
                    'ordno_SC': ordNo,
                },
                'n': 1,
                's': 1000,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/orders/correlation-order/queries',

            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_info_using_folderId(self, folderId):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'folderId_SEQ': folderId,
                    'cancellation_filter': '1',
                    'qcCategoryId_EQ': 0,
                    'singlejudgment_filter': '1',
                    'retestFlag_IN': '0,1',
                },
                'n': -1,
                's': 1000,
                'qf': {},
                'o': [
                    {
                        "NLSSORT(ordno, 'NLS_SORT = SCHINESE_PINYIN_M')": 'asc',
                    },
                ],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/client-folders/orders/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_info_using_unitname(self, unitname):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'companyId_SEQ': '819656806245760',
                    'reportEdit_filter': '1',
                    'ext$': {},
                },
                'n': 1,
                's': 1000,
                'qf': {
                    'clientName_CISC': unitname,
                },
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/folders/report/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )
        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_T_LIMS_ORDERTASK(self, id_):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        params = {
            'table': 'T_LIMS_ORDERTASK',
            'id': id_,
        }

        json_data = {
            'p': {
                'f': {},
                'n': -1,
                's': 1000,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/core/module/sys/bpmn-comments/queries',
            params=params,
            headers=headers,
            json=json_data,
            verify=False,
        )
        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_testinfo_using_ordId(self, ordId):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'orderId_EQ': ordId,
                },
                'n': -1,
                's': 1000,
                'qf': {},
                'o': [
                    {
                        "NLSSORT(runId, 'NLS_SORT = SCHINESE_PINYIN_M')": 'asc',
                    },
                ],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/client-folders/order-task-item/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def isearch_test_using_ordId(self, ordId):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'orderId_EQ': ordId,
                    'repeatNo_EQ': '1',
                    'reportShow_IN': '1,2,3,4',
                    'subItem_filter': '1',
                    'relatedaddflag_SEQ': '0',
                    'itemtype_zs': '1',
                },
                'n': 1,
                's': 1000,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/client-folders/order-task-result/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @staticmethod
    def ipublic_key():
        cookies = {
            'locale': 'zh-CN',
        }

        headers = {
            'Accept': 'text/plain, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            # 'Cookie': 'locale=zh-CN',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
        }

        response = requests.get('http://192.168.30.131:8090/open/security/public-key', cookies=cookies, headers=headers,
                                verify=False)

        return response.text

    @staticmethod
    def print_json(json_data):
        json_str = json.dumps(json_data, ensure_ascii=False)
        print(json_str)
        pyperclip.copy(json_str)

    @my_decorator
    def correlation(self, nfssiOrderId_SC):
        from datetime import datetime, timedelta

        # 获取当前日期
        current_date = datetime.now().date()

        # 计算往前15天的日期
        past_date = (current_date - timedelta(days=60)).strftime('%Y-%m-%d')

        # 计算往后15天的日期
        future_date = (current_date + timedelta(days=15)).strftime('%Y-%m-%d')

        # 打印结果
        print(f"Current date: {current_date.strftime('%Y-%m-%d')}")
        print(f"Date 15 days ago: {past_date}")
        print(f"Date 15 days from now: {future_date}")

        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'cancellation_filter': '1',
                    'companyId_SEQ': '819656806245760',
                    'foldercreatedtime_DGOE': past_date,
                    'foldercreatedtime_DLOE': future_date,
                    'retestFlag_IN': '0,1',
                    'qcCategoryId_SEQ': 0,
                    'nfssiOrderId_SC': nfssiOrderId_SC,
                },
                'n': 1,
                's': 100,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/orders/correlation-order/queries',

            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data

    @my_decorator
    def correlation_long(self, nfssiOrderId_SC):
        from datetime import datetime, timedelta

        # 获取当前日期
        current_date = datetime.now().date()

        # 计算往前15天的日期
        past_date = (current_date - timedelta(days=360)).strftime('%Y-%m-%d')

        # 计算往后15天的日期
        future_date = (current_date + timedelta(days=15)).strftime('%Y-%m-%d')

        # 打印结果
        print(f"Current date: {current_date.strftime('%Y-%m-%d')}")
        print(f"Date 15 days ago: {past_date}")
        print(f"Date 15 days from now: {future_date}")

        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Pragma': 'no-cache',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'cancellation_filter': '1',
                    'companyId_SEQ': '819656806245760',
                    'foldercreatedtime_DGOE': past_date,
                    'foldercreatedtime_DLOE': future_date,
                    'retestFlag_IN': '0,1',
                    'qcCategoryId_SEQ': 0,
                    'nfssiOrderId_SC': nfssiOrderId_SC,
                },
                'n': 1,
                's': 100,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/orders/correlation-order/queries',

            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data


    def upload_to_id(self, fileName, file_path, id):

        files = {
            'file': (fileName, open(file_path, 'rb'), 'image/jpeg'),
            'targetId': (None, 'T_LIMS_ORDER${}'.format(id)),
            'name': (None, fileName),
            'bizCategory': (None, 'order'),
        }
        # files = {
        #     'file': (fileName, open(file_path, 'rb'), 'image/jpeg'),
        #     'targetId': (None, 'T_LIMS_RUN$240502814'),
        #     'name': (None, 'test.jpg'),
        #     'bizCategory': (None, 'fileAcq'),
        # }

        boundary = '----WebKitFormBoundary' + ''.join(random.sample(string.ascii_letters + string.digits, 16))
        m = MultipartEncoder(fields=files, boundary=boundary)
        headers = {
            'Accept': '*/*',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Connection': 'keep-alive',
            'Content-Type': m.content_type,
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
        }

        response = requests.post(
            'http://192.168.30.131:8090/core/module/item/files',
            headers=headers,
            data=m,
            verify=False,
        )
        print(response.text)
        return response.text

    def logout(self):

        headers = {
            'Accept': 'text/plain, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Connection': 'keep-alive',
            # 'Content-Length': '0',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        response = requests.post('http://192.168.30.131:8090/core/module/sys/logout', headers=headers,
                                 verify=False)

    def search_id(self,fid):
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'p': {
                'f': {
                    'targetId': 'T_LIMS_ORDER${}'.format(fid),
                    'bizId': fid,
                },
                'n': -1,
                's': 100,
                'qf': {},
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/core/module/item/files/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data
    def delete_files(self,rs):
        headers = {
            'Accept': 'text/plain, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Cookie': self.Cookies,
            'Origin': 'http://192.168.30.131:8090',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',
        }

        json_data = {
            'b': [
                '',
                [
                    rs,
                ],
            ],
        }

        response = requests.delete(
            'http://192.168.30.131:8090/core/module/item/files',
            headers=headers,
            json=json_data,
            verify=False,
        )


    def _client_folders(self,n=1,s=100,createdTime_TGOE='2025-02-01',createdTime_TLOE='2025-04-18 23:59:59',clientName_CISC='市场监督'):
        # 临时使用
        headers = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Accept-Language': 'zh-CN,zh;q=0.9',
            'Connection': 'keep-alive',
            'Content-Type': 'application/json',
            'Origin': 'http://192.168.30.131:8090',
            'Referer': 'http://192.168.30.131:8090/',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
            'X-Requested-With': 'XMLHttpRequest',
            'locale': 'zh-cn',

            'Cookie': self.Cookies,
        }

        json_data = {
            'p': {
                'f': {
                    'folderType_IN': 'LIMS',
                    'companyId_SEQ': '819656806245760',
                    'preFlag_SEQ': '0',
                    'processStatus_SB': 'approve',
                    'createdTime_TGOE':createdTime_TGOE,
                    'createdTime_TLOE': createdTime_TLOE,
                },
                'n': n,
                's': s,
                'qf': {
                    'clientName_CISC': clientName_CISC,
                },
                'o': [],
            },
        }

        response = requests.post(
            'http://192.168.30.131:8090/secure/lims/module/sp/client-folders/queries',
            headers=headers,
            json=json_data,
            verify=False,
        )

        json_data = response.json()
        self.print_json(json_data)
        return json_data
if __name__ == '__main__':
    # import pyperclip
    wl = Walle()
    wl.login()
    # rs1 = wl.isearch_info({"lcFolderNo_CISC": "1233"})
    # rs1 = wl.correlation('SBP25310000316430046ZX')
    # # date_string = rs1['rows'][0]['ext$']['accepttime']
    # # print(date_string)
    rs1 = wl.search_id('1601788392864864')["total"]
    print(rs1)
    # for r in rs1['rows']:
    #     wl.delete_files(r)

    # wl.upload_to_id('抽样单电子版.jpg', '抽样单电子版.jpg', '1410104990009536')
    wl.logout()