Commit bd07e249 by 向延琳

去掉数据同步的sql

1 parent fcdc5fd9
......@@ -54,29 +54,7 @@ ALTER TABLE `t_device_journey_overview`
ALTER TABLE `t_device_journey_overview`
ADD INDEX idx_vd_id (`vd_id`);
-- 设备行程表
create table t_device_journey
(
id int(11) auto_increment comment '里程主键ID'
primary key,
sn varchar(32) null comment '设备序列号',
vd_id int(11) null comment '车辆、设备关系id',
begin_time datetime null comment '里程开始时间',
end_time datetime null comment '里程结束时间',
begin_address varchar(64) null comment '里程开始地址',
end_address varchar(64) null comment '里程结束地址',
mileage int(11) null comment '行驶里程km',
del_flag tinyint default 0 null comment '是否删除 0=正常 -1=删除',
created_date datetime null comment '创建时间|入库时间',
created_by int(11) null comment '创建人用户id',
updated_date datetime null comment '更新时间',
updated_by int(11) null comment '更新人用户id'
)
comment '新e盾|里程表';
ALTER TABLE `t_device_journey`
ADD INDEX idx_sn (`sn`);
ALTER TABLE `t_device_journey`
ADD INDEX idx_vd_id (`vd_id`);
ALTER TABLE `t_device_journey`
ADD INDEX idx_begin_time (`begin_time`);
......@@ -163,24 +141,6 @@ CREATE TABLE `t_zhongli_carservice_info` (
) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='仲利新E盾包活干对应服务商信息';
-- 里程初始化
-- 更新vdId
update t_device_journey tdj
INNER JOIN t_vehicle_device tvd on tvd.sn = tdj.sn
LEFT JOIN t_vehicle tv on tv.id = tvd.vehicle_id
SET tdj.vd_id = tvd.id,
tdj.created_by = tv.created_by
where tvd.del_flag = 0
and tdj.begin_time >= tv.created_date
and tvd.bind_status = 1
and tdj.id < 500000 and tdj.id>= 0;
INSERT INTO t_device_journey_overview (sn, vd_id, total_journey_count, distance, created_by, created_date, updated_date)
select sn, vd_id, count(1), sum(mileage), created_by, created_date, updated_date
from t_device_journey
where vd_id is not null
group by sn, vd_id;
alter table t_electric_fence_sns add vd_id int null comment '车辆设备绑定关系' after sn;
alter table t_electric_fence_sns_copy add vd_id int null comment '车辆设备绑定关系' after sn;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!