您的位置:首页 > 其它

DOC文件中法规对标系统完成

2016-08-06 14:23 204 查看
我们工程设计报告中,每个章节很多法律法规规程规范,如何快捷地核对这些文件的有效性,即法律的发布日期,执行日期,规范的编号和执行日期等。用这个系统就简单了。

考进去,输出的就是你想要的有效的编号了。

package controllers

import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/tealeg/xlsx"
"quick/models"
"regexp"
"strconv"
"strings"
"time"
)

type LegislationController struct {
beego.Controller
}

type Legislationmore struct {
Id            int64
Number        string //`orm:"unique"`
Title         string //原法规名称
LibraryNumber string //规范有效版本库中的编号
LibraryTitle  string
Execute       string //执行时间
}

func (c *LegislationController) Index() { //
c.Data["IsLegislation"] = true //
c.TplName = "legislation.tpl"
c.Data["IsLogin"] = checkAccount(c.Ctx)
uname, _, _ := checkRoleread(c.Ctx) //login里的
// rolename, _ = strconv.Atoi(role)
c.Data["Uname"] = uname
legislations, err := models.GetAllLegislations() //这里传入空字符串
if err != nil {
beego.Error(err.Error)
} else {
c.Data["Legislations"] = legislations
c.Data["Length"] = len(legislations) //得到总记录数
}

logs := logs.NewLogger(1000)
logs.SetLogger("file", `{"filename":"log/test.log"}`)
logs.EnableFuncCallDepth(true)
logs.Info(c.Ctx.Input.IP())
logs.Close()
}

//搜索规范或者图集的名称或编号
func (c *LegislationController) Checklist() { //checklist用的是post方法
name := c.Input().Get("name")
beego.Info(name)
array := strings.Split(name, "\n")
aa := make([]Legislationmore, len(array))
for i, v := range array {
// beego.Info(v)
//1、正则取到名称
reg := regexp.MustCompile(`[《].*[》]`) //(`^\\<.*\\>`)
text2 := reg.FindAllString(v, -1)
text3 := SubString(text2[0], 1, len([]rune(text2[0]))-2)
//2、根据名称搜索标准版本库,取得名称和版本号
library, err := models.SearchLiabraryName(text3)
if err != nil {
beego.Error(err.Error)
}
text4 := strconv.Itoa(i + 1)
Id1, _ := strconv.ParseInt(text4, 10, 64)
aa[i].Id = Id1

if library != nil {
//3、构造struct
aa[i].LibraryNumber = library.LiNumber //规范有效版本库中的完整编号
aa[i].LibraryTitle = library.Title
aa[i].Execute = library.Execute //执行日期
} else {
// aa[i].Number = library.Number //`orm:"unique"`
// aa[i].Title = text3
aa[i].LibraryNumber = "No LibraryNumber Match Find!"
aa[i].LibraryTitle = text3
aa[i].Execute = ""
}
}
c.Data["IsLegislation"] = true
c.TplName = "legislation.tpl"
c.Data["IsLogin"] = checkAccount(c.Ctx)
uname, _, _ := checkRoleread(c.Ctx) //login里的
c.Data["Uname"] = uname

c.Data["json"] = aa //这里必须要是c.Data["json"],其他c.Data["Data"]不行
c.ServeJSON()

logs := logs.NewLogger(1000)
logs.SetLogger("file", `{"filename":"log/test.log"}`)
logs.EnableFuncCallDepth(true)
logs.Info(c.Ctx.Input.IP() + " " + "SearchLegislationsName:" + name)
logs.Close()
}


//由法规名称精确搜索有效版本库
func SearchLiabraryName(Name string) (*Library, error) {
o := orm.NewOrm()
library := new(Library)
qs := o.QueryTable("library")
err := qs.Filter("title", Name).One(library)
if err != nil {
return nil, err
}
return library, err
}


没想到大半天完成了这个系统。beego开发效率还是有点高啊。





 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐