Example #1
0
def test_batch():
    with open("./test_data/batch.json", "r") as j:
        data = json.load(j)

    batch = Batch(**data)
    batch.run()
    return (batch)
Example #2
0
def uploadFile():
    form = request.form.to_dict()
    id = form.get('id')
    print('上传接受的参数', form)
    print('接收信息', request.files)
    file = request.files['file']
    print('file', type(file), file)
    print('文件名', file.filename)  # 打印文件名
    print('name', file.name)
    f = file.read()  # 文件内容
    data = xlrd.open_workbook(file_contents=f)
    table = data.sheets()[0]
    names = data.sheet_names()  # 返回book中所有工作表的名字

    status = data.sheet_loaded(names[0])  # 检查sheet1是否导入完毕
    print('导入状态', status)
    nrows = table.nrows  # 获取该sheet中的有效行数
    ncols = table.ncols  # 获取该sheet中的有效列数
    # print('nrows',nrows)
    # print('ncols',ncols)
    s = table.col_values(2)  # 第1列数据
    print('尺码', s)
    table_name = names[0]
    Batch.update(id=id, upload=1, excel_name=form.get('excel_name'))
    Stock.delete_by_batch_id(id=id)
    res = formatExcel(table)
    # 根据文件名添加批次
    for r in res:
        r['batch'] = form.get('id')

    r = Stock.add_by_list(res)
    # print('导入结果', r)
    return make_response(jsonify(Res.success(r)))
Example #3
0
def delete():
    form = request.form.to_dict()
    id = form.get('id')
    r = Stock.delete_by_batch_id(id=id)
    r = Batch.delete_by_ids(id)
    r = Batch.all()
    print('删除', r)
    return make_response(jsonify(r))
Example #4
0
def update():
    form = request.form.to_dict()
    form['editor'] = session.get('id')
    print('form', form)
    data = Batch.update(**form)
    print('data', data)
    r = Res.success(data)
    return make_response(jsonify(r))
Example #5
0
 def get_instance():
     if BatchSingleton.__instance__ is None:
         new_batch_dict = {
             "status": "PROCESSING",
             "createdAt": time.localtime(time.time()),
             "updatedAt": time.localtime(time.time())
         }
         BatchSingleton.__instance__ = batch_dao.add_batch(
             Batch(new_batch_dict))
         return BatchSingleton.__instance__
     else:
         return BatchSingleton.__instance__
Example #6
0
 def build(config):
     batch = Batch(config = config.path)
     batch.build_jobs(*nodes)
     batch.build_shell_variables(**argument_hash(config))
     return batch
Example #7
0
def generate_fake_date():
    print('测试开始')
    # 增加 类型
    product1 = dict(
        name='AIR JORDAN 11 RETRO',
        code='AR0715 200',
        cover=
        'https://c.static-nike.com/a/images/t_prod_ss/w_960,c_limit,f_auto/c0k2mkpdrvz3caggsm7f/womens-air-jordan-11-neutral-olive-sail-gum-light-brown-release-date.jpg',
        note='橄榄 女款',
    )
    product2 = dict(
        name='AIR JORDAN 1 MID',
        code='AR0715 200',
        cover='https://inews.gtimg.com/newsapp_bt/0/9964332871/1000',
        note='黒曜石 黑白',
    )
    p = Product.add(product1)
    p2 = Product.add(product1)

    Product.add(product2)
    print('p', p.id)
    # 增加子类型
    product1_attr1 = dict(bar_code='191888280841',
                          size="38.5",
                          product_id=p.id)
    product1_attr2 = dict(bar_code='191888280858', size="39", product_id=p.id)
    ProductAttr.new(product1_attr1)
    ProductAttr.new(product1_attr2)
    p3 = dict(bar_code="191888280841")
    p3 = ProductAttr.queryByBarCode(p3)
    print('p3', p3)
    p4 = ProductAttr.all()
    print('p444444444444', p4)
    # 增加用户
    u = dict(
        openid="oACYX0d8qtLPAZ6Mtx0sgBY3AtGw",
        identity=0,
    )
    User.login(u)
    tester = dict(
        username='******',
        password='******',
        openid='tester',
        identity=2,
    )
    User.new(tester)

    # 增加字典表

    d1 = [
        {
            'key': 0,
            'value': '管理员',
            'alias': 'admin',
            'status': 0,
            'type': 'USER_TYPE',
            'note': '用户权限',
        },
        {
            'key': 1,
            'value': '普通用户',
            'alias': 'normal',
            'status': 0,
            'type': 'USER_TYPE',
            'note': '用户权限',
        },
        {
            'key': 2,
            'value': '微信测试账号',
            'alias': 'tester',
            'status': 0,
            'type': 'USER_TYPE',
            'note': '用户权限',
        },
        {
            'key': 0,
            'value': '出售中',
            'alias': 'sale',
            'status': 0,
            'type': 'STOCK_STATUS',
            'note': '出售状态',
        },
        {
            'key': 1,
            'value': '已出售',
            'alias': 'sell',
            'status': 0,
            'type': 'STOCK_STATUS',
            'note': '出售状态',
        },
        {
            'key': 2,
            'value': '寄售',
            'alias': 'consignment',
            'status': 0,
            'type': 'STOCK_STATUS',
            'note': '出售状态',
        },
        {
            'key': 3,
            'value': '退回中',
            'alias': 'return',
            'status': 0,
            'type': 'STOCK_STATUS',
            'note': '出售状态',
        },
        {
            'key': 0,
            'value': '未上传',
            'alias': 'unupload',
            'status': 0,
            'type': 'BATCH_UPLOAD',
            'note': '批次表格导入状态',
        },
        {
            'key': 1,
            'value': '已上传',
            'alias': 'uploaded',
            'status': 0,
            'type': 'BATCH_UPLOAD',
            'note': '批次表格导入状态',
        },
    ]
    DictMap.new_by_list_dict(d1)
    # # 新增批次
    b1 = dict(purchase_time='2019-8-26', name='测试', proportion=5)
    b2 = dict(purchase_time='2019-9-1', name='批次2', proportion=10)
    Batch.new(b1)
    Batch.new(b2)
Example #8
0
def add_one():
    form = request.form.to_dict()
    print('form in add batch', form)
    r = Batch.new(form).json()
    r = Res.success(r)
    return make_response(jsonify(r))
Example #9
0
def query_all():
    # 查询商品大类
    r = Batch.all()
    r = Res.success(r)
    print('查询所有商品', r)
    return make_response(jsonify(r))