-- 车队 资产管理 机构数据变更脚本 --
-- ag_device_info 表
UPDATE ag_device_info d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_device_info d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_device_info  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE ag_device_info  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE ag_device_info  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- ag_device_info_gps 表
UPDATE ag_device_info_gps d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_device_info_gps d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_device_info_gps  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_device_info_gps  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_device_info_gps  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- ag_device_info_log 表
UPDATE ag_device_info_log d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_device_info_log d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_device_info_log  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_device_info_log  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_device_info_log  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- ag_survey_car 表
UPDATE ag_survey_car d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_survey_car d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_survey_car  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_survey_car  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_survey_car  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- ag_survey_car_asset 表
UPDATE ag_survey_car_asset d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_survey_car_asset d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_survey_car_asset  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_survey_car_asset  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_survey_car_asset  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- ag_survey_logger 表
UPDATE ag_survey_logger d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_survey_logger d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_survey_logger  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_survey_logger  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_survey_logger  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- ag_user_info 表
UPDATE ag_user_info d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE ag_user_info d1 , sys_dept d2 SET d1.branch_code = d2.dept_id   WHERE d1.branch_name = d2.dept_name;
UPDATE ag_user_info  SET branch_code = '244' , branch_name = '周口中心支中心' WHERE branch_code = '63';
UPDATE ag_user_info  SET branch_code = '245' , branch_name = '南阳中心支中心' WHERE branch_code = '64';
UPDATE ag_user_info  SET branch_code = '271' , branch_name = '长治中心支公司' WHERE branch_code = '66';

-- vfms_alarm_config 表
UPDATE vfms_alarm_config d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_alarm_config  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_alarm_config  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_alarm_config  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_alarm_fault 表
UPDATE vfms_alarm_fault d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_alarm_fault  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_alarm_fault  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_alarm_fault  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_alarm_monitor 表
UPDATE vfms_alarm_monitor d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_alarm_monitor  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_alarm_monitor  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_alarm_monitor  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_alarm_statistics 表 
UPDATE vfms_alarm_statistics d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_alarm_statistics d1 , sys_dept d2 SET d1.org_branch_code = d2.dept_id   WHERE d1.org_branch_name = d2.dept_name;
UPDATE vfms_alarm_statistics  SET org_branch_code = '244' , org_branch_name = '周口中心支中心' WHERE org_branch_code = '63';
UPDATE vfms_alarm_statistics  SET org_branch_code = '245' , org_branch_name = '南阳中心支中心' WHERE org_branch_code = '64';
UPDATE vfms_alarm_statistics  SET org_branch_code = '271' , org_branch_name = '长治中心支公司' WHERE org_branch_code = '66';

-- vfms_record_upkeep_apply 表
UPDATE vfms_record_upkeep_apply d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_record_upkeep_apply d1 , sys_dept d2 SET d1.org_branch_code = d2.dept_id   WHERE d1.org_branch_name = d2.dept_name;
UPDATE vfms_record_upkeep_apply  SET org_branch_code = '244' , org_branch_name = '周口中心支中心' WHERE org_branch_code = '63';
UPDATE vfms_record_upkeep_apply  SET org_branch_code = '245' , org_branch_name = '南阳中心支中心' WHERE org_branch_code = '64';
UPDATE vfms_record_upkeep_apply  SET org_branch_code = '271' , org_branch_name = '长治中心支公司' WHERE org_branch_code = '66';

-- vfms_record_vehicle_refuel 表
UPDATE vfms_record_vehicle_refuel d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_record_vehicle_refuel d1 , sys_dept d2 SET d1.org_branch_code = d2.dept_id   WHERE d1.org_branch_name = d2.dept_name;
UPDATE vfms_record_vehicle_refuel  SET org_branch_code = '244' , org_branch_name = '周口中心支中心' WHERE org_branch_code = '63';
UPDATE vfms_record_vehicle_refuel  SET org_branch_code = '245' , org_branch_name = '南阳中心支中心' WHERE org_branch_code = '64';
UPDATE vfms_record_vehicle_refuel  SET org_branch_code = '271' , org_branch_name = '长治中心支公司' WHERE org_branch_code = '66';

-- vfms_record_vehicle_statistics 表
UPDATE vfms_record_vehicle_statistics d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_record_vehicle_statistics d1 , sys_dept d2 SET d1.org_branch_code = d2.dept_id   WHERE d1.org_branch_name = d2.dept_name;
UPDATE vfms_record_vehicle_statistics  SET org_branch_code = '244' , org_branch_name = '周口中心支中心' WHERE org_branch_code = '63';
UPDATE vfms_record_vehicle_statistics  SET org_branch_code = '245' , org_branch_name = '南阳中心支中心' WHERE org_branch_code = '64';
UPDATE vfms_record_vehicle_statistics  SET org_branch_code = '271' , org_branch_name = '长治中心支公司' WHERE org_branch_code = '66';

-- vfms_record_vehicle_trajectory 表
UPDATE vfms_record_vehicle_trajectory d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_record_vehicle_trajectory d1 , sys_dept d2 SET d1.org_branch_code = d2.dept_id   WHERE d1.org_branch_name = d2.dept_name;
UPDATE vfms_record_vehicle_trajectory  SET org_branch_code = '244' , org_branch_name = '周口中心支中心' WHERE org_branch_code = '63';
UPDATE vfms_record_vehicle_trajectory  SET org_branch_code = '245' , org_branch_name = '南阳中心支中心' WHERE org_branch_code = '64';
UPDATE vfms_record_vehicle_trajectory  SET org_branch_code = '271' , org_branch_name = '长治中心支公司' WHERE org_branch_code = '66';

-- vfms_survey_user 表
UPDATE vfms_survey_user d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_survey_user  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_survey_user  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_survey_user  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_survey_user_gps 表
UPDATE vfms_survey_user_gps d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_survey_user_gps  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_survey_user_gps  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_survey_user_gps  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_survey_user_sign 表
UPDATE vfms_survey_user_sign d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_survey_user_sign  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_survey_user_sign  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_survey_user_sign  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_task 表
UPDATE vfms_task d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_task  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_task  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_task  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_upkeep_apply_image 表
UPDATE vfms_upkeep_apply_image d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_upkeep_apply_image  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_upkeep_apply_image  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_upkeep_apply_image  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';

-- vfms_vehicle 表
UPDATE vfms_vehicle d1 , sys_dept d2 SET d1.org_code = d2.dept_id   WHERE d1.org_name = d2.dept_name;
UPDATE vfms_vehicle  SET org_code = '244' , org_name = '周口中心支中心' WHERE org_code = '63';
UPDATE vfms_vehicle  SET org_code = '245' , org_name = '南阳中心支中心' WHERE org_code = '64';
UPDATE vfms_vehicle  SET org_code = '271' , org_name = '长治中心支公司' WHERE org_code = '66';