码迷,mamicode.com
首页 > 其他好文 > 详细

记录一下中间过程2

时间:2015-03-13 18:23:57      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

-- 资源表
select     t1.cmtsresourceid,         -- 资源ID GUID
                t1.createtime,                -- 创建时间                
                t1.fileext,                        -- 扩展名
                t1.filename,                    -- 文件名                
                t1.filesize,                    -- 文件大小,整数    
                t1.ismultifile,                -- 是不是复合文件 
                t1.title,                            -- 标题
                t1.categoryid,                -- 应用类型            
                t1.fileext,                        -- 扩展名                            
                t1.new_mediatype_id,    -- 媒体类型
                t1.new_mediatype_name,-- 媒体类型                                
                t1.new_stage_id,            -- 目标库的学段
                t1.new_subject_id,      -- 目的库的学科

                t1.versionid,                    -- 版本                
                t1.nodeid,                        -- 结点                                

                t1.new_user_id    ,            -- 用户ID                
                t1.new_user_name,            -- 用户姓名
                t1.new_path                    -- 新资源路径    
            
        from t_cmts_cmtsresource t1 where isdelete=0 limit 100;
-- ----------------------------------------------------------------
use zyk_ts;
-- ======================================================================================================
-- 媒体类型 
-- 修正一下实现完整对应
update t_stype_mediatype set mediatype_name=图片 where mediatype_id=002;
update t_stype_mediatype set mediatype_name=其他 where mediatype_id=007;
alter table t_cmts_cmtsresource add column new_mediatype_id varchar(36);
alter table t_cmts_cmtsresource add column new_mediatype_name varchar(36);
-- 删除270个没有检查到的
delete from t_cmts_cmtsresource where fileext not in (select extension_name from dsideal_db_tskp.t_resource_extension);
-- 添加新表中对应的媒体类型ID
update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_resource_extension t2  on t1.fileext=t2.extension_name set  t1.new_mediatype_id=t2.extension_id;
-- 添加新表中对应的媒体类型名称
update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_resource_extension t2  on t1.fileext=t2.extension_name set  t1.new_mediatype_name=t2.mediatype_name;
-- ======================================================================================================
-- 学段名称
alter table t_cmts_cmtsresource add column stage_name varchar(30);
update t_cmts_cmtsresource t1 inner join t_stype_stage t2   on t1.stageid=t2.stage_id set  t1.stage_name=t2.stage_name ;
-- 科目名称
alter table t_cmts_cmtsresource add column subject_name varchar(30);
update t_cmts_cmtsresource t1 inner join t_stype_subject t2 on t1.subjectid=t2.subject_id set t1.subject_name=t2.subject_name ;

-- 在新的表中的学段ID
alter table t_cmts_cmtsresource add column new_stage_id varchar(30);
-- 目标的学段ID
update t_cmts_cmtsresource t1 set t1.new_stage_id=4 where stageid=0001;
update t_cmts_cmtsresource t1 set t1.new_stage_id=5 where stageid=0002;
update t_cmts_cmtsresource t1 set t1.new_stage_id=6 where stageid=0003;

-- 在新的表中的科目ID
alter table t_cmts_cmtsresource add column new_subject_id varchar(30);
-- 目标的科目ID
update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_dm_subject t2 on t1.subject_name=t2.subject_name and t1.new_stage_id=t2.stage_id
set t1.new_subject_id=t2.subject_id;
-- ======================================================================================================
-- 新的版本ID
alter table t_cmts_cmtsresource add column new_scheme_id_char varchar(36);
alter table t_cmts_cmtsresource add column new_scheme_id_int int;

alter table t_cmts_cmtsresource add column new_structure_code  varchar(36);
alter table t_cmts_cmtsresource add column new_structure_id_char varchar(36);
alter table t_cmts_cmtsresource add column new_structure_id int;

-- 目标的版本ID
-- update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_resource_scheme t2 on t1.versionid=t2.old_version_id set t1.new_scheme_id=t2.scheme_id;
-- 新的版本名称
select  versionid from t_cmts_cmtsresource where versionid not in (select old_version_id from dsideal_db_tskp.t_resource_scheme);

select *,node_id,node_name,node_code from t_stype_node; 
select old_structure_id from dsideal_db_tskp.t_resource_structure where old_structure_id is not null;

select * from t_stype_node where node_id not in (select node_id from dsideal_db_tskp.t_resource_structure_new where node_id is not null)
-- ======================================================================================================
-- 新的完整的路径
alter table t_cmts_cmtsresource add column new_path varchar(128);
update t_cmts_cmtsresource set mediatypeid=002;
-- 旧资源
update t_cmts_cmtsresource t1  set t1.new_path=CONCAT(D:/dsideal_cmts/Tomcat_7.0.34/webapps/cmts/uploadfiles/resources,t1.filepath) where t1.resfrom is null;
-- 新资源
update t_cmts_cmtsresource t1 inner join t_cmts_disk t2 on t1.stageid=t2.stage_id and t1.subjectid=t2.subject_id and t1.mediatypeid=t2.mediatype_id
set t1.new_path=concat(t2.path_content,t1.filepath) where t1.resfrom is not null;
-- ======================================================================================================
-- 用户名称
alter table t_cmts_cmtsresource add column new_user_id varchar(128);
alter table t_cmts_cmtsresource add column new_user_name varchar(128);

update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_sys_loginperson t2   on t1.userid=t2.old_user_uuid set  t1.new_user_id=t2.person_id ;
update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_sys_loginperson t2   on t1.userid=t2.old_user_uuid set  t1.new_user_name=t2.person_name ;
-- ======================================================================================================

alter table t_cmts_cmtsresource add column new_thumb_status varchar(128);
alter table t_cmts_cmtsresource add column new_preview_status varchar(128);
alter table t_cmts_cmtsresource add column new_thumb_id varchar(128);
update t_cmts_cmtsresource t1 inner join dsideal_db_tskp.t_resource_extension t2   on t1.fileext=t2.extension_name set  
t1.new_thumb_status=t2.thumb_status , t1.new_preview_status=t2.preview_status , t1.new_thumb_id=t2.thumb_id ;
-- ======================================================================================================
-- 标识为来自开平
alter table dsideal_db_tskp.t_resource_base add column from_Kp int;
alter table dsideal_db_tskp.t_resource_info add column from_Kp int;
alter table dsideal_db_tskp.t_resource_my_info add column from_Kp int;
-- 记录原始路径
alter table dsideal_db_tskp.t_resource_base add column old_file_path varchar(128);
-- ======================================================================================================
-- 要求前端人员小蒙:将备课的类型修改为:
-- 002    教案     1
-- 003    学案     2   
-- 006    微课堂   3 
-- 007    视频课堂 4
-- 007    视频课堂 5
-- ======================================================================================================
-- 宽城的版权信息等需要修改。
-- ======================================================================================================
-- 最后记得要将t_resource_base  t_resource_info t_resource_my_info 的主键取消掉自动增长
-- 应用类型:     app_type_id:2 默认是素材
--                          res_type :2 
                        -- 媒体类型:resource_type_name,resource_type
                        -- meterial_type:和媒体类型一样
--                          bk_type,bk_type_name
                        -- release_status:1
                      -- parent_structure_name:-1
                      -- reource_size_int :-1
                      


-- 备课类型:    
-- 001    课件     1 
-- 002    教案     2
-- 003    学案     3   
-- 006    微课堂   4 
-- 007    视频课堂 5

insert into dsideal_db_tskp.t_resource_base 
(
            -- 1
            resource_id_char,resource_title,resource_size,resource_size_int,
            resource_type,resource_type_name,resource_category,resource_page,
            create_time,person_name,create_person,b_use,update_logo,ts,

            -- 4
            source_id,extension,file_id,file_md5,file_sha1,thumb_id,
            thumb_md5,thumb_sha1,pinyin,product_id,scheme_id_char,
            scheme_id,structure_code,structure_id_char,structure_id,

            -- 7
            material_type,is_single,is_old,preview_status,down_count,
            check_status,check_message,thumb_status,old_file_path,
            is_multifile,chuli,is_3_2,parent_name,width,height,

            -- 10
            for_urlencoder_url,for_iso_url,release_status,res_type,
            bk_type,bk_type_name,
            m3u8_status,m3u8_url,stage_id,subject_id ,from_Kp
)
select     
                -- 1
                t1.cmtsresourceid,t1.title,-1,-1,                            -- 资源ID GUID   标题  文件尺寸 文件尺寸大小
                t1.new_mediatype_id,t1.new_mediatype_name,-1,0,    -- 媒体类型 媒体类型    给平台使用-1,资源页数
                t1.createtime,    t1.new_user_name,        t1.new_user_id    ,    1,-1,2014051914330000833,        -- 用户ID         用户姓名                 创建时间                
                
                -- 4
              1,t1.fileext,‘‘,‘‘,‘‘,new_thumb_id,                -- 扩展名
                ‘‘,‘‘,‘‘,-1,new_scheme_id_char,
                t1.new_scheme_id_int,t1.new_structure_code,t1.new_structure_id_char,t1.new_structure_id,
                
                -- 7
                t1.new_mediatype_id,1,-1,t1.new_preview_status,0,
                1,‘‘,t1.new_thumb_status,t1.new_path,
                t1.ismultifile,-1,-1,‘‘,0,0,
                
                -- 10
                ‘‘,‘‘,1,2,
                (case categoryid when 001 then 1 when 002 then 2 when 003 then 3 when 006 then 4 when 007 then 5 end),
                (case categoryid when 001 then 课件 when 002 then 教案 when 003 then 学案 when 006 then 微课堂 when 007 then 视频课堂 end),
                -1,‘‘,t1.new_stage_id,    -- 目标库的学段
                t1.new_subject_id,1      -- 目的库的学科                        
                
        from t_cmts_cmtsresource t1 where isdelete=0 limit 10;
-- -==================================================================================================
insert into dsideal_db_tskp.t_resource_info
(
             resource_id_int,resource_id_char,resource_title,resource_type_name,
             resource_format,resource_page,resource_size,resource_size_int,create_time,
             down_count,file_id,thumb_id,resource_type,structure_id,person_id,person_name,identity_id,
             
             group_id,preview_status,scheme_id_int,ts,thumb_status,update_ts,for_urlencoder_url,for_iso_url,
             width,height,parent_structure_name,release_status,res_type,bk_type,bk_type_name,material_type,m3u8_status,
             m3u8_url,app_type_id,stage_id,subject_id,from_kp
)
select t1.resource_id_int,t1.resource_id_char,t1.resource_title,t1.resource_type_name,
             t1.extension,t1.resource_page,t1.resource_size,t1.resource_size_int,t1.create_time,
             t1.down_count,t1.file_id,t1.thumb_id,t1.resource_type,t1.structure_id,t1.create_person,t1.person_name,5,
             2,t1.preview_status,t1.scheme_id,t1.ts,t1.thumb_status,-1,t1.for_urlencoder_url,t1.for_iso_url,
             t1.width,t1.height,t1.parent_name,t1.release_status,t1.resource_type,t1.bk_type,t1.bk_type_name,t1.material_type,t1.m3u8_status,
            t1.m3u8_url,2,t1.stage_id,t1.subject_id,t1.from_kp
 from dsideal_db_tskp.t_resource_base t1 where from_kp=1; 
-- ======================================================================================================
insert into dsideal_db_tskp.t_resource_my_info
(
        resource_id_int,resource_id_char,resource_title,resource_type,resource_size_int,resource_format,
        person_id,identity_id,resource_page,ts,down_count,type_id,update_ts,structure_id,scheme_id_int,preview_status,
        thumb_status,for_urlencoder_url,for_iso_url,table_pk,resource_type_name,file_id,thumb_id,create_time,resource_size,
        group_id,width,height,parent_structure_name,down_type,res_type,bk_type,bk_type_name,m3u8_status,m3u8_url,
        app_type_id,b_delete,stage_id,subject_id
)
select t1.resource_id_int,t1.resource_id_char,t1.resource_title,t1.resource_type,t1.resource_size_int,t1.extension,
           t1.create_person,5,t1.resource_page,t1.ts,t1.down_count,6,-1,t1.structure_id,t1.scheme_id,t1.preview_status,
t1.thumb_status,t1.for_urlencoder_url,t1.for_iso_url,t1.resource_id_int,t1.resource_type_name,t1.file_id,t1.thumb_id,t1.create_time,t1.resource_size,
            2,t1.width,t1.height,t1.parent_name,1,2,t1.bk_type,t1.bk_type_name,t1.m3u8_status,t1.m3u8_url,
            2,0,t1.stage_id,t1.subject_id
 from dsideal_db_tskp.t_resource_base t1 where from_kp=1;
-- ======================================================================================================

 

记录一下中间过程2

标签:

原文地址:http://www.cnblogs.com/littlehb/p/4335557.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!