浏览代码

历史排班

28169 1年前
父节点
当前提交
f9ae25b88b

+ 1 - 1
controllers/doctors_api_controller.go 查看文件

778
 	last_time := this.GetString("last_time")
778
 	last_time := this.GetString("last_time")
779
 	timeLayout := "2006-01-02"
779
 	timeLayout := "2006-01-02"
780
 	loc, _ := time.LoadLocation("Local")
780
 	loc, _ := time.LoadLocation("Local")
781
-	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+"23:59:59", loc)
781
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
782
 	lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
782
 	lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
783
 	patient_id, _ := this.GetInt64("patient_id")
783
 	patient_id, _ := this.GetInt64("patient_id")
784
 	adminUserInfo := this.GetAdminUserInfo()
784
 	adminUserInfo := this.GetAdminUserInfo()

文件差异内容过多而无法显示
+ 1537 - 865
controllers/his_api_controller.go


+ 2 - 1
controllers/self_drug_api_congtroller.go 查看文件

2392
 	page, _ := this.GetInt64("page")
2392
 	page, _ := this.GetInt64("page")
2393
 	storehouse_id, _ := this.GetInt64("storehouse_id")
2393
 	storehouse_id, _ := this.GetInt64("storehouse_id")
2394
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2394
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2395
+	appId := this.GetAdminUserInfo().CurrentAppId
2395
 	list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId, storehouse_id)
2396
 	list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId, storehouse_id)
2396
 	inventoryList, _, _ := service.GetDrugInventoryDetailListTwo(keyword, page, limit, orgId, storehouse_id)
2397
 	inventoryList, _, _ := service.GetDrugInventoryDetailListTwo(keyword, page, limit, orgId, storehouse_id)
2397
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2398
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2398
-	doctorList, _ := service.GetAllDoctorThree(orgId)
2399
+	doctorList, _ := service.GetAllDoctorListSix(orgId, appId)
2399
 	if err != nil {
2400
 	if err != nil {
2400
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2401
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2401
 		return
2402
 		return

+ 10 - 11
controllers/sign_api_controller.go 查看文件

7
 	"encoding/json"
7
 	"encoding/json"
8
 	"fmt"
8
 	"fmt"
9
 	"github.com/astaxie/beego"
9
 	"github.com/astaxie/beego"
10
-	"github.com/jung-kurt/gofpdf"
11
 	"io/ioutil"
10
 	"io/ioutil"
12
 	"time"
11
 	"time"
13
 )
12
 )
310
 
309
 
311
 func (this *SignApiController) GetTestThrityMent() {
310
 func (this *SignApiController) GetTestThrityMent() {
312
 
311
 
313
-	pdf := gofpdf.New("P", "mm", "A4", "")
314
-	pdf.AddPage()
315
-	pdf.SetFont("Arial", "B", 16)
316
-	pdf.Cell(40, 10, "Hello, World!")
317
-	pdf.OutputFileAndClose("output.pdf")
318
-
319
-	this.ServeSuccessJSON(map[string]interface{}{
320
-		"sign": "msg",
321
-	})
322
-	return
312
+	//pdf := gofpdf.New("P", "mm", "A4", "")
313
+	//pdf.AddPage()
314
+	//pdf.SetFont("Arial", "B", 16)
315
+	//pdf.Cell(40, 10, "Hello, World!")
316
+	//pdf.OutputFileAndClose("output.pdf")
317
+	//
318
+	//this.ServeSuccessJSON(map[string]interface{}{
319
+	//	"sign": "msg",
320
+	//})
321
+	//return
323
 }
322
 }
324
 
323
 
325
 func loremList() []string {
324
 func loremList() []string {

+ 4 - 0
main.go 查看文件

5
 	"XT_New/service"
5
 	"XT_New/service"
6
 	"encoding/xml"
6
 	"encoding/xml"
7
 	"github.com/astaxie/beego"
7
 	"github.com/astaxie/beego"
8
+	"net/http"
8
 )
9
 )
9
 
10
 
10
 func init() {
11
 func init() {
24
 	//beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 6000
25
 	//beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 6000
25
 	//beego.BConfig.WebConfig.AutoRender = false
26
 	//beego.BConfig.WebConfig.AutoRender = false
26
 	//
27
 	//
28
+	go func() {
29
+		http.ListenAndServe("localhost:6060", nil)
30
+	}()
27
 
31
 
28
 	beego.Run()
32
 	beego.Run()
29
 
33
 

+ 1 - 1
models/schedule_models.go 查看文件

388
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"assessment_befor_dislysis"`
388
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"assessment_befor_dislysis"`
389
 	XtDoctorAdvice             XtDoctorAdvice             `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_doctor_advice"`
389
 	XtDoctorAdvice             XtDoctorAdvice             `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_doctor_advice"`
390
 	XtDoctorAdviceOne          []*XtDoctorAdvice          `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"advice"`
390
 	XtDoctorAdviceOne          []*XtDoctorAdvice          `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"advice"`
391
-	HisDoctorAdvice            HisDoctorAdvice            `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_doctor_advice"`
391
+	HisDoctorAdvice            []*HisDoctorAdvice         `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_doctor_advice"`
392
 	ReceiveTreatmentAsses      ReceiveTreatmentAsses      `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_receive_treatment_asses"`
392
 	ReceiveTreatmentAsses      ReceiveTreatmentAsses      `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_receive_treatment_asses"`
393
 	XtAssessmentAfterDislysis  XtAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_assesment_after_dislysis"`
393
 	XtAssessmentAfterDislysis  XtAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_assesment_after_dislysis"`
394
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
394
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`

+ 2 - 2
service/dialysis_solution_service.go 查看文件

103
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
103
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
104
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
104
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
105
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
105
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
106
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
106
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Preload("HisDoctorAdvice", "status=1 and user_org_id =? and advice_date =?", orgID, scheduleDate).Find(&schedule).Error
107
 	} else {
107
 	} else {
108
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
108
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
109
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
109
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
110
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
110
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Preload("HisDoctorAdvice", "status=1 and user_org_id =? and advice_date =?", orgID, scheduleDate).Find(&schedule).Error
111
 	}
111
 	}
112
 
112
 
113
 	return schedule, total, err
113
 	return schedule, total, err

+ 50 - 7
service/his_service.go 查看文件

402
 	return err
402
 	return err
403
 }
403
 }
404
 
404
 
405
-func SaveHisPrescription(tx *gorm.DB, prescription *models.HisPrescription) (err error) {
405
+func SaveHisPrescriptionOne(tx *gorm.DB, prescription *models.HisPrescription) (err error) {
406
 
406
 
407
 	err = tx.Model(&models.HisPrescription{}).Save(prescription).Error
407
 	err = tx.Model(&models.HisPrescription{}).Save(prescription).Error
408
 	if err != nil {
408
 	if err != nil {
413
 	return
413
 	return
414
 }
414
 }
415
 
415
 
416
+func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
417
+	tx := writeDb.Begin()
418
+
419
+	if err = tx.Model(&models.HisPrescription{}).Save(prescription).Error; err != nil {
420
+		tx.Rollback()
421
+		return
422
+	}
423
+	tx.Commit()
424
+	return
425
+}
426
+
416
 func SaveHisPrescriptionTwo(prescription *models.HisPrescription) (err error) {
427
 func SaveHisPrescriptionTwo(prescription *models.HisPrescription) (err error) {
417
 
428
 
418
 	err = writeDb.Model(&models.HisPrescription{}).Save(prescription).Error
429
 	err = writeDb.Model(&models.HisPrescription{}).Save(prescription).Error
887
 	return
898
 	return
888
 }
899
 }
889
 
900
 
890
-func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
901
+func CreateHisDoctorAdviceOne(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
891
 
902
 
892
 	err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error
903
 	err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error
893
 
904
 
898
 	return
909
 	return
899
 }
910
 }
900
 
911
 
912
+func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
913
+
914
+	tx := writeDb.Begin()
915
+	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
916
+		tx.Rollback()
917
+		return
918
+	}
919
+	tx.Commit()
920
+
921
+	return
922
+}
923
+
901
 func CreateHisDoctorAdviceTwo(s *models.HisDoctorAdviceInfo) (err error) {
924
 func CreateHisDoctorAdviceTwo(s *models.HisDoctorAdviceInfo) (err error) {
902
 	tx := writeDb.Begin()
925
 	tx := writeDb.Begin()
903
 	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
926
 	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
909
 	return
932
 	return
910
 }
933
 }
911
 
934
 
912
-func CreateHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
935
+func CreateNewHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
913
 	err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error
936
 	err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error
914
 	if err != nil {
937
 	if err != nil {
915
 		tx.Rollback()
938
 		tx.Rollback()
917
 	}
940
 	}
918
 	return
941
 	return
919
 }
942
 }
943
+func CreateHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
944
+	tx := writeDb.Begin()
945
+	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
946
+		tx.Rollback()
947
+		return
948
+	}
949
+	tx.Commit()
920
 
950
 
921
-func GetLastHisProject(patient_id int64, user_org_id int64, record_date int64, tx *gorm.DB) (models.HisPrescriptionProject, error) {
951
+	return
952
+}
953
+
954
+func GetLastHisProject(patient_id int64, user_org_id int64, record_date int64, tx *gorm.DB, good_id int64) (models.HisPrescriptionProject, error) {
922
 
955
 
923
 	prescriptionProject := models.HisPrescriptionProject{}
956
 	prescriptionProject := models.HisPrescriptionProject{}
924
-	err := tx.Where("patient_id = ? and user_org_id = ? and record_date = ? and status=1", patient_id, user_org_id, record_date).Find(&prescriptionProject).Error
957
+	err := tx.Where("patient_id = ? and user_org_id = ? and record_date = ? and status=1 and project_id = ? and type =3", patient_id, user_org_id, record_date, good_id).Find(&prescriptionProject).Error
925
 	if err != gorm.ErrRecordNotFound {
958
 	if err != gorm.ErrRecordNotFound {
926
 		if err != nil {
959
 		if err != nil {
927
 			tx.Rollback()
960
 			tx.Rollback()
940
 	return
973
 	return
941
 }
974
 }
942
 
975
 
943
-func SaveHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
976
+func SaveNewHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
944
 	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
977
 	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
945
 	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error; err != nil {
978
 	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error; err != nil {
946
 		tx.Rollback()
979
 		tx.Rollback()
949
 	return
982
 	return
950
 }
983
 }
951
 
984
 
985
+func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
986
+	err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
987
+	return
988
+}
989
+
952
 func CreateHisPatientTwo(patient *models.VMHisPatient) error {
990
 func CreateHisPatientTwo(patient *models.VMHisPatient) error {
953
 	err := writeDb.Create(&patient).Error
991
 	err := writeDb.Create(&patient).Error
954
 	return err
992
 	return err
2639
 	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2677
 	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2640
 }
2678
 }
2641
 
2679
 
2642
-func CreateHisLabelRecord(label *models.HisLabelPrintInfo, tx *gorm.DB) (err error) {
2680
+func CreateNewHisLabelRecord(label *models.HisLabelPrintInfo, tx *gorm.DB) (err error) {
2643
 	if err = tx.Save(&label).Error; err != nil {
2681
 	if err = tx.Save(&label).Error; err != nil {
2644
 		tx.Rollback()
2682
 		tx.Rollback()
2645
 		return
2683
 		return
2647
 	return
2685
 	return
2648
 }
2686
 }
2649
 
2687
 
2688
+func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2689
+	err := writeDb.Save(&label).Error
2690
+	return err
2691
+}
2692
+
2650
 func CreateHisLabelRecordTwo(label *models.HisLabelPrintInfo) (err error) {
2693
 func CreateHisLabelRecordTwo(label *models.HisLabelPrintInfo) (err error) {
2651
 	err = writeDb.Save(&label).Error
2694
 	err = writeDb.Save(&label).Error
2652
 	return
2695
 	return

+ 2 - 2
service/manage_center_service.go 查看文件

1083
 	return err
1083
 	return err
1084
 }
1084
 }
1085
 
1085
 
1086
-func GetPatientGoodStockCount(patient_id int64, record_time int64, user_org_id int64) (auto []*models.XtAutomaticReduceDetail, err error) {
1086
+func GetPatientGoodStockCount(patient_id int64, record_time int64, user_org_id int64) (auto []*models.AutomaticReduceDetail, err error) {
1087
 
1087
 
1088
-	err = XTReadDB().Where("patient_id = ? and record_time =? and user_org_id = ? and status=1", patient_id, record_time, user_org_id).Find(&auto).Error
1088
+	err = XTReadDB().Where("patient_id = ? and record_time =? and org_id = ? and status=1", patient_id, record_time, user_org_id).Find(&auto).Error
1089
 	return auto, err
1089
 	return auto, err
1090
 }
1090
 }

+ 36 - 21
service/new_warehouse_service.go 查看文件

646
 
646
 
647
 	stockCount := models.XtDrugStockCount{}
647
 	stockCount := models.XtDrugStockCount{}
648
 	err := tx.Where("drug_id = ? and user_org_id = ? and storehouse_id=?", drug_id, org_id, storehouse_id).Find(&stockCount).Error
648
 	err := tx.Where("drug_id = ? and user_org_id = ? and storehouse_id=?", drug_id, org_id, storehouse_id).Find(&stockCount).Error
649
-	if err != nil {
650
-		tx.Rollback()
651
-		return stockCount, err
649
+	if err != gorm.ErrRecordNotFound {
650
+		if err != nil {
651
+			tx.Rollback()
652
+			return stockCount, err
653
+		}
652
 	}
654
 	}
655
+
653
 	return stockCount, err
656
 	return stockCount, err
654
 }
657
 }
655
 
658
 
2555
 	info := models.XtDrugWarehouseOutInfo{}
2558
 	info := models.XtDrugWarehouseOutInfo{}
2556
 	var err error
2559
 	var err error
2557
 	err = tx.Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1 and drug_id = ? and is_sys=1", patient_id, advice_date, orgid, drug_id).Find(&info).Error
2560
 	err = tx.Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1 and drug_id = ? and is_sys=1", patient_id, advice_date, orgid, drug_id).Find(&info).Error
2558
-
2559
-	if err != nil {
2560
-		tx.Rollback()
2561
-		return &info, nil
2561
+	if err != gorm.ErrRecordNotFound {
2562
+		if err != nil {
2563
+			tx.Rollback()
2564
+			return &info, nil
2565
+		}
2562
 	}
2566
 	}
2567
+
2563
 	return &info, nil
2568
 	return &info, nil
2564
 }
2569
 }
2565
 
2570
 
2579
 func UpdateNewSingleDrugWarehouseOutInfoSix(patient_id int64, advice_date int64, orgid int64, info *models.DrugWarehouseOutInfo, advice_id int64, tx *gorm.DB) error {
2584
 func UpdateNewSingleDrugWarehouseOutInfoSix(patient_id int64, advice_date int64, orgid int64, info *models.DrugWarehouseOutInfo, advice_id int64, tx *gorm.DB) error {
2580
 
2585
 
2581
 	err := tx.Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and advice_id = ? and status= 1", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
2586
 	err := tx.Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and advice_id = ? and status= 1", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
2582
-	if err != nil {
2583
-		tx.Rollback()
2584
-		return err
2587
+	if err != gorm.ErrRecordNotFound {
2588
+		if err != nil {
2589
+			tx.Rollback()
2590
+			return err
2591
+		}
2585
 	}
2592
 	}
2593
+
2586
 	return err
2594
 	return err
2587
 }
2595
 }
2588
 
2596
 
2611
 	detail := models.DrugAutomaticReduceDetail{}
2619
 	detail := models.DrugAutomaticReduceDetail{}
2612
 	var err error
2620
 	var err error
2613
 	err = tx.Where("patient_id = ? and record_time = ? and org_id = ?", patient_id, advice_date, orgid).Find(&detail).Error
2621
 	err = tx.Where("patient_id = ? and record_time = ? and org_id = ?", patient_id, advice_date, orgid).Find(&detail).Error
2614
-	if err == gorm.ErrRecordNotFound {
2615
-		return nil, err
2616
-	}
2617
-	if err != nil {
2618
-		return nil, err
2622
+
2623
+	if err != gorm.ErrRecordNotFound {
2624
+		if err != nil {
2625
+			tx.Rollback()
2626
+			return &detail, nil
2627
+		}
2619
 	}
2628
 	}
2620
 	return &detail, nil
2629
 	return &detail, nil
2621
 }
2630
 }
2690
 func FindNewDrugWarehouseOutInfoCount(drugid int64, patient_id int64, record_date int64, org_id int64, advice_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
2699
 func FindNewDrugWarehouseOutInfoCount(drugid int64, patient_id int64, record_date int64, org_id int64, advice_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
2691
 
2700
 
2692
 	err = tx.Where("drug_id = ? and patient_id = ? and system_time = ? and user_org_id = ? and consumable_type = 3 and status = 1 and advice_id = ?", drugid, patient_id, record_date, org_id, advice_id).Find(&flow).Error
2701
 	err = tx.Where("drug_id = ? and patient_id = ? and system_time = ? and user_org_id = ? and consumable_type = 3 and status = 1 and advice_id = ?", drugid, patient_id, record_date, org_id, advice_id).Find(&flow).Error
2693
-	if err != nil {
2694
-		tx.Rollback()
2695
-		return flow, err
2702
+	if err != gorm.ErrRecordNotFound {
2703
+		if err != nil {
2704
+			tx.Rollback()
2705
+			return flow, err
2706
+		}
2696
 	}
2707
 	}
2708
+
2697
 	return flow, err
2709
 	return flow, err
2698
 }
2710
 }
2699
 
2711
 
2711
 func FindNewDrugCancelOutInfo(drugid int64, patient_id int64, record_date int64, org_id int64, advice_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
2723
 func FindNewDrugCancelOutInfo(drugid int64, patient_id int64, record_date int64, org_id int64, advice_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
2712
 	err = tx.Where("drug_id = ? and patient_id = ? and system_time = ? and user_org_id = ? and consumable_type = 7 and status = 1 and advice_id = ?", drugid, patient_id, record_date, org_id, advice_id).Find(&flow).Error
2724
 	err = tx.Where("drug_id = ? and patient_id = ? and system_time = ? and user_org_id = ? and consumable_type = 7 and status = 1 and advice_id = ?", drugid, patient_id, record_date, org_id, advice_id).Find(&flow).Error
2713
 
2725
 
2714
-	if err != nil {
2715
-		tx.Rollback()
2716
-		return flow, err
2726
+	if err != gorm.ErrRecordNotFound {
2727
+		if err != nil {
2728
+			tx.Rollback()
2729
+			return flow, err
2730
+		}
2717
 	}
2731
 	}
2732
+
2718
 	return flow, err
2733
 	return flow, err
2719
 }
2734
 }
2720
 
2735
 

+ 1 - 1
service/schedule_service.go 查看文件

1880
 
1880
 
1881
 func GetPatientGoodCountToday(patient_id int64, schedule_date int64, user_org_id int64) (list []*models.WarehouseOutInfo, err error) {
1881
 func GetPatientGoodCountToday(patient_id int64, schedule_date int64, user_org_id int64) (list []*models.WarehouseOutInfo, err error) {
1882
 
1882
 
1883
-	err = XTReadDB().Where("patient_id =? and record_time=? and use_org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&list).Error
1883
+	err = XTReadDB().Where("patient_id =? and sys_record_time=? and org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&list).Error
1884
 	return list, err
1884
 	return list, err
1885
 }
1885
 }

+ 11 - 12
service/sign_service.go 查看文件

10
 	"encoding/json"
10
 	"encoding/json"
11
 	"fmt"
11
 	"fmt"
12
 	"github.com/astaxie/beego"
12
 	"github.com/astaxie/beego"
13
-	"github.com/jung-kurt/gofpdf"
13
+	//"github.com/jung-kurt/gofpdf"
14
 	"io/ioutil"
14
 	"io/ioutil"
15
 	"net/http"
15
 	"net/http"
16
-	"path"
17
 )
16
 )
18
 
17
 
19
 func GetSignNameByPhone(phoneOne string) string {
18
 func GetSignNameByPhone(phoneOne string) string {
2039
 }
2038
 }
2040
 
2039
 
2041
 func SingleImg2Pdf(pathStr string) {
2040
 func SingleImg2Pdf(pathStr string) {
2042
-	pdf := gofpdf.New("P", "mm", "A4", "")
2043
-	pdf.AddPage()
2044
-	pdf.SetFont("Arial", "", 11)
2045
-	pdf.Image(pathStr, 10, 10, pdf.GetPageSizeStr("A4").Wd-20, 0, false, "", 0, "")
2046
-	// pdf.Text(50, 20, "logo.png")
2047
-	fileNameAll := path.Base(pathStr)
2048
-	fileSuffix := path.Ext(pathStr)
2049
-	fileStr := fmt.Sprintf("./pdfs/%s.pdf", fileNameAll[0:len(fileNameAll)-len(fileSuffix)])
2050
-	err := pdf.OutputFileAndClose(fileStr)
2051
-	fmt.Println(err)
2041
+	//pdf := gofpdf.New("P", "mm", "A4", "")
2042
+	//pdf.AddPage()
2043
+	//pdf.SetFont("Arial", "", 11)
2044
+	//pdf.Image(pathStr, 10, 10, pdf.GetPageSizeStr("A4").Wd-20, 0, false, "", 0, "")
2045
+	//// pdf.Text(50, 20, "logo.png")
2046
+	//fileNameAll := path.Base(pathStr)
2047
+	//fileSuffix := path.Ext(pathStr)
2048
+	//fileStr := fmt.Sprintf("./pdfs/%s.pdf", fileNameAll[0:len(fileNameAll)-len(fileSuffix)])
2049
+	//err := pdf.OutputFileAndClose(fileStr)
2050
+	//fmt.Println(err)
2052
 }
2051
 }
2053
 
2052
 
2054
 func GetAllPatientNew(org_id int64) (new []*models.XtPatients, err error) {
2053
 func GetAllPatientNew(org_id int64) (new []*models.XtPatients, err error) {

+ 1 - 1
service/stock_service.go 查看文件

3627
 
3627
 
3628
 func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
3628
 func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
3629
 	err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3 or stock_attribute = 4)", orgid).
3629
 	err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3 or stock_attribute = 4)", orgid).
3630
-		Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
3630
+		Preload("GoodInfo", "org_id = ? and status = 1 and  find_in_set('停用',good_status) = 0", orgid).Find(&goodstype).Error
3631
 	return goodstype, err
3631
 	return goodstype, err
3632
 }
3632
 }
3633
 
3633
 

+ 6 - 5
service/warhouse_service.go 查看文件

6194
 func FindNewLastDrugWarehouseOutInfo(orgid int64, tx *gorm.DB) (models.DrugWarehouseOutInfo, error) {
6194
 func FindNewLastDrugWarehouseOutInfo(orgid int64, tx *gorm.DB) (models.DrugWarehouseOutInfo, error) {
6195
 	info := models.DrugWarehouseOutInfo{}
6195
 	info := models.DrugWarehouseOutInfo{}
6196
 	err := tx.Where("org_id = ? and status = 1", orgid).Last(&info).Error
6196
 	err := tx.Where("org_id = ? and status = 1", orgid).Last(&info).Error
6197
-	if err != nil {
6198
-		tx.Rollback()
6199
-		return info, err
6197
+	if err != gorm.ErrRecordNotFound {
6198
+		if err != nil {
6199
+			tx.Rollback()
6200
+			return info, err
6201
+		}
6200
 	}
6202
 	}
6201
-	tx.Rollback()
6202
 	return info, err
6203
 	return info, err
6203
 }
6204
 }
6204
 
6205
 
8011
 		OutInfo.Count = count - out_count_two + out_count_one
8012
 		OutInfo.Count = count - out_count_two + out_count_one
8012
 
8013
 
8013
 		_, errcodes := GetNewNewWarehouseOutInfoIsExistSix(goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8014
 		_, errcodes := GetNewNewWarehouseOutInfoIsExistSix(goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8014
-		fmt.Println("errcodes-------------------------------------------", errcodes)
8015
+
8015
 		if errcodes == gorm.ErrRecordNotFound {
8016
 		if errcodes == gorm.ErrRecordNotFound {
8016
 			errOne := AddNewSigleWarehouseOutInfo(OutInfo, tx)
8017
 			errOne := AddNewSigleWarehouseOutInfo(OutInfo, tx)
8017
 			if errOne != nil {
8018
 			if errOne != nil {