if __name__ == "__main__": #大于180天部分 sql = """SELECT OP.id,OP.cname,OP.p_id,ab.name,datediff(now(),IFNULL(PT.last_ctime,OP.bbtime)) from (select a.id,a.cname,a.p_id,a.bbtime,a.stage from out_proj a where not EXISTS (select 1 from tracking_push_log b where b.prj_id=a.id and b.status>1)) OP left join ( select pid,MAX(ctime) as last_ctime from out_proj_tracking GROUP BY pid ) PT ON PT.pid=OP.id left join addr_book ab on ab.id=OP.p_id where datediff(now(),IFNULL(PT.last_ctime,OP.bbtime)) >=180 and OP.stage =1 and OP.p_id in(106,243) order by OP.p_id""" rows, iN = local.select(sql) print iN p_id = 0 for e in rows: if e[2] != p_id: print e[3] errcode = mWxPushMsg_tracking_fw(e[0], e[1], e[2], e[3], 2) print errcode if str(errcode) == '0': sql = """INSERT INTO tracking_push_log(prj_id,ctime,status) VALUES(%s,now(),2) """ % ( e[0]) local.executesql(sql) p_id = e[2] #90天-180天部分 sql = """SELECT OP.id,OP.cname,OP.p_id,ab.name,datediff(now(),IFNULL(PT.last_ctime,OP.bbtime))
for e in lT: id = e[0] sql = "select id from labour_contract_invalid where id=%s"%(id) lT1,iN1 = byerp.select(sql) if iN1 == 0: sql = "delete from labour_contract_invalid where id=%s"%(id) print sql local.executesql(sql) ''' #print "erp........" sql = """SELECT GROUP_CONCAT(table_EN_name separator ",") FROM z_synchro_table WHERE status=1 """ lT, iN = local.select(sql) tables = lT[0][0] tables = tables.split(',') tables.append('empl_job') tables.append('out_proj_tracking') for (table_erp, data_erp) in DD.items(): #print table_erp if table_erp not in tables: SourceDataBase = byerp field = data_deal(data_erp) strlist = field.split(',') for value in strlist: key = value #第一个为自增ID break maxID = Get_MaxID(table_erp, key, 1) insertSql(table_erp, field, key, SourceDataBase, 1,