|
@@ -1,38 +1,14 @@
|
|
from handlers.HandlerBase import BaseHandler
|
|
from handlers.HandlerBase import BaseHandler
|
|
from model import DingTalkUtils
|
|
from model import DingTalkUtils
|
|
import os
|
|
import os
|
|
-from model.DataBaseUtils import MysqlUtils
|
|
|
|
-from model.DateUtils import DateUtils
|
|
|
|
-
|
|
|
|
|
|
+import subprocess
|
|
|
|
|
|
class SrcBookInfo(BaseHandler):
|
|
class SrcBookInfo(BaseHandler):
|
|
-
|
|
|
|
def get(self):
|
|
def get(self):
|
|
- db = MysqlUtils()
|
|
|
|
- du = DateUtils()
|
|
|
|
|
|
+ subprocess.Popen('source ~/.bashrc && /root/.local/share/virtualenvs/DataCenter-EjFsiCkN/bin/python /root/DataCenter/app/etl/src/src_book_info.py')
|
|
|
|
+ subprocess.call()
|
|
|
|
+ self.write('ok')
|
|
|
|
|
|
- sql = """SELECT date_format(a.effect_day,'%Y-%m-%d'),
|
|
|
|
- case a.type when 'mp' then 'MP' when 'gdt' then 'GDT' end type,
|
|
|
|
- b.book_name,c.platform_name,a.node_price from t_platform_book_ratio a
|
|
|
|
- left join t_platform_book b on a.platform_book_id=b.id
|
|
|
|
- left join t_platform_novel c on b.platform_id=c.id order by a.effect_day"""
|
|
|
|
|
|
|
|
- data = db.zx.getData(sql)
|
|
|
|
|
|
|
|
- di = {}
|
|
|
|
- for i in data:
|
|
|
|
- thedate = i[0]
|
|
|
|
- while True:
|
|
|
|
- if thedate > du.get_n_days(0):
|
|
|
|
- break
|
|
|
|
- else:
|
|
|
|
- di[thedate + ',' + i[1] + ',' + i[2] + ',' + i[3]] = i[4]
|
|
|
|
- thedate = du.add_days(thedate, 1)
|
|
|
|
- li = []
|
|
|
|
- for i, j in di.items():
|
|
|
|
- li.append(i.split(',') + [j])
|
|
|
|
|
|
|
|
- db.dm.execute("truncate table src_book_info")
|
|
|
|
- db.dm.executeMany("insert into src_book_info values (%s,%s,%s,%s,%s)", li)
|
|
|
|
- print('src_book_info success')
|
|
|
|
- self.write('ok')
|
|
|