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/05 增加仓储费结算对象.sql

444 lines
18 KiB
Transact-SQL

--APCLIENTWMSOUT
--alter table OP_WMS_CHANGE drop column ARCLIENTWMSOUT
--alter table OP_WMS_FEEDUI_CUST_DETAIL drop column ARCLIENTWMSOUT
--alter table OP_WMS_IN_DO drop column ARCLIENTWMSOUT
--GO
/*
/// <summary>
/// 仓储费应收对象
/// </summary>
[Display(Name = "仓储费应收对象")]
[MaxLength(50)]
[Column(TypeName = "varchar(50)")]
[Editable(true)]
public string ARCLIENTWMSOUT { get; set; }
*/
alter table OP_WMS_IN_PLAN add ARCLIENTWMSOUT varchar(50) null
GO
alter table OP_WMS_IN_DO_GOODS add ARCLIENTWMSOUT varchar(50) null
GO
alter table OP_WMS add ARCLIENTWMSOUT varchar(50) null
GO
alter table OP_WMS_TRANSFERGOODS add ARCLIENTWMSOUT varchar(50) null
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_PLAN] AS select [WMSPLANID]
,[WMSNO]
,[MBLNO]
,[CONTRACTNO]
,[BILLTYPE]
,[PLANTIME]
,[ACCDATE]
,[CUSTOMERNAME]
,[CORPID]
,[ACCBOOKNO]
,[KGS]
,[PKGS]
,[CBM]
,[GOODSNAME]
,[KINDPKGS]
,[STORAGEUNIT]
,[STORAGEUNITCOUNT]
,[RULEUNIT]
,[RULEUNITCOUNT]
,[REMARK]
,[BSSOURCE]
,[Creator]
,[CreateID]
,[CreateDate]
,[FEESTATUS]
,[BSSTATUS]
,[TIMEMARK]
,[ModifyDate]
,[ModifyID]
,[Modifier]
,[ISEND]
,[MASTERBSNO]
,[NETWEIGHT]
,[CUSTOMNO]
,[ETA]
,[CTNNUM]
,[JINJINGBEIANSHENBAORIQI]
,[JINGNEISHOUHUOREN]
,[INSPECTION_NO]
,[PLAN_GETTIME]
,[CUSTOMAMOUNT]
,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=GOODSNAME)GOODSFEETYPE
,GOODSOWNER
,BILLSTATUS,ARCLIENTWMSOUT
FROM [OP_WMS_IN_PLAN]
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.KGS,0)+isnull(odg.KGS,0) [KGS]
,w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)+isnull(odg.NETWEIGHT,0) [NETWEIGHT]
,w.CBM-isnull(td.CBM,0)-isnull(opd.CBM,0)+isnull(odg.CBM,0) [CBM]
,w.PKGS-isnull(td.PKGS,0)-isnull(opd.PKGS,0)+isnull(odg.PKGS,0) [PKGS]
,w.[KINDPKGS]
,w.[STORAGEUNIT]
,w.STORAGEUNITCOUNT-isnull(td.STORAGEUNITCOUNT,0)-isnull(opd.STORAGEUNITCOUNT,0)+isnull(odg.STORAGEUNITCOUNT,0)[STORAGEUNITCOUNT]
,w.[RULEUNIT]
,w.RULEUNITCOUNT-isnull(td.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.KGS,0)+
w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0)+
w.CBM-isnull(td.CBM,0)-isnull(opd.CBM,0)+
w.PKGS-isnull(td.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
where (select isnull(isend,0) from OP_WMS_OUT_PLAN where WMSPLANID=_opd.WMSPLANID)=0
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 )
group by wmsid)odg on odg.WMSID=w.WMSID
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.ARCLIENTWMSOUT
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_OUT_DO_GOODS]
AS
SELECT dbo.OP_WMS_OUT_DO_GOODS.WMSDODETAILID, dbo.OP_WMS_OUT_DO_GOODS.WMSDOID,
dbo.OP_WMS_OUT_DO_GOODS.WMSPLANDETAILID, dbo.OP_WMS_OUT_DO_GOODS.MATERIALNO,
dbo.OP_WMS_OUT_DO_GOODS.GOODSCODE, dbo.OP_WMS_OUT_DO_GOODS.GOODSNAME,
dbo.OP_WMS_OUT_DO_GOODS.GOODSHSCODE, dbo.OP_WMS_OUT_DO_GOODS.MBLNO,
dbo.OP_WMS_OUT_DO_GOODS.CNTRNO, dbo.OP_WMS_OUT_DO_GOODS.STOREHOUSE,
dbo.OP_WMS_OUT_DO_GOODS.AREACODE, dbo.OP_WMS_OUT_DO_GOODS.KGS, dbo.OP_WMS_OUT_DO_GOODS.NETWEIGHT,
dbo.OP_WMS_OUT_DO_GOODS.CBM, dbo.OP_WMS_OUT_DO_GOODS.PKGS,
dbo.OP_WMS_OUT_DO_GOODS.KINDPKGS, dbo.OP_WMS_OUT_DO_GOODS.STORAGEUNIT,
dbo.OP_WMS_OUT_DO_GOODS.STORAGEUNITCOUNT, dbo.OP_WMS_OUT_DO_GOODS.RULEUNIT,
dbo.OP_WMS_OUT_DO_GOODS.RULEUNITCOUNT, dbo.OP_WMS_OUT_DO_GOODS.WMSID,
dbo.OP_WMS_OUT_DO.CUSTOMERNAME, dbo.OP_WMS_OUT_DO.WMSNO, dbo.OP_WMS_OUT_DO.ISEND,
dbo.OP_WMS_OUT_DO.FEESTATUS, dbo.OP_WMS_OUT_DO.BSSTATUS, dbo.OP_WMS_OUT_DO.BILLSTATUS,
dbo.OP_WMS_OUT_DO.CORPID, dbo.OP_WMS_OUT_DO.DODATE, dbo.OP_WMS_OUT_DO.BSSOURCE,
dbo.OP_WMS_OUT_DO.MBLNO AS Expr1, dbo.OP_WMS_OUT_DO.CUSTOMNO_IMPORT,
dbo.OP_WMS_OUT_DO.CUSTOMNO, dbo.OP_WMS_OUT_DO.PICKUPNAME, dbo.OP_WMS_OUT_DO.TRUCKNO,
dbo.OP_WMS_OUT_DO.TRUCKMODEL, dbo.OP_WMS_OUT_DO.WMSPLANID,w.ARCLIENTWMSOUT
FROM dbo.OP_WMS_OUT_DO INNER JOIN
dbo.OP_WMS_OUT_DO_GOODS ON dbo.OP_WMS_OUT_DO.WMSDOID = dbo.OP_WMS_OUT_DO_GOODS.WMSDOID
left join OP_WMS w on w.WMSID= OP_WMS_OUT_DO_GOODS.WMSID
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUT_PLAN_NEED]
AS
SELECT [WMSPLANID]
,[WMSNO]
,[PLANTIME]
,[CUSTOMERNAME]
,[CORPID]
,[REMARK]
,[Creator]
,[CreateID]
,[CreateDate]
,[FEESTATUS]
,[BSSTATUS]
,[TIMEMARK]
,[ModifyDate]
,[ModifyID]
,[Modifier]
,[ISEND]
,[CUSTOMNO]
,[GOODSNAME]
,[GOODSFEETYPE]
,[GOODSOWNER]
,[BILLSTATUS],dbo.[F_OUTPLANDETAIL_MBLNO](WMSPLANID) MBLNO,dbo.[F_OUTPLANDETAIL_CNTRNO](WMSPLANID) CNTRNO
,dbo.[F_OUTPLANDETAIL_MBLNO](WMSPLANID)+dbo.[F_OUTPLANDETAIL_CNTRNO](WMSPLANID) MBLNOCNTRNO
FROM dbo.OP_WMS_OUT_PLAN where ISEND='false'
GO
ALTER VIEW [dbo].[VW_OP_WMS_AREAGOODS] AS select w.WMSID,w.BSNO, w.CORPID, p.MBLNO,w.CUSTOMNO,p.CNTRNO,p.CUSTOMERNAME,(select codename from info_client where shortname=p.CUSTOMERNAME)CUSTOMERCODE,p.KGS,p.PKGS,p.CBM,p.NETWEIGHT,p.STORAGEUNITCOUNT,p.RULEUNITCOUNT,p.STORAGEUNIT,p.RULEUNIT,p.GOODSNAME,h.AREANAME STOREHOUSENAME,a.AREANAME,w.INDATE,w.FEERATESTARTDATE,w.WMSINDATE
,p.AREACODE,p.STOREHOUSE,(select top 1 PKGS from OP_WMS_CHANGE where CHANGETYPE in('入库','货转入库') and wmsid=p.WMSID) PKGS_FIRST,w.BILLTYPE,LOWER(w.ACCBOOKNO) ACCBOOKNO
,(select top 1 GOODSFEETYPE from code_goods where GOODNAME=p.GOODSNAME)GOODSFEETYPE,w.GOODSOWNER,w.ARCLIENTWMSOUT
,(select top 1 goodstypegid from code_goods where GOODNAME=p.GOODSNAME)GOODSTYPEGID
from Vw_Op_Wms_Physics_Need p
left join op_wms w on w.WMSID=p.WMSID
left join OP_WMS_STOREHOUSE h on h.AREACODE=p.STOREHOUSE
left join OP_WMS_STOREHOUSE_AREA a on a.AREACODE= p.AREACODE
where (p.PKGS>0 or p.KGS>0 or p.CBM>0)
GO
ALTER VIEW [dbo].[Vw_Op_Wms_FeeBase] 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],FEERATESTARTDATE,WMSINDATE
,isnull([FEEENDDATE],'3000-12-12') [FEEENDDATE]
,[MBLNO]+[CNTRNO] MBLNOCNTRNO
,KGS_SINGLE,CBM_SINGLE,STORAGEUNITCOUNT_SINGLE,RULEUNITCOUNT_SINGLE,OP
,CUSTOMNO,ACCBOOKNO,GOODSOWNER,ARCLIENTWMSOUT
from OP_WMS
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
from OP_WMS
GO
ALTER VIEW [dbo].[VW_OP_WMS_TRANSFERGOODS] AS select G.[WMSTRANSFERGOODSID]
,[BSNO]
,[OLDCUSTOMERNAME]
,[TRANSFERDATE]
,[STOREHOUSEDAYS]
,[STOREHOUSEENDDATE]
,[WMSINFEE_OLDCUST]
,[WMSOUTFEE_OLDCUST]
,[REMARK]
,[CORPID]
,[ModifyID]
,[Modifier]
,[ModifyDate]
,[CreateID]
,[Creator]
,[CreateDate]
,[BILLSTATUS]
,[NEWCUSTOMERNAME]
,[OLD_GOODSOWNER]
,[NEW_GOODSOWNER]
,[USENEWFEERATEDATE]
,[NEWFEERATEDATE]
,[ARCLIENTWMSOUT],(select top 1 MBLNO from OP_WMS where exists (select 1 from OP_WMS_TRANSFERGOODS_DETAIL d where d.WMSID=op_wms.WMSID and d.WMSTRANSFERGOODSID=g.WMSTRANSFERGOODSID)) MBLNO,(select name from company where GID=CORPID) COMPANYNAME
,isnull((select sum(KGS) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) KGS
,isnull((select sum(CBM) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) CBM
,isnull((select sum(PKGS) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) PKGS
,isnull((select sum(NETWEIGHT) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) NETWEIGHT
,isnull((select sum(STORAGEUNITCOUNT) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) STORAGEUNITCOUNT
,isnull((select sum(RULEUNITCOUNT) from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=G.WMSTRANSFERGOODSID),0) RULEUNITCOUNT
from OP_WMS_TRANSFERGOODS G
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO_GOODS]
AS
SELECT WMSDODETAILID, WMSDOID, STOREHOUSE, AREACODE, KGS, CBM, PKGS, KINDPKGS, STORAGEUNIT,
STORAGEUNITCOUNT, RULEUNIT, RULEUNITCOUNT, WMSPLANID, WMSPLANDETAILID, MBLNO, CNTRNO, REMARK, ARCLIENTWMSOUT,
OP, NETWEIGHT, REMARK2,(select top 1 SEALNO from OP_WMS_IN_PLAN_GOODS where GID = WIG.WMSPLANDETAILID)SEALNO,
(select top 1 CTNALL from OP_WMS_IN_PLAN_GOODS where GID = WIG.WMSPLANDETAILID)CTNALL,
(SELECT ISNULL(CUSTOMSINSPECTION, 0) AS Expr1
FROM dbo.OP_WMS_IN_PLAN_GOODS
WHERE (GID = WIG.WMSPLANDETAILID)) AS CUSTOMSINSPECTION,
(SELECT ISNULL(STOREHOUSEINSPECTION, 0) AS Expr1
FROM dbo.OP_WMS_IN_PLAN_GOODS
WHERE (GID = WIG.WMSPLANDETAILID)) AS STOREHOUSEINSPECTION
FROM dbo.OP_WMS_IN_DO_GOODS AS WIG
GO
ALTER VIEW [dbo].[VW_WMS_IN_PLAN_GOODS_NEEDDO] AS SELECT * from (
select g.CBM,g.CNTRNO,g.SEALNO,g.CUSTOMSINSPECTION,g.GID,g.GOODSCODE,p.GOODSNAME,g.GOODSHSCODE,g.KGS,g.NETWEIGHT,g.PKGS,g.KINDPKGS,g.MATERIALNO
,g.REMARK,g.RULEUNIT,g.RULEUNITCOUNT,g.STORAGEUNIT,g.STORAGEUNITCOUNT,g.STOREHOUSEINSPECTION,g.WMSPLANID,p.CUSTOMNO,
--g.*
--,
p.mblno MBLNO ,p.mblno+'-'+g.CNTRNO MBLNOCNTRNO,isnull(p.ISEND,'false') ISEND,p.PLANTIME,p.CUSTOMERNAME,p.BSSTATUS planbsstatus
,p.ETA,p.CTNNUM,p.JINJINGBEIANSHENBAORIQI,p.JINGNEISHOUHUOREN,p.INSPECTION_NO,p.PLAN_GETTIME
,isnull((select sum(pkgs) from OP_WMS_IN_DO_GOODS where WMSPLANDETAILID=g.GID),0) DONEPKGS
,isnull((select sum(kgs) from OP_WMS_IN_DO_GOODS where WMSPLANDETAILID=g.GID),0) DONEKGS
,p.GOODSOWNER,g.CTNALL,p.ARCLIENTWMSOUT
from OP_WMS_IN_PLAN_GOODS g
left join OP_WMS_IN_PLAN p on p.WMSPLANID=g.WMSPLANID)t
where ISEND='false' and planbsstatus='true' and (PKGS<>DONEPKGS AND KGS<>DONEKGS)
GO
ALTER view [dbo].[VW_OP_REP_HISTORYSTORAGE] as
select b.WMSLOGID,b.CHANGETYPE,b.PKGS3,b.KGS3,b.CBM3,b.NETWEIGHT3,b.STORAGEUNITCOUNT3,w.STORAGEUNIT,b.RULEUNITCOUNT3,w.RULEUNIT,b.DODATE
,w.INDATE,w.BSNO,w.CUSTOMERNAME,w.GOODSNAME,cg.GOODSFEETYPE,cg.GoodsTypeGID,w.MBLNO,w.CNTRNO,w.CORPID ,w.WMSID,w.FEERATESTARTDATE,w.WMSINDATE
,'' STOREHOUSE,'' AREACODE,(select top 1 CUSTOMNO from OP_WMS_IN_DO where mblno=w.MBLNO) CUSTOMNO,w.GOODSOWNER,w.ARCLIENTWMSOUT
from op_wms_change b
left join op_wms w on w.wmsid=b.wmsid
left join code_goods cg on cg.GOODNAME=w.GOODSNAME
where dodate=(select max(dodate) from op_wms_change c where wmsid=b.wmsid)
GO
ALTER VIEW [dbo].[VW_OP_WMS_REPORT_TIMEZONES_DETAIL_BYCLIENT] AS select D.REPORTID
,sum(d.PKGS) PKGS,sum(d.KGS) KGS,sum(d.CBM) CBM,sum(d.NETWEIGHT) NETWEIGHT,sum(d.STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(d.RULEUNITCOUNT) RULEUNITCOUNT
,sum(d.PKGS2_1) PKGS2_1,sum(d.KGS2_1) KGS2_1,sum(d.CBM2_1) CBM2_1,sum(d.NETWEIGHT2_1) NETWEIGHT2_1,sum(d.STORAGEUNITCOUNT2_1) STORAGEUNITCOUNT2_1,sum(d.RULEUNITCOUNT2_1) RULEUNITCOUNT2_1
,sum(d.PKGS2_2) PKGS2_2,sum(d.KGS2_2) KGS2_2,sum(d.CBM2_2) CBM2_2,sum(d.NETWEIGHT2_2) NETWEIGHT2_2,sum(d.STORAGEUNITCOUNT2_2) STORAGEUNITCOUNT2_2,sum(d.RULEUNITCOUNT2_2) RULEUNITCOUNT2_2
,sum(d.PKGS3) PKGS3,sum(d.KGS3) KGS3,sum(d.CBM3) CBM3,sum(d.NETWEIGHT3) NETWEIGHT3,sum(d.STORAGEUNITCOUNT3) STORAGEUNITCOUNT3,sum(d.RULEUNITCOUNT3) RULEUNITCOUNT3
,w.CUSTOMERNAME,isnull(w.GOODSOWNER,'') GOODSOWNER
from OP_WMS_REPORT_TIMEZONES_DETAIL D
left join op_wms w on w.wmsid=d.WMSID
group by D.REPORTID,w.CUSTOMERNAME,w.GOODSOWNER
GO
ALTER VIEW [dbo].[VW_OP_WMS_REPORT_TIMEZONES_DETAIL_BYMBLNO] AS select D.REPORTID
,sum(d.PKGS) PKGS,sum(d.KGS) KGS,sum(d.CBM) CBM,sum(d.NETWEIGHT) NETWEIGHT,sum(d.STORAGEUNITCOUNT) STORAGEUNITCOUNT,sum(d.RULEUNITCOUNT) RULEUNITCOUNT
,sum(d.PKGS2_1) PKGS2_1,sum(d.KGS2_1) KGS2_1,sum(d.CBM2_1) CBM2_1,sum(d.NETWEIGHT2_1) NETWEIGHT2_1,sum(d.STORAGEUNITCOUNT2_1) STORAGEUNITCOUNT2_1,sum(d.RULEUNITCOUNT2_1) RULEUNITCOUNT2_1
,sum(d.PKGS2_2) PKGS2_2,sum(d.KGS2_2) KGS2_2,sum(d.CBM2_2) CBM2_2,sum(d.NETWEIGHT2_2) NETWEIGHT2_2,sum(d.STORAGEUNITCOUNT2_2) STORAGEUNITCOUNT2_2,sum(d.RULEUNITCOUNT2_2) RULEUNITCOUNT2_2
,sum(d.PKGS3) PKGS3,sum(d.KGS3) KGS3,sum(d.CBM3) CBM3,sum(d.NETWEIGHT3) NETWEIGHT3,sum(d.STORAGEUNITCOUNT3) STORAGEUNITCOUNT3,sum(d.RULEUNITCOUNT3) RULEUNITCOUNT3
,w.MBLNO ,w.CUSTOMERNAME,isnull(w.GOODSOWNER ,'') GOODSOWNER
,w.GOODSNAME,cg.GOODSFEETYPE,cg.GoodsTypeGID
from OP_WMS_REPORT_TIMEZONES_DETAIL D
left join op_wms w on w.wmsid=d.WMSID
left join code_goods cg on cg.GOODNAME=w.GOODSNAME
group by D.REPORTID,w.MBLNO,w.GOODSNAME,w.CUSTOMERNAME,w.GOODSOWNER,cg.GOODSFEETYPE,cg.GoodsTypeGID
GO
ALTER view [dbo].[VW_OP_WMS_REPORT_TIMEZONES_DETAIL] as
SELECT [ID]
,[REPORTID]
,d.[WMSID]
,w.MBLNO,w.CNTRNO,w.GOODSNAME,w.CUSTOMERNAME
,isnull(w.GOODSOWNER,'') GOODSOWNER
,isnull(w.CUSTOMNO,'')CUSTOMNO
,w.OP
,isnull(cg.GOODSFEETYPE,'')GOODSFEETYPE
,isnull(cgt.GoodsTypeName,'')GoodsTypeName
,w.INDATE
,d.[PKGS]
,d.[KGS]
,d.[CBM]
,d.[NETWEIGHT]
,d.[STORAGEUNITCOUNT]
,d.[RULEUNITCOUNT]
,[PKGS2_1]
,[KGS2_1]
,[CBM2_1]
,[NETWEIGHT2_1]
,[STORAGEUNITCOUNT2_1]
,[RULEUNITCOUNT2_1]
,[PKGS2_2]
,[KGS2_2]
,[CBM2_2]
,[NETWEIGHT2_2]
,[STORAGEUNITCOUNT2_2]
,[RULEUNITCOUNT2_2]
,[PKGS3]
,[KGS3]
,[CBM3]
,[NETWEIGHT3]
,[STORAGEUNITCOUNT3]
,[RULEUNITCOUNT3]
,[CUSTOMNO_OUT]
,[STOREHOUSE]
,[AREACODE]
FROM [dbo].[OP_WMS_REPORT_TIMEZONES_DETAIL] d
left join OP_WMS w on w.WMSID=d.WMSID
left join code_goods cg on cg.GOODNAME=w.GOODSNAME
left join code_goodsType cgt on convert(varchar(50), cgt.GID)=convert(varchar(50),cg.GoodsTypeGID)
GO
/* 处理原有数据
update op_wms set ARCLIENTWMSOUT = CUSTOMERNAME where isnull(ARCLIENTWMSOUT,'')=''
--select * from OP_WMS_TRANSFERGOODS where isnull( WMSOUTFEE_OLDCUST,'false')='false'
--select * from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID in(select WMSTRANSFERGOODSID from OP_WMS_TRANSFERGOODS where isnull( WMSOUTFEE_OLDCUST,'false')='false')
--select * from op_wms where wmsid in(select WMSID_NEW from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID in(select WMSTRANSFERGOODSID from OP_WMS_TRANSFERGOODS where isnull( WMSOUTFEE_OLDCUST,'false')='false'))
update op_wms set ARCLIENTWMSOUT = GOODSOWNER where wmsid in(select WMSID_NEW from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID in(select WMSTRANSFERGOODSID from OP_WMS_TRANSFERGOODS where isnull( WMSOUTFEE_OLDCUST,'false')='false'))
update op_wms set ARCLIENTWMSOUT = GOODSOWNER where wmsid in(select WMSID_NEW from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID in(select WMSTRANSFERGOODSID from OP_WMS_TRANSFERGOODS where isnull( WMSOUTFEE_OLDCUST,'false')='false'))
update OP_WMS_TRANSFERGOODS set ARCLIENTWMSOUT = OLDCUSTOMERNAME
update OP_WMS_TRANSFERGOODS set ARCLIENTWMSOUT = NEW_GOODSOWNER where isnull( WMSOUTFEE_OLDCUST,'false')='false'
--select customername,GOODSOWNER,ARCLIENTWMSOUT from OP_WMS
*/