CREATE TABLE [dbo].[OP_WMS_BASE]( [WMSBASEID] [uniqueidentifier] NOT NULL, [BSNO] [varchar](50) NULL, [BILLTYPE] [varchar](50) NULL, [REMARK] [varchar](50) NULL, [CORPID] [varchar](50) NULL, [CreateID] [uniqueidentifier] NULL, [Creator] [varchar](50) NULL, [CreateDate] [datetime] NULL, [CUSTOMERNAME] [varchar](50) NULL, [MATERIALNO] [varchar](50) NULL, [GOODSCODE] [varchar](50) NULL, [GOODSNAME] [varchar](50) NULL, [GOODSHSCODE] [varchar](50) NULL, [MBLNO] [varchar](50) NULL, [CNTRNO] [varchar](50) NULL, [KGS] [numeric](18, 3) NULL, [CBM] [numeric](18, 3) NULL, [PKGS] [numeric](18, 3) NULL, [KINDPKGS] [varchar](50) NULL, [STORAGEUNIT] [varchar](50) NULL, [STORAGEUNITCOUNT] [numeric](22, 6) NULL, [RULEUNIT] [varchar](50) NULL, [RULEUNITCOUNT] [numeric](18, 3) NULL, [FEEENDDATE] [datetime] NULL, [FEESTARTDATE] [datetime] NULL, [INDATE] [datetime] NULL, [STORAGEUNITCOUNT_SINGLE] [numeric](22, 6) NULL, [RULEUNITCOUNT_SINGLE] [numeric](18, 3) NULL, [OP] [uniqueidentifier] NULL, [NETWEIGHT] [decimal](18, 3) NULL, [CUSTOMNO] [varchar](50) NULL, [ACCBOOKNO] [varchar](50) NULL, [GOODSOWNER] [varchar](50) NULL, [FEERATESTARTDATE] [datetime] NULL, [WMSINDATE] [datetime] NULL, [ARCLIENTWMSOUT] [varchar](50) NULL, [COUNTRY] [varchar](100) NULL, CONSTRAINT [PK_OP_WMS_BASE] PRIMARY KEY CLUSTERED ( [WMSBASEID] 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 alter table OP_WMS add WMSBASEID [uniqueidentifier] null GO alter table OP_WMS add APCLIENTWMSOUT [varchar](50) NULL GO alter table OP_WMS_IN_PLAN add APCLIENTWMSOUT [varchar](50) NULL GO alter table OP_WMS_IN_DO add APCLIENTWMSOUT [varchar](50) NULL 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 from OP_WMS GO ALTER PROCEDURE [dbo].[proc_isClientRepeat] @oldGID VarChar(36), @oldCODENAME VarChar(20), @oldSHORTNAME VarChar(20), @oldDESCRIPTION VarChar(50), @newGID VarChar(36), @newCODENAME VarChar(20), @newSHORTNAME VarChar(20), @newDESCRIPTION VarChar(50), @strUserID VarChar(36), @strUserName VarChar(150) AS BEGIN SET NOCOUNT ON; BEGIN TRANSACTION--开始事务 DECLARE @errorSun INT --定义错误计数器 SET @errorSun=0 --没错为0 --海运业务预订舱表 委托单位 UPDATE [crm_seaeorder] SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务预订舱表 船公司 UPDATE [crm_seaeorder] SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务预订舱表 订舱代理 UPDATE [crm_seaeorder] SET FORWARDER = @newSHORTNAME WHERE FORWARDER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务预订舱表 场站 UPDATE [crm_seaeorder] SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 委托单位 UPDATE op_seae SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 场站 UPDATE op_seae SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 船公司 UPDATE op_seae SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 订舱代理 UPDATE op_seae SET FORWARDER = @newSHORTNAME WHERE FORWARDER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 报关行 UPDATE op_seae SET CUSTOMSER = @newSHORTNAME WHERE CUSTOMSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 承运车队 UPDATE op_seae SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 国外代理 UPDATE op_seae SET AGENTID= @newSHORTNAME WHERE AGENTID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 仓库 UPDATE op_seae SET WAREHOUSE= @newSHORTNAME WHERE WAREHOUSE = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运提单信息 场站 UPDATE op_seae_billmanage SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电信息表 TO(往来单位全称) UPDATE op_letter SET HEAD_TO = @newDESCRIPTION WHERE HEAD_TO = @oldDESCRIPTION --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电入货通知信息表 提箱场站 UPDATE op_letter_yard SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电入货通知信息表 入货场站 UPDATE op_letter_yard SET YARD2 = @newSHORTNAME WHERE YARD2 = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电派车通知信息表 承运车队 UPDATE op_letter_truck SET TRUCK = @newSHORTNAME WHERE TRUCK = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电派车通知信息表 背箱场站 UPDATE op_letter_truck SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --业务函电派车通知信息表 返箱场站 UPDATE op_letter_truck SET RETURNYARD = @newSHORTNAME WHERE RETURNYARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --航次资料设置 默认场站(码头) UPDATE code_voyno SET YARDID = @newSHORTNAME WHERE YARDID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --费用信息表 客户名称 UPDATE ch_fee SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --费用申请修改表 客户名称 UPDATE ch_fee_modify SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --提单签发管理表 快递公司 UPDATE op_blissue SET EXPRESSCORP = @newSHORTNAME WHERE EXPRESSCORP = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --费用对账表 结算客户 UPDATE ch_dui SET CUSTNAME = @newSHORTNAME WHERE CUSTNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --预收预付表 结算客户 UPDATE ch_fee_advance_payment SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --预收预付明细表 结算客户 UPDATE ch_fee_advance_payment_detail SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --预收预付明细表 结算客户 UPDATE ch_fee_agentdc SET AGENT = @newSHORTNAME WHERE AGENT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --自动对账表 结算客户 UPDATE CH_FEE_AutoDui SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --结算信息表 结算客户 UPDATE ch_fee_settlement SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --费用处理明细表 结算客户 UPDATE ch_fee_do SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --付费申请表 结算客户 UPDATE ch_fee_payapplication SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --发票申请表 客户名称 UPDATE ch_fee_invoiceapplication SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --发票表 客户名称 UPDATE ch_fee_invoice SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --订舱费用表 客户名称 UPDATE crm_orderfee SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --发票核销表 客户名称 UPDATE ch_fee_hexiao SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --进账单表 客户名称 UPDATE ch_fee_jinzhang SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --管理费用明细表 客户名称 UPDATE ch_fee_Mbody SET CUSTOMERSIDE = @newSHORTNAME WHERE CUSTOMERSIDE = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE ch_fee_recvapplication SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --支票信息表 客户名称 UPDATE ch_fee_cheque SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --费用模板明细信息表 结算单位名称 UPDATE code_fee_templatedetail SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --客户运价查询日志表 日志创建人 UPDATE crm_price_carrier_log SET CREATEUSER = @newSHORTNAME WHERE CREATEUSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 ------------------------------------------------- --客户联系人信息从表 客户关联id UPDATE info_client_contact SET LINKID = @newGID WHERE LINKID = @oldGID --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --收发货人信息维护表 客户关联id UPDATE info_shipper SET codename = @newCODENAME WHERE codename = @oldCODENAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --CRM往来单位管理表信息表 客户关联id UPDATE info_client SET ISSTOP=1,MODIFIEDUSER=@strUserID,MODIFIEDTIME=getdate() WHERE GID = @oldGID --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 INSERT INTO [sys_log]([NAME],[LOGTYPE],[LOGTIME],[LOGCONTENT],[CREATEUSER]) VALUES('重复往来单位合并','UPDATE 更新操作',getdate(),@strUserName+' 将 '+@oldSHORTNAME+' 同 '+@newSHORTNAME+' 合并 ',@strUserID) ------------------------------------------------- --接口 cw_vouitems表 客户关联CUSTOMERNAME UPDATE cw_vouitems SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 ------------------------------------------------- --总账cw_vouitems_gl表 客户关联ACCALL UPDATE cw_vouitems_gl SET [ACCALL] = replace(ACCALL,@oldSHORTNAME,@newSHORTNAME) WHERE [ACCALL] like ('%'+@oldSHORTNAME+'%') --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --总账cw_vouitems_gl表 客户关联CUSTOMERNAME UPDATE cw_vouitems_gl SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] like ('%'+@oldSHORTNAME+'%') --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --总账cw_genleg_accitems表 客户关联CORPACC --UPDATE cw_genleg_accitems SET [CORPACC] = @newSHORTNAME WHERE [CORPACC] = @oldSHORTNAME --事务操作SQL语句 --SET @errorSun=@errorSun+@@ERROR --累计是否有错 --总账cw_genleg_accitems表 客户关联CORPACC UPDATE cw_genleg_accitems SET [AMTYEARDR]=[AMTYEARDR]+ISNULL((SELECT sum([AMTYEARDR]) as [AMTYEARDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTYEARCR]=[AMTYEARCR]+ISNULL((SELECT sum([AMTYEARCR]) as [AMTYEARCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTYEARBLC]=[AMTYEARBLC]+ISNULL((SELECT sum([AMTYEARBLC]) as [AMTYEARBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTDR]=[AMTDR]+ISNULL((SELECT sum([AMTDR]) as [AMTDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTCR]=[AMTCR]+ISNULL((SELECT sum([AMTCR]) as [AMTCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTBLC]=[AMTBLC]+ISNULL((SELECT sum([AMTBLC]) as [AMTBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTLASTDR]=[AMTLASTDR]+ISNULL((SELECT sum([AMTLASTDR]) as [AMTLASTDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTLASTCR]=[AMTLASTCR]+ISNULL((SELECT sum([AMTLASTCR]) as [AMTLASTCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[AMTLASTBLC]=[AMTLASTBLC]+ISNULL((SELECT sum([AMTLASTBLC]) as [AMTLASTBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYYEARDR]=[FCYYEARDR]+ISNULL((SELECT sum([FCYYEARDR]) as [FCYYEARDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYYEARCR]=[FCYYEARCR]+ISNULL((SELECT sum([FCYYEARCR]) as [FCYYEARCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYYEARBLC]=[FCYYEARBLC]+ISNULL((SELECT sum([FCYYEARBLC]) as [FCYYEARBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYDR]=[FCYDR]+ISNULL((SELECT sum([FCYDR]) as [FCYDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYCR]=[FCYCR]+ISNULL((SELECT sum([FCYCR]) as [FCYCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYBLC]=[FCYBLC]+ISNULL((SELECT sum([FCYBLC]) as [FCYBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYLASTDR]=[FCYLASTDR]+ISNULL((SELECT sum([FCYLASTDR]) as [FCYLASTDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYLASTCR]=[FCYLASTCR]+ISNULL((SELECT sum([FCYLASTCR]) as [FCYLASTCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[FCYLASTBLC]=[FCYLASTBLC]+ISNULL((SELECT sum([FCYLASTBLC]) as [FCYLASTBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYYEARDR]=[QTYYEARDR]+ISNULL((SELECT sum([QTYYEARDR]) as [QTYYEARDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYYEARCR]=[QTYYEARCR]+ISNULL((SELECT sum([QTYYEARCR]) as [QTYYEARCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYYEARBLC]=[QTYYEARBLC]+ISNULL((SELECT sum([QTYYEARBLC]) as [QTYYEARBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYDR]=[QTYDR]+ISNULL((SELECT sum([QTYDR]) as [QTYDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYCR]=[QTYCR]+ISNULL((SELECT sum([QTYCR]) as [QTYCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYBLC]=[QTYBLC]+ISNULL((SELECT sum([QTYBLC]) as [QTYBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYLASTDR]=[QTYLASTDR]+ISNULL((SELECT sum([QTYLASTDR]) as [QTYLASTDR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYLASTCR]=[QTYLASTCR]+ISNULL((SELECT sum([QTYLASTCR]) as [QTYLASTCR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[QTYLASTBLC]=[QTYLASTBLC]+ISNULL((SELECT sum([QTYLASTBLC]) as [QTYLASTBLC] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[PFADR]=[PFADR]+ISNULL((SELECT sum([PFADR]) as [PFADR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0),[PFACR]=[PFACR]+ISNULL((SELECT sum([PFACR]) as [PFACR] from cw_genleg_accitems as a where [YEAR]=cw_genleg_accitems.[YEAR] and [MONTH]=cw_genleg_accitems.[MONTH] and [LINKGID]=cw_genleg_accitems.[LINKGID] and [DEPTACC]=cw_genleg_accitems.[DEPTACC] and [EMPLACC]=cw_genleg_accitems.[EMPLACC] and [CORPACC]=@oldSHORTNAME and [ITEMACC]=cw_genleg_accitems.[ITEMACC] and [CURRENCY]=cw_genleg_accitems.[CURRENCY] and [STARTGID]=cw_genleg_accitems.[STARTGID] and [ACCDATE]=cw_genleg_accitems.[ACCDATE] and [CORPID]=cw_genleg_accitems.[CORPID]),0) WHERE [CORPACC] = @newSHORTNAME --SET @errorSun=@errorSun+@@ERROR --累计是否有错 DELETE from cw_genleg_accitems where gid in (SELECT a.gid from cw_genleg_accitems as a,(SELECT * from cw_genleg_accitems where [CORPACC] = @newSHORTNAME) as b where a.[CORPACC] = @oldSHORTNAME and a.[YEAR]=b.[YEAR] and a.[MONTH]=b.[MONTH] and a.[LINKGID]=b.[LINKGID] and a.[DEPTACC]=b.[DEPTACC] and a.[EMPLACC]=b.[EMPLACC] and a.[ITEMACC]=b.[ITEMACC] and a.[CURRENCY]=b.[CURRENCY] and a.[STARTGID]=b.[STARTGID] and a.[ACCDATE]=b.[ACCDATE] and a.[CORPID]=b.[CORPID]) --SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE cw_genleg_accitems SET [CORPACC] = @newSHORTNAME WHERE [CORPACC] = @oldSHORTNAME --事务操作SQL语句 --SET @errorSun=@errorSun+@@ERROR --累计是否有错 ------------------------------------------------- ---Begin 2014-02-24 添加仓储相关表-------------------- --入库主表 客户名称 UPDATE wms SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库主表 应收账款客户名称/仓库或客户 UPDATE wms SET ARCLIENT = @newSHORTNAME WHERE ARCLIENT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库主表 装卸队名称/应付账款客户名称 UPDATE wms SET TRUCKNAME = @newSHORTNAME WHERE TRUCKNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库主表 原客户名称 UPDATE wms SET CLIENTNAMEOLD = @newSHORTNAME WHERE CLIENTNAMEOLD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库主表 仓库名称 UPDATE wms SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库明细表 客户名称 UPDATE wms_in SET CLIENTNAME = @newSHORTNAME WHERE CLIENTNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库明细表 仓库名称 UPDATE wms_in SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --入库明细表 原客户名称 UPDATE wms_in SET CLIENTNAMEOLD = @newSHORTNAME WHERE CLIENTNAMEOLD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --出库记录表 客户名称 UPDATE wms_out SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --出库记录表 仓库名称 UPDATE wms_out SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --出库记录表 装卸队名称/应付账款客户名称 UPDATE wms_out SET TRUCKNAME = @newSHORTNAME WHERE TRUCKNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --出库记录表 货权转移的客户名称 UPDATE wms_out SET CLIENTNAMEOLD = @newSHORTNAME WHERE CLIENTNAMEOLD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --出库记录表 应收账款客户名称/仓库或客户 UPDATE wms_out SET ARCLIENT = @newSHORTNAME WHERE ARCLIENT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --库位信息表 仓库名称 UPDATE wms_storage_area SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费率表 客户名称 UPDATE wms_rate SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费率出库明细表 客户名称 UPDATE wms_rate_detail SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费用查询实时表 客户名称 UPDATE wms_wmsrate_test SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费用查询实时表 仓库名称 UPDATE wms_wmsrate_test SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费录入表 客户名称 UPDATE wms_fee SET CLIENTNAME = @newSHORTNAME WHERE CLIENTNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --仓储费录入表 仓库名称 UPDATE wms_fee SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --进口贸易 主表 UPDATE Import_main SET buyer = @newSHORTNAME WHERE buyer = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --进口贸易 销售 UPDATE Import_Sales SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --进口贸易 出库 UPDATE Import_Delivery SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --185. 仓储结算清单明细表(wms_settlement_detail) 货主 UPDATE wms_settlement_detail SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --185. 仓储结算清单明细表(wms_settlement_detail) 仓库 UPDATE wms_settlement_detail SET STORAGENAME = @newSHORTNAME WHERE STORAGENAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --188. 仓储结算清单主表(wms_settlement_list) 对账客户 UPDATE wms_settlement_detail SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 ---End ---Begin 2017-01-10 添加其他相关表-------------------- --170. 报价单主表(crm_quotation)船公司 UPDATE crm_quotation SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --171. 报价单明细表(crm_quotation_detail)船公司 UPDATE crm_quotation SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务进口信息主表 委托单位 UPDATE op_seai SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务进口信息主表 场站 UPDATE op_seai SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 船公司 UPDATE op_seai SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 订舱代理 UPDATE op_seai SET FORWARDER = @newSHORTNAME WHERE FORWARDER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 报关行 UPDATE op_seai SET CUSTOMSER = @newSHORTNAME WHERE CUSTOMSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 承运车队 UPDATE op_seai SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 国外代理 UPDATE op_seai SET AGENTID= @newSHORTNAME WHERE AGENTID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 仓库 UPDATE op_seai SET WAREHOUSE= @newSHORTNAME WHERE WAREHOUSE = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 码头 UPDATE op_seai SET matou= @newSHORTNAME WHERE MaTou = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运业务信息主表 船代 UPDATE op_seai SET SHIPAGENCY= @newSHORTNAME WHERE SHIPAGENCY = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运内贸信息主表 委托单位 UPDATE op_InternalTrade SET [CUSTOMERNAME] = @newSHORTNAME WHERE [CUSTOMERNAME] = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运内贸信息主表 场站 UPDATE op_InternalTrade SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运内贸信息主表 船公司 UPDATE op_InternalTrade SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运内贸信息主表 承运车队 UPDATE op_InternalTrade SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --海运内贸信息主表 承运车队 UPDATE op_InternalTrade SET TRUCKER2 = @newSHORTNAME WHERE TRUCKER2 = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --191. 表:op_other 综合业务信息主表 委托单位 UPDATE op_other SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --综合业务信息主表 报关行 UPDATE op_other SET CUSTOMSER = @newSHORTNAME WHERE CUSTOMSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --综合业务主表 仓库 UPDATE op_other SET WAREHOUSE= @newSHORTNAME WHERE WAREHOUSE = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --194. 表:op_sub_seaorder分部订舱表 UPDATE op_sub_seaorder SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --208. 表:op_seae_edi海运EDI表 场站 UPDATE op_seae_edi SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --208. 表:op_seae_edi海运EDI表 货代 --UPDATE op_seae_edi SET FOWARDER = @newSHORTNAME WHERE FOWARDER = @oldSHORTNAME --事务操作SQL语句 --SET @errorSun=@errorSun+@@ERROR --累计是否有错 --208. 表:op_seae_edi海运EDI表 船公司 UPDATE op_seae_edi SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --218. 表:op_railway铁路运输业务信息主表 委托单位 UPDATE op_railway SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --218. 表:op_railway铁路运输业务信息主表 承运人 UPDATE op_railway SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --218. 表:op_railway铁路运输业务信息主表 承运人 UPDATE op_railway SET CUSTOMTRANSITCORP = @newSHORTNAME where CUSTOMTRANSITCORP= @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_railway SET RETURNCTNCORP = @newSHORTNAME where RETURNCTNCORP= @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_railway SET RECEIVEYARD = @newSHORTNAME where RECEIVEYARD= @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --219. 表:op_railway_bill 铁路运单信息 发货人 UPDATE op_railway_bill SET SHIPPERID = @newSHORTNAME WHERE SHIPPERID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --219. 表:op_railway_bill 铁路运单信息 收货人 UPDATE op_railway_bill SET CONSIGNEEID = @newSHORTNAME WHERE CONSIGNEEID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --220. 表:op_railway_bill_road 铁路运单运踪信息 承运人 UPDATE op_railway_bill_road SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --221. 表:op_railway_bill_train 铁路运单火车信息 承运人 UPDATE op_railway_bill_train SET CARRIER = @newSHORTNAME WHERE CARRIER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 委托单位 UPDATE op_aire SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 发货人 UPDATE op_aire SET SHIPPERID = @newSHORTNAME WHERE SHIPPERID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 收货人 UPDATE op_aire SET CONSIGNEEID = @newSHORTNAME WHERE CONSIGNEEID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 通知人 UPDATE op_aire SET NOTIFYPARTYID = @newSHORTNAME WHERE NOTIFYPARTYID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 国外代理 UPDATE op_aire SET AGENTID = @newSHORTNAME WHERE AGENTID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 航空公司 UPDATE op_aire SET AIRLINES = @newSHORTNAME WHERE AIRLINES = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 订舱公司 UPDATE op_aire SET FORWARDER = @newSHORTNAME WHERE FORWARDER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 报关行 UPDATE op_aire SET CUSTOMSER = @newSHORTNAME WHERE CUSTOMSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --223. 表:op_aire空运出口业务信息主表 承运车队 UPDATE op_aire SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 委托单位 UPDATE op_airi SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 发货人 UPDATE op_airi SET SHIPPERID = @newSHORTNAME WHERE SHIPPERID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 收货人 UPDATE op_airi SET CONSIGNEEID = @newSHORTNAME WHERE CONSIGNEEID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 通知人 UPDATE op_airi SET NOTIFYPARTYID = @newSHORTNAME WHERE NOTIFYPARTYID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 国外代理 UPDATE op_airi SET AGENTID = @newSHORTNAME WHERE AGENTID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 航空公司 UPDATE op_airi SET AIRLINES = @newSHORTNAME WHERE AIRLINES = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 订舱公司 UPDATE op_airi SET FORWARDER = @newSHORTNAME WHERE FORWARDER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 报关行 UPDATE op_airi SET CUSTOMSER = @newSHORTNAME WHERE CUSTOMSER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --224. 表:op_airi空运进口业务信息主表 承运车队 UPDATE op_airi SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --225. 表:op_aire_bill空运出口业务提单 发货人 UPDATE op_aire_bill SET SHIPPERID = @newSHORTNAME WHERE SHIPPERID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --225. 表:op_aire_bill空运出口业务提单 收货人 UPDATE op_aire_bill SET CONSIGNEEID = @newSHORTNAME WHERE CONSIGNEEID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --225. 表:op_aire_bill空运出口业务提单 通知人 UPDATE op_aire_bill SET NOTIFYPARTYID = @newSHORTNAME WHERE NOTIFYPARTYID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --225. 表:op_aire_bill空运出口业务提单 国外代理 UPDATE op_aire_bill SET AGENTID = @newSHORTNAME WHERE AGENTID = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_express SET EXPRESSCORP = @newSHORTNAME WHERE EXPRESSCORP = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_express SET SENDERCUST = @newSHORTNAME WHERE SENDERCUST = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_express SET RECEIVECUST = @newSHORTNAME WHERE RECEIVECUST = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_truck_bulk SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_truck_bulk SET YARD = @newSHORTNAME WHERE YARD = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_truck_bulk_pc SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_truck_bulk_pc SET TRUCKER = @newSHORTNAME WHERE TRUCKER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 UPDATE op_truck_bulk_pc SET YARD = @newSHORTNAME WHERE YARD= @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 ---End ---Begin 车队相关 --226. 表:tMsWlBsHead 派车业务 委托单位 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlBsHead]') AND type in (N'U')) UPDATE tMsWlBsHead SET CustName = @newSHORTNAME,CustCode=@newCODENAME WHERE CustName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --227. 表:tMsWlBulkHead 派车业务 委托单位 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlBulkHead]') AND type in (N'U')) UPDATE tMsWlBulkHead SET CustName = @newSHORTNAME,CustCode=@newCODENAME WHERE CustName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlDjHead]') AND type in (N'U')) UPDATE tMsWlDjHead SET CustName = @newSHORTNAME,CustCode=@newCODENAME WHERE CustName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlDjPound]') AND type in (N'U')) UPDATE tMsWlDjPound SET CustName = @newSHORTNAME,CustCode=@newCODENAME WHERE CustName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlPcHead]') AND type in (N'U')) UPDATE tMsWlPcHead SET CustName = @newSHORTNAME,CustCode=@newCODENAME WHERE CustName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlPcHead]') AND type in (N'U')) UPDATE tMsWlPcHead SET YardName = @newSHORTNAME,YardCode=@newCODENAME WHERE YardName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlPcHead]') AND type in (N'U')) UPDATE tMsWlPcHead SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlPcHead]') AND type in (N'U')) UPDATE tMsWlPcHead SET F_CustomerName = @newSHORTNAME WHERE F_CustomerName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tMsWlPcHead]') AND type in (N'U')) UPDATE tMsWlPcHead SET DispatchName = @newSHORTNAME WHERE DispatchName = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 --新仓储相关表 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS]') AND type in (N'U')) UPDATE OP_WMS SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --仓储业务 客户 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS]') AND type in (N'U')) UPDATE OP_WMS SET GOODSOWNER = @newSHORTNAME WHERE GOODSOWNER = @oldSHORTNAME --仓储业务 货主 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS]') AND type in (N'U')) UPDATE OP_WMS SET ARCLIENTWMSOUT = @newSHORTNAME WHERE ARCLIENTWMSOUT = @oldSHORTNAME --仓储业务 仓储费结算对象 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_CHECK]') AND type in (N'U')) UPDATE OP_WMS_CHECK SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_CHECK]') AND type in (N'U')) UPDATE OP_WMS_CHECK SET GOODSOWNER = @newSHORTNAME WHERE GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_FEECALENDAR]') AND type in (N'U')) UPDATE OP_WMS_FEECALENDAR SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_FEEDUI_CUST_DETAIL]') AND type in (N'U')) UPDATE OP_WMS_FEEDUI_CUST_DETAIL SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_FEEDUI_STORAGE]') AND type in (N'U')) UPDATE OP_WMS_FEEDUI_STORAGE SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_FEEDUI_STORAGE_DETAIL]') AND type in (N'U')) UPDATE OP_WMS_FEEDUI_STORAGE_DETAIL SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_FEERATE]') AND type in (N'U')) UPDATE OP_WMS_FEERATE SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_DO]') AND type in (N'U')) UPDATE OP_WMS_IN_DO SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_DO]') AND type in (N'U')) UPDATE OP_WMS_IN_DO SET GOODSOWNER = @newSHORTNAME WHERE GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_DO]') AND type in (N'U')) UPDATE OP_WMS_IN_DO SET ARCLIENTWMSOUT = @newSHORTNAME WHERE ARCLIENTWMSOUT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_PLAN]') AND type in (N'U')) UPDATE OP_WMS_IN_PLAN SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_PLAN]') AND type in (N'U')) UPDATE OP_WMS_IN_PLAN SET GOODSOWNER = @newSHORTNAME WHERE GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_IN_PLAN]') AND type in (N'U')) UPDATE OP_WMS_IN_PLAN SET ARCLIENTWMSOUT = @newSHORTNAME WHERE ARCLIENTWMSOUT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_MOVE]') AND type in (N'U')) UPDATE OP_WMS_MOVE SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_OUT_PLAN]') AND type in (N'U')) UPDATE OP_WMS_OUT_PLAN SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_OUT_PLAN]') AND type in (N'U')) UPDATE OP_WMS_OUT_PLAN SET GOODSOWNER = @newSHORTNAME WHERE GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_OUT_PLAN]') AND type in (N'U')) UPDATE OP_WMS_OUT_PLAN SET PICKUPNAME = @newSHORTNAME WHERE PICKUPNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_OUT_DO]') AND type in (N'U')) UPDATE OP_WMS_OUT_DO SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_OUT_DO]') AND type in (N'U')) UPDATE OP_WMS_OUT_DO SET PICKUPNAME = @newSHORTNAME WHERE PICKUPNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_TRANSFERGOODS]') AND type in (N'U')) UPDATE OP_WMS_TRANSFERGOODS SET OLDCUSTOMERNAME = @newSHORTNAME WHERE OLDCUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_TRANSFERGOODS]') AND type in (N'U')) UPDATE OP_WMS_TRANSFERGOODS SET NEWCUSTOMERNAME = @newSHORTNAME WHERE NEWCUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_TRANSFERGOODS]') AND type in (N'U')) UPDATE OP_WMS_TRANSFERGOODS SET OLD_GOODSOWNER = @newSHORTNAME WHERE OLD_GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_TRANSFERGOODS]') AND type in (N'U')) UPDATE OP_WMS_TRANSFERGOODS SET NEW_GOODSOWNER = @newSHORTNAME WHERE NEW_GOODSOWNER = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_TRANSFERGOODS]') AND type in (N'U')) UPDATE OP_WMS_TRANSFERGOODS SET ARCLIENTWMSOUT = @newSHORTNAME WHERE ARCLIENTWMSOUT = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OP_WMS_WEIGH]') AND type in (N'U')) UPDATE OP_WMS_WEIGH SET CUSTOMERNAME = @newSHORTNAME WHERE CUSTOMERNAME = @oldSHORTNAME --事务操作SQL语句 SET @errorSun=@errorSun+@@ERROR --累计是否有错 insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),newid(),'合并客户',GETDATE(),@oldSHORTNAME+'替换为'+@newSHORTNAME,@strUserName) ---End IF @errorSun<>0 BEGIN ROLLBACK TRANSACTION--事务回滚语句 return 0 END ELSE BEGIN COMMIT TRANSACTION--事务提交语句 return 1 END set nocount off END 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,APCLIENTWMSOUT,COUNTRY,ISRULECHECK FROM [OP_WMS_IN_PLAN] 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 from OP_WMS_IN_DO D GO ALTER VIEW [dbo].[VW_OP_WMS_IN_DO_ACCEPT] AS select D.[BSNO] ,[WMSDOID] ,[WMS_PLAN_BSNO] ,[BILLTYPE] ,[CUSTOMERNAME] ,[GOODSOWNER] ,[ARCLIENTWMSOUT] ,[APCLIENTWMSOUT] ,[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].[v_op_bs] as SELECT BSNO,MASTERNO, 'op_seae' AS OPLB, '海运出口' AS OPLBNAME,'海运出口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE, STLNAME, VESSEL, VOYNO, INPUTBY,BLTYPE, CREATETIME, BSSTATUS, SALE , OP , DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE,CUSTOMNO, ACCDATE,CARRIER, BSSOURCE,BSSOURCEDETAIL, LANE, FORWARDER, 0 AS NETWEIGHT, KGS,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN TEU ELSE 0 END TEU, CNTRTOTAL, CORPID,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR1 ELSE 0 END CNTR1,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR2 ELSE 0 END CNTR2, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR3 ELSE 0 END CNTR3, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR4 ELSE 0 END CNTR4, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR5 ELSE 0 END CNTR5,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR6 ELSE 0 END CNTR6, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR7 ELSE 0 END CNTR7, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR8 ELSE 0 END CNTR8, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR9 ELSE 0 END CNTR9,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR10 ELSE 0 END CNTR10, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN OTCNTR ELSE 0 END OTCNTR, '' AS TRADETYPE, GOODSNAME, FEESTATUS,ETD AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,''BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,OPERATOR,SERVICECONTRACTNO,ISCANCEL ,APPLYNO,ISSUETYPE,BLISSUESTATUS,REMARK,TRADETERM,PLACERECEIPT,DESTINATION,CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,DESTINATIONID,SALECORPID,YARD,DELIVERYDATE,FRCUSTSERVICE,SERVICE,OPERATORFAX REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,CLOSINGDATE,KINDPKGS,CARGOID,DCLASS FROM dbo.op_seae WITH (NOLOCK) UNION ALL SELECT BSNO,MASTERNO, 'op_seai' AS OPLB, '海运进口' AS OPLBNAME,'海运进口' AS BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL, VOYNO, INPUTBY,BLTYPE, CREATETIME, BSSTATUS, SALE ,OP , DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO,ACCDATE, CARRIER, BSSOURCE,BSSOURCEDETAIL, LANE, FORWARDER, NETWEIGHT, KGS,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN TEU ELSE 0 END TEU, CNTRTOTAL, CORPID,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR1 ELSE 0 END CNTR1,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR2 ELSE 0 END CNTR2, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR3 ELSE 0 END CNTR3, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR4 ELSE 0 END CNTR4, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR5 ELSE 0 END CNTR5,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR6 ELSE 0 END CNTR6, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR7 ELSE 0 END CNTR7, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR8 ELSE 0 END CNTR8, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR9 ELSE 0 END CNTR9,CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN CNTR10 ELSE 0 END CNTR10, CASE WHEN (BLTYPE='整箱' OR BLTYPE='拼箱主票') THEN OTCNTR ELSE 0 END OTCNTR, TRADETYPE, GOODSNAME, FEESTATUS,ETD AS OPDATE,CUSTOMDATE,ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,''BOOKNO,AGENTID,ISPRINTPR,NUMBERPLATE,0 FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,APPLYNO,ISSUETYPE,BLISSUESTATUS,REMARK,TRADETERM,PLACERECEIPT,DESTINATION,CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,DESTINATIONID,SALECORPID,YARD,TIHUOTIME DELIVERYDATE,FRCUSTSERVICE,SERVICE,REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,CARGOID,DCLASS FROM dbo.op_seai WITH (NOLOCK) UNION ALL SELECT BSNO,MASTERNO, 'op_aire' AS OPLB, '空运出口' AS OPLBNAME,'空运出口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE, CREATETIME, BSSTATUS, SALE , OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO, ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,LANE, FORWARDER, FEEKGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME, FEESTATUS,ETD AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM ,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,DELIVERYDATE,FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_aire WITH (NOLOCK) UNION ALL SELECT BSNO, MASTERNO,'op_airi' AS OPLB, '空运进口' AS OPLBNAME,'空运进口' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETA) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE, CREATETIME, BSSTATUS, SALE ,OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE,CUSTOMNO, ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,LANE, FORWARDER, FEEKGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME, FEESTATUS,ETA AS OPDATE,CUSTOMDATE,'' ENTERP,PKGS,CBM,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE,FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID ,'' YARD,DELIVERYDATE,FRCUSTSERVICE,SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_airi WITH (NOLOCK) UNION ALL SELECT BSNO, MASTERNO,'op_apply' AS OPLB, '报关业务' AS OPLBNAME,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=96004 and EnumValueID=OP_APPLY.BsType) as BSTYPE,CUSTOMERNAME, CUSTNO,'' ORDERNO, MBLNO, HBLNO, CUSTOMDATE as ETD,'' ETA ,'' STLDATE,'' STLNAME, VESSEL, VOYNO, INPUTBY,CUSTOMTYPE BLTYPE, BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE, CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,TEU,'' CNTRTOTAL, CORPID,CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,OPDATE,CUSTOMDATE,ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_apply WITH (NOLOCK) UNION ALL SELECT BSNO, BSNO MASTERNO,'op_other' AS OPLB, '综合业务' AS OPLBNAME,TRANSTYPE as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO, MBLNO, HBLNO, ETD,'' ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL, VOYNO,OP AS INPUTBY,'' BLTYPE, BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_other WITH (NOLOCK) UNION ALL SELECT BSNO,BSNO MASTERNO, 'op_bulk' AS OPLB, '大宗散货' AS OPLBNAME,TRANSTYPE as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,'' MBLNO,'' HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE, BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_bulk WITH (NOLOCK) UNION ALL SELECT ContractNo AS BSNO, ContractNo MASTERNO,'import_main' AS OPLB, '进口贸易' AS OPLBNAME,'进口贸易' AS BSTYPE, buyer AS CUSTOMERNAME, HTH AS CUSTNO,Supplier_Billno+' '+Other_Billno ORDERNO, billno as MblNo, M.ContainerNo AS HBLNO, dbo.trimdate(Arrivaldate) AS ETD,dbo.trimtime(M.ArrivalDate) ETA ,'' STLDATE,'' STLNAME, VESSEL,voyage as VOYNO, (select showname from [user] where codename=creator) AS INPUTBY,'' BLTYPE, CREATTIME as CREATETIME,isnull(BSSTATUS,0) AS BSSTATUS, (select showname from [user] where codename=creator) AS SALE, OP AS OP, op AS DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=10 and EnumValueID=M.port) AS PORTDISCHARGE, '' AS CUSTOMNO, case when isnull(ACCDATE,'')='' then '' else dbo.trimdate(ACCDATE) end ACCDATE , '' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, isnull(FEESTATUS,0) FEESTATUS,Arrivaldate AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'',ISVOU,'' VOUNO ,'' DESTINATIONID,M.company SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,null BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.import_main M WITH (NOLOCK) UNION ALL SELECT BSNO,MASTERNO, 'op_railway' AS OPLB, '铁路运输' AS OPLBNAME,'铁路运输' as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO,HBLNO,SETOUTDATE ETD,'' ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE, BSDATE AS CREATETIME, BSSTATUS, SALE, OP,'' DOC,CUSTSERVICE, PLACELOAD,DESTINATIONENAME AS PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,SETOUTDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO ,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,PLACERECEIPT,DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO,DESTINATIONENAME DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_railway WITH (NOLOCK) UNION ALL SELECT GId BSNO,GId MASTERNO, 'tMsWlPcHead' AS OPLB, '陆运派车单' AS OPLBNAME,'陆运派车单' as BSTYPE,CUSTOMERNAME,Billno CUSTNO,'' ORDERNO,MBLNO MBLNO,'' HBLNO,dbo.trimdate(ExpDate) ETD,dbo.trimdate(RtnDocTime) ETA ,'' STLDATE,'' STLNAME,TruckNo VESSEL,(select top 1 DrvName from tMsWlDriver where DrvCode=dbo.tMsWlPcHead.DrvCode) VOYNO,(select top 1 showname from [user] where CODENAME=DdCode) INPUTBY, BLTYPE, '' CREATETIME,BillStatus BSSTATUS,SalesName SALE,case isnull(UserName,'') when '' then (select top 1 showname from [user] where CODENAME=DdCode) else UserName end OP,'' DOC,'' CUSTSERVICE,LoadPlace PLACELOAD,DstArea PORTDISCHARGE,'' CUSTOMNO, case when dbo.trimdate(ExpDate)<>'' then LEFT(dbo.trimdate(ExpDate),7) else '' end ACCDATE ,'' CARRIER,'' BSSOURCE,'' BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU, (select top 1 Ctn from code_ctn where CtnId=dbo.tMsWlPcHead.ContainerType)+'*'+convert(varchar(20),dbo.tMsWlPcHead.ContainerQty) CNTRTOTAL, (select top 1 GID from company where codename=dbo.tMsWlPcHead.orgcode) CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,dbo.trimdate(ExpDate) OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,RtnDocStatus BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,DstArea DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.tMsWlPcHead WITH (NOLOCK) UNION ALL SELECT F_NO AS BSNO,F_NO MASTERNO, 'import_finance' AS OPLB, '贸易融资' AS OPLBNAME,'贸易融资' AS BSTYPE, CUSTOMER AS CUSTOMERNAME, F_NO AS CUSTNO,f.HTH ORDERNO, F.Billno MblNo,'' HBLNO, STARTDATE AS ETD,'' ETA ,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO, (select showname from [user] where gid=M.OP) AS INPUTBY,'' BLTYPE, ENTERDATE as CREATETIME, 0 BSSTATUS, '' AS SALE, (select showname from [user] where gid=M.OP) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, '' AS CUSTOMNO, case when isnull(STARTDATE,'')='' then '' else dbo.trimdate(STARTDATE) end ACCDATE , '' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, '' CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, 0 FEESTATUS,STARTDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,'' REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,'' ,M.ISVOU,'' VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,null BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.IMPORT_FINANCE M WITH (NOLOCK) left join [dbo].[Import_main] f on (f.ContractNo=M.MAINNO) UNION ALL SELECT ASSOCIATEDNO AS BSNO,ASSOCIATEDNO MASTERNO, 'WMS' AS OPLB, '仓储业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME, WMSNO AS CUSTNO,WMSNO ORDERNO, BLNO MblNo,'' HBLNO, WMSDATE AS ETD,'' ETA ,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,(select top 1 showname from [user] where gid= createuser) AS INPUTBY,'' BLTYPE, CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, '' AS CUSTOMNO, case when isnull(WMSDATE,'')='' then '' else dbo.trimdate(WMSDATE) end ACCDATE , '' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, '' CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,WMSDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,'' REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.WMS WITH (NOLOCK) where ASSOCIATEDNO=gid UNION ALL SELECT GID AS BSNO, GID MASTERNO,'WMS_IN' AS OPLB, '仓储入库' AS OPLBNAME,'仓储入库' AS BSTYPE, CUSTOMERNAME, WMSNO AS CUSTNO,WMSNO ORDERNO, BLNO MblNo,'' HBLNO, WMSDATE AS ETD,'' ETA ,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,WMSOP AS INPUTBY,'' BLTYPE, CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=WMS.MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, CUSTOMNO, ACCDATE , '' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME, FEESTATUS,WMSDATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus,ISVOU,VOUNO,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.WMS WITH (NOLOCK) where ASSOCIATEDNO<>gid UNION ALL SELECT GID AS BSNO,GID MASTERNO, 'WMS_OUT' AS OPLB, '仓储出库' AS OPLBNAME,'仓储出库' AS BSTYPE, CUSTOMERNAME, BSNO AS CUSTNO,BSNO as ORDERNO, ISNULL( (select top 1 BLNO from wms where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)), (select top 1 BLNO from wms where gid = (select top 1 ASSOCIATEDNO from wms_in where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)))) MblNo,'' HBLNO, DODATE AS ETD,'' ETA ,'' STLDATE,'' STLNAME,'' VESSEL,'' VOYNO,WMSOP AS INPUTBY,'' BLTYPE, CREATETIME as CREATETIME, 0 BSSTATUS, '' AS SALE, (select top 1 showname from [user] where gid=wms_out.MODIFIEDUSER) AS OP, '' DOC, '' AS CUSTSERVICE,'' AS PORTLOAD, '' AS PORTDISCHARGE, CUSTOMNO, ACCDATE , '' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,'' LANE,'' FORWARDER, 0 AS NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME, FEESTATUS,DODATE AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO ,'' DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.wms_out WITH (NOLOCK) UNION ALL SELECT b.BSNO,b.BSNO MASTERNO, 'op_airn' AS OPLB, '国内空运' AS OPLBNAME,'国内空运' AS BSTYPE, CUSTOMERNAME, CUSTNO,ORDERNO,MBLNO, HBLNO,dbo.trimtime(ETD) ETD,dbo.trimtime(ETA) ETA ,dbo.trimdate(STLDATE) STLDATE,STLNAME STLNAME, VESSEL,'' VOYNO, INPUTBY,BLTYPE, CREATETIME, BSSTATUS, SALE , OP ,'' DOC, CUSTSERVICE, PORTLOAD, PORTDISCHARGE, '' AS CUSTOMNO, ACCDATE,AIRLINES CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE, FORWARDER ,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) AS NETWEIGHT ,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE ,c.CARGONAME GOODSNAME, FEESTATUS,ETD AS OPDATE,'' AS CUSTOMDATE,'' ENTERP ,(case b.BLTYPE when '国内分单' then c.BOXCOUNT else d.BOXCOUNT end) PKGS ,(case b.BLTYPE when '国内分单' then c.CBM else d.CBM end) CBM ,BLFRT,SALEDEPT,CUSTOMSNUM,INVNO,'' BSCUSTOMNO, INSPECTIONDATE,INSPECTIONNO,CONTRACTNO,'' BOOKNO,AGENTID,ISPRINTPR,'' as NUMBERPLATE ,(case b.BLTYPE when '国内分单' then c.[WEIGHT] else d.[WEIGHT] end) FEEKGS,OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO ,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,'' SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_airn b WITH (NOLOCK) left join OP_AIRN_CARGO C on b.BLTYPE='国内分单' and c.bsno = B.bsno left join OP_AIRN_CARGO D on b.BLTYPE='国内主单' and c.bsno =(select top 1 bsno from OP_AIRN where HBLNO=b.HBLNO and BLTYPE='国内分单') UNION ALL SELECT BSNO, BSNO MASTERNO,'op_truck_bulk' AS OPLB, CASE WHEN TRANSTYPE='普运' THEN '陆运普货订单' ELSE '陆运集运订单' END AS OPLBNAME,CASE WHEN TRANSTYPE='普运' THEN '陆运普货订单' ELSE '陆运集运订单' END as BSTYPE,CUSTOMERNAME, CUSTNO,ORDERNO,ORDERNO MBLNO,ORDERNO HBLNO, ETD,ETA ,STLDATE,STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE, CREATETIME, BSSTATUS, SALE, OP, DDOP AS DOC,CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_truck_bulk WITH (NOLOCK) UNION ALL SELECT BSNO,BSNO MASTERNO, 'op_truck_bulk_pc' AS OPLB, CASE WHEN TRANSTYPE='普运' THEN '陆运普货派车' ELSE '陆运集运派车' END AS OPLBNAME,CASE WHEN TRANSTYPE='普运' THEN '陆运普货派车' ELSE '陆运集运派车' END as BSTYPE,CUSTOMERNAME, CUSTNO,'' ORDERNO,'' MBLNO,'' HBLNO, ETD,ETA ,STLDATE,STLNAME,'' VESSEL,'' VOYNO,OP AS INPUTBY,'' BLTYPE, CREATETIME, BSSTATUS,'' SALE, OP, DDOP AS DOC,'' CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER, NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,PKGS,CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,CONTRACTNO,'' BOOKNO,'' AGENTID,ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,ISVOU,VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_truck_bulk_pc WITH (NOLOCK) UNION ALL SELECT BSNO,BSNO MASTERNO, 'op_ctnmng' AS OPLB, '集装箱管理' AS OPLBNAME,BLTYPE as BSTYPE,CUSTOMERNAME,CUSTNO,'' ORDERNO, MBLNO,'' HBLNO,BSDATE ETD,ETD ETA ,'' STLDATE,'' STLNAME, VESSEL, VOYNO,OP AS INPUTBY,BLTYPE BLTYPE, BSDATE AS CREATETIME, BSSTATUS, SALE, OP, OP AS DOC,'' AS CUSTSERVICE, PORTLOAD, PORTDISCHARGE,'' CUSTOMNO, ACCDATE,'' CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER,0 NETWEIGHT,0 KGS,TEU, CNTRTOTAL, CORPID,CNTR1,CNTR2,CNTR3,CNTR4,CNTR5,CNTR6,CNTR7,CNTR8,CNTR9,CNTR10,OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT,'' SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,BillFeeStatus ,0 ISVOU,'' VOUNO,PORTDISCHARGE DESTINATIONID,SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_ctnmng WITH (NOLOCK) UNION ALL SELECT BSNO,BSNO MASTERNO, 'op_InternalTrade' AS OPLB, '内贸海运管理' AS OPLBNAME,'整箱' as BSTYPE,CUSTOMERNAME,CUSTNO,'' ORDERNO, MBLNO,'' HBLNO,dbo.trimdate(ETD) ETD,dbo.trimdate(ETA) ETA ,dbo.trimdate( STLDATE) STLDATE,STLNAME, VESSEL, VOYNO,OP AS INPUTBY,'整箱' BLTYPE, BSDATE AS CREATETIME, BSSTATUS,(select showname from [user] where GID=SALE ) SALE, OP, OP AS DOC, CUSTSERVICE, PORTLOADID+'_'+PORTLOAD PORTLOAD, PORTDISCHARGEID+'_'+PORTDISCHARGE PORTDISCHARGE,'' CUSTOMNO, ACCDATE,CARRIER, BSSOURCE,BSSOURCEDETAIL,'' LANE,'' FORWARDER,0 NETWEIGHT,0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,ETD AS OPDATE,'' CUSTOMDATE,'' ENTERP,0 PKGS,0 CBM,'' BLFRT, SALEDEPT,0 CUSTOMSNUM,'' INVNO,'' BSCUSTOMNO, '' INSPECTIONDATE,'' INSPECTIONNO,'' CONTRACTNO,'' BOOKNO,'' AGENTID,'' ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS, OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,isnull(PORTLOADREMARK,'')+';;'+isnull(VIA_MARK,'') remark,'' TRADETERM,'' PLACERECEIPT,PlACERECEIPT DESTINATION,SEALNO CNTRSEALNO ,BillFeeStatus ,0 ISVOU,'' VOUNO,PORTDISCHARGE DESTINATIONID,CORPID SALECORPID,'' YARD,dbo.trimtime(DELIVERYDATE) DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.op_InternalTrade WITH (NOLOCK) union all SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_IN_DO' AS OPLB, '入库执行' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'入库执行' BLTYPE, CreateDate CREATETIME, BSSTATUS,'' SALE ,(select SHOWNAME from vw_user where USERID=CreateID ) OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, KGS AS NETWEIGHT, KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE, GOODSNAME, FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP,PKGS,CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,KGS FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.VW_OP_WMS_IN_DO union all SELECT Convert(varchar(36),OP_WMS_OUT_DO_BSNO.GID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_OUT_DO' AS OPLB, '出库明细' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,WMSNO CUSTNO,WMSNO ORDERNO,OP_WMS_OUT_DO.MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA ,null STLDATE,null STLNAME,'' VESSEL,OP_WMS_OUT_DO.TRUCKNO VOYNO, Creator,'出库明细' BLTYPE, CreateDate CREATETIME, BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) AS NETWEIGHT, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, isnull((select sum(PKGS) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0)PKGS, isnull((select sum(CBM) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_OUT_DO_BSNO left join dbo.OP_WMS_OUT_DO on OP_WMS_OUT_DO.WMSDOID=OP_WMS_OUT_DO_BSNO.BSNO union all SELECT Convert(varchar(36),WMSPLANID) BSNO,Convert(varchar(36),WMSPLANID) MASTERNO, 'VW_OP_WMS_OUT_PLAN' AS OPLB, '出库作业' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,WMSNO CUSTNO,WMSNO ORDERNO,VW_OP_WMS_OUT_PLAN.MBLNO,'' HBLNO,dbo.trimtime(PLANTIME) ETD,dbo.trimtime(PLANTIME) ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'出库受理' BLTYPE, CreateDate CREATETIME, BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),PLANTIME,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, isnull((select sum(NETWEIGHT) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=VW_OP_WMS_OUT_PLAN.WMSPLANID),0) AS NETWEIGHT, isnull((select sum(kgs) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=VW_OP_WMS_OUT_PLAN.WMSPLANID),0) KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,PLANTIME AS OPDATE,PLANTIME CUSTOMDATE,'' ENTERP, isnull((select sum(PKGS) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=VW_OP_WMS_OUT_PLAN.WMSPLANID),0)PKGS, isnull((select sum(CBM) from OP_WMS_OUT_PLAN_DETAIL where WMSPLANID=VW_OP_WMS_OUT_PLAN.WMSPLANID),0) CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.VW_OP_WMS_OUT_PLAN union all SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_OUT_DO' AS OPLB, '出库作业' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,WMSNO CUSTNO,WMSNO ORDERNO,OP_WMS_OUT_DO.MBLNO,'' HBLNO,dbo.trimtime(DODATE) ETD,dbo.trimtime(DODATE) ETA ,null STLDATE,null STLNAME,'' VESSEL,TRUCKNO VOYNO, Creator,'出库作业' BLTYPE, CreateDate CREATETIME, BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER, isnull((select sum(NETWEIGHT) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) AS NETWEIGHT, isnull((select sum(kgs) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, isnull((select sum(PKGS) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0)PKGS, isnull((select sum(CBM) from OP_WMS_OUT_DO_GOODS where WMSDOID=OP_WMS_OUT_DO.WMSDOID),0) CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,Creator OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_OUT_DO union all SELECT Convert(varchar(36),D.WMSDUIDETAILID) BSNO,Convert(varchar(36),D.WMSDUIID) MASTERNO, 'OP_WMS_FEEDUI' AS OPLB, '仓储月结账单' AS OPLBNAME,'仓储业务' AS BSTYPE, D.CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,dbo.trimtime(D.STARTDATE) ETD,dbo.trimtime(D.ENDDATE) ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'仓储月结' BLTYPE, CreateDate CREATETIME,0 BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),h.ACCDATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, FEESTATUS,D.ACCDATE AS OPDATE,D.ACCDATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,h.REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,FEESTATUS BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_FEEDUI_STORAGE_DETAIL D left join OP_WMS_FEEDUI_STORAGE h on D.WMSDUIID=h.WMSDUIID union all SELECT Convert(varchar(36),WMSWEIGHID) BSNO,Convert(varchar(36),WMSWEIGHID) MASTERNO, 'OP_WMS_WEIGH' AS OPLB, '过磅业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,MBLNO,'' HBLNO,DODATE ETD,DODATE ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'过磅业务' BLTYPE, CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, '' FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_WEIGH union all SELECT Convert(varchar(36),WMSTRANSFERGOODSID) BSNO,Convert(varchar(36),WMSTRANSFERGOODSID) MASTERNO, 'OP_WMS_TRANSFERGOODS' AS OPLB, '货转业务' AS OPLBNAME,'仓储业务' AS BSTYPE, NEWCUSTOMERNAME CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,(select MBLNO from op_wms where wmsid=(select top 1 WMSID from OP_WMS_TRANSFERGOODS_DETAIL where WMSTRANSFERGOODSID=OP_WMS_TRANSFERGOODS.WMSTRANSFERGOODSID))MBLNO,'' HBLNO,TRANSFERDATE ETD,TRANSFERDATE ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'货转业务' BLTYPE, CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),TRANSFERDATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, '' FEESTATUS,TRANSFERDATE AS OPDATE,TRANSFERDATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_TRANSFERGOODS union all SELECT Convert(varchar(36),WMSDOID) BSNO,Convert(varchar(36),WMSDOID) MASTERNO, 'OP_WMS_MOVE' AS OPLB, '移库业务' AS OPLBNAME,'仓储业务' AS BSTYPE, CUSTOMERNAME,BSNO CUSTNO,BSNO ORDERNO,(select MBLNO from OP_WMS where WMSID=OP_WMS_MOVE.WMSID) MBLNO,'' HBLNO,DODATE ETD,DODATE ETA ,null STLDATE,null STLNAME,'' VESSEL,'' VOYNO, Creator,'移库业务' BLTYPE, CreateDate CREATETIME,'' BSSTATUS,'' SALE ,Creator OP ,'' DOC,'' CUSTSERVICE,'' PORTLOAD,'' PORTDISCHARGE,'' CUSTOMNO, CONVERT(VARCHAR(7),DODATE,120) ACCDATE,'' CARRIER,'' BSSOURCE,''BSSOURCEDETAIL,''LANE,'' FORWARDER,0 AS NETWEIGHT, 0 KGS,0 TEU,'' CNTRTOTAL, CORPID,0 CNTR1,0 CNTR2,0 CNTR3,0 CNTR4,0 CNTR5,0 CNTR6,0 CNTR7,0 CNTR8,0 CNTR9,0 CNTR10,0 OTCNTR, '' AS TRADETYPE,'' GOODSNAME, '' FEESTATUS,DODATE AS OPDATE,DODATE CUSTOMDATE,'' ENTERP, 0 PKGS,0 CBM ,''BLFRT,''SALEDEPT,''CUSTOMSNUM,''INVNO,'' BSCUSTOMNO, ''INSPECTIONDATE,''INSPECTIONNO,''CONTRACTNO,'' BOOKNO,''AGENTID,''ISPRINTPR,'' as NUMBERPLATE,0 FEEKGS,'' OPERATOR,'' SERVICECONTRACTNO,0 ISCANCEL ,'' APPLYNO,'' ISSUETYPE,'' BLISSUESTATUS,REMARK,'' TRADETERM,'' PLACERECEIPT,'' DESTINATION,'' CNTRSEALNO,'' BillFeeStatus,0 ISVOU, '' VOUNO,'' DESTINATIONID,CORPID SALECORPID,'' YARD,'' DELIVERYDATE,'' FRCUSTSERVICE,'' SERVICE,'' REMARK2,'' BILLFEESTATUSTIME,'' TRUCKER,'' CUSTOMSER,null CLOSINGDATE,'' KINDPKGS,'' CARGOID,'' DCLASS FROM dbo.OP_WMS_MOVE GO insert Into code_fee_group values( '649AACAF-DE14-4E8C-A57B-E763A847AC05','cksl','出库受理','' ) GO ALTER VIEW [dbo].[VW_OP_REP_WMSOUTDO] AS select wc.WMSLOGID,od.DODATE,w.CORPID, w.CUSTOMERNAME,w.GOODSNAME,w.MBLNO,w.CUSTOMNO,w.CNTRNO,-wc.PKGS PKGS,-wc.KGS KGS,-wc.NETWEIGHT NETWEIGHT,-wc.CBM CBM,wc.PKGS3,wc.KGS3,wc.NETWEIGHT3,wc.CBM3,-wc.STORAGEUNITCOUNT STORAGEUNITCOUNT,wc.STORAGEUNITCOUNT3,odg.STOREHOUSE ,odg.AREACODE,w.OP ,wc.CHANGETYPE,od.WMSNO,cg.GOODSFEETYPE,cg.GoodsTypeGID,w.GOODSOWNER ,od.TRUCKNO,w.INDATE,w.WMSINDATE,w.FEESTARTDATE,od.CUSTOMNO CUSTOMNO_OUT ,od.CreateID DO_CreateID from OP_WMS_CHANGE wc left join op_wms w on w.WMSID=wc.WMSID left join op_wms_OUT_do od on od.WMSDOID=wc.DOBSNO left join OP_WMS_OUT_DO_GOODS odg on odg.WMSDOID=wc.DOBSNO and odg.WMSDODETAILID=wc.DOGID left join OP_WMS_PHYSICS p on p.WMSPHYSICSID=odg.WMSPHYSICSID left join code_goods cg on cg.GOODNAME=w.GOODSNAME where wc.CHANGETYPE='出库' GO --drop table OP_WMS_FEEPAYINFO create table OP_WMS_FEEPAYINFO ( [GID] [uniqueidentifier] NOT NULL, [WMSID] [uniqueidentifier] NOT NULL, [WMSBASEID] [uniqueidentifier] NOT NULL, [FEESTARTDATE] datetime NOT NULL, [FEEENDDATE] datetime NULL, FEERATEWMSID uniqueidentifier null, SOURCEDOID uniqueidentifier null, [ARCLIENTWMSOUT] [varchar](50) NULL, [APCLIENTWMSOUT] [varchar](50) NULL, [ARCLIENTWMSIN] [varchar](50) NULL, [APCLIENTWMSIN] [varchar](50) NULL, [ARCLIENTWMS_OUTDO] [varchar](50) NULL, [APCLIENTWMS_OUTDO] [varchar](50) NULL, STORAGEUNITCOUNT numeric(22,6), CONSTRAINT [PK_OP_WMS_FEEPAYINFO] 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 ALTER VIEW [dbo].[Vw_Op_Wms_FeeBase] AS select P.gid, w.[WMSID],[BSNO],[BILLTYPE],[REMARK],[CORPID],[CUSTOMERNAME],[MATERIALNO],[GOODSCODE],[GOODSNAME] ,[GOODSHSCODE],[MBLNO],[CNTRNO],[KGS],NETWEIGHT,[CBM],[PKGS],[KINDPKGS],[STORAGEUNIT] ,P.STORAGEUNITCOUNT ,P.FEERATEWMSID ,[ISCLEAR],[INDATE],WMSINDATE ,p.FEESTARTDATE ,(select FEERATESTARTDATE from op_wms where wmsid=p.FEERATEWMSID)FEERATESTARTDATE ,case when p.FEEENDDATE is null then (case when w.FEEENDDATE is null then '3000-12-12' else w.FEEENDDATE end) else case when isnull(p.FEEENDDATE,'3000-12-12') > isnull(w.FEEENDDATE,'3000-12-12') then w.FEEENDDATE else isnull(p.FEEENDDATE,'3000-12-12') end end [FEEENDDATE] ,[MBLNO]+[CNTRNO] MBLNOCNTRNO ,OP,CUSTOMNO,ACCBOOKNO,GOODSOWNER ,P.ARCLIENTWMSOUT from OP_WMS_FEEPAYINFO p left join OP_WMS w on p.WMSID=w.wmsid where (case when p.FEEENDDATE is null then (case when w.FEEENDDATE is null then '3000-12-12' else w.FEEENDDATE end) else case when p.FEEENDDATE > isnull(w.FEEENDDATE,'3000-12-12') then w.FEEENDDATE else p.FEEENDDATE end end>=p.FEESTARTDATE )