def get(self):
        parser_ = SDRequestParser()
        parser_.add_argument("site_num", type=str, required=False)
        parser_.add_argument("date", type=str, required=True)

        params = parser_.parse_args()
        site_num = params['site_num']
        date = params['date']

        # 判断date是否合法
        if date is None or date == '' or (not str(date).startswith('2016') and
                                          not str(date).startswith('2018')):
            ret = SDCommonJsonRet(code=SDCodeMsg.PARAMS_ERROR.code,
                                  success=False,
                                  msg=SDCodeMsg.PARAMS_ERROR.msg,
                                  data=SDCodeMsg.PARAMS_ERROR.msg)
            ret = make_response(ret.toJsonStr())
            ret.headers['Access-Control-Allow-Origin'] = '*'
            return ret

        # 查询线路的所有站点列表
        site_totalNum_dict = sodaVisualizationService.querySiteTotalRecordsBySiteNumAndDate(
            site_num, date)

        # 判断站点数据是否为空,为空则返回错误
        if site_totalNum_dict is None or site_totalNum_dict == '' or len(
                site_totalNum_dict) == 0:
            ret = SDCommonJsonRet(
                code=SDCodeMsg.SITE_FLOW_RECORD_NOT_FOUND.code,
                success=False,
                msg=SDCodeMsg.SITE_FLOW_RECORD_NOT_FOUND.msg,
                data=SDCodeMsg.SITE_FLOW_RECORD_NOT_FOUND.msg)
        else:
            # 不为空,则返回数据
            ret = SDCommonJsonRet(code=SDCodeMsg.SUCCESS.code,
                                  success=True,
                                  msg=SDCodeMsg.SUCCESS.msg,
                                  data=site_totalNum_dict)
        ret = make_response(ret.toJsonStr())
        ret.headers['Access-Control-Allow-Origin'] = '*'
        return ret
    def get(self):
        parser_ = SDRequestParser()
        parser_.add_argument("site", type=str, required=True)
        parser_.add_argument("date", type=str, required=True)

        params = parser_.parse_args()
        site = params['site']
        date = params['date']

        # 查询当日当前站点人流量数据
        flow_data = sodaVisualizationService.queryPredictedFlowBySiteAndDate(
            site, date)

        # 判断人流量数据是否为空,为空则返回错误
        if flow_data is None or flow_data == '':
            ret = SDCommonJsonRet(code=SDCodeMsg.FLOW_RECORD_NOT_FOUND.code,
                                  success=False,
                                  msg=SDCodeMsg.FLOW_RECORD_NOT_FOUND.msg,
                                  data=SDCodeMsg.FLOW_RECORD_NOT_FOUND.msg)
        else:
            # 不为空,则返回数据
            ret = SDCommonJsonRet(code=SDCodeMsg.SUCCESS.code,
                                  success=True,
                                  msg=SDCodeMsg.SUCCESS.msg,
                                  data=flow_data.as_dict())
        ret = make_response(ret.toJsonStr())
        ret.headers['Access-Control-Allow-Origin'] = '*'
        return ret
    def get(self):
        parser_ = SDRequestParser()
        parser_.add_argument("site_num", type=str, required=False)

        params = parser_.parse_args()
        site_num = params['site_num']

        # 查询线路的所有站点列表
        site_list = sodaVisualizationService.querySiteByNum(site_num)

        # 判断站点数据是否为空,为空则返回错误
        if site_list is None or site_list == '' or len(site_list) == 0:
            ret = SDCommonJsonRet(code=SDCodeMsg.SITE_RECORD_NOT_FOUND.code,
                                  success=False,
                                  msg=SDCodeMsg.SITE_RECORD_NOT_FOUND.msg,
                                  data=SDCodeMsg.SITE_RECORD_NOT_FOUND.msg)
        else:
            # 不为空,则返回数据
            ret = SDCommonJsonRet(code=SDCodeMsg.SUCCESS.code,
                                  success=True,
                                  msg=SDCodeMsg.SUCCESS.msg,
                                  data=site_list)
        ret = make_response(ret.toJsonStr())
        ret.headers['Access-Control-Allow-Origin'] = '*'
        return ret
Esempio n. 4
0
def health_check():
    return SDCommonJsonRet(code=200,
                           success=True,
                           msg="health check is ok",
                           data="").toJsonStr()
Esempio n. 5
0
def default_error_handler(exception):
    logging.error(exception)
    return SDCommonJsonRet(code=500,
                           success=False,
                           msg=exception.message,
                           data="server exception capture").toJson()
Esempio n. 6
0
def page_not_not_found(error):
    return SDCommonJsonRet(code=404,
                           success=False,
                           msg="404 Not Found . there is not this api",
                           data="").toJsonStr()