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/sqlserver/增加净重20201117服务端.sql

305 lines
12 KiB
MySQL

2 years ago
alter table OP_WMS_IN_PLAN add NETWEIGHT decimal(18,3) null
--alter table OP_WMS_IN_PLAN_GOODS drop column NETKGS
alter table OP_WMS_IN_PLAN_GOODS add NETWEIGHT decimal(18,3) null
alter table OP_WMS_IN_DO add NETWEIGHT decimal(18,3) null
alter table OP_WMS_IN_DO drop column NETWEIGHT
alter table OP_WMS_IN_DO_GOODS add NETWEIGHT decimal(18,3) null
alter table OP_WMS add NETWEIGHT decimal(18,3) null
alter table OP_WMS_CHANGE add NETWEIGHT decimal(18,3) null
alter table OP_WMS_CHANGE add NETWEIGHT2 decimal(18,3) null
alter table OP_WMS_CHANGE add NETWEIGHT3 decimal(18,3) null
alter table OP_WMS_PHYSICS_DODETAIL add NETWEIGHT decimal(18,3) null
alter table OP_WMS_PHYSICS add NETWEIGHT decimal(18,3) null
alter table OP_WMS_PHYSICS_CHANGE add NETWEIGHT decimal(18,3) null
alter table OP_WMS_PHYSICS_CHANGE add NETWEIGHT2 decimal(18,3) null
alter table OP_WMS_PHYSICS_CHANGE add NETWEIGHT3 decimal(18,3) null
alter table OP_WMS_OUT_PLAN_GOODS add NETWEIGHT decimal(18,3) null
alter table OP_WMS_OUT_PLAN_DETAIL add NETWEIGHT decimal(18,3) null
alter table OP_WMS_MOVE add NETWEIGHT decimal(18,3) null
alter table OP_WMS_TRANSFERGOODS_DETAIL add NETWEIGHT decimal(18,3) null
alter table OP_WMS_OUT_PLAN drop column NETWEIGHT
alter table OP_WMS_OUT_DO drop column NETWEIGHT
alter table OP_WMS_IN_DO drop column NETWEIGHT
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]
,KGS_SINGLE,CBM_SINGLE,STORAGEUNITCOUNT_SINGLE,RULEUNITCOUNT_SINGLE,OP
from OP_WMS
GO
ALTER view [dbo].[Vw_Op_Wms_Need]
as
select w.[WMSID],w.CUSTOMERNAME
,w.MBLNO,w.CNTRNO,w.GOODSNAME,w.INDATE,w.OP
,w.KGS-isnull(td.KGS,0)-isnull(opd.KGS,0) [KGS]
,w.NETWEIGHT-isnull(td.NETWEIGHT,0)-isnull(opd.NETWEIGHT,0) [NETWEIGHT]
,w.CBM-isnull(td.CBM,0)-isnull(opd.CBM,0) [CBM]
,w.PKGS-isnull(td.PKGS,0)-isnull(opd.PKGS,0) [PKGS]
,w.[KINDPKGS]
,w.[STORAGEUNIT]
,w.STORAGEUNITCOUNT-isnull(td.STORAGEUNITCOUNT,0)-isnull(opd.STORAGEUNITCOUNT,0)[STORAGEUNITCOUNT]
,w.[RULEUNIT]
,w.RULEUNITCOUNT-isnull(td.RULEUNITCOUNT,0)-isnull(opd.RULEUNITCOUNT,0)[RULEUNITCOUNT]
,w.[FEESTARTDATE]
,w.[FEEENDDATE]
,w.MBLNO+'_'+w.CNTRNO MBLNOCNTRNO
,w.KGS-isnull(td.KGS,0)-isnull(opd.KGS,0)+
w.CBM-isnull(td.CBM,0)-isnull(opd.CBM,0)+
w.PKGS-isnull(td.PKGS,0)-isnull(opd.PKGS,0) ALLSTORAGECOUNT
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 not exists (select 1 from OP_WMS_OUT_DO_GOODS og left join OP_WMS_OUT_DO od on od.WMSDOID=og.WMSDOID where WMSPLANID=_opd.WMSPLANID and od.billstatus='1012' )
group by wmsid)opd on opd.WMSID=w.WMSID
GO
ALTER view [dbo].[Vw_Op_Wms_Physics]
as
select p.*
,convert(numeric(18,6) ,p.KGS/1000)TONS
,(select areaname from OP_WMS_STOREHOUSE where AREACODE=p.STOREHOUSE)
+'_'+(select areaname from OP_WMS_STOREHOUSE_AREA where AREACODE=p.AREACODE) AREANAME
,w.CORPID,w.MBLNO,w.CNTRNO,w.CUSTOMERNAME,w.GOODSNAME
from Op_Wms_Physics p left join op_wms w on w.WMSID=p.WMSID
GO
ALTER view [dbo].[Vw_Op_Wms_Physics_Need]
as
select p.[WMSPHYSICSID]
,p.[WMSID]
,p.[STOREHOUSE]
,p.[AREACODE]
,p.KGS-isnull(d.KGS,0)-isnull(od.KGS,0) [KGS]
,p.NETWEIGHT-isnull(d.NETWEIGHT,0)-isnull(od.NETWEIGHT,0) [NETWEIGHT]
,p.CBM-isnull(d.CBM,0)-isnull(od.CBM,0) [CBM]
,p.PKGS-isnull(d.PKGS,0)-isnull(od.PKGS,0) [PKGS]
,p.[KINDPKGS]
,p.[STORAGEUNIT]
,p.STORAGEUNITCOUNT-isnull(d.STORAGEUNITCOUNT,0)-isnull(od.STORAGEUNITCOUNT,0)[STORAGEUNITCOUNT]
,p.[RULEUNIT]
,p.RULEUNITCOUNT-isnull(d.RULEUNITCOUNT,0)-isnull(od.RULEUNITCOUNT,0)[RULEUNITCOUNT]
,p.[STARTDATE]
,p.[FEEENDDATE]
,w.MBLNO,w.CNTRNO,w.MBLNO+'_'+w.CNTRNO MBLNOCNTRNO,w.GOODSNAME,w.INDATE,w.CUSTOMERNAME,w.OP
,convert(numeric(18,6) ,p.KGS/1000)TONS
from Op_Wms_Physics p
left join op_wms w on w.WMSID=p.WMSID
left join OP_WMS_PHYSICS_DODETAIL d on d.WMSPHYSICSID=p.WMSPHYSICSID
and (select billstatus from OP_WMS_Transfergoods where WMSTRANSFERGOODSID=d.WMSDOID )='1000'
left join OP_WMS_PHYSICS_DODETAIL od on od.WMSPHYSICSID=p.WMSPHYSICSID
and (select BSSTATUS from OP_WMS_OUT_DO where WMSDOID=d.WMSDOID )='false'
GO
ALTER view [dbo].[VW_OP_WMS_AREAGOODS] as
select w.WMSID, w.CORPID, p.MBLNO,p.CNTRNO,p.CUSTOMERNAME,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
,p.AREACODE,p.STOREHOUSE,(select top 1 PKGS from OP_WMS_CHANGE where CHANGETYPE in('<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>') and wmsid=p.WMSID) PKGS_FIRST
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
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO] AS select D.*,
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_GOODS]
as
select WIG.*
,(select isnull(CUSTOMSINSPECTION,0) from OP_WMS_IN_PLAN_GOODS where GID=wig.WMSPLANDETAILID ) CUSTOMSINSPECTION
,(select isnull(STOREHOUSEINSPECTION,0) from OP_WMS_IN_PLAN_GOODS where GID=wig.WMSPLANDETAILID ) STOREHOUSEINSPECTION
from OP_WMS_IN_DO_GOODS WIG
GO
ALTER view [dbo].[VW_OP_WMS_OUT_PLAN_DETAIL] as
select opd.*,p.AREACODE,p.STOREHOUSE from OP_WMS_OUT_PLAN_DETAIL opd left join OP_WMS_PHYSICS p on opd.WMSPHYSICSID=p.WMSPHYSICSID
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUTPLANDETAIL]
AS
SELECT WMSID, MATERIALNO, GOODSCODE, GOODSNAME, GOODSHSCODE, MBLNO, CNTRNO, KGS,NETWEIGHT, CBM, PKGS,
STORAGEUNIT, STORAGEUNITCOUNT, RULEUNIT, RULEUNITCOUNT, CUSTOMERNAME, KINDPKGS
FROM dbo.OP_WMS
GO
ALTER VIEW [dbo].[VW_OP_WMS_OUT_PLANDETAIL_PHYSICS]
AS
SELECT dbo.OP_WMS_OUT_PLAN_DETAIL.WMSOUTDETAILID, dbo.OP_WMS_OUT_PLAN_DETAIL.WMSPLANID,
dbo.OP_WMS_OUT_PLAN_DETAIL.WMSID, dbo.OP_WMS_OUT_PLAN_DETAIL.MBLNO,
dbo.OP_WMS_OUT_PLAN_DETAIL.CNTRNO, dbo.OP_WMS_OUT_PLAN_DETAIL.MATERIALNO,
dbo.OP_WMS_OUT_PLAN_DETAIL.GOODSCODE, dbo.OP_WMS_OUT_PLAN_DETAIL.GOODSNAME,
dbo.OP_WMS_OUT_PLAN_DETAIL.GOODSHSCODE, dbo.OP_WMS_OUT_PLAN_DETAIL.KGS, dbo.OP_WMS_OUT_PLAN_DETAIL.NETWEIGHT,
dbo.OP_WMS_OUT_PLAN_DETAIL.PKGS, dbo.OP_WMS_OUT_PLAN_DETAIL.CBM,
dbo.OP_WMS_OUT_PLAN_DETAIL.KINDPKGS, dbo.OP_WMS_OUT_PLAN_DETAIL.STORAGEUNIT,
dbo.OP_WMS_OUT_PLAN_DETAIL.STORAGEUNITCOUNT, dbo.OP_WMS_OUT_PLAN_DETAIL.RULEUNIT,
dbo.OP_WMS_OUT_PLAN_DETAIL.RULEUNITCOUNT, pc.STOREHOUSE,
pc.AREACODE, pc.PKGS AS PKGS1,pc.WMSPHYSICSID
FROM dbo.OP_WMS_OUT_PLAN_DETAIL
left JOIN dbo.OP_WMS_PHYSICS pc ON
(dbo.OP_WMS_OUT_PLAN_DETAIL.WMSID = pc.WMSID and pc.PKGS>=0) or (OP_WMS_OUT_PLAN_DETAIL.WMSPHYSICSID=pc.WMSPHYSICSID)
GO
--drop view VW_OP_WMS_OUT_DO_GOODSDETAIL
GO
create VIEW [dbo].[VW_OP_WMS_OUT_PLAN_NEED]
AS
SELECT *,dbo.[F_OUTPLANDETAIL_MBLNO](WMSPLANID) MBLNO,dbo.[F_OUTPLANDETAIL_CNTRNO](WMSPLANID) CNTRNO
FROM dbo.OP_WMS_OUT_PLAN
GO
ALTER view [dbo].[VW_OP_WMS_PHYSICS_DODETAIL] as
select D.*,W.CUSTOMERNAME,W.GOODSNAME,W.MBLNO,W.CNTRNO from OP_WMS_PHYSICS_DODETAIL D
left join OP_WMS W on W.WMSID=D.WMSID
GO
ALTER view [dbo].[VW_OP_WMS_TRANSFERGOODS_DETAIL] as
select d.*,w.GOODSNAME,w.MBLNO,w.CNTRNO,w.INDATE
from OP_WMS_TRANSFERGOODS_DETAIL d
left join op_wms w on w.WMSID=d.WMSID
GO
------ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>NETKGS
ALTER view [dbo].[VW_WMS_IN_PLAN_GOODS_NEEDDO]
as
SELECT * from (
select g.CBM,g.CNTRNO,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,
--g.*
--,
p.mblno MBLNO ,p.mblno+'-'+g.CNTRNO MBLNOCNTRNO,isnull(p.ISEND,'false') ISEND,p.PLANTIME,p.CUSTOMERNAME,p.BSSTATUS planbsstatus
,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
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
--drop VIEW [dbo].[VM_WMS_OUT_DO_GOODS]
GO
create 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
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
GO
update Sys_TableColumn set ColumnCNName='ë<EFBFBD><EFBFBD><><C7A7>)' where ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǧ<EFBFBD>ˣ<EFBFBD>'
update Sys_TableColumn set ColumnCNName='ë<EFBFBD><EFBFBD><><C7A7>)' where ColumnCNName='ǧ<EFBFBD><EFBFBD>'
update Sys_TableColumn set ColumnCNName='ë<EFBFBD><EFBFBD><><C7A7>)' where ColumnCNName='ǧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
update Sys_TableColumn set ColumnCNName='ë<EFBFBD><EFBFBD><><C7A7>)' where ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
update Sys_TableColumn set ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)' where ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
update Sys_TableColumn set ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)' where ColumnCNName='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
ALTER view [dbo].[VW_OP_WMS_AREAGOODS] as
select w.WMSID, w.CORPID, p.MBLNO,p.CNTRNO,p.CUSTOMERNAME,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
,p.AREACODE,p.STOREHOUSE,(select top 1 PKGS from OP_WMS_CHANGE where CHANGETYPE in('<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>') and wmsid=p.WMSID) PKGS_FIRST
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
GO