コード例 #1
0
def _exit_cb(srv, item, payload):
    try:
        data = payload[KETUO_EXIT_TYPE]
        park_id = int(data['parkID'])
        event_type = data['eventType']
        fields = data['data']

        car_no = fields['carPatenum']
        parking_id = fields['id']
        entry_time = fields['comeTime']
        entry_time = str2datetime(entry_time)
        exit_time = fields['outTime']
        exit_time = str2datetime(exit_time)
        exit_code = fields['outPlace']
        duration = (exit_time - entry_time).total_seconds() / 60

        pay_money = float(fields['payMoney'])
        pre_money = float(fields['preMoney'])
        ticket = float(fields['ticket'])
        total_money = float(fields['totalMoney'])
        in2out_money = float(fields['InToOutMoney'])
        fee = in2out_money if in2out_money >= total_money else total_money
        if pre_money > fee:
            fee = pre_money
        elif ticket > fee:
            fee = ticket
        elif pay_money > fee:
            fee = pay_money
    except Exception, e:
        message = "[EXIT_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #2
0
ファイル: pama.py プロジェクト: zhanglao112/justsync
def _exit_cb(srv, item, payload):
    try:
        data = payload['Data']
        parking_id = data["inLogId"]
        car_no = data["plateNumber"]
        exit_code = data["entranceCode"]

        entry_time = data["inTime"]
        entry_time = str2datetime(entry_time)
        exit_time = data["outTime"]
        exit_time = str2datetime(exit_time)

        card_type = (0 if int(data["carType"]) == 0 else 3)
        duration = int(data["duration"])
        fee = float(data["due"])
        park_id = int(data["parkId"])
    except Exception, e:
        _ack(srv, item, payload, True)
        message = "[EXIT_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #3
0
ファイル: lifang.py プロジェクト: zhanglao112/justsync
def _exit_cb(srv, item):
    try:
        data = item.data[LIFANG_EXIT_TYPE]
        event_type = data['eventType']
        fields = data['data']

        car_no = fields['CarCode']
        entry_time = fields['InTime']
        entry_time = str2datetime(entry_time)
        exit_time = fields['OutEventTime']
        exit_time = str2datetime(exit_time)
        exit_code = ''
        duration = fields['StopTime']
        fee = float(fields['Amount'])

        parking_id = 'YY_UNUSED'
        park_id = int(data['parkID'])
    except Exception, e:
        message = "[EXIT_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #4
0
ファイル: pama.py プロジェクト: zhanglao112/justsync
def _entry_cb(srv, item, payload):
    try:
        data = payload['Data']
        park_id = int(data['parkId'])
        parking_id = data['logId']
        car_no = data['plateNumber']
        entry_code = data['entranceCode']
        entry_time = data['time']
        entry_time = str2datetime(entry_time)
        card_type = (0 if int(data['carType']) == 0 else 3)
    except Exception, e:
        _ack(srv, item, payload, True)
        message = "[ENTRY_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #5
0
ファイル: pama.py プロジェクト: zhanglao112/justsync
def _fee_cb(srv, item, payload):
    try:
        data = payload['Data']
        car_no = data['plateNumber']
        fee = data['price']

        fee_time = data['endTime']
        fee_time = str2datetime(fee_time)

        result = int(data['retcode'])  # FIXME: protocol doc is retCode
        park_id = int(data['parkId'])
    except Exception, e:
        message = "[FEE_CB] payload [%s] catch exception [%s]" % (str(payload),
                                                                  str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #6
0
ファイル: lifang.py プロジェクト: zhanglao112/justsync
def _entry_cb(srv, item, payload):
    try:
        data = payload[LIFANG_ENTRY_TYPE]
        event_type = data['eventType']
        fields = data['data']
        car_no = fields['CarCode']
        entry_time = fields['Crdtm']
        entry_time = str2datetime(entry_time)
        entry_code = fields['ChannelID']
        parking_id = str(fields['RecordID'])
        park_id = int(data['parkID'])
        card_type = 2
    except Exception, e:
        message = "[ENTRY_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #7
0
def _entry_cb(srv, item, payload):
    try:
        data = payload[KETUO_ENTRY_TYPE]
        event_type = data['eventType']
        fields = data['data']

        car_no = fields['carPlateNum']
        entry_time = fields['comeTime']
        entry_time = str2datetime(entry_time)
        entry_code = fields['caremaId']
        parking_id = str(fields['id'])
        park_id = int(data['parkID'])
        card_type = int(fields['carType'])
    except Exception, e:
        message = "[ENTRY_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #8
0
ファイル: xixiangfeng.py プロジェクト: zhanglao112/justsync
def _parking_cb(srv, item, payload):
    try:
        data = payload[XIXIANGFENG_PARKING_TABLE]
        event_type = data['eventType']
        fields = data['data']
        car_no = fields['car_cp']

        entry_time = fields['in_time']
        entry_time = str2datetime(entry_time)

        entry_code = fields['in_sbname']
        parking_id = str(fields['parked_id'])
        park_id = int(data['parkID'])
        card_type = 2 if fields['card_kind'] == '月租卡' else 0
    except Exception, e:
        message = "[PARKING_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False
コード例 #9
0
ファイル: xixiangfeng.py プロジェクト: zhanglao112/justsync
        card_type = 2 if fields['card_kind'] == '月租卡' else 0
    except Exception, e:
        message = "[PARKING_CB] payload [%s] catch exception [%s]" % (
            str(payload), str(e))
        do_log(srv, item, "WARN", LOG_T_LOCAL, message)
        return False

    notified = True
    parking_info = ParkingInfo(park_id, parking_id, car_no, card_type)
    if event_type.upper() == 'INSERT':
        parking_info.set_entry(entry_time, entry_code)
        notified = handle_entry(srv, item, parking_info)
    elif event_type.upper() == 'UPDATE' and fields['out_time'] <> 'null':
        try:
            exit_time = fields['out_time']
            exit_time = str2datetime(exit_time)

            exit_code = fields['out_sbname']
            duration = (exit_time - entry_time).total_seconds() / 60
            fee = float(fields['CentreReceiveMoney']) * 10
        except Exception, e:
            message = "[PARKING_CB] payload [%s] catch exception [%s]" % (
                str(payload), str(e))
            do_log(srv, item, "WARN", LOG_T_LOCAL, message)
            return False

        parking_info.set_exit(exit_time, duration, fee, exit_code)
        notified = handle_exit(srv, item, parking_info)
    else:
        pass