|
@@ -8,6 +8,7 @@ import (
|
8
|
8
|
"fmt"
|
9
|
9
|
"github.com/astaxie/beego"
|
10
|
10
|
"github.com/jung-kurt/gofpdf"
|
|
11
|
+ "github.com/mozillazg/go-pinyin"
|
11
|
12
|
"io/ioutil"
|
12
|
13
|
"time"
|
13
|
14
|
)
|
|
@@ -658,80 +659,81 @@ func (this *SignApiController) GetEnterPriseDetail() {
|
658
|
659
|
func (this *SignApiController) UploadPrintOrder() {
|
659
|
660
|
|
660
|
661
|
fmt.Println("WOOWOWOWOWOWOWOWOWOWOWWOOWOWWO")
|
661
|
|
- //list, _ := service.GetAllPatientNew(10188)
|
662
|
|
- //for _, item := range list {
|
663
|
|
- //
|
664
|
|
- // hans := item.Name // 要转换的汉字字符串
|
665
|
|
- // // 创建一个拼音转换器
|
666
|
|
- // p := pinyin.NewArgs()
|
667
|
|
- //
|
668
|
|
- // // 将汉字转为拼音
|
669
|
|
- // pinyinSlice := pinyin.Pinyin(hans, p)
|
670
|
|
- //
|
671
|
|
- // // 输出拼音
|
672
|
|
- // fmt.Println("Pinyin:", pinyinSlice)
|
|
662
|
+ list, _ := service.GetAllPatientNew(10579)
|
|
663
|
+ for _, item := range list {
|
|
664
|
+
|
|
665
|
+ hans := item.Name // 要转换的汉字字符串
|
|
666
|
+ // 创建一个拼音转换器
|
|
667
|
+
|
|
668
|
+ p := pinyin.NewArgs()
|
|
669
|
+
|
|
670
|
+ // 将汉字转为拼音
|
|
671
|
+ pinyinSlice := pinyin.Pinyin(hans, p)
|
|
672
|
+
|
|
673
|
+ // 输出拼音
|
|
674
|
+ fmt.Println("Pinyin:", pinyinSlice)
|
|
675
|
+
|
|
676
|
+ // 获取首字母
|
|
677
|
+ firstLetter := ""
|
|
678
|
+ for _, py := range pinyinSlice {
|
|
679
|
+ if len(py) > 0 {
|
|
680
|
+ firstLetter += string(py[0][0])
|
|
681
|
+ }
|
|
682
|
+ }
|
|
683
|
+
|
|
684
|
+ item.FirstLetter = firstLetter
|
|
685
|
+ service.UpdatePatientNew(item.ID, item.FirstLetter)
|
|
686
|
+ // 输出首字母
|
|
687
|
+ //fmt.Println("First Letter:", firstLetter)
|
|
688
|
+ }
|
|
689
|
+
|
|
690
|
+ //pdf := gofpdf.New("P", "mm", "A4", "")
|
|
691
|
+ //pdf.AddPage()
|
|
692
|
+ //pdf.Text(5, 10, "血液净化治疗记录单")
|
673
|
693
|
//
|
674
|
|
- // // 获取首字母
|
675
|
|
- // firstLetter := ""
|
676
|
|
- // for _, py := range pinyinSlice {
|
677
|
|
- // if len(py) > 0 {
|
678
|
|
- // firstLetter += string(py[0][0])
|
679
|
|
- // }
|
680
|
|
- // }
|
|
694
|
+ //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
|
695
|
+ //pdf.SetFont("simfang", "", 20)
|
|
696
|
+ //var title = "血液透析(滤过)记录表单"
|
|
697
|
+ ////表格居中显示
|
|
698
|
+ //pdf.Text(70, 10, title)
|
|
699
|
+ //wd := pdf.GetStringWidth(title) + 100
|
|
700
|
+ //fmt.Println("wd", wd)
|
|
701
|
+ //pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
|
|
702
|
+ //pdf.SetX((210 - wd) / 2) //水平居中的算法
|
|
703
|
+ //var numuber = "张三"
|
|
704
|
+ ////表格居中显示
|
|
705
|
+ //pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
|
706
|
+ //pdf.Text(10, 20, "姓名:"+numuber)
|
|
707
|
+ //pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
|
708
|
+ //pdf.Text(35, 20, "性别:"+"男")
|
|
709
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
710
|
+ //pdf.Text(60, 20, "年龄:"+"18")
|
|
711
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
712
|
+ //pdf.Text(90, 20, "门诊:"+"住院")
|
|
713
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
714
|
+ //pdf.Text(120, 20, "病区:"+"A区")
|
|
715
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
716
|
+ //pdf.Text(150, 20, "床号:"+"1号")
|
|
717
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
718
|
+ //pdf.Text(180, 20, "透析号:")
|
|
719
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
720
|
+ //pdf.Text(210, 20, "住院号/门诊号:")
|
|
721
|
+ //pdf.SetFont("", "", 14) // 设置正常字体和字号
|
|
722
|
+ ////表格居中显示
|
|
723
|
+ //pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
|
724
|
+ //pdf.Text(10, 30, "入科方式:"+numuber)
|
|
725
|
+ //pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
|
726
|
+ //pdf.Text(60, 30, "诊断:")
|
681
|
727
|
//
|
682
|
|
- // item.FirstLetter = firstLetter
|
683
|
|
- // service.UpdatePatientNew(item.ID, item.FirstLetter)
|
684
|
|
- // // 输出首字母
|
685
|
|
- // //fmt.Println("First Letter:", firstLetter)
|
686
|
|
- //}
|
687
|
|
-
|
688
|
|
- pdf := gofpdf.New("P", "mm", "A4", "")
|
689
|
|
- pdf.AddPage()
|
690
|
|
- pdf.Text(5, 10, "血液净化治疗记录单")
|
691
|
|
-
|
692
|
|
- pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
693
|
|
- pdf.SetFont("simfang", "", 20)
|
694
|
|
- var title = "血液透析(滤过)记录表单"
|
695
|
|
- //表格居中显示
|
696
|
|
- pdf.Text(70, 10, title)
|
697
|
|
- wd := pdf.GetStringWidth(title) + 100
|
698
|
|
- fmt.Println("wd", wd)
|
699
|
|
- pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
|
700
|
|
- pdf.SetX((210 - wd) / 2) //水平居中的算法
|
701
|
|
- var numuber = "张三"
|
702
|
|
- //表格居中显示
|
703
|
|
- pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
704
|
|
- pdf.Text(10, 20, "姓名:"+numuber)
|
705
|
|
- pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
706
|
|
- pdf.Text(35, 20, "性别:"+"男")
|
707
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
708
|
|
- pdf.Text(60, 20, "年龄:"+"18")
|
709
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
710
|
|
- pdf.Text(90, 20, "门诊:"+"住院")
|
711
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
712
|
|
- pdf.Text(120, 20, "病区:"+"A区")
|
713
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
714
|
|
- pdf.Text(150, 20, "床号:"+"1号")
|
715
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
716
|
|
- pdf.Text(180, 20, "透析号:")
|
717
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
718
|
|
- pdf.Text(210, 20, "住院号/门诊号:")
|
719
|
|
- pdf.SetFont("", "", 14) // 设置正常字体和字号
|
720
|
|
- //表格居中显示
|
721
|
|
- pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
722
|
|
- pdf.Text(10, 30, "入科方式:"+numuber)
|
723
|
|
- pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
724
|
|
- pdf.Text(60, 30, "诊断:")
|
725
|
|
-
|
726
|
|
- pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
727
|
|
- pdf.SetFont("simfang", "", 16) // 设置字体、字号
|
728
|
|
- pdf.SetFillColor(200, 200, 200)
|
729
|
|
- //// 设置起始位置
|
730
|
|
- var x = 10.0
|
731
|
|
- var y = 40.0
|
732
|
|
- pdf.SetXY(x, y)
|
733
|
|
- // 设置填充颜色
|
734
|
|
- pdf.CellFormat(200, 15, "透析前情况", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
|
|
728
|
+ //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
|
729
|
+ //pdf.SetFont("simfang", "", 16) // 设置字体、字号
|
|
730
|
+ //pdf.SetFillColor(200, 200, 200)
|
|
731
|
+ ////// 设置起始位置
|
|
732
|
+ //var x = 10.0
|
|
733
|
+ //var y = 40.0
|
|
734
|
+ //pdf.SetXY(x, y)
|
|
735
|
+ //// 设置填充颜色
|
|
736
|
+ //pdf.CellFormat(200, 15, "透析前情况", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
|
735
|
737
|
|
736
|
738
|
//param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
|
737
|
739
|
//param2: 单元格的高,不能为0,单位根据new()里面设置的来
|
|
@@ -790,18 +792,18 @@ func (this *SignApiController) UploadPrintOrder() {
|
790
|
792
|
//
|
791
|
793
|
//pdf.Ln(2)
|
792
|
794
|
|
793
|
|
- if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
|
794
|
|
- panic(err.Error())
|
795
|
|
- }
|
|
795
|
+ //if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
|
|
796
|
+ // panic(err.Error())
|
|
797
|
+ //}
|
796
|
798
|
|
797
|
799
|
// 此处可以继续绘制表格的其他部分,例如内容行等。
|
798
|
800
|
// ...
|
799
|
801
|
|
800
|
802
|
// 保存PDF文档到文件
|
801
|
|
- err := pdf.OutputFileAndClose("treatment_sheet_with_header.pdf")
|
802
|
|
- if err != nil {
|
803
|
|
- panic(err)
|
804
|
|
- }
|
|
803
|
+ //err := pdf.OutputFileAndClose("treatment_sheet_with_header.pdf")
|
|
804
|
+ //if err != nil {
|
|
805
|
+ // panic(err)
|
|
806
|
+ //}
|
805
|
807
|
|
806
|
808
|
this.ServeSuccessJSON(map[string]interface{}{
|
807
|
809
|
//"sign": information,
|