Ejemplo n.º 1
0
 def GetBookByName(self, keyword):
     mysql = Mysql()
     book_list = mysql.getAll("select * from book where bookname like '%" + keyword + "%'")
     mysql.dispose()
     if book_list == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(book_list)
     return tums
Ejemplo n.º 2
0
 def GetAllAdminRecord(self):
     '''
     :param Dict:
     输出admin表所有字段
     '''
     mysql = Mysql()
     sqlAll = "select * from admin"
     result = mysql.getAll(sqlAll)
     mysql.dispose()
     show = MiddleLayer()
     tums = show.ShowAdmin(result)
     return tums
Ejemplo n.º 3
0
 def GetUserIllegal(self, obj):
     # 拼接
     Seq = []
     Val = []
     if obj.get_illegalid() != '':
         Seq.append('illegalid')
         Val.append(obj.get_illegalid())
     if obj.get_userid() != '':
         Seq.append('userid')
         Val.append(obj.get_userid())
     if obj.get_bookid() != '':
         Seq.append('bookid')
         Val.append(obj.get_bookid())
     if obj.get_amount() != '':
         Seq.append('amount')
         Val.append(obj.get_amount())
     if obj.get_isprocessed() != '':
         Seq.append('isprocessed')
         Val.append(obj.get_isprocessed())
     if obj.get_illegaldate() != '':
         Seq.append('illegaldate')
         Val.append(obj.get_illegaldate())
     if obj.get_illegaltype() != '':
         Seq.append('illegaltype')
         Val.append(obj.get_illegaltype())
     Ile = dict(zip(Seq, Val))
     mysql = Mysql()
     sql = "select * from illegal where "
     keys = tuple(Ile.keys())
     vals = tuple(Ile.values())
     Len = len(Ile)
     for i in range(Len):
         if (i != Len - 1):
             sql = sql + keys[i] + "='" + str(vals[i]) + "' and "
         else:
             sql = sql + keys[i] + "='" + str(vals[i]) + "'"
     Ilegal = mysql.getAll(sql)
     if Ilegal == False:
         print("No Illegal record!")
     else:
         print("Illegal records:")
         if Ilegal:
             for row in Ilegal:
                 print("%s\t%s\t%s\t%s\t%s\t%s\t%s" %
                       (row[0], row[1], row[2], row[3], row[4], row[5],
                        row[6]))
     mysql.dispose()
     show = MiddleLayer()
     tums = show.ShowIllegal(Ilegal)
     return tums
Ejemplo n.º 4
0
 def GetAllIlegal(self, num):
     mysql = Mysql()
     if (str(num) == '0'):
         sqlAll = "select * from Illegal"
     else:
         sqlAll = "select * from Illegal limit " + str(num)
     result = mysql.getAll(sqlAll)
     # if result :
     #     for row in result :
     # print("%s\t%s\t%s\t%s\t%s\t%s\t%s" %(row[0],row[1],row[2],row[3],row[4],row[5],row[6]))
     mysql.dispose()
     show = MiddleLayer()
     tums = show.ShowIllegal(result)
     return tums
Ejemplo n.º 5
0
 def GetBorrowRecordByField(self, obj):
     # 拼接
     Seq = []
     Val = []
     if obj.get_borrowid() != '':
         Seq.append('borrowid')
         Val.append(obj.get_borrowid())
     if obj.get_userid() != '':
         Seq.append('userid')
         Val.append(obj.get_userid())
     if obj.get_bookid() != '':
         Seq.append('bookid')
         Val.append(obj.get_bookid())
     if obj.get_borrowdate() != '':
         Seq.append('borrowdate')
         Val.append(obj.get_borrowdate())
     if obj.get_presretdate() != '':
         Seq.append('presretdate')
         Val.append(obj.get_presretdate())
     if obj.get_actretdate() != '':
         Seq.append('actretdate')
         Val.append(obj.get_actretdate())
     Dict = dict(zip(Seq, Val))
     mysql = Mysql()
     sql = "select * from borrow where "
     keys = tuple(Dict.keys())
     vals = tuple(Dict.values())
     Len = len(Dict)
     for i in range(Len):
         if (i != Len - 1):
             sql = sql + keys[i] + "='" + str(vals[i]) + "' and "
         else:
             sql = sql + keys[i] + "='" + str(vals[i]) + "'"
     Bor = mysql.getAll(sql)
     if Bor == False:
         print('no record')
     # Book = mysql.getAll(sql)
     # if Book == False:
     #     print('no record')
     # if len(Book) == 0:
     #     print("No borrow record found!")
     # else:
     #     print("The borrow record you found:")
     #     if Book:
     #         for row in Book:
     #             print("%s\t%s\t%s\t%s\t%s\t%s" % (row[0], row[1], row[2], row[3], row[4], row[5]))
     mysql.dispose()
     show = MiddleLayer()
     tums = show.ShowBorrow(Bor)
     return tums
Ejemplo n.º 6
0
 def GetBookByDis(self, desci):
     mysql = Mysql()
     Dis_List = mysql.getAll("select * from book where discipline = '" + desci + "'")
     # print("Classification of " + desci + ":\n")
     # print("bookid\tbookname\tauthor\tpages\tcollecttime\tversion\tmajor\tdiscipline\tisbn\tbooklanguage\tpublisher\tstatus\tabstract\tstack\tshelf\tfloor\tbookvalue")
     # if Dis_List:
     #     for row in Dis_List:
     #         print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
     mysql.dispose()
     if Dis_List == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(Dis_List)
     return tums
Ejemplo n.º 7
0
 def RetureIllegalRecord(self):
     mysql = Mysql()
     # 获取系统时间
     systime = datetime.datetime.now().strftime('%Y-%m-%d')
     # 返回超过系统时间还未还的图书借阅记录
     # sql = "select * from borrow where actretdate < '" + systime + "' and presretdate = '0000-00-00'"
     sql = "select * from borrow where actretdate < '" + "1996-01-01" + "' and presretdate = '0000-00-00'"
     result = mysql.getAll(sql)
     mysql.dispose()
     if (result == False):
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBorrow(result)
     return tums
Ejemplo n.º 8
0
 def GetAllBookRecord(self, num=0):
     mysql = Mysql()
     if (str(num) == '0'):
         sqlAll = "select * from book"
     else:
         sqlAll = "select * from book limit " + str(num)
     result = mysql.getAll(sqlAll)
     # print("bookid\tbookname\tauthor\tpages\tcollecttime\tversion\tmajor\tdiscipline\tisbn\tbooklanguage\tpublisher\tstatus\tabstract\tstack\tshelf\tfloor\tbookvalue")
     # if result :
     #     for row in result :
     # print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %(row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
     mysql.dispose()
     if result == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBook(result)
     return tums
Ejemplo n.º 9
0
 def __init__(self, x):
     self.cnn1 = CNN(x, x.shape, (20, 1, 5, 5))
     self.cnn2 = CNN(self.cnn1.output, self.cnn1.output.shape,
                     (50, 20, 5, 5))
     middle_input = self.cnn2.output.flatten(2)
     self.mdl = MiddleLayer(middle_input, 50 * 4 * 4, 500)
     self.mlg = MultiLogisticRegression(self.mdl.y, 500, 10)
     self.pred = self.mlg.pred
     self.params = self.cnn1.params + self.cnn2.params + self.mdl.params + self.mlg.params
Ejemplo n.º 10
0
 def GetBorrowRecord(self, num=0):
     mysql = Mysql()
     if (str(num) == '0'):
         sqlAll = "select * from borrow"
     else:
         sqlAll = "select * from borrow limit " + str(num)
     result = mysql.getAll(sqlAll)
     print("borrowid\tuserid\tbookid\tborrowdate\tpresretdate\tactretdate")
     if result:
         for row in result:
             print("%s\t%s\t%s\t%s\t%s\t%s" % \
                   (row[0], row[1], row[2], row[3], row[4], row[5]))
     mysql.dispose()
     if result == False:
         print('no record')
         return 0
     show = MiddleLayer()
     tums = show.ShowBorrow(result)
     return tums
Ejemplo n.º 11
0
    def GetBookByField(self, obj):
        # 拼接成Dict函数
        # 例:{'bookid': '100014', 'author': '韩强军'}
        Seq = []
        Val = []
        if obj.get_bookid() != '':
            Seq.append('bookid')
            Val.append(obj.get_bookid())
        if obj.get_bookname() != '':
            Seq.append('bookname')
            Val.append(obj.get_bookname())
        if obj.get_author() != '':
            Seq.append('author')
            Val.append(obj.get_author())
        if obj.get_pages() != '':
            Seq.append('pages')
            Val.append(obj.get_pages())
        if obj.get_collecttime() != '':
            Seq.append('collecttime')
            Val.append(obj.get_collecttime())
        if obj.get_version() != '':
            Seq.append('version')
            Val.append(obj.get_version())
        if obj.get_major() != '':
            Seq.append('major')
            Val.append(obj.get_major())
        if obj.get_discipline() != '':
            Seq.append('discipline')
            Val.append(obj.get_discipline())
        if obj.get_isbn() != '':
            Seq.append('isbn')
            Val.append(obj.get_isbn())
        if obj.get_booklanguage() != '':
            Seq.append('booklanguage')
            Val.append(obj.get_booklanguage())
        if obj.get_publisher() != '':
            Seq.append('publisher')
            Val.append(obj.get_publisher())
        if obj.get_status() != '':
            Seq.append('status')
            Val.append(obj.get_status())
        if obj.get_abstract() != '':
            Seq.append('abstract')
            Val.append(obj.get_abstract())
        if obj.get_stack() != '':
            Seq.append('stack')
            Val.append(obj.get_stack())
        if obj.get_shelf() != '':
            Seq.append('shelf')
            Val.append(obj.get_shelf())
        if obj.get_floor() != '':
            Seq.append('floor')
            Val.append(obj.get_floor())
        if obj.get_bookvalue() != '':
            Seq.append('bookvalue')
            Val.append(obj.get_bookvalue())

        Dict = dict(zip(Seq, Val))

        mysql = Mysql()
        sql = "select * from book where "
        keys = tuple(Dict.keys())
        vals = tuple(Dict.values())
        Len = len(Dict)
        for i in range(Len):
            if (i != Len - 1):
                sql = sql + keys[i] + "='" + str(vals[i]) + "' and "
            else:
                sql = sql + keys[i] + "='" + str(vals[i]) + "'"
        Book = mysql.getAll(sql)
        if Book == False:
            print('no record')
            return 0
        # if len(Book) == 0:
        #     print("No books found!")
        # else:
        #     print("The book you found:")
        #     if Book:
        #         for row in Book:
        #
        #             print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" %\
        #                   (row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],\
        #                  row[9],row[10],row[11],row[12],row[13],row[14],row[15],row[16]))
        mysql.dispose()
        show = MiddleLayer()
        tums = show.ShowBook(Book)
        return tums
Ejemplo n.º 12
0
 def __init__(self, x, n_in, n_middle, n_out):
     self.mdl = MiddleLayer(x, n_in, n_middle)
     self.mlg = MultiLogisticRegression(self.mdl.y, n_middle, n_out)
     self.params = [self.mdl.W, self.mdl.b, self.mlg.W, self.mlg.b]
     self.pred = self.mlg.pred