
-- 初始化收单任务表
TRUNCATE TABLE dd_task_item;

-- ---------收单任务表数据迁移------------------
INSERT INTO `dd_task_item` (
	`case_info_id`,
	`surveyor_name`,
	`surveyor_code`,
	`license_no`,
	`linker_name`,
	`linker_phone`,
	`collect_time`,
	`collect_address`,
	`survey_lng`,
	`survey_lat`,
	`delegate_remark`,
	`remark`,
	`damage_date`,
	`damage_place`,
	`information`,
	`status`,
	`dispatcher_name`,
	`dispatcher_code`
) SELECT
	case_info_id,
	userName,
	userCode,
	licenseNo,
	contact,
	contactPhone,
	collectTime,
	collectAddress,
	LONGITUDE,
	LATITUDE,
	delegateRemark,
	remark,
	damageDate,
	damagePlace,
	information,
	`status`,
	YARDMAN_NAME,
	YARDMAN_ID
FROM
	sd_task_item;
	
-- ------------------------------额外处理字段------------------------------

-- -----1-和案件表保持一致的字段
UPDATE dd_task_item t,
 dd_case_info c
SET t.regist_no = c.regist_no,
t.org_code=c.org_code,
t.org_name=c.org_name
WHERE
	t.case_info_id = c.case_info_id;

-- ------2-查勘员表相关字段
UPDATE dd_task_item t,
 dd_surveyor s
SET t.surveyor_tel = s.surveyor_tel,
t.surveyor_org_code = s.org_code,
t.surveyor_org_name = s.org_name
WHERE
	t.surveyor_code = s.surveyor_code;





