斌哥的Oracle

select distinct TaskNumber, no, h.WarehouseKeeperId
  from LRP_WMTx_H h
  join lrp_wmtx_l l
    on h.oid = l.soid
 where h. TxTypeCode = '302'
   and h.WarehouseKeeperId =
       (select oid from lrp_warehousekeeper where code = 'HB05')
   and h.status = 200;
   


select   h.WarehouseKeeperId,l.tasknumber,l.status,l.*,h.rowid
  from LRP_WMTx_H h
  join lrp_wmtx_l l
    on h.oid = l.soid
 where  1=1
   and h.WarehouseKeeperId =3705875;
   
   
       (select oid from lrp_warehousekeeper where code = 'LYB');
 
select WarehouseKeeperId, t.*,rowid  from LRP_WMTx_H  t where WarehouseKeeperId = 3705875; 

select t.string3, t.* from lrp_warehousekeeper t  where code = 'LYB';
 
---数据闪回
--alter table lrp_wmtx_l enable row movement;
--flashback table lrp_wmtx_l to timestamp to_timestamp('2018-03-21 12:01:00','yyyy-mm-dd hh24:mi:ss');
t_jde_saleinpack    sp --包装
select t.* from t_jde_direction t  ; --起送量中间表
t_jde_batch  ---批次表;物料

select t.* from t_jde_batch t where t.wmlotn like '%201705020028%' ;
select t.* from t_jde_saleinpack T where T.WMITM = 4029;

select t.* from LRP_LocType t
select t.* from lrp_location t where t.loctypeid=219695;
 
select t.* from lrp_materialloctype t;
select t.abctype,  count(*)  from lrp_materialstrategy  t group by t.abctype; 
select count(*), count(distinct t.soid)   from lrp_material t, lrp_materialstrategy t1 where t.soid = t1.soid;
 
select * from v$process where program='ORACLE.EXE(SHAD)'; --当前的数据库连接数
select value from v$parameter where name ='processes';--数据库允许的最大连接数
--alter system set processes = 300 scope = spfile;--修改最大连接数:

/*将ABC分类共享存储区换成E类*/
--Update Lrp_Location Set Abctype='E' Where Abctype Is Null;
/*还原*/
--update LRP_Location set ABCType ='' where  ABCType='E';
/*清空PDA操作员数据  上架*/
UPDATE LRP_WarehouseKeeper SET STRING3='' where Code='SD25';
commit;
select Code,t.* from LRP_WarehouseKeeper t  where Code='SD25';
/*清空PDA操作员数据  拣货*/
--update LRP_WMTx_H set WarehouseKeeperId = ? where soid in (select soid from LRP_WMTx_L where TaskNumber=?);
commit; 
 
select OID,
       SOID,
       POID,
       VERID,
       DVERID,
       WAREHOUSEKEEPERID,
       WarehouseCenterId, 
       t.rowid
  from LRP_WMTx_H t where 
   t.oid in 
('3901717','3901719','3901721','3901723','3901725','3901727','3901729','3901731','3901733');

 where no = 'OU20180123000054'  
   and (WarehouseCenterId = 11285);
select t.tasknumber,printmark, t.*,rowid  from LRP_WMTx_l t where t.soid = 3890454;
select t.* from LRP_WMTx_H t where t.oid in 
('3901717','3901719','3901721','3901723','3901725','3901727','3901729','3901731','3901733');
select t.tasknumber,t.materialid,printmark, t.*,rowid  from LRP_WMTx_l t where t.tasknumber = '201801240001'
and t.materialid =665281;
select t.* from lrp_material t where code  =100260; 
---'5707';   补货
--上架单的托盘号字段在明细是DestStrUserDef3,报工序列号在表头是LOCN 
 select DestStrUserDef3,t.*
   from (select *--count(onhandqty) onhandqty
           from lrp_quant q
           join (select distinct DestStrUserDef3  
                  from LRP_WMTx_H h  --按订单拣货
                  left join LRP_WMTx_L l
                    on h.oid = l.soid /*where h.locn= ?*/
                ) d
             on q.StrUserDef3 = d.DestStrUserDef3) t
  where onhandqty > 0;

--维表
select t.*, t.rowid from tb_constant t;
--客户
select t.* from  BK_Customer t  where   t.code =30200257;  --客户头
select DeliveryDIorection,IsVilidArea, t.* from  BK_Customer_L t where t.soid =3016837; --客户明细

select DeliveryDIorection,IsVilidArea, t.* from  BK_Customer_L t where t.warehousecenterid = 11285; --客户明细
select count(*) ,count(distinct t.soid)  from  bk_customer_l t where t.warehousecenterid = 11285; --客户明细

select DeliveryDIorection ,IsVilidArea, t.* from  BK_Customer_L t where t.soid =3016837 IsVilidArea is not null ; --客户明细

--物流公司就城市
select IsModeTransPortation ,t.* from Lrp_City  t where t.code ='1218668' SOID = 30100435 order by Name;  --城市
select * from LRP_District where SOID = 100094; --城市字典

select * from authority t where t.menu_name like '%物流管理%' ;  
select * from SYS_Operator t  where t.soid in ('24668','2719006'); t.code like '%lyb%' ;
select t.* from SYS_OperatorRole t where t.soid =2719006;  --角色表
select t.* from SYS_SESSIONLOG t  where t.OPERATOR =2719006;  --登陆日志
SELECT *   FROM LRP_WarehouseCenter  WHERE Enable = 1    AND OID = 11283; --仓库
select * from lrp_storeroom t;  --仓间
select t.* from LRP_DispatchOrg t;
select t.* from LRP_DispatchOrg_Op t; 
select t.* from SYS_Operator t;
select t.* from SYS_OperatorRole t;
select t.* from SYS_Role t;

                   and s.isrecvarea = 0
                   and s.isshiparea = 0
                   and s.issampletestarea = 0
                   and s.iskittingarea = 1) a)
                   
--s.IsRecvArea  是否收货区, s.IsShipArea 是否发货区, s.IsSampleTestArea 是否检验区, s.IsKittingArea 是否加工区
select s.IsRecvArea, s.IsShipArea, s.IsSampleTestArea, s.IsKittingArea ,s.* from lrp_storearea s;  --库区
select t.warehousecenterid, t.storeroomid, t.storeareaid, t.code, t.name,t.* from lrp_location t ; --储位
select t.* from lrp_MATERIAL t ; --物料维表
select t.* from LRP_LocType t; --储位类型
select * from user_indexes where UPPER(table_name) ='C##TM';
select * from user_tables  where UPPER(table_name)='BK_COSTCENTERGROUP_OR';
select * from user_TAB_COLUMNS where UPPER(table_name) ='BK_COSTCENTERGROUP_OR'; 
-- PROCESSTYPE ='Y'
select t.PROCESSTYPE from LRP_OutboundNotice_L t;
--这个标识为 PROCESSTYPE ='Y' 


select t.*,rowid  from LRP_LogisticsOrder_H t where t.no = 'LO20180314000003'; -- 物流订单头
select * from LRP_LogisticsOrderMat_L t; --物流订单物料明细
select * from LRP_LogisticsOrderStep_L t; --物流订单步骤明细
select * from LRP_OutboundNotice_H t; --出库订单头
select t.* from LRP_OutboundNotice_L t;--出库订单明细
select t.* from LRP_InboundNotice_H t; --入库通知单头
select t.* from LRP_InboundNotic_L t;  --入库通知单明细 
select t.* from LRP_WarehouseKeeper t; --仓管员
select * from LRP_Division t;--分部
---发运单
LRP_ShipmentOrder_H
LRP_ShipmentOrder_L
select t.* from LRP_WMTx_H t;  --库存事务单头
select t.* from LRP_WMTx_L t; --库存事务单明细
select t.* from LRP_WMTxSerial_L t ;--库存事务单序列号明细
select t.* from LRP_WMTxPerson_L t ;--包装人明细
--调度单
LRP_TransportDispatch_H
LRP_TransportDJ_L

select 
       t.no,
       t.ownerid, --货主
       t.ownerno, --货主单号
       t.warehousekeeperid,--仓管员ID
       t.numbertrailers,--每拖箱数
       t.modetransportation,--备货规则
       t.salesordernumber,--销售出库单号
       t.salescompany,--销售出货公司
       t.salesordertype,--销售出货类型
       t.putawaytype,--上架方式
       t.palletno,--托盘编号
       t.employee,--报工员
       t.storeroomid,--仓间
       t.storeareaid,--库区
       t.noticeno, --退货通知单号
       t.txdatetime, --事务日期时间
       t.*
  from LRP_WMTx_H t;


-- 1271038 1271039  OU20180108000033 内销出库订单头 OU20180111000029  2855456  OU20180105000034  2766406  
select t.status, t.*,rowid  from LRP_OutboundNotice_L t where  oid  = 3886852; where t.no ='LO20171107000022' ;-- 内销出库订明细 
--update LRP_OutboundNotice_H t set status= 200 where  no in ('OU20180308000001');
commit;


--下面判断下推是否生成拣货单
select t.SRCREFSOID, t.*
  from lrp_wmtx_l t  --库存事务单明细
 where t.srcrefsoid in
       (select t.oid
          from LRP_OutboundNotice_H t--出库订单头
         where t.oid in ('2710821', '2679592', '2663248'));
         
  select SrcSOID,BasicQty,SrcOID,MapKey,t.* from LRP_WMTx_L t where SrcSOID = 2794351  ;--库存事务单

--按通知收货单序事薄  库存事务单  按订单拣货

select t.oid,
       t.soid,
       Vendor, -- 供应商
       OrderFrom, -- 订单来源
       OrderNumber, -- 订单号
       OrderType, -- 订单类型
       Status, -- 状态
       NoticeNo, -- 入库通知单号
       OwnerId, -- 货主
       DeliveryDate, -- 送货日期 
       ExpectedArrival, --预计到货时间
       5
  from LRP_WMTx_H t
 where t.NoticeNo = 'IN20180121000002';
 
select t.oid,
       t.soid,
       t.boxno,
       t.deststruserdef3, --托盘号
       t.destbatchno, --批号
       t.materialid,
       t.boxno,
       t.boxunitnum,
       t.boxunitnum_cf,
       DestStoreroomId, --"收货仓间"  
       DestStoreareaId, --"收货库区" 
       DestLocationId, --"收货储位" 
       DestStrUserDef4, --规格        
       DestStrUserDef1, --"第二项目号"    
       InterfaceReturn, -- "接口反馈"
       BasicQty, --基本单位量
       Qty, --数量
       1
  from LRP_WMTx_L t
 where t.soid = 2940901;
  
--onhandqty, --在库量, expectinqty, --待入库量, expectreplenishqty, --待补货量 expectoutqty, --待出货量  
--create table lyb_lrp_quant as 
--select t.*,rowid  from lrp_quant t where t.materialid = 663996;  
select t.warehousecenterid, t.storeroomid, t.storeareaid, t.code, t.name,t.* from lrp_location t ; --储位
 

select onhandqty, --在库
       expectinqty, ----待入
       expectreplenishqty, ---       
       expectoutqty, --待出
       t.storeroomid, --仓间
       t.storeareaid, --仓区
       t.batchno,
       t1.code, --物料CODE
       t4.code, --分布
       t.dictuserdef1, --分布
       t3.code, --库区
       t3.name,
       t.locationid, --储位
       t2.code, --储位
       t2.name,
       t.numuserdef1, ----箱包装量
       onhandqty, --库存量 
       expectoutqty, --待出货量         
       expectinqty, --待入库量
       expectreplenishqty, --待补货量
       t1.code,
       materialid,
       --(onhandqty + expectinqty + expectreplenishqty + expectoutqty) aaaa,
       --在库量,待入库量,待补货量,待出货量
       --t.*,
       t2.LocTypeId, --储位类型
       t5.code,
       t5.name,
       t.warehousecenterid,
       t6.code,
       t6.name,
       t.rowid
  from lrp_quant           t, --库存
       lrp_MATERIAL        t1, --物料维表
       lrp_location        t2, --储位
       lrp_storearea       t3, --库区
       lrp_division        t4, --分布
       LRP_LocType         t5, --储位类型
       LRP_WarehouseCenter t6, --仓间
       t_jde_saleinpack    sp --包装
 where t.materialid = t1.oid(+)
   and t.locationid = t2.soid(+)
   and t.storeareaid = t3.soid(+)
   and t.dictuserdef1 = t4.soid(+)
   and t2.loctypeid = t5.oid(+)
   and t.warehousecenterid = t6.oid(+)
   and sp.wmitm = t1.code(+)
   --and sp.wmwm not in ('BX', 'SB')  
   and t1.CODE =4503;
--and t.onhandqty <0
-- and t.locationid =3393406
--and t.warehousecenterid <> 11287
--and t4.soid = 17182
--and  t2.code like 'HB%' 
--and (t2.code like '%C05-0107%' or t2.code like '%07-2705%')
-- and (onhandqty + expectinqty + expectreplenishqty + expectoutqty) >0
--and t2.code = '1'
;

select t.* from lrp_location  t where  code ='C05-4904';
select t.* from lrp_location  t where  code ='1';


---修改库存量
select t.oid,
       t.materialid,
       t.batchno,
       onhandqty,
       expectinqty,
       expectreplenishqty,
       expectoutqty, 
       rowid
  from lrp_quant t
 where t.oid = 3858509;
 
   
   
  -- and t.materialid in ('17769','660648') and t.locationid =247068;
   
   select t.warehousecenterid, t.storeroomid, t.storeareaid, t.code, t.name,t.* from lrp_location t ; --储位

  -- and t.locationid in ('760218', '760219');
--wms   
create table lrp_quant_bak_20180121 as 
select t.* from lrp_quant t 

    
create table lyb_lrp_quant as 
select t.*,rowid  from lrp_quant t where t.materialid = 663996;
   
--物料
select t.* from lrp_MATERIAL t where t.code = 1064;
select t.* from lrp_location t where t.code = '0104';--储位 

 
<Item Caption="已输入" Key="prepared" Value=" 100"/>
<Item Caption="已确认" Key="confirmed" Value="200"/>
<Item Caption="处理中" Key="handled" Value="  500"/>
<Item Caption="已完成" Key="finished" Value=" 900"/>

--销售订单类型
SO    
S6 --发往分公司
S1   
ST 
SY --外销
SJ --外销
select SalesOrderType
  from LRP_OutboundNotice_H
 where salesordertype <> 'SY'
   and salesordertype <> 'SJ'
 group by SalesOrderType;
 select * from LRP_OutboundNotice_H;
 
onhandqty, --在库量,
expectinqty, --待入库量,
expectreplenishqty, --待补货量
expectoutqty, --待出货量 
t.storeroomid  "仓间", --仓间
t.storeareaid  "仓区", --仓区
t.locationid   "储位", --储位




------------20180305 bak-----
create table LRP_ReprenishStrategy_H_bak as 
select t.* from LRP_ReprenishStrategy_H t where warehousecenterid = 11287; --补货策略
create table LRP_ReplenishStrategy_QM_L_bak as 
select t.* from LRP_ReplenishStrategy_QM_L t; --补货策略库存匹配明细
select t.* from LRP_ReplenishStrategy_QS_L t; --补货策略库存排序明细
create table LRP_ReplenishStrategy_PM_L_bak as 
select t.* from LRP_ReplenishStrategy_PM_L t; --补货策略拣货位匹配明细
select t.* from LRP_ReplenishStrategy_PS_L t; --补货策略拣货位排序明细 
select t.* from LRP_NoticePickStrategy_H t; --订单拣货策略头
select t.* from LRP_NoticePickStrategy_CM_L t; --订单拣货策略条件匹配明细
select t.* from LRP_NoticePickStrategy_QM_L t; --订单拣货策略库存匹配明细
select t.* from LRP_NoticePickStrategy_QS_L t; --订单拣货策略库存排序明细
select t.* from LRP_NoticePickStrategy_PQM_L t; --订单拣货策略整件库存匹配明细
select t.* from LRP_NoticePickStrategy_PQS_L t; --订单拣货策略整件库存排序明细
select t.* from LRP_NoticePickStrategy_SM_L t; --订单拣货策略发货区匹配明细
select t.* from LRP_NoticePickStrategy_SS_L t; --订单拣货策略发货区排序明细

select t.* from LRP_PutawayStrategy_H t; --上架策略
select t.* from LRP_PutawayStrategy_CM_L t; --上架策略条件匹配明细
select t.* from LRP_PutawayStrategy_NoMix_L t; --上架策略不可混放明细
select t.* from LRP_PutawayStrategy_Loc_L t; --上架策略储位匹配明细
select t.* from LRP_PutawayStrategy_LS_L t; --上架策略储位排序明细 

select t.* from LRP_QuantUserDefFields t;--库存预留字段

select t.*,rowid  from lrp_materialloctype t where t.soid = 665279;  --物料-储位类型关系表
select t.* from lrp_materialstrategy t  where t.soid =665279;  --仓储策略明细
select t.*,rowid  from lrp_material t where t.code =100440;
-----------------------------------
truncate table test;
declare
  aa        varchar2(140);
  wa        number;
  leng      number;
begin
  wa := 0; 
  while wa <= 4 loop 
    aa   := wa;
    leng := length(aa);
    while leng <= 9 loop
      aa   := '0' || aa;
      leng := leng + 1;
      if leng = 10 then
        insert into test (aa) values (aa);
        commit;
      end if;
    end loop;
    wa := wa + 1;
  end loop;
end;

--物料仓储策略明细
delete from lrp_materialstrategy t where t.oid in (
select oid  from (
select t.oid,
       row_number() over(partition by poid || soid || verid || dverid || status || enable || nodetype || parentid || tleft || tright || code || name || creator || createtime || modifier || modifytime || strategytype || strategyid || sortorder || warehousecenterid || replenishwarningqty || maxwaitqty || mapcount || slock || abctype order by oid) rn
  from lrp_materialstrategy t )t where rn >1); 
  
select t.* from  lrp_material t where t.oid in (
select oid  from (
select t.oid,
       row_number() over(partition by  t.soid||t.code
       order by soid)
        rn
  from lrp_material t )t where rn >1);   
  
select t.* from test t ;
------------------------------

 1, sqlplus 
 2, sys as sysdba 用户名
 3,tongming       密码
 4,select count(*) from v$process  //查询连接数
 5,select value from v$parameter where name = 'processes' 查询默认允许最大连接数
 6,alter system set processes=300 scope=spfile;  修改链接数
 7,alter system set sessions=335 scope=spfile;  修改会话
 8,重启数据库:
  shutdown immediate;
  startup;

-------------
---查找物料绑定的空储位
select l.oid,
       l.storeareaid,
       l.storeroomid,
       l.CargoCapacity,
       l.sortorder,
       t.PalletQtyLimit, sum(coalesce(q.onhandqty, 0)), sum( coalesce(q.expectoutqty, 0))
  from lrp_location l
  left join lrp_quant q
    on q.locationid = l.oid
  left join LRP_LocType t
    on t.oid = l.loctypeid
 where l.specifymaterialid = 273329  --指定物料  select t.* from lrp_material t where t.oid =273329;
   and l.WAREHOUSECENTERID = 11283   --仓库
   and l.oid in (select L.OID
                   from LRP_Location L
                   join LRP_Storearea A
                     on L.StoreareaId = A.OID
                   join LRP_Storeroom R
                     on L.StoreroomId = R.OID
                   join LRP_LocType T
                     on L.LocTypeId = T.OID
                  where L.LocTypeId = 219695)  ---盒区储位类型
 group by l.oid,
          l.storeareaid,
          l.storeroomid,
          l.WAREHOUSECENTERID,
          l.sortorder,
          l.CargoCapacity,
          t.PalletQtyLimit
having sum(coalesce(q.onhandqty, 0) - coalesce(q.expectoutqty, 0)) = 0
----------------=============== 

 /* 4、散件补货还可以在虚拟库补货 */
select l.oid,l.warehousecenterid,
       l.storeroomid,
       l.storeareaid,
       l.CargoCapacity,
       l.sortorder,
       t.PalletQtyLimit
  from lrp_location l
  join LRP_LocType t
    on t.oid = l.loctypeid
  join LRP_Storearea a
    on L.StoreareaId = A.OID
 where a.code like '%LHXNKQ%'
   and l.warehousecenterid =11283; -- ?
   
----散件拣货
select Q.*
  from LRP_Quant Q
  join LRP_Location L
    on Q.LocationId = L.OID
  join LRP_Storearea A
    on L.StoreareaId = A.OID
  join LRP_Storeroom R
    on L.StoreroomId = R.OID
  join LRP_LocType T
    on L.LocTypeId = T.OID
  join LRP_WarehouseCenter W
    on Q.WarehouseCenterId = W.OID
 where Q.MaterialId = 664093
   and A.IsRecvArea = 0
   and A.IsShipArea = 0
   and A.IsSampleTestArea = 0
   and A.IsKittingArea = 0
   and Q.WarehouseCenterId = 11283
   and Q.OwnerID = 11292
   and Q.OnhandQty - Q.ExpectOutQty > 0
   AND R.Code like '%LHK%'
   and Q.NumUserDef1 = 270000
   and Q.DictUserDef1 = 17182
 order by l.SortOrder desc;


 ---紧急补货 begin

--根据物料 拣货方式 找补货策略
 select oid
   from LRP_ReprenishStrategy_H
  where StrategyTypeFor = 'IP'
    and materialid =665908 --?
    and WarehouseCenterId =11283 --?
    and pickingway ='FCL' --? 
    #0 :665908;
 #1 :11283;
 #2 :FCL; 
  
 --根据物料ABC类型找补货策略
select oid StrategyId
  from LRP_ReprenishStrategy_H
 where StrategyTypeFor = 'IP'
   and pickingway = 'FCL'  --?
   and materialtype like '%B%' --  ?
   and WarehouseCenterId = 11283 --?
#0 :FCL;
#1 :%B%;
#2 :11283; 

 ---紧急补货 end    
 
  
---整件 散件 缺货补货 找源储位
select l.code, L.ABCType ,Q.*
  from LRP_Quant Q
  join LRP_Location L
    on Q.LocationId = L.OID
  join LRP_Storearea A
    on L.StoreareaId = A.OID
  join LRP_Storeroom R
    on L.StoreroomId = R.OID
  join LRP_LocType T
    on L.LocTypeId = T.OID
  join LRP_Division d
    on q.DictUserDef1 = d.OID
 where Q.OnhandQty - Q.ExpectOutQty > 0
   and Q.MaterialId = 665908
   and Q.OID in
       (select Q.OID
          from LRP_Quant Q
          join LRP_Location L
            on Q.LocationId = L.OID
          join LRP_Storearea A
            on L.StoreareaId = A.OID
          join LRP_Storeroom R
            on L.StoreroomId = R.OID
          join LRP_LocType T
            on L.LocTypeId = T.OID
          join LRP_Division D
            on Q.DictUserDef1 = D.OID
         where ((A.Code = 'JHQ') or (A.Code = 'LTK') or (A.Code = 'CCQ'))
         -- and ((L.ABCType <> 'C') or (L.ABCType <> 'D'))
          )
   and Q.WarehouseCenterId = 11283
   and q.NumUserDef1 = 480
   and d.code = 'PT'
 Order by L.SortOrder ASC ;
 
   
 ---整件补货上架 查找目标储位   
 select l.oid,
        l.storeareaid,
        l.storeroomid,
        l.CargoCapacity,
        l.sortorder,
        t.PalletQtyLimit
   from lrp_location l
   left join lrp_quant q
     on q.locationid = l.oid
   left join LRP_LocType t
     on t.oid = l.loctypeid
  where l.islocked = 0
    and l.specifymaterialid = ?
    and l.WAREHOUSECENTERID = ?
    and l.oid in (select L.OID
                    from LRP_Location L
                    join LRP_Storearea A
                      on L.StoreareaId = A.OID
                    join LRP_Storeroom R
                      on L.StoreroomId = R.OID
                    join LRP_LocType T
                      on L.LocTypeId = T.OID
                   where ((A.Code = 'CCQ') or (A.Code = 'JHQ')))
  group by l.oid,
           l.storeareaid,
           l.storeroomid,
           l.WAREHOUSECENTERID,
           l.sortorder,
           l.CargoCapacity,
           t.PalletQtyLimit
 having sum(coalesce(q.onhandqty, 0) - coalesce(q.expectoutqty, 0)) = 0
  Order by L.SortOrder ASC#0 :665908;
 #1 :11283;
----------------
select floor(onhandqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(onhandqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(onhandqty, nvl(wmconv, 1)) || '支' onhandqty, --在库
       floor(expectinqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectinqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectinqty, nvl(wmconv, 1)) || '支' expectinqty,----待入
       floor(expectreplenishqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectreplenishqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectreplenishqty, nvl(wmconv, 1)) || '支' expectreplenishqty,---       
       floor(expectoutqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectoutqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectoutqty, nvl(wmconv, 1)) || '支' expectoutqty,  --待出
            
       t.storeroomid, --仓间
       t.storeareaid, --仓区
       t.batchno,
       t1.code, --物料CODE
       t4.code, --分布
       t.dictuserdef1, --分布
       t3.code, --库区
       t3.name,
       t.locationid, --储位
       t2.code, --储位
       t2.name,
       t.numuserdef1, ----箱包装量
       onhandqty, --库存量 
       expectoutqty, --待出货量         
       expectinqty, --待入库量
       expectreplenishqty, --待补货量
       t1.code,
       materialid,
       --(onhandqty + expectinqty + expectreplenishqty + expectoutqty) aaaa,
       
       --在库量,待入库量,待补货量,待出货量
       --t.*,
       t2.LocTypeId, --储位类型
       t5.code,
       t5.name,
       t.warehousecenterid,
       t6.code,
       t6.name,
       t.rowid
  from lrp_quant           t, --库存
       lrp_MATERIAL        t1, --物料维表
       lrp_location        t2, --储位
       lrp_storearea       t3, --库区
       lrp_division        t4, --分布
       LRP_LocType         t5, --储位类型
       LRP_WarehouseCenter t6, --仓间
       t_jde_saleinpack    sp --包装
 where t.materialid = t1.oid(+)
   and t.locationid = t2.soid(+)
   and t.storeareaid = t3.soid(+)
   and t.dictuserdef1 = t4.soid(+)
   and t2.loctypeid = t5.oid(+)
   and t.warehousecenterid = t6.oid(+)
   and sp.wmitm = t1.code
   --and sp.wmwm not in ('BX', 'SB')
      --and t2.CODE like '%010106%' 
      --and t.onhandqty <0
      -- and t.locationid =3393406
    and t.warehousecenterid <> 11287
      --and t4.soid = 17182
      and  t2.code like 'HB%' 
   --and (t2.code like '%C05-0107%' or t2.code like '%07-2705%')
-- and (onhandqty + expectinqty + expectreplenishqty + expectoutqty) >0
--and t2.code = '1'
;   




select floor(onhandqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(onhandqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(onhandqty, nvl(wmconv, 1)) || '支' onhandqty, --在库
       floor(expectinqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectinqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectinqty, nvl(wmconv, 1)) || '支' expectinqty,----待入
       floor(expectreplenishqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectreplenishqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectreplenishqty, nvl(wmconv, 1)) || '支' expectreplenishqty,---       
       floor(expectoutqty / nvl(numuserdef1, 1)) || '箱' ||
       floor(mod(expectoutqty, nvl(numuserdef1, 1)) / nvl(wmconv, 1)) || '盒' ||
       mod(expectoutqty, nvl(wmconv, 1)) || '支' expectoutqty,  --待出
            
       t.storeroomid, --仓间
       t.storeareaid, --仓区
       t.batchno,
       t1.code, --物料CODE
       t4.code, --分布
       t.dictuserdef1, --分布
       t3.code, --库区
       t3.name,
       t.locationid, --储位
       t2.code, --储位
       t2.name,
       t.numuserdef1, ----箱包装量
       onhandqty, --库存量 
       expectoutqty, --待出货量         
       expectinqty, --待入库量
       expectreplenishqty, --待补货量
       t1.code,
       materialid,
       --(onhandqty + expectinqty + expectreplenishqty + expectoutqty) aaaa,
       
       --在库量,待入库量,待补货量,待出货量
       --t.*,
       t2.LocTypeId, --储位类型
       t5.code,
       t5.name,
       t.warehousecenterid,
       t6.code,
       t6.name,
       t.rowid
  from lrp_quant           t, --库存
       lrp_MATERIAL        t1, --物料维表
       lrp_location        t2, --储位
       lrp_storearea       t3, --库区
       lrp_division        t4, --分布
       LRP_LocType         t5, --储位类型
       LRP_WarehouseCenter t6, --仓间
       t_jde_saleinpack    sp --包装
 where t.materialid = t1.oid(+)
   and t.locationid = t2.soid(+)
   and t.storeareaid = t3.soid(+)
   and t.dictuserdef1 = t4.soid(+)
   and t2.loctypeid = t5.oid(+)
   and t.warehousecenterid = t6.oid(+)
   and sp.wmitm = t1.code
   --and sp.wmwm not in ('BX', 'SB')
      --and t2.CODE like '%010106%' 
      --and t.onhandqty <0
      -- and t.locationid =3393406
    and t.warehousecenterid <> 11287
      --and t4.soid = 17182
      and  t2.code like 'HB%' 
   --and (t2.code like '%C05-0107%' or t2.code like '%07-2705%')
-- and (onhandqty + expectinqty + expectreplenishqty + expectoutqty) >0
--and t2.code = '1'
;

  

posted @ 2018-04-17 20:57  奋斗的少年(逝去2019)  阅读(197)  评论(0编辑  收藏  举报