Exemple #1
0
 def getByFilmName(self, filmName):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     num = cursor.execute(
         "select * from tf_merge_film where film_name ='%s' " % (filmName))
     if (num == 0):
         return None
     rows = cursor.fetchall()
     row = rows[0]
     filmMergeItem = FilmMergeItem()
     filmMergeItem.id = row['id']
     filmMergeItem.filmName = row['film_name']
     filmMergeItem.grade = row['grade']
     filmMergeItem.showTime = row['show_time']
     filmMergeItem.showState = row['show_state']
     filmMergeItem.img = row['img']
     filmMergeItem.filmType = row['film_type']
     filmMergeItem.ver = row['ver']
     filmMergeItem.actor = row['actor']
     filmMergeItem.country = row['country']
     filmMergeItem.direct = row['direct']
     filmMergeItem.initDate = row['init_date']
     filmMergeItem.duration = row['duration']
     filmMergeItem.state = row['state']
     baseDao.commitCloseDb(db)
     return filmMergeItem
Exemple #2
0
 def insertNew(self, FilmItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     num = cursor.execute("select 1 from tf_film where website_id='%s' and website_film_id='%s' " % \
                          (FilmItem.websiteId,FilmItem.websiteFilmId))
     if num > 0:
         return
     if FilmItem.grade.isdigit() == False:
         FilmItem.grade = 0.0
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_film (film_name, website_id, website_film_id,grade, show_time, show_state, img, ver, actor, country, direct,film_type,init_date,clob,state) VALUES ('%s', '%s', '%s','%s','%s', '%s', '%s','%s', '%s','%s', '%s', '%s','%s','%s','%s')" % \
                             (FilmItem.filmName,FilmItem.websiteId,FilmItem.websiteFilmId,str(FilmItem.grade),
                             str(FilmItem.showTime),
                             str(FilmItem.showState),
                             FilmItem.img,
                             FilmItem.ver,
                             FilmItem.actor,
                             FilmItem.country,
                             FilmItem.direct,
                             FilmItem.filmType,
                             now,FilmItem.clob,FilmItem.state)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #3
0
 def getByWebsiteFilmId(self, websiteFilmId):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     num = cursor.execute(
         "select * from tf_film where website_film_id = '%s' ",
         websiteFilmId)
     rows = cursor.fetchall()
     row = rows[0]
     filmItem = FilmItem()
     filmItem.id = row['id']
     filmItem.filmName = row['film_name']
     filmItem.websiteId = row['website_id']
     filmItem.websiteFilmId = row['website_film_id']
     filmItem.grade = row['grade']
     filmItem.showTime = row['show_time']
     filmItem.showState = row['show_state']
     filmItem.img = row['img']
     filmItem.filmType = row['film_type']
     filmItem.ver = row['ver']
     filmItem.actor = row['actor']
     filmItem.country = row['country']
     filmItem.direct = row['direct']
     filmItem.initDate = row['init_date']
     filmItem.clob = row['clob']
     filmItem.duration = row['duration']
     filmItem.mergeId = row['merge_id']
     baseDao.commitCloseDb(db)
     return filmItem
Exemple #4
0
 def getNoMergeFilm(self):
     filmItems = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     num = cursor.execute(
         "select * from tf_film where merge_id is null and state=1 ")
     rows = cursor.fetchall()
     for row in rows:
         filmItem = FilmItem()
         filmItem.id = row['id']
         filmItem.filmName = row['film_name']
         filmItem.websiteId = row['website_id']
         filmItem.websiteFilmId = row['website_film_id']
         filmItem.grade = row['grade']
         filmItem.showTime = row['show_time']
         filmItem.showState = row['show_state']
         filmItem.img = row['img']
         filmItem.filmType = row['film_type']
         filmItem.ver = row['ver']
         filmItem.actor = row['actor']
         filmItem.country = row['country']
         filmItem.direct = row['direct']
         filmItem.initDate = row['init_date']
         filmItem.clob = row['clob']
         filmItem.duration = row['duration']
         filmItem.mergeId = row['merge_id']
         filmItems.append(filmItem)
     baseDao.commitCloseDb(db)
     return filmItems
Exemple #5
0
 def deleteOneDay(self, dateInt, websiteId):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     num = cursor.execute("delete from tf_daily_film_cinema where website_id='%s' and date_no='%s' " % \
                          (websiteId,dateInt))
     baseDao.commitCloseDb(db)
Exemple #6
0
 def updateArea(self,id,area):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标 
     cursor = db.cursor()
     sql = "update tf_merge_cinema set area='%s' where id='%s'" % (area,id)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #7
0
 def updateFilmMergeId(self, id, mergeId):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     sql = "update tf_film set merge_id='%s' where id='%s' " % (mergeId, id)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #8
0
 def deleteFailed(self, dateNo, websiteId, logType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     sql = "delete from tf_daily_log where website_id='%s' and date_no='%s' and state in (-1,0) and log_type='%s'" % (
         websiteId, dateNo, logType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #9
0
 def deleteByDateNo(self, dateNo, calcType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     sql = "delete from  tf_calc where date_no='%s' and calc_type='%s' " % (
         dateNo, calcType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #10
0
 def deleteOneDay(self, dateNo, msType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "delete from tf_message where date_no='%s' and ms_type='%s'" % (
         dateNo, msType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #11
0
 def insert(self, MessageItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_message (date_no, content, ms_type,state,init_date) VALUES ('%s', '%s', '%s', '%s', '%s')" % \
             (str(MessageItem.dateNo),str(MessageItem.content),str(MessageItem.msType),'1',now)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #12
0
 def hasDailyLog(self, dateNo, websiteId, logType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     sql = "select 1 from tf_daily_log where website_id='%s' and date_no='%s' and log_type='%s' " % (
         websiteId, dateNo, logType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
     return num > 0
Exemple #13
0
 def insert(self, CalcItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_calc (date_no, calc_type, website_id, merge_cinema_id, merge_film_id, init_date) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')" % \
                 (str(CalcItem.dateNo),str(CalcItem.calcType),str(CalcItem.websiteId),str(CalcItem.mergeCinemaId),str(CalcItem.mergeFilmId),now)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #14
0
 def insertStart(self, dateNo, websiteId, logType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_daily_log (date_no, website_id, start_date, state,log_type) VALUES ('%s', '%s', '%s', '%s','%s')" % \
                 (str(dateNo),str(websiteId),now,'0',logType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #15
0
 def insertNew(self, FilmMergeItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_merge_film (film_name, grade, show_time, show_state, img, film_type, ver, actor, country, direct, init_date,state) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');" % \
                             (FilmMergeItem.filmName,str(FilmMergeItem.grade),str(FilmMergeItem.showTime),str(FilmMergeItem.showState),FilmMergeItem.img,FilmMergeItem.filmType,FilmMergeItem.ver,FilmMergeItem.actor,FilmMergeItem.country,FilmMergeItem.direct,now,str(FilmMergeItem.state))
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
     return self.getByFilmName(FilmMergeItem.filmName)
Exemple #16
0
 def updateEnd(self, dateNo, websiteId, state, msg, logType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     msg = msg.replace('\'', '\\\'')
     sql = "update tf_daily_log set end_date='%s' ,state='%s',msg='%s' where date_no='%s' and website_id = '%s' and log_type = '%s'" % \
                 (now,str(state),msg,str(dateNo),str(websiteId),logType)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #17
0
 def insertNew(self,CinemaMergeItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标 
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     sql = "INSERT INTO tf_merge_cinema (cinema_name, area, addr, state, init_date) VALUES ('%s', '%s', '%s', %s, '%s')" % \
                             (CinemaMergeItem.cinemaName,CinemaMergeItem.area,CinemaMergeItem.addr,str(CinemaMergeItem.state),now)
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
     return self.getByCinemaName(CinemaMergeItem.cinemaName)
Exemple #18
0
 def getPersonName(self, sendType):
     personNames = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "select * from tf_message_send where state=1 and send_type='%s' order by id desc" % (
         sendType)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     for row in rows:
         personNames.append(row['person_name'])
     baseDao.commitCloseDb(db)
     return personNames
Exemple #19
0
 def insert(self, DailyFilmCinemaItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     try:
         DailyFilmCinemaItem.grade = float(DailyFilmCinemaItem.grade)
     except:
         DailyFilmCinemaItem.grade = 0.0
     sql = "INSERT INTO tf_daily_film_cinema (website_id, website_film_id, website_cinema_id, grade, date_no, show_state, price, init_date,show_cinema_num,show_round_num) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s')" % \
             (str(DailyFilmCinemaItem.websiteId),str(DailyFilmCinemaItem.websiteFilmId),str(DailyFilmCinemaItem.websiteCinemaId),str(DailyFilmCinemaItem.grade),str(DailyFilmCinemaItem.dateNo),str(DailyFilmCinemaItem.showState),str(DailyFilmCinemaItem.price),now,str(DailyFilmCinemaItem.showCinemaNum),str(DailyFilmCinemaItem.showRoundNum))
     print(sql)
     num = cursor.execute(sql)
     baseDao.commitCloseDb(db)
Exemple #20
0
 def insertNew(self, CinemaItem):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = db.cursor()
     num = cursor.execute("select 1 from tf_cinema where website_id='%s' and website_cinema_id='%s' " % \
                          (CinemaItem.websiteId,CinemaItem.websiteCinemaId))
     if num > 0:
         return
     now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     print("INSERT INTO tf_cinema (cinema_name, website_cinema_id, website_id, area, addr, state, init_date) VALUES ('%s', '%s', '%s', %s, '%s', '%s', '%s')" % \
                             (CinemaItem.cinemaName,str(CinemaItem.websiteCinemaId),str(CinemaItem.websiteId),CinemaItem.area,CinemaItem.addr,str(CinemaItem.state),now))
     num = cursor.execute("INSERT INTO tf_cinema (cinema_name, website_cinema_id, website_id, area, addr, state, init_date) VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s')" % \
                             (CinemaItem.cinemaName,CinemaItem.websiteCinemaId,CinemaItem.websiteId,str(CinemaItem.area),CinemaItem.addr,CinemaItem.state,now))
     baseDao.commitCloseDb(db)
Exemple #21
0
 def getByCinemaName(self,cinemaName):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标 
     cursor = baseDao.getDictCursor(db)
     num = cursor.execute("select * from tf_merge_cinema where cinema_name ='%s' " % (cinemaName))
     if(num == 0):
         return None
     rows = cursor.fetchall()
     row = rows[0]
     cinemaMergeItem = CinemaMergeItem()
     cinemaMergeItem.id = row['id']
     cinemaMergeItem.cinemaName = row['cinema_name']
     cinemaMergeItem.area = row['area']
     cinemaMergeItem.addr = row['addr']
     cinemaMergeItem.state = row['state']
     baseDao.commitCloseDb(db)
     return cinemaMergeItem
Exemple #22
0
 def getGradeHiFilm(self, dateNo):
     mergeFilmIds = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "select  distinct(b.merge_id) merge_film_id from  \
          tf_daily_film_cinema a left join tf_film b on a.website_film_id=b.website_film_id \
          left join tf_merge_film c on b.merge_id=c.id \
         where a.date_no='%s'  \
         order by a.grade desc limit 3" % (dateNo)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     for row in rows:
         mergeFilmIds.append(row['merge_film_id'])
     baseDao.commitCloseDb(db)
     return mergeFilmIds
Exemple #23
0
 def getMostRoundFilms(self, dateNo):
     mergerFilmIds = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "select b.merge_id merge_id\
         from tf_daily_film_round a left join tf_film b on a.website_film_id=b.website_film_id \
             left join tf_merge_film c on b.merge_id = c.id \
         where a.date_no='%s' \
         group by b.merge_id \
         order by (a.show_round_num) desc limit 3" % (dateNo)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     for row in rows:
         mergerFilmIds.append(row['merge_id'])
     baseDao.commitCloseDb(db)
     return mergerFilmIds
Exemple #24
0
 def doSelect(self,sql):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标 
     cursor = baseDao.getDictCursor(db)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     cinemaMergeItems = []
     for row in rows:
         cinemaMergeItem = CinemaMergeItem()
         cinemaMergeItem.id = row['id']
         cinemaMergeItem.cinemaName = row['cinema_name']
         cinemaMergeItem.area = row['area']
         cinemaMergeItem.addr = row['addr']
         cinemaMergeItem.state = row['state']
         cinemaMergeItems.append(cinemaMergeItem)
     baseDao.commitCloseDb(db)
     return cinemaMergeItems
Exemple #25
0
 def doSelect(self, sql):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     items = []
     for row in rows:
         item = MessageItem()
         item.id = row['id']
         item.dateNo = row['date_no']
         item.msType = row['ms_type']
         item.content = row['content']
         item.state = row['state']
         item.initDate = row['init_date']
         items.append(item)
     baseDao.commitCloseDb(db)
     return items
Exemple #26
0
 def doSelect(self, sql):
     items = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     for row in rows:
         item = CalcItem()
         item.id = row['id']
         item.dateNo = row['date_no']
         item.calcType = row['calc_type']
         item.websiteId = row['website_id']
         item.websiteCinemaId = row['website_cinema_id']
         item.websiteFilmId = row['website_film_id']
         item.initDate = row['init_date']
         items.append(item)
     baseDao.commitCloseDb(db)
     return items
Exemple #27
0
 def getCheapCimane(self, filmMergeId, dateNo):
     calcItems = []
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "select a.website_id website_id, b.merge_id cinema_merge_id,d.merge_id film_merge_id \
             from tf_daily_film_cinema a left join tf_cinema b on a.website_cinema_id = b.website_cinema_id  \
             left join tf_film d on a.website_film_id = d.website_film_id left join tf_merge_cinema f on b.merge_id=f.id \
             where d.merge_id='%s' and a.date_no='%s' and f.area in ('红桥区','南开区') \
             order by a.price limit 1" % (str(filmMergeId), str(dateNo))
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     for row in rows:
         calcItem = CalcItem()
         calcItem.dateNo = dateNo
         calcItem.websiteId = row['website_id']
         calcItem.mergeCinemaId = row['cinema_merge_id']
         calcItem.mergeFilmId = row['film_merge_id']
         calcItems.append(calcItem)
     baseDao.commitCloseDb(db)
     return calcItems
Exemple #28
0
 def getCalcMessage(self, dateNo, calcType):
     baseDao = BaseDao()
     db = baseDao.getDB()
     # 使用cursor()方法获取操作游标
     cursor = baseDao.getDictCursor(db)
     sql = "select b.film_name,c.cinema_name,d.website_name,b.film_type,b.actor \
         from tf_calc a left join tf_merge_film b on a.merge_film_id=b.id left join tf_merge_cinema c on a.merge_cinema_id=c.id \
             left join tf_website d on a.website_id=d.id \
         where a.date_no='%s' and a.calc_type='%s'" % (dateNo, calcType)
     print(sql)
     num = cursor.execute(sql)
     rows = cursor.fetchall()
     items = []
     for row in rows:
         messageContentItem = MessageContentItem()
         messageContentItem.filmName = row['film_name']
         messageContentItem.cinemaName = row['cinema_name']
         messageContentItem.websiteName = row['website_name']
         messageContentItem.filmType = row['film_type']
         messageContentItem.actor = row['actor']
         items.append(messageContentItem)
     baseDao.commitCloseDb(db)
     return items