電子規範管理系統standardms在linux系統中部署遇到的坑
阿新 • • 發佈:2018-11-15
區域網內用一臺閒置的電腦,安裝了linux,部署了engineercms,docker和onlyoffice進行專案管理、文件協作,還缺少一利器:電子規範管理。於是請一哥們幫忙編譯了我的standardms電子規範管理系統。
第一次編譯,還是老問題,原始碼中,路徑是win下的“\\”,到linux系統下是不行的,必須全部改成“/”。
重新編譯,在linux系統下執行,新上傳的pdf檔案可以下載閱覽,以前的pdf檔案,死活下載不了。
找了很久,懷疑是檔案的讀寫許可權,資料夾的讀寫許可權,都不是。
終於發現,原來,用securefx上傳檔案到linux系統下,中文檔名全被修改了,可是在securefx裡卻看不出來什麼異樣。用securecrt在命令列下,列表檔案,就發現上傳的中文檔名都亂碼了。用flashfxp上傳就沒問題,standardms可以訪問。
上網查securefx亂碼解決方案,原來是將ini檔案的00000最後一個0改為1就行了。
果然,解決了大問題。
電子規範管理系統其實有不少商用的,也有不少網站提供下載,官方的也逐漸放開了電子版的下載了。不過暫時還是猶抱琵琶半遮面,都不是很齊全,自己收集的一些電子規範,在單位裡用用,平時解燃眉之急,開審查會,也可以隨時通過VPN進入區域網內進行檢索,甚是方便。
這個系統開發一個自動更新規範編號有效版本的資料庫,根據網路上最新發布的規範編號進行更新,僅僅是更新編號資料庫,如果發現檢索到的電子規範,其名稱與規範資料庫中的版本號不一致,提醒這個規範已經過期,需要謹慎對待。但舊規範沒必要刪除,可以作為對照使用。
爬蟲
package main import ( "fmt" "log" "net/http" "strconv" "code.google.com/p/mahonia" "github.com/PuerkitoBio/goquery" "github.com/mozillazg/request" "github.com/tealeg/xlsx" ) type Cata1 struct { Id string Number string Title string Category string Leixing string Banbudata string Shishidata string Licinumber string Feizhidata string Tidainumber string Biaozhunfile string } func mainrequest1() { c := new(http.Client) req := request.NewRequest(c) req.Cookies = map[string]string{ "JSESSIONID": "EF9156C40832CF0ADC83F7A509C90350", "stylePath": "", } slice1 := make([]Cata1, 0) for i := 0; i < 5; i++ {//分頁 //職業健康法律 resp, _ := req.Get("http://xxx/ProjManager/flfgv08070300009.jsp?flf81024flfgl01=%D6%B0%D2%B5%BD%A1%BF%B5%B0%B2%C8%AB%B7%A8%C2%C9%B7%A8%B9%E6&08070300004_page=" + strconv.Itoa(i)) //環境法律 // resp, _ := req.Get("http://xxx/ProjManager/flfgv08070300009.jsp?flf81024flfgl01=%BB%B7%BE%B3%B7%A8%C2%C9%B7%A8%B9%E6&08070300004_page=" + strconv.Itoa(i)) //規範 // resp, _ := req.Get("http://xxx/ProjManager/flfgv08070300009.jsp?flf81024flfgl01=%BC%BC%CA%F5%B1%EA%D7%BC&08070300004_page=" + strconv.Itoa(i)) // j, _ := resp.Text() // fmt.Println(j) defer resp.Body.Close() // Don't forget close the response body dec := mahonia.NewDecoder("GB2312") //定義轉換亂碼 // fmt.Println(dec.ConvertString(j)) //轉成utf-8 rd := dec.NewReader(resp.Body) doc, err := goquery.NewDocumentFromReader(rd) if err != nil { log.Fatal(err) } // var Cata []*Cata1 // Find the review items doc.Find("tr.trclass").Each(func(i int, s *goquery.Selection) { // For each item found, get the band and title // band := s.Find("td").Text() // fmt.Print(band) aa := make([]Cata1, 1) s.Find("td.tdclass").Each(func(i1 int, s1 *goquery.Selection) { //band := s1.Text() if i1 == 0 && s1.Text() != "" { aa[0].Number = s1.Text() // fmt.Printf("%d:1 %s\n", i1, s1.Text()) } if i1 == 1 && s1.Text() != "" { aa[0].Title = s1.Text() // fmt.Printf("%d:2 %s\n", i1, s1.Text()) } if i1 == 2 && s1.Text() != "" { aa[0].Category = s1.Text() // fmt.Printf("%d:3 %s\n", i1, s1.Text()) } if i1 == 3 && s1.Text() != "" { aa[0].Leixing = s1.Text() // fmt.Printf("%d:4 %s\n", i1, s1.Text()) } if i1 == 4 && s1.Text() != "" { aa[0].Banbudata = s1.Text() // fmt.Printf("%d:5 %s\n", i1, s1.Text()) } if i1 == 5 && s1.Text() != "" { aa[0].Shishidata = s1.Text() // fmt.Printf("%d:6 %s\n", i1, s1.Text()) } if i1 == 6 && s1.Text() != "" { aa[0].Licinumber = s1.Text() // fmt.Printf("%d:7 %s\n", i1, s1.Text()) } if i1 == 7 && s1.Text() != "" { aa[0].Feizhidata = s1.Text() // fmt.Printf("%d:8 %s\n", i1, s1.Text()) } if i1 == 8 && s1.Text() != "" { aa[0].Tidainumber = s1.Text() // fmt.Printf("%d:9 %s\n", i1, s1.Text()) } if i1 == 9 && s1.Text() != "" { aa[0].Biaozhunfile = s1.Text() // fmt.Printf("%d:10 %s\n", i1, s1.Text()) } //fmt.Printf("%d: 序號、編號、名稱、分類……%s\n", i1, band) //, title }) slice1 = append(slice1, aa...) }) } // fmt.Printf("slice1", slice1) //寫入excel var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell file = xlsx.NewFile() sheet, _ = file.AddSheet("Sheet1") row = sheet.AddRow() //增加行 cell = row.AddCell() //增加列 cell.Value = "#" cell = row.AddCell() //增加列 cell.Value = "標準編號" cell = row.AddCell() //增加列 cell.Value = "標準名稱" cell = row.AddCell() //增加列 cell.Value = "標準類別" cell = row.AddCell() //增加列 cell.Value = "法律法規型別" cell = row.AddCell() //增加列 cell.Value = "頒佈日期" cell = row.AddCell() //增加列 cell.Value = "實施日期" cell = row.AddCell() //增加列 cell.Value = "歷次被替代標準編號" cell = row.AddCell() //增加列 cell.Value = "廢止日期" cell = row.AddCell() //增加列 cell.Value = "替代標準編號" cell = row.AddCell() //增加列 cell.Value = "標準檔案" for w, z := range slice1 { //行 row = sheet.AddRow() //增加行 cell = row.AddCell() //增加列 cell.Value = strconv.Itoa(w + 1) cell = row.AddCell() //增加列 cell.Value = z.Number cell = row.AddCell() //增加列 cell.Value = z.Title cell = row.AddCell() //增加列 cell.Value = z.Category cell = row.AddCell() //增加列 cell.Value = z.Leixing cell = row.AddCell() //增加列 cell.Value = z.Banbudata cell = row.AddCell() //增加列 cell.Value = z.Shishidata cell = row.AddCell() //增加列 cell.Value = z.Licinumber cell = row.AddCell() //增加列 cell.Value = z.Feizhidata cell = row.AddCell() //增加列 cell.Value = z.Tidainumber cell = row.AddCell() //增加列 cell.Value = z.Biaozhunfile } err := file.Save("MyXLSXFile.xlsx") if err != nil { fmt.Printf(err.Error()) } }