#
# drop table if exists CONTRACT_COST;

create table if not exists PROJECT_COST
(
    ID                        int auto_increment
        primary key,
    CONTRACT_ID               int                null comment '合同编号',
    PROJECT_ID               int                null comment '项目编号',
    APPLY_DATE                date               null comment '申请日期',
    STANDARD_CONTRACT_TEXT    bit   default b'0' not null comment '是否是标准合同文本',
    STANDARD_PAY_WAY          bit   default b'0' not null comment '是否是标准付款方式',
    NO_STANDARD_PAY_WAY_TEXT  varchar(255)       null comment '非标准付款方式文本',
    NO_STANDARD_CONTRACT_TEXT varchar(255)       null comment '非标准合同文本',
    ON_SITE_POSITION_FEE      float default 0    not null comment '现场就位费',
    ON_SITE_SERVICE_FEE       float default 0    not null comment '现场服务费',
    ASSEMBLY_SERVICE_FEE      float default 0    not null comment '装机服务费',
    TECHNICAL_SERVICE_FEE     float default 0    not null comment '技术服务费',
    BID_SERVICE_FEE           float default 0    not null comment '投标服务费',
    FREIGHT_COST              float default 0    not null comment '运费',
    GUARANTEE_LETTER_FEE      float default 0    not null comment '保函费',
    TAX_AND_SURCHARGES        float default 0    not null comment '营业税及附加费',
    GROSS_PROFIT_MARGIN       double default 0    not null comment '毛利率',
    IN_EXCLUSIVE_TAX_AMOUNT   double default 0    not null comment '不含税进项总金额',
    IN_QUANTITY               double default 0    not null comment '进项总数',
    IN_TAX_AMOUNT             double default 0    not null comment '含税进项总金额',
    OUT_EXCLUSIVE_TAX_AMOUNT  double default 0    not null comment '不含税出项总金额',
    OUT_QUANTITY              double default 0    not null comment '出项总数',
    OUT_TAX_AMOUNT            double default 0    not null comment '含税出项总金额',
    constraint CONTRACT_COST_CONTRACT_ID_fk
        foreign key (CONTRACT_ID) references CONTRACT (ID),
    constraint PROJECT_COST_PROJECT_ID_fk
        foreign key (PROJECT_ID) references PROJECT (ID)

)
    comment '项目的成本';


/***
  转换为项目成本
 */

select A.ID, A.PROJECT_ID,C.ID, P.ID  from PROJECT_COST as A left join CONTRACT as C on A.CONTRACT_ID = C.ID left join PROJECT as P on C.PROJECT_ID = P.ID


select pc1_0.ID,pc1_0.APPLICANT_ID,pc1_0.APPLY_DATE,pc1_0.ASSEMBLY_SERVICE_FEE,pc1_0.AUTHORIZER_FILE,pc1_0.AUTHORIZER_DATE,pc1_0.AUTHORIZER_ID,pc1_0.BID_SERVICE_FEE,pc1_0.CONTRACT_ID,pc1_0.DESCRIPTION,pc1_0.FREIGHT_COST,pc1_0.GROSS_PROFIT_MARGIN,pc1_0.GUARANTEE_LETTER_FEE,pc1_0.IMPORT_LOCK,pc1_0.IN_EXCLUSIVE_TAX_AMOUNT,pc1_0.IN_QUANTITY,pc1_0.IN_TAX_AMOUNT,pc1_0.NO_STANDARD_CONTRACT_TEXT,pc1_0.NO_STANDARD_PAY_WAY_TEXT,pc1_0.ON_SITE_SERVICE_FEE,pc1_0.OUT_EXCLUSIVE_TAX_AMOUNT,pc1_0.OUT_QUANTITY,pc1_0.OUT_TAX_AMOUNT,pc1_0.PROJECT_ID,pc1_0.STAMP_TAX,pc1_0.STAMP_TAX_FEE,pc1_0.STANDARD_CONTRACT_TEXT,pc1_0.STANDARD_PAY_WAY,pc1_0.TAX_AND_SURCHARGES,pc1_0.TAX_AND_SURCHARGES_FEE,pc1_0.TECHNICAL_SERVICE_FEE,pc1_0.VER
from PROJECT_COST pc1_0 where pc1_0.DESCRIPTION like ? escape '' and pc1_0.PROJECT_ID=274

