apzl_leasing/src_sql/procedure/proc_insert_init_cardata.sql

130 lines
2.5 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

create procedure proc_insert_init_cardata()
begin
-- 删除车品牌表,初始化表的时间为2018/06/17历史数据对应车品牌、车系、车型为tmp_10、tmp_14、tmp_12
delete from lb_cardata_brand where inputtime='2018/06/17';
INSERT INTO `apzl`.`lb_cardata_brand` (
`ID`,
`brandid`,
`brandname`,
`brandinitial`,
`opertype`,
`inputuserid`,
`inputorgid`,
`inputtime`,
`updateuserid`,
`updateorgid`,
`updatetime`
)
(SELECT
REPLACE(UUID(), '-', ''),
t.brand_id,
t.brand_name,
t.brand_initial,
'新增',
'administrator',
'8009001',
'2018/06/17', -- DATE_FORMAT(CURDATE(), '%Y/%m/%d'),后期可替换为系统当前日期
'',
'',
''
FROM
tmp_10 t
where t.brand_id not in (select brandid from lb_cardata_brand)
) ;
-- 删除车系表
delete from lb_cardata_series where inputtime='2018/06/17';
INSERT INTO `apzl`.`lb_cardata_series` (
`ID`,
`brandid`,
`brandname`,
`seriesid`,
`seriesname`,
`seriesgroupname`,
`levelname`,
`makertype`,
`opertype`,
`inputuserid`,
`inputorgid`,
`inputtime`,
`updateuserid`,
`updateorgid`,
`updatetime`
)
(SELECT
REPLACE(UUID(), '-', ''),
t.brand_id,
t.brand_name,
t.series_id,
t.series_name,
t.series_group_name,
t.level_name,
t.maker_type,
'新增',
'administrator',
'8009001',
'2018/06/17',
'',
'',
''
FROM tmp_14 t
WHERE t.series_id NOT IN (SELECT seriesid FROM lb_cardata_series)
) ;
-- 删除车型表
delete from lb_cardata_model where inputtime='2018/06/17';
INSERT INTO `apzl`.`lb_cardata_model` (
`ID`,
`brandid`,
`brandname`,
`seriesid`,
`seriesname`,
`seriesgroupname`,
`modelid`,
`modelname`,
`price`,
`liter`,
`geartype`,
`modelyear`,
`makertype`,
`dischargestandard`,
`seatnumber`,
`minregyear`,
`maxregyear`,
`opertype`,
`inputuserid`,
`inputorgid`,
`inputtime`,
`updateuserid`,
`updateorgid`,
`updatetime`
)
(SELECT
REPLACE(UUID(), '-', ''),
t.brand_id,
t.brand_name,
t.series_id,
t.series_name,
t.series_group_name,
t.model_id,
t.model_name,
t.price,
t.liter,
t.gear_type,
t.model_year,
t.maker_type,
t.discharge_standard,
t.seat_number,
t.min_reg_year,
t.max_reg_year,
'新增',
'administrator',
'8009001',
'2018/06/17',
'',
'',
'' FROM tmp_12 t WHERE t.model_id NOT IN (SELECT modelid FROM lb_cardata_model)
) ;
end;