#coding:utf8
from BaseDataMaintenance.model.ots.BaseModel import BaseModel
from BaseDataMaintenance.common.Utils import *
from BaseDataMaintenance.primarykey.startSnowflake import get_guid
import json
from BaseDataMaintenance.dataSource.source import getConnect_ots
from tablestore import *

from BaseDataMaintenance.maintenance.dataflow import Dataflow_dumplicate

ots_client = getConnect_ots()

stage_priority_dict = {
    "立项阶段": "立项阶段",
    "可研阶段": "可研阶段",
    "环评阶段": "环评阶段",
    "稳评阶段": "环评阶段",
    "咨询阶段": "环评阶段",
    "造价阶段": "环评阶段",
    "设计阶段": "设计阶段",
    "勘察阶段": "设计阶段",
    "EPC总承包":"设计阶段",
    "施工图审": "施工准备",
    "施工许可": "施工准备",
    "施工准备": "施工准备",
    "施工在建": "施工在建",
    "竣工阶段": "竣工阶段"
}

data_flow = Dataflow_dumplicate(start_delete_listener=False)

class proposedBuilding_tmp(BaseModel):

    def __init__(self,_dict):

        for k,v in _dict.items():
            self.setValue(k,v,True)
        self.table_name = "proposedBuilding_tmp"
        self.dict_enterprise = {}
        self.dict_enterprise_contact = {}
        self.dict_document = {}
        self.data_flow = data_flow

    def getPrimary_keys(self):
        return ["uuid"]


    # def getFollows(self,list_group):
    #
    #
    #
    #     dict_stage = {}
    #
    #
    #     #sort
    #     list_group.sort(key=lambda x:x.get("page_time",""))
    #
    #
    #     list_follows = []
    #     #dumplicate
    #     set_stage_page_time = set()
    #     for _group in list_group:
    #         current_stage = _group.get("stage","")
    #         current_pageTime = _group.get("page_time","")
    #         if current_stage=="" or current_pageTime=="":
    #             continue
    #         _key = "%s-%s"%(str(current_stage),str(current_pageTime))
    #         if _key in set_stage_page_time:
    #             continue
    #         list_follows.append(_group)
    #         set_stage_page_time.add(_key)
    #     return list_follows


        # for _group in list_group:
        #     _stage = _group["stage"]
        #     if _stage not in dict_stage:
        #         dict_stage[_stage] = []
        #     dict_stage[_stage].append(_group)
        #
        #
        #
        # LIST_STEGES = ["施工在建","施工准备","环评阶段","设计阶段"]
        # # LIST_STEGES = ["立项","可研","环评","稳评","其他咨询服务","造价","勘察设计","施工图审查","施工许可证","施工准备","施工在建","竣工"]
        # for k,v in dict_stage.items():
        #     v.sort(key=lambda x:x.get("page_time",""),reverse=True)
        # list_follows = []
        # last_stage = ""
        # last_pageTime = ""
        # for _STAGE_i in range(len(LIST_STEGES)):
        #     _STAGE = LIST_STEGES[_STAGE_i]
        #     for _group in dict_stage.get(_STAGE,[]):
        #         current_stage = _group.get("stage","")
        #         current_pageTime = _group.get("page_time","")
        #         if last_stage=="":
        #             last_stage = current_stage
        #             last_pageTime = current_pageTime
        #         if last_stage in LIST_STEGES[:_STAGE_i]:
        #             continue
        #         if current_pageTime>last_pageTime:
        #             continue
        #         last_stage = current_stage
        #         last_pageTime = current_pageTime
        #         list_follows.append(_group)
        # list_follows.reverse()
        # return list_follows


    def getEnterprise(self,enterprise_name,columns):
        _time = time.time()
        if enterprise_name in self.dict_enterprise:
            return self.dict_enterprise[enterprise_name]
        enterprise_dict = self.search(ots_client,"enterprise",[("name",str(enterprise_name))],columns)
        self.dict_enterprise[enterprise_name] = enterprise_dict
        log("search Enterprise %s takes %.2f"%(str(enterprise_name),time.time()-_time))
        return enterprise_dict

    def getEnterprise_contact(self,enterprise_name,limit=2,columns=["enterprise_name","contact_person","phone_no"]):

        _time = time.time()
        if enterprise_name in self.dict_enterprise_contact:
            return self.dict_enterprise_contact[enterprise_name]
        _query = BoolQuery(must_queries=[TermQuery("enterprise_name",enterprise_name),
                                         TermQuery("is_mobile",1)])

        rows,next_token,total_count,is_all_succee = ots_client.search("enterprise_contact","enterprise_contact_index",
                                                                      SearchQuery(_query,sort=Sort(sorters=[FieldSort("score",SortOrder.DESC)]),limit=limit),
                                                                      columns_to_get=ColumnsToGet(columns,ColumnReturnType.SPECIFIED))
        list_data = getRow_ots(rows)
        self.dict_enterprise_contact[enterprise_name] = list_data
        return self.dict_enterprise_contact[enterprise_name]





    def getStage(self,_stage):

        return stage_priority_dict.get(_stage)

    def addContact(self,_contacts,_type,enterprise_name):
        #add contacts from enterprise table

        enterprise_dict = self.getEnterprise(enterprise_name,["province","contacts","address","contacts1","contacts2","contacts3","contacts4","contacts5"])

        enterprise_contact = self.getEnterprise_contact(enterprise_name)
        _time = time.time()
        if enterprise_dict is None:
            enterprise_dict = {}
        cellphone = ""

        _count = 0
        for _contact in enterprise_contact:
            cellphone = _contact.get("phone_no","")
            contact_name = _contact.get("contact_person","")
            _dict_contact = {"address":enterprise_dict.get("address",""),"cellphone":cellphone,
                             "phone":"","company_name":enterprise_name,"contact_name":contact_name,
                             "type":_type,"id":get_guid()}
            _dict_contact = popNoneFromDict(_dict_contact)
            _count += 1
            _contacts.append(_dict_contact)
            if _count>=2:
                break
            log("extract contact %s takes %.2f "%(enterprise_name,time.time()-_time))


    def getContacts(self,ots_client,list_group,set_enterprise,_contacts):


        set_contact = set()

        return_tenderee = ""
        for _group in list_group:
            # add contacts of tenderee
            return_tenderee = _group.get("tenderee","")


        for _group in list_group:
            # add contacts of tenderee
            _tenderee = _group.get("tenderee")
            if _tenderee is not None and _tenderee not in set_enterprise:

                set_enterprise.add(_tenderee)

                enterprise_dict = self.getEnterprise(_tenderee,["province","contacts","address","contacts1","contacts2","contacts3","contacts4","contacts5"])
                _time = time.time()
                if enterprise_dict is None:
                    enterprise_dict = {}
                cellphone = ""
                phone = ""
                if isCellphone(_group.get("tenderee_phone","")):
                    cellphone = _group.get("tenderee_phone","")
                else:
                    phone = _group.get("tenderee_phone","")
                if cellphone!="" or phone!="":
                    _dict_contact = {"address":enterprise_dict.get("address",""),"cellphone":cellphone,"phone":phone,
                                     "company_name":_tenderee,"contact_name":_group.get("tenderee_contact",""),
                                     "type":"业主单位","id":get_guid()}

                    _dict_contact = popNoneFromDict(_dict_contact)
                    _contacts.append(_dict_contact)


                self.addContact(_contacts,"业主单位",_tenderee)


            _agency = _group.get("agency")
            if _agency is not None and _agency!=_tenderee and  _agency not in set_enterprise:

                set_enterprise.add(_agency)
                self.addContact(_contacts,"代理单位",_agency)

            # add contacts of win_tenderee

            _time = time.time()
            _docid = _group.get("docid")
            if _docid is not None:
                _docid = int(_docid)
                document_dict = self.getDocumentWithDocid(_docid,["sub_docs_json","tenderee","tenderee_contact","tenderee_phone","agency","agency_contact","agency_phone"])
            else:
                document_dict = None
            win_tenderer = ""
            log("search document  %s takes %.2f"%(str(_docid),time.time()-_time))

            if document_dict is not None:
                _tenderee = document_dict.get("tenderee","")
                if return_tenderee=="" and  _tenderee!="":
                    enterprise_dict = self.getEnterprise(_tenderee,["province","contacts","address","contacts1","contacts2","contacts3","contacts4","contacts5"])
                    if enterprise_dict is None:
                        enterprise_dict = {}
                    tenderee_contact = document_dict.get("tenderee_contact","")
                    tenderee_phone = document_dict.get("tenderee_phone","")
                    if tenderee_phone!="":
                        cellphone = ""
                        phone = ""
                        if isCellphone(tenderee_phone):
                            cellphone = tenderee_phone
                        else:
                            phone = tenderee_phone
                        _dict_contact = {"address":enterprise_dict.get("address",""),"cellphone":cellphone,"phone":phone,
                                         "company_name":_tenderee,"contact_name":tenderee_contact,
                                         "type":"业主单位","id":get_guid()}
                        _dict_contact = popNoneFromDict(_dict_contact)
                        _contacts.append(_dict_contact)

                _agency = document_dict.get("agency","")
                if _agency!="":
                    enterprise_dict = self.getEnterprise(_agency,["province","contacts","address","contacts1","contacts2","contacts3","contacts4","contacts5"])
                    if enterprise_dict is None:
                        enterprise_dict = {}
                    tenderee_contact = document_dict.get("agency_contact","")
                    tenderee_phone = document_dict.get("agency_phone","")
                    if tenderee_phone!="":
                        cellphone = ""
                        phone = ""
                        if isCellphone(tenderee_phone):
                            cellphone = tenderee_phone
                        else:
                            phone = tenderee_phone
                        _dict_contact = {"address":enterprise_dict.get("address",""),"cellphone":cellphone,"phone":phone,
                                         "company_name":_agency,"contact_name":tenderee_contact,
                                         "type":"代理单位","id":get_guid()}
                        _dict_contact = popNoneFromDict(_dict_contact)
                        _contacts.append(_dict_contact)

                    sub_docs_json = document_dict.get("sub_docs_json",'[{}]')
                    for sub_docs in json.loads(sub_docs_json):
                        if win_tenderer=="":
                            win_tenderer = sub_docs.get("win_tenderer","")

            if win_tenderer!="" and win_tenderer not in set_enterprise:
                set_enterprise.add(win_tenderer)

                self.addContact(_contacts,"%s单位"%(str(_group.get("stage","")).replace("None","").replace("阶段","")),win_tenderer)
        tenderee_count = 0
        list_contact = []
        for _c in _contacts:
            _line = "%s-%s"%(_c.get("cellphone",""),_c.get("phone",""))
            if _c.get("cellphone","")=="" and _c.get("phone","")=="":
                continue
            if _c.get("type","")=="业主单位":
                tenderee_count += 1
            if _line not in set_contact:
                list_contact.append(_c)
            set_contact.add(_line)
        return list_contact,tenderee_count

    def getFollows(self,list_group,_contacts,set_enterprise):
        set_follow = set()
        _version_index = 0
        set_project_uuid = set()
        list_follow = []
        if len(list_group)==0:
            return list_follow
        for _group in list_group:
            _spid = _group.get("shenpi_id")
            _docid = _group.get("docid")
            _stage = _group.get("stage")
            follow_time = _group.get("page_time")
            _docchannel = _group.get("docchannel")
            _doctitle = _group.get("doctitle")
            progress_remark = ""
            if _docid is not None and _docid==0:
                continue
            if "is_completed" in _group or "proportion" in _group:
                continue

            if _docid is not None and _docid!="":
                document_dict = self.getDocumentWithDocid(_docid,["status"])
                if document_dict is None or (document_dict.get("status",0)>=401 and document_dict.get("status",0)<=450):
                    continue
            #     win_tenderer = ""
            #
            #     if document_dict is not None:
            #
            #         for sub_docs in json.loads(document_dict.get("sub_docs_json","[{}]")):
            #             if win_tenderer=="":
            #                 win_tenderer = sub_docs.get("win_tenderer","")
            #
            #         _status = document_dict.get("status")
            #         remain_docid = _docid
            #         if not(_status>=201 and _status<=300):
            #             remain_docid = self.data_flow.getRemainDoc(remain_docid)
            #             log("remain_docid from %s to %s"%(str(_docid),str(remain_docid)))
            #         project_flag = False
            #         if remain_docid is not None:
            #             _project = self.getProjectWithDocid(remain_docid,["zhao_biao_page_time","zhong_biao_page_time","win_tenderer","tenderee"])
            #
            #             if _project is not None:
            #                 _uuid = _project.get("uuid")
            #                 if _uuid in set_project_uuid:
            #                     continue
            #                 progress_remark = ""
            #                 if _project.get("zhao_biao_page_time") is not None:
            #                     follow_time = max(follow_time,_project.get("zhao_biao_page_time"))
            #                     progress_remark += "%s,项目处于%s的招标阶段；"%(_project.get("zhao_biao_page_time"),_stage)
            #                 if _project.get("zhong_biao_page_time") is not None:
            #                     follow_time = max(follow_time,_project.get("zhong_biao_page_time"))
            #                     progress_remark += "截止%s"%(_project.get("zhong_biao_page_time"))
            #                 if _project.get("win_tenderer") is not None:
            #                     progress_remark += "确定%s中标人为%s"%(_stage,_project.get("win_tenderer"))
            #
            #                 if _project.get("win_tenderer") is not None:
            #                     if _project.get("win_tenderer") not in set_enterprise:
            #                         self.addContact(_contacts,"%s单位"%(str(_group.get("stage","")).replace("None","").replace("阶段","")),_project.get("win_tenderer"))
            #                         set_enterprise.add(_project.get("win_tenderer"))
            #
            #                 if _project.get("tenderee") is not None:
            #                     if _project.get("tenderee") not in set_enterprise:
            #                         self.addContact(_contacts,"业主单位",_project.get("tenderee"))
            #                         set_enterprise.add(_project.get("tenderee"))
            #
            #                 project_flag = True
            #                 set_project_uuid.add(_uuid)
            #         if not project_flag:
            #             if document_dict.get("docchannel") in (101,118,119,120):
            #                 progress_remark = "截止%s,项目处于%s；"%(_group["page_time"],str(_stage))
            #                 if win_tenderer!="":
            #                     progress_remark += "确定%s中标人为%s"%(_stage,win_tenderer)
            #             else:
            #                 progress_remark = "截止%s,项目处于%s的招标阶段；"%(_group["page_time"],str(_stage))
            # else:
            #     progress_remark = "截止%s,项目处于%s；"%(_group["page_time"],str(_stage))
            #
            # _key = "%s-%s"%(_group["page_time"],str(_stage))
            # if _key in set_follow:
            #     continue
            # set_follow.add(_key)

            _version_index += 1
            _follow = {"id":get_guid(),"crtime":getCurrent_date(),"docid":_docid,"spid":_spid,
                       "mdate":"%s 00:00:00"%follow_time,
                       "docchannel":_docchannel,"doctitle":_doctitle,
             "progress":_stage,"progress_remark":progress_remark,
             "version":"跟进%d"%(_version_index)}

            list_follow.append(_follow)
        list_follow.sort(key=lambda x:x.get("mdate",""))
        _version_index = 0
        for _follow in list_follow:
            _version_index += 1
            _follow["version"] = "跟进%d"%(_version_index)
        return list_follow




    def getId(self,list_docid,list_spid):

        #
        # list_should_query = []
        # for _docid in list_docid:
        #     _q = TermQuery("docids",_docid)
        #     list_should_query.append(_q)
        # for _spid in list_spid:
        #     _q = TermQuery("spids",_spid)
        #     list_should_query.append(_q)

        return get_guid()

    def getDocumentWithDocid(self,docid,columns=["page_time","docchannel","sub_docs_json"]):
        if docid is None or docid=="":
            return None
        if docid in self.dict_document:
            return self.dict_document.get(docid)
        partitionkey = int(docid)%500+1
        document_dict = self.search(ots_client,"document",[("partitionkey",partitionkey),("docid",int(docid))],columns)
        self.dict_document[docid] = document_dict
        return document_dict

    def getProjectWithDocid(self,docid,columns):

        bool_query = BoolQuery(must_queries=[TermQuery("docids",docid)])

        rows,next_token,total_count,is_all_succeed = ots_client.search("project2","project2_index",
                                                                       SearchQuery(bool_query,get_total_count=True,limit=10),
                                                                       columns_to_get=ColumnsToGet(columns,ColumnReturnType.SPECIFIED))
        if len(rows)>0:
            list_data = getRow_ots(rows)
            return list_data[0]
        return None


    def toDesigned_project(self,ots_client):
        if "json_list_group" not in self.getProperties() or self.json_list_group is None or self.json_list_group=="":
            return None
        print("1111")
        list_group = json.loads(self.json_list_group)
        is_completed = False
        for _group in list_group:
            if "page_time" not in _group or _group["page_time"] is None:
                _group["page_time"] = ""
            if _group.get("is_completed",0)==1:
                is_completed = True
        list_group.sort(key=lambda x:x["page_time"])

        set_contacts = set()
        list_contacts = []
        set_follows = set()
        _version_index = 1
        crtime = getCurrent_date()
        floor_space = ""
        covered_area = ""
        project_address = ""
        begintime = ""
        endtime = ""
        project_description = ''
        project_name = ""
        high_project_name = ""
        ordinary_name = ""
        project_follow = ""

        progress = ""

        status = "1"

        update_status = "0"
        update_time = getCurrent_date("%Y-%m-%d %H:%M:%S")
        page_time = ""
        project_code = ""
        project_type = ""
        area = ""
        province = ""
        city = ""
        district = ""

        set_docid = set()
        set_spid = set()
        set_enterprise = set()



        latest_service_time = ""

        list_follows = []

        _version_index = 0
        for _group in list_group:
            _docid = _group.get("docid")
            _spid = _group.get("shenpi_id")

            _stage = _group.get("stage")
            follow_time = _group.get("page_time")
            _docchannel = _group.get("docchannel")
            _doctitle = _group.get("doctitle")
            progress_remark = ""

            if _docid is not None and _docid>0:
                set_docid.add(str(_docid))
            if _spid is not None and _spid>0:
                set_spid.add(str(_spid))
            if floor_space=="":
                floor_space = _group.get("proportion","")
                covered_area = floor_space
            if begintime=="" and _group.get("begin_time") is not None:
                begintime = _group.get("begin_time","")
            if endtime=="" and _group.get("endtime") is not None:
                endtime = _group.get("endtime","")
            if project_description=="":
                project_description = _group.get("projectDigest","")
            if project_code=="":
                project_code = _group.get("project_code","")
            if project_name=="":
                project_name = _group.get("project_name","")
                high_project_name = project_name
                ordinary_name = project_name
            if _group.get("page_time","")>page_time:
                page_time = _group.get("page_time","")
            if project_type=="":
                project_type = _group.get("industry","")
            if area=="":
                area = _group.get("city","")
            if province=="":
                province = _group.get("province","")
            if city=="":
                city = _group.get("city","")
            if district=="":
                district = _group.get("district","")
            if _group.get("latest_service_time","")!="" and _group.get("latest_service_time") is not None:
                latest_service_time = _group.get("latest_service_time")

            # _follow = "%s-%s"%(_group["stage"],_group["page_time"])
            # if _follow not in set_follows:
            #     list_follows.append({"id":get_guid(),"crtime":getCurrent_date(),"mdate":"%s 00:00:00"%_group["page_time"],
            #                          "progress":_group["stage"],"progress_remark":"截止%s,该项目处于%s"%(_group["page_time"],str(self.getStage(_group.get("stage","")))),
            #                          "version":"跟进%d"%(_version_index)})
            #     set_follows.add(_follow)
            #     project_follow = "跟进%d"%(_version_index)
            #     _version_index += 1

            if _docid is not None and _docid==0:
                continue
            if "is_completed" in _group or "proportion" in _group:
                continue

            if _docid is not None and _docid!="":
                document_dict = self.getDocumentWithDocid(_docid,["status"])
                if document_dict is None or (document_dict.get("status",0)>=401 and document_dict.get("status",0)<=450):
                    continue
            _prop = str(self.getStage(_group.get("stage","")))
            if _prop!="" and _prop!="None":
                progress = _prop

            if is_completed:
                progress = "竣工阶段"


            _version_index += 1
            _follow = {"id":get_guid(),"crtime":getCurrent_date(),"docid":_docid,"spid":_spid,
                       "mdate":"%s 00:00:00"%follow_time,
                       "docchannel":_docchannel,"doctitle":_doctitle,
                       "progress":_stage,"progress_remark":progress_remark,
                       "version":"跟进%d"%(_version_index)}

            list_follows.append(_follow)
        if page_time=="":
            page_time = update_time[:10]

        list_follows.sort(key=lambda x:x.get("mdate",""))
        _version_index = 0
        for _follow in list_follows:
            _version_index += 1
            _follow["version"] = "跟进%d"%(_version_index)

        # list_follows = self.getFollows(list_group,legal_contacts,set_enterprise)

        legal_contacts = []
        legal_contacts,tenderee_count = self.getContacts(ots_client,list_group,set_enterprise,legal_contacts)
        if len(legal_contacts)==0:
            return None

        des_project_type = "30"
        if len(list_follows)>=3:
            des_project_type = "10"
        elif tenderee_count>=1:
            des_project_type = "20"

        if len(list_follows)==0:
            return None
        # get the key,if exists then search else generate
        id = self.getId(list(set_docid),list(set_spid))
        partitionkey = id%200+1
        project_dict = {"partitionkey":partitionkey,"id":id,
                        "crtime":crtime,"floor_space":floor_space,"project_address":project_address,
                        "begintime":begintime,"endtime":endtime,"project_description":project_description,
                        "project_name":project_name,"ordinary_name":ordinary_name,"high_project_name":high_project_name,
                        "project_follow":project_follow,"page_time":page_time,"progress":progress,"contacts":json.dumps(legal_contacts,ensure_ascii=False),
                        "follows":json.dumps(list_follows,ensure_ascii=False),
                        "follow_number":len(list_follows),
                        "docids":",".join(list(set_docid)),"spids":",".join(list(set_spid)),"des_project_type":des_project_type,"status":status,"covered_area":covered_area,
                        "update_status":update_status,"update_time":update_time,"project_code":project_code,
                        "project_type":project_type,"area":area,"latest_service_time":latest_service_time,
                        "full_text":"%s%s"%(str(project_name),str(project_description)),
                        "json_list_group":self.json_list_group,
                        "province":province,"city":city,"district":district}
        return project_dict





if __name__=="__main__":

    s = '''
[{"docid": 0, "shenpi_id": 0, "type_id": 0, "page_time": "2023-11-17", "province": "河北", "city": "沧州", "district": "沧县", "tenderee": "澜沧拉祜族自治县教育体育局", "tenderee_contact": "李光友", "tenderee_phone": "13619495665", "agency": "普洱市普平工程招标有限责任公司", "project_code": "GC530800202300495001001", "project_name": "澜沧县第二幼儿园大水井社区幼儿园、佛房社区幼儿园建设项目", "doctitle": "澜沧县第二幼儿园（大水井社区幼儿园、佛房社区幼儿园）建设项目资格预审公告", "docchannel": "52", "stage": "施工准备", "proportion": "", "projectDigest": "招标概况，招标项目名称：澜沧县第二幼儿园(大水井社区幼儿园、佛房社区幼儿园)建设项目，资金来源：国资100.0%自筹%贷款%外资%。建设规模：建设教学综合楼3960平方米，教学及生活辅助用房5145平方米。公共资源交易行业分类：房屋建筑工程，工程类型：施工，招标方式：资格审查方式：", "projectAddress": null, "begin_time": "", "end_time": "", "project_name_refind": "澜沧县第二幼儿园大水井社区幼儿园、佛房社区幼儿园建设项目", "industry": "教育及研究", "location": null, "service_time": "（日历天）：300", "service_days": "300", "project2_uuid": null, "nlp_enterprise": "[\'澜沧县第二幼儿园\',\'澜沧县第二幼儿园（大水井社区幼儿园\',\'大水井社区幼儿园\',\'佛房社区幼儿园\',\'澜沧县公共资源交易中心\',\'澜沧拉祜族自治县住房和城乡建设局\',\'澜沧拉祜族自治县教育体育局\',\'普洱市普平工程招标有限责任公司\',\'澜沧县民族小学\']", "nlp_enterprise_attachment": "[\'澜沧县公共资源交易中心\',\'澜沧县第二幼儿园\',\'佛房社区幼儿园\',\'中华人民共和国\',\'国家发展改革委\',\'云南省发展和改革委员会\',\'澜沧县第二幼儿园（大水井社区幼儿园\',\'大水井社区幼儿园\',\'澜沧拉祜族自治县发展和改革局\',\'澜沧县发展和改革局\',\'澜沧拉祜族自治县教育体育局\',\'中央\',\'普洱市普平工程招标有限责任公司\',\'澜沧县民族小学\']", "main": 1, "new_enough": 1, "follow_enough": 1, "area": "华北", "show_name_refind": "澜沧县第二幼儿园大水井社区幼儿园、佛房社区幼儿园建设项目"}, {"docid": 381184440, "shenpi_id": null, "type_id": "381184440", "stage": "施工准备", "page_time": "2023-11-17", "location": null, "phase": null, "section": null, "new_enough": 0, "follow_enough": 1}]
    '''
    print(json.loads(s))
    a = proposedBuilding_tmp({"json_list_group":s})
    _project_dict = a.toDesigned_project(ots_client)
    print(_project_dict)
    # from BaseDataMaintenance.model.ots.designed_project import designed_project
    # _time = time.time()
    # if _project_dict is not None:
    #     #更新数据
    #     # log("project_dict:"+json.dumps(_project_dict))
    #     _designed_project = designed_project(_project_dict)
    #     _designed_project.update_project(ots_client)
    #     print("updated")
