美文网首页
PowerDesigner编辑CDM文档

PowerDesigner编辑CDM文档

作者: 斜月86 | 来源:发表于2020-06-09 12:56 被阅读0次

    1 vb脚本导出cdm结构

    Option Explicit 
    ValidationMode = True
    InteractiveMode = im_Batch 
    Dim mdl ' the current model 
    Set mdl = ActiveModel
    Dim fso
    Dim file
    set fso =createobject("scripting.filesystemobject")
    ' 导出cdm结构存放地址
    set file = fso.CreateTextFile("d:/cdm_construct_data_new.txt",true)
    Dim cld
    ' 循环所有的包
    for each cld in mdl.Packages
       ProcessFolder cld, file
    next
    '最外层的信息
    ProcessFolder mdl, file
    file.close
    
    ' 定义函数导出cdm结构
    Private sub ProcessFolder(folder, file) 
    Dim  item   '要处理的对象
    for each item in folder.Entities 
       if not item.isShortcut then  
          Dim col ' 定义 column 
          for each col in item.Attributes 
              '写文件
              ' 实体名 \t 实体名称 \t 实体注释 \t 字段名\t 字段名称 \t字段注释 \t 字段类型 \t 是否必填 \t  是否主键 \t 默认值 \n
              file.write(UCase(item.code) +Chr(9) + UCase(item.name) + Chr(9) + UCase(item.comment) + Chr(9)+ UCase(col.code) + Chr(9) + UCase(col.name) + Chr(9)+ UCase(col.comment) + Chr(9)+ CStr(col.datatype) + Chr(9)+ CStr(col.mandatory) + Chr(9) + Cstr(col.primaryIdentifier) +  Chr(9) + Cstr(col.defaultValue)+ Chr(13))
          next 
       end if 
    next 
    ' last finish 
    end sub
    

    2 vb脚本修改实体名称注释

    Option Explicit 
    ValidationMode = True
    InteractiveMode = im_Batch 
    Dim mdl ' the current model 
    Set mdl = ActiveModel
    Dim cld
    for each cld in mdl.Packages
       ProcessFolder cld 
    next
    ProcessFolder mdl
    ' 修改函数
    Private sub ProcessFolder(folder) 
    
    Dim  item   '要处理的对象
    MsgBox folder
    '循环每个实体对象
    for each item in folder.Entities 
       '修改表名称注释
       if not item.isShortcut And UCase(item.code) = "CMPA_INFO_D" then
             item.code = "CMPA_INFO_B"
             item.name = "申投诉信息表"
             item.comment = "申投诉信息表"
        end if 
    
        if not item.isShortcut And UCase(item.code) = "DRUG_DCLA_EVT_C" then
             item.code = "DRUG_DCLA_EVT_C"
             item.name = "药品申报事件表"
             item.comment = "药品申报事件表"
        end if 
    next  
    end sub
    

    3 vb修改表字段注释类型长度必填

    Option Explicit 
    ValidationMode = True
    InteractiveMode = im_Batch 
    
    Dim mdl ' the current model 
    Set mdl = ActiveModel
    
    Dim cld
    for each cld in mdl.Packages
       ProcessFolder cld 
    next
    
    ProcessFolder mdl
    
    ' 修改函数
    Private sub ProcessFolder(folder) 
    
    Dim  item   '要处理的对象
    ' MsgBox folder
    
    for each item in folder.Entities  
        if not item.isShortcut then  
           Dim col
           for each col in item.Attributes 
    '删除CMPA_INFO_B表中PROCRSLT字段
    if UCase(item.code) = "CMPA_INFO_B" And col.code = "PROCRSLT" then 
         col.delete
    end if 
    '修改CMPA_INFO_B表中CMPA_TIME字段 datetime 类型如果是date则是 D
    if UCase(item.code) = "CMPA_INFO_B" And col.code = "CMPA_TIME" then 
     '修改注释名称类型是否必填   mandatory:true,false 非必填 primaryIdentifier  是否主键 true 是false 否
             col.comment = "申投诉时间"
             col.name = "申投诉时间"
             col.dataType = "DT"
             col.mandatory = TRUE
             col.primaryIdentifier = TRUE
    end if
    ' 修改PERF_SCO_INFO_B表中CRTER_NAME字段   varchar(50)             
    if UCase(item.code) = "PERF_SCO_INFO_B" And col.code = "CRTER_NAME" then 
                 '注释 类型 长度 是否必填     
                  col.comment = "创建人姓名"
                  col.dataType = "VA50"
                  col.length = 50
                  col.mandatory = FALSE
    end if 
    '修改PERF_SCO_INFO_B表中CRTE_OPTINS_NO字段  varchar(20)         
    if UCase(item.code) = "PERF_SCO_INFO_B" And col.code = "CRTE_OPTINS_NO" then 
                 col.comment = "创建机构编号"
                 col.dataType = "VA20"
                 col.length = 20
                 col.mandatory = TRUE
    end if
    '修改DIM_BIDPRCU_MCS_PROD_E表中PERF_COMP字段 类型text longtext 使用 LVA
    if UCase(item.code) = "DIM_BIDPRCU_PROD_E" And col.code = "PERF_COMP" then 
                  col.comment = "性能组成"
                  col.dataType = "TXT"
                  col.mandatory = FALSE
    end if 
    ' 修改FACT_SETL_E表中PURC_CNT字段 类型decimal(18,2)      length 长度 precision 精度       
    if UCase(item.code) = "FACT_SETL_E" And col.code = "PURC_CNT" then
                 col.comment = "采购数量"
                 col.dataType = "DC18,2"
                 col.length = 18
                 col.precision = 2
                 col.mandatory = FALSE
    end if 
    '修改FACT_SHORMED_E表中OUTSTO_CNT字段 类型int bigint用LI   
    if UCase(item.code) = "FACT_SHORMED_E" And col.code = "PURC_CNT" then
               col.comment = "缺货数量"
               col.dataType = "I"
               col.mandatory = FALSE
    end if                 
    '修改FACT_MCS_SETL_E表中DELV_CNT字段 类型decimal(18) 
    if UCase(item.code) = "FACT_MCS_SETL_E" And col.code = "DELV_CNT" then 
          col.comment = "配送数量"
          col.dataType = "DC18"
          col.length = 18
          col.mandatory = TRUE
    end if 
          next
        end if    
    next  
    end sub
    
    

    4 添加表

    Option Explicit 
    ValidationMode = True
    InteractiveMode = im_Batch 
    ' the current model 
    Dim mdl   
    Set mdl = ActiveModel
    
    Dim cld
    for each cld in mdl.Packages
       ProcessFolder cld 
    next
    
    ProcessFolder mdl
    
    '  修改函数
    Private sub ProcessFolder(folder) 
    
    Dim item, obj  '要处理的对象
    MsgBox folder
    ' 信息模块下添加表
       if folder.name = "信息" then
            Set obj = folder.Entities.CreateNew()
            obj.SetNameAndCode "评分信息表", "PERF_INFO_B"
            obj.comment = "评分信息表"
       end if 
    
    end sub
    
    

    5 添加表字段

    Option Explicit 
    ValidationMode = True
    InteractiveMode = im_Batch 
    
    Dim mdl ' the current model 
    Set mdl = ActiveModel
    
    Dim cld
    for each cld in mdl.Packages
       ProcessFolder cld 
    next
    
    ProcessFolder mdl
    
    ' 修改函数
    Private sub ProcessFolder(folder) 
    
    Dim item
    for each item in folder.Entities 
    
              Dim new_t
              if not item.isShortcut And UCase(item.code) = "PERF_SCO_INFO_B" then 
                  Set new_t = item.Attributes.CreateNew()
                  new_t.SetNameAndCode "履约评分ID", "PERF_SCO_ID" 
                  new_t.comment = "履约评分ID"
                  new_t.dataType = "VA40"
                  new_t.length = 40
                  new_t.mandatory = FALSE
              end if 
    next
    
    end sub
    

    相关文章

      网友评论

          本文标题:PowerDesigner编辑CDM文档

          本文链接:https://www.haomeiwen.com/subject/ziestktx.html