-- 初始化查勘员表
TRUNCATE TABLE dd_surveyor;

-- ---------查勘员表数据迁移------------------
INSERT INTO `dd_surveyor` (
	`surveyor_name`,
	`surveyor_code`,
	`surveyor_tel`,
	`surveyor_account`,
	`password`,
	`longitude`,
	`latitude`,
	`gps_upload_time`,
	`sign_status`,
	`survey_type`,
	survey_car_roll,
	`auth_estimate_prop`,
	`auth_estimate_vehicle`,
	`auth_estimate_people`,
	`auth_survey_people`,
	`auth_survey`,
	`auth_video_estimate`,
	`actual_org_code`,
	`address`,
	`id_card_no`,
	`task_upper_limit`,
	`task_num`,
	`is_enable`,
	`location_status`,
	`create_by`,
	`create_time`,
	`update_by`,
	`update_time`,
	`sms_phone`,
	`branch_off_site`,
	`mid_range`,
	`leader_name`,
	`leader_phone`,
	`update_pwd_time`
) SELECT
	`NAME`,
	USER_CODE,
	TEL,
	USERNAME,
	PASS_WORD,
	LONGITUDE,
	LATITUDE,
	UPLOAD_TIME,
	SIGN_STATUS,
	SURVEY_TYPE,
	SURVEY_ROLL,
	AUTH_PROP_ESTIMATE,
	AUTH_VEHICLE_ESTIMATE,
	AUTH_PEOPLE_ESTIMATE,
	AUTH_PEOPLE_SURVEY,
	AUTH_SURVEY,
	IS_VIDEO,
	ORGCODE_ORIG,
	ADDRESS,
	personcard_no,
	TASKUPPERLIMIT,
	'0',
	IS_ENABLE,
	SIGN_STATUS,
	CREATE_BY,
	CREATE_DATE,
	UPDATE_BY,
	UPDATE_DATE,
	sms_phone,
	branchOffSite,
	midRange,
	leaderName,
	leaderPhone,
	update_pwd_time
FROM
	sd_survey
WHERE
	SURVEY_TYPE = '0';


	
	
-- ------------------------------额外处理字段------------------------------

-- -----机构编码——org_code
UPDATE dd_surveyor SET org_code = LEFT(actual_org_code,2);
-- -----机构名称——org_name
UPDATE dd_surveyor s,sys_dept d SET s.org_name=d.dept_name WHERE s.org_code=d.dept_code;

-- -----实际机构名称——actual_org_name
UPDATE dd_surveyor s,sys_dept d SET s.actual_org_name=d.dept_name WHERE s.actual_org_code=d.dept_code;




