Beispiel #1
0
def get_alarmId(timestamp=None):

    if timestamp is None:
        timestamp = timestamp

    tmp_time = TimeHelper.get_time_from_timestamp(timestamp)
    timestamp = TimeHelper.get_timestamp_from_time(assigned_time=tmp_time)
    part_1 = TimeHelper.get_time_from_timestamp(timestamp=timestamp, time_format="%Y-%m-%d_%H-%M-%S")
    part_2 = StringHelper.random_digit(100,999)
    part_3 = StringHelper.random_digit(1000,9999)
    part_4 = StringHelper.random_digit(0,9)
    return "{}_{}_{}_{}".format(part_1, part_2, part_3, part_4)
Beispiel #2
0
def random_publicDevice_deviceCode(length=None):
    if not length:
        length=14
    return StringHelper.get_random_normalString(length)
Beispiel #3
0
def random_iotUser_userEmail():

    return StringHelper.get_random_email()
Beispiel #4
0
def random_node_secondPartnerName():
    return "二级合作方{}".format(StringHelper.get_random_normalString(10))
Beispiel #5
0
    def scn_device_auth(self,
                        deviceCode,
                        data=None,
                        headers=None,
                        res_accurate=False,
                        business_exception=False):
        '''

        :param headers:
        :param deviceCode: 设备编码
        :param data: 数据加密
        :param res_accurate:
        :param business_exception:
        :return:
        '''

        # 参数化
        deviceCode = deviceCode

        json_dict = {
            "equno": deviceCode,
            "time": TimeHelper.get_time_from_timestamp(),
            "randCode": StringHelper.random_string(16)
        }

        publicKey = utils.get_publicKey_from_mysql(deviceCode)
        # RSA加密方法
        rsa = utils.RSA()

        data = rsa.rsa_pubkey_encrypt(publicKey, json.dumps(json_dict))

        # 发送业务请求
        res_json = self.bns_device_auth(
            headers=headers,
            deviceCode=deviceCode,
            data=data,
        )

        # 定义一个http状态码的白名单, 如果状态码不在白名单中,则直接返回
        white_list = [200, 201]
        # 获取当前请求的http状态码
        http_code = JsonHelper.parseJson_by_objectpath(res_json,
                                                       "$.response_code")
        # 如果请求返回的状态码不是期望的http状态码, 则直接返回该状态码
        if http_code not in white_list:
            return res_json

        # 提取业务码
        actually_business_code = JsonHelper.parseJson_by_objectpath(
            res_json, "$.response_data.resultCode")
        # 异常码集合
        exception_list = [
            # 400004,   # 设备类型不合法
        ]

        # 正常业务状态码下, 函数的返回信息
        if actually_business_code == 0:

            # 解析返回信息或调用自定义函数
            data = JsonHelper.parseJson_by_objectpath(res_json,
                                                      "$.response_data.data")
            res = rsa.rsa_pubkey_decrypt(publicKey, data)  # 解密接口返回的信息

            # 精确返回的内容
            if res_accurate:
                pass
                # return deviceCode

            # 全部信息返回
            info_dict = json.loads(res)
            return info_dict if info_dict else JsonHelper.parseJson_by_objectpath(
                res_json, "$.response_data")

        # 异常业务状态码下(已知异常), 函数的返回信息
        elif actually_business_code in exception_list:

            if business_exception:
                raise DefinedBusinessException("接口已知业务异常:设备鉴权")

            return JsonHelper.parseJson_by_objectpath(res_json,
                                                      "$.response_data")

        # 异常业务状态码下(未知异常), 函数的返回信息
        else:
            raise UndefinedBusinessException("接口未知业务异常:设备鉴权")
Beispiel #6
0
def random_node_nodeName():
    return "抓拍子节点{}".format(StringHelper.get_random_normalString(10))
Beispiel #7
0
def random_node_brandName():
    return "品牌名称{}".format(StringHelper.get_random_normalString(10))
Beispiel #8
0
def random_iotDevice_approvalSuggestion():
    return "申请单审批建议{}".format(StringHelper.get_random_normalString(10))
Beispiel #9
0
def get_member_membercardNo():
    return "会员卡号{}" .format(StringHelper.get_random_normalString(10))
Beispiel #10
0
def random_member_membername():
    return "会员姓名{}" .format(StringHelper.get_random_normalString(10))
Beispiel #11
0
def random_memberlevel_levelName():
    return "会员级别{}".format(StringHelper.get_random_normalString(6))
Beispiel #12
0
def random_node_floorName():
    return "楼层节点{}".format(StringHelper.get_random_normalString(10))
Beispiel #13
0
def random_node_thirdPartnerName():
    return "三级合作方{}".format(StringHelper.get_random_normalString(10))
Beispiel #14
0
def random_iotDevice_deviceBarCode(length=None):
    if not length:
        length=10
    return StringHelper.get_random_normalString(length)
Beispiel #15
0
def random_employee_remark():
    return "店员备注{}" .format(StringHelper.get_random_normalString(10))
Beispiel #16
0
def random_iotDevice_applyDesc():
    return "申请设备下架{}".format(StringHelper.get_random_normalString(10))
Beispiel #17
0
def random_employee_employeename():
    return "店员姓名{}" .format(StringHelper.get_random_normalString(10))
Beispiel #18
0
def random_device_deviceName():
    return "设备名称{}".format(StringHelper.get_random_normalString(10))
Beispiel #19
0
def random_operateUser_userName():

    return "人员名字{}".format(StringHelper.get_random_normalString(5))
Beispiel #20
0
def random_node_shopName():
    return "门店名称{}".format(StringHelper.get_random_normalString(10))
Beispiel #21
0
def random_iotUser_userName():

    return "人员名字{}".format(StringHelper.get_random_normalString(7))
Beispiel #22
0
def random_node_collectNodeName():
    return "汇总节点{}".format(StringHelper.get_random_normalString(10))
Beispiel #23
0
def random_iotUser_userPhone():

    return StringHelper.get_random_phoneno()
Beispiel #24
0
    def scn_employee_add(self,
                         mallareaCode,
                         faceId,
                         imagePath,
                         headers=None,
                         employeename=None,
                         phoneNo=None,
                         sex=None,
                         age=None,
                         remark=None,
                         res_accurate=False,
                         business_exception=False):
        '''

        :param headers:
        :param mallareaCode: 门店编码
        :param employeename: 店员姓名
        :param phoneNo: 手机号码
        :param faceId: 人脸faceId
        :param imagePath: 图片路径
        :param sex: 性别
        :param age: 年龄
        :param remark: 备注
        :param res_accurate:
        :param business_exception:
        :return:
        '''

        # 参数化
        if employeename is None:
            employeename = gen_bnsData.random_employee_employeename()
        if phoneNo is None: phoneNo = StringHelper.get_random_phoneno()
        if remark is None: remark = gen_bnsData.random_employee_remark()

        # 发送业务请求
        res_json = self.bns_employee_add(
            headers=headers,
            mallareaCode=mallareaCode,
            employeename=employeename,
            phoneNo=phoneNo,
            faceId=faceId,
            imagePath=imagePath,
            sex=sex,
            age=age,
            remark=remark,
        )

        # 定义一个http状态码的白名单, 如果状态码不在白名单中,则直接返回
        white_list = [200, 201]
        # 获取当前请求的http状态码
        http_code = JsonHelper.parseJson_by_objectpath(res_json,
                                                       "$.response_code")
        # 如果请求返回的状态码不是期望的http状态码, 则直接返回该状态码
        if http_code not in white_list:
            return res_json

        # 提取业务码
        actually_business_code = JsonHelper.parseJson_by_objectpath(
            res_json, "$.response_data.code")
        # 异常码集合
        exception_list = [
            # 400004,   # 设备类型不合法
        ]

        # 正常业务状态码下, 函数的返回信息
        if actually_business_code == 0:

            # 解析返回信息或调用自定义函数

            # 精确返回的内容
            if res_accurate:
                pass
                # return deviceCode

            # 全部信息返回
            info_dict = dict()
            if mallareaCode is not None:
                info_dict.setdefault('mallareaCode', mallareaCode)
            if employeename is not None:
                info_dict.setdefault('employeename', employeename)
            if phoneNo is not None: info_dict.setdefault('phoneNo', phoneNo)
            if faceId is not None: info_dict.setdefault('faceId', faceId)
            if imagePath is not None:
                info_dict.setdefault('imagePath', imagePath)
            if sex is not None: info_dict.setdefault('sex', sex)
            if age is not None: info_dict.setdefault('age', age)
            if remark is not None: info_dict.setdefault('remark', remark)
            return info_dict if info_dict else JsonHelper.parseJson_by_objectpath(
                res_json, "$.response_data")

        # 异常业务状态码下(已知异常), 函数的返回信息
        elif actually_business_code in exception_list:

            if business_exception:
                raise DefinedBusinessException("接口已知业务异常:新增店员")

            return JsonHelper.parseJson_by_objectpath(res_json,
                                                      "$.response_data")

        # 异常业务状态码下(未知异常), 函数的返回信息
        else:
            raise UndefinedBusinessException("接口未知业务异常:新增店员")
Beispiel #25
0
def random_node_firstPartnerName():
    return "一级合作方{}".format(StringHelper.get_random_normalString(10))