Create Production Order per X++

本文介绍了在AX系统中通过源代码创建生产订单的过程及注意事项。主要包括初始化生产订单数据、输入生产日期、使用预定义的物料清单和工作计划以及录入生产合同等内容。文章强调了在ProdTableType类中使用insert方法来通知准备工作的必要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

From: http://blog.ak-home.net/CategoryView,category,Dynamics%2BAx%2cProgrammierung%2cAPI.aspx

 

Unlike other modules of AX, there is no class structure which provides the functions of create purchase order.

A scenario like this an interface that parse a test file to be produce goods and generate corresponding production order in AX.

 

The question now is how to create production orders by source code, and all related data should be generated correctlly(include BOM, routing and storage company).

 

1. Initialize the data of the production order of the produced article.

2. enter production and delivery date

3. User parts list and plan of work which are defined

4. enter production contract

 

It is important that the preparation (stored in the database) is notified by “insert” method in class “ProdTableType”, not method “insert” of table “ProdTable”. Only then, the appropriate stock rotation/storage company is generated in the system and a necessary stored references to a sales contract or other production.

For example:

 

Of course, you can create production order in other ways. For example, a production order of a sales order can be created by using the method “initFromSalesLine”.

-- 用户表 CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, name VARCHAR(100) NOT NULL, role ENUM('admin', 'purchaser', 'manager') NOT NULL ); -- 订单表 CREATE TABLE orders ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, order_date DATETIME NOT NULL, status ENUM('pending', 'processing', 'completed') DEFAULT 'pending', FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); -- 产品表 CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, description TEXT ); -- 组件表 CREATE TABLE components ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL ); -- 产品-组件关联表 (多对多) CREATE TABLE product_components ( product_id INT NOT NULL, component_id INT NOT NULL, quantity INT NOT NULL DEFAULT 1, PRIMARY KEY (product_id, component_id), FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE, FOREIGN KEY (component_id) REFERENCES components(id) ON DELETE CASCADE ); -- 板材材质表 CREATE TABLE board_materials ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL UNIQUE ); -- 木皮表 CREATE TABLE wood_veneers ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL UNIQUE ); -- 油漆表 CREATE TABLE paints ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL UNIQUE ); -- 板材表 CREATE TABLE boards ( id INT AUTO_INCREMENT PRIMARY KEY, material_id INT NOT NULL, top_veneer_id INT, bottom_veneer_id INT, paint_id INT, FOREIGN KEY (material_id) REFERENCES board_materials(id), FOREIGN KEY (top_veneer_id) REFERENCES wood_veneers(id), FOREIGN KEY (bottom_veneer_id) REFERENCES wood_veneers(id), FOREIGN KEY (paint_id) REFERENCES paints(id) ); -- 组件生产工艺表 (核心关联) CREATE TABLE component_production ( id INT AUTO_INCREMENT PRIMARY KEY, component_id INT NOT NULL, board_id INT NOT NULL, components_per_board INT NOT NULL, FOREIGN KEY (component_id) REFERENCES components(id) ON DELETE CASCADE, FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE ); -- 采购类型表 CREATE TABLE purchase_types ( id INT AUTO_INCREMENT PRIMARY KEY, type ENUM('board', 'order_product', 'order_component') NOT NULL ); -- 采购记录表 CREATE TABLE purchases ( id INT AUTO_INCREMENT PRIMARY KEY, purchase_type_id INT NOT NULL, order_id INT, product_id INT, component_id INT, board_id INT NOT NULL, quantity INT NOT NULL, purchase_date DATETIME NOT NULL, user_id INT NOT NULL, FOREIGN KEY (purchase_type_id) REFERENCES purchase_types(id), FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE SET NULL, FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE SET NULL, FOREIGN KEY (component_id) REFERENCES components(id) ON DELETE SET NULL, FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); -- 库存记录表 CREATE TABLE inventory ( id INT AUTO_INCREMENT PRIMARY KEY, board_id INT NOT NULL, quantity INT NOT NULL DEFAULT 0, last_updated DATETIME NOT NULL, FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE ); -- 库存流水表 CREATE TABLE inventory_transactions ( id INT AUTO_INCREMENT PRIMARY KEY, inventory_id INT NOT NULL, purchase_id INT, order_id INT, change_type ENUM('in', 'out') NOT NULL, quantity INT NOT NULL, transaction_date DATETIME NOT NULL, FOREIGN KEY (inventory_id) REFERENCES inventory(id) ON DELETE CASCADE, FOREIGN KEY (purchase_id) REFERENCES purchases(id) ON DELETE SET NULL, FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE SET NULL ); 根据表格实现springboot实体类
06-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值