You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/word/新协航_设计文档/数据库建表文档/1.0/Cargo.sql

127 lines
4.1 KiB
MySQL

3 years ago
/****** Object: Table [dbo].[Import_cargo] Script Date: 09/02/2013 14:12:49 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Import_cargo]') AND type in (N'U'))
DROP TABLE [dbo].[Import_cargo]
GO
/****** Object: Table [dbo].[Import_cargo] Script Date: 09/02/2013 14:12:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Import_cargo](
[id] [int] IDENTITY(1,1) NOT NULL,
[ContractNo] varchar(50) NOT NULL,
[cargoinfo_id] [int] NOT NULL,
[cargociq_id] [int] not null,
[name] [varchar](50) NOT NULL,
[Ename] [varchar](50) NULL,
[UNIT] tinyint default 0 NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ kg <EFBFBD><EFBFBD>
[U_PRICE] numeric(18,3) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[U_weight] [numeric](18, 3) NULL,----<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>
[weight] [numeric](18, 3) NULL,--kg<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[m_weight] [numeric](18, 3) NULL,--ë<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ)
[price] [numeric](18, 3) NULL,--<EFBFBD>۸<EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۣ<EFBFBD><EFBFBD><EFBFBD>kgΪ<EFBFBD><EFBFBD>λ)
[price_agio] [numeric](18, 3) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD>۸<EFBFBD>֮<EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬprice)
[price_limit] [numeric](18, 3) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>۸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
[Amount] [numeric](18, 3) NULL,--Ӧ<EFBFBD>ռ۸<EFBFBD> weight*Price
[tex_Amount] [numeric](18, 3) NULL,--<EFBFBD><EFBFBD><EFBFBD>ۼ۸<EFBFBD>
[pay_Amount] [numeric](18, 3) NULL,--Ӧ<EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD> (price-price_agio)*price
[BoxCount] [int] NULL,--<EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[BoxWeight] [numeric](18, 3) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[Exporter] [varchar](50) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[FactoryNo] [varchar](50) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[Productiondate] [varchar](250) NULL,--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[currid] varchar(50) null,--<EFBFBD>ұ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>code_currency
[prepayments] [numeric](18, 3) NULL,--Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[balance] [numeric](18, 3) NULL,--β<EFBFBD><EFBFBD>
[paypart] tinyint default 0,
[baolv] numeric(8,4) default 1,
[tariff] varchar(20) null,
[tax] numeric(8,3) null,
[tax_zz] numeric(8,3) null,
[Declarenumber] varchar(50) null,--<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>
[Exchangerate] numeric(18,4) default 1,
-- [FinanceStatus] tinyint default 0,
CONSTRAINT [PK_Import_cargo] PRIMARY KEY CLUSTERED
(
[id] ASC
)
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name)
values ('A1',1,1,'<EFBFBD><EFBFBD>Ʒ1')
insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name)
values ('A2',2,2,'<EFBFBD><EFBFBD>Ʒ2')
insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name)
values ('A3',3,3,'<EFBFBD><EFBFBD>Ʒ2_2')
insert into [Import_cargo] (contractno,cargoinfo_id,cargociq_id,name)
values ('A4',4,4,'<EFBFBD><EFBFBD>Ʒ2_3')
SELECT c.*,
(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=11 and EnumValueID=c.unit) as UnitRef,
(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=12 and EnumValueID=c.paypart) as paypartRef,
ci.code as cicode,ci.name as ciname,curr.codename,curr.defaultrate,
ci.code+'_'+ci.name as cicodeandname,
ciq.ciqcode as ciqcode,ciq.ciqname as ciqname,
ciq.ciqcode+'_'+ciq.ciqname as ciqcodeandname
--,
--(select EnumValueName from tSysEnumValue where LangId=0
--and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff,
--case cc.tariff when 0 then ci.tax_zhg when 1 then ci.tax_pt end tax,
--ci.tax_zz
FROM [ShippingWeb].[dbo].[Import_cargo] c
left join [Import_cargoinfo] ci on c.[cargoinfo_id] = ci.id
left join [Import_cargociq] ciq on c.[cargociq_id] = ciq.id
left join [code_currency] curr on curr.gid=c.currid
left join [import_main] m on M.contractno=c.contractno
left join [code_country] cc on cc.countryid=m.countryid
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>hs<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>/<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˰˰<EFBFBD>ʺ<EFBFBD><EFBFBD><EFBFBD>ֵ˰˰<EFBFBD><EFBFBD>
select code,name,code+'_'+name codeandname,
countryid,(select EnumValueName from tSysEnumValue where LangId=0
and EnumTypeID=9000 and EnumValueID=cc.tariff) as tariff,
case cc.tariff when 0 then ci.tax_zhg when 1 then ci.tax_pt/100 end tax,
ci.tax_zz/100
from code_country cc,import_cargoinfo ci
where countryid='gb'
/*
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Import_cargo
DROP CONSTRAINT DF__Import_ca__Finan__1EA62536
GO
ALTER TABLE dbo.Import_cargo
DROP COLUMN FinanceStatus
GO
ALTER TABLE dbo.Import_cargo SET (LOCK_ESCALATION = TABLE)
GO
COMMIT
*/