Пример #1
0
def check_case_type_id():
    """ 216库中查找案件类型的id """

    dbarg = {"sql_host": "192.168.1.216", "sql_user": "******",
             "sql_db": "judge_center", "sql_pass": "******", "sql_port": 33669}

    sql = "select name, value from ot_judge_dict"
    res, desc = dbtool.exec_sql(dbarg, sql)
    if desc and desc[0]:
        return desc
Пример #2
0
    def on_init(self):
        """ 初始化
        """

        self.cause_of_action_id = {}
        self.cause_of_actions = []
        engine = create_engine(DB_URL, echo=False)

        with engine.connect() as conn:
            old_anyou = conn.execute(
                "select anyou_name,new_id,max(level) from ot_judge_anyou_old group by anyou_name").fetchall()

            new_anyou = conn.execute(
                "select anyou_name,id,max(level) from ot_judge_anyou group by anyou_name").fetchall()

            self.replace_keywords = dict(conn.execute(
                "select keyword,keyword_replace from ot_judge_keyword_filter").fetchall()
            )

        self.cause_of_action_id.update(dict((x[0], x[1]) for x in old_anyou))
        self.cause_of_action_id.update(dict((x[0], x[1]) for x in new_anyou))

        self.cause_of_actions.extend(
            sorted(set(x[0] for x in new_anyou), lambda x, y: len(y) - len(x)))
        self.cause_of_actions.extend(
            sorted(set(x[0] for x in old_anyou), lambda x, y: len(y) - len(x)))

        # 获取地区识别模块
        self.area_parse = IdentArea('192.168.3.234', 7779, 'area')

        dbarg = {"name": "uc_area", "sql_host": "192.168.1.216", "sql_user": "******",
                 "sql_db": "user_cloud_db", "sql_pass": "******", "sql_port": 57789}

        sql = 'select id,  province, city,country, grade from uc_area'

        res, desc = dbtool.exec_sql(dbarg, sql)

        """
        self.area_parse.set_areas(
            [(result['id'], result['province'], result['city'],
            result['country'])
            for result in desc])
        """
        for result in desc:
            if result['grade'] == 2:
                self.area_parse.set_area(
                    result['country'], result['id'], 2, result['city'])
            if result['grade'] == 1:
                self.area_parse.set_area(
                    result['city'], result['id'], 1, result['province'])
            if result['grade'] == 0:
                self.area_parse.set_area(
                    result['province'], result['id'], 0, '')
Пример #3
0
    def init(self, **kwargs):
        """初始化处理器类。

        param kwargs:
        """

        if len(sys.argv) > 5:
            nums = sys.argv[-2]
            self.page = int(re.split("-", nums)[0])
            self.pages = int(re.split("-", nums)[1])
            self.p_type = True
            

        self._from = {}
        self._to = {}
        self._process_func = {}

        for warehouse in self.from_warehouses:
            self._from[warehouse.__name__] = warehouse

        for warehouse in self.to_warehouses:
            self._to[warehouse.__name__] = warehouse
            self._process_func[warehouse.__name__] = getattr(
                self, 'to_%s' % warehouse.__name__)

        #import pdb
        #pdb.set_trace()

        self.start_id = int(kwargs.pop('after_id', '0'))

        dbarg = {"sql_host": "192.168.1.215", "sql_user": "******",
                 "sql_db": "judge_original", "sql_pass": "******", "sql_port": 33123}
        #dbarg = {"sql_host": "127.0.0.1", "sql_user": "******",
        #         "sql_db": "flcrawl", "sql_pass": "******", "sql_port": 3306}


        p_m = sys.argv[2].split(".")[-1]

        if p_m == "CourtGovCnProcesser":
            sql = self.sql_p
        elif p_m == "CourtGovCnOperateProcesser":
            sql = self.sql_op
        elif p_m == "CourtGovCnMergeProcesser":
            sql = self.sql_m
        elif p_m == "CourtGovCnMergeProcesserLawyer":
            sql = self.sql_ml
        elif p_m == "CourtGovCnMergeProcesserLawyerUp":
            sql = self.sql_lu
        elif p_m == "CourtGovCnMake":
            sql = self.sql_mk
        if p_m == "CourtGovCnProcesserMake":
            sql = self.sql_pmake
#        elif p_m == "SCCourtProcesser":
#        elif p_m == "SCCourtProcesser":
#            sql = self.sql_sc
#        elif p_m == "GSCourtProcesser":
#            sql = self.sql_gs
#        elif p_m == "YNCourtProcesser":
#            sql = self.sql_yn
#        elif p_m == "QHCourtProcesser":
#            sql = self.sql_qh
        elif p_m == "CQCourtProcesser":
            sql = self.sql_cq

        #import pdb
        #pdb.set_trace()
        if not self.p_type:
            if p_m == "CourtGovCnMergeProcesserLawyer":
                self.start_id = self.startid[1]
            elif p_m == "CourtGovCnMergeProcesserLawyerUp":
                self.start_id = self.startid[2]
            else:
                res, desc = dbtool.exec_sql(dbarg, sql)
                if len(desc) > 0 and desc[0]:
                    if p_m == "CourtGovCnMake" or p_m == "CourtGovCnProcesserMake":
                        self.start_id = desc[0]['max(id)']
                        #self.start_id = 1
                    else:
                        self.start_id = desc[0]['parent_id']
        elif self.p_type:
            self.start_id = self.page

        #self.start_id = 1
        self.start_datetime = kwargs.pop('after_datetime', None)

        self.on_init(**kwargs)