From fe8a9a7c2b7b617beee414d14f9e03729777f9cd Mon Sep 17 00:00:00 2001 From: laoxiao Date: Mon, 8 May 2023 14:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E5=90=8E=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4bc53945-f65a-487e-8aae-a32e60fe31b7.xml | 2868 ++++++++++++++--- ERP_5/apps/financial_info/models.py | 124 +- ERP_5/apps/production_info/models.py | 21 + .../serializer/inspection_serializer.py | 30 + .../serializer/product_task_serializer.py | 148 +- ERP_5/apps/production_info/urls.py | 3 +- .../production_info/views/inspection_views.py | 41 + .../views/product_task_views.py | 25 +- ERP_5/apps/warehouse_info/models.py | 3 + ERP_5/settings/dev.py | 2 +- ERP_5/settings/prod.py | 183 +- ERP_5/wsgi.py | 2 +- 12 files changed, 2867 insertions(+), 583 deletions(-) create mode 100644 ERP_5/apps/production_info/serializer/inspection_serializer.py create mode 100644 ERP_5/apps/production_info/views/inspection_views.py diff --git a/.idea/dataSources/4bc53945-f65a-487e-8aae-a32e60fe31b7.xml b/.idea/dataSources/4bc53945-f65a-487e-8aae-a32e60fe31b7.xml index ca49fd2..f4dd2d1 100644 --- a/.idea/dataSources/4bc53945-f65a-487e-8aae-a32e60fe31b7.xml +++ b/.idea/dataSources/4bc53945-f65a-487e-8aae-a32e60fe31b7.xml @@ -950,1787 +950,3659 @@ SELECT|sys.sys_config:null
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1 int|0s 1 null - + 2 varchar(150)|0s 1 - + name 1 btree - + 1 id 1 - + name name - + 1 bigint|0s 1 null - + 2 int|0s 1 - + 3 int|0s 1 - + group_id permission_id 1 btree - + permission_id btree - + 1 id 1 - + group_id permission_id auth_group_permissions_group_id_permission_id_0cd325b0_uniq - + group_id auth_group id - + permission_id auth_permission id - + 1 int|0s 1 null - + 2 varchar(255)|0s 1 - + 3 int|0s 1 - + 4 varchar(100)|0s 1 - + content_type_id codename 1 btree - + 1 id 1 - + content_type_id codename auth_permission_content_type_id_codename_01ab375a_uniq - + content_type_id django_content_type id - + 1 int|0s 1 - + 2 varchar(30)|0s 1 - + 3 int|0s 1 - + province_id btree - + 1 id 1 - + province_id province id - + 1 int|0s 1 null - + 2 datetime(6)|0s 1 - + 3 longtext|0s - + 4 varchar(200)|0s 1 - + 5 smallint unsigned|0s 1 - + 6 longtext|0s 1 - + 7 int|0s - + 8 bigint|0s 1 - + content_type_id btree - + user_id btree - + 1 id 1 - + content_type_id django_content_type id - + user_id t_user id - + 1 int|0s 1 null - + 2 varchar(100)|0s 1 - + 3 varchar(100)|0s 1 - + app_label model 1 btree - + 1 id 1 - + app_label model django_content_type_app_label_model_76bd3d3b_uniq - + 1 bigint|0s 1 null - + 2 varchar(255)|0s 1 - + 3 varchar(255)|0s 1 - + 4 datetime(6)|0s 1 - + 1 id 1 - + 1 varchar(40)|0s 1 - + 2 longtext|0s 1 - + 3 datetime(6)|0s 1 - + expire_date btree - + 1 session_key 1 - + 1 int|0s 1 - + 2 varchar(30)|0s 1 - + 1 id 1 - + 1 int|0s 1 - + 2 varchar(30)|0s 1 - + 3 int|0s 1 - + nation_id btree - + 1 id 1 - + nation_id nation id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(100)|0s 1 - + 6 varchar(20)|0s - + 1 id 1 - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + + 5 + varchar(28)|0s + 1 + + + 6 + varchar(20)|0s + 1 + + + 7 + varchar(50)|0s + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(512)|0s + + + 11 + decimal(10,2 digit)|0s + 1 + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + bigint|0s + + + 15 + bigint|0s + + + 16 + bigint|0s + + + goods_id + btree + + + parent_goods_id + btree + + + units_id + btree + + + 1 + id + 1 + + + goods_id + t_goods + id + + + parent_goods_id + t_goods + id + + + units_id + t_units + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + int|0s + 1 + + + 6 + varchar(50)|0s + 1 + + + 7 + varchar(20)|0s + 1 + + + 8 + decimal(10,2 digit)|0s + 1 + + + 9 + varchar(512)|0s + + + 10 + bigint|0s + + + 11 + bigint|0s + + + leader_user_id + btree + + + parent_goods_id + btree + + + 1 + id + 1 + + + leader_user_id + t_user + id + + + parent_goods_id + t_goods + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + 5 varchar(100)|0s 1 - + 6 varchar(28)|0s 1 - + 7 varchar(512)|0s - + 8 int|0s 1 - + 9 bigint|0s - + number_code 1 btree - + parent_id btree - + 1 id 1 - + number_code number_code - + parent_id t_category id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(100)|0s 1 - + 6 varchar(11)|0s - + 7 varchar(22)|0s - + 8 varchar(22)|0s - + 9 varchar(50)|0s - + 10 varchar(50)|0s - + 11 varchar(50)|0s - + 12 varchar(50)|0s - + 13 varchar(50)|0s - + 14 varchar(50)|0s - + 15 varchar(50)|0s - + 16 varchar(50)|0s - + 17 varchar(512)|0s - + 18 decimal(20,2 digit)|0s - + 19 decimal(20,2 digit)|0s - + 20 int|0s 1 - + name 1 btree - + 1 id 1 - + name name - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(32)|0s 1 - + 6 varchar(128)|0s 1 - + 7 bigint|0s - + name 1 btree - + parent_id btree - + 1 id 1 - + name name - + parent_id t_dept id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(20)|0s 1 - + 6 varchar(50)|0s - + 7 varchar(50)|0s - + 8 varchar(50)|0s - + 9 varchar(50)|0s - + 10 int|0s - + 11 varchar(512)|0s - + 12 varchar(28)|0s 1 - + 13 decimal(10,2 digit)|0s 1 - + 14 decimal(10,2 digit)|0s 1 - + 15 decimal(10,2 digit)|0s 1 - + 16 decimal(10,2 digit)|0s 1 - + 17 int|0s 1 - + 18 varchar(20)|0s - + 19 bigint|0s - + 20 bigint|0s - + name 1 btree - + number_code 1 btree - + category_id btree - + units_id btree - + 1 id 1 - + name name - + number_code number_code - + category_id t_category id - + units_id t_units id - + 1 bigint|0s 1 null - + 2 decimal(10,2 digit)|0s 1 - + 3 decimal(10,2 digit)|0s 1 - + 4 decimal(10,2 digit)|0s 1 - + 5 decimal(10,2 digit)|0s 1 - + 6 varchar(50)|0s 1 - + 7 bigint|0s - + 8 bigint|0s 1 - + goods_id btree - + warehouse_id btree - + 1 id 1 - + goods_id t_goods id - + warehouse_id t_warehouse id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 int|0s - + 6 varchar(256)|0s - + 7 varchar(50)|0s 1 - + 8 bigint|0s - + parent_id btree - + 1 id 1 - + parent_id t_menu id - - 1 - bigint|0s - 1 - null - - - 2 - varchar(1)|0s - 1 - - - 3 - datetime(6)|0s - 1 - - - 4 - datetime(6)|0s - 1 - - - 5 - varchar(50)|0s - 1 - - - 6 - tinyint(1)|0s - 1 - - - 7 - varchar(8)|0s - 1 - - - 8 - varchar(200)|0s - 1 - - - 9 - varchar(512)|0s - 1 - - - 10 - bigint|0s - - - menu_id - btree - - - 1 - id - 1 - - - menu_id - t_menu - id - - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 datetime(6)|0s 1 - + 6 varchar(28)|0s 1 - + 7 - decimal(5,2 digit)|0s - 1 + decimal(10,2 digit)|0s - + 8 decimal(10,2 digit)|0s 1 - + 9 - varchar(512)|0s + decimal(10,2 digit)|0s + 1 - + 10 - decimal(13,2 digit)|0s - 1 + varchar(512)|0s - + 11 - decimal(10,2 digit)|0s - 1 + varchar(20)|0s - + 12 - decimal(10,2 digit)|0s - 1 + varchar(2)|0s - + 13 varchar(1)|0s 1 - + 14 varchar(20)|0s - + 15 varchar(20)|0s - + 16 varchar(30)|0s - + 17 varchar(20)|0s - + 18 bigint|0s - + 19 bigint|0s - + 20 bigint|0s - + 21 bigint|0s - + + 22 + bigint|0s + + account_id btree - + check_user_id btree - + operator_user_id btree - + + purchase_id + btree + + supplier_id btree - + 1 id 1 - + account_id t_settlement_account id - + check_user_id t_user id - + operator_user_id t_user id - + + purchase_id + t_purchase + id + + supplier_id t_supplier id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 - varchar(20)|0s + varchar(28)|0s 1 - + 6 - varchar(50)|0s - - - 7 - varchar(28)|0s - - - 8 - varchar(512)|0s - - - 9 decimal(10,2 digit)|0s 1 - - 10 + + 7 decimal(10,2 digit)|0s 1 - - 11 - decimal(10,2 digit)|0s - 1 + + 8 + varchar(512)|0s - - 12 + + 9 bigint|0s - - 13 + + 10 bigint|0s - - goods_id + + payment_id btree - - purchase_id + + purchase_storage_id btree - + 1 id 1 - - goods_id - t_goods + + payment_id + t_payment id - - purchase_id - t_purchase + + purchase_storage_id + t_purchase_storage id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 - varchar(32)|0s + varchar(50)|0s 1 - - name - 1 - btree - - - 1 - id - 1 - - - name - name - - - 1 - bigint|0s + + 6 + tinyint(1)|0s + 1 + + + 7 + varchar(8)|0s + 1 + + + 8 + varchar(200)|0s + 1 + + + 9 + varchar(512)|0s + 1 + + + 10 + bigint|0s + + + menu_id + btree + + + 1 + id + 1 + + + menu_id + t_menu + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(28)|0s + 1 + + + 6 + varchar(20)|0s + 1 + + + 7 + varchar(50)|0s + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(512)|0s + + + 11 + decimal(10,2 digit)|0s + 1 + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + decimal(10,2 digit)|0s + 1 + + + 15 + decimal(10,2 digit)|0s + 1 + + + 16 + decimal(10,2 digit)|0s + 1 + + + 17 + decimal(10,2 digit)|0s + 1 + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + goods_id + btree + + + product_task_id + btree + + + units_id + btree + + + 1 + id + 1 + + + goods_id + t_goods + id + + + product_task_id + t_product_task + id + + + units_id + t_units + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + int|0s + 1 + + + 6 + varchar(128)|0s + 1 + + + 7 + varchar(20)|0s + 1 + + + 8 + decimal(10,2 digit)|0s + 1 + + + 9 + decimal(10,2 digit)|0s + 1 + + + 10 + date|0s + + + 11 + varchar(512)|0s + + + 12 + bigint|0s + + + 13 + bigint|0s + + + leader_user_id + btree + + + product_task_id + btree + + + 1 + id + 1 + + + leader_user_id + t_user + id + + + product_task_id + t_product_task + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + + + 6 + varchar(28)|0s + 1 + + + 7 + varchar(20)|0s + 1 + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(28)|0s + 1 + + + 11 + varchar(28)|0s + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + date|0s + + + 15 + date|0s + 1 + + + 16 + varchar(28)|0s + + + 17 + varchar(1)|0s + 1 + + + 18 + decimal(10,2 digit)|0s + 1 + + + 19 + decimal(10,2 digit)|0s + 1 + + + 20 + decimal(10,2 digit)|0s + 1 + + + 21 + varchar(512)|0s + + + 22 + bigint|0s + + + 23 + bigint|0s + + + 24 + bigint|0s + + + 25 + varchar(20)|0s + + + number_code + 1 + btree + + + goods_id + btree + + + sale_id + btree + + + check_user_id + btree + + + 1 + id + 1 + + + number_code + number_code + + + goods_id + t_goods + id + + + sale_id + t_sales + id + + + check_user_id + t_user + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + 1 + + + 6 + varchar(28)|0s + 1 + + + 7 + decimal(5,2 digit)|0s + 1 + + + 8 + decimal(10,2 digit)|0s + 1 + + + 9 + varchar(512)|0s + + + 10 + decimal(13,2 digit)|0s + 1 + + + 11 + decimal(10,2 digit)|0s + 1 + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + varchar(1)|0s + 1 + + + 14 + varchar(20)|0s + + + 15 + varchar(20)|0s + + + 16 + varchar(30)|0s + + + 17 + varchar(20)|0s + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + 21 + bigint|0s + + + account_id + btree + + + check_user_id + btree + + + operator_user_id + btree + + + supplier_id + btree + + + 1 + id + 1 + + + account_id + t_settlement_account + id + + + check_user_id + t_user + id + + + operator_user_id + t_user + id + + + supplier_id + t_supplier + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(20)|0s + 1 + + + 6 + varchar(50)|0s + + + 7 + varchar(28)|0s + + + 8 + varchar(512)|0s + + + 9 + decimal(10,2 digit)|0s + 1 + + + 10 + decimal(10,2 digit)|0s + 1 + + + 11 + decimal(10,2 digit)|0s + 1 + + + 12 + bigint|0s + + + 13 + bigint|0s + + + goods_id + btree + + + purchase_id + btree + + + 1 + id + 1 + + + goods_id + t_goods + id + + + purchase_id + t_purchase + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + 1 + + + 6 + varchar(28)|0s + 1 + + + 7 + varchar(512)|0s + + + 8 + decimal(5,2 digit)|0s + + + 9 + decimal(10,2 digit)|0s + + + 10 + decimal(13,2 digit)|0s + + + 11 + decimal(10,2 digit)|0s + + + 12 + decimal(10,2 digit)|0s + + + 13 + decimal(10,2 digit)|0s + + + 14 + decimal(10,2 digit)|0s + 1 + + + 15 + varchar(1)|0s + 1 + + + 16 + varchar(20)|0s + + + 17 + varchar(20)|0s + + + 18 + varchar(30)|0s + + + 19 + varchar(20)|0s + + + 20 + varchar(1)|0s + 1 + + + 21 + bigint|0s + + + 22 + bigint|0s + + + 23 + bigint|0s + + + 24 + bigint|0s + + + 25 + bigint|0s + + + account_id + btree + + + check_user_id + btree + + + operator_user_id + btree + + + purchase_id + btree + + + supplier_id + btree + + + 1 + id + 1 + + + account_id + t_settlement_account + id + + + check_user_id + t_user + id + + + operator_user_id + t_user + id + + + purchase_id + t_purchase + id + + + supplier_id + t_supplier + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(20)|0s + 1 + + + 6 + varchar(28)|0s + + + 7 + varchar(50)|0s + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(50)|0s + + + 11 + varchar(50)|0s + + + 12 + varchar(512)|0s + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + decimal(10,2 digit)|0s + 1 + + + 15 + decimal(10,2 digit)|0s + 1 + + + 16 + varchar(50)|0s + + + 17 + bigint|0s + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + 21 + bigint|0s + + + category_id + btree + + + goods_id + btree + + + purchase_storage_id + btree + + + units_id + btree + + + warehouse_id + btree + + + 1 + id + 1 + + + category_id + t_category + id + + + goods_id + t_goods + id + + + purchase_storage_id + t_purchase_storage + id + + + units_id + t_units + id + + + warehouse_id + t_warehouse + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + 1 + + + 6 + varchar(28)|0s + 1 + + + 7 + decimal(10,2 digit)|0s + + + 8 + decimal(10,2 digit)|0s + 1 + + + 9 + decimal(10,2 digit)|0s + 1 + + + 10 + varchar(512)|0s + + + 11 + varchar(20)|0s + + + 12 + varchar(2)|0s + + + 13 + varchar(1)|0s + 1 + + + 14 + varchar(20)|0s + + + 15 + varchar(20)|0s + + + 16 + varchar(30)|0s + + + 17 + varchar(20)|0s + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + 21 + bigint|0s + + + 22 + bigint|0s + + + account_id + btree + + + check_user_id + btree + + + customer_id + btree + + + operator_user_id + btree + + + sale_id + btree + + + 1 + id + 1 + + + account_id + t_settlement_account + id + + + check_user_id + t_user + id + + + customer_id + t_customer + id + + + operator_user_id + t_user + id + + + sale_id + t_sales + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(28)|0s + 1 + + + 6 + decimal(10,2 digit)|0s + 1 + + + 7 + decimal(10,2 digit)|0s + 1 + + + 8 + varchar(512)|0s + + + 9 + bigint|0s + + + 10 + bigint|0s + + + deliver_storage_id + btree + + + receipt_id + btree + + + 1 + id + 1 + + + deliver_storage_id + t_sale_deliver + id + + + receipt_id + t_receipt + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(32)|0s + 1 + + + name + 1 + btree + + + 1 + id + 1 + + + name + name + + + 1 + bigint|0s + 1 + null + + + 2 + bigint|0s + 1 + + + 3 + bigint|0s + 1 + + + rolesmodel_id +permissionsmodel_id + 1 + btree + + + permissionsmodel_id + btree + + + 1 + id + 1 + + + rolesmodel_id +permissionsmodel_id + t_roles_permissions_rolesmodel_id_permission_791416f1_uniq + + + rolesmodel_id + t_roles + id + + + permissionsmodel_id + t_permissions + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + 1 + + + 6 + varchar(28)|0s + 1 + + + 7 + varchar(512)|0s + + + 8 + decimal(5,2 digit)|0s + + + 9 + decimal(10,2 digit)|0s + + + 10 + decimal(13,2 digit)|0s + + + 11 + decimal(10,2 digit)|0s + + + 12 + decimal(10,2 digit)|0s + + + 13 + decimal(10,2 digit)|0s + + + 14 + decimal(10,2 digit)|0s + + + 15 + decimal(10,2 digit)|0s + 1 + + + 16 + varchar(1)|0s + 1 + + + 17 + varchar(20)|0s + + + 18 + varchar(20)|0s + + + 19 + varchar(30)|0s + + + 20 + varchar(20)|0s + + + 21 + varchar(1)|0s + 1 + + + 22 + bigint|0s + + + 23 + bigint|0s + + + 24 + bigint|0s + + + 25 + bigint|0s + + + 26 + bigint|0s + + + 27 + bigint|0s + + + account_id + btree + + + check_user_id + btree + + + customer_id + btree + + + operator_user_id + btree + + + sale_id + btree + + + product_task_id + btree + + + 1 + id + 1 + + + account_id + t_settlement_account + id + + + check_user_id + t_user + id + + + customer_id + t_customer + id + + + operator_user_id + t_user + id + + + sale_id + t_sales + id + + + product_task_id + t_product_task + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(20)|0s + 1 + + + 6 + varchar(28)|0s + + + 7 + varchar(50)|0s + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(50)|0s + + + 11 + varchar(50)|0s + + + 12 + varchar(512)|0s + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + decimal(10,2 digit)|0s + 1 + + + 15 + decimal(10,2 digit)|0s + 1 + + + 16 + varchar(50)|0s + + + 17 + bigint|0s + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + 21 + bigint|0s + + + category_id + btree + + + goods_id + btree + + + sale_deliver_id + btree + + + units_id + btree + + + warehouse_id + btree + + + 1 + id + 1 + + + category_id + t_category + id + + + goods_id + t_goods + id + + + sale_deliver_id + t_sale_deliver + id + + + units_id + t_units + id + + + warehouse_id + t_warehouse + id + + + 1 + bigint|0s 1 null - + 2 - bigint|0s + varchar(1)|0s 1 - + 3 - bigint|0s + datetime(6)|0s 1 - - rolesmodel_id -permissionsmodel_id - 1 + + 4 + datetime(6)|0s + 1 + + + 5 + datetime(6)|0s + 1 + + + 6 + varchar(28)|0s + 1 + + + 7 + decimal(5,2 digit)|0s + 1 + + + 8 + decimal(10,2 digit)|0s + 1 + + + 9 + varchar(512)|0s + + + 10 + decimal(13,2 digit)|0s + 1 + + + 11 + decimal(10,2 digit)|0s + 1 + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + varchar(1)|0s + 1 + + + 14 + varchar(20)|0s + + + 15 + varchar(20)|0s + + + 16 + varchar(30)|0s + + + 17 + varchar(20)|0s + + + 18 + bigint|0s + + + 19 + bigint|0s + + + 20 + bigint|0s + + + 21 + bigint|0s + + + account_id btree - - permissionsmodel_id + + check_user_id + btree + + + customer_id + btree + + + operator_user_id btree - + 1 id 1 - - rolesmodel_id -permissionsmodel_id - t_roles_permissions_rolesmodel_id_permission_791416f1_uniq + + account_id + t_settlement_account + id + + + check_user_id + t_user + id + + + customer_id + t_customer + id + + + operator_user_id + t_user + id + + + 1 + bigint|0s + 1 + null + + + 2 + varchar(1)|0s + 1 + + + 3 + datetime(6)|0s + 1 + + + 4 + datetime(6)|0s + 1 + + + 5 + varchar(20)|0s + 1 + + + 6 + varchar(28)|0s + + + 7 + varchar(50)|0s + + + 8 + varchar(50)|0s + + + 9 + varchar(50)|0s + + + 10 + varchar(50)|0s + + + 11 + varchar(512)|0s + + + 12 + decimal(10,2 digit)|0s + 1 + + + 13 + decimal(10,2 digit)|0s + 1 + + + 14 + decimal(10,2 digit)|0s + 1 + + + 15 + bigint|0s + + + 16 + bigint|0s + + + 17 + bigint|0s + + + goods_id + btree + + + sale_id + btree + + + units_id + btree + + + 1 + id + 1 - - rolesmodel_id - t_roles + + goods_id + t_goods id - - permissionsmodel_id - t_permissions + + sale_id + t_sales + id + + + units_id + t_units id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(100)|0s 1 - + 6 varchar(28)|0s 1 - + 7 varchar(512)|0s - + 8 decimal(10,2 digit)|0s - + 9 decimal(10,2 digit)|0s - + 10 int|0s 1 - + 11 tinyint(1)|0s 1 - + name 1 btree - + number_code 1 btree - + 1 id 1 - + name name - + number_code number_code - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(100)|0s 1 - + 6 varchar(11)|0s - + 7 varchar(22)|0s - + 8 varchar(22)|0s - + 9 varchar(50)|0s - + 10 varchar(50)|0s - + 11 varchar(50)|0s - + 12 varchar(50)|0s - + 13 varchar(50)|0s - + 14 varchar(50)|0s - + 15 varchar(50)|0s - + 16 varchar(50)|0s - + 17 varchar(512)|0s - + 18 decimal(20,2 digit)|0s 1 - + 19 decimal(20,2 digit)|0s 1 - + 20 int|0s 1 - + name 1 btree - + 1 id 1 - + name name - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(20)|0s 1 - + 6 varchar(20)|0s - + 7 varchar(512)|0s - + basic_name 1 btree - + 1 id 1 - + basic_name basic_name - + 1 bigint|0s 1 null - + 2 varchar(128)|0s 1 - + 3 datetime(6)|0s - + 4 tinyint(1)|0s 1 - + 5 varchar(150)|0s 1 - + 6 varchar(150)|0s 1 - + 7 varchar(150)|0s 1 - + 8 varchar(254)|0s 1 - + 9 tinyint(1)|0s 1 - + 10 tinyint(1)|0s 1 - + 11 datetime(6)|0s 1 - + 12 varchar(11)|0s - + 13 varchar(128)|0s - + 14 bigint|0s - + username 1 btree - + phone 1 btree - + dept_id btree - + 1 id 1 - + username username - + phone phone - + dept_id t_dept id - + 1 bigint|0s 1 null - + 2 bigint|0s 1 - + 3 int|0s 1 - + usermodel_id group_id 1 btree - + group_id btree - + 1 id 1 - + usermodel_id group_id t_user_groups_usermodel_id_group_id_549edf93_uniq - + usermodel_id t_user id - + group_id auth_group id - + 1 bigint|0s 1 null - + 2 bigint|0s 1 - + 3 int|0s 1 - + usermodel_id permission_id 1 btree - + permission_id btree - + 1 id 1 - + usermodel_id permission_id t_user_user_permissions_usermodel_id_permission_id_190f53a6_uniq - + usermodel_id t_user id - + permission_id auth_permission id - + 1 bigint|0s 1 null - + 2 bigint|0s 1 - + 3 bigint|0s 1 - + usermodel_id rolesmodel_id 1 btree - + rolesmodel_id btree - + 1 id 1 - + usermodel_id rolesmodel_id t_users_roles_usermodel_id_rolesmodel_id_c10fb137_uniq - + usermodel_id t_user id - + rolesmodel_id t_roles id - + 1 bigint|0s 1 null - + 2 varchar(1)|0s 1 - + 3 datetime(6)|0s 1 - + 4 datetime(6)|0s 1 - + 5 varchar(100)|0s 1 - + 6 varchar(50)|0s - + 7 varchar(50)|0s - + 8 varchar(50)|0s - + 9 varchar(50)|0s - + 10 varchar(512)|0s - + 11 decimal(10,2 digit)|0s - + 12 decimal(10,2 digit)|0s - + 13 int|0s 1 - + 14 tinyint(1)|0s 1 - + 15 bigint|0s - + name 1 btree - + leader_user_id btree - + 1 id 1 - + name name - + leader_user_id t_user id diff --git a/ERP_5/apps/financial_info/models.py b/ERP_5/apps/financial_info/models.py index 65538c4..a094a44 100644 --- a/ERP_5/apps/financial_info/models.py +++ b/ERP_5/apps/financial_info/models.py @@ -33,12 +33,12 @@ class PaymentModel(BaseModel): account = models.ForeignKey('basic_info.SettlementAccountModel', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='结算账户,审核之后不能改') - operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator_pay_list', null=True, + operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator14_pay_list', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='财务操作人员,不能修改') # 增加一个冗余字段 operator_user_name = models.CharField('财务人员的真实姓名', max_length=20, null=True, blank=True) - check_user = models.ForeignKey('erp_system.UserModel', related_name='operator3_pay_list', null=True, blank=True, on_delete=models.SET_NULL, + check_user = models.ForeignKey('erp_system.UserModel', related_name='check13_pay_list', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='审核人员,不能修改') # 增加一个冗余字段 check_user_name = models.CharField('审核人员的真实姓名', max_length=20, null=True, blank=True) @@ -102,12 +102,12 @@ class ReceiptModel(BaseModel): account = models.ForeignKey('basic_info.SettlementAccountModel', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='结算账户,审核之后不能改') - operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator2_pay_list', null=True, + operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator12_pay_list', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='财务操作人员,不能修改') # 增加一个冗余字段 operator_user_name = models.CharField('财务人员的真实姓名', max_length=20, null=True, blank=True) - check_user = models.ForeignKey('erp_system.UserModel', related_name='operator4_pay_list', null=True, blank=True, on_delete=models.SET_NULL, + check_user = models.ForeignKey('erp_system.UserModel', related_name='operator11_pay_list', null=True, blank=True, on_delete=models.SET_NULL, verbose_name='审核人员,不能修改') # 增加一个冗余字段 check_user_name = models.CharField('审核人员的真实姓名', max_length=20, null=True, blank=True) @@ -149,61 +149,61 @@ class ReceiptItemModel(BaseModel): # 收款单的模型类 -class ReceiptModel(BaseModel): - pay_date = models.DateTimeField('收款日期') - number_code = models.CharField('单据编号,不让用户填写', max_length=28) - discount_money = models.DecimalField('优惠金额(收款优惠),最多精确到小数点后两位', max_digits=10, default=0, decimal_places=2, - blank=True, null=True) - receipt_money = models.DecimalField('合计 收款金额最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) - this_money = models.DecimalField('实际 收款金额最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) - remark = models.CharField('备注', max_length=512, blank=True, null=True) - currency = models.CharField('货币种类', max_length=20, null=True, choices=currency_choices, default='CNY') - pay_category = models.CharField('收款类型', max_length=2, null=True, choices=pay_choices, default='1') - status = models.CharField('状态,0:未审核,1:已审核', max_length=1, default='0') - - account = models.ForeignKey('basic_info.SettlementAccountModel', null=True, blank=True, on_delete=models.SET_NULL, - verbose_name='结算账户,审核之后不能改') - operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator_pay_list', null=True, - blank=True, on_delete=models.SET_NULL, - verbose_name='财务操作人员,不能修改') - # 增加一个冗余字段 - operator_user_name = models.CharField('财务人员的真实姓名', max_length=20, null=True, blank=True) - check_user = models.ForeignKey('erp_system.UserModel', related_name='operator3_pay_list', null=True, blank=True, on_delete=models.SET_NULL, - verbose_name='审核人员,不能修改') - # 增加一个冗余字段 - check_user_name = models.CharField('审核人员的真实姓名', max_length=20, null=True, blank=True) - - customer = models.ForeignKey('basic_info.CustomerModel', null=True, blank=True, on_delete=models.SET_NULL, - verbose_name='客户,审核之后不能改') - # 增加一个冗余字段 - customer_name = models.CharField('客户名称', max_length=30, null=True, blank=True) - sale = models.ForeignKey('purchase_info.SaleModel', null=True, blank=True, on_delete=models.SET_NULL, - verbose_name='销售订单,审核之后不能改') - attachment_list = models.CharField('附件的id列表,字段的值为: 1,2,3,4', max_length=20, null=True, blank=True) - - class Meta: - db_table = 't_receipt' - verbose_name = '收款单表' - verbose_name_plural = verbose_name - ordering = ['id'] - - -# 收款单中 收款项目的模型类 -class ReceiptItemModel(BaseModel): - # 冗余字段 - storage_code = models.CharField('销售出库单编号,不让用户填写', max_length=28) - deliver_storage = models.ForeignKey('warehouse_info.SaleDeliverModel', related_name='pay_item_list', null=True, blank=True, - on_delete=models.SET_NULL, verbose_name='采购入库单') - - receipt = models.ForeignKey('ReceiptModel', null=True, blank=True, related_name='item_list', on_delete=models.SET_NULL, - verbose_name='收款单,不能改') - should_money = models.DecimalField('应该 收款金额(就是采购入库单中需要支收的金额),最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) - this_money = models.DecimalField('本次 收款金额,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) - - remark = models.CharField('备注', max_length=512, blank=True, null=True) - - class Meta: - db_table = 't_receipt_item' - verbose_name = '收款单中的 收款项目表' - verbose_name_plural = verbose_name - ordering = ['id'] \ No newline at end of file +# class ReceiptModel(BaseModel): +# pay_date = models.DateTimeField('收款日期') +# number_code = models.CharField('单据编号,不让用户填写', max_length=28) +# discount_money = models.DecimalField('优惠金额(收款优惠),最多精确到小数点后两位', max_digits=10, default=0, decimal_places=2, +# blank=True, null=True) +# receipt_money = models.DecimalField('合计 收款金额最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) +# this_money = models.DecimalField('实际 收款金额最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) +# remark = models.CharField('备注', max_length=512, blank=True, null=True) +# currency = models.CharField('货币种类', max_length=20, null=True, choices=currency_choices, default='CNY') +# pay_category = models.CharField('收款类型', max_length=2, null=True, choices=pay_choices, default='1') +# status = models.CharField('状态,0:未审核,1:已审核', max_length=1, default='0') +# +# account = models.ForeignKey('basic_info.SettlementAccountModel', null=True, blank=True, on_delete=models.SET_NULL, +# verbose_name='结算账户,审核之后不能改') +# operator_user = models.ForeignKey('erp_system.UserModel', related_name='operator_pay_list', null=True, +# blank=True, on_delete=models.SET_NULL, +# verbose_name='财务操作人员,不能修改') +# # 增加一个冗余字段 +# operator_user_name = models.CharField('财务人员的真实姓名', max_length=20, null=True, blank=True) +# check_user = models.ForeignKey('erp_system.UserModel', related_name='operator3_pay_list', null=True, blank=True, on_delete=models.SET_NULL, +# verbose_name='审核人员,不能修改') +# # 增加一个冗余字段 +# check_user_name = models.CharField('审核人员的真实姓名', max_length=20, null=True, blank=True) +# +# customer = models.ForeignKey('basic_info.CustomerModel', null=True, blank=True, on_delete=models.SET_NULL, +# verbose_name='客户,审核之后不能改') +# # 增加一个冗余字段 +# customer_name = models.CharField('客户名称', max_length=30, null=True, blank=True) +# sale = models.ForeignKey('purchase_info.SaleModel', null=True, blank=True, on_delete=models.SET_NULL, +# verbose_name='销售订单,审核之后不能改') +# attachment_list = models.CharField('附件的id列表,字段的值为: 1,2,3,4', max_length=20, null=True, blank=True) +# +# class Meta: +# db_table = 't_receipt' +# verbose_name = '收款单表' +# verbose_name_plural = verbose_name +# ordering = ['id'] +# +# +# # 收款单中 收款项目的模型类 +# class ReceiptItemModel(BaseModel): +# # 冗余字段 +# storage_code = models.CharField('销售出库单编号,不让用户填写', max_length=28) +# deliver_storage = models.ForeignKey('warehouse_info.SaleDeliverModel', related_name='pay_item_list', null=True, blank=True, +# on_delete=models.SET_NULL, verbose_name='采购入库单') +# +# receipt = models.ForeignKey('ReceiptModel', null=True, blank=True, related_name='item_list', on_delete=models.SET_NULL, +# verbose_name='收款单,不能改') +# should_money = models.DecimalField('应该 收款金额(就是采购入库单中需要支收的金额),最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) +# this_money = models.DecimalField('本次 收款金额,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) +# +# remark = models.CharField('备注', max_length=512, blank=True, null=True) +# +# class Meta: +# db_table = 't_receipt_item' +# verbose_name = '收款单中的 收款项目表' +# verbose_name_plural = verbose_name +# ordering = ['id'] \ No newline at end of file diff --git a/ERP_5/apps/production_info/models.py b/ERP_5/apps/production_info/models.py index f7af7e2..754aa60 100644 --- a/ERP_5/apps/production_info/models.py +++ b/ERP_5/apps/production_info/models.py @@ -142,3 +142,24 @@ class ProductProcessModel(BaseModel): db_table = 't_product_process' verbose_name = '生产工序表' verbose_name_plural = verbose_name + + +# 生产过程中的验收记录 +class InspectionRecordModel(BaseModel): + inspection_date = models.DateField('验收日期') + inspection_username = models.CharField('验收人员的名字', max_length=20) + inspection_user = models.ForeignKey('erp_system.UserModel', related_name='inspection_in_list', null=True, blank=True, + on_delete=models.SET_NULL, verbose_name='验收人员') + + qualified_count = models.DecimalField('合格数量,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + unqualified_count = models.DecimalField('不合格的数量,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + scrap_count = models.DecimalField('报废的数量', max_digits=10, decimal_places=2, default=0) + remark = models.CharField('备注', max_length=512, blank=True, null=True) + + product_task = models.ForeignKey('ProductTaskModel', on_delete=models.SET_NULL, null=True, blank=True, + verbose_name='生产任务', related_name='inspection_list') + + class Meta: + db_table = 't_inspection_record' + verbose_name = '验收记录表' + verbose_name_plural = verbose_name \ No newline at end of file diff --git a/ERP_5/apps/production_info/serializer/inspection_serializer.py b/ERP_5/apps/production_info/serializer/inspection_serializer.py new file mode 100644 index 0000000..73a2ef8 --- /dev/null +++ b/ERP_5/apps/production_info/serializer/inspection_serializer.py @@ -0,0 +1,30 @@ +from django.db import transaction +from django.db.models import F +from rest_framework import serializers + +from production_info.models import InspectionRecordModel, ProductTaskModel + + +class InspectionRecordSerializer(serializers.ModelSerializer): + """ + 验收记录的序列化器 + """ + + class Meta: + model = InspectionRecordModel + fields = '__all__' + + def create(self, validated_data): + """ + 1、插入一条验收记录数据 + 2、修改生产任务中的: 验收合格数量 + :param validated_data: + :return: + """ + with transaction.atomic(): + # 第一件事情搞定 + irm: InspectionRecordModel = super(InspectionRecordSerializer, self).create(validated_data) + # 修改生产任务中的: 验收合格数量 + ProductTaskModel.objects.filter(id=irm.product_task_id) \ + .update(check_number=F('check_number') + irm.qualified_count) + return irm diff --git a/ERP_5/apps/production_info/serializer/product_task_serializer.py b/ERP_5/apps/production_info/serializer/product_task_serializer.py index 1db8008..ec02769 100644 --- a/ERP_5/apps/production_info/serializer/product_task_serializer.py +++ b/ERP_5/apps/production_info/serializer/product_task_serializer.py @@ -10,7 +10,7 @@ from ERP_5.utils.get_inventory import get_inventory_by_goods from basic_info.models import WarehouseModel from goods_info.models import GoodsModel, GoodsInventoryModel from production_info.models import ProductProcessModel, ProductMaterialModel, ProductTaskModel -from warehouse_info.models import SaleDeliverModel, SaleDeliverItemModel +from warehouse_info.models import SaleDeliverModel, SaleDeliverItemModel, PurchaseStorageModel, PurchaseStorageItemModel class ProductProcessSerializer(serializers.ModelSerializer): @@ -65,17 +65,21 @@ class ProductTaskSerializer(serializers.ModelSerializer): return pt def update(self, instance, validated_data): - if instance.status != '0': - raise ValidationError("生产任务已经生效,不能修改!") - process_list = validated_data.pop('process_list') - material_list = validated_data.pop('material_list') + process_list = [] + material_list = [] + if instance.status == '2': + raise ValidationError("生产任务已经完成,不能修改!") + if 'process_list' in validated_data: + process_list = validated_data.pop('process_list') + if 'material_list' in validated_data: + material_list = validated_data.pop('material_list') old_list1 = instance.process_list old_list2 = instance.material_list with transaction.atomic(): - if old_list1.exists(): + if process_list and old_list1.exists(): # 然后把旧数据删除,因为在validated_data拿不到货品库存数据的ID instance.process_list.all().delete() - if old_list2.exists(): + if material_list and old_list2.exists(): # 然后把旧数据删除,因为在validated_data拿不到货品库存数据的ID instance.material_list.all().delete() for item in process_list: @@ -151,3 +155,133 @@ class GetMaterialSerializer(serializers.Serializer): material_id = serializers.IntegerField(help_text='所属生产物料的主键') pt_id = serializers.IntegerField(help_text='所属生产任务的主键') + +class BackMaterialSerializer(serializers.Serializer): + """ + 退料的序列化器 + """ + + def update(self, instance, validated_data): + pass + + def create(self, validated_data): + # 需要完成4件事情 + with transaction.atomic(): + # 1、插入 入库单 + storage = PurchaseStorageModel.objects.create(invoices_date=timezone.now(), + number_code=generate_code(NumberPrefix['storage'].value), + last_amount=validated_data['money'], + number_count=validated_data['count'], + product_task_id=validated_data['pt_id'], + status='1', + is_other='1') + # 2、插入 入库单中的项目 + goods = GoodsModel.objects.get(pk=validated_data['good_id']) + wh = WarehouseModel.objects.get(pk=validated_data['warehouse_id']) + psi = PurchaseStorageItemModel() + psi.goods_id = goods.id + psi.specification = goods.specification + psi.model_number = goods.model_number + psi.number_code = goods.number_code + psi.color = goods.color + psi.category = goods.category + psi.category_name = goods.category.name + psi.units = goods.units + psi.units_name = goods.units.basic_name + psi.name = goods.name + + psi.purchase_count = validated_data['count'] + psi.purchase_price = validated_data['price'] + psi.purchase_money = validated_data['money'] + psi.warehouse_name = wh.name + psi.warehouse_id = wh.id + + psi.purchase_storage_id = storage.id + psi.save() + + # 3、 修改库存数量 + GoodsInventoryModel.objects \ + .filter(goods_id=goods.id, warehouse_id=wh.id) \ + .update(cur_inventory=F('cur_inventory') + psi.purchase_count) + # 4、 修改生产物料中退料数量 + ProductMaterialModel.objects.filter(id=validated_data['material_id']) \ + .update(back_count=F('back_count') + psi.purchase_count) + + return storage + + goods_number_code = serializers.CharField(help_text='物料的条码或者编号', required=False) + warehouse_name = serializers.CharField(help_text='退还仓库的名字', required=False) + warehouse_id = serializers.IntegerField(help_text='退还仓库的主键') + good_id = serializers.IntegerField(help_text='退还的货品主键') + + count = serializers.DecimalField(help_text='退还数量,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + price = serializers.DecimalField(help_text='退还的成本单价,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + money = serializers.DecimalField(help_text='退还的成本总价,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + + material_id = serializers.IntegerField(help_text='所属生产物料的主键') + pt_id = serializers.IntegerField(help_text='所属生产任务的主键') + + +class ProductStorageSerializer(serializers.Serializer): + """ + 生产入库的序列化器 + """ + + def update(self, instance, validated_data): + pass + + def create(self, validated_data): + # 需要完成4件事情 + with transaction.atomic(): + # 1、插入 入库单 + storage = PurchaseStorageModel.objects.create(invoices_date=timezone.now(), + number_code=generate_code(NumberPrefix['storage'].value), + last_amount=validated_data['money'], + number_count=validated_data['count'], + product_task_id=validated_data['pt_id'], + status='1', + is_other='1') + # 2、插入 入库单中的项目 + goods = GoodsModel.objects.get(pk=validated_data['good_id']) + wh = WarehouseModel.objects.get(pk=validated_data['warehouse_id']) + psi = PurchaseStorageItemModel() + psi.goods_id = goods.id + psi.specification = goods.specification + psi.model_number = goods.model_number + psi.number_code = goods.number_code + psi.color = goods.color + psi.category = goods.category + psi.category_name = goods.category.name + psi.units = goods.units + psi.units_name = goods.units.basic_name + psi.name = goods.name + + psi.purchase_count = validated_data['count'] + psi.purchase_price = validated_data['price'] + psi.purchase_money = validated_data['money'] + psi.warehouse_name = wh.name + psi.warehouse_id = wh.id + + psi.purchase_storage_id = storage.id + psi.save() + + # 3、 修改库存数量 + GoodsInventoryModel.objects \ + .filter(goods_id=goods.id, warehouse_id=wh.id) \ + .update(cur_inventory=F('cur_inventory') + psi.purchase_count) + # 4、 修改生产任务的:已入库数量 + ProductTaskModel.objects.filter(id=validated_data['pt_id']) \ + .update(storage_number=F('storage_number') + psi.purchase_count) + + return storage + + goods_number_code = serializers.CharField(help_text='入库商品的条码或者编号', required=False) + good_id = serializers.IntegerField(help_text='入库的货品主键') + warehouse_name = serializers.CharField(help_text='入库仓库的名字', required=False) + warehouse_id = serializers.IntegerField(help_text='入库仓库的主键') + + count = serializers.DecimalField(help_text='入库数量,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + price = serializers.DecimalField(help_text='成本单价,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + money = serializers.DecimalField(help_text='入库成本总价,最多精确到小数点后两位', max_digits=10, decimal_places=2, default=0) + + pt_id = serializers.IntegerField(help_text='所属生产任务的主键') diff --git a/ERP_5/apps/production_info/urls.py b/ERP_5/apps/production_info/urls.py index 54abf78..24b9538 100644 --- a/ERP_5/apps/production_info/urls.py +++ b/ERP_5/apps/production_info/urls.py @@ -16,7 +16,7 @@ Including another URLconf from django.contrib import admin from django.urls import path, re_path from rest_framework.routers import DefaultRouter -from .views import bom_views, product_task_views +from .views import bom_views, product_task_views, inspection_views from rest_framework_jwt.views import obtain_jwt_token @@ -31,5 +31,6 @@ router.register('bom_material', bom_views.MaterialViewSets) router.register('bom_process', bom_views.ProcessViewSets) router.register('bom', bom_views.GoodsBomViewSet) router.register('products', product_task_views.ProductTaskViewSets) +router.register('inspection', inspection_views.InspectionViewSets) urlpatterns += router.urls diff --git a/ERP_5/apps/production_info/views/inspection_views.py b/ERP_5/apps/production_info/views/inspection_views.py new file mode 100644 index 0000000..a8fb5a0 --- /dev/null +++ b/ERP_5/apps/production_info/views/inspection_views.py @@ -0,0 +1,41 @@ +from rest_framework.viewsets import ModelViewSet + +from production_info.models import InspectionRecordModel +from production_info.serializer.inspection_serializer import InspectionRecordSerializer + + +class InspectionViewSets(ModelViewSet): + """ + create: + 验收记录--新增; + + 验收记录新增, status: 201(成功), return: 新增验收记录信息 + + destroy: + 验收记录--删除 + + 验收记录删除, status: 204(成功), return: None + + update: + 验收记录--修改,注意:其中images_list="1,2,3,4";里面是附件的ID + + 验收记录修改, status: 200(成功), return: 修改后的验收记录信息 + + partial_update: + 验收记录--局部修改,可以传参任意属性的值,服务器会修改指定的属性值 + + 验收记录局部修改, status: 200(成功), return: 修改后的验收记录信息 + + list: + 验收记录--的列表查询 + + 验收记录列表信息, status: 200(成功), return: 验收记录信息列表 + + retrieve: + 查询某一个验收记录 + + 查询指定ID的验收记录, status: 200(成功), return: 用户验收记录 + """ + + queryset = InspectionRecordModel.objects.all() + serializer_class = InspectionRecordSerializer \ No newline at end of file diff --git a/ERP_5/apps/production_info/views/product_task_views.py b/ERP_5/apps/production_info/views/product_task_views.py index 971a88d..7d01d73 100644 --- a/ERP_5/apps/production_info/views/product_task_views.py +++ b/ERP_5/apps/production_info/views/product_task_views.py @@ -8,7 +8,8 @@ from rest_framework.response import Response from ERP_5.utils.base_views import MultipleDestroyMixin, MultipleAuditMixin from ERP_5.utils.paginations import GlobalPagination from production_info.models import ProductTaskModel -from production_info.serializer.product_task_serializer import ProductTaskSerializer, GetMaterialSerializer +from production_info.serializer.product_task_serializer import ProductTaskSerializer, GetMaterialSerializer, \ + BackMaterialSerializer, ProductStorageSerializer class ProductTaskViewSets(viewsets.ModelViewSet, MultipleDestroyMixin, MultipleAuditMixin): @@ -106,5 +107,27 @@ class ProductTaskViewSets(viewsets.ModelViewSet, MultipleDestroyMixin, MultipleA def get_serializer_class(self): if self.action == 'get_material': return GetMaterialSerializer + elif self.action == 'back_material': + return BackMaterialSerializer + elif self.action == 'product_storage': + return ProductStorageSerializer else: return ProductTaskSerializer + + @swagger_auto_schema(method='POST', request_body=BackMaterialSerializer, + operation_description="生产任务中退还物料") + @action(methods=['POST'], detail=False) + def back_material(self, request, *args, **kwargs): + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + result = serializer.save() + return Response({'msg': 'ok'}) + + @swagger_auto_schema(method='POST', request_body=ProductStorageSerializer, + operation_description="生产任务中的生产入库") + @action(methods=['POST'], detail=False) + def product_storage(self, request, *args, **kwargs): + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + result = serializer.save() + return Response({'msg': 'ok'}) \ No newline at end of file diff --git a/ERP_5/apps/warehouse_info/models.py b/ERP_5/apps/warehouse_info/models.py index 8d27dce..82cd1a1 100644 --- a/ERP_5/apps/warehouse_info/models.py +++ b/ERP_5/apps/warehouse_info/models.py @@ -50,6 +50,9 @@ class PurchaseStorageModel(BaseModel): is_other = models.CharField('是否是其他入库,0:采购入库,1:其他入库', max_length=1, default='0') + product_task = models.ForeignKey('production_info.ProductTaskModel', null=True, blank=True, + on_delete=models.SET_NULL, + verbose_name='所属的生产任务') class Meta: db_table = 't_purchase_storage' verbose_name = '入库单表' diff --git a/ERP_5/settings/dev.py b/ERP_5/settings/dev.py index 92b3fbc..678bcc9 100644 --- a/ERP_5/settings/dev.py +++ b/ERP_5/settings/dev.py @@ -152,7 +152,7 @@ USE_TZ = False # https://docs.djangoproject.com/en/3.2/howto/static-files/ STATIC_URL = '/static/' - +STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field diff --git a/ERP_5/settings/prod.py b/ERP_5/settings/prod.py index dabfb0a..d1db9c7 100644 --- a/ERP_5/settings/prod.py +++ b/ERP_5/settings/prod.py @@ -9,12 +9,15 @@ https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ - +import sys +import os +import datetime from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +sys.path.insert(0, os.path.join(BASE_DIR, 'apps')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ @@ -23,10 +26,9 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-o!nl319=c4gr)@c)n#@*kq)zil-i(4puha&59&1o*wd0cbrj!5' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] +# DEBUG = True +ALLOWED_HOSTS = ['*'] # Application definition @@ -37,9 +39,23 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'rest_framework', + 'corsheaders', + 'erp_system', + 'basic_info', + 'goods_info', + 'purchase_info', + 'warehouse_info', + 'financial_info', + 'sale_info', + 'production_info', + # 'django.contrib.staticfiles', # required for serving swagger ui's css/js files + 'drf_yasg', + ] MIDDLEWARE = [ + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -48,6 +64,12 @@ MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +CORS_ORIGIN_WHITELIST = ( + 'http://127.0.0.1:8080', + 'http://localhost:8080', + +) +CORS_ALLOW_CREDENTIALS = True ROOT_URLCONF = 'ERP_5.urls' @@ -70,17 +92,30 @@ TEMPLATES = [ WSGI_APPLICATION = 'ERP_5.wsgi.application' - # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'erp_5', + 'USER': 'laoxiao', + 'PASSWORD': '123456', + 'HOST': '192.168.23.1', + 'PORT': '3306', } } +# 配置Redis数据库 +CACHES = { + "default": { # 默认 + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://192.168.23.1:6379/0", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + } + } +} # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators @@ -100,27 +135,151 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] - # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = 'zh-Hans' -TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True -USE_TZ = True - +USE_TZ = False # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ STATIC_URL = '/static/' +# 配置抽取静态文件之后,存放的目录 +STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static') # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + + + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { # + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s %(filename)s: %(lineno)d %(message)s' + }, + 'simple': { + 'format': '%(levelname)s %(module)s %(lineno)d %(message)s' + }, + }, + 'filters': { # + 'require_debug_true': { # + '()': 'django.utils.log.RequireDebugTrue', + }, + }, + 'handlers': { # + 'console': { # + 'level': 'INFO', + 'filters': ['require_debug_true'], + 'class': 'logging.StreamHandler', + 'formatter': 'verbose' + }, + 'my_con': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + }, + 'file': { + 'level': 'INFO', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(BASE_DIR, 'logs/mangguo.log'), + 'maxBytes': 300 * 1024 * 1024, + 'backupCount': 10, + 'formatter': 'verbose' + }, + }, + 'loggers': { + 'my': { + # 'handlers': ['console', 'file'], + 'handlers': ['console'], + 'level': 'DEBUG', + 'propagate': True, + }, + 'django.db.backends': { + # 'handlers': ['console', 'file'], + 'handlers': ['my_con'], + 'propagate': True, + 'level': 'DEBUG', + }, + + } +} + +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', + ), + 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', + 'DEFAULT_PERMISSION_CLASSES': + ( + # 'rest_framework.permissions.IsAuthenticated', + # 'ERP_5.utils.rbac_permissions.RbacPermission', # 自定义的权限验证 + ) + +} + + +JWT_AUTH = { + 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=1), + 'JWT_RESPONSE_PAYLOAD_HANDLER': 'ERP_5.utils.jwt_handler.my_jwt_response_msg', +} + +# 添加自定义用户模型类(应用名.模型类名) +AUTH_USER_MODEL = 'erp_system.UserModel' + +# 指定自定义认证类路径 +AUTHENTICATION_BACKENDS = ['erp_system.erp_auth.UserLoginAuth'] + + +# SWAGGER 接口文档支持JWT的自动认证(自动在请求头中加入token) +SWAGGER_SETTINGS = { + # 'PERSIST_AUTH': True, + 'REFETCH_SCHEMA_WITH_AUTH': True, + 'REFETCH_SCHEMA_ON_LOGOUT': True, + + 'SECURITY_DEFINITIONS': { + 'JWT': { + 'type': 'apiKey', + 'name': 'Authorization', + 'in': 'header' + }, + } +} + + +# celery +# Broker配置,使用Redis作为消息中间件 +CELERY_BROKER_URL = 'redis://127.0.0.1:6379/4' + +# BACKEND配置,这里使用redis +CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/5' + +# 结果序列化方案 +CELERY_RESULT_SERIALIZER = 'json' + +# 任务结果过期时间,秒 +CELERY_TASK_RESULT_EXPIRES = 60 * 60 * 24 + +# 时区配置 +CELERY_TIMEZONE = 'Asia/Shanghai' + + +BASE_API = 'api/' # 项目BASE API, 如设置时必须以/结尾 +# 权限认证白名单 +WHITE_LIST = [f'/{BASE_API}users/login/', f'/{BASE_API}users/register/', f'/docs/.*', f'/swagger/.*'] +REGEX_URL = '^{url}$' # 权限匹配时,严格正则url + +# 设置媒体路由地址信息 +MEDIA_URL = '/media/' +# # 配置上传件存放的目录,获取media文件夹的完整路径信息 +MEDIA_ROOT = BASE_DIR / 'media' \ No newline at end of file diff --git a/ERP_5/wsgi.py b/ERP_5/wsgi.py index de03e6a..b636b53 100644 --- a/ERP_5/wsgi.py +++ b/ERP_5/wsgi.py @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ERP_5.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ERP_5.settings.prod') application = get_wsgi_application()