mirror of
https://github.com/suhf/No1WMSPython.git
synced 2026-02-04 12:13:27 +09:00
입고후 입고예정 db 입고예정 체크 컬럽 데이터 업데이트하여 입고처리
화면에 데이터 알맞게 출력되도록 수정 화면에서 확인버튼 클릭 시 입고에 데이터 insert 기능 추가
This commit is contained in:
160
app.py
160
app.py
@@ -5,12 +5,23 @@ import configparser
|
|||||||
import os
|
import os
|
||||||
import pymysql
|
import pymysql
|
||||||
# ---
|
# ---
|
||||||
|
import datetime
|
||||||
|
# import uuid
|
||||||
|
|
||||||
|
# 전역함수
|
||||||
|
global url
|
||||||
|
global group_number
|
||||||
|
global product_id
|
||||||
|
global warehouse_id
|
||||||
|
global manager_id
|
||||||
|
|
||||||
# DB 연결 설정 정보 세팅 ( db_config.ini에 정의 )
|
# DB 연결 설정 정보 세팅 ( db_config.ini에 정의 )
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(os.getcwd() + os.sep + 'db_config.ini', encoding='utf-8')
|
config.read(os.getcwd() + os.sep + 'db_config.ini', encoding='utf-8')
|
||||||
|
|
||||||
conn = pymysql.connect(
|
# db 연결
|
||||||
|
def dbcon():
|
||||||
|
return pymysql.connect(
|
||||||
host = config.get('DB_CONFIG', 'HOST'),
|
host = config.get('DB_CONFIG', 'HOST'),
|
||||||
port = int(config['DB_CONFIG']['PORT']),
|
port = int(config['DB_CONFIG']['PORT']),
|
||||||
user= config['DB_CONFIG']['USER'],
|
user= config['DB_CONFIG']['USER'],
|
||||||
@@ -18,35 +29,114 @@ conn = pymysql.connect(
|
|||||||
db= config['DB_CONFIG']['DBNAME'],
|
db= config['DB_CONFIG']['DBNAME'],
|
||||||
charset="utf8")
|
charset="utf8")
|
||||||
|
|
||||||
# Tuple
|
def insert_data(quantity):
|
||||||
cur = conn.cursor()
|
try:
|
||||||
|
db = dbcon()
|
||||||
|
c = db.cursor()
|
||||||
|
setdata = (group_number, product_id, datetime.datetime.now(), quantity, warehouse_id, manager_id, 'a', True)
|
||||||
|
# setdata = (uuid.uuid1(), uuid.uuid1(), uuid.uuid1(), datetime.datetime.now(), quantity, uuid.uuid1(), uuid.uuid1(), 'test', True)
|
||||||
|
# c.execute("INSERT INTO wms.product_in2 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", setdata)
|
||||||
|
c.execute("INSERT INTO wms.product_in(id, group_number, product_id, in_date, quantity, warehouse_id, manager_id, note, activation) VALUES(UUID(), %s, %s, %s, %s, %s, %s, %s, %s)", setdata)
|
||||||
|
db.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print('db error:', e)
|
||||||
|
print(group_number)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
# DictCursor
|
def update_data(url):
|
||||||
cur = conn.cursor(pymysql.cursors.DictCursor)
|
try:
|
||||||
|
db = dbcon()
|
||||||
|
c = db.cursor()
|
||||||
|
setdata = (url)
|
||||||
|
c.execute("UPDATE wms.plan_In SET clear = TRUE WHERE url=%s", setdata)
|
||||||
|
db.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print('db error:', e)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
# sql = f"""SELECT * FROM wms.plan_In2
|
def select_all():
|
||||||
|
ret = list()
|
||||||
|
try:
|
||||||
|
db = dbcon()
|
||||||
|
c = db.cursor()
|
||||||
|
#c.execute('SELECT * FROM wms.plan_In')
|
||||||
|
c.execute('SELECT * FROM wms.plan_In WHERE clear=0')
|
||||||
|
ret = c.fetchall()
|
||||||
|
# for row in c.execute('SELECT * FROM student'):
|
||||||
|
# ret.append(row)
|
||||||
|
except Exception as e:
|
||||||
|
print('db error:', e)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# def select_num(url):
|
||||||
|
# ret = ()
|
||||||
|
# try:
|
||||||
|
# db = dbcon()
|
||||||
|
# #c = db.cursor()
|
||||||
|
# c = db.cursor(pymysql.cursors.DictCursor)
|
||||||
|
# setdata = (url)
|
||||||
|
# # c.execute('SELECT * FROM wms.plan_In WHERE url=%s', setdata)
|
||||||
|
# c.execute('SELECT * FROM wms.plan_In WHERE url=%s AND clear=0', setdata)
|
||||||
|
# ret = c.fetchall()
|
||||||
|
# except Exception as e:
|
||||||
|
# print('db error:', e)
|
||||||
|
# finally:
|
||||||
|
# db.close()
|
||||||
|
# return ret
|
||||||
|
|
||||||
|
def select_num(url):
|
||||||
|
ret = ()
|
||||||
|
try:
|
||||||
|
db = dbcon()
|
||||||
|
#c = db.cursor()
|
||||||
|
c = db.cursor(pymysql.cursors.DictCursor)
|
||||||
|
setdata = (url)
|
||||||
|
# c.execute('SELECT * FROM wms.plan_In WHERE url=%s', setdata)
|
||||||
|
c.execute('SELECT wms.plan_In.url url, wms.plan_In.group_number group_number, wms.plan_In.product_id product_id, wms.plan_In.warehouse_id warehouse_id, wms.plan_In.manager_id manager_id, wms.plan_In.quantity quantity, wms.product.name pd_name, wms.warehouse.name wh_name, wms.plan_In.`date` FROM wms.plan_In left join wms.product on wms.product.id = wms.plan_In.product_id left join wms.warehouse on wms.warehouse.id = wms.plan_In.warehouse_id WHERE url=%s AND clear=0', setdata)
|
||||||
|
ret = c.fetchall()
|
||||||
|
except Exception as e:
|
||||||
|
print('db error:', e)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# # # DB 연결
|
||||||
|
# # db = dbcon()
|
||||||
|
|
||||||
|
# # Tuple
|
||||||
|
# cur = conn.cursor()
|
||||||
|
|
||||||
|
# # DictCursor
|
||||||
|
# cur = conn.cursor(pymysql.cursors.DictCursor)
|
||||||
|
|
||||||
|
# # sql = f"""SELECT * FROM wms.plan_In2
|
||||||
|
# # """
|
||||||
|
|
||||||
|
# sql = f"""SELECT * FROM wms.plan_In2 where qr_hash=%s
|
||||||
# """
|
# """
|
||||||
|
|
||||||
sql = f"""SELECT * FROM wms.plan_In2 where qr_hash=%s
|
# cur.execute(sql, 'testqr')
|
||||||
"""
|
|
||||||
|
|
||||||
cur.execute(sql, 'testqr')
|
|
||||||
|
|
||||||
# 데이터 접근
|
# 데이터 접근
|
||||||
# result = cur.fetchall()
|
# result = cur.fetchall()
|
||||||
rows = cur.fetchall()
|
# rows = cur.fetchall()
|
||||||
# result = cur.fetchone()
|
# result = cur.fetchone()
|
||||||
|
|
||||||
# for record in result:
|
# for record in result:
|
||||||
# print(record)
|
# print(record)
|
||||||
|
|
||||||
# 연결 종료
|
# 연결 종료
|
||||||
conn.close()
|
#conn.close()
|
||||||
|
|
||||||
for row in rows:
|
# ret = select_num('485b02c0-b05e-11ee-935d-0242ac110006')
|
||||||
# print(row)
|
|
||||||
print(row['quantity'], row['qr_hash'], row['date'])
|
|
||||||
|
|
||||||
|
# for row in ret:
|
||||||
|
# # print(row)
|
||||||
|
# print(row['wh_name'], row['pd_name'])
|
||||||
# rows = [list(rows[x]) for x in range(len(rows))]
|
# rows = [list(rows[x]) for x in range(len(rows))]
|
||||||
#------------------------------------------------
|
#------------------------------------------------
|
||||||
|
|
||||||
@@ -54,8 +144,7 @@ app = Flask(__name__)
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello():
|
def hello():
|
||||||
# return 'Hello, World!'
|
return 'Hello, World!'
|
||||||
return rows
|
|
||||||
|
|
||||||
@app.route('/hello')
|
@app.route('/hello')
|
||||||
def hellohtml():
|
def hellohtml():
|
||||||
@@ -100,10 +189,29 @@ def url_test():
|
|||||||
def myimage():
|
def myimage():
|
||||||
return render_template("myimage.html")
|
return render_template("myimage.html")
|
||||||
|
|
||||||
@app.route('/form')
|
#@app.route('/form')
|
||||||
def formhtml():
|
@app.route('/form/<string:str>')
|
||||||
|
#def formhtml():
|
||||||
|
def formhtml(str):
|
||||||
|
ret = select_num(str)
|
||||||
|
for row in ret:
|
||||||
|
print()
|
||||||
|
|
||||||
|
global group_number
|
||||||
|
global product_id
|
||||||
|
global warehouse_id
|
||||||
|
global manager_id
|
||||||
|
global url
|
||||||
|
group_number = row['group_number']
|
||||||
|
product_id = row['product_id']
|
||||||
|
warehouse_id = row['warehouse_id']
|
||||||
|
manager_id = row['manager_id']
|
||||||
|
url = row['url']
|
||||||
|
# print(group_number, product_id, warehouse_id, manager_id)
|
||||||
|
# if str == 'f90aef8a-aecd-11ee-935d-0242ac110006':
|
||||||
|
# return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], quantity = row['quantity'])
|
||||||
# return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], name = row['name'], quantity = row['quantity'])
|
# return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], name = row['name'], quantity = row['quantity'])
|
||||||
return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], quantity = row['quantity'])
|
return render_template("form.html", date = row['date'], wh_name = row['wh_name'], quantity = row['quantity'], pd_name = row['pd_name'])
|
||||||
|
|
||||||
@app.route('/method', methods=['GET', 'POST'])
|
@app.route('/method', methods=['GET', 'POST'])
|
||||||
def method():
|
def method():
|
||||||
@@ -121,15 +229,19 @@ def method():
|
|||||||
# args_dict = request.args.to_dict()
|
# args_dict = request.args.to_dict()
|
||||||
# print(args_dict)
|
# print(args_dict)
|
||||||
date = request.args.get["date"]
|
date = request.args.get["date"]
|
||||||
warehouse_id = request.args.get("warehouse_id")
|
warehouse_id = request.args.get("wh_name")
|
||||||
# name = request.args.get("name")
|
# name = request.args.get("name")
|
||||||
# return "GET으로 전달된 데이터({}, {})".format(date, warehouse_id, quantity, name)
|
# return "GET으로 전달된 데이터({}, {})".format(date, warehouse_id, quantity, name)
|
||||||
return "GET으로 전달된 데이터({}, {}, {})".format(date, warehouse_id, quantity)
|
return "GET으로 전달된 데이터({}, {}, {})".format(date, wh_name, quantity)
|
||||||
else:
|
else:
|
||||||
date = request.form["date"]
|
date = request.form["date"]
|
||||||
warehouse_id = request.form["warehouse_id"]
|
wh_name = request.form["wh_name"]
|
||||||
quantity = request.form["quantity"]
|
quantity = request.form["quantity"]
|
||||||
return "POST로 전달된 데이터({}, {}, {})".format(date, warehouse_id, quantity)
|
pd_name = request.form["pd_name"]
|
||||||
|
insert_data(quantity)
|
||||||
|
update_data(url)
|
||||||
|
return "POST로 전달된 데이터({}, {}, {}, {})".format(date, wh_name, quantity, pd_name)
|
||||||
|
# return render_template("form.html", date = row['date'], warehouse_id = row['warehouse_id'], quantity = row['quantity'])
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
|
|||||||
@@ -1,21 +1,67 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.6">
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
|
<style>
|
||||||
|
input:read-only{
|
||||||
|
background-color: rgb(224, 222, 222);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>WMS</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<h2>WMS</h2>
|
<h2>WMS</h2>
|
||||||
|
|
||||||
<form action="/method" method="POST">
|
<form action="/method" method="POST">
|
||||||
<label for="date">날짜</label>
|
<label for="date">날짜</label>
|
||||||
<input type="text" id="date" name="date" value="{{date}}"><br><br>
|
<input type="text" id="date" name="date" value="{{date}}" readonly><br><br>
|
||||||
<label for="warehouse_id">창고</label>
|
<label for="wh_name">창고명</label>
|
||||||
<input type="text" id="warehouse_id" name="warehouse_id" value="{{warehouse_id}}"><br><br>
|
<input type="text" id="wh_name" name="wh_name" value="{{wh_name}}" readonly><br><br>
|
||||||
<label for="name">제품명</label>
|
<label for="pd_name">제품명</label>
|
||||||
<input type="text" id="name" value="{{name}}"><br><br>
|
<input type="text" id="pd_name" name="pd_name" value="{{pd_name}}" readonly><br><br>
|
||||||
<label for="quantity">수량</label>
|
<label for="quantity">제품수량</label>
|
||||||
<input type="text" id="quantity" name="quantity" value="{{quantity}}"><br><br>
|
<input type="number" id="quantity" min="0" name="quantity" value="{{quantity}}" readonly>
|
||||||
|
|
||||||
|
<button type="button" id="u-btn">수정</button>
|
||||||
|
<br><br>
|
||||||
|
<script>
|
||||||
|
const ubtn = document.getElementById("u-btn");
|
||||||
|
ubtn.addEventListener('click', () => {
|
||||||
|
document.getElementById('quantity').readOnly = false;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<input type="submit" value="확인">
|
<input type="submit" value="확인">
|
||||||
<input type="submit" value="취소">
|
<input type="reset" value="취소">
|
||||||
|
|
||||||
|
<!-- <script>
|
||||||
|
$("#formInput").val();
|
||||||
|
let data = {};
|
||||||
|
data['컬럼명1'] = $("#id1").val();
|
||||||
|
data['컬럼명2'] = $("#id2").val();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type : 'post', // 타입 (get, post, put 등등)
|
||||||
|
url : '/authority/create_process', // 요청할 서버url
|
||||||
|
dataType : 'json', // 데이터 타입 (html, xml, json, text 등등)
|
||||||
|
data : data,
|
||||||
|
success : function(result) { // 결과 성공 콜백함수
|
||||||
|
alert(result);
|
||||||
|
if(result === 's'){
|
||||||
|
$("#authority_name").attr('disabled','true');
|
||||||
|
}else if(result === 'f'){
|
||||||
|
alert("이미 존재하는 권한 명 입니다");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(request, status, error) {
|
||||||
|
alert(error)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script> -->
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user