diff --git a/sql/v1.1.0/heli.sql b/sql/v1.1.0/heli.sql index 4b2c56d1..8614b97a 100644 --- a/sql/v1.1.0/heli.sql +++ b/sql/v1.1.0/heli.sql @@ -160,3 +160,16 @@ CREATE TABLE `base_serial_number` ( PRIMARY KEY ( `id` ) USING BTREE, UNIQUE KEY `uk_business_segment` ( `business_type`, `segment` ) USING BTREE ) ENGINE = InnoDB COMMENT = '序列号记录表'; + +CREATE ALGORITHM = UNDEFINED DEFINER = `root` @`%` SQL SECURITY DEFINER VIEW `v_storage_material_amount` AS +select `t`.`tenant_id` AS `tenant_id`,`t`.`mat_id` AS `mat_id`,`t`.`mat_name` AS `mat_name`,`t`.`mat_code` AS `mat_code`, + `t`.`wh_id` AS `wh_id`,`t`.`rg_id` AS `rg_id`,`t`.`pn_id` AS `pn_id`,`t`.`spec` AS `spec`,`t`.`unit` AS `unit`, + `t`.`material_type` AS `material_type`,`t`.`lot_no` AS `lot_no`,'' AS `storage_ok_qty`,sum(`t`.`storage_ok_qty`) AS `mat_rest` +from ( + select `st`.`stock_type` AS `stock_type`,`mat`.`tenant_id` AS `tenant_id`,`mat`.`mat_id` AS `mat_id`,`bm`.`code` AS `mat_code`,`bm`.`name` AS `mat_name`, + `mat`.`wh_id` AS `wh_id`,`mat`.`rg_id` AS `rg_id`,`mat`.`pn_id` AS `pn_id`,`mat`.`lot_no` AS `lot_no`,`bm`.`spec` AS `spec`,`bm`.`unit` AS `unit`,`bm`.`material_type` AS `material_type`, + (case when (`st`.`stock_type` = 1) then `mat`.`storage_ok_qty` else (`mat`.`storage_ok_qty` * -(1)) end) AS `storage_ok_qty` + from ((`mes-heli`.`wms_storage_mat` `mat` + left join `mes-heli`.`wms_storage` `st` on((`mat`.`stock_id` = `st`.`id`))) + left join `mes-heli`.`base_material` `bm` on((`mat`.`mat_id` = `bm`.`id`))) + where ((`mat`.`deleted` = 0) and (`st`.`status` <> 3) and (`st`.`deleted` = 0) and (`bm`.`deleted` = 0) and (`bm`.`status` = 1))) `t` group by `t`.`mat_id` \ No newline at end of file