Browse Source

历史排班

28169 1 year ago
parent
commit
9a7ba413bd
4 changed files with 122 additions and 91 deletions
  1. 97 79
      controllers/sign_api_controller.go
  2. 9 8
      models/device_models.go
  3. 2 2
      service/schedule_service.go
  4. 14 2
      service/sign_service.go

+ 97 - 79
controllers/sign_api_controller.go View File

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

+ 9 - 8
models/device_models.go View File

1015
 }
1015
 }
1016
 
1016
 
1017
 type VmSchedule struct {
1017
 type VmSchedule struct {
1018
-	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1019
-	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1020
-	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1021
-	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1022
-	Partition    int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1023
-	Name         string `gorm:"column:name" json:"name" form:"name"`
1024
-	Number       string `gorm:"column:number" json:"number" form:"number"`
1025
-	ZoneName     string `gorm:"column:name" json:"zon_name" form:"name"`
1018
+	ScheduleDate        int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1019
+	ScheduleType        int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1020
+	ScheduleWeek        int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1021
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1022
+	Partition           int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1023
+	Name                string `gorm:"column:name" json:"name" form:"name"`
1024
+	Number              string `gorm:"column:number" json:"number" form:"number"`
1025
+	ZoneName            string `gorm:"column:name" json:"zon_name" form:"name"`
1026
+	DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
1026
 }
1027
 }
1027
 
1028
 
1028
 type XtDeviceOxygenates struct {
1029
 type XtDeviceOxygenates struct {

+ 2 - 2
service/schedule_service.go View File

1032
 }
1032
 }
1033
 
1033
 
1034
 func ExportScheduleTemplate(m *models.PatientScheduleTemplateItem) (total int64) {
1034
 func ExportScheduleTemplate(m *models.PatientScheduleTemplateItem) (total int64) {
1035
-	readDb.Model(&models.PatientScheduleTemplateItem{}).Where("template_id = ? AND patient_id = ? AND week_day = ? AND org_id = ?", m.TemplateID, m.PatientID, m.Weekday, m.OrgID).Count(&total)
1035
+	readDb.Model(&models.PatientScheduleTemplateItem{}).Where("template_id = ? AND patient_id = ? AND weekday = ? AND org_id = ? and status =1", m.TemplateID, m.PatientID, m.Weekday, m.OrgID).Count(&total)
1036
 	return
1036
 	return
1037
 }
1037
 }
1038
 
1038
 
1174
 	if partionid > 0 {
1174
 	if partionid > 0 {
1175
 		db = db.Where("x.partition_id = ?", partionid)
1175
 		db = db.Where("x.partition_id = ?", partionid)
1176
 	}
1176
 	}
1177
-	err = db.Select("x.schedule_date,x.schedule_type,x.schedule_week,x.bed_id,x.partition_id,t.name,n.number,z.name").Joins("left join xt_patients as t on t.id = x.patient_id and t.user_org_id = ? and t.status = 1", orgid).Joins("left join xt_device_zone as z on z.id = x.partition_id and z.org_id = ? and z.status =1", orgid).Joins("left join xt_device_number as n on n.id = x.bed_id and n.org_id = ? and n.status =1", orgid).Scan(&schedule).Error
1177
+	err = db.Select("x.schedule_date,x.schedule_type,x.schedule_week,x.bed_id,x.partition_id,t.name,n.number,z.name,x.dialysis_machine_name").Joins("left join xt_patients as t on t.id = x.patient_id and t.user_org_id = ? and t.status = 1", orgid).Joins("left join xt_device_zone as z on z.id = x.partition_id and z.org_id = ? and z.status =1", orgid).Joins("left join xt_device_number as n on n.id = x.bed_id and n.org_id = ? and n.status =1", orgid).Scan(&schedule).Error
1178
 
1178
 
1179
 	return schedule, err
1179
 	return schedule, err
1180
 }
1180
 }

+ 14 - 2
service/sign_service.go View File

2051
 	fmt.Println(err)
2051
 	fmt.Println(err)
2052
 }
2052
 }
2053
 
2053
 
2054
-func GetAllPatientNew(org_id int64) (new []*models.XtPatientsNew, err error) {
2054
+func GetAllPatientNew(org_id int64) (new []*models.XtPatients, err error) {
2055
 
2055
 
2056
 	err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error
2056
 	err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error
2057
 	return new, err
2057
 	return new, err
2059
 
2059
 
2060
 func UpdatePatientNew(id int64, firstleterr string) error {
2060
 func UpdatePatientNew(id int64, firstleterr string) error {
2061
 
2061
 
2062
-	err := XTWriteDB().Model(models.XtPatientsNew{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2062
+	err := XTWriteDB().Model(models.XtPatients{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2063
+	return err
2064
+}
2065
+
2066
+func GeteAllBaseList(user_org_id int64) (list []*models.BaseDrugLib, err error) {
2067
+
2068
+	err = XTWriteDB().Model(&list).Where("user_org_id = ? and status =1", user_org_id).Find(&list).Error
2069
+	return list, err
2070
+}
2071
+
2072
+func UpdateBaseList(id int64, firstleterr string) error {
2073
+
2074
+	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status =1", id, firstleterr).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2063
 	return err
2075
 	return err
2064
 }
2076
 }