INSERT INTO ${tableName} (${fields}) VALUES ${values} update ${tableName} set ${updateSegment} where ${where} DELETE FROM ${tableName} where ${where} DELETE FROM ${tableTempName} where EXISTS ( SELECT pre_merge_id from maintain_detail d where parent_id = ${maintainId} and d.pre_merge_id = ${tableTempName}.id ) INSERT INTO ${tableName} SELECT ${tempFields} from ${tableTempName} t where EXISTS ( SELECT std_id from ${tableTempName} tm LEFT JOIN maintain_detail on tm.id = maintain_detail.pre_merge_id WHERE maintain_detail.parent_id = ${maintainId} and operate = 'create' and tm.id = t.id ) INSERT INTO maintain_detail SELECT md5(uuid()) as id, ${maintainId} as parent_id, ${operate} as operate, id as pre_merge_id, NOW() as create_time from ${tableTempName} m WHERE m.deal = 0 INSERT INTO maintain_detail SELECT md5(uuid()) as id, ${maintainId} as parent_id, 'delete' as operate, id as pre_merge_id, NOW() as create_time from ${tableTempName} m WHERE m.deal = 0 update ${tableTempName} set std_id = md5(uuid()) WHERE deal = 0 INSERT INTO ${recordTableName} SELECT ${tempFieldList}, 0 as deal from ${tableName} update ${tableTempName} INNER JOIN maintain_detail on ${tableTempName}.id = maintain_detail.pre_merge_id set ${updateSegment} WHERE maintain_detail.parent_id = ${maintainId} DELETE ${tableTempName} from ${tableTempName} INNER JOIN maintain_detail on maintain_detail.pre_merge_id = ${tableTempName}.id WHERE maintain_detail.parent_id = ${maintainId} and ${tableTempName}.std_id = ${stdId}