|
|
|
|
|
|
|
|
|
alter table OP_WMS_IN_DO_GOODS add MANAGEMENTNO varchar(50)
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
alter table OP_WMS add MANAGEMENTNO varchar(50)
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
ALTER VIEW [dbo].[Vw_Op_Wms] AS select [WMSID]
|
|
|
|
|
,[BSNO]
|
|
|
|
|
,[BILLTYPE]
|
|
|
|
|
,[REMARK]
|
|
|
|
|
,[CORPID]
|
|
|
|
|
,[ModifyID]
|
|
|
|
|
,[Modifier]
|
|
|
|
|
,[ModifyDate]
|
|
|
|
|
,[CreateID]
|
|
|
|
|
,[Creator]
|
|
|
|
|
,[CreateDate]
|
|
|
|
|
,[CUSTOMERNAME]
|
|
|
|
|
,[MATERIALNO]
|
|
|
|
|
,[GOODSCODE]
|
|
|
|
|
,[GOODSNAME]
|
|
|
|
|
,[GOODSHSCODE]
|
|
|
|
|
,[MBLNO]
|
|
|
|
|
,[CNTRNO]
|
|
|
|
|
,[KGS]
|
|
|
|
|
,NETWEIGHT
|
|
|
|
|
,[CBM]
|
|
|
|
|
,[PKGS]
|
|
|
|
|
,[KINDPKGS]
|
|
|
|
|
,[STORAGEUNIT]
|
|
|
|
|
,[STORAGEUNITCOUNT]
|
|
|
|
|
,[RULEUNIT]
|
|
|
|
|
,[RULEUNITCOUNT]
|
|
|
|
|
,[ISCLEAR]
|
|
|
|
|
,[BSSTATUS]
|
|
|
|
|
,[FEESTATUS]
|
|
|
|
|
,[INDATE]
|
|
|
|
|
,[FEESTARTDATE]
|
|
|
|
|
,[FEEENDDATE]
|
|
|
|
|
,[FEERATESTARTDATE]
|
|
|
|
|
,[WMSINDATE]
|
|
|
|
|
,KGS_SINGLE,CBM_SINGLE,STORAGEUNITCOUNT_SINGLE,RULEUNITCOUNT_SINGLE,OP,CUSTOMNO,ACCBOOKNO,GOODSOWNER
|
|
|
|
|
,ARCLIENTWMSOUT,WMSBASEID,WMSPROJECTID,MANAGEMENTNO
|
|
|
|
|
from OP_WMS
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
ALTER VIEW [dbo].[Vw_Op_Wms_Need] AS
|
|
|
|
|
|
|
|
|
|
select w.[WMSID],w.WMSBASEID,w.WMSPROJECTID,w.BSNO,w.CUSTOMERNAME,w.CORPID
|
|
|
|
|
,w.MBLNO,w.CUSTOMNO,w.CNTRNO,w.MANAGEMENTNO,w.GOODSNAME,w.INDATE,w.OP
|
|
|
|
|
,w.KGS-isnull(td.KGS,0)-isnull(opd_0.KGS,0)-isnull(opd.KGS,0)+isnull(odg.KGS,0)-isnull(odg_noplan.KGS,0) [KGS]
|
|
|
|
|
,w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd_0.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)+isnull(odg.NETWEIGHT,0)-isnull(odg_noplan.NETWEIGHT,0) [NETWEIGHT]
|
|
|
|
|
,w.CBM-isnull(td.CBM,0)-isnull(opd_0.CBM,0)-isnull(opd.CBM,0)+isnull(odg.CBM,0)-isnull(odg_noplan.CBM,0) [CBM]
|
|
|
|
|
,w.PKGS-isnull(td.PKGS,0)-isnull(opd_0.PKGS,0)-isnull(opd.PKGS,0)+isnull(odg.PKGS,0)-isnull(odg_noplan.PKGS,0) [PKGS]
|
|
|
|
|
,w.[KINDPKGS]
|
|
|
|
|
,w.[STORAGEUNIT]
|
|
|
|
|
,w.STORAGEUNITCOUNT-isnull(td.STORAGEUNITCOUNT,0)-isnull(opd_0.STORAGEUNITCOUNT,0)-isnull(opd.STORAGEUNITCOUNT,0)+isnull(odg.STORAGEUNITCOUNT,0)-isnull(odg_noplan.STORAGEUNITCOUNT,0)[STORAGEUNITCOUNT]
|
|
|
|
|
,w.[RULEUNIT]
|
|
|
|
|
,-isnull(odg_noplan.KGS,0) KGS_odg_noplan
|
|
|
|
|
,w.RULEUNITCOUNT-isnull(td.RULEUNITCOUNT,0)-isnull(opd_0.RULEUNITCOUNT,0)-isnull(opd.RULEUNITCOUNT,0)+isnull(odg.RULEUNITCOUNT,0)-isnull(odg_noplan.RULEUNITCOUNT,0)[RULEUNITCOUNT]
|
|
|
|
|
,w.[FEESTARTDATE]
|
|
|
|
|
,w.[FEEENDDATE],w.[FEERATESTARTDATE]
|
|
|
|
|
,w.WMSINDATE
|
|
|
|
|
,isnull(w.MBLNO,'')+'_'+isnull(w.CNTRNO,'') MBLNOCNTRNO
|
|
|
|
|
,w.KGS-isnull(td.KGS,0)-isnull(opd_0.KGS,0)-isnull(opd.KGS,0)-isnull(odg_noplan.KGS,0)+
|
|
|
|
|
w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)-isnull(odg_noplan.NETWEIGHT,0)+
|
|
|
|
|
w.CBM-isnull(td.CBM,0)-isnull(opd_0.CBM,0)-isnull(opd.CBM,0)-isnull(odg_noplan.CBM,0)+
|
|
|
|
|
w.PKGS-isnull(td.PKGS,0)-isnull(opd_0.PKGS,0)-isnull(opd.PKGS,0)-isnull(odg_noplan.PKGS,0) ALLSTORAGECOUNT
|
|
|
|
|
,w.GOODSOWNER,w.ARCLIENTWMSOUT
|
|
|
|
|
from Op_Wms w
|
|
|
|
|
|
|
|
|
|
left join(select wmsid,sum(KGS) KGS,sum(NETWEIGHT) NETWEIGHT,sum(CBM) CBM,sum(PKGS) PKGS,sum(STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(RULEUNITCOUNT) RULEUNITCOUNT from OP_WMS_TRANSFERGOODS_DETAIL _td
|
|
|
|
|
where exists (select 1 from OP_WMS_Transfergoods where WMSTRANSFERGOODSID=_td.WMSTRANSFERGOODSID and BILLSTATUS='1000' )
|
|
|
|
|
group by wmsid) td on td.WMSID=w.wmsid
|
|
|
|
|
|
|
|
|
|
left join (select wmsid,sum(KGS) KGS,sum(NETWEIGHT) NETWEIGHT,sum(CBM) CBM,sum(PKGS) PKGS,sum(STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(RULEUNITCOUNT) RULEUNITCOUNT from OP_WMS_OUT_PLAN_DETAIL opd_0
|
|
|
|
|
where exists (select 1 from OP_WMS_OUT_PLAN_BEFORE where WMSOUTPLANBEFOREID=opd_0.WMSPLANID and isnull(OP_WMS_OUT_PLAN_BEFORE.isend,0)=0)
|
|
|
|
|
group by wmsid)opd_0 on opd_0.WMSID=w.WMSID
|
|
|
|
|
|
|
|
|
|
left join (select wmsid,sum(KGS) KGS,sum(NETWEIGHT) NETWEIGHT,sum(CBM) CBM,sum(PKGS) PKGS,sum(STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(RULEUNITCOUNT) RULEUNITCOUNT from OP_WMS_OUT_PLAN_DETAIL _opd
|
|
|
|
|
where exists (select 1 from OP_WMS_OUT_PLAN where WMSPLANID=_opd.WMSPLANID) and
|
|
|
|
|
(select isnull(isend,0) from OP_WMS_OUT_PLAN where WMSPLANID=_opd.WMSPLANID)=0
|
|
|
|
|
and isnull(_opd.PLAN_BEFORE_DETAIL_GID,'00000000-0000-0000-0000-000000000000')='00000000-0000-0000-0000-000000000000'
|
|
|
|
|
group by wmsid)opd on opd.WMSID=w.WMSID
|
|
|
|
|
|
|
|
|
|
left join (select wmsid,sum(KGS) KGS,sum(NETWEIGHT) NETWEIGHT,sum(CBM) CBM,sum(PKGS) PKGS,sum(STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(RULEUNITCOUNT) RULEUNITCOUNT from OP_WMS_OUT_DO_GOODS _odg
|
|
|
|
|
where exists (select 1 from OP_WMS_OUT_DO od where od.WMSDOID=_odg.WMSDOID and od.billstatus='1012' and (select isnull(isend,0) from OP_WMS_OUT_PLAN where WMSPLANID=od.WMSPLANID)=0 )
|
|
|
|
|
or exists (select 1 from OP_WMS_OUT_PLAN_BEFORE where isnull(isend,0)=0 and WMSOUTPLANBEFOREID in (select wmsplanid from OP_WMS_OUT_PLAN_DETAIL where PLAN_BEFORE_DETAIL_GID in (select WMSOUTDETAILID from OP_WMS_OUT_PLAN_DETAIL where WMSPLANDETAILID=_odg.WMSPLANDETAILID)))
|
|
|
|
|
group by wmsid)odg on odg.WMSID=w.WMSID
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ȥ<EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD> δ<EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD> ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
|
|
|
|
|
left join (select wmsid,sum(KGS) KGS,sum(NETWEIGHT) NETWEIGHT,sum(CBM) CBM,sum(PKGS) PKGS,sum(STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(RULEUNITCOUNT) RULEUNITCOUNT from OP_WMS_OUT_DO_GOODS _odg
|
|
|
|
|
where exists (select 1 from OP_WMS_OUT_DO od where od.WMSDOID=_odg.WMSDOID and od.billstatus<>'1012' )
|
|
|
|
|
and _odg.WMSPLANDETAILID is null
|
|
|
|
|
|
|
|
|
|
group by wmsid)odg_noplan on odg_noplan.WMSID=w.WMSID
|
|
|
|
|
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
ALTER View [dbo].[Vw_Op_Wms_Need_Project] as
|
|
|
|
|
select vwn.*,
|
|
|
|
|
p.STOREHOUSE,p.AREACODE from Vw_Op_Wms_Need vwn
|
|
|
|
|
left join OP_WMS_PROJECT wb on wb.WMSPROJECTID=vwn.WMSPROJECTID
|
|
|
|
|
left join OP_WMS_PHYSICS p on p.WMSID=vwn.WMSID and (p.PKGS>0 and (p.KGS>0 or p.CBM>0))
|
|
|
|
|
where vwn.WMSPROJECTID is not null and vwn.ALLSTORAGECOUNT>0
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
alter table OP_WMS_IN_DO add FEESTARTDATE datetime null
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO] AS select D.[BSNO]
|
|
|
|
|
,[WMSDOID]
|
|
|
|
|
,[WMS_PLAN_BSNO]
|
|
|
|
|
,[BILLTYPE]
|
|
|
|
|
,[CUSTOMERNAME]
|
|
|
|
|
,[MATERIALNO]
|
|
|
|
|
,[GOODSCODE]
|
|
|
|
|
,[GOODSNAME]
|
|
|
|
|
,[GOODSHSCODE]
|
|
|
|
|
,[MBLNO]
|
|
|
|
|
,[PAYEDTAXES]
|
|
|
|
|
,[BSSTATUS]
|
|
|
|
|
,[CreateDate]
|
|
|
|
|
,[Creator]
|
|
|
|
|
,[CreateID]
|
|
|
|
|
,[REMARK]
|
|
|
|
|
,[FEESTATUS]
|
|
|
|
|
,[BILLSTATUS]
|
|
|
|
|
,[DODATE]
|
|
|
|
|
,[CORPID]
|
|
|
|
|
,[CUSTOMNO]
|
|
|
|
|
,[GOODSOWNER]
|
|
|
|
|
,[TRUCKNO],dbo.F_INDODETAIL_CNTRNO(d.WMSDOID) CNTRNO,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=GOODSNAME)GOODSFEETYPE,ARCLIENTWMSOUT,APCLIENTWMSOUT,
|
|
|
|
|
(select count(CNTRNO) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) CTNNUM,
|
|
|
|
|
isnull((select sum(KGS) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) KGS,
|
|
|
|
|
isnull((select sum(NETWEIGHT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) NETWEIGHT,
|
|
|
|
|
isnull((select sum(CBM) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) CBM,
|
|
|
|
|
isnull((select sum(PKGS) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) PKGS,
|
|
|
|
|
(select top 1 KINDPKGS from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) KINDPKGS,
|
|
|
|
|
(select top 1 STORAGEUNIT from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) STORAGEUNIT,
|
|
|
|
|
(select top 1 RULEUNIT from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) RULEUNIT,
|
|
|
|
|
isnull((select sum(STORAGEUNITCOUNT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) STORAGEUNITCOUNT,
|
|
|
|
|
isnull((select sum(RULEUNITCOUNT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) RULEUNITCOUNT,
|
|
|
|
|
D.FEESTARTDATE
|
|
|
|
|
from OP_WMS_IN_DO D
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO_PROJECT] AS select
|
|
|
|
|
D.[BSNO]
|
|
|
|
|
,[WMSDOID]
|
|
|
|
|
,D.WMSPROJECTID
|
|
|
|
|
,J.PROJECTNAME
|
|
|
|
|
,[CUSTOMERNAME]
|
|
|
|
|
,[MATERIALNO]
|
|
|
|
|
,[GOODSCODE]
|
|
|
|
|
,D.GOODSNAME
|
|
|
|
|
,[GOODSHSCODE]
|
|
|
|
|
,D.MBLNO
|
|
|
|
|
,[PAYEDTAXES]
|
|
|
|
|
,[BSSTATUS]
|
|
|
|
|
,D.CreateDate
|
|
|
|
|
,D.Creator
|
|
|
|
|
,D.CreateID
|
|
|
|
|
,D.REMARK
|
|
|
|
|
,[FEESTATUS]
|
|
|
|
|
,D.BILLSTATUS
|
|
|
|
|
,[DODATE],D.FEESTARTDATE
|
|
|
|
|
,D.CORPID
|
|
|
|
|
,[CUSTOMNO]
|
|
|
|
|
,[GOODSOWNER]
|
|
|
|
|
,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=D.GOODSNAME)GOODSFEETYPE
|
|
|
|
|
,ARCLIENTWMSOUT,APCLIENTWMSOUT,
|
|
|
|
|
isnull((select sum(KGS) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) KGS,
|
|
|
|
|
isnull((select sum(NETWEIGHT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) NETWEIGHT,
|
|
|
|
|
isnull((select sum(CBM) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) CBM,
|
|
|
|
|
isnull((select sum(PKGS) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) PKGS,
|
|
|
|
|
(select top 1 KINDPKGS from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) KINDPKGS,
|
|
|
|
|
(select top 1 STORAGEUNIT from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) STORAGEUNIT,
|
|
|
|
|
(select top 1 RULEUNIT from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid) RULEUNIT,
|
|
|
|
|
isnull((select sum(STORAGEUNITCOUNT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) STORAGEUNITCOUNT,
|
|
|
|
|
isnull((select sum(RULEUNITCOUNT) from OP_WMS_IN_DO_GOODS where WMSDOID=d.wmsdoid),0) RULEUNITCOUNT
|
|
|
|
|
from OP_WMS_IN_DO D
|
|
|
|
|
left join OP_WMS_PROJECT J on J.WMSPROJECTID=D.WMSPROJECTID
|
|
|
|
|
where EXISTS (select 1 from OP_WMS_PROJECT where WMSPROJECTID=D.WMSPROJECTID)
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|