Beispiel #1
0
    def exSql(self, moreCheck, c):

        for i in range(0, len(moreCheck[1])):
            try:
                isql = (
                    "insert into fetchcard VALUES ("
                    + str(moreCheck[1][i].id)
                    + ","
                    + str(moreCheck[1][i].userId)
                    + ","
                    + str(moreCheck[1][i].parentUserId)
                    + ',"'
                    + moreCheck[1][i].cardCode
                    + '","'
                    + moreCheck[1][i].userName
                    + '","'
                    + moreCheck[1][i].parentName
                    + '","'
                    + str(moreCheck[1][i].actionType)
                    + '","'
                    + str(moreCheck[1][i].usertype)
                    + '","'
                    + moreCheck[1][i].positionName
                    + '","'
                    + moreCheck[1][i].departmentName
                    + '","'
                    + moreCheck[1][i].userNameUnison
                    + '")'
                )
            except Exception as e:
                print e
            pubAction.sqliteConnect([isql, c])
Beispiel #2
0
    def fetchCard(self, event):

        gardenId = self.messageGardenId.GetValue()
        if gardenId == "":
            pubAction.dialog(self, u"没输入幼儿园ID")
            return

        messageIp = self.messageIp.GetValue()
        if messageIp == "":
            pubAction.dialog(self, u"没输入IP")
            return

        url = "http://" + messageIp + "/http_invoke"
        s = pubAction.SysConstants()[2]
        headers = pubAction.SysConstants()[3]
        s.headers.update(headers)
        try:
            s.get(url)
            self.buttonFetchCard.Disable()
            self.buttonFetchCard
            getGardenName = self.registerCheckinMachine(gardenId)[0]
            wx.StaticText(self.panelRight, -1, getGardenName, (382, 218))
            usql = "update checktable SET gardenid = " + '"' + gardenId + '",gardenname =' + '"' + getGardenName + '"'

            pubAction.sqliteConnect([usql, 1])

            checkParemeter = [0, url, s]
            moreCheck = self.chackMoreAction(checkParemeter)
            count = 0
            dsql = "delete from fetchcard"
            pubAction.sqliteConnect([dsql, 1])

            while moreCheck[2]:
                self.exSql(moreCheck, 0)
                count = len(moreCheck[1]) + count
                checkParemeter = [moreCheck[0], url, s]
                moreCheck = self.chackMoreAction(checkParemeter)

            else:
                self.exSql(moreCheck, 1)
                count = len(moreCheck[1]) + count
                pubAction.dialog(self, u"幼儿园:" + getGardenName + u",同步完成,总计" + str(count) + u"个卡号")
        except Exception as e:
            pubAction.dialog(self, u"无法连接服务器")
Beispiel #3
0
    def getGardenName(self):

        sql = "select count(gardenname) from checktable"
        rsql = pubAction.sqliteConnect([sql, 0])
        if rsql != False:
            for gCount in rsql:
                if gCount[0] == 0:
                    gardenName = ""
                else:
                    sgSql = "select gardenname from checktable"
                    resSgSql = pubAction.sqliteConnect([sgSql, 0])
                    for reGardenName in resSgSql:
                        # print reGardenName[0]
                        gardenName = reGardenName[0]
        elif not rsql:
            initSql = pubAction.checkSql()
            for sql in initSql:
                pubAction.sqliteConnect([sql, 1])
                gardenName = ""
        pubAction.sqliteConnect(["", 2])
        return gardenName
Beispiel #4
0
    def checkIn(self, event):

        messageIp = self.messageIp.GetValue()
        messageGardenId = self.messageGardenId.GetValue()
        messageCustId = self.messageCustId.GetValue()
        messageCardCode = self.messageCardCode.GetValue()
        messageDateYear = self.messageDateYear.GetValue()
        messageDateMonth = self.messageDateMonth.GetValue()
        messageDateDay = self.messageDateDay.GetValue()
        messageDateHour = self.messageDateHour.GetValue()
        messageDateMinute = self.messageDateMinute.GetValue()
        messageDateSecond = self.messageDateSecond.GetValue()

        if messageIp == "":
            pubAction.dialog(self, u"没输入IP")
            return
        if messageGardenId == "":
            pubAction.dialog(self, u"没输入幼儿园ID")
            return
        if messageCustId == "":
            pubAction.dialog(self, u"没输入用户ID")
            return
        if messageCardCode == "":
            pubAction.dialog(self, u"没输入卡号")
            return
        if messageDateYear == "":
            messageDateYear = pubAction.getTime()[1]
        if messageDateMonth == "":
            messageDateMonth = pubAction.getTime()[2]
        if messageDateDay == "":
            messageDateDay = pubAction.getTime()[3]
        if messageDateHour == "":
            messageDateHour = pubAction.getTime()[4]
        if messageDateMinute == "":
            messageDateMinute = pubAction.getTime()[5]
        if messageDateSecond == "":
            messageDateSecond = pubAction.getTime()[6]

        mTime = datetime.datetime.now().microsecond
        imputDateTime = datetime.datetime(
            year=int(messageDateYear),
            month=int(messageDateMonth),
            day=int(messageDateDay),
            hour=int(messageDateHour),
            minute=int(messageDateMinute),
            second=int(messageDateSecond),
        )
        formatTime = long(round(time.mktime(imputDateTime.timetuple())))
        nowTime = long(str(formatTime) + str(mTime / 1000))
        # nowTime = long(round(time.time()*1000))

        reList = []
        countSql = "select count(*) from fetchcard"
        countRes = pubAction.sqliteConnect([countSql, 0])
        for checkCout in countRes:
            if checkCout[0] == 0:
                pubAction.dialog(self, u"先同步幼儿园卡号")
                self.messageResoult.SetValue(u"false")
            else:
                sSqlC = 'select count(*) from fetchcard where cardcode = "' + messageCardCode + '"'
                sSqlU = 'select count(*) from fetchcard where userid = "' + messageCustId + '"'
                sSqlG = 'select count(*) from checktable where gardenid = "' + messageGardenId + '"'
                reCheckGardenId = pubAction.sqliteConnect([sSqlG, 0])
                reCheckCardCode = pubAction.sqliteConnect([sSqlC, 0])
                reCheckUserId = pubAction.sqliteConnect([sSqlU, 0])

                for checkGardenId in reCheckGardenId:
                    if checkGardenId[0] == 0:
                        reList.append(checkGardenId[0])
                    else:
                        reList.append(1)
                for checkCardCode in reCheckCardCode:
                    if checkCardCode[0] == 0:
                        reList.append(checkCardCode[0])
                    else:
                        reList.append(1)
                for checkUserId in reCheckUserId:
                    if checkUserId[0] == 0:
                        reList.append(checkUserId[0])
                    else:
                        reList.append(1)
                if reList[0] == 0:
                    pubAction.dialog(self, u"没有同步ID为:" + str(messageGardenId) + u" 幼儿园的数据,或幼儿园ID错误")
                    self.messageResoult.SetValue(u"false")
                elif reList[1] == 0:
                    pubAction.dialog(
                        self, u"在ID为:" + str(messageGardenId) + u"的幼儿园中找不到卡号为:" + str(messageCardCode) + u" 的用户"
                    )
                    self.messageResoult.SetValue(u"false")
                elif reList[2] == 0:
                    pubAction.dialog(
                        self, u"在ID为:" + str(messageGardenId) + u"的幼儿园中找不到ID为:" + str(messageCustId) + u" 的用户"
                    )
                    self.messageResoult.SetValue(u"false")
                else:
                    url = "http://" + messageIp + "/http_invoke"
                    s = pubAction.SysConstants()[2]
                    headers = pubAction.SysConstants()[3]
                    s.headers.update(headers)
                    try:
                        s.get(url)
                        self.buttonSendMessage.Disable()
                        messageAttach = wjy_pb2.Attach()
                        messageAttach.fileurl = "0998c950-93d5-4ad5-8590-518dec6d1f57"
                        messageAttach.attachType = long("1")

                        ##########Checkin
                        messageCheckin = wjy_pb2.Checkin()
                        messageCheckin.id = long("12313131321")
                        messageCheckin.cardCode = str(messageCardCode)
                        # 10000004
                        messageCheckin.attach.fileurl = messageAttach.fileurl
                        messageCheckin.attach.attachType = messageAttach.attachType
                        messageCheckin.userId = long(messageCustId)
                        # 2290987
                        messageCheckin.checkinTime = long(nowTime)
                        messageCheckin.gardenId = long(messageGardenId)

                        ##########CheckinRequest
                        machineCheckin = wjy_pb2.CheckinRequest()
                        machineCheckin.machineId = "test001test0001"

                        checkIn = machineCheckin.checkin.add()
                        checkIn.id = messageCheckin.id
                        checkIn.cardCode = messageCheckin.cardCode
                        checkIn.attach.fileurl = messageCheckin.attach.fileurl
                        checkIn.userId = messageCheckin.userId
                        checkIn.attach.attachType = messageCheckin.attach.attachType
                        checkIn.checkinTime = messageCheckin.checkinTime
                        checkIn.gardenId = messageCheckin.gardenId
                        # print machineCheckin

                        ##########MessageRequest
                        bodyMessageString = machineCheckin.SerializeToString()

                        postMessage = pubAction.mainMessageRequest(["/checkin", "", "", bodyMessageString, url, s, ""])
                        invoke = pubAction.mainMessageResponse(postMessage)

                        if postMessage.status_code == 200:
                            self.messageResoult.SetValue(u"success")
                            sSqlUname = "select username from fetchcard where userid = " + '"' + messageCustId + '"'
                            sUserName = pubAction.sqliteConnect([sSqlUname, 0])
                            for userName in sUserName:
                                if userName[0] != "":
                                    pubAction.dialog(
                                        self, u"用户ID:" + str(messageCustId) + u",用户名:" + userName[0] + u",签到成功"
                                    )
                                    self.buttonSendMessage.Enable()
                                else:
                                    pubAction.dialog(
                                        self, u"用户ID:" + str(messageCustId) + u",用户名:" + userName[0] + u",签到失败"
                                    )
                        else:
                            self.messageResoult.SetValue(u"error:" + str(postMessage.status_code))
                    except Exception as e:
                        pubAction.dialog(self, u"无法连接服务器")
        pubAction.sqliteConnect(["", 2])