remove dev
This commit is contained in:
@ -6,3 +6,8 @@ gunicorn
|
||||
python-dotenv
|
||||
lark-oapi
|
||||
Flask-SQLAlchemy
|
||||
|
||||
development:
|
||||
flask run --reload
|
||||
production:
|
||||
gunicorn -w 4 -b 0.0.0.0:8000 app:app
|
@ -15,7 +15,7 @@ from lark_oapi.api.auth.v3 import *
|
||||
from lark_oapi.api.bitable.v1 import *
|
||||
|
||||
class Inventory(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
||||
tag = db.Column(db.Text)
|
||||
amount = db.Column(db.Integer)
|
||||
checked = db.Column(db.Boolean, default=False)
|
||||
@ -23,10 +23,15 @@ class Inventory(db.Model):
|
||||
tableid = db.Column(db.Text)
|
||||
# lasttime = db.Column(db.DateTime, default=datetime.now())
|
||||
|
||||
# client = lark.Client.builder() \
|
||||
# .app_id(application.config['LARK_APP_ID']) \
|
||||
# .app_secret(application.config['LARK_APP_SECRECT']) \
|
||||
# .log_level(lark.LogLevel.DEBUG) \
|
||||
# .build()
|
||||
|
||||
client = lark.Client.builder() \
|
||||
.app_id(application.config['LARK_APP_ID']) \
|
||||
.app_secret(application.config['LARK_APP_SECRECT']) \
|
||||
.log_level(lark.LogLevel.DEBUG) \
|
||||
.build()
|
||||
|
||||
TIMER = time.time()
|
||||
@ -107,6 +112,8 @@ def get_table_record(id, page_token=None):
|
||||
page_token = None
|
||||
if rep['data']['has_more']:
|
||||
page_token = rep['data']['page_token']
|
||||
else:
|
||||
page_token = None
|
||||
for i in rep['data']['items']:
|
||||
if '已盘' in i['fields']:
|
||||
cd = i['fields']['已盘']
|
||||
@ -130,7 +137,7 @@ def update_record(id, recordid, amount):
|
||||
# 构造请求对象
|
||||
request: UpdateAppTableRecordRequest = UpdateAppTableRecordRequest.builder() \
|
||||
.app_token(application.config['LARK_TB_TOKEN']) \
|
||||
.table_id(id['table_id']) \
|
||||
.table_id(id) \
|
||||
.record_id(recordid) \
|
||||
.request_body(AppTableRecord.builder()
|
||||
.fields({"已盘":True,"外库数量":amount})
|
||||
@ -160,12 +167,11 @@ def init_db():
|
||||
youxin, page_token= get_table_record(application.config['YOUXIN_ID'])
|
||||
for i in youxin:
|
||||
inv = Inventory()
|
||||
inv.id = i['sort']
|
||||
inv.tag = i['tag']
|
||||
inv.amount = i['amount']
|
||||
inv.checked = i['checked']
|
||||
inv.recordid = i['recordid']
|
||||
inv.tableid = application.config['YOUXIN_ID']
|
||||
inv.tableid = application.config['YOUXIN_ID']['table_id']
|
||||
db.session.add(inv)
|
||||
while page_token:
|
||||
youxin, page_token = get_table_record(application.config['YOUXIN_ID'], page_token)
|
||||
@ -173,23 +179,21 @@ def init_db():
|
||||
break
|
||||
for i in youxin:
|
||||
inv = Inventory()
|
||||
inv.id = i['sort']
|
||||
inv.tag = i['tag']
|
||||
inv.amount = i['amount']
|
||||
inv.checked = i['checked']
|
||||
inv.recordid = i['recordid']
|
||||
inv.tableid = application.config['YOUXIN_ID']
|
||||
inv.tableid = application.config['YOUXIN_ID']['table_id']
|
||||
db.session.add(inv)
|
||||
|
||||
waimo, page_token= get_table_record(application.config['WAIMO_ID'])
|
||||
for i in waimo:
|
||||
inv = Inventory()
|
||||
inv.id = i['sort']
|
||||
inv.tag = i['tag']
|
||||
inv.amount = i['amount']
|
||||
inv.checked = i['checked']
|
||||
inv.recordid = i['recordid']
|
||||
inv.tableid = application.config['WAIMO_ID']
|
||||
inv.tableid = application.config['WAIMO_ID']['table_id']
|
||||
db.session.add(inv)
|
||||
while page_token:
|
||||
waimo, page_token = get_table_record(application.config['WAIMO_ID'], page_token)
|
||||
@ -197,12 +201,11 @@ def init_db():
|
||||
break
|
||||
for i in waimo:
|
||||
inv = Inventory()
|
||||
inv.id = i['sort']
|
||||
inv.tag = i['tag']
|
||||
inv.amount = i['amount']
|
||||
inv.checked = i['checked']
|
||||
inv.recordid = i['recordid']
|
||||
inv.tableid = application.config['WAIMO_ID']
|
||||
inv.tableid = application.config['WAIMO_ID']['table_id']
|
||||
db.session.add(inv)
|
||||
|
||||
|
||||
|
@ -29,17 +29,11 @@ application.config['LARK_TB_TOKEN'] = os.getenv('LARK_TB_TOKEN', 'lark_app_secre
|
||||
|
||||
application.config['WAIMO_ID'] = {
|
||||
'table_id': 'tbluSufkcQm0noBz',
|
||||
'view_id': 'vewLYvBFns',
|
||||
'tag_id': 'fld2xdCqrs',
|
||||
'amount_id': 'fldC9cnnAY',
|
||||
'checked_id': 'fldJkHhQgQ'
|
||||
'view_id': 'vewLYvBFns'
|
||||
}
|
||||
|
||||
application.config['YOUXIN_ID'] = {
|
||||
'table_id': 'tbl9NPZQMl5IVHQ2',
|
||||
'view_id': 'vewrOuK32q',
|
||||
'tag_id': 'fldrxqL8uz',
|
||||
'amount_id': 'fldsOIpOBk',
|
||||
'checked_id': 'fldsuS6SuR'
|
||||
'view_id': 'vewrOuK32q'
|
||||
}
|
||||
|
||||
|
@ -10,26 +10,16 @@ function decrement() {
|
||||
}
|
||||
function checknext() {
|
||||
var amount = document.getElementById("inventory-amount");
|
||||
// 获取ID为"forid"的元素
|
||||
var idelement = document.getElementById("inventory-id");
|
||||
// 获取该元素的文本内容,并解析为整数
|
||||
var id = parseInt(idelement.innerText, 10); // 第二个参数10表示解析的基数,这里是十进制
|
||||
var id = parseInt(idelement.innerText, 10);
|
||||
var tagelement = document.getElementById("inventory-tag");
|
||||
var tag = tagelement.innerText;
|
||||
var msg = document.getElementById("flash-msg");
|
||||
var location = document.getElementById("inventory-location");
|
||||
// var params = new URLSearchParams({
|
||||
// checked: 1,
|
||||
// id: id,
|
||||
// amount: amount.value
|
||||
// });
|
||||
// var url = `/check?${params.toString()}`;
|
||||
fetch('/get_inventory', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({id: id, amount: amount.value})
|
||||
body: JSON.stringify({id: id, amount: parseInt(amount.value, 10)})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
@ -38,8 +28,6 @@ function checknext() {
|
||||
tagelement.innerText = data.tag;
|
||||
idelement.innerText = data.id;
|
||||
msg.innerText = data.checkedone + " 盘点数 " + data.checkedamount;
|
||||
location.innerText = data.location;
|
||||
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
{% block content %}{% endblock %}
|
||||
<footer>
|
||||
{% block footer %}
|
||||
<small> 2025 © SDHLMH
|
||||
<small> 2025 © 鸾
|
||||
</small>
|
||||
{% endblock %}
|
||||
</footer>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div>
|
||||
<div class="handler">
|
||||
<a href="/"><button type="button">返回</button></a>
|
||||
<div id="inventory-location"></div><div><p id="inventory-id" hidden>{{ inventory.id }}</p></div>
|
||||
<div><p id="inventory-id" hidden>{{ inventory.id }}</p></div>
|
||||
</div>
|
||||
<h1 id="inventory-tag">{{ inventory.tag }}</h1>
|
||||
<hr>
|
||||
|
@ -1,7 +1,9 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method=get action="/readme">
|
||||
<input style="width:150px;" type=submit value=说明>
|
||||
</form>
|
||||
<form method=get action="/init">
|
||||
<input style="width:150px;" type=submit value=初始化>
|
||||
</form>
|
||||
|
@ -1,15 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}上传Excel文件{% endblock %}
|
||||
{% block title %}初始化{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>初始化</h1>
|
||||
<div class="handler">
|
||||
<a href="/"><button type="button">返回</button></a>
|
||||
<div></div><div></div>
|
||||
</div>
|
||||
<hr>
|
||||
<form method=post enctype=multipart/form-data action="/import">
|
||||
<div>初始化是从多维表格获取数据,修改多维表格后务必运行,花费约1-5分钟,请耐心等待</div>
|
||||
<div style="text-align:left;">初始化是从多维表格获取数据,<br>修改多维表格后务必运行,<br>花费约1-5分钟,<br>不要多次点击按钮,<br>请耐心等待页面刷新</div>
|
||||
<form method=get enctype=multipart/form-data action="/import">
|
||||
<div class="handler"><div></div><input style="width:100px;"type=submit value=初始化></div>
|
||||
</form>
|
||||
<div>
|
||||
|
21
inventory_check_lark/templates/readme.html
Normal file
21
inventory_check_lark/templates/readme.html
Normal file
@ -0,0 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}说明{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="handler">
|
||||
<a href="/"><button type="button">返回</button></a>
|
||||
<div></div><div></div>
|
||||
</div>
|
||||
<div style="text-align:left;">本应用绑定<a href="https://hailiang.feishu.cn/base/EciWbKOEXa68HIsnh5Ac7vZgnff?table=tbl9NPZQMl5IVHQ2&view=vewrOuK32q">这个飞书多维表格</a><br>
|
||||
修改多维表格后务必运行 >> 初始化<br>
|
||||
1.盘点前检查飞书表格添加或删除行<br>
|
||||
2.将 已盘 一列全部修改为空心方框<br>
|
||||
3.返回 >> 主页 点击 >> 初始化,<br>
|
||||
4.初始化后,点继续盘点按顺序展示<br>
|
||||
5.盘点若出错可以直接修改飞书表格<br>
|
||||
6.因需与飞书通信,确认按钮会卡手<br>
|
||||
7.其它问题联系作者<br>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -15,9 +15,18 @@ from werkzeug.exceptions import BadRequest
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@application.route('/readme')
|
||||
def readme():
|
||||
return render_template('readme.html')
|
||||
|
||||
@application.route('/init')
|
||||
def init():
|
||||
return 'ok' if init_db() else 'error'
|
||||
return render_template('init.html')
|
||||
|
||||
@application.route('/import')
|
||||
def do_init():
|
||||
init_db()
|
||||
return render_template('after.html',msg="初始化完成")
|
||||
|
||||
@application.route('/check', methods=['GET'])
|
||||
def check():
|
||||
@ -26,16 +35,16 @@ def check():
|
||||
return render_template('after.html',msg="未初始化或已盘完")
|
||||
return render_template('check.html',inventory=inventory)
|
||||
|
||||
@application.route('/get_youxin_inventory', methods=['POST'])
|
||||
def update_youxin_inventory():
|
||||
@application.route('/get_inventory', methods=['POST'])
|
||||
def update_inventory():
|
||||
try:
|
||||
# 获取并验证表单数据
|
||||
data = request.get_json()
|
||||
inventory_id = data['id']
|
||||
amount = data['amount']
|
||||
|
||||
if not inventory_id or not amount:
|
||||
raise BadRequest('Missing inventory id or amount')
|
||||
# if not inventory_id or not amount:
|
||||
# raise BadRequest('Missing inventory id or amount')
|
||||
|
||||
# 查询并更新库存对象
|
||||
inventory = Inventory.query.get(inventory_id)
|
||||
|
Reference in New Issue
Block a user