原材料表:
需求量:生產單裡面mrp_production裡面的需求數量,這裡不能直接和產品相連,因為生產單裡面是原材料而產品表裡是成品,
通過物料清單裡的bom表與產品表相連
select
t6.產品id,
t6.產品名稱,
t6.材質,
t6.規格,
t6.實際庫存,
(t6.需求總量-t6.已領總量+t6.退回總量) as 下單待領數,
(t6.實際庫存-(t6.需求總量-t6.已領總量+t6.退回總量)) as 虛擬庫存,
t6.在途料
from
(select t0.id as 產品id ,t0.name_template as 產品名稱,t1.material as 材質,t1.cust_spec as 規格,
coalesce(t2.sjkc,0) as 實際庫存 ,coalesce(t3.ztqty,0) as 在途料,coalesce(t8.xqqty ,0) as 需求總量,
coalesce(t9.ylqty ,0) as 已領總量,coalesce(t10.thqty ,0) as 退回總量
from product_product t0
left join product_template t1 on t0.product_tmpl_id=t1.id
--需求總量
left join ( select t5.product_id,sum(t0.materialkg) as xqqty from mrp_production t0
left join mrp_bom t1 on t1.id=t0.bom_id
left join mrp_bom_line t5 on t5.bom_id=t1.id
where t0.state!='done' and t0.company_id='4'
group by t0.product_id,t5.product_id
) t8 on t8.product_id=t0.id
-- 已領數量
left join(select t1.product_id , sum(t1.product_uom_qty) as ylqty from stock_picking t0
left join stock_move t1 on t0.id=t1.picking_id
where t1.location_id=get_warehouse_id('恆益原材料倉') and t1.location_dest_id=get_warehouse_id('恆益車間倉')
and t1.state='done'
group by t1.product_id ) t9 on t9.product_id=t0.id
--退回數量
left join(select t1.product_id , sum(t1.product_uom_qty) as thqty from stock_picking t0
left join stock_move t1 on t0.id=t1.picking_id
where t1.location_id=get_warehouse_id('恆益車間倉') and t1.location_dest_id=get_warehouse_id('恆益原材料倉')
and t1.state='done'
group by t1.product_id) t10 on t10.product_id=t0.id
--實際庫存
left join(select product_id,sum(qty) sjkc from stock_quant where location_id=get_warehouse_id('恆益原材料倉') group by product_id) t2
on t2.product_id=t0.id
--在途料 在採購追蹤表裡面相連
left join( select product_id,sum(udlvqty) ztqty from purchase_order_track_report where udlvqty>0 and company='恆益' group by product_id)
t3 on t3.product_id=t0.name_template
where t1.categ_id=3 and t0.id<>15261 ) as t6
where t6.在途料!='0'
;
原 單例模式
下面 中的理解 singleton類之所以是private型構造方法,就是為了防止其它類通過new來建立例項,即如此,那我們就必須用乙個static的方法來建立乙個例項 為什麼要用static的方法?因為既然其它類不能通過new來建立例項,那麼就無法獲取其物件,那麼只用有類的方法來獲取了 class...
思維才是真正的力量,知識只是改變思維的原材料而於
思維才是真正的力量,知識只是改變思維的原材料而於!知識就是力量的描述不準確 思維才是改變一切的力量和源泉 網摘 洛地說 別人都說知識就是力量,知識改變一切,然而我要說的是 思維才是改變一切的力量和源泉,知識你在何處都能學到,但思維是要靠自己去啟發的,你們來學校做研究,要學的不單純是知識,而應該是一種...
多執行緒 單生產單消費模型
建立資源物件,提供儲存和取出方法 使用synchronized 塊實現 created by shaoqinghua on 2018 5 3.定義乙個負責儲存和取出的資源類 public class resource catch interruptedexception e objs 0 obj s...