Beispiel #1
0
    def get(self):
        self.xsrf_form_html()
        page_index = int(self.get_argument("page", default="1"))
        limit = int(self.get_argument("limit", default="30"))
        is_correct = int(self.get_argument("is_correct", default="1"))
        keyword = self.get_argument("keyword", default="")
        create_time = self.get_argument("create_time", default="1970-01-0-1")
        last_login = self.get_argument("last_login", default="3000-12-31")
        if create_time == "":
            create_time = "1970-01-01"
        if last_login == "":
            last_login = "******"

        # 数据判断条件
        filters = {
            db.or_(db.Manager.id.like('%' + keyword + '%'),
                   db.Manager.email.like('%' + keyword + '%'),
                   db.Manager.managername.like('%' + keyword + '%'),
                   db.Manager.is_active.like('%' + keyword + '%')),
            db.Manager.create_time.between(create_time + " 00:00:00",
                                           last_login + " 23:59:59"),
            ~db.Manager.id.in_([int(self.get_secure_cookie("manager_id"))]),
        }
        s = db.session()
        count = s.query(db.Manager).filter(*filters).count()
        if page_index < 1 or count == 0:
            page_index = 1
        elif limit * page_index > count:
            page_index = int((count + limit - 1) / limit)
        #asc升序
        managers = s.query(db.Manager).order_by(
            db.Manager.create_time.desc()).filter(
                *filters).limit(limit).offset((page_index - 1) * limit).all()
        s.close()
        if create_time == "1970-01-01":
            create_time = ""
        if last_login == "3000-12-31":
            last_login = ""

            #转变成json文件格式
        result_dict = [u.column_dict() for u in managers]

        res = {"code": 0, "msg": "", "count": count, "data": result_dict}
        # self.render("pics_management.html",page_index = page_index,count = count,limit = limit, keyword = keyword, start_date = start_date, end_date = end_date, pictures = pictures)
        self.write(res)
Beispiel #2
0
    def get(self):
        self.xsrf_form_html()
        page_index = int(self.get_argument("page", default="1"))
        limit = int(self.get_argument("limit", default="30"))
        is_correct = int(self.get_argument("is_correct", default="1"))
        keyword = self.get_argument("keyword", default="")
        start_date = self.get_argument("start_date", default="1970-01-01")
        end_date = self.get_argument("end_date", default="3000-12-31")
        if start_date == "":  #给时间赋予初始值
            start_date = default = "1970-01-01"
        if end_date == "":
            end_date = default = "3000-12-31"
        # 数据判断条件
        filters = {
            db.or_(
                db.Picture.name.like('%' + keyword + '%'),
                db.Picture.code.like('%' + keyword + '%'),
                db.Picture.address.like('%' + keyword + '%'),
            ),
            db.Picture.create_time.between(start_date + " 00:00:00",
                                           end_date + " 23:59:59")
        }
        s = db.session()
        count = s.query(db.Picture).filter(*filters).count()
        if page_index < 1 or count == 0:
            page_index = 1
        elif limit * page_index > count:
            page_index = int((count + limit - 1) / limit)
        #asc升序
        pictures = s.query(db.Picture).order_by(
            db.Picture.create_time.desc()).filter(
                *filters).limit(limit).offset((page_index - 1) * limit).all()
        s.close()

        if start_date == "1970-01-01":
            start_date = ""
        if end_date == "3000-12-31":
            end_date = ""
            #转变成json文件格式
        result_dict = [u.column_dict() for u in pictures]

        res = {"code": 0, "msg": "", "count": count, "data": result_dict}
        # self.render("pics_management.html",page_index = page_index,count = count,limit = limit, keyword = keyword, start_date = start_date, end_date = end_date, pictures = pictures)
        self.write(res)
Beispiel #3
0
 def get(self):
     self.xsrf_form_html()
     page_index = int(self.get_argument("page",
                                        default="1"))  #获取前端中page参数,默认为1
     limit = int(self.get_argument("limit",
                                   default="15"))  #获取前端中limit参数,默认15
     is_correct = int(self.get_argument("is_correct", default="1"))
     keyword = self.get_argument("keyword", default="")
     start_date = self.get_argument("start_date", default="1970-01-01")
     end_date = self.get_argument("end_date", default="3000-12-31")
     if start_date == "":
         start_date = default = "1970-01-01"
     if end_date == "":
         end_date = default = "3000-12-31"
     # 数据判断条件
     filters = {
         db.or_(
             db.Picture.name.like('%' + keyword + '%'),
             db.Picture.code.like('%' + keyword + '%'),
             db.Picture.address.like('%' + keyword + '%'),
         ),
         db.Picture.create_time.between(start_date + " 00:00:00",
                                        end_date + " 23:59:59")
     }
     s = db.session()
     count = s.query(db.Picture).filter(*filters).count()
     if page_index < 1 or count == 0:
         page_index = 1
     elif limit * page_index > count:
         page_index = int((count + limit - 1) / limit)
     #asc升序
     # pictures = s.query(db.Picture).order_by(db.Picture.create_time.desc()).filter(*filters).limit(limit).offset((page_index-1)*limit).all()
     s.close()
     if start_date == "1970-01-01":
         start_date = ""
     if end_date == "3000-12-31":
         end_date = ""
     self.render("pics_management.html",
                 page_index=page_index,
                 count=count,
                 limit=limit,
                 keyword=keyword,
                 start_date=start_date,
                 end_date=end_date)  #, pictures = pictures)
Beispiel #4
0
    def get(self):
        self.xsrf_form_html()
        user_id = tornado.escape.json_decode(self.get_secure_cookie("user_id"))
        page_index = int(self.get_argument("page",default="1"))
        limit = int(self.get_argument("limit",default="15"))
        keyword = self.get_argument("keyword",default="")
        start_date = self.get_argument("start_date",default="1970-01-01")
        end_date = self.get_argument("end_date",default="3000-12-31")
        if start_date == "":
            start_date = default="1970-01-01"
        if end_date == "":
            end_date = default="3000-12-31"

        # 数据判断条件
        filters = {
                db.Picture.user_id == user_id, #只允许查询自己的业务
                db.Picture.is_correct == 1, #只允许查询自己的业务

                db.or_(db.Picture.name.like('%'+keyword+'%'),
                       db.Picture.code.like('%'+keyword+'%'),
                       db.Picture.address.like('%'+keyword+'%'),
                       ),
                db.Picture.create_time.between(start_date+" 00:00:00", end_date+" 23:59:59")
        }
        s=db.session()
        count = s.query(db.Picture).filter(*filters).count()

        if page_index < 1 or count == 0:
            page_index = 1
        elif limit*page_index > count:
            page_index = int((count + limit -1) / limit);
        #asc升序
        pictures = s.query(db.Picture).order_by(db.Picture.create_time.desc()).filter(*filters).limit(limit).offset((page_index-1)*limit).all()
        s.close()

        s = db.session()
        user_infos = s.query( db.User ).filter_by(id = user_id ).first() 
        s.close()
        if start_date == "1970-01-01":
            start_date = ""
        if end_date == "3000-12-31":
            end_date = ""
        self.render("user_OBDList.html",user_infos = user_infos, page_index = page_index,count = count,limit = limit, keyword = keyword, start_date = start_date, end_date = end_date, pictures = pictures)
Beispiel #5
0
    def get(self):
        self.xsrf_form_html()
        page_index = int(self.get_argument("page", default="1"))
        limit = int(self.get_argument("limit", default="30"))
        keyword = self.get_argument("keyword", default="")
        # data = tornado.escape.json_decode(self.request.body)
        # if "page" in self.request.arguments:      #pyhton3 新特性不支持has_key
        #page_index = int(self.get_argument("page",default="1"))
        # if "limit" in self.request.arguments:
        #page_size = int(self.get_argument("limit",default="15"))

        filters = {
            db.or_(
                db.Manager.id.like("%" + keyword + "%"),
                db.Manager.email.like("%" + keyword + "%"),
                db.Manager.managername.like("%" + keyword + "%"),
            ),
            # db.User.create_time.between(create_time+"00:00:00",last_login+"00:00:00"),
        }
        s = db.session()
        count = s.query(db.Manager).filter(*filters).count()
        if page_index < 1 or count == 0:
            page_index = 1
        elif limit * page_index > count:
            page_index = int((count + limit - 1) / limit)

            #asc升序
        #users = s.query(db.User).order_by(db.User.create_time.desc()).filter(*filters).limit(page_size).offset((page_index-1)*page_size).all()
        managers = s.query(db.Manager).order_by(
            db.Manager.create_time.desc()).filter(
                *filters).limit(limit).offset((page_index - 1) * limit).all()
        s.close()
        self.render("managers_management.html",
                    page_index=page_index,
                    count=count,
                    limit=limit,
                    keyword=keyword,
                    managers=managers)
Beispiel #6
0
    def post(self):
        self.xsrf_form_html()
        obd = self.get_argument("obd",default="excl")
        page_index = int(self.get_argument("page",default="1"))
        limit = int(self.get_argument("limit",default="30"))
        is_correct = int(self.get_argument("is_correct",default="1"))
        keyword = self.get_argument("keyword",default="")
        start_date = self.get_argument("start_date",default="1970-01-01")
        end_date = self.get_argument("end_date",default="3000-12-31")
        ids = self.get_argument("ids",default="")
        idslist = ids.split(',')
        # 时间判断
        if start_date == "":
            start_date = default="1970-01-01"
        if end_date == "":
            end_date = default="3000-12-31"
        print(ids)
        # 数据判断条件
        if idslist != ['']:
            filters = {db.Picture.id.in_(idslist)}
        else:
            filters = {
                db.or_(db.Picture.name.like('%'+keyword+'%'),
                       db.Picture.code.like('%'+keyword+'%'),
                       db.Picture.address.like('%'+keyword+'%'),
                       ),
                db.Picture.create_time.between(start_date+" 00:00:00", end_date+" 23:59:59")
            }
        s=db.session()

        # count = s.query(db.Picture).filter(*filters).count()
        
        # if page_index < 1 or count == 0:
        #     page_index = 1
        # elif limit*page_index > count:
        #     page_index = int((count + limit -1) / limit);
        
        #asc升序
        # 这样子写的话输出就是正常的list内容
        # pictures = s.query(db.Picture.id,
        #                    db.Picture.code,
        #                    db.Picture.name,
        #                    db.Picture.address,
        #                    db.Picture.GPS,
        #                    db.Picture.port_direction,
        #                    db.Picture.zero_port_pos,
        #                    db.Picture.port_sort,
        #                    db.Picture.picture_path,
        #                    db.Picture.confirmed_picture_path,
        #                    db.Picture.ports_occupy,
        #                    db.Picture.is_correct,
        #                    db.Picture.uncorrect_msg,
        #                    db.Picture.create_time,
        #                    db.Picture.update_time,
        #                    db.Picture.user_id,
        #                    db.Picture.manager_id).order_by(db.Picture.create_time.desc()).filter(*filters).all()
        pictures = s.query(db.Picture).order_by(db.Picture.create_time.desc()).filter(*filters).all()
        s.close()

        print(pictures)
        #导出excl或图片zip数据
        path = 'tmp'
        if obd == 'imgzip':
            filename = patch2imgzip(pictures,path)
        else:
            filename = patch2excl(pictures,path)
        self.write({"filename":filename})