Exemple #1
0
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'添加失败')
Exemple #2
0
def addAssetClass():
    try:
        data = request.form
        dataNew = {}
        for k, v in data.items():
            dataNew[k] = v
        num, msg = AttributeManagerService().addAssetClass(dataNew)
        if -1 == num:
            LOG.error("添加错误")
            return ajax.api_error(msg=msg)
        elif 0 == num:
            return ajax.api_success(msg=msg, data=False)
        else:
            return ajax.api_success(msg=msg)
    except Exception as _ex:
        LOG.error("error occured while add asset tree node: %s" % str(_ex))
        return ajax.api_error(msg=u'添加失败')
Exemple #3
0
def store_consume_old_data():
    data = request.form
    ret, msg = AssetConsumeService().store_consume_old_add_data(data)
    if ret:
        LOG.info(msg)
        return ajax.api_success(msg=msg, data=[])
    else:
        LOG.error(msg)
        return ajax.api_error(msg=msg)
Exemple #4
0
def store_phone_out_data():
    data = request.form
    operator = session.get('rtx_id')
    ret, msg = AssetPhoneService().store_phone_out_data(data, operator)
    if ret:
        LOG.info(msg)
        return ajax.api_success(msg=msg, data=[])
    else:
        LOG.error(msg)
        return ajax.api_error(msg=msg)
Exemple #5
0
def store_phone_old_data():
    data = request.form
    print data
    ret, msg = AssetPhoneService().store_phone_old_add_data(data)
    if ret:
        LOG.info(msg)
        return ajax.api_success(msg=msg, data=[])
    else:
        LOG.error(msg)
        return ajax.api_error(msg=msg)
Exemple #6
0
def add_old_asset_info():
    params = request.form
    operator = session.get('rtx_id')
    ret = AssetConsumeService().store_out_add_consume_data(params, operator)
    if ret:
        msg = u"已有耗材类数据出库成功"
        LOG.info(msg)
        return ajax.api_success(msg=msg, data=[])
    else:
        msg = u"已有耗材类数据出库失败"
        LOG.error(msg)
        return ajax.api_error(msg=msg)
Exemple #7
0
def addStorehouseMsgs():
    try:
        data = request.form
        print data
        bFlag, msg = AttributeManagerService().addStorePlace(data)
        if bFlag:
            return ajax.api_success(msg=msg, data=[])
        else:
            return ajax.api_error(msg=msg)
    except Exception as _ex:
        LOG.error("error occured while add storehouse msgs: %s" % str(_ex))
        return ajax.api_error(msg=u'添加失败')
Exemple #8
0
def removeAssetClassNode():
    try:
        data = request.form
        dataNew = {}
        for k, v in data.items():
            dataNew[k] = v
        bFlag = AttributeManagerService().removeAssetClassNode(dataNew)
        if bFlag:
            return ajax.api_error(msg=u'删除失败')
        return ajax.api_success(msg=u"删除成功", data=[])
    except Exception as _ex:
        LOG.error("error occured while remvoe asset tree node: %s" % str(_ex))
        return ajax.api_error(msg=u'删除失败')
Exemple #9
0
def addDeviceType():
    try:
        data = request.form
        dataNew = {}
        for k, v in data.items():
            dataNew[k] = v
        bFlag, strRet = AttributeManagerService().addDeviceTypeInfos(dataNew)
        if bFlag:
            return ajax.api_success(msg=strRet, data=[])
        else:
            return ajax.api_error(msg=strRet)
    except Exception, _ex:
        LOG.error("error occured while add device type: %s" % str(_ex))
        return ajax.api_error(msg=u'添加失败')
Exemple #10
0
def submit_asset_info():
    try:
        params = request.form
        ams = AssetManagerService()
        ret, msg = ams.store_edit_asset_info_data(params)
        if ret:
            LOG.info(msg)
            return ajax.api_success(msg=msg, data=[])
        else:
            LOG.error(msg)
            return ajax.api_error(msg=msg)
    except Exception, _ex:
        LOG.error("error occured while submit_asset_info : %s" % str(_ex))
        return u"编辑失败"
Exemple #11
0
def updateStockOutInfos():
    try:
        data = request.form
        dataNew = {}
        for k, v in data.items():
            dataNew[k] = v
        bRet, msg = StockOutService().updateStockOutInfos(dataNew)
        if not bRet:
            return ajax.api_error(msg=msg)
        else:
            return ajax.api_success(msg=u'出库成功', data=[])
    except Exception as _ex:
        LOG.error("error occured while modify stock out asset infos: %s"
                  % str(_ex))
        return ajax.api_error(msg=u'出库失败')