Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
396393dbdd

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 9 - 1
controllers/gobal_config_api_controller.go View File

@@ -1387,6 +1387,10 @@ func (c *GobalConfigApiController) PostXTHisConfig() {
1387 1387
 		}
1388 1388
 
1389 1389
 		err := service.UpdateXTHisRecord(&modifyConfig)
1390
+		redis := service.RedisClient()
1391
+		defer redis.Close()
1392
+		key := strconv.FormatInt(org_id, 10) + ":" + ":his_config"
1393
+		redis.Set(key, "", time.Second)
1390 1394
 		if err != nil {
1391 1395
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1392 1396
 			return
@@ -1425,6 +1429,10 @@ func (c *GobalConfigApiController) PostXTHisProjectConfig() {
1425 1429
 
1426 1430
 	if errs == gorm.ErrRecordNotFound {
1427 1431
 		err := service.CreateXTHisProjectRecord(&config)
1432
+		redis := service.RedisClient()
1433
+		key := strconv.FormatInt(org_id, 10) + ":his_project_config"
1434
+		redis.Set(key, "", time.Second)
1435
+		defer redis.Close()
1428 1436
 		if err != nil {
1429 1437
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1430 1438
 			return
@@ -1469,7 +1477,7 @@ func (c *GobalConfigApiController) GetXTHisConfig() {
1469 1477
 func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1470 1478
 	adminUserInfo := c.GetAdminUserInfo()
1471 1479
 	_, config := service.FindXTHisRecordByOrgId(adminUserInfo.CurrentOrgId)
1472
-	_, project_config := service.FindXTHisProjectByOrgId(adminUserInfo.CurrentOrgId)
1480
+	_, project_config := service.FindXTHisProjectByOrgIdOne(adminUserInfo.CurrentOrgId)
1473 1481
 
1474 1482
 	c.ServeSuccessJSON(map[string]interface{}{
1475 1483
 		"is_open_xt_his":         config.IsOpen,

+ 16 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -93,7 +93,7 @@ func (this *DialysisAPIController) Scheduals() {
93 93
 
94 94
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
95 95
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
96
-		fmt.Println("hhhhhh2323232323223222我的", scheduals)
96
+
97 97
 		if err != nil {
98 98
 			this.ErrorLog("获取排班信息失败:%v", err)
99 99
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -105,7 +105,6 @@ func (this *DialysisAPIController) Scheduals() {
105 105
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
106 106
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
107 107
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
108
-				fmt.Println("hh23322332323232323233223", dialysisOrders)
109 108
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
110 109
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
111 110
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
@@ -2044,9 +2043,12 @@ func (this *DialysisAPIController) StartDialysis() {
2044 2043
 
2045 2044
 		redis := service.RedisClient()
2046 2045
 		defer redis.Close()
2046
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2047
+		redis.Set(key, "", time.Second)
2047 2048
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2048 2049
 		//清空key 值
2049 2050
 		redis.Set(keyOne, "", time.Second)
2051
+
2050 2052
 		if createErr != nil {
2051 2053
 			this.ErrorLog("上机失败:%v", createErr)
2052 2054
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2712,6 +2714,8 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2712 2714
 	change_nurse, _ := this.GetInt64("change_nurse")
2713 2715
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
2714 2716
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
2717
+	patient_id, _ := this.GetInt64("patient_id")
2718
+	record_date, _ := this.GetInt64("record_date")
2715 2719
 	if record_id == 0 {
2716 2720
 		this.ErrorLog("id:%v", record_id)
2717 2721
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -2846,7 +2850,13 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2846 2850
 	}
2847 2851
 
2848 2852
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
2849
-
2853
+	redis := service.RedisClient()
2854
+	defer redis.Close()
2855
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
2856
+	redis.Set(key, "", time.Second)
2857
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2858
+	//清空key 值
2859
+	redis.Set(keyOne, "", time.Second)
2850 2860
 	if updateErr != nil {
2851 2861
 		this.ErrorLog("修改上机失败:%v", updateErr)
2852 2862
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -3435,9 +3445,9 @@ func (c *DialysisAPIController) GetSolution() {
3435 3445
 	patient_id, _ := c.GetInt64("patient_id")
3436 3446
 	mode_id, _ := c.GetInt64("mode_id")
3437 3447
 	adminUserInfo := c.GetMobileAdminUserInfo()
3438
-	solution, err := service.MobileGetDialysisSolutionByModeId(adminUserInfo.Org.Id, patient_id, mode_id)
3439
-	prescription, err := service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.Org.Id, patient_id, mode_id)
3440
-	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.Org.Id, mode_id)
3448
+	solution, err := service.MobileGetDialysisSolutionByModeIdSeven(adminUserInfo.Org.Id, patient_id, mode_id)
3449
+	prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSeven(adminUserInfo.Org.Id, patient_id, mode_id)
3450
+	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSeven(adminUserInfo.Org.Id, mode_id)
3441 3451
 
3442 3452
 	if err != nil {
3443 3453
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 29 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -585,9 +585,20 @@ func (c *PatientApiController) ExecDoctorAdvice() {
585 585
 		var err error
586 586
 		if groupno > 0 {
587 587
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
588
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
589
+			redis := service.RedisClient()
590
+			defer redis.Close()
591
+			//清空key 值
592
+			redis.Set(key, "", time.Second)
588 593
 		} else {
589 594
 
590 595
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
596
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
597
+			redis := service.RedisClient()
598
+			defer redis.Close()
599
+			//清空key 值
600
+			redis.Set(key, "", time.Second)
601
+
591 602
 		}
592 603
 
593 604
 		if err != nil {
@@ -891,6 +902,11 @@ func (c *PatientApiController) ExecDoctorAdvice() {
891 902
 			item.ExecutionStaff = adminInfo.AdminUser.Id
892 903
 			item.ExecutionTime = theTime.Unix()
893 904
 			err = service.SaveHisDoctorAdvice(item)
905
+			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
906
+			redis := service.RedisClient()
907
+			defer redis.Close()
908
+			//清空key 值
909
+			redis.Set(key, "", time.Second)
894 910
 		}
895 911
 
896 912
 		if err == nil {
@@ -1165,6 +1181,11 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1165 1181
 		var err error
1166 1182
 		if groupno > 0 {
1167 1183
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1184
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1185
+			redis := service.RedisClient()
1186
+			defer redis.Close()
1187
+			//清空key 值
1188
+			redis.Set(key, "", time.Second)
1168 1189
 		} else {
1169 1190
 
1170 1191
 			if len(ids[0]) <= 0 {
@@ -1212,6 +1233,11 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1212 1233
 			item.CheckTime = time.Now().Unix()
1213 1234
 			item.CheckState = 1
1214 1235
 			err = service.SaveHisDoctorAdvice(item)
1236
+			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1237
+			redis := service.RedisClient()
1238
+			defer redis.Close()
1239
+			//清空key 值
1240
+			redis.Set(key, "", time.Second)
1215 1241
 		}
1216 1242
 		if err == nil {
1217 1243
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -1251,7 +1277,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1251 1277
 		return
1252 1278
 	}
1253 1279
 
1254
-	theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
1280
+	theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationSeven(adminUserInfo.Org.Id, id, theAssessmentDateTime)
1255 1281
 	if getPEErr != nil {
1256 1282
 		c.ErrorLog("获取透前评估失败:%v", getPEErr)
1257 1283
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1544,8 +1570,9 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1544 1570
 	// 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1545 1571
 	// 	}
1546 1572
 	// }
1547
-
1573
+	fmt.Println("hh233232323232evaluation", evaluation)
1548 1574
 	err = service.UpadatePredialysisEvaluation(&evaluation)
1575
+	fmt.Println("除非3333223323233232323323232", err)
1549 1576
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
1550 1577
 	redis := service.RedisClient()
1551 1578
 	defer redis.Close()

+ 10 - 3
service/dialysis_service.go View File

@@ -796,6 +796,9 @@ func GetAllStarfEs(orgid int64) (es []*models.SgjUserAdminRoles, err error) {
796 796
 		err = db.Select("x.id,x.admin_user_id,x.org_id,x.app_id,x.role_id,x.user_name,x.avatar,x.user_type,s.creator,s.url,s.hash").Joins("left join sgj_user_admin_electronic_signature as s on s.creator = x.admin_user_id and s.status = 1").Where("x.org_id = ?", orgid).Scan(&es).Error
797 797
 		if err != nil {
798 798
 			if err == gorm.ErrRecordNotFound {
799
+				if len(es) <= 0 {
800
+					redis.Set(key, "starfes_str_null", time.Second*60*60*18)
801
+				}
799 802
 				return nil, nil
800 803
 			} else {
801 804
 				return nil, err
@@ -809,14 +812,18 @@ func GetAllStarfEs(orgid int64) (es []*models.SgjUserAdminRoles, err error) {
809 812
 					return es, nil
810 813
 				}
811 814
 			} else {
812
-				redis.Set(key, " ", time.Second*60*60*18)
815
+				redis.Set(key, "starfes_str_null", time.Second*60*60*18)
813 816
 				return es, nil
814 817
 			}
815 818
 			return es, nil
816 819
 		}
817 820
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
818
-		json.Unmarshal([]byte(starfes_str), &es)
819
-		return es, nil
821
+		if starfes_str == "starfes_str_null" {
822
+			return es, nil
823
+		} else {
824
+			json.Unmarshal([]byte(starfes_str), &es)
825
+			return es, nil
826
+		}
820 827
 	}
821 828
 }
822 829
 

+ 17 - 3
service/gobal_config_service.go View File

@@ -31,6 +31,9 @@ func FindAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.Go
31 31
 		err = readDb.Model(&models.GobalConfig{}).Where("status = 1 AND org_id = ?", org_id).Find(&config).Error
32 32
 		if err != nil {
33 33
 			if err == gorm.ErrRecordNotFound {
34
+				if config.ID <= 0 {
35
+					redis.Set(key, "gobla_config_null", time.Second*60*60*18)
36
+				}
34 37
 				return nil, config
35 38
 			} else {
36 39
 				return err, config
@@ -44,14 +47,19 @@ func FindAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.Go
44 47
 					return nil, config
45 48
 				}
46 49
 			} else {
47
-				redis.Set(key, " ", time.Second*60*60*18)
50
+				redis.Set(key, "gobla_config_null", time.Second*60*60*18)
48 51
 				return nil, config
49 52
 			}
50 53
 			return nil, config
51 54
 		}
52 55
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
53
-		json.Unmarshal([]byte(gobal_config_str), &config)
54
-		return nil, config
56
+		if gobal_config_str == "gobla_config_null" {
57
+			return nil, config
58
+		} else {
59
+			json.Unmarshal([]byte(gobal_config_str), &config)
60
+			return nil, config
61
+		}
62
+
55 63
 	}
56 64
 }
57 65
 
@@ -925,3 +933,9 @@ func GetDrugFlowBatch(ware_out_id int64, drug_id int64, orgid int64) (flow []*mo
925 933
 	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
926 934
 	return flow, err
927 935
 }
936
+
937
+func FindXTHisProjectByOrgIdOne(org_id int64) (err error, config models.XtHisProjectConfig) {
938
+
939
+	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
940
+	return err, config
941
+}

+ 11 - 3
service/his_service.go View File

@@ -1997,6 +1997,9 @@ func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time
1997 1997
 		err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1", user_org_id, patient_id, record_time).Find(&projects).Error
1998 1998
 		if err != nil {
1999 1999
 			if err == gorm.ErrRecordNotFound {
2000
+				if len(projects) <= 0 {
2001
+					redis.Set(key, "his_prescription_null", time.Second*60*60*18)
2002
+				}
2000 2003
 				return nil, nil
2001 2004
 			} else {
2002 2005
 				return nil, err
@@ -2009,13 +2012,18 @@ func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time
2009 2012
 					redis.Set(key, his_prescription_project_str, time.Second*60*60*18)
2010 2013
 				}
2011 2014
 			} else {
2012
-				redis.Set(key, " ", time.Second*60*60*18)
2015
+				redis.Set(key, "his_prescription_null", time.Second*60*60*18)
2013 2016
 			}
2014 2017
 			return projects, nil
2015 2018
 		}
2016 2019
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2017
-		json.Unmarshal([]byte(his_prescription_project_str), &projects)
2018
-		return projects, nil
2020
+		if his_prescription_project_str == "his_prescription_null" {
2021
+			return projects, nil
2022
+		} else {
2023
+			json.Unmarshal([]byte(his_prescription_project_str), &projects)
2024
+			return projects, nil
2025
+		}
2026
+
2019 2027
 	}
2020 2028
 
2021 2029
 }

+ 250 - 53
service/mobile_dialysis_service.go View File

@@ -442,11 +442,14 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
442 442
 					redis.Set(key, schedual_detail_str, time.Second*60*60*18)
443 443
 				}
444 444
 			} else {
445
-				redis.Set(key, " ", time.Second*60*60*18)
445
+				redis.Set(key, "null", time.Second*60*60*18)
446 446
 			}
447 447
 			return &vm, nil
448 448
 		}
449 449
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
450
+		if schedual_detail_str == "null" {
451
+			return &vm, nil
452
+		}
450 453
 		json.Unmarshal([]byte(schedual_detail_str), &vm)
451 454
 
452 455
 		return &vm, nil
@@ -556,11 +559,17 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
556 559
 
557 560
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
558 561
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
559
-
562
+	fmt.Println("长度233232323322332322323", receive_treatment_asses_str)
560 563
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
561 564
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
562 565
 		if err != nil {
566
+			fmt.Println("h2323232woweewweweweweeweeewweewweweweewweewwewe", record.ID)
563 567
 			if err == gorm.ErrRecordNotFound {
568
+				if record.ID <= 0 {
569
+
570
+					redis.Set(key, "null", time.Second*60*60*18)
571
+					fmt.Println("j你来了呃呃呃呃呃呃呃呃呃呃")
572
+				}
564 573
 				return nil, nil
565 574
 			} else {
566 575
 				return nil, err
@@ -573,11 +582,15 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
573 582
 					redis.Set(key, receive_treatment_asses_str, time.Second*60*60*18)
574 583
 				}
575 584
 			} else {
576
-				redis.Set(key, " ", time.Second*60*60*18)
585
+				redis.Set(key, "null", time.Second*60*60*18)
577 586
 			}
578 587
 			return &record, nil
579 588
 		}
580 589
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
590
+		if receive_treatment_asses_str == "null" {
591
+
592
+			return &record, nil
593
+		}
581 594
 		json.Unmarshal([]byte(receive_treatment_asses_str), &record)
582 595
 		return &record, nil
583 596
 	}
@@ -598,6 +611,9 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
598 611
 		err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
599 612
 		if err != nil {
600 613
 			if err == gorm.ErrRecordNotFound {
614
+				if record.ID <= 0 {
615
+					redis.Set(key, "null", time.Second*60*60*18)
616
+				}
601 617
 				return nil, nil
602 618
 			} else {
603 619
 				return nil, err
@@ -610,13 +626,18 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
610 626
 					redis.Set(key, assessment_before_dislysis_str, time.Second*60*60*18)
611 627
 				}
612 628
 			} else {
613
-				redis.Set(key, " ", time.Second*60*60*18)
629
+				redis.Set(key, "null", time.Second*60*60*18)
614 630
 			}
615 631
 			return &record, nil
616 632
 		}
617 633
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
618
-		json.Unmarshal([]byte(assessment_before_dislysis_str), &record)
619
-		return &record, nil
634
+		if assessment_before_dislysis_str == "null" {
635
+			return &record, nil
636
+		} else {
637
+			json.Unmarshal([]byte(assessment_before_dislysis_str), &record)
638
+			return &record, nil
639
+		}
640
+
620 641
 	}
621 642
 }
622 643
 
@@ -634,6 +655,9 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
634 655
 		err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
635 656
 		if err != nil {
636 657
 			if err == gorm.ErrRecordNotFound {
658
+				if record.ID <= 0 {
659
+					redis.Set(key, "null", time.Second*60*60*18)
660
+				}
637 661
 				return nil, nil
638 662
 			} else {
639 663
 				return nil, err
@@ -646,13 +670,18 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
646 670
 					redis.Set(key, assessment_before_dislysis_last_str, time.Second*60*60*4)
647 671
 				}
648 672
 			} else {
649
-				redis.Set(key, " ", time.Second*60*60*18)
673
+				redis.Set(key, "null", time.Second*60*60*18)
650 674
 			}
651 675
 			return &record, nil
652 676
 		}
653 677
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
654
-		json.Unmarshal([]byte(assessment_before_dislysis_last_str), &record)
655
-		return &record, nil
678
+		if assessment_before_dislysis_last_str == "null" {
679
+			return &record, nil
680
+		} else {
681
+			json.Unmarshal([]byte(assessment_before_dislysis_last_str), &record)
682
+			return &record, nil
683
+		}
684
+
656 685
 	}
657 686
 }
658 687
 
@@ -690,6 +719,9 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
690 719
 			Scan(&records).Error
691 720
 		if err != nil {
692 721
 			if err == gorm.ErrRecordNotFound {
722
+				if len(records) <= 0 {
723
+					redis.Set(key, "null", time.Second*60*60*18)
724
+				}
693 725
 				return nil, nil
694 726
 			} else {
695 727
 				return nil, err
@@ -703,14 +735,18 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
703 735
 					return records, nil
704 736
 				}
705 737
 			} else {
706
-				redis.Set(key, " ", time.Second*60*60*18)
738
+				redis.Set(key, "null", time.Second*60*60*18)
707 739
 				return records, nil
708 740
 			}
709 741
 			return records, nil
710 742
 		}
711 743
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
712
-		json.Unmarshal([]byte(doctor_advices_str), &records)
713
-		return records, nil
744
+		if doctor_advices_str == "null" {
745
+			return records, nil
746
+		} else {
747
+			json.Unmarshal([]byte(doctor_advices_str), &records)
748
+			return records, nil
749
+		}
714 750
 	}
715 751
 }
716 752
 
@@ -728,6 +764,9 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
728 764
 		err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
729 765
 		if err != nil {
730 766
 			if err == gorm.ErrRecordNotFound {
767
+				if record.ID <= 0 {
768
+					redis.Set(key, "null", time.Second*60*60*18)
769
+				}
731 770
 				return nil, nil
732 771
 			} else {
733 772
 				return nil, err
@@ -740,13 +779,18 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
740 779
 					redis.Set(key, dialysis_order_str, time.Second*60*60*18)
741 780
 				}
742 781
 			} else {
743
-				redis.Set(key, " ", time.Second*60*60*18)
782
+				redis.Set(key, "null", time.Second*60*60*18)
744 783
 			}
745 784
 			return &record, nil
746 785
 		}
747 786
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
748
-		json.Unmarshal([]byte(dialysis_order_str), &record)
749
-		return &record, nil
787
+		if dialysis_order_str == "null" {
788
+			return &record, nil
789
+		} else {
790
+			json.Unmarshal([]byte(dialysis_order_str), &record)
791
+			return &record, nil
792
+		}
793
+
750 794
 	}
751 795
 }
752 796
 
@@ -764,6 +808,9 @@ func MobileGetDoubleCheck(orgID int64, patientID int64, recordDate int64) (*mode
764 808
 		err := readDb.Model(&models.DoubleCheck{}).Where("patient_id = ? and user_org_id = ? and status = 1 and check_date = ?", patientID, orgID, recordDate).First(&record).Error
765 809
 		if err != nil {
766 810
 			if err == gorm.ErrRecordNotFound {
811
+				if record.ID <= 0 {
812
+					redis.Set(key, "null", time.Second*60*60*18)
813
+				}
767 814
 				return nil, nil
768 815
 			} else {
769 816
 				return nil, err
@@ -776,13 +823,18 @@ func MobileGetDoubleCheck(orgID int64, patientID int64, recordDate int64) (*mode
776 823
 					redis.Set(key, double_check_str, time.Second*60*60*18)
777 824
 				}
778 825
 			} else {
779
-				redis.Set(key, " ", time.Second*60*60*18)
826
+				redis.Set(key, "null", time.Second*60*60*18)
780 827
 			}
781 828
 			return &record, nil
782 829
 		}
783 830
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
784
-		json.Unmarshal([]byte(double_check_str), &record)
785
-		return &record, nil
831
+		if double_check_str == "null" {
832
+			return &record, nil
833
+		} else {
834
+			json.Unmarshal([]byte(double_check_str), &record)
835
+			return &record, nil
836
+		}
837
+
786 838
 	}
787 839
 }
788 840
 
@@ -800,6 +852,9 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
800 852
 		err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, recordDate).Order("operate_time asc").Find(&records).Error
801 853
 		if err != nil {
802 854
 			if err == gorm.ErrRecordNotFound {
855
+				if len(records) <= 0 {
856
+					redis.Set(key, "null", time.Second*60*60*18)
857
+				}
803 858
 				return nil, nil
804 859
 			} else {
805 860
 				return nil, err
@@ -812,13 +867,18 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
812 867
 					redis.Set(key, monitor_records_str, time.Second*60*60*18)
813 868
 				}
814 869
 			} else {
815
-				redis.Set(key, " ", time.Second*60*60*18)
870
+				redis.Set(key, "null", time.Second*60*60*18)
816 871
 			}
817 872
 			return records, nil
818 873
 		}
819 874
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
820
-		json.Unmarshal([]byte(monitor_records_str), &records)
821
-		return records, nil
875
+		if monitor_records_str == "null" {
876
+			return records, nil
877
+		} else {
878
+			json.Unmarshal([]byte(monitor_records_str), &records)
879
+			return records, nil
880
+		}
881
+
822 882
 	}
823 883
 }
824 884
 
@@ -844,6 +904,9 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
844 904
 		err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
845 905
 		if err != nil {
846 906
 			if err == gorm.ErrRecordNotFound {
907
+				if record.ID <= 0 {
908
+					redis.Set(key, "null", time.Second*60*60*18)
909
+				}
847 910
 				return nil, nil
848 911
 			} else {
849 912
 				return nil, err
@@ -856,13 +919,17 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
856 919
 					redis.Set(key, monitor_record_last_str, time.Second*60*60*18)
857 920
 				}
858 921
 			} else {
859
-				redis.Set(key, " ", time.Second*60*60*18)
922
+				redis.Set(key, "null", time.Second*60*60*18)
860 923
 			}
861 924
 			return &record, nil
862 925
 		}
863 926
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
864
-		json.Unmarshal([]byte(monitor_record_last_str), &record)
865
-		return &record, nil
927
+		if monitor_record_last_str == "null" {
928
+			return &record, nil
929
+		} else {
930
+			json.Unmarshal([]byte(monitor_record_last_str), &record)
931
+			return &record, nil
932
+		}
866 933
 	}
867 934
 }
868 935
 
@@ -880,6 +947,9 @@ func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate i
880 947
 		err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
881 948
 		if err != nil {
882 949
 			if err == gorm.ErrRecordNotFound {
950
+				if record.ID <= 0 {
951
+					redis.Set(key, "null", time.Second*60*60*18)
952
+				}
883 953
 				return nil, nil
884 954
 			} else {
885 955
 				return nil, err
@@ -892,13 +962,17 @@ func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate i
892 962
 					redis.Set(key, assessment_after_dislysis_str, time.Second*60*60*18)
893 963
 				}
894 964
 			} else {
895
-				redis.Set(key, " ", time.Second*60*60*18)
965
+				redis.Set(key, "null", time.Second*60*60*18)
896 966
 			}
897 967
 			return &record, nil
898 968
 		}
899 969
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
900
-		json.Unmarshal([]byte(assessment_after_dislysis_str), &record)
901
-		return &record, nil
970
+		if assessment_after_dislysis_str == "null" {
971
+			return &record, nil
972
+		} else {
973
+			json.Unmarshal([]byte(assessment_after_dislysis_str), &record)
974
+			return &record, nil
975
+		}
902 976
 	}
903 977
 }
904 978
 
@@ -916,6 +990,9 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
916 990
 		err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
917 991
 		if err != nil {
918 992
 			if err == gorm.ErrRecordNotFound {
993
+				if record.ID <= 0 {
994
+					redis.Set(key, "null", time.Second*60*60*18)
995
+				}
919 996
 				return nil, nil
920 997
 			} else {
921 998
 				return nil, err
@@ -928,13 +1005,18 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
928 1005
 					redis.Set(key, assessment_after_dislysis_last_str, time.Second*60*60*18)
929 1006
 				}
930 1007
 			} else {
931
-				redis.Set(key, " ", time.Second*60*60*18)
1008
+				redis.Set(key, "null", time.Second*60*60*18)
932 1009
 			}
933 1010
 			return &record, nil
934 1011
 		}
935 1012
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
936
-		json.Unmarshal([]byte(assessment_after_dislysis_last_str), &record)
937
-		return &record, nil
1013
+		if assessment_after_dislysis_last_str == "null" {
1014
+			return &record, nil
1015
+		} else {
1016
+			json.Unmarshal([]byte(assessment_after_dislysis_last_str), &record)
1017
+			return &record, nil
1018
+		}
1019
+
938 1020
 	}
939 1021
 }
940 1022
 func MobileGetLast(orgID int64, patientID int64, maxDate int64) (models.AssessmentAfterDislysis, error) {
@@ -952,11 +1034,15 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
952 1034
 	// cur_date := time.Now().Format("2006-01-02")
953 1035
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":treatment_summary"
954 1036
 	treatment_summary_str, _ := redis.Get(key).Result()
955
-	fmt.Println("质量洗哦啊稼23323232323232323233232322332", treatment_summary_str)
956 1037
 	if len(treatment_summary_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
957 1038
 		err := readDb.Model(&models.TreatmentSummary{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
1039
+
958 1040
 		if err != nil {
959 1041
 			if err == gorm.ErrRecordNotFound {
1042
+				if record.ID <= 0 {
1043
+					fmt.Println("创建成功没有", treatment_summary_str)
1044
+					redis.Set(key, "null", time.Second*60*60*18)
1045
+				}
960 1046
 				return nil, nil
961 1047
 			} else {
962 1048
 				return nil, err
@@ -969,13 +1055,18 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
969 1055
 					redis.Set(key, treatment_summary_str, time.Second*60*60*18)
970 1056
 				}
971 1057
 			} else {
972
-				redis.Set(key, " ", time.Second*60*60*18)
1058
+				redis.Set(key, "null", time.Second*60*60*18)
973 1059
 			}
974 1060
 			return &record, nil
975 1061
 		}
976 1062
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
977
-		json.Unmarshal([]byte(treatment_summary_str), &record)
978
-		return &record, nil
1063
+
1064
+		if treatment_summary_str == "null" {
1065
+			return &record, nil
1066
+		} else {
1067
+			json.Unmarshal([]byte(treatment_summary_str), &record)
1068
+			return &record, nil
1069
+		}
979 1070
 	}
980 1071
 }
981 1072
 
@@ -1809,6 +1900,9 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
1809 1900
 		err := readDb.Model(&models.SgjPatientDryweight{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Last(&record).Error
1810 1901
 		if err != nil {
1811 1902
 			if err == gorm.ErrRecordNotFound {
1903
+				if record.ID <= 0 {
1904
+					redis.Set(key, "null", time.Second*60*60*18)
1905
+				}
1812 1906
 				return nil, nil
1813 1907
 			} else {
1814 1908
 				return nil, err
@@ -1822,14 +1916,19 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
1822 1916
 					return nil, err
1823 1917
 				}
1824 1918
 			} else {
1825
-				redis.Set(key, " ", time.Second*60*60*18)
1919
+				redis.Set(key, "null", time.Second*60*60*18)
1826 1920
 				return nil, err
1827 1921
 			}
1828 1922
 			return &record, nil
1829 1923
 		}
1830 1924
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1831
-		json.Unmarshal([]byte(last_dry_weight_str), &record)
1832
-		return &record, nil
1925
+		if last_dry_weight_str == "null" {
1926
+			return &record, nil
1927
+		} else {
1928
+			json.Unmarshal([]byte(last_dry_weight_str), &record)
1929
+			return &record, nil
1930
+		}
1931
+
1833 1932
 	}
1834 1933
 }
1835 1934
 
@@ -1847,6 +1946,9 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
1847 1946
 		err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
1848 1947
 		if err != nil {
1849 1948
 			if err == gorm.ErrRecordNotFound {
1949
+				if record.ID <= 0 {
1950
+					redis.Set(key, "null", time.Second*60*60*18)
1951
+				}
1850 1952
 				return nil, nil
1851 1953
 			} else {
1852 1954
 				return nil, err
@@ -1859,13 +1961,18 @@ func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int
1859 1961
 					redis.Set(key, dialysis_solution_str, time.Second*60*60*18)
1860 1962
 				}
1861 1963
 			} else {
1862
-				redis.Set(key, " ", time.Second*60*60*18)
1964
+				redis.Set(key, "null", time.Second*60*60*18)
1863 1965
 			}
1864 1966
 			return &record, nil
1865 1967
 		}
1866 1968
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1867
-		json.Unmarshal([]byte(dialysis_solution_str), &record)
1868
-		return &record, nil
1969
+		if dialysis_solution_str == "null" {
1970
+			return &record, nil
1971
+		} else {
1972
+			json.Unmarshal([]byte(dialysis_solution_str), &record)
1973
+			return &record, nil
1974
+		}
1975
+
1869 1976
 	}
1870 1977
 }
1871 1978
 
@@ -1884,6 +1991,9 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1884 1991
 		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? AND mode_id = ?", patientID, orgID, recordDate, mode_id).First(&record).Error
1885 1992
 		if err != nil {
1886 1993
 			if err == gorm.ErrRecordNotFound {
1994
+				if record.ID <= 0 {
1995
+					redis.Set(key, "null", time.Second*60*60*18)
1996
+				}
1887 1997
 				return nil, nil
1888 1998
 			} else {
1889 1999
 				return nil, err
@@ -1896,13 +2006,18 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1896 2006
 					redis.Set(key, dialysis_prescribe_str, time.Second*60*60*18)
1897 2007
 				}
1898 2008
 			} else {
1899
-				redis.Set(key, " ", time.Second*60*60*18)
2009
+				redis.Set(key, "null", time.Second*60*60*18)
1900 2010
 			}
1901 2011
 			return &record, nil
1902 2012
 		}
1903 2013
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1904
-		json.Unmarshal([]byte(dialysis_prescribe_str), &record)
1905
-		return &record, nil
2014
+		if dialysis_prescribe_str == "null" {
2015
+			return &record, nil
2016
+		} else {
2017
+			json.Unmarshal([]byte(dialysis_prescribe_str), &record)
2018
+			return &record, nil
2019
+		}
2020
+
1906 2021
 	}
1907 2022
 }
1908 2023
 
@@ -1919,6 +2034,9 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
1919 2034
 		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
1920 2035
 		if err != nil {
1921 2036
 			if err == gorm.ErrRecordNotFound {
2037
+				if record.ID <= 0 {
2038
+					redis.Set(key, "null", time.Second*60*60*18)
2039
+				}
1922 2040
 				return nil, nil
1923 2041
 			} else {
1924 2042
 				return nil, err
@@ -1934,14 +2052,20 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
1934 2052
 					return nil, err
1935 2053
 				}
1936 2054
 			} else {
1937
-				redis.Set(key, " ", time.Second*60*60*18)
2055
+				redis.Set(key, "null", time.Second*60*60*18)
1938 2056
 				return nil, err
1939 2057
 			}
1940 2058
 			return &record, nil
1941 2059
 		}
1942 2060
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1943
-		json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
1944
-		return &record, nil
2061
+		if dialysis_prescribe_by_mode_str == "null" {
2062
+			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2063
+			return &record, nil
2064
+		} else {
2065
+			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2066
+			return &record, nil
2067
+		}
2068
+
1945 2069
 	}
1946 2070
 }
1947 2071
 
@@ -1981,6 +2105,9 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
1981 2105
 		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and mode_id = ?", patientID, orgID, mode_id).First(&record).Error
1982 2106
 		if err != nil {
1983 2107
 			if err == gorm.ErrRecordNotFound {
2108
+				if record.ID <= 0 {
2109
+					redis.Set(key, "null", time.Second*60*60*18)
2110
+				}
1984 2111
 				return nil, nil
1985 2112
 			} else {
1986 2113
 				return nil, err
@@ -1992,18 +2119,24 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
1992 2119
 				dialysis_prescribe_by_mode_str, err := json.Marshal(record)
1993 2120
 
1994 2121
 				if err == nil {
2122
+
1995 2123
 					redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
1996 2124
 					return nil, err
1997 2125
 				}
1998 2126
 			} else {
1999
-				redis.Set(key, " ", time.Second*60*60*18)
2127
+				redis.Set(key, "null", time.Second*60*60*18)
2000 2128
 				return nil, err
2001 2129
 			}
2002 2130
 			return &record, nil
2003 2131
 		}
2004 2132
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2005
-		json.Unmarshal([]byte(dialysis_prescribe_by_mode_id), &record)
2006
-		return &record, nil
2133
+		if dialysis_prescribe_by_mode_id == "null" {
2134
+			return &record, nil
2135
+		} else {
2136
+			json.Unmarshal([]byte(dialysis_prescribe_by_mode_id), &record)
2137
+			return &record, nil
2138
+		}
2139
+
2007 2140
 	}
2008 2141
 }
2009 2142
 
@@ -2191,6 +2324,9 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
2191 2324
 		err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).First(&record).Error
2192 2325
 		if err != nil {
2193 2326
 			if err == gorm.ErrRecordNotFound {
2327
+				if record.ID <= 0 {
2328
+					redis.Set(key, "null", time.Second*60*60*18)
2329
+				}
2194 2330
 				return nil, nil
2195 2331
 			} else {
2196 2332
 				return nil, err
@@ -2203,13 +2339,17 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
2203 2339
 					redis.Set(key, system_dialysis_prescribe_str, time.Second*60*60*18)
2204 2340
 				}
2205 2341
 			} else {
2206
-				redis.Set(key, " ", time.Second*60*60*18)
2342
+				redis.Set(key, "null", time.Second*60*60*18)
2207 2343
 			}
2208 2344
 			return &record, nil
2209 2345
 		}
2210 2346
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2211
-		json.Unmarshal([]byte(system_dialysis_prescribe_str), &record)
2212
-		return &record, nil
2347
+		if system_dialysis_prescribe_str == "null" {
2348
+			return &record, nil
2349
+		} else {
2350
+			json.Unmarshal([]byte(system_dialysis_prescribe_str), &record)
2351
+			return &record, nil
2352
+		}
2213 2353
 	}
2214 2354
 }
2215 2355
 
@@ -2552,6 +2692,9 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
2552 2692
 		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patientid, orgid, recorddate).Find(&his).Error
2553 2693
 		if err != nil {
2554 2694
 			if err == gorm.ErrRecordNotFound {
2695
+				if len(his) <= 0 {
2696
+					redis.Set(key, "null", time.Second*60*60*18)
2697
+				}
2555 2698
 				return his, nil
2556 2699
 			} else {
2557 2700
 				return his, err
@@ -2564,7 +2707,7 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
2564 2707
 					redis.Set(key, his_doctor_advice_str, time.Second*60*60*18)
2565 2708
 				}
2566 2709
 			} else {
2567
-				redis.Set(key, " ", time.Second*60*60*18)
2710
+				redis.Set(key, "null", time.Second*60*60*18)
2568 2711
 			}
2569 2712
 			return his, nil
2570 2713
 		}
@@ -3054,3 +3197,57 @@ func UPdateAutoStockGoods(good_id int64, record_time int64, patient_id int64, co
3054 3197
 	err := XTWriteDB().Model(&detail).Where("good_id = ? and record_time = ? and patient_id = ? and count <> 0 and status = 1", good_id, record_time, patient_id).Updates(map[string]interface{}{"count": count}).Error
3055 3198
 	return err
3056 3199
 }
3200
+
3201
+func MobileGetDialysisSolutionByModeIdSeven(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
3202
+	var record models.DialysisSolution
3203
+	err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
3204
+	if err != nil {
3205
+		if err == gorm.ErrRecordNotFound {
3206
+			return nil, nil
3207
+		} else {
3208
+			return nil, err
3209
+		}
3210
+	}
3211
+	return &record, nil
3212
+}
3213
+
3214
+func MobileGetLastDialysisPrescribeByModeIdSeven(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
3215
+	var record models.DialysisPrescription
3216
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1  AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
3217
+	if err != nil {
3218
+		if err == gorm.ErrRecordNotFound {
3219
+			return nil, nil
3220
+		} else {
3221
+			return nil, err
3222
+		}
3223
+	}
3224
+	return &record, nil
3225
+}
3226
+
3227
+func MobileGetSystemDialysisPrescribeByModeIdSeven(orgID int64, mode_id int64) (*models.SystemPrescription, error) {
3228
+	var record models.SystemPrescription
3229
+	err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).First(&record).Error
3230
+	if err != nil {
3231
+		if err == gorm.ErrRecordNotFound {
3232
+			return nil, nil
3233
+		} else {
3234
+			return nil, err
3235
+		}
3236
+	}
3237
+	return &record, nil
3238
+}
3239
+
3240
+// 透前评估
3241
+func MobileGetPredialysisEvaluationSeven(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
3242
+	fmt.Println("recordDate", recordDate)
3243
+	var record models.PredialysisEvaluation
3244
+	err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
3245
+	if err != nil {
3246
+		if err == gorm.ErrRecordNotFound {
3247
+			return nil, nil
3248
+		} else {
3249
+			return nil, err
3250
+		}
3251
+	}
3252
+	return &record, nil
3253
+}

+ 102 - 20
service/patient_service.go View File

@@ -91,6 +91,9 @@ func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientLi
91 91
 		err = readDb.Model(&models.MSchedualPatientList{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
92 92
 		if err != nil {
93 93
 			if err == gorm.ErrRecordNotFound {
94
+				if len(patients) <= 0 {
95
+					redis.Set(key, "null", time.Second*60*60*18)
96
+				}
94 97
 				return nil, nil
95 98
 			} else {
96 99
 				return nil, err
@@ -102,12 +105,18 @@ func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientLi
102 105
 				if err == nil {
103 106
 					redis.Set(key, patient_info_json, time.Second*60*60*18)
104 107
 				}
108
+			} else {
109
+				redis.Set(key, "null", time.Second*60*60*18)
105 110
 			}
106 111
 			return patients, nil
107 112
 		}
108 113
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
109
-		json.Unmarshal([]byte(patient_info_str), &patients)
110
-		return patients, nil
114
+		if patient_info_str == "null" {
115
+			return nil, nil
116
+		} else {
117
+			json.Unmarshal([]byte(patient_info_str), &patients)
118
+			return patients, nil
119
+		}
111 120
 	}
112 121
 }
113 122
 
@@ -121,6 +130,9 @@ func GetAllDevicetByList(orgID int64) (devices []*models.MDeviceNumberForList, e
121 130
 		err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=? and status=1 ", orgID).Find(&devices).Error
122 131
 		if err != nil {
123 132
 			if err == gorm.ErrRecordNotFound {
133
+				if len(devices) <= 0 {
134
+					redis.Set(key, "null", time.Second*60*60*18)
135
+				}
124 136
 				return nil, nil
125 137
 			} else {
126 138
 				return nil, err
@@ -132,12 +144,18 @@ func GetAllDevicetByList(orgID int64) (devices []*models.MDeviceNumberForList, e
132 144
 				if err == nil {
133 145
 					redis.Set(key, device_list_str, time.Second*60*60*18)
134 146
 				}
147
+			} else {
148
+				redis.Set(key, "null", time.Second*60*60*18)
135 149
 			}
136 150
 			return devices, nil
137 151
 		}
138 152
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
139
-		json.Unmarshal([]byte(device_list_str), &devices)
140
-		return devices, nil
153
+		if device_list_str == "null" {
154
+			return nil, nil
155
+		} else {
156
+			json.Unmarshal([]byte(device_list_str), &devices)
157
+			return devices, nil
158
+		}
141 159
 	}
142 160
 }
143 161
 
@@ -151,6 +169,9 @@ func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMD
151 169
 		err = readDb.Model(&models.VMDoctorAdviceForList{}).Where("status = 1 AND user_org_id = ? AND advice_type = 2 AND advice_date = ? ", orgID, scheduleDate).Find(&advices).Error
152 170
 		if err != nil {
153 171
 			if err == gorm.ErrRecordNotFound {
172
+				if len(advices) <= 0 {
173
+					redis.Set(key, "null", time.Second*60*60*18)
174
+				}
154 175
 				return nil, nil
155 176
 			} else {
156 177
 				return nil, err
@@ -162,12 +183,19 @@ func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMD
162 183
 				if err == nil {
163 184
 					redis.Set(key, advice_list_str, time.Second*60*60*18)
164 185
 				}
186
+			} else {
187
+				redis.Set(key, "null", time.Second*60*60*18)
165 188
 			}
166 189
 			return advices, nil
167 190
 		}
168 191
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
169
-		json.Unmarshal([]byte(advice_list_str), &advices)
170
-		return advices, nil
192
+		if advice_list_str == "null" {
193
+			return nil, nil
194
+		} else {
195
+			json.Unmarshal([]byte(advice_list_str), &advices)
196
+			return advices, nil
197
+		}
198
+
171 199
 	}
172 200
 }
173 201
 
@@ -181,6 +209,9 @@ func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions [
181 209
 		err = readDb.Model(&models.DialysisPrescriptionList{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
182 210
 		if err != nil {
183 211
 			if err == gorm.ErrRecordNotFound {
212
+				if len(prescriptions) <= 0 {
213
+					redis.Set(key, "null", time.Second*60*60*18)
214
+				}
184 215
 				return nil, nil
185 216
 			} else {
186 217
 				return nil, err
@@ -192,12 +223,19 @@ func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions [
192 223
 				if err == nil {
193 224
 					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
194 225
 				}
226
+			} else {
227
+				redis.Set(key, "null", time.Second*60*60*18)
195 228
 			}
196 229
 			return prescriptions, nil
197 230
 		}
198 231
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
199
-		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
200
-		return prescriptions, nil
232
+		if prescriptions_list_all == "null" {
233
+			return nil, nil
234
+		} else {
235
+			json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
236
+			return prescriptions, nil
237
+		}
238
+
201 239
 	}
202 240
 }
203 241
 
@@ -211,6 +249,9 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
211 249
 		err = readDb.Model(&models.PredialysisEvaluationList{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
212 250
 		if err != nil {
213 251
 			if err == gorm.ErrRecordNotFound {
252
+				if len(assessmentBefores) <= 0 {
253
+					redis.Set(key, "null", time.Second*60*60*18)
254
+				}
214 255
 				return nil, nil
215 256
 			} else {
216 257
 				return nil, err
@@ -229,7 +270,7 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
229 270
 		}
230 271
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
231 272
 		if assessment_befores_list_all == "null" {
232
-			return nil,nil
273
+			return nil, nil
233 274
 		} else {
234 275
 			json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
235 276
 			return assessmentBefores, nil
@@ -242,12 +283,15 @@ func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders
242 283
 	defer redis.Close()
243 284
 	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
244 285
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
245
-	fmt.Println("hhhhhahdhaf3e2323323223", len(dialysis_orders_list_all))
286
+
246 287
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
247 288
 		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
248
-		fmt.Println("err2332233232323232232323", err)
289
+
249 290
 		if err != nil {
250 291
 			if err == gorm.ErrRecordNotFound {
292
+				if len(dialysisOrders) <= 0 {
293
+					redis.Set(key, "null", time.Second*60*60*18)
294
+				}
251 295
 				return nil, nil
252 296
 			} else {
253 297
 				return nil, err
@@ -259,12 +303,19 @@ func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders
259 303
 				if err == nil {
260 304
 					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
261 305
 				}
306
+			} else {
307
+				redis.Set(key, "null", time.Second*60*60*18)
262 308
 			}
263 309
 			return dialysisOrders, nil
264 310
 		}
265 311
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
266
-		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
267
-		return dialysisOrders, nil
312
+		if dialysis_orders_list_all == "null" {
313
+			return nil, nil
314
+		} else {
315
+			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
316
+			return dialysisOrders, nil
317
+		}
318
+
268 319
 	}
269 320
 }
270 321
 
@@ -278,6 +329,9 @@ func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSu
278 329
 		err = readDb.Model(&models.VMTreatmentSummaryForList{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&treatmentSummarys).Error
279 330
 		if err != nil {
280 331
 			if err == gorm.ErrRecordNotFound {
332
+				if len(treatment_summarys_all) <= 0 {
333
+					redis.Set(key, "null", time.Second*60*60*18)
334
+				}
281 335
 				return nil, nil
282 336
 			} else {
283 337
 				return nil, err
@@ -296,7 +350,7 @@ func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSu
296 350
 		}
297 351
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
298 352
 		if treatment_summarys_all == "null" {
299
-			return nil,nil
353
+			return nil, nil
300 354
 		} else {
301 355
 			json.Unmarshal([]byte(treatment_summarys_all), &treatmentSummarys)
302 356
 			return treatmentSummarys, nil
@@ -314,6 +368,9 @@ func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (asses
314 368
 		err = readDb.Model(&models.VMAssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
315 369
 		if err != nil {
316 370
 			if err == gorm.ErrRecordNotFound {
371
+				if len(assessmentAfterDislysis) <= 0 {
372
+					redis.Set(key, "null", time.Second*60*60*18)
373
+				}
317 374
 				return nil, nil
318 375
 			} else {
319 376
 				return nil, err
@@ -325,12 +382,19 @@ func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (asses
325 382
 				if err == nil {
326 383
 					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
327 384
 				}
385
+			} else {
386
+				redis.Set(key, "null", time.Second*60*60*18)
328 387
 			}
329 388
 			return assessmentAfterDislysis, nil
330 389
 		}
331 390
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
332
-		json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
333
-		return assessmentAfterDislysis, nil
391
+		if assessment_after_dislysis__all == "null" {
392
+			return nil, nil
393
+		} else {
394
+			json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
395
+			return assessmentAfterDislysis, nil
396
+		}
397
+
334 398
 	}
335 399
 }
336 400
 
@@ -344,6 +408,9 @@ func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHis
344 408
 		err = readDb.Model(&VMHisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).Find(&hisAdvices).Error
345 409
 		if err != nil {
346 410
 			if err == gorm.ErrRecordNotFound {
411
+				if len(hisAdvices) <= 0 {
412
+					redis.Set(key, "null", time.Second*60*60*18)
413
+				}
347 414
 				return nil, nil
348 415
 			} else {
349 416
 				return nil, err
@@ -355,12 +422,19 @@ func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHis
355 422
 				if err == nil {
356 423
 					redis.Set(key, his_advices_all, time.Second*60*60*18)
357 424
 				}
425
+			} else {
426
+				redis.Set(key, "null", time.Second*60*60*18)
358 427
 			}
359 428
 			return hisAdvices, nil
360 429
 		}
361 430
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
362
-		json.Unmarshal([]byte(his_advices_all), &hisAdvices)
363
-		return hisAdvices, nil
431
+		if his_advices_all == "null" {
432
+			return nil, nil
433
+		} else {
434
+			json.Unmarshal([]byte(his_advices_all), &hisAdvices)
435
+			return hisAdvices, nil
436
+		}
437
+
364 438
 	}
365 439
 }
366 440
 
@@ -462,12 +536,20 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
462 536
 				if err == nil {
463 537
 					redis.Set(key, patient_info_json, time.Second*60*60*18)
464 538
 				}
539
+			} else {
540
+				redis.Set(key, "null", time.Second*60*60*18)
465 541
 			}
466 542
 			return patient, nil
467 543
 		}
468 544
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
469
-		json.Unmarshal([]byte(patient_info_str), &patient)
470
-		return patient, nil
545
+
546
+		if patient_info_str == "null" {
547
+			return patient, nil
548
+		} else {
549
+			json.Unmarshal([]byte(patient_info_str), &patient)
550
+			return patient, nil
551
+		}
552
+
471 553
 	}
472 554
 }
473 555
 

+ 11 - 3
service/patientmanage_service.go View File

@@ -1575,6 +1575,9 @@ func GetLastPassWayAssessment(orgid int64, patientId int64) (models.XtPatientVas
1575 1575
 		err := XTReadDB().Model(&assessment).Where("user_org_id = ? and patient_id = ? and status =1 and user_status = 1", orgid, patientId).Order("start_time desc").Last(&assessment).Error
1576 1576
 		if err != nil {
1577 1577
 			if err == gorm.ErrRecordNotFound {
1578
+				if assessment.ID <= 0 {
1579
+					redis.Set(key, "pass_way_null", time.Second*60*60*18)
1580
+				}
1578 1581
 				return assessment, nil
1579 1582
 			} else {
1580 1583
 				return assessment, err
@@ -1588,14 +1591,19 @@ func GetLastPassWayAssessment(orgid int64, patientId int64) (models.XtPatientVas
1588 1591
 					return assessment, nil
1589 1592
 				}
1590 1593
 			} else {
1591
-				redis.Set(key, " ", time.Second*60*60*18)
1594
+				redis.Set(key, "pass_way_null", time.Second*60*60*18)
1592 1595
 				return assessment, nil
1593 1596
 			}
1594 1597
 			return assessment, nil
1595 1598
 		}
1596 1599
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1597
-		json.Unmarshal([]byte(pass_way_assessment_last_str), &assessment)
1598
-		return assessment, nil
1600
+		if pass_way_assessment_last_str == "pass_way_null" {
1601
+			return assessment, nil
1602
+		} else {
1603
+			json.Unmarshal([]byte(pass_way_assessment_last_str), &assessment)
1604
+			return assessment, nil
1605
+		}
1606
+
1599 1607
 	}
1600 1608
 }
1601 1609
 

+ 52 - 40
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -285,6 +285,9 @@ type AssessmentBeforeDislysisVM struct {
285 285
 	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`
286 286
 	UrineVolume                    float64 `gorm:"column:urine_volume" json:"urine_volume" form:"urine_volume"`
287 287
 	Edema                          string  `gorm:"column:edema" json:"edema" form:"edema"`
288
+	PreDialysisDrugs               string  `gorm:"column:pre_dialysis_drugs" json:"pre_dialysis_drugs" form:"pre_dialysis_drugs"`
289
+	Period                         int64   `gorm:"column:period" json:"period" form:"period"`
290
+	EstimatedFoodIntake            string  `gorm:"column:estimated_food_intake" json:"estimated_food_intake" form:"estimated_food_intake"`
288 291
 }
289 292
 
290 293
 func (AssessmentBeforeDislysisVM) TableName() string {
@@ -359,6 +362,14 @@ type AssessmentAfterDislysisVM struct {
359 362
 	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
360 363
 	SealingFluidSpecial             string  `gorm:"column:sealing_fluid_special" json:"sealing_fluid_special" form:"sealing_fluid_special"`
361 364
 	MachineRun                      string  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
365
+	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
366
+	Urr                             string  `gorm:"column:urr" json:"urr" form:"urr"`
367
+	Hypertenison                    int64   `gorm:"column:hypertenison" json:"hypertenison" form:"hypertenison"`
368
+	Hypopiesia                      int64   `gorm:"column:hypopiesia" json:"hypopiesia" form:"hypopiesia"`
369
+	LeaveOfficeMethod               int64   `gorm:"column:leave_office_method" json:"leave_office_method" form:"leave_office_method"`
370
+	Lapse                           int64   `gorm:"column:lapse" json:"lapse" form:"lapse"`
371
+	Consciousness                   int64   `gorm:"column:consciousness" json:"consciousness" form:"consciousness"`
372
+	Fallrisk                        int64   `gorm:"column:fallrisk" json:"fallrisk" form:"fallrisk"`
362 373
 }
363 374
 
364 375
 func (AssessmentAfterDislysisVM) TableName() string {
@@ -495,46 +506,47 @@ func (XtReceiveTreatmentAsses) TableName() string {
495 506
 }
496 507
 
497 508
 type MonitoringRecordVM struct {
498
-	ID                        int64   `gorm:"column:id" json:"id"`
499
-	PatientID                 int64   `gorm:"column:patient_id" json:"patient_id"`
500
-	MonitoringDate            int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
501
-	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time"`
502
-	PulseFrequency            float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
503
-	BreathingRate             float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
504
-	SystolicBloodPressure     float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
505
-	DiastolicBloodPressure    float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
506
-	BloodPressureType         int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
507
-	BloodFlowVolume           float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
508
-	VenousPressure            float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
509
-	VenousPressureType        int64   `gorm:"column:venous_pressure_type" json:"venous_pressure_type"`
510
-	ArterialPressure          float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
511
-	ArterialPressureType      int64   `gorm:"column:arterial_pressure_type" json:"arterial_pressure_type"`
512
-	TransmembranePressure     float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
513
-	TransmembranePressureType int64   `gorm:"column:transmembrane_pressure_type" json:"transmembrane_pressure_type"`
514
-	UltrafiltrationRate       float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
515
-	UltrafiltrationVolume     float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
516
-	SodiumConcentration       float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
517
-	DialysateTemperature      float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
518
-	Temperature               float64 `gorm:"column:temperature" json:"temperature"`
519
-	ReplacementRate           float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
520
-	DisplacementQuantity      float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
521
-	Ktv                       float64 `gorm:"column:ktv" json:"ktv"`
522
-	Symptom                   string  `gorm:"column:symptom" json:"symptom"`
523
-	Dispose                   string  `gorm:"column:dispose" json:"dispose"`
524
-	Result                    string  `gorm:"column:result" json:"result"`
525
-	MonitoringNurse           int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
526
-	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
527
-	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
528
-	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
529
-	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
530
-	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
531
-	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
532
-	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
533
-	AccumulatedBloodVolume    float64 `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
534
-	BloodTemperature          float64 `gorm:"column:blood_temperature" json:"blood_temperature" form:"blood_temperature"`
535
-	UreaMonitoring            float64 `gorm:"column:urea_monitoring" json:"urea_monitoring" form:"urea_monitoring"`
536
-	BloodThickness            float64 `gorm:"column:blood_thickness" json:"blood_thickness" form:"blood_thickness"`
537
-	BloodMonitor              float64 `gorm:"column:blood_monitor" json:"blood_monitor" form:"blood_monitor"`
509
+	ID                          int64   `gorm:"column:id" json:"id"`
510
+	PatientID                   int64   `gorm:"column:patient_id" json:"patient_id"`
511
+	MonitoringDate              int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
512
+	OperateTime                 int64   `gorm:"column:operate_time" json:"operate_time"`
513
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
514
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
515
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
516
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
517
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
518
+	BloodFlowVolume             float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
519
+	VenousPressure              float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
520
+	VenousPressureType          int64   `gorm:"column:venous_pressure_type" json:"venous_pressure_type"`
521
+	ArterialPressure            float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
522
+	ArterialPressureType        int64   `gorm:"column:arterial_pressure_type" json:"arterial_pressure_type"`
523
+	TransmembranePressure       float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
524
+	TransmembranePressureType   int64   `gorm:"column:transmembrane_pressure_type" json:"transmembrane_pressure_type"`
525
+	UltrafiltrationRate         float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
526
+	UltrafiltrationVolume       float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
527
+	SodiumConcentration         float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
528
+	DialysateTemperature        float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
529
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
530
+	ReplacementRate             float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
531
+	DisplacementQuantity        float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
532
+	Ktv                         float64 `gorm:"column:ktv" json:"ktv"`
533
+	Symptom                     string  `gorm:"column:symptom" json:"symptom"`
534
+	Dispose                     string  `gorm:"column:dispose" json:"dispose"`
535
+	Result                      string  `gorm:"column:result" json:"result"`
536
+	MonitoringNurse             int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
537
+	Conductivity                float64 `gorm:"column:conductivity" json:"conductivity"`
538
+	DisplacementFlowQuantity    float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
539
+	BloodOxygenSaturation       string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
540
+	Creator                     int64   `gorm:"column:creator" json:"creator" form:"creator"`
541
+	Modify                      int64   `gorm:"column:modify" json:"modify" form:"modify"`
542
+	Heparin                     float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
543
+	DialysateFlow               float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
544
+	AccumulatedBloodVolume      float64 `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
545
+	BloodTemperature            float64 `gorm:"column:blood_temperature" json:"blood_temperature" form:"blood_temperature"`
546
+	UreaMonitoring              float64 `gorm:"column:urea_monitoring" json:"urea_monitoring" form:"urea_monitoring"`
547
+	BloodThickness              float64 `gorm:"column:blood_thickness" json:"blood_thickness" form:"blood_thickness"`
548
+	BloodMonitor                float64 `gorm:"column:blood_monitor" json:"blood_monitor" form:"blood_monitor"`
549
+	BloodPressureMonitoringSite int64   `gorm:"column:blood_pressure_monitoring_site" json:"blood_pressure_monitoring_site" form:"blood_pressure_monitoring_site"`
538 550
 }
539 551
 
540 552
 func (MonitoringRecordVM) TableName() string {

+ 24 - 8
service/stock_service.go View File

@@ -2,11 +2,11 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"encoding/json"
5 6
 	"fmt"
6 7
 	"github.com/jinzhu/gorm"
7 8
 	"strconv"
8 9
 	"strings"
9
-	"encoding/json"
10 10
 	"time"
11 11
 )
12 12
 
@@ -2807,9 +2807,12 @@ func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
2807 2807
 
2808 2808
 	if len(stock_type_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2809 2809
 		err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3)", orgid).
2810
-		Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
2810
+			Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
2811 2811
 		if err != nil {
2812 2812
 			if err == gorm.ErrRecordNotFound {
2813
+				if len(goodstype) <= 0 {
2814
+					redis.Set(key, "sotck_type_null", time.Second*60*60*18)
2815
+				}
2813 2816
 				return nil, nil
2814 2817
 			} else {
2815 2818
 				return nil, err
@@ -2822,13 +2825,18 @@ func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
2822 2825
 					redis.Set(key, stock_type_str, time.Second*60*60*18)
2823 2826
 				}
2824 2827
 			} else {
2825
-				redis.Set(key, " ", time.Second*60*60*18)
2828
+				redis.Set(key, "sotck_type_null", time.Second*60*60*18)
2826 2829
 			}
2827 2830
 			return goodstype, nil
2828 2831
 		}
2829 2832
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2830
-		json.Unmarshal([]byte(stock_type_str), &goodstype)
2831
-		return goodstype, nil
2833
+		if stock_type_str == "sotck_type_null" {
2834
+			return goodstype, nil
2835
+		} else {
2836
+			json.Unmarshal([]byte(stock_type_str), &goodstype)
2837
+			return goodstype, nil
2838
+		}
2839
+
2832 2840
 	}
2833 2841
 }
2834 2842
 
@@ -2856,6 +2864,9 @@ func GetDialyStockOut(orgid int64, recordtime int64, patientId int64) (prepare [
2856 2864
 			if err == gorm.ErrRecordNotFound {
2857 2865
 				return nil, nil
2858 2866
 			} else {
2867
+				if len(prepare) <= 0 {
2868
+					redis.Set(key, "prepare_null", time.Second*60*60*18)
2869
+				}
2859 2870
 				return nil, err
2860 2871
 			}
2861 2872
 		} else {
@@ -2866,13 +2877,18 @@ func GetDialyStockOut(orgid int64, recordtime int64, patientId int64) (prepare [
2866 2877
 					redis.Set(key, dialy_stock_out_str, time.Second*60*60*18)
2867 2878
 				}
2868 2879
 			} else {
2869
-				redis.Set(key, " ", time.Second*60*60*18)
2880
+				redis.Set(key, "prepare_null", time.Second*60*60*18)
2870 2881
 			}
2871 2882
 			return prepare, nil
2872 2883
 		}
2873 2884
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2874
-		json.Unmarshal([]byte(dialy_stock_out_str), &prepare)
2875
-		return prepare, nil
2885
+		if dialy_stock_out_str == "prepare_null" {
2886
+			return prepare, nil
2887
+		} else {
2888
+			json.Unmarshal([]byte(dialy_stock_out_str), &prepare)
2889
+			return prepare, nil
2890
+		}
2891
+
2876 2892
 	}
2877 2893
 }
2878 2894