You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DSWMS/DB/SQL_banben/16 菲尔斯特逻辑修改.sql

373 lines
15 KiB
Transact-SQL

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

CREATE TABLE [dbo].[OP_WMS_TRUCKINFO](
[GID] [uniqueidentifier] NOT NULL,
[TRUCKNO] [varchar](20) NOT NULL,
[TRUCKMODEL] [varchar](50) NULL,
[REMARK] [varchar](200) NULL,
CreateID [uniqueidentifier] NULL,
Creator [varchar](50) NULL,
CreateDate datetime null,
ModifyID[uniqueidentifier] NULL,
Modifier [varchar](50) NULL,
ModifyDate datetime null,
CONSTRAINT [PK_OP_WMS_TRUCKINFO] PRIMARY KEY CLUSTERED
(
[GID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[OP_WMS_TRUCKINFO_DRIVER](
[GID] [uniqueidentifier] NOT NULL,
[PID] [uniqueidentifier] NOT NULL,
[DRIVERNAME] [varchar](50) NOT NULL,
[DRIVERTEL] [varchar](50) NULL,
[LICENSENUM] [varchar](50) NULL,
[REMARK] [varchar](200) NULL,
CONSTRAINT [PK_OP_WMS_TRUCKINFO_DRIVER] PRIMARY KEY CLUSTERED
(
[GID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
create view VW_OP_WMS_TRUCKINFO_DRIVER as
select GID,PID,DRIVERNAME,DRIVERTEL,LICENSENUM,(select top 1 TRUCKNO from OP_WMS_TRUCKINFO where gid=PID) TRUCKNO from OP_WMS_TRUCKINFO_DRIVER
GO
alter table OP_WMS_IN_DO add ARCLIENTWMSOUT varchar(50) null
GO
create VIEW [dbo].[VW_OP_WMS_IN_DO_ACCEPT] AS select D.[BSNO]
,[WMSDOID]
,[WMS_PLAN_BSNO]
,[BILLTYPE]
,[CUSTOMERNAME]
,[GOODSOWNER]
,[ARCLIENTWMSOUT]
,[MATERIALNO]
,[GOODSCODE]
,[GOODSNAME]
,[GOODSHSCODE]
,[MBLNO]
,[PAYEDTAXES]
,[BSSTATUS]
,[CreateDate]
,[Creator]
,[CreateID]
,[REMARK]
,[FEESTATUS]
,[BILLSTATUS]
,[DODATE]
,[CORPID]
,[CUSTOMNO]
,dbo.F_INDODETAIL_CNTRNO(d.WMSDOID) CNTRNO,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=GOODSNAME)GOODSFEETYPE,
(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
from OP_WMS_IN_DO D
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO] AS select D.[BSNO]
,[WMSDOID]
,[WMS_PLAN_BSNO]
,[BILLTYPE]
,[CUSTOMERNAME]
,[GOODSOWNER]
,[ARCLIENTWMSOUT]
,[MATERIALNO]
,[GOODSCODE]
,[GOODSNAME]
,[GOODSHSCODE]
,[MBLNO]
,[PAYEDTAXES]
,[BSSTATUS]
,[CreateDate]
,[Creator]
,[CreateID]
,[REMARK]
,[FEESTATUS]
,[BILLSTATUS]
,[DODATE]
,[CORPID]
,[CUSTOMNO]
,[TRUCKNO],dbo.F_INDODETAIL_CNTRNO(d.WMSDOID) CNTRNO,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=GOODSNAME)GOODSFEETYPE,
(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
from OP_WMS_IN_DO D
GO
alter table OP_WMS_TRUCK add TRUCKMODEL varchar(50) null
GO
alter table OP_WMS_TRUCKINFO add TRUCKTEAM varchar(50) null
GO
alter table OP_WMS_TRUCKINFO add LICENSENUM varchar(50) null
GO
Create view VW_OP_WMS_TRUCKINFO_DRIVER as
select isnull( D.GID,newid()) GID, D.PID,isnull(DRIVERNAME,'') DRIVERNAME,isnull(DRIVERTEL,'')DRIVERTEL,isnull(D.LICENSENUM,'')LICENSENUM
,TRUCKNO ,isnull(TRUCKTEAM,'')TRUCKTEAM,TRUCKMODEL
from OP_WMS_TRUCKINFO T left join OP_WMS_TRUCKINFO_DRIVER D on T.GID=D.PID
GO
ALTER VIEW [dbo].[VW_OP_WMS_FEERATE]
AS
SELECT dbo.OP_WMS_FEERATE_DETAIL.ID, dbo.OP_WMS_FEERATE_DETAIL.FEEMAKETYPE,
dbo.OP_WMS_FEERATE_DETAIL.FEENAME, dbo.OP_WMS_FEERATE_DETAIL.DEFAULTUNIT,
dbo.OP_WMS_FEERATE_DETAIL.FEEPRICE, dbo.OP_WMS_FEERATE_DETAIL.FEETYPE,
dbo.OP_WMS_FEERATE_DETAIL.FEEGRADE, dbo.OP_WMS_FEERATE_DETAIL.FEESCALE,
dbo.OP_WMS_FEERATE_DETAIL.ADDPRICE, dbo.OP_WMS_FEERATE.CORPID,
dbo.OP_WMS_FEERATE.CUSTOMERNAME, dbo.OP_WMS_FEERATE.GOODSFEETYPE,
dbo.OP_WMS_FEERATE.REMARK, dbo.OP_WMS_FEERATE.FEERATEID,OP_WMS_FEERATE.INUSE,ENDPRICE
FROM dbo.OP_WMS_FEERATE INNER JOIN
dbo.OP_WMS_FEERATE_DETAIL ON
dbo.OP_WMS_FEERATE.FEERATEID = dbo.OP_WMS_FEERATE_DETAIL.FEERATEID
GO
alter table OP_WMS_OUT_PLAN_BEFORE add ARCLIENTWMSOUT varchar(50) null
GO
ALTER view [dbo].[VW_OP_WMS_OUT_PLAN_BEFORE]
as
SELECT [WMSOUTPLANBEFOREID]
,[WMSNO]
,[PLANTIME]
,[CUSTOMERNAME]
,[CORPID]
,[REMARK]
,[Creator]
,[CreateID]
,[CreateDate]
,[FEESTATUS]
,[BSSTATUS]
,[ModifyDate]
,[ModifyID]
,[Modifier]
,[ISEND]
,[CUSTOMNO]
,GOODSNAME,GOODSFEETYPE
,dbo.[F_OUTPLANDETAIL_MBLNO]([WMSOUTPLANBEFOREID]) MBLNO
,dbo.[F_OUTPLANDETAIL_CNTRNO]([WMSOUTPLANBEFOREID]) CNTRNO
,GOODSOWNER,BILLSTATUS,ARCLIENTWMSOUT
,(select sum(PKGS) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=[OP_WMS_OUT_PLAN_BEFORE].[WMSOUTPLANBEFOREID]) PKGS
FROM [dbo].[OP_WMS_OUT_PLAN_BEFORE]
GO
alter table OP_WMS_OUT_PLAN_DETAIL add PLAN_BEFORE_DETAIL_GID uniqueidentifier null
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUT_PLAN_DETAIL] AS select opd.[WMSOUTDETAILID]
,opd.[WMSPLANID]
,opd.[WMSID]
,opd.[MBLNO]
,opd.[CNTRNO]
,opd.[MATERIALNO]
,opd.[GOODSCODE]
,opd.[GOODSNAME]
,opd.[GOODSHSCODE]
,opd.[KGS]
,opd.[PKGS]
,opd.[CBM]
,opd.[KINDPKGS]
,opd.[STORAGEUNIT]
,opd.[STORAGEUNITCOUNT]
,opd.[RULEUNIT]
,opd.[RULEUNITCOUNT]
,opd.[WMSPHYSICSID]
,opd.[NETWEIGHT]
,opd.CUSTOMNO,p.AREACODE,p.STOREHOUSE
,w.CUSTOMERNAME,w.GOODSOWNER,w.ARCLIENTWMSOUT,PLAN_BEFORE_DETAIL_GID
from OP_WMS_OUT_PLAN_DETAIL opd left join OP_WMS_PHYSICS p on opd.WMSPHYSICSID=p.WMSPHYSICSID left join OP_WMS w on w.WMSID=opd.WMSID
GO
ALTER VIEW [dbo].[Vw_Op_Wms_Need] AS
select w.[WMSID],w.CUSTOMERNAME,w.CORPID
,w.MBLNO,w.CUSTOMNO,w.CNTRNO,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) [KGS]
,w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd_0.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)+isnull(odg.NETWEIGHT,0) [NETWEIGHT]
,w.CBM-isnull(td.CBM,0)-isnull(opd_0.CBM,0)-isnull(opd.CBM,0)+isnull(odg.CBM,0) [CBM]
,w.PKGS-isnull(td.PKGS,0)-isnull(opd_0.PKGS,0)-isnull(opd.PKGS,0)+isnull(odg.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)[STORAGEUNITCOUNT]
,w.[RULEUNIT]
,w.RULEUNITCOUNT-isnull(td.RULEUNITCOUNT,0)-isnull(opd_0.RULEUNITCOUNT,0)-isnull(opd.RULEUNITCOUNT,0)+isnull(odg.RULEUNITCOUNT,0)[RULEUNITCOUNT]
,w.[FEESTARTDATE]
,w.[FEEENDDATE],w.[FEERATESTARTDATE],w.WMSINDATE
,w.MBLNO+'_'+w.CNTRNO MBLNOCNTRNO
,w.KGS-isnull(td.KGS,0)-isnull(opd_0.KGS,0)-isnull(opd.KGS,0)+
w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)+
w.CBM-isnull(td.CBM,0)-isnull(opd_0.CBM,0)-isnull(opd.CBM,0)+
w.PKGS-isnull(td.PKGS,0)-isnull(opd_0.PKGS,0)-isnull(opd.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
GO
insert into tSysBillType(BillCode,BillName,BillGrp,IsRule,NoLength,IsPrefix,PrefixLen,PrefixNo,IsDate,DateFmt,SerialLen,YearNo,MonthNo,DayNo,MaxSerial,BillHeadTbl,IsOrgPrefix,GID,IsEmpPrefix)values('WM14','<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>','<EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','1',18,'1',4,'CKPL','1','YYYYMMDD',6,'2020','01','01',57,'OP_WMS_OUT_PLAN_BEFORE','0','CD476AF1-B537-43C5-AFD7-50946DC46C51',NULL)
GO
insert sys_billno_set(GID,OPLBNAME,RULEBLNO,RULEDATETYPE,BILLTYPE,COMPANYID,CREATEUSER,CREATETIME,ISEDIT,ISAUTO,CUSTOMHEAD) values( 'CD476AF1-B537-43C5-AFD7-50946DC46C51' , '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>' , 'ί<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>' , 'ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' , 'WM14' , 'Comcab2d43f60454327af30a131fc1d3abd' , NULL , NULL , '1' , NULL , NULL )
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUT_PLAN_DETAIL] AS select opd.[WMSOUTDETAILID]
,opd.[WMSPLANID]
,opd.[WMSID]
,opd.[MBLNO]
,opd.[CNTRNO]
,opd.[MATERIALNO]
,opd.[GOODSCODE]
,opd.[GOODSNAME]
,opd.[GOODSHSCODE]
,opd.[KGS]
,opd.[PKGS]
,opd.[CBM]
,opd.[KINDPKGS]
,opd.[STORAGEUNIT]
,opd.[STORAGEUNITCOUNT]
,opd.[RULEUNIT]
,opd.[RULEUNITCOUNT]
,opd.[WMSPHYSICSID]
,opd.[NETWEIGHT]
,opd.CUSTOMNO,p.AREACODE,p.STOREHOUSE
,w.CUSTOMERNAME,w.GOODSOWNER
,w.ARCLIENTWMSOUT,opd.PLAN_BEFORE_DETAIL_GID
,D.KGS KGS_BEFORE
,D.PKGS PKGS_BEFORE
,D.NETWEIGHT NETWEIGHT_BEFORE
,D.CBM CBM_BEFORE
,D.STORAGEUNITCOUNT STORAGEUNITCOUNT_BEFORE
,D.RULEUNITCOUNT RULEUNITCOUNT_BEFORE
from OP_WMS_OUT_PLAN_DETAIL opd
left join OP_WMS_PHYSICS p on opd.WMSPHYSICSID=p.WMSPHYSICSID
left join OP_WMS w on w.WMSID=opd.WMSID
left join OP_WMS_OUT_PLAN_DETAIL d on d.WMSOUTDETAILID=opd.PLAN_BEFORE_DETAIL_GID
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUT_DO_GOODS]
AS
SELECT odg.WMSDODETAILID, odg.WMSDOID,
odg.WMSPLANDETAILID, odg.MATERIALNO,
odg.GOODSCODE, odg.GOODSNAME,
odg.GOODSHSCODE, odg.MBLNO,
odg.CNTRNO, odg.STOREHOUSE,
odg.AREACODE, odg.KGS, odg.NETWEIGHT,
odg.CBM, odg.PKGS,
odg.KINDPKGS, odg.STORAGEUNIT,
odg.STORAGEUNITCOUNT, odg.RULEUNIT,
odg.RULEUNITCOUNT, odg.WMSID,
od.CUSTOMERNAME, od.WMSNO, od.ISEND,
od.FEESTATUS, od.BSSTATUS, od.BILLSTATUS,
od.CORPID, od.DODATE, od.BSSOURCE,
odg.MBLNO AS Expr1, od.CUSTOMNO_IMPORT,
od.CUSTOMNO, od.PICKUPNAME, od.TRUCKNO,
od.TRUCKMODEL, od.WMSPLANID,w.ARCLIENTWMSOUT
,opd.KGS PLAN_KGS,opd.PKGS PLAN_PKGS,opd.CBM PLAN_CBM,opd.NETWEIGHT PLAN_NETWEIGHT
,opd.STORAGEUNITCOUNT PLAN_STORAGEUNITCOUNT
,opd.RULEUNITCOUNT PLAN_RULEUNITCOUNT
FROM OP_WMS_OUT_DO_GOODS odg
left join dbo.OP_WMS_OUT_DO od ON od.WMSDOID = odg.WMSDOID
left join OP_WMS w on w.WMSID= odg.WMSID
left join OP_WMS_OUT_PLAN_DETAIL opd on opd.WMSOUTDETAILID=odg.WMSPLANDETAILID
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO_ACCEPT_GOODS] AS SELECT WMSDODETAILID, WMSDOID, STOREHOUSE, AREACODE,WIG.KGS, WIG.CBM, WIG.PKGS, WIG.KINDPKGS, WIG.STORAGEUNIT,
WIG.STORAGEUNITCOUNT, WIG.RULEUNIT, WIG.RULEUNITCOUNT, WIG.WMSPLANID, WMSPLANDETAILID, WIG.MBLNO, WIG.CNTRNO, WIG.REMARK, WIG.ARCLIENTWMSOUT,
OP, WIG.NETWEIGHT, REMARK2,ipg.SEALNO SEALNO,ipg.CTNALL,ISNULL(ipg.CUSTOMSINSPECTION, 0) CUSTOMSINSPECTION,
ISNULL(ipg.STOREHOUSEINSPECTION, 0) STOREHOUSEINSPECTION,ipg.GOODSNAME,inplan.COUNTRY
,ACCEPT_PKGS,ACCEPT_KGS,ACCEPT_CBM,ACCEPT_NETWEIGHT,ACCEPT_STORAGEUNITCOUNT,ACCEPT_RULEUNITCOUNT,TRUCKNO
,ipg.PKGS INPLAN_PKGS,ipg.KGS INPLAN_KGS,ipg.CBM INPLAN_CBM,ipg.NETWEIGHT INPLAN_NETWEIGHT
,ipg.STORAGEUNITCOUNT INPLAN_STORAGEUNITCOUNT,ipg.RULEUNITCOUNT INPLAN_RULEUNITCOUNT
,ACCEPT_STOREHOUSE,ACCEPT_AREACODE
FROM dbo.OP_WMS_IN_DO_GOODS AS WIG
left join OP_WMS_IN_PLAN_GOODS ipg on ipg.GID=wig.WMSPLANDETAILID
left join op_wms_in_plan inplan on inplan.WMSPLANID=ipg.WMSPLANID
GO
alter table op_wms_out_plan_before add STOREHOUSEENDDATE datetime null
GO
alter table op_wms_out_plan_before add PICKUPNAME varchar(50) null
GO
alter table op_wms_out_plan_before add ISOUTTRANSFER bit default 0
GO
ALTER view [dbo].[VW_OP_WMS_OUT_PLAN_BEFORE]
as
SELECT [WMSOUTPLANBEFOREID]
,[WMSNO]
,[PLANTIME]
,[CUSTOMERNAME]
,[CORPID]
,[REMARK]
,[Creator]
,[CreateID]
,[CreateDate]
,[FEESTATUS]
,[BSSTATUS]
,[ModifyDate]
,[ModifyID]
,[Modifier]
,[ISEND]
,[CUSTOMNO]
,GOODSNAME,GOODSFEETYPE
,dbo.[F_OUTPLANDETAIL_MBLNO]([WMSOUTPLANBEFOREID]) MBLNO
,dbo.[F_OUTPLANDETAIL_CNTRNO]([WMSOUTPLANBEFOREID]) CNTRNO
,GOODSOWNER,BILLSTATUS,ARCLIENTWMSOUT,STOREHOUSEENDDATE,PICKUPNAME,ISOUTTRANSFER
,(select sum(PKGS) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=[OP_WMS_OUT_PLAN_BEFORE].[WMSOUTPLANBEFOREID]) PKGS
FROM [dbo].[OP_WMS_OUT_PLAN_BEFORE]
GO