def ebank_trade_rep_rate(db, org_code, etldate, detail_id, pei_freq): #电子银行替代率 sql = "select weight,target from PE_CONTRACT_DETAIL where id = ? " db.cursor.execute(sql, detail_id) row = db.cursor.fetchone() weight = row[0] if row is not None else 0 aimscore = row[1] if row is not None else 0 sql = "SELECT A.DRRQ,A.JYTDL FROM T_JGC_JXKH_LR_QM A where A.JGBH=? and SJLX='6' and A.DRRQ = ?" drrq = util.tostrdate(etldate) db.cursor.execute(sql, str(org_code), drrq) row = db.cursor.fetchone() if row is not None and aimscore is not None: if row[1] * 100 < aimscore * 100: score = 0 else: score = 100 * weight else: return (False, False) return (score, row[1])
def clac_contract_scrore(db, etldate): db1 = util.DBConnect() sql = """ select sum(d.score),p.id,def.PEI_FREQ from PE_CONTRACT_DETAIL d inner join PE_CONTRACT p on d.contract_id = p.id inner join PE_PEI_DEF def on def.pei_id = d.pe_pei_id group by p.id,def.PEI_FREQ """ upsql = """ update PE_CONTRACT set score = ?,date = ? where id = ? """ db.cursor.execute(sql) row = db.cursor.fetchone() while row: score = row[0] if row[0] is not None else 0 date = util.tostrdate(etldate) pe_id = row[1] db1.cursor.execute(upsql, score, date, pe_id) row = db.cursor.fetchone() db1.conn.commit() db1.closeDB()
def __init__(self, etldate=None): self.db = util.DBConnect() self.etldate = etldate self.stretldate = util.tostrdate(self.etldate) self.para = util.get_common_parameter(self.db) if etldate is not None: self.para['TJRQ'] = etldate