示例#1
0
文件: stock_in.py 项目: wzqwsrf/itdb
def upload_asset_file():
    try:
        f = request.files.get("file")
        if not f:
            return ajax.api_error(msg=u'没有获取文件信息')
        fileName = secure_filename(f.filename)
        path = '/tmp/'
        fileFullPath = os.path.join(path, fileName)
        # import re
        # temp = tempfile.mkdtemp(suffix='xlsx', prefix='asset', dir=fileFullPath)
        # os.rename(os.path.join(path, fileName), os.path.join(path, new_name))
        f.save(fileFullPath)
        ret, msg = get_excel_sheet_name(fileFullPath)
        if not ret:
            return ajax.api_error(msg=msg)
        else:
            operator = session.get('rtx_id')
            ss = StockInService()
            ret, msg = ss.muti_stock_in_different_assets(fileFullPath, operator, int(msg))
            if ret:
                return ajax.api_success(msg=msg, data=[])
            else:
                return ajax.api_error(msg=msg)
    except Exception, _ex:
        LOG.error("error occured while upload_asset_file : %s" % str(_ex))
        return ajax.api_error(msg=u'添加失败')
示例#2
0
文件: stock_in.py 项目: wzqwsrf/itdb
def add_new_asset_info():
    # try:
    data = request.form
    sis = StockInService()
    new_data = {}
    for k, v in data.items():
        new_data[k] = v
    ret, msg = sis.add_new_asset_info(new_data)
    return json.dumps(dict(msg=msg, success=ret))