Commit b56af54b authored by pengxiong's avatar pengxiong

修复

parent 8376e873
......@@ -5,7 +5,7 @@ from sqlalchemy import Column, DECIMAL, Date, DateTime, Index, String, Table, Te
from sqlalchemy.dialects.mysql import BIGINT, INTEGER
from sqlalchemy.ext.declarative import declarative_base
from app.api.engine import TAMP_SQL, tamp_user_engine
from app.api.engine import TAMP_SQL, tamp_user_engine, tamp_diagnose_app_engine
from app.model.base import Base
from app.model.base import BaseModel
......@@ -136,14 +136,21 @@ class HoldDiagnoseReport(Base, BaseModel):
else:
allow_field = all_field
data = {c: int(getattr(self, c).timestamp()) if isinstance(getattr(self, c), datetime.datetime) else getattr(self, c) for c in allow_field}
with TAMP_SQL(tamp_user_engine) as tamp_user:
with TAMP_SQL(tamp_user_engine) as tamp_user, TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_user_session = tamp_user.session
tamp_diagnose_app_session = tamp_diagnose_app.session
sql = "select ui_username_mp from user_info where id = '{}'".format(self.ifa_id)
res = tamp_user_session.execute(sql)
sql2 = "select customer_name from tamp_diagnose_app.customer_view where id = '{}'".format(self.customer_id)
res2 = tamp_user_session.execute(sql2)
data['author_name'] = res.fetchone()[0]
data['customer_name'] = res2.fetchone()[0]
res2 = tamp_diagnose_app_session.execute(sql2)
if res:
data['author_name'] = res.fetchone()[0]
else:
data['author_name'] = ''
if res2:
data['customer_name'] = res2.fetchone()[0]
else:
data['customer_name'] = ''
data['type'] = 2
return data
......@@ -167,18 +174,22 @@ class HoldReport(Base, BaseModel):
allow_field = set(allow_field) & set(allow_field)
else:
allow_field = all_field
data = {
c: int(getattr(self, c).timestamp()) if isinstance(getattr(self, c), datetime.datetime) else getattr(self,
c) for
c in allow_field}
with TAMP_SQL(tamp_user_engine) as tamp_user:
data = {c: int(getattr(self, c).timestamp()) if isinstance(getattr(self, c), datetime.datetime) else getattr(self, c) for c in allow_field}
with TAMP_SQL(tamp_user_engine) as tamp_user, TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_user_session = tamp_user.session
tamp_diagnose_app_session = tamp_diagnose_app.session
sql = "select ui_username_mp from user_info where id = '{}'".format(self.ifa_id)
res = tamp_user_session.execute(sql)
sql2 = "select customer_name from tamp_diagnose_app.customer_view where id = '{}'".format(self.customer_id)
res2 = tamp_user_session.execute(sql2)
data['author_name'] = res.fetchone()[0]
data['customer_name'] = res2.fetchone()[0]
res2 = tamp_diagnose_app_session.execute(sql2)
if res:
data['author_name'] = res.fetchone()[0]
else:
data['author_name'] = ''
if res2:
data['customer_name'] = res2.fetchone()[0]
else:
data['customer_name'] = ''
data['type'] = 1
return data
......@@ -202,18 +213,22 @@ class PeriodicReport(Base, BaseModel):
allow_field = set(allow_field) & set(allow_field)
else:
allow_field = all_field
data = {
c: int(getattr(self, c).timestamp()) if isinstance(getattr(self, c), datetime.datetime) else getattr(self,
c) for
c in allow_field}
with TAMP_SQL(tamp_user_engine) as tamp_user:
data = {c: int(getattr(self, c).timestamp()) if isinstance(getattr(self, c), datetime.datetime) else getattr(self, c) for c in allow_field}
with TAMP_SQL(tamp_user_engine) as tamp_user, TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_user_session = tamp_user.session
tamp_diagnose_app_session = tamp_diagnose_app.session
sql = "select ui_username_mp from user_info where id = '{}'".format(self.ifa_id)
res = tamp_user_session.execute(sql)
sql2 = "select customer_name from tamp_diagnose_app.customer_view where id = '{}'".format(self.customer_id)
res2 = tamp_user_session.execute(sql2)
data['author_name'] = res.fetchone()[0]
data['customer_name'] = res2.fetchone()[0]
res2 = tamp_diagnose_app_session.execute(sql2)
if res:
data['author_name'] = res.fetchone()[0]
else:
data['author_name'] = ''
if res2:
data['customer_name'] = res2.fetchone()[0]
else:
data['customer_name'] = ''
data['type'] = 3
return data
......
......@@ -55,7 +55,8 @@ def get_report_list(args):
res = periodic_report
totalSize = res.count()
data = res.offset(offset).limit(pageSize)
data = [r.to_dict() for r in data]
if data:
data = [r.to_dict() for r in data]
return {
'content': data,
'pageNum': pageNumber,
......@@ -169,6 +170,7 @@ def make_report(args):
args['update_time'] = datetime.datetime.now()
args['update_status'] = 1
args.pop('type')
record_id = 0
with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_diagnose_session = tamp_diagnose_app.session
......@@ -189,6 +191,10 @@ def make_report(args):
try:
dt = DataIntegrate(ifa_id=ifa_id, customer_id=customer_id, pdf_name=pdf_name, type=type)
dt.render_data(data=report_data)
except:
pass
with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_diagnose_session = tamp_diagnose_app.session
hold_report = tamp_diagnose_session.query(HoldReport).filter(and_(
HoldReport.id == record_id,
HoldReport.ifa_id == ifa_id,
......@@ -214,7 +220,5 @@ def make_report(args):
'update_status': 2,
'update_time': datetime.datetime.now()
})
except:
pass
else:
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment