예제 #1
0
 def add_node(args):
     node_new = Node(**args)
     try:
         session.add(node_new)
         session.commit()
     except exc.SQLAlchemyError as e:
         session.rollback()
         return False, "数据提交失败,失败原因为{0}".format(e)
     return True, "数据提交成功,成功新增基站{0}".format(args)
예제 #2
0
 def add_intro(**intro):
     Intro = TWorkIntroduction
     the_intro = TWorkIntroduction(**intro)
     the_intro.userid = g.user.ID
     the_intro.create_user = g.user.ID
     the_intro.username = session.query(TStaff.StaffName).filter_by(ID=g.user.ID).first()[0]
     the_intro.snumber = session.query(func.max(Intro.snumber)).first()[0] + 1
     try:
         session.add(the_intro)
         session.commit()
     except exc.SQLAlchemyError as e:
         session.rollback()
         return False, "数据提交失败"
     return True, "数据提交成功"
예제 #3
0
 def add_daily(**kwargs):
     kwargs["userid"] = g.user.ID
     kwargs["createuser"] = g.user.ID
     kwargs["updateuser"] = g.user.ID
     kwargs["isdelete"] = 0
     daily = TDailyRecord(**kwargs)
     date_p = datetime.strptime(kwargs["WorkDate"], '%Y-%m-%d').date()
     years, daily.Weeks, daily.DayInWeek = date_p.isocalendar()  # 获取周数和星期几
     daily.JobDescription = session.query(
         TbIntro.workintro).filter_by(id=daily.workintroId).first()[0]
     daily.StaffName = session.query(
         TStaff.StaffName).filter_by(ID=g.user.ID).first()[0]
     daily.ProjectName = session.query(
         TbProject.ProjectName).filter_by(ID=kwargs["ProjectID"]).first()[0]
     try:
         session.add(daily)
         session.commit()
     except exc.SQLAlchemyError as e:
         session.rollback()
         return False, "工作日报数据新增失败"