iceClientUtil.py 2.03 KB
import logging
import pandas as pd
import sys,traceback,Ice
Ice.loadSlice("--all -I.. ice/bsd.ice")
Ice.loadSlice("--all -I.. ice/Hdao_gps.ice")
Ice.loadSlice("--all -I.. --underscore ice/district.ice")
Ice.loadSlice("--all -I.. --underscore ice/ipoi.ice")
Ice.loadSlice("--all -I.. --underscore ice/HDao_mile.ice")
import datetime
import BaseStationData
import HDaoGps,HDaoMile
import DISTRICT
import pymysql
import POI

print("sys config " + __name__)
log_name = './log/iceinvoker/iceclientutl.log'
log_format = '[%(asctime)s-%(filename)s-%(levelname)s:%(message)s]'
log_level = logging.DEBUG
log_mode = 'a'
logging.basicConfig(filename=log_name, format=log_format, level=log_level, filemode=log_mode)

class IceClientUtil:

    # env_host = "192.168.3.101"
    # env_host = "192.168.5.31"
    env_host = "192.168.5.26"
    daoGpsServicePrx = None

    def __init__(self, handle_month):
        logging.info("init construct bean")
        self.handleDescription = "dj renewal match iccid and device location"

        self.handleMonth = handle_month
        self.hmonth = handle_month.replace('-', '')[2:6]

        with Ice.initialize(sys.argv) as communicator:
                obj = communicator.stringToProxy(f'HDaoGpsSvc:default -h {self.env_host} -p 23469')
                obj.ice_ping()
                self.daoGpsServicePrx = HDaoGps.DaoGpsServicePrx.checkedCast(obj)

    def getLatestGpsRecord(self, sn,type = 5):
        try:
            if not self.daoGpsServicePrx:
                raise RuntimeError("Invalid proxy")
            req = HDaoGps.LatestGpsGetRequest()
            req.userID = int(sn)
            req.apType = type
            req.extraMapReq = 0

            rsp = self.daoGpsServicePrx.getLatestGpsRecord(req)
            # print(rsp[1].gps.gpsTime)
            print(rsp)
            return rsp
        except:
            traceback.print_exc()
            return None
        
if __name__ == "__main__":
     iceClientUtil = IceClientUtil()

     sn = '561063062817521'
     gpsRecord = iceClientUtil.getLatestGpsRecord(sn)
     print(gpsRecord)