Esempio n. 1
0
def updateOperationFarmRecordInDb(houseCode, time, desc):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        # cursor.execute('select * from ' + Conf.plantHistoryGrowInfoTable );
        # insert into data_order(GreenhouseCode,ActorCode,ActionCode,ActionParameter1 VALUES
        recordFormat = "({0},'{1}','{2}')"
        values = str.format(recordFormat, houseCode, str(time), str(desc))
        print values
        #sql = 'insert into  data_order (GreenHouseCode, ActorCode, ActionCode, actionParameter1) values  ' + values;
        sql = "insert into Journal_WorkTask (GreenhouseCode,JournaTime,JournaContent) values " + values
        print sql
        # cursor.execute('insert into  data_order (GreenHouseCode, ActorCode, ActionCode, ) values  (1001)' );
        cursor.execute(sql)
        conn.commit()
        # values = cursor.fetchall();
        # for d in values:
        #   print d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],d[8],d[9],d[10],d[11]
        # return values;
        # print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 2
0
def selectFromInfoTable():
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        cursor.execute('select * from ' + Conf.greenHouseInfoTable)
        values = cursor.fetchall()
        return values
        #print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 3
0
def selectGrowInfoFromTable():
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        cursor.execute('select * from ' + Conf.plantBestGrowInfoTable)
        values = cursor.fetchall()
        #for d in values:
        #print d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9],d[10],d[11],d[12],d[13],d[14],d[15]
        return values
    except Exception as e:
        print "get grow optimal Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 4
0
def selectNowGrowStateInfo(houseCode):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        #cursor.execute('select * from ' + Conf.nowGrowStateTable + ' where greenhousecode in(1001,1002,1003,1004)')
        cursor.execute("select * from  " + Conf.nowGrowStateTable +
                       " where greenhousecode in({})".format(houseCode))
        values = cursor.fetchall()
        return values
        # print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 5
0
def selectAlarmingRecord(code):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        #cursor.execute('select * from  '+ farmingRecordTable + '  where GreenhouseCode= %s '+' order by ALARMDATE desc limit 8',(code))
        cursor.execute(
            'SELECT * FROM v_di_alarm where GreenhouseCode=%s order by ALARMDATE desc limit 8',
            code)
        values = cursor.fetchall()
        return values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 6
0
def selectDeviceStateInfo(houseCodes):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        # cursor.execute('select * from ' + Conf.plantHistoryGrowInfoTable );
        cursor.execute("select * from  " + Conf.deviceStateTable +
                       " where greenhousecode in({})".format(houseCodes))
        values = cursor.fetchall()
        # for d in values:
        #   print d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],d[8],d[9],d[10],d[11]
        return values
        # print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 7
0
def selectPlantHourOptimalFactor(plantCodes):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        #cursor.execute('select * from ' + Conf.allPlantsOptimalTable)
        cursor.execute("select * from  " + Conf.plantHourOptimalTable +
                       " where growthmodelcode in({})".format(plantCodes))
        values = cursor.fetchall()
        #for d in values:
        #   print d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14]
        return values
        # print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 8
0
def selectActualTimeGrowInfo(houseCode):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        print(houseCode)
        #cursor.execute('select * from ' + Conf.plantActualTimeGrowInfoTable + ' where greenhousecode in(1001,1002,1003,1004)')
        cursor.execute("select * from  " + Conf.plantActualTimeGrowInfoTable +
                       " where greenhousecode in({})".format(houseCode))
        values = cursor.fetchall()
        #for d in values:
        #print d[0], d[1], d[2], d[3], d[4], d[5],d[6],d[7],d[8],d[9]
        return values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()
Esempio n. 9
0
def updateOrderInDb(houseCode, actorCode, action, time):
    conn = POOL.connection()
    cursor = conn.cursor()
    try:
        # cursor.execute('select * from ' + Conf.plantHistoryGrowInfoTable );
        #insert into data_order(GreenhouseCode,ActorCode,ActionCode,ActionParameter1 VALUES
        orderFormat = "({0},{1},{2},{3})"
        values = str.format(orderFormat, houseCode, actorCode, action, time)
        print values
        sql = 'insert into  data_order (GreenHouseCode, ActorCode, ActionCode, actionParameter1) values  ' + values
        print sql
        #cursor.execute('insert into  data_order (GreenHouseCode, ActorCode, ActionCode, ) values  (1001)' );
        cursor.execute(sql)
        conn.commit()
        #values = cursor.fetchall();
        # for d in values:
        #   print d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],d[8],d[9],d[10],d[11]
        #return values;
        # print values
    except Exception as e:
        print "Exception: " + traceback.print_exc()
    finally:
        cursor.close()
        conn.close()