|
@@ -8,7 +8,6 @@ import (
|
8
|
8
|
"fmt"
|
9
|
9
|
"github.com/astaxie/beego"
|
10
|
10
|
"github.com/jung-kurt/gofpdf"
|
11
|
|
- "github.com/mozillazg/go-pinyin"
|
12
|
11
|
"io/ioutil"
|
13
|
12
|
"time"
|
14
|
13
|
)
|
|
@@ -658,68 +657,38 @@ func (this *SignApiController) GetEnterPriseDetail() {
|
658
|
657
|
|
659
|
658
|
func (this *SignApiController) UploadPrintOrder() {
|
660
|
659
|
|
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)
|
673
|
|
-
|
674
|
|
- // 获取首字母
|
675
|
|
- firstLetter := ""
|
676
|
|
- for _, py := range pinyinSlice {
|
677
|
|
- if len(py) > 0 {
|
678
|
|
- firstLetter += string(py[0][0])
|
679
|
|
- }
|
680
|
|
- }
|
681
|
|
-
|
682
|
|
- item.FirstLetter = firstLetter
|
683
|
|
- service.UpdatePatientNew(item.ID, item.FirstLetter)
|
684
|
|
- // 输出首字母
|
685
|
|
- //fmt.Println("First Letter:", firstLetter)
|
686
|
|
- }
|
687
|
|
-
|
688
|
|
- //pdfg, _ := wkhtml.NewPDFGenerator()
|
|
660
|
+ fmt.Println("WOOWOWOWOWOWOWOWOWOWOWWOOWOWWO")
|
|
661
|
+ //list, _ := service.GetAllPatientNew(10188)
|
|
662
|
+ //for _, item := range list {
|
|
663
|
+ //
|
|
664
|
+ // hans := item.Name // 要转换的汉字字符串
|
|
665
|
+ // // 创建一个拼音转换器
|
|
666
|
+ // p := pinyin.NewArgs()
|
689
|
667
|
//
|
690
|
|
- //htmlStr := `<html><body><h1 style="color:red;">This is an html
|
691
|
|
- // from pdf to test color<h1><img src="http://api.qrserver.com/v1/create-qr-
|
692
|
|
- //code/?data=HelloWorld" ></img></body></html>`
|
|
668
|
+ // // 将汉字转为拼音
|
|
669
|
+ // pinyinSlice := pinyin.Pinyin(hans, p)
|
693
|
670
|
//
|
694
|
|
- //pdfg.AddPage(wkhtml.NewPageReader(strings.NewReader(htmlStr)))
|
|
671
|
+ // // 输出拼音
|
|
672
|
+ // fmt.Println("Pinyin:", pinyinSlice)
|
695
|
673
|
//
|
696
|
|
- //// Create PDF document in internal buffer
|
697
|
|
- //err = pdfg.Create()
|
|
674
|
+ // // 获取首字母
|
|
675
|
+ // firstLetter := ""
|
|
676
|
+ // for _, py := range pinyinSlice {
|
|
677
|
+ // if len(py) > 0 {
|
|
678
|
+ // firstLetter += string(py[0][0])
|
|
679
|
+ // }
|
|
680
|
+ // }
|
698
|
681
|
//
|
699
|
|
- ////Your Pdf Name
|
700
|
|
- //err = pdfg.WriteFile("./Your_pdfname.pdf")
|
701
|
|
-
|
702
|
|
- //dataBody := make(map[string]interface{}, 0)
|
703
|
|
- //err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
704
|
|
- //fmt.Println(err)
|
705
|
|
- //name := dataBody["name"].(string)
|
706
|
|
- //fmt.Println(name)
|
707
|
|
- //sign := service.CreateNewUploadPact(name)
|
708
|
|
- //fmt.Println("sign")
|
709
|
|
- //information, pdfBase64 := service.SavePdfInformation(name)
|
|
682
|
+ // item.FirstLetter = firstLetter
|
|
683
|
+ // service.UpdatePatientNew(item.ID, item.FirstLetter)
|
|
684
|
+ // // 输出首字母
|
|
685
|
+ // //fmt.Println("First Letter:", firstLetter)
|
|
686
|
+ //}
|
710
|
687
|
|
711
|
688
|
pdf := gofpdf.New("P", "mm", "A4", "")
|
712
|
689
|
pdf.AddPage()
|
713
|
690
|
pdf.Text(5, 10, "血液净化治疗记录单")
|
714
|
|
- //wd := pdf.GetStringWidth(titleStr) + 6
|
715
|
|
- //fmt.Println("wd", wd)
|
716
|
|
- //pdf.SetY(0.6) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
|
717
|
|
- //pdf.SetX((210 - wd) / 2) //水平居中的算法
|
718
|
|
- //pdf.AddUTF8Font("simkai", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
719
|
|
- //pdf.SetFont("simkai", "", 20)
|
720
|
|
-
|
721
|
|
- //将字体加载进来
|
722
|
|
- //AddUTF8Font("给字体起个别名", "", "fontPath")
|
|
691
|
+
|
723
|
692
|
pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
724
|
693
|
pdf.SetFont("simfang", "", 20)
|
725
|
694
|
var title = "血液透析(滤过)记录表单"
|
|
@@ -729,31 +698,41 @@ func (this *SignApiController) UploadPrintOrder() {
|
729
|
698
|
fmt.Println("wd", wd)
|
730
|
699
|
pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
|
731
|
700
|
pdf.SetX((210 - wd) / 2) //水平居中的算法
|
732
|
|
- //pdf.SetLineWidth(0)
|
733
|
|
-
|
734
|
|
- //pdf.Line(10, 30, 585, 30)
|
735
|
|
- //pdf.Ln(1)
|
736
|
|
- //pdf.Write(10, "\n")
|
737
|
|
- var numuber = "100000"
|
|
701
|
+ var numuber = "张三"
|
738
|
702
|
//表格居中显示
|
739
|
703
|
pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
740
|
|
- pdf.Text(10, 20, "病历号:"+numuber)
|
|
704
|
+ pdf.Text(10, 20, "姓名:"+numuber)
|
741
|
705
|
pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
742
|
|
- pdf.Text(60, 20, "姓名:")
|
|
706
|
+ pdf.Text(35, 20, "性别:"+"男")
|
743
|
707
|
pdf.SetFont("", "", 14) // 设置正常字体和字号
|
744
|
|
- pdf.Text(90, 20, "性别:")
|
|
708
|
+ pdf.Text(60, 20, "年龄:"+"18")
|
745
|
709
|
pdf.SetFont("", "", 14) // 设置正常字体和字号
|
746
|
|
- pdf.Text(120, 20, "年龄:")
|
|
710
|
+ pdf.Text(90, 20, "门诊:"+"住院")
|
747
|
711
|
pdf.SetFont("", "", 14) // 设置正常字体和字号
|
748
|
|
- pdf.Text(150, 20, "透析次数:")
|
|
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, "住院号/门诊号:")
|
749
|
719
|
pdf.SetFont("", "", 14) // 设置正常字体和字号
|
750
|
|
-
|
751
|
720
|
//表格居中显示
|
752
|
721
|
pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
753
|
722
|
pdf.Text(10, 30, "入科方式:"+numuber)
|
754
|
723
|
pdf.SetFont("", "", 14) // 设置加粗字体和字号
|
755
|
724
|
pdf.Text(60, 30, "诊断:")
|
756
|
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()方法创建表格单元格
|
|
735
|
+
|
757
|
736
|
//param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
|
758
|
737
|
//param2: 单元格的高,不能为0,单位根据new()里面设置的来
|
759
|
738
|
//param3: 单元格内容
|
|
@@ -763,43 +742,65 @@ func (this *SignApiController) UploadPrintOrder() {
|
763
|
742
|
//param7: 是否填充单元格,需要调用SetFillColor()方法.默认false
|
764
|
743
|
//param8: 内部超链接,没用过
|
765
|
744
|
//param9: 超链接,没用过
|
766
|
|
- pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
767
|
|
- pdf.SetFont("simfang", "", 14) // 设置字体、字号
|
768
|
|
- pdf.SetFillColor(200, 200, 200) // 设置填充颜色
|
|
745
|
+ //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
|
|
746
|
+ //pdf.SetFont("simfang", "", 8) // 设置字体、字号
|
|
747
|
+ //pdf.SetFillColor(200, 200, 200) // 设置填充颜色
|
|
748
|
+ //
|
|
749
|
+ //// 设置起始位置
|
|
750
|
+ //var x = 10.0
|
|
751
|
+ //var y = 40.0
|
|
752
|
+ ////创建8行2列的表格
|
|
753
|
+ //
|
|
754
|
+ //for j := 0; j < 1; j++ {
|
|
755
|
+ // // 填充每个单元格的内容
|
|
756
|
+ // pdf.SetXY(x, y) // 设置当前位置
|
|
757
|
+ // pdf.CellFormat(20, 15, "时间", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
|
|
758
|
+ // pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
|
|
759
|
+ // pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
|
|
760
|
+ // pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
|
|
761
|
+ // pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
|
|
762
|
+ // pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
|
|
763
|
+ // pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
|
|
764
|
+ // pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
|
|
765
|
+ // pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
|
|
766
|
+ // pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
|
|
767
|
+ // pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
|
|
768
|
+ //
|
|
769
|
+ // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
|
|
770
|
+ //}
|
|
771
|
+ //for j := 0; j < 1; j++ {
|
|
772
|
+ // // 填充每个单元格的内容
|
|
773
|
+ // pdf.SetXY(x, y) // 设置当前位置
|
|
774
|
+ // pdf.CellFormat(20, 15, "13:57", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
|
|
775
|
+ // pdf.CellFormat(20, 15, "120/90", "1", 0, "CM", false, 0, "")
|
|
776
|
+ // pdf.CellFormat(20, 15, "64", "1", 0, "CM", false, 0, "")
|
|
777
|
+ // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
|
|
778
|
+ // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
|
|
779
|
+ // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
|
|
780
|
+ // pdf.CellFormat(20, 15, "90", "1", 0, "CM", false, 0, "")
|
|
781
|
+ // pdf.CellFormat(20, 15, "36.5", "1", 0, "CM", false, 0, "")
|
|
782
|
+ // pdf.CellFormat(20, 15, "26", "1", 0, "CM", false, 0, "")
|
|
783
|
+ // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
|
|
784
|
+ // pdf.CellFormat(35, 15, "及时九嶷山", "1", 0, "CM", false, 0, "")
|
|
785
|
+ //
|
|
786
|
+ // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
|
|
787
|
+ //}
|
|
788
|
+ //x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
|
|
789
|
+ //y = 10.0 // 行起始位置的y坐标重置为10
|
|
790
|
+ //
|
|
791
|
+ //pdf.Ln(2)
|
769
|
792
|
|
770
|
|
- // 设置起始位置
|
771
|
|
- var x = 10.0
|
772
|
|
- var y = 40.0
|
773
|
|
- // 创建8行2列的表格
|
774
|
|
-
|
775
|
|
- for j := 0; j < 1; j++ {
|
776
|
|
- //cellText := fmt.Sprintf("行%d列%d", i+1, j+1) // 填充每个单元格的内容
|
777
|
|
- pdf.SetXY(x, y) // 设置当前位置
|
778
|
|
- pdf.CellFormat(15, 15, "时间", "1", 0, "C", false, 0, "") // 使用CellFormat()方法创建表格单元格
|
779
|
|
- pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
|
780
|
|
- pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
|
781
|
|
- pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
|
782
|
|
- pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
|
783
|
|
- pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
|
784
|
|
- pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
|
785
|
|
- pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
|
786
|
|
- pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
|
787
|
|
- pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
|
788
|
|
- pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
|
789
|
|
-
|
790
|
|
- y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
|
|
793
|
+ if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
|
|
794
|
+ panic(err.Error())
|
791
|
795
|
}
|
792
|
|
- x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
|
793
|
|
- y = 10.0 // 行起始位置的y坐标重置为10
|
794
|
|
-
|
795
|
|
- //设置表格单元格大小,
|
796
|
|
- //pdf.CellFormat(180, 15, "李王", "1", 0, "LM", false, 0, "")
|
797
|
796
|
|
798
|
|
- pdf.Ln(2)
|
799
|
|
- //pdf.Ln(2) 行距2mm
|
|
797
|
+ // 此处可以继续绘制表格的其他部分,例如内容行等。
|
|
798
|
+ // ...
|
800
|
799
|
|
801
|
|
- if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
|
802
|
|
- panic(err.Error())
|
|
800
|
+ // 保存PDF文档到文件
|
|
801
|
+ err := pdf.OutputFileAndClose("treatment_sheet_with_header.pdf")
|
|
802
|
+ if err != nil {
|
|
803
|
+ panic(err)
|
803
|
804
|
}
|
804
|
805
|
|
805
|
806
|
this.ServeSuccessJSON(map[string]interface{}{
|