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/15 裕龙 入库计划加法检等.sql

211 lines
7.3 KiB
MySQL

2 years ago
-----------------------
ALTER TABLE [dbo].[OP_WMS_IN_PLAN] ADD [ISRULECHECK] bit NULL
GO
ALTER TABLE [dbo].[OP_WMS_IN_PLAN] DROP COLUMN [ACCBOOKNO]
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,w.COUNTRY
,0 DAYS
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_IN_PLAN] AS select [WMSPLANID]
,[WMSNO]
,[MBLNO]
,[CONTRACTNO]
,[BILLTYPE]
,[PLANTIME]
,[ACCDATE]
,[CUSTOMERNAME]
,[CORPID]
,[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,COUNTRY,ISRULECHECK
FROM [OP_WMS_IN_PLAN]
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_PLAN_BEFORE] AS select [WMSPLANID]
,[WMSNO]
,[MBLNO]
,[CONTRACTNO]
,[BILLTYPE]
,[PLANTIME]
,[ACCDATE]
,[CUSTOMERNAME]
,[CORPID]
,[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
FROM [OP_WMS_IN_PLAN] where BSSOURCE='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>'
GO
---------
alter table OP_OTHER add TRUCKNO varchar(max) null
GO
ALTER VIEW [dbo].[VW_OP_REP_WMSINDO] AS select wc.WMSLOGID,id.DODATE,w.CORPID, w.CUSTOMERNAME,w.GOODSNAME,w.MBLNO,w.CUSTOMNO,w.CNTRNO
,wc.PKGS,wc.KGS,wc.NETWEIGHT,wc.CBM,wc.PKGS3,wc.KGS3,wc.NETWEIGHT3,wc.CBM3,idg.STOREHOUSE ,idg.AREACODE,w.OP
,wc.CHANGETYPE,id.BSNO,GOODSFEETYPE,GoodsTypeGID,w.GOODSOWNER,w.ARCLIENTWMSOUT
,inplan.INSPECTION_NO,inplan.CONTRACTNO,inplan.JINGNEISHOUHUOREN
,inplan.JINJINGBEIANSHENBAORIQI,inplan.CUSTOMAMOUNT
,inplan.CUSTOMAMOUNT/(select sum(kgs) from OP_WMS_in_DO_GOODS where WMSPLANID=inplan.WMSPLANID) CUSTOMAMOUNT_KGS
,inplan.CUSTOMAMOUNT*idg.KGS/(select sum(kgs) from OP_WMS_in_DO_GOODS where WMSPLANID=inplan.WMSPLANID) CUSTOMAMOUNT_SINGLE
,id.CreateID DO_CreateID,inplan.CreateID PLAN_CreateID
,ipg.PKGS PLANPKGS,ipg.PKGS-idg.PKGS OVERNUMER
,case when ipg.PKGS-idg.PKGS>0 then '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>' when ipg.PKGS-idg.PKGS<0 then '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>'when idg.PKGS=null then '' else '<EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' END DORESULT
from OP_WMS_CHANGE wc
left join op_wms w on w.WMSID=wc.WMSID
left join op_wms_in_do id on id.WMSDOID=wc.DOBSNO
left join OP_WMS_in_DO_GOODS idg on idg.WMSDODETAILID=wc.DOGID
left join OP_WMS_IN_PLAN inplan on inplan.WMSPLANID=idg.WMSPLANID
left join code_goods cg on cg.GOODNAME=w.GOODSNAME
left join OP_WMS_IN_PLAN_GOODS ipg on ipg.GID=idg.WMSPLANDETAILID
where wc.CHANGETYPE='<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
GO
alter table OP_WMS_TRUCK add GOODSCODE varchar(50) null
GO
update OP_WMS_TRUCK set GOODSCODE=GOODSCOD
GO
alter table OP_WMS_TRUCK drop column GOODSCOD
GO
-------------
---<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ <EFBFBD><EFBFBD>ʾʱҲ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>ļƻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
---ͬʱִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:PKGS KGS CBM NETWEIGHT STORAGEUNITCOUNT RULEUNITCOUNT
---<EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>
alter table OP_WMS_IN_DO_GOODS add ACCEPT_PKGS numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_KGS numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_CBM numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_NETWEIGHT numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_STORAGEUNITCOUNT numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_RULEUNITCOUNT numeric(18,3) null
GO
alter table OP_WMS_IN_DO_GOODS add TRUCKNO varchar(20) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_STOREHOUSE varchar(50) null
GO
alter table OP_WMS_IN_DO_GOODS add ACCEPT_AREACODE varchar(50) null
GO
update OP_WMS_IN_DO_GOODS set ACCEPT_PKGS=PKGS,ACCEPT_KGS=KGS,ACCEPT_CBM=CBM ,ACCEPT_NETWEIGHT=NETWEIGHT,
ACCEPT_STORAGEUNITCOUNT=STORAGEUNITCOUNT,ACCEPT_RULEUNITCOUNT=RULEUNITCOUNT
,ACCEPT_STOREHOUSE=STOREHOUSE,ACCEPT_AREACODE=AREACODE
GO
ALTER VIEW [dbo].[VW_OP_WMS_IN_DO_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
,inplan.PKGS INPLAN_PKGS,inplan.KGS INPLAN_KGS,inplan.CBM INPLAN_CBM,inplan.NETWEIGHT INPLAN_NETWEIGHT
,inplan.STORAGEUNITCOUNT INPLAN_STORAGEUNITCOUNT,inplan.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
Create 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
,inplan.PKGS INPLAN_PKGS,inplan.KGS INPLAN_KGS,inplan.CBM INPLAN_CBM,inplan.NETWEIGHT INPLAN_NETWEIGHT
,inplan.STORAGEUNITCOUNT INPLAN_STORAGEUNITCOUNT,inplan.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
------------