2020-09-18-x
Xplorist Lv6

2020-09-18

todo-list

  • 修改ePDMWeb的端口为8080,修改231.103上的Nginx端口为80
  • 叫运维帮忙修改10.244.168.180上关于10.244.231.103上的项目代理

record-list

  • 测试使用nginx来将工管系统中的页面脱离出来

  • 同一个nginx中的静态资源配置和单页应用访问配置不能共存

  • 用nginx作网关,通过反向代理将耗材模块的前后端分离,并从工管系统中脱离出来

  • 以后的新模块都不用在老工管系统里面开发了,现在可以通过反向代理一个新项目来整合到工管系统中去

  • 耗材模块都放在阶段下面,分成四个模块,前端为Vue cli项目,然后四个路由,工管系统中添加四个路由地址就行了。

  • 分析NPI阶段打样表数据结构

  • 创建耗材需求(新)打样模块的数据表

  • IntelliJ IDEA的Generate POJOs.groovy生成JPA Entity

  • IDEA自定义Generate POJOs.groovy生成实体 - JPA+Lombok的模板

  • 使用 IntelliJ IDEA 快速生成项目代码

  • Generate POJOs4JPA.groovy

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187

    import com.intellij.database.model.DasTable
    import com.intellij.database.model.ObjectKind
    import com.intellij.database.util.Case
    import com.intellij.database.util.DasUtil

    import java.sql.Date
    import java.time.LocalDateTime
    import java.time.format.DateTimeFormatter


    /*
    * Available context bindings:
    * SELECTION Iterable<DasObject>
    * PROJECT project
    * FILES files helper
    */

    packageName = "com.sample;"

    typeMapping = [
    (~/(?i)int|tinyint|smallint|mediumint/) : "Integer",
    (~/(?i)bool|bit/) : "Boolean",
    (~/(?i)float|double|decimal|real|number/): "BigDecimal",
    (~/(?i)datetime|timestamp|date|time/) : "Date",
    (~/(?i)binary|bfile|raw|image/) : "InputStream",
    (~/(?i)blob|clob/) : "lob",
    (~/(?i)/) : "String"
    ]


    FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->
    SELECTION.filter { it instanceof DasTable && it.getKind() == ObjectKind.TABLE }.each { generate(it, dir) }
    }


    def generate(table, dir) {
    def className = javaName(table.getName(), true) + "Entity"
    def fields = calcFields(table)
    packageName = getPackageName(dir)
    // 解决乱码问题
    new File(dir, className + ".java").withPrintWriter("utf-8") { out -> generate(out, className, fields, table) }
    }


    // 获取包所在文件夹路径
    def getPackageName(dir) {
    return dir.toString().replaceAll("\\\\", ".").replaceAll("/", ".").replaceAll("^.*src(\\.main\\.java\\.)?", "") + ";"
    }

    def generate(out, className, fields, table) {
    out.println "package $packageName"
    out.println ""
    out.println "import javax.persistence.*;"
    out.println "import java.io.Serializable;"
    out.println "import lombok.*;"

    Set types = new HashSet()

    fields.each() {
    types.add(it.type)
    }

    if (types.contains("BigDecimal")) {
    out.println "import java.math.BigDecimal;"
    }

    if (types.contains("Date")) {
    out.println "import java.util.Date;"
    out.println "import org.hibernate.annotations.GenericGenerator;"
    out.println "import org.hibernate.annotations.UpdateTimestamp;"
    out.println "import org.hibernate.annotations.CreationTimestamp;"
    out.println "import com.fasterxml.jackson.annotation.JsonFormat;"
    }

    if (types.contains("InputStream")) {
    out.println "import java.io.InputStream;"
    }
    out.println ""
    out.println "/**\n" +
    " * @Author: C3005579 xbr\n" +
    " * @Date: " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm")) +"\n"+
    " */"
    out.println "@Data"
    out.println "@Entity"
    out.println "@Table (name = \"" + table.getName() + "\")"
    out.println "@Builder"
    out.println "@NoArgsConstructor"
    out.println "@AllArgsConstructor"
    out.println "public class $className implements Serializable {"
    out.println ""
    out.println genSerialID()
    fields.each() {
    out.println ""
    // 输出注释
    if (isNotEmpty(it.commoent)) {
    out.println "\t/**${it.commoent.toString()}*/"
    }
    // 输出Java Annotation(注解)
    if (it.annos != "") out.println " ${it.annos}"
    // 输出成员变量
    out.println "\tprivate ${it.type} ${it.name};"
    }
    out.println ""
    out.println "}"
    }

    def calcFields(table) {
    DasUtil.getColumns(table).reduce([]) { fields, col ->
    def spec = Case.LOWER.apply(col.getDataType().getSpecification())

    def typeStr = typeMapping.find { p, t -> p.matcher(spec).find() }.value
    def comm = [
    colName : col.getName(),
    name : javaName(col.getName(), false),
    type : typeStr,
    commoent: col.getComment(),
    annos : "\t@Column(name = \"" + col.getName() + "\" )"]
    if ("id".equals(Case.LOWER.apply(col.getName()))){
    comm.annos = "\t@Id\n"
    //自增主键需要
    comm.annos += "\t@GenericGenerator(name = \"idGen\", strategy = \"uuid\")\n"
    comm.annos += "\t@GeneratedValue(generator = \"idGen\")\n"
    comm.annos += "\t@Column(name = \"id\")"
    }
    if ("create_time".equals(Case.LOWER.apply(col.getName()))){
    comm.annos += "\n\t@CreationTimestamp"
    comm.annos += "\n\t@Temporal(TemporalType.TIMESTAMP)"
    comm.annos += "\n\t@JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\",timezone=\"GMT+8\")"
    }
    if ("update_time".equals(Case.LOWER.apply(col.getName()))){
    comm.annos += "\n\t@UpdateTimestamp"
    comm.annos += "\n\t@Temporal(TemporalType.TIMESTAMP)"
    comm.annos += "\n\t@JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\",timezone=\"GMT+8\")"
    }
    if ("delete_time".equals(Case.LOWER.apply(col.getName()))){
    comm.annos += "\n\t@JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\",timezone=\"GMT+8\")"
    }
    if("lob".equals(typeStr)) {
    comm.type = "String";
    comm.annos = "\t@Lob\n"
    comm.annos += "\t@Basic(fetch = FetchType.EAGER)\n"
    comm.annos += "\t@Column(name = \"" + col.getName() + "\", columnDefinition = \"CLOB\")"
    }
    fields += [comm]
    }
    }

    def javaName(str, capitalize) {
    def s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str)
    .collect { Case.LOWER.apply(it).capitalize() }
    .join("")
    .replaceAll(/[^\p{javaJavaIdentifierPart}[_]]/, "_")
    // 这里是因为我的表都是以T_命名的,所以需要处理去掉生成类名时的开头的T,如果不用处理注释掉下面这句代码
    //s = s[1..s.size() - 1]
    capitalize || s.length() == 1? s : Case.LOWER.apply(s[0]) + s[1..-1]
    }

    def fileName(str, capitalize) {
    def s = com.intellij.psi.codeStyle.NameUtil.splitNameIntoWords(str)
    .collect { Case.LOWER.apply(it).capitalize() }
    .join("")
    .replaceAll(/[^\p{javaJavaIdentifierPart}[_]]/, "_")
    capitalize || s.length() == 1? s : Case.LOWER.apply(s[0]) + s[1..-1]
    }

    def isNotEmpty(content) {
    return content != null && content.toString().trim().length() > 0
    }

    static String changeStyle(String str, boolean toCamel) {
    if (!str || str.size() <= 1)
    return str

    if (toCamel) {
    String r = str.toLowerCase().split('_').collect { cc -> Case.LOWER.apply(cc).capitalize() }.join('')
    return r[0].toLowerCase() + r[1..-1]
    } else {
    str = str[0].toLowerCase() + str[1..-1]
    return str.collect { cc -> ((char) cc).isUpperCase() ? '_' + cc.toLowerCase() : cc }.join('')
    }
    }

    static String genSerialID() {
    return "\tprivate static final long serialVersionUID = " + Math.abs(new Random().nextLong()) + "L;";
    }

home-redcord-list

  • 为routine_record repository建立hexo 显示,这个要实现貌似比较复杂,有必要吗?貌似不是很需要,只要把routine_record中的内容移植到knowledge-library-blog下就行了。
    况且,routine_record创建的目的就是为了处理knowledge-library-blog不完善的情况。统一一下也是好的吧。
 评论
// variables $gt-color-main := #6190e8 $gt-color-sub := #a1a1a1 $gt-color-loader := #999999 $gt-color-error := #ff3860 $gt-color-hr := #e9e9e9 $gt-color-comment-txt := #333333 $gt-color-link-active := #333333 $gt-color-btn := #ffffff $gt-size-base := 16px // default font-size $gt-size-border-radius := 5px $gt-breakpoint-mobile := 479px $gt-mask-z-index := 9999 // functions & mixins clearfix() { &:before &:after { display table clear both content "" } } em($px, $base-size = $gt-size-base) { u = unit($px) if (u is 'px') { unit($px / $base-size, 'em') } else { unit($px, u) } } mobile() { @media (max-width $gt-breakpoint-mobile) { {block} } } // variables - calculated $gt-size-loader-dot := em(6px) $gt-size-loader := em(28px) $gt-size-avatar := em(50px) $gt-size-avatar-mobi := em(32px) // styles // Put everything under container to avoid style conflicts .comments-container { .gt-container { box-sizing border-box * { box-sizing border-box } font-size $gt-size-base // common a { color $gt-color-main &:hover { color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } &.is--active { color $gt-color-link-active cursor default !important &:hover { color $gt-color-link-active } } } .hide { display none !important } // icons .gt-svg { display inline-block width em(16px) height em(16px) vertical-align sub svg { width 100% height 100% fill $gt-color-main } } .gt-ico { display inline-block &-text { margin-left em(5px) } &-github { width 100% height 100% .gt-svg { width 100% height 100% } svg { fill inherit } } } // loader .gt-spinner { position relative &::before { position absolute top 3px box-sizing border-box width em(12px) height em(12px) margin-top em(-3px) margin-left em(-6px) border 1px solid $gt-color-btn border-top-color $gt-color-main border-radius 50% animation gt-kf-rotate 0.6s linear infinite content '' } } .gt-loader { position relative display inline-block width $gt-size-loader height $gt-size-loader font-style normal // font-size: $gt-size-loader line-height $gt-size-loader border 1px solid $gt-color-loader border-radius 50% animation ease gt-kf-rotate 1.5s infinite &:before { position absolute top 0 left 50% display block width $gt-size-loader-dot height $gt-size-loader-dot margin-top -($gt-size-loader-dot / 2) margin-left -($gt-size-loader-dot / 2) background-color $gt-color-loader border-radius 50% content '' } } // avatar .gt-avatar { display inline-block width $gt-size-avatar height $gt-size-avatar +mobile() { width $gt-size-avatar-mobi height $gt-size-avatar-mobi } img { width 100% height auto border-radius 3px } &-github { width $gt-size-avatar - em(2px) height $gt-size-avatar - em(2px) cursor pointer +mobile() { width $gt-size-avatar-mobi - em(2px) height $gt-size-avatar-mobi - em(2px) } } } // button .gt-btn { display inline-block padding em(12px) em(20px) color $gt-color-btn font-size em(12px) line-height 1 white-space nowrap text-decoration none background-color $gt-color-main border 1px solid $gt-color-main border-radius $gt-size-border-radius outline none cursor pointer &-text { font-weight 400 } &-loading { position relative display inline-block width em(12px) height em(16px) margin-left em(8px) vertical-align top } &.is--disable { cursor not-allowed opacity 0.5 } &-login { margin-right 0 } &-preview { color $gt-color-main background-color var(--background-color) &:hover { background-color var(--second-background-color) } } &-public { &:hover { background-color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } } } } &-loadmore // loadmore /* error */ .gt-error { margin em(10px) color $gt-color-error text-align center } // initing .gt-initing { padding em(20px) 0 text-align center &-text { margin em(10px) auto font-size 92% } } // no int .gt-no-init { padding em(20px) 0 text-align center } // link .gt-link { border-bottom 1px dotted $gt-color-main &-counts &-project { text-decoration none } } // meta .gt-meta { position relative z-index 10 margin em(20px) 0 padding em(16px) 0 font-size em(16px) border-bottom 1px solid $gt-color-hr clearfix() } .gt-counts { margin 0 em(10px) 0 0 color var(--default-text-color) } .gt-user { float right margin 0 font-size 92% &-pic { width 16px height 16px margin-right em(8px) vertical-align top } &-inner { display inline-block cursor pointer .gt-user-name { color var(--default-text-color) } } .gt-ico { margin 0 0 0 em(5px) svg { fill var(--default-text-color) } } .is--poping { .gt-ico { svg { fill $gt-color-main } } } } .gt-version { margin-left em(6px) color $gt-color-sub } .gt-copyright { margin 0 em(15px) em(8px) padding-top em(8px) border-top 1px solid var(--border-color) } // popup .gt-popup { position absolute top em(38px) right 0 display inline-block padding em(10px) 0 font-size em(14px) letter-spacing 0.5px background var(--background-color) border 1px solid var(--border-color) .gt-action { position relative display block margin em(8px) 0 padding 0 em(18px) text-decoration none cursor pointer &.is--active { &:before { position absolute top em(7px) left em(8px) width em(4px) height em(4px) background $gt-color-main content '' } } } } // header .gt-header { position relative display flex &-comment { flex 1 margin-left em(20px) +mobile() { margin-left em(14px) } } &-textarea { display block box-sizing border-box width 100% min-height em(82px) max-height em(240px) padding em(12px) color var(--default-text-color) font-size em(14px) word-wrap break-word background-color var(--fourth-text-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius outline none transition all 0.25s ease resize vertical &:hover { background-color var(--background-color) } } &-preview { padding em(12px) background-color var(--background-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius } &-controls { position relative margin em(12px) 0 0 clearfix() +mobile() { margin 0 } &-tip { color $gt-color-main font-size em(14px) text-decoration none vertical-align sub +mobile() { display none } } .gt-btn { float right margin-left em(20px) +mobile() { float none width 100% margin em(12px) 0 0 } } } } &:after { position fixed top 0 right 0 bottom 100% left 0 opacity 0 content '' } &.gt-input-focused { position relative &:after { position fixed top 0 right 0 bottom 0 left 0 z-index $gt-mask-z-index background #000 opacity 0.6 transition opacity 0.3s, bottom 0s content '' } .gt-header-comment { z-index $gt-mask-z-index + 1 } } // comments .gt-comments { padding-top em(20px) &-null { text-align center } &-controls { margin em(20px) 0 text-align center } } // comment .gt-comment { position relative display flex padding em(10px) 0 &-content { flex 1 margin-left em(20px) padding em(12px) em(16px) overflow auto background-color var(--second-background-color) transition all ease 0.25s +mobile() { margin-left em(14px) padding em(10px) em(12px) } } &-header { position relative margin-bottom em(8px) font-size em(14px) } &-block-1 { float right width em(32px) height em(22px) } &-block-2 { float right width em(64px) height em(22px) } &-username { color $gt-color-main font-weight 500 text-decoration none &:hover { text-decoration underline } } &-text { margin-left em(8px) color $gt-color-sub } &-date { margin-left em(8px) color $gt-color-sub } &-like &-edit &-reply { position absolute height em(22px) &:hover { cursor pointer } } &-like { top 0 right em(32px) } &-edit &-reply { top 0 right 0 } &-body { // color: $gt-color-comment-txt !important color var(--second-text-color) !important .email-hidden-toggle a { display inline-block height 12px padding 0 9px color #444d56 font-weight 600 font-size 12px line-height 6px text-decoration none vertical-align middle background #dfe2e5 border-radius 1px &:hover { background-color #c6cbd1 } } .email-hidden-reply { display none white-space pre-wrap .email-signature-reply { margin 15px 0 padding 0 15px color #586069 border-left 4px solid #dfe2e5 } } .email-hidden-reply.expanded { display block } } &-admin { .gt-comment-content { background-color var(--fourth-text-color) } } } @keyframes gt-kf-rotate { 0% { transform rotate(0) } 100% { transform rotate(360deg) } } }