Selaa lähdekoodia

11月8日库存管理

XMLWAN 3 vuotta sitten
vanhempi
commit
91c829083c

+ 3 - 3
conf/app.conf Näytä tiedosto

@@ -226,10 +226,10 @@ writesgjpatientmysqlname = sgj_patient
226 226
 
227 227
 #redishost = 120.77.235.13
228 228
 #redishost = 112.74.16.180
229
-redishost = localhost
229
+redishost = kuyi6666.redis.rds.aliyuncs.com
230 230
 redisport = 6379
231
-redispasswrod = syh@#$%123456!
232
-redisdb = 0
231
+redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
232
+redisdb = 7
233 233
 
234 234
 niprocart =  83
235 235
 jms = 80

+ 136 - 65
controllers/dialysis_api_controller.go Näytä tiedosto

@@ -371,71 +371,6 @@ func (c *DialysisApiController) PostPrescription() {
371 371
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
372 372
 	}
373 373
 
374
-	//查询最近透析准备表里是否存在 透析器 灌流器
375
-
376
-	//splitStr := strings.Split(dialysis_dialyszers, ",")
377
-	//
378
-	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
379
-	//
380
-	//mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
381
-	//if len(mation)>0{
382
-	//  for _, item := range splitStr {
383
-	//    for _,it := range mation{
384
-	//      if(item == it.SpecificationName){
385
-	//
386
-	//        //查询最近一次的透析器
387
-	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
388
-	//
389
-	//        if errcode == gorm.ErrRecordNotFound{
390
-	//          //插入数据
391
-	//          prepare := models.DialysisBeforePrepare{
392
-	//            UserOrgId:  adminUserInfo.CurrentOrgId,
393
-	//            PatientId:  patient,
394
-	//            RecordDate: recordDate.Unix(),
395
-	//            GoodTypeId: it.GoodTypeId,
396
-	//            GoodId:     it.ID,
397
-	//            Count:      1,
398
-	//            Ctime:      time.Now().Unix(),
399
-	//            Creater:    adminUserInfo.AdminUser.Id,
400
-	//            Status:1,
401
-	//
402
-	//          }
403
-	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
404
-	//          fmt.Println("",errcode)
405
-	//        }
406
-	//      }
407
-	//    }
408
-	//
409
-	//  }
410
-	//
411
-	//  for _, item := range splitIrrigation {
412
-	//    for _,it := range mation{
413
-	//      if(item == it.SpecificationName){
414
-	//        //查询最近一次的透析器
415
-	//        _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
416
-	//        if errcode == gorm.ErrRecordNotFound{
417
-	//          //插入数据
418
-	//          prepare := models.DialysisBeforePrepare{
419
-	//            UserOrgId:  adminUserInfo.CurrentOrgId,
420
-	//            PatientId:  patient,
421
-	//            RecordDate: recordDate.Unix(),
422
-	//            GoodTypeId: it.GoodTypeId,
423
-	//            GoodId:     it.ID,
424
-	//            Count:      1,
425
-	//            Ctime:      time.Now().Unix(),
426
-	//            Creater:    adminUserInfo.AdminUser.Id,
427
-	//            Status:1,
428
-	//
429
-	//          }
430
-	//          errcode := service.CreateDialysisBeforePrepareOne(&prepare)
431
-	//          fmt.Println(errcode)
432
-	//      }
433
-	//      }
434
-	//    }
435
-	//  }
436
-	//
437
-	//}
438
-
439 374
 	if appRole.UserType == 2 || appRole.UserType == 1 {
440 375
 		prescription.PrescriptionDoctor = appRole.AdminUserId
441 376
 	}
@@ -448,6 +383,12 @@ func (c *DialysisApiController) PostPrescription() {
448 383
 
449 384
 		prescription.Creater = adminUserInfo.AdminUser.Id
450 385
 		err := service.AddSigleRecord(&prescription)
386
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
387
+		redis := service.RedisClient()
388
+		defer redis.Close()
389
+		//清空key 值
390
+		redis.Set(key, "", time.Second)
391
+
451 392
 		if err == nil {
452 393
 			updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
453 394
 			if updateErr != nil {
@@ -501,6 +442,11 @@ func (c *DialysisApiController) PostPrescription() {
501 442
 		prescription.ID = dialysisPrescription.ID
502 443
 
503 444
 		updateErr := service.UpDateDialysisPrescription(&prescription)
445
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
446
+		redis := service.RedisClient()
447
+		defer redis.Close()
448
+		//清空key 值
449
+		redis.Set(key, "", time.Second)
504 450
 		if updateErr == nil {
505 451
 			updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
506 452
 			if updateErr != nil {
@@ -902,6 +848,16 @@ func (c *DialysisApiController) PostSoulution() {
902 848
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
903 849
 	}
904 850
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
851
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
852
+	redis := service.RedisClient()
853
+
854
+	//清空key 值
855
+	redis.Set(key, "", time.Second)
856
+
857
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
858
+	//清空key 值
859
+	redis.Set(keyOne, "", time.Second)
860
+	defer redis.Close()
905 861
 	if err == nil {
906 862
 		c.ServeSuccessJSON(map[string]interface{}{
907 863
 			"solution":     &solution,
@@ -1001,6 +957,11 @@ func (c *DialysisApiController) PostDouleCheck() {
1001 957
 		doubleCheck.Modifier = modifier
1002 958
 
1003 959
 		err := service.AddSigleDoubleCheck(&doubleCheck)
960
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
961
+		redis := service.RedisClient()
962
+		defer redis.Close()
963
+		//清空key 值
964
+		redis.Set(key, "", time.Second)
1004 965
 		if err == nil {
1005 966
 			c.ServeSuccessJSON(map[string]interface{}{
1006 967
 				"doubleCheck": doubleCheck,
@@ -1288,6 +1249,11 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1288 1249
 		assessment.AssessmentDate = recordDate.Unix()
1289 1250
 
1290 1251
 		err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
1252
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1253
+		redis := service.RedisClient()
1254
+		defer redis.Close()
1255
+		//清空key 值
1256
+		redis.Set(key, "", time.Second)
1291 1257
 	}
1292 1258
 
1293 1259
 	if err != nil {
@@ -1472,6 +1438,11 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1472 1438
 		}
1473 1439
 
1474 1440
 		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
1441
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1442
+		redis := service.RedisClient()
1443
+		defer redis.Close()
1444
+		//清空key 值
1445
+		redis.Set(key, "", time.Second)
1475 1446
 		if err == nil {
1476 1447
 			c.ServeSuccessJSON(map[string]interface{}{
1477 1448
 				"assessmentBeforeDislysis": &assessmentBeforeDislysis,
@@ -1755,6 +1726,11 @@ func (c *DialysisApiController) PostTreatmentSummary() {
1755 1726
 	if tempTreatmentSummary.ID == 0 { //新增
1756 1727
 		treatmentSummary.Creater = adminUserInfo.AdminUser.Id
1757 1728
 		err := service.AddSigleSummaryRecord(&treatmentSummary)
1729
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
1730
+		redis := service.RedisClient()
1731
+		defer redis.Close()
1732
+		//清空key 值
1733
+		redis.Set(key, "", time.Second)
1758 1734
 		if err == nil {
1759 1735
 			c.ServeSuccessJSON(map[string]interface{}{
1760 1736
 				"summary": treatmentSummary,
@@ -1783,6 +1759,11 @@ func (c *DialysisApiController) PostTreatmentSummary() {
1783 1759
 		treatmentSummary.Modifier = adminUserInfo.AdminUser.Id
1784 1760
 		treatmentSummary.ID = tempTreatmentSummary.ID
1785 1761
 		err := service.UpdateSummeRecord(&treatmentSummary)
1762
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
1763
+		//清空key 值
1764
+		redis := service.RedisClient()
1765
+		redis.Set(key, "", time.Second)
1766
+		defer redis.Close()
1786 1767
 		if err == nil {
1787 1768
 			c.ServeSuccessJSON(map[string]interface{}{
1788 1769
 				"summary": treatmentSummary,
@@ -1828,6 +1809,96 @@ func (c *DialysisApiController) GetDialysisWatch() {
1828 1809
 	adminUserInfo := c.GetAdminUserInfo()
1829 1810
 	if len(keywords) > 0 {
1830 1811
 		dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
1812
+
1813
+		//获取所有床位号
1814
+		numberList, _ := service.GetAllDeviceNumberByList(adminUserInfo.CurrentOrgId)
1815
+
1816
+		//获取所有分区
1817
+		//zoneList, _ := service.GetAllZoneByList(adminUserInfo.CurrentOrgId)
1818
+		//获取透析处方
1819
+		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1820
+		//获取透前评估
1821
+		assessmentBefores, _ := service.GetAllAssessmentBeforesByListThree(adminUserInfo.CurrentOrgId, startTime)
1822
+		//获取上机
1823
+		dialysisOrders, _ := service.GetAllDialysisOrdersByListThree(adminUserInfo.CurrentOrgId, startTime)
1824
+		//获取透后
1825
+		AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListThree(adminUserInfo.CurrentOrgId, startTime)
1826
+
1827
+		//获取透后监测
1828
+		monitorlist, _ := service.GetAllMonitorListThree(adminUserInfo.CurrentOrgId, startTime)
1829
+
1830
+		//获取所有的患者
1831
+		patients, _ := service.GetAllPatientListByListThree(adminUserInfo.CurrentOrgId)
1832
+
1833
+		//获取所有透析模式
1834
+		treatments, _ := service.GetAllTreatModeByList(adminUserInfo.CurrentOrgId)
1835
+
1836
+		for key, scheduals := range dialysisSchedule {
1837
+			// 获取患者信息
1838
+			for _, patient := range patients {
1839
+				if scheduals.PatientId == patient.ID {
1840
+					dialysisSchedule[key].MonitorPatients = patient
1841
+					break
1842
+				}
1843
+			}
1844
+			// 床位信息
1845
+			for _, device := range numberList {
1846
+				if scheduals.BedId == device.ID {
1847
+					dialysisSchedule[key].DeviceNumber = device
1848
+					break
1849
+				}
1850
+			}
1851
+
1852
+			// 医嘱信息
1853
+			for _, prescription := range prescriptions {
1854
+				if scheduals.PatientId == prescription.PatientId {
1855
+					dialysisSchedule[key].Prescription = prescription
1856
+					break
1857
+				}
1858
+			}
1859
+
1860
+			// 透前评估
1861
+			for _, assessmentBefore := range assessmentBefores {
1862
+				if scheduals.PatientId == assessmentBefore.PatientId {
1863
+					dialysisSchedule[key].AssessmentBeforeDislysis = assessmentBefore
1864
+					break
1865
+				}
1866
+			}
1867
+
1868
+			// 透析上下机
1869
+			for _, dialysisOrder := range dialysisOrders {
1870
+				if scheduals.PatientId == dialysisOrder.PatientId {
1871
+					dialysisSchedule[key].DialysisOrder = dialysisOrder
1872
+					break
1873
+				}
1874
+			}
1875
+
1876
+			records := make([]*models.MonitoringRecord, 0)
1877
+			// 透析监测
1878
+			for _, it := range monitorlist {
1879
+				records := append(records, it)
1880
+				if scheduals.PatientId == it.PatientId {
1881
+					dialysisSchedule[key].MonitoringRecord = records
1882
+				}
1883
+			}
1884
+
1885
+			// 透后评估
1886
+			for _, afterDislysis := range AssessmentAfterDislysis {
1887
+				if scheduals.PatientId == afterDislysis.PatientId {
1888
+					dialysisSchedule[key].AssessmentAfterDislysis = afterDislysis
1889
+					break
1890
+				}
1891
+			}
1892
+
1893
+			//透析模式
1894
+			for _, treatment := range treatments {
1895
+				if scheduals.ModeId == treatment.ID {
1896
+					dialysisSchedule[key].TreatmentMode = treatment
1897
+					break
1898
+				}
1899
+			}
1900
+		}
1901
+		//获取所有床位号
1831 1902
 		if err == nil {
1832 1903
 			c.ServeSuccessJSON(map[string]interface{}{
1833 1904
 				"schedule": dialysisSchedule,

+ 28 - 18
controllers/dialysis_record_api_controller.go Näytä tiedosto

@@ -222,12 +222,12 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
222 222
 		return
223 223
 	}
224 224
 
225
-	dialysisPrescribe, getDialysisPrescribeErr := service.GetDialysisPrescribe(adminInfo.CurrentOrgId, patientID, date.Unix())
226
-	if getDialysisPrescribeErr != nil {
227
-		this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
228
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
229
-		return
230
-	}
225
+	dialysisPrescribe, _ := service.GetDialysisPrescribe(adminInfo.CurrentOrgId, patientID, date.Unix())
226
+	//if getDialysisPrescribeErr != nil {
227
+	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
228
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
229
+	//	return
230
+	//}
231 231
 	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
232 232
 	//dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolutionOne(adminInfo.CurrentOrgId, schedual.ModeId)
233 233
 
@@ -237,19 +237,19 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
237 237
 		return
238 238
 	}
239 239
 
240
-	lastDialysisPrescribe, getDialysisPrescribeErr := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
241
-	if getDialysisPrescribeErr != nil {
242
-		this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
243
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
244
-		return
245
-	}
240
+	lastDialysisPrescribe, _ := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
241
+	//if getDialysisPrescribeErr != nil {
242
+	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
243
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
244
+	//	return
245
+	//}
246 246
 
247
-	systemDialysisPrescribe, getSystemDialysisPrescribeErr := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
248
-	if getSystemDialysisPrescribeErr != nil {
249
-		this.ErrorLog("获取系统透析处方失败:%v", getSystemDialysisPrescribeErr)
250
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
251
-		return
252
-	}
247
+	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
248
+	//if getSystemDialysisPrescribeErr != nil {
249
+	//	this.ErrorLog("获取系统透析处方失败:%v", getSystemDialysisPrescribeErr)
250
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
251
+	//	return
252
+	//}
253 253
 
254 254
 	if getLPEErr != nil {
255 255
 		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
@@ -481,6 +481,11 @@ func (this *DialysisRecordAPIController) EditMonitor() {
481 481
 			BloodMonitor:                monitorParam.BloodMonitor,
482 482
 		}
483 483
 		createErr := service.CreateMonitor(&monitor)
484
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
485
+		redis := service.RedisClient()
486
+		defer redis.Close()
487
+		//清空key 值
488
+		redis.Set(key, "", time.Second)
484 489
 		if createErr != nil {
485 490
 			this.ErrorLog("创建监测记录失败:%v", createErr)
486 491
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -762,6 +767,11 @@ func (this *DialysisRecordAPIController) StartDialysis() {
762 767
 	}
763 768
 
764 769
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
770
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
771
+	redis := service.RedisClient()
772
+	defer redis.Close()
773
+	//清空key 值
774
+	redis.Set(key, "", time.Second)
765 775
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
766 776
 
767 777
 	if createErr != nil {

+ 43 - 0
controllers/doctors_api_controller.go Näytä tiedosto

@@ -81,10 +81,53 @@ func (c *DoctorsApiController) ScheduleAdvices() {
81 81
 	orgID := adminUserInfo.CurrentOrgId
82 82
 
83 83
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
84
+
84 85
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
85 86
 
86 87
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
87 88
 
89
+	//获取所有的患者
90
+	patients, _ := service.GetAllPatientListByListTwo(orgID)
91
+
92
+	//获取所有床位
93
+	numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
94
+
95
+	//获取透析处方
96
+	prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
97
+
98
+	//获取上机
99
+	dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
100
+	for key, item := range project {
101
+		for _, patient := range patients {
102
+			if item.PatientId == patient.ID {
103
+				project[key].SchedualPatient = patient
104
+				break
105
+			}
106
+		}
107
+		// 获取床位信息
108
+		for _, it := range numberList {
109
+			if item.BedId == it.ID {
110
+				project[key].DeviceNumber = it
111
+				break
112
+			}
113
+		}
114
+
115
+		// 获取处方
116
+		for _, it := range prescriptions {
117
+			if item.PatientId == it.PatientId {
118
+				project[key].Prescription = it
119
+				break
120
+			}
121
+		}
122
+
123
+		//获取上机
124
+		for _, it := range dialysisOrders {
125
+			if item.PatientId == it.PatientId {
126
+				project[key].DialysisOrder = it
127
+				break
128
+			}
129
+		}
130
+	}
88 131
 	config, _ := service.GetHisDoctorConfig(orgID)
89 132
 	project_config, _ := service.GetHisProjectConfig(orgID)
90 133
 

+ 120 - 85
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

@@ -88,11 +88,12 @@ func (this *DialysisAPIController) Scheduals() {
88 88
 
89 89
 	// cur_date := time.Now().Format("2006-01-02")
90 90
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
91
-	fmt.Println("keyhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", key)
91
+
92 92
 	scheduals_json_str, _ := redis.Get(key).Result()
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
 		if err != nil {
97 98
 			this.ErrorLog("获取排班信息失败:%v", err)
98 99
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -104,6 +105,7 @@ func (this *DialysisAPIController) Scheduals() {
104 105
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
105 106
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
106 107
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
108
+				fmt.Println("hh23322332323232323233223", dialysisOrders)
107 109
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
108 110
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
109 111
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
@@ -325,80 +327,82 @@ func (this *DialysisAPIController) DialysisRecord() {
325 327
 	adminInfo := this.GetMobileAdminUserInfo()
326 328
 
327 329
 	// 先走redis,没有走数据库
328
-	patient, getPatientErr := service.FindPatientByIdWithDiseases(adminInfo.Org.Id, patientID)
329
-	if getPatientErr != nil {
330
-		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
331
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
332
-		return
333
-	} else if patient.ID == 0 {
334
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
335
-		return
336
-	}
330
+	patient, _ := service.FindPatientByIdWithDiseases(adminInfo.Org.Id, patientID)
331
+
332
+	//if getPatientErr != nil {
333
+	//	this.ErrorLog("获取患者信息失败:%v", getPatientErr)
334
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
335
+	//	return
336
+	//} else if patient.ID == 0 {
337
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
338
+	//	return
339
+	//}
337 340
 
338 341
 	// 先走redis,没有走数据库
339
-	schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
342
+	schedual, _ := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
340 343
 
341
-	if getSchedualErr != nil {
342
-		this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
343
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
344
-		return
345
-	}
344
+	//if getSchedualErr != nil {
345
+	//	this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
346
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
347
+	//	return
348
+	//}
346 349
 
347 350
 	// 先走redis,没有走数据库
348
-	receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
349
-	if getRTARErr != nil {
350
-		this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
351
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
352
-		return
353
-	}
351
+	receiverTreatmentAccess, _ := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
352
+	//if getRTARErr != nil {
353
+	//	this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
354
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
355
+	//	return
356
+	//}
354 357
 
355 358
 	// // 先走redis,没有走数据库
356
-	predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
357
-	if getPEErr != nil {
358
-		this.ErrorLog("获取透前评估失败:%v", getPEErr)
359
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
360
-		return
361
-	}
359
+	predialysisEvaluation, _ := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
360
+	//if getPEErr != nil {
361
+	//	this.ErrorLog("获取透前评估失败:%v", getPEErr)
362
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
363
+	//	return
364
+	//}
362 365
 
363 366
 	// // 先走redis,没有走数据库
364
-	lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
365
-	if getLPEErr != nil {
366
-		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
367
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
368
-		return
369
-	}
367
+	lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
368
+	//if getLPEErr != nil {
369
+	//	this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
370
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
371
+	//	return
372
+	//}
370 373
 
371 374
 	// // 先走redis,没有走数据库
372
-	doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
373
-	if getDoctorAdvicesErr != nil {
374
-		this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
375
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
376
-		return
377
-	}
375
+	doctorAdvices, _ := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
376
+
377
+	//if getDoctorAdvicesErr != nil {
378
+	//	this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
379
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
380
+	//	return
381
+	//}
378 382
 
379 383
 	// // 先走redis,没有走数据库
380
-	dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
381
-	if getDialysisOrderErr != nil {
382
-		this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
383
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
384
-		return
385
-	}
384
+	dialysisOrder, _ := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
385
+	//if getDialysisOrderErr != nil {
386
+	//	this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
387
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
388
+	//	return
389
+	//}
386 390
 
387 391
 	// // 先走redis,没有走数据库
388
-	doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
389
-	if getDoubleCheckErr != nil {
390
-		this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
391
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392
-		return
393
-	}
392
+	doubleCheck, _ := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
393
+	//if getDoubleCheckErr != nil {
394
+	//	this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
395
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
396
+	//	return
397
+	//}
394 398
 
395 399
 	// // 先走redis,没有走数据库
396
-	monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
397
-	if getMonitorRecordsErr != nil {
398
-		this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
399
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
400
-		return
401
-	}
400
+	monitorRecords, _ := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
401
+	//if getMonitorRecordsErr != nil {
402
+	//	this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
403
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
404
+	//	return
405
+	//}
402 406
 	var lastMonitorRecord *models.MonitoringRecord
403 407
 
404 408
 	// // 先走redis,没有走数据库
@@ -410,28 +414,28 @@ func (this *DialysisAPIController) DialysisRecord() {
410 414
 	}
411 415
 
412 416
 	// // 先走redis,没有走数据库
413
-	assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
414
-	if getAADErr != nil {
415
-		this.ErrorLog("获取透后评估失败:%v", getAADErr)
416
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
417
-		return
418
-	}
417
+	assessmentAfterDislysis, _ := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
418
+	//if getAADErr != nil {
419
+	//	this.ErrorLog("获取透后评估失败:%v", getAADErr)
420
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
421
+	//	return
422
+	//}
419 423
 
420 424
 	// // 先走redis,没有走数据库
421
-	lastAssessmentAfterDislysis, getLAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
422
-	if getLAADErr != nil {
423
-		this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
424
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
425
-		return
426
-	}
425
+	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
426
+	//if getLAADErr != nil {
427
+	//	this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
428
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
429
+	//	return
430
+	//}
427 431
 
428 432
 	// // 先走redis,没有走数据库
429
-	treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
430
-	if getTreatmentSummaryErr != nil {
431
-		this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
432
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
433
-		return
434
-	}
433
+	treatmentSummary, _ := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
434
+	//if getTreatmentSummaryErr != nil {
435
+	//	this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
436
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
437
+	//	return
438
+	//}
435 439
 
436 440
 	// // 先走redis,没有走数据库
437 441
 	dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
@@ -506,12 +510,12 @@ func (this *DialysisAPIController) DialysisRecord() {
506 510
 	// }
507 511
 
508 512
 	// 先走redis,没有走数据库
509
-	lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
510
-	if getDryErr != nil {
511
-		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
512
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
513
-		return
514
-	}
513
+	lastDryWeightDislysis, _ := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
514
+	//if getDryErr != nil {
515
+	//	this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
516
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
517
+	//	return
518
+	//}
515 519
 
516 520
 	// //headNurses, _ := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminInfo.Org.Id, adminInfo.App.Id, models.SpecialPermissionTypeHeadNurse)
517 521
 
@@ -525,7 +529,6 @@ func (this *DialysisAPIController) DialysisRecord() {
525 529
 
526 530
 	//consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patientID, date.Unix())
527 531
 	//lastConsumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patientID, date.Unix())
528
-
529 532
 	returnData := map[string]interface{}{
530 533
 		"patient":                        patient,
531 534
 		"schedual":                       schedual,
@@ -641,6 +644,11 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
641 644
 	if treatmentSummary.ID == 0 { //新增
642 645
 		summary.Creater = adminUserInfo.AdminUser.Id
643 646
 		service.AddSigleSummaryRecord(&summary)
647
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
648
+		redis := service.RedisClient()
649
+		defer redis.Close()
650
+		//清空key 值
651
+		redis.Set(key, "", time.Second)
644 652
 		c.ServeSuccessJSON(map[string]interface{}{
645 653
 			"summary": summary,
646 654
 		})
@@ -758,6 +766,11 @@ func (c *DialysisAPIController) PostDoubleCheck() {
758 766
 		doubleCheck.Modifier = modifier
759 767
 
760 768
 		err := service.AddSigleDoubleCheck(&doubleCheck)
769
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
770
+		redis := service.RedisClient()
771
+		defer redis.Close()
772
+		//清空key 值
773
+		redis.Set(key, "", time.Second)
761 774
 		if err == nil {
762 775
 			c.ServeSuccessJSON(map[string]interface{}{
763 776
 				"doubleCheck": &doubleCheck,
@@ -772,6 +785,11 @@ func (c *DialysisAPIController) PostDoubleCheck() {
772 785
 		doubleCheck.CreatedTime = check.CreatedTime
773 786
 		doubleCheck.ID = check.ID
774 787
 		err := service.UpdateDoubleCheck(&doubleCheck)
788
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
789
+		redis := service.RedisClient()
790
+		defer redis.Close()
791
+		//清空key 值
792
+		redis.Set(key, "", time.Second)
775 793
 		if err == nil {
776 794
 			c.ServeSuccessJSON(map[string]interface{}{
777 795
 				"doubleCheck": &doubleCheck,
@@ -1100,6 +1118,12 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1100 1118
 		}
1101 1119
 
1102 1120
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1121
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1122
+		redis := service.RedisClient()
1123
+		defer redis.Close()
1124
+		//清空key 值
1125
+		redis.Set(key, "", time.Second)
1126
+
1103 1127
 		if err == nil {
1104 1128
 			c.ServeSuccessJSON(map[string]interface{}{
1105 1129
 				"assessmentAfterDislysis": assessmentAfterDislysis,
@@ -1840,7 +1864,7 @@ func (this *DialysisAPIController) StartDialysis() {
1840 1864
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1841 1865
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1842 1866
 	zone_id, _ := this.GetInt64("zone_id")
1843
-	fmt.Println("zone23333232323232232332232323", zone_id)
1867
+
1844 1868
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
1845 1869
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1846 1870
 		return
@@ -2017,6 +2041,12 @@ func (this *DialysisAPIController) StartDialysis() {
2017 2041
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2018 2042
 	if errorscode == gorm.ErrRecordNotFound {
2019 2043
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2044
+
2045
+		redis := service.RedisClient()
2046
+		defer redis.Close()
2047
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2048
+		//清空key 值
2049
+		redis.Set(keyOne, "", time.Second)
2020 2050
 		if createErr != nil {
2021 2051
 			this.ErrorLog("上机失败:%v", createErr)
2022 2052
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2816,6 +2846,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2816 2846
 	}
2817 2847
 
2818 2848
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
2849
+
2819 2850
 	if updateErr != nil {
2820 2851
 		this.ErrorLog("修改上机失败:%v", updateErr)
2821 2852
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -3309,7 +3340,11 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
3309 3340
 
3310 3341
 	if len(advices) > 0 {
3311 3342
 		list, err := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, groupNo)
3312
-
3343
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
3344
+		redis := service.RedisClient()
3345
+		defer redis.Close()
3346
+		//清空key 值
3347
+		redis.Set(key, "", time.Second)
3313 3348
 		if err != nil {
3314 3349
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3315 3350
 			return

+ 11 - 0
controllers/mobile_api_controllers/dialysis_api_controller_extend.go Näytä tiedosto

@@ -7,6 +7,7 @@ import (
7 7
 	"XT_New/utils"
8 8
 	"fmt"
9 9
 	"github.com/jinzhu/gorm"
10
+	"strconv"
10 11
 	"time"
11 12
 )
12 13
 
@@ -167,6 +168,11 @@ func (this *DialysisAPIController) AddMonitorRecord() {
167 168
 	}
168 169
 
169 170
 	err := service.CreateMonitor(&record)
171
+	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
172
+	redis := service.RedisClient()
173
+	defer redis.Close()
174
+	//清空key 值
175
+	redis.Set(key, "", time.Second)
170 176
 	if err != nil {
171 177
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
172 178
 		return
@@ -324,6 +330,11 @@ func (this *DialysisAPIController) EditMonitorRecord() {
324 330
 	monitor.BloodThickness = blood_thickness
325 331
 	monitor.BloodTemperature = blood_temperature
326 332
 	err = service.UpdateMonitor(monitor)
333
+	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
334
+	redis := service.RedisClient()
335
+	defer redis.Close()
336
+	//清空key 值
337
+	redis.Set(key, "", time.Second)
327 338
 	if err != nil {
328 339
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
329 340
 		return

+ 78 - 2
controllers/mobile_api_controllers/doctor_advice_api_controller.go Näytä tiedosto

@@ -5,7 +5,6 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
-	"fmt"
9 8
 )
10 9
 
11 10
 type DoctorAdviceAPIController struct {
@@ -38,12 +37,89 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
38 37
 	adminInfo := this.GetMobileAdminUserInfo()
39 38
 	orgID := adminInfo.Org.Id
40 39
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
40
+	//获取所有的患者
41
+	blood_patients, _ := service.GetAllPatientListByListTwo(orgID)
42
+	//获取透析处方
43
+	blood_prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
44
+	//获取上机
45
+	blood_dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
46
+
47
+	for key, schedule := range scheduals {
48
+		for _, patient := range blood_patients {
49
+			if schedule.PatientId == patient.ID {
50
+				scheduals[key].SchedualPatient = patient
51
+				break
52
+			}
53
+		}
54
+
55
+		for _, prescription := range blood_prescriptions {
56
+			if schedule.PatientId == prescription.PatientId {
57
+				scheduals[key].Prescription = prescription
58
+				break
59
+			}
60
+		}
61
+
62
+		//获取上机
63
+		for _, dialysisorder := range blood_dialysisOrders {
64
+			if schedule.PatientId == dialysisorder.PatientId {
65
+				scheduals[key].DialysisOrder = dialysisorder
66
+				break
67
+			}
68
+		}
69
+
70
+	}
71
+
41 72
 	config, _ := service.GetHisDoctorConfig(orgID)
42 73
 	project_config, _ := service.GetHisProjectConfig(orgID)
43
-	fmt.Println("project_config23223232323", project_config)
74
+
44 75
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
45 76
 		//获取his医嘱数据
46 77
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
78
+
79
+		//获取所有的患者
80
+		patients, _ := service.GetAllPatientListByListTwo(orgID)
81
+
82
+		//获取所有床位
83
+		numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
84
+
85
+		//获取透析处方
86
+		prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
87
+
88
+		//获取上机
89
+		dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
90
+
91
+		for key, item := range project {
92
+			for _, patient := range patients {
93
+				if item.PatientId == patient.ID {
94
+					project[key].SchedualPatient = patient
95
+					break
96
+				}
97
+			}
98
+			// 获取床位信息
99
+			for _, it := range numberList {
100
+				if item.BedId == it.ID {
101
+					project[key].DeviceNumber = it
102
+					break
103
+				}
104
+			}
105
+
106
+			// 获取处方
107
+			for _, it := range prescriptions {
108
+				if item.PatientId == it.PatientId {
109
+					project[key].Prescription = it
110
+					break
111
+				}
112
+			}
113
+
114
+			//获取上机
115
+			for _, it := range dialysisOrders {
116
+				if item.PatientId == it.PatientId {
117
+					project[key].DialysisOrder = it
118
+					break
119
+				}
120
+			}
121
+		}
122
+
47 123
 		hisAdvices, _ := service.GetHisDoctorAdvicesTwo(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
48 124
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
49 125
 		if err != nil {

+ 112 - 0
controllers/mobile_api_controllers/patient_api_controller.go Näytä tiedosto

@@ -240,6 +240,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
240 240
 	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
241 241
 
242 242
 	err := service.CreateDoctorAdvice(&advice)
243
+
243 244
 	if err != nil {
244 245
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
245 246
 		return
@@ -1075,6 +1076,7 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1075 1076
 			UpdatedTime:   time.Now().Unix(),
1076 1077
 		}
1077 1078
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1079
+
1078 1080
 	}
1079 1081
 	if err != nil {
1080 1082
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
@@ -1544,6 +1546,11 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1544 1546
 	// }
1545 1547
 
1546 1548
 	err = service.UpadatePredialysisEvaluation(&evaluation)
1549
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
1550
+	redis := service.RedisClient()
1551
+	defer redis.Close()
1552
+	//清空key 值
1553
+	redis.Set(key, "", time.Second)
1547 1554
 	if err != nil {
1548 1555
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1549 1556
 		return
@@ -2508,6 +2515,106 @@ func (c *PatientApiController) GetPatientMonitor() {
2508 2515
 	adminInfo := c.GetMobileAdminUserInfo()
2509 2516
 	orgID := adminInfo.Org.Id
2510 2517
 	monitor, err := service.GetMonitorRecord(orgID, theStartTime, partition, patient_id)
2518
+	if err != nil {
2519
+		c.ErrorLog("获取排班信息失败:%v", err)
2520
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2521
+	} else {
2522
+		if len(monitor) > 0 {
2523
+			//获取所有床位
2524
+			numberList, _ := service.GetAllDeviceNumberByList(orgID)
2525
+			//获取所有分区
2526
+			zoneList, _ := service.GetAllZoneByList(orgID)
2527
+			//获取透析处方
2528
+			prescriptions, _ := service.GetAllPrescriptionByList(orgID, theStartTime)
2529
+			//获取透前评估
2530
+			assessmentBefores, _ := service.GetAllAssessmentBeforesByListOne(orgID, theStartTime)
2531
+			//获取上机
2532
+			dialysisOrders, _ := service.GetAllDialysisOrdersByListOne(orgID, theStartTime)
2533
+			//获取透后
2534
+			AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListOne(orgID, theStartTime)
2535
+
2536
+			//获取透后监测
2537
+			monitorlist, _ := service.GetAllMonitorList(orgID, theStartTime)
2538
+
2539
+			//获取所有的患者
2540
+			patients, _ := service.GetAllPatientListByListOne(orgID)
2541
+
2542
+			//获取所有透析模式
2543
+			treatments, _ := service.GetAllTreatModeByList(orgID)
2544
+
2545
+			for key, item := range monitor {
2546
+				// 获取床位信息
2547
+				for _, it := range numberList {
2548
+					if item.BedId == it.ID {
2549
+						monitor[key].DeviceNumber = it
2550
+						break
2551
+					}
2552
+				}
2553
+
2554
+				//获取分区信息
2555
+				for _, it := range zoneList {
2556
+					if item.PartitionId == it.ID {
2557
+						monitor[key].DeviceZone = it
2558
+					}
2559
+				}
2560
+
2561
+				for _, prescription := range prescriptions {
2562
+					if item.PatientId == prescription.PatientId {
2563
+						monitor[key].Prescription = prescription
2564
+						break
2565
+					}
2566
+				}
2567
+
2568
+				// 透前评估
2569
+				for _, assessmentBefore := range assessmentBefores {
2570
+					if item.PatientId == assessmentBefore.PatientId {
2571
+						monitor[key].AssessmentBeforeDislysis = assessmentBefore
2572
+						break
2573
+					}
2574
+				}
2575
+
2576
+				// 透析上下机
2577
+				for _, dialysisOrder := range dialysisOrders {
2578
+					if item.PatientId == dialysisOrder.PatientId {
2579
+						monitor[key].DialysisOrder = dialysisOrder
2580
+						break
2581
+					}
2582
+				}
2583
+
2584
+				// 治疗小节
2585
+				for _, afterDislysis := range AssessmentAfterDislysis {
2586
+					if item.PatientId == afterDislysis.PatientId {
2587
+						monitor[key].AssessmentAfterDislysis = afterDislysis
2588
+						break
2589
+					}
2590
+				}
2591
+				records := make([]*models.VMMonitoringRecord, 0)
2592
+				// 透析监测
2593
+				for _, it := range monitorlist {
2594
+					records := append(records, it)
2595
+					if item.PatientId == it.PatientId {
2596
+						monitor[key].MonitoringRecord = records
2597
+					}
2598
+				}
2599
+
2600
+				for _, patient := range patients {
2601
+					if item.PatientId == patient.ID {
2602
+						monitor[key].MonitorPatients = patient
2603
+						break
2604
+					}
2605
+				}
2606
+
2607
+				for _, treatment := range treatments {
2608
+					if item.ModeId == treatment.ID {
2609
+						monitor[key].TreatmentMode = treatment
2610
+						break
2611
+					}
2612
+				}
2613
+			}
2614
+		}
2615
+
2616
+	}
2617
+
2511 2618
 	//获取患者的透析次数
2512 2619
 	count, err := service.GetDialysisCount(orgID, partition)
2513 2620
 
@@ -2961,6 +3068,11 @@ func (c *PatientApiController) CreateGroupAdvice() {
2961 3068
 		}
2962 3069
 
2963 3070
 		newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
3071
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
3072
+		redis := service.RedisClient()
3073
+		defer redis.Close()
3074
+		//清空key 值
3075
+		redis.Set(key, "", time.Second)
2964 3076
 		if createErr != nil {
2965 3077
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
2966 3078
 			return

+ 1 - 0
controllers/new_mobile_api_controllers/new_manage_api_controller.go Näytä tiedosto

@@ -21,6 +21,7 @@ func (this *NewManageApiController) GetEquitAutoInfo() {
21 21
 	adminUser := this.GetMobileAdminUserInfo()
22 22
 	orgid := adminUser.Org.Id
23 23
 	remander, err := service.GetRemanderData(orgid)
24
+
24 25
 	if err != nil {
25 26
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
26 27
 		return

+ 1 - 1
main.go Näytä tiedosto

@@ -18,6 +18,6 @@ func main() {
18 18
 	//service.BeginAutoCreateStaffScheduleJob()
19 19
 	//service.BeginAutoCreateDrugJob()
20 20
 	//service.BeginAutoCreateStockJob()
21
-	beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60
21
+	//beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 6000
22 22
 	beego.Run()
23 23
 }

+ 9 - 9
models/dialysis.go Näytä tiedosto

@@ -180,16 +180,16 @@ type DialysisSchedule struct {
180 180
 	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
181 181
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
182 182
 
183
-	MonitorPatients MonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
184
-	DeviceNumber    DeviceNumber    `gorm:"ForeignKey:BedId" json:"device_number"`
185
-	DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId" json:"device_zone"`
186
-	TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
183
+	MonitorPatients *MonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
184
+	DeviceNumber    *DeviceNumber    `gorm:"ForeignKey:BedId" json:"device_number"`
185
+	DeviceZone      *DeviceZone      `gorm:"ForeignKey:PartitionId" json:"device_zone"`
186
+	TreatmentMode   *TreatmentMode   `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
187 187
 
188
-	DialysisOrder            MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
189
-	Prescription             DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
190
-	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
191
-	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
192
-	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
188
+	DialysisOrder            *MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
189
+	Prescription             *DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
190
+	AssessmentBeforeDislysis *PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
191
+	AssessmentAfterDislysis  *AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
192
+	MonitoringRecord         []*MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
193 193
 
194 194
 	//Patient         string          `gorm:"-" json:"patient" form:"patient"`
195 195
 	//SchedualPatient SchedualPatient `gorm:"ForeignKey:PatientId"`

+ 10 - 10
models/new_monitor.go Näytä tiedosto

@@ -11,16 +11,16 @@ type NewVMMonitorDialysisSchedule struct {
11 11
 	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
12 12
 	Status       int64 `gorm:"column:status" json:"status"`
13 13
 
14
-	MonitorPatients VMMonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
15
-	DeviceNumber    DeviceNumber      `gorm:"ForeignKey:BedId" json:"device_number"`
16
-	DeviceZone      DeviceZone        `gorm:"ForeignKey:PartitionId" json:"device_zone"`
17
-	TreatmentMode   TreatmentMode     `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
18
-
19
-	DialysisOrder            VMMonitorDialysisOrder    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
20
-	Prescription             VMDialysisPrescription    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
21
-	AssessmentBeforeDislysis VMPredialysisEvaluation   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
22
-	AssessmentAfterDislysis  VMAssessmentAfterDislysis `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
23
-	MonitoringRecord         []VMMonitoringRecord      `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
14
+	MonitorPatients *VMMonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
15
+	DeviceNumber    *DeviceNumber      `gorm:"ForeignKey:BedId" json:"device_number"`
16
+	DeviceZone      *DeviceZone        `gorm:"ForeignKey:PartitionId" json:"device_zone"`
17
+	TreatmentMode   *TreatmentMode     `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
18
+
19
+	DialysisOrder            *VMMonitorDialysisOrder    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
20
+	Prescription             *VMDialysisPrescription    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
21
+	AssessmentBeforeDislysis *VMPredialysisEvaluation   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
22
+	AssessmentAfterDislysis  *VMAssessmentAfterDislysis `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
23
+	MonitoringRecord         []*VMMonitoringRecord      `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
24 24
 }
25 25
 
26 26
 func (NewVMMonitorDialysisSchedule) TableName() string {

+ 31 - 0
models/patient_models.go Näytä tiedosto

@@ -1356,3 +1356,34 @@ type XtAssessmentBeforeDislysis struct {
1356 1356
 func (XtAssessmentBeforeDislysis) TableName() string {
1357 1357
 	return "xt_assessment_before_dislysis"
1358 1358
 }
1359
+
1360
+type MsDeviceNumber struct {
1361
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
1362
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1363
+	Number  string `gorm:"column:number" json:"number" form:"number"`
1364
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
1365
+	ZoneId  int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1366
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
1367
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1368
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1369
+	Sort    int64  `gorm:"column:sort" json:"sort" form:"sort"`
1370
+}
1371
+
1372
+func (MsDeviceNumber) TableName() string {
1373
+	return "xt_device_number"
1374
+}
1375
+
1376
+type MsDeviceZone struct {
1377
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
1378
+	OrgId  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1379
+	Name   string `gorm:"column:name" json:"name" form:"name"`
1380
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
1381
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
1382
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1383
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1384
+	Sort   int64  `gorm:"column:sort" json:"sort" form:"sort"`
1385
+}
1386
+
1387
+func (MsDeviceZone) TableName() string {
1388
+	return "xt_device_zone"
1389
+}

+ 45 - 31
service/dialysis_service.go Näytä tiedosto

@@ -2,12 +2,12 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"encoding/json"
5 6
 	"fmt"
7
+	"github.com/jinzhu/gorm"
8
+	"strconv"
6 9
 	"strings"
7 10
 	"time"
8
-	"strconv"
9
-	"encoding/json"
10
-	"github.com/jinzhu/gorm"
11 11
 )
12 12
 
13 13
 //GetPatientList 返回患者的列表
@@ -702,39 +702,51 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
702 702
 	return schedule, err, total
703 703
 }
704 704
 
705
-func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) ([]*models.DialysisSchedule, error, int64) {
706
-	var patients []*models.Patients
707
-	getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
708
-	if getPatientErr != nil {
709
-		return nil, getPatientErr, 0
710
-	}
711
-	patientIDs := make([]int64, len(patients))
712
-	for index, patient := range patients {
713
-		patientIDs[index] = patient.ID
714
-	}
705
+func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) (schedules []*models.DialysisSchedule, err error, total int64) {
706
+	//var patients []*models.Patients
707
+	//getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
708
+	//if getPatientErr != nil {
709
+	//	return nil, getPatientErr, 0
710
+	//}
711
+	//patientIDs := make([]int64, len(patients))
712
+	//for index, patient := range patients {
713
+	//	patientIDs[index] = patient.ID
714
+	//}
715
+	//
716
+	//db := readDb.
717
+	//	Model(&models.DialysisSchedule{}).
718
+	//	Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
719
+	//	Preload("TreatmentMode", "status = 1").
720
+	//	Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
721
+	//	Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
722
+	//	Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
723
+	//	Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
724
+	//	Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
725
+	//	Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
726
+	//db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
727
+	//if schedulType > 0 {
728
+	//	db = db.Where("schedule_type = ?", schedulType)
729
+	//}
730
+	//if partitionType > 0 {
731
+	//	db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
732
+	//
733
+	//}
734
+	//var schedules []*models.DialysisSchedule
735
+	//total := int64(0)
736
+	//err := db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
737
+	//return schedules, err, total
738
+
739
+	db := readDb.Model(&models.DialysisSchedule{}).Where("status = 1")
715 740
 
716
-	db := readDb.
717
-		Model(&models.DialysisSchedule{}).
718
-		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
719
-		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
720
-		Preload("TreatmentMode", "status = 1").
721
-		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
722
-		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
723
-		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
724
-		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
725
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
726
-		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
727
-	db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
728 741
 	if schedulType > 0 {
729
-		db = db.Where("schedule_type = ?", schedulType)
742
+		db = db.Where("scheudle_type = ?", schedulType)
730 743
 	}
744
+
731 745
 	if partitionType > 0 {
732
-		db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
733
-		// db = db.Where("partition_id = ?", partitionType)
746
+		db = db.Where("partition_id = ?", partitionType)
734 747
 	}
735
-	var schedules []*models.DialysisSchedule
736
-	total := int64(0)
737
-	err := db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
748
+
749
+	err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
738 750
 	return schedules, err, total
739 751
 }
740 752
 
@@ -794,9 +806,11 @@ func GetAllStarfEs(orgid int64) (es []*models.SgjUserAdminRoles, err error) {
794 806
 				starfes_str, err := json.Marshal(es)
795 807
 				if err == nil {
796 808
 					redis.Set(key, starfes_str, time.Second*60*60*18)
809
+					return es, nil
797 810
 				}
798 811
 			} else {
799 812
 				redis.Set(key, " ", time.Second*60*60*18)
813
+				return es, nil
800 814
 			}
801 815
 			return es, nil
802 816
 		}

+ 15 - 13
service/gobal_config_service.go Näytä tiedosto

@@ -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
-	"time"
8
-	"encoding/json"
9 8
 	"strconv"
9
+	"time"
10 10
 )
11 11
 
12 12
 func CreateAutomaticReduceRecord(config *models.GobalConfig) (err error) {
@@ -24,16 +24,16 @@ func FindAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.Go
24 24
 	defer redis.Close()
25 25
 
26 26
 	// cur_date := time.Now().Format("2006-01-02")
27
-	key := strconv.FormatInt(org_id, 10) +  ":gobal_config"
27
+	key := strconv.FormatInt(org_id, 10) + ":gobal_config"
28 28
 	gobal_config_str, _ := redis.Get(key).Result()
29 29
 
30 30
 	if len(gobal_config_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
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
-				return nil,config
34
+				return nil, config
35 35
 			} else {
36
-				return err,config
36
+				return err, config
37 37
 			}
38 38
 		} else {
39 39
 			if config.ID > 0 {
@@ -41,15 +41,17 @@ func FindAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.Go
41 41
 				gobal_config_str, err := json.Marshal(config)
42 42
 				if err == nil {
43 43
 					redis.Set(key, gobal_config_str, time.Second*60*60*18)
44
+					return nil, config
44 45
 				}
45 46
 			} else {
46 47
 				redis.Set(key, " ", time.Second*60*60*18)
48
+				return nil, config
47 49
 			}
48
-			return nil,config
50
+			return nil, config
49 51
 		}
50 52
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
51 53
 		json.Unmarshal([]byte(gobal_config_str), &config)
52
-		return nil,config
54
+		return nil, config
53 55
 	}
54 56
 }
55 57
 
@@ -223,9 +225,9 @@ func FindXTHisRecordByOrgId(org_id int64) (err error, config models.XtHisConfig)
223 225
 		err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
224 226
 		if err != nil {
225 227
 			if err == gorm.ErrRecordNotFound {
226
-				return nil,config
228
+				return nil, config
227 229
 			} else {
228
-				return err,config
230
+				return err, config
229 231
 			}
230 232
 		} else {
231 233
 			if config.ID > 0 {
@@ -237,11 +239,11 @@ func FindXTHisRecordByOrgId(org_id int64) (err error, config models.XtHisConfig)
237 239
 			} else {
238 240
 				redis.Set(key, " ", time.Second*60*60*18)
239 241
 			}
240
-			return nil,config
242
+			return nil, config
241 243
 		}
242 244
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
243 245
 		json.Unmarshal([]byte(his_config_str), &config)
244
-		return nil,config
246
+		return nil, config
245 247
 	}
246 248
 }
247 249
 
@@ -282,11 +284,11 @@ func FindXTHisProjectByOrgId(org_id int64) (err error, config models.XtHisProjec
282 284
 			} else {
283 285
 				redis.Set(key, " ", time.Second*60*60*18)
284 286
 			}
285
-			return nil,config
287
+			return nil, config
286 288
 		}
287 289
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
288 290
 		json.Unmarshal([]byte(his_project_config_str), &config)
289
-		return nil,config
291
+		return nil, config
290 292
 	}
291 293
 }
292 294
 

+ 189 - 101
service/mobile_dialysis_service.go Näytä tiedosto

@@ -370,15 +370,44 @@ func MobileGetDialysisRecord(orgID int64, patientID int64, recordDate int64) (*m
370 370
 // 用户基本信息
371 371
 func MobileGetPatientDetail(orgID int64, patientID int64) (*MPatient, error) {
372 372
 	var patient MPatient
373
-	err := readDb.Model(&MPatient{}).Where("status = 1 AND user_org_id = ? AND id = ?", orgID, patientID).First(&patient).Error
374
-	if err != nil {
375
-		if err == gorm.ErrRecordNotFound {
376
-			return nil, nil
373
+	//err := readDb.Model(&MPatient{}).Where("status = 1 AND user_org_id = ? AND id = ?", orgID, patientID).First(&patient).Error
374
+	//if err != nil {
375
+	//	if err == gorm.ErrRecordNotFound {
376
+	//		return nil, nil
377
+	//	} else {
378
+	//		return nil, err
379
+	//	}
380
+	//}
381
+	//return &patient, nil
382
+
383
+	redis := RedisClient()
384
+	defer redis.Close()
385
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":patient_info"
386
+
387
+	patient_info_str, _ := redis.Get(key).Result()
388
+
389
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
390
+		err = readDb.Model(&patient).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
391
+		if err != nil {
392
+			if err == gorm.ErrRecordNotFound {
393
+				return &patient, nil
394
+			} else {
395
+				return &patient, err
396
+			}
377 397
 		} else {
378
-			return nil, err
398
+			if patient.ID > 0 {
399
+				//缓存数据
400
+				patient_info_json, err := json.Marshal(&patient)
401
+				if err == nil {
402
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
403
+				}
404
+			}
405
+			return &patient, nil
379 406
 		}
407
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
408
+		json.Unmarshal([]byte(patient_info_str), &patient)
409
+		return &patient, nil
380 410
 	}
381
-	return &patient, nil
382 411
 }
383 412
 
384 413
 // 用户排班信息
@@ -387,14 +416,12 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
387 416
 	defer redis.Close()
388 417
 	var vm MDialysisScheduleVM
389 418
 
390
-	// cur_date := time.Now().Format("2006-01-02")
391 419
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
392 420
 	schedual_detail_str, _ := redis.Get(key).Result()
393 421
 
394 422
 	if len(schedual_detail_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
395 423
 		err := readDb.
396 424
 			Table("xt_schedule").
397
-			// Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
398 425
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
399 426
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
400 427
 			Where("status = 1 AND user_org_id = ? AND schedule_date = ? AND patient_id = ?", orgID, schedualDate, patientID).
@@ -410,6 +437,7 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
410 437
 			if vm.ID > 0 {
411 438
 				//缓存数据
412 439
 				schedual_detail_str, err := json.Marshal(vm)
440
+
413 441
 				if err == nil {
414 442
 					redis.Set(key, schedual_detail_str, time.Second*60*60*18)
415 443
 				}
@@ -420,6 +448,7 @@ func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (
420 448
 		}
421 449
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
422 450
 		json.Unmarshal([]byte(schedual_detail_str), &vm)
451
+
423 452
 		return &vm, nil
424 453
 	}
425 454
 }
@@ -525,7 +554,6 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
525 554
 	redis := RedisClient()
526 555
 	defer redis.Close()
527 556
 
528
-	// cur_date := time.Now().Format("2006-01-02")
529 557
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
530 558
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
531 559
 
@@ -654,10 +682,8 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
654 682
 	// cur_date := time.Now().Format("2006-01-02")
655 683
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
656 684
 	doctor_advices_str, _ := redis.Get(key).Result()
657
-
658 685
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
659
-		err := readDb.
660
-			Model(&models.DoctorAdvice{}).
686
+		err := readDb.Model(&models.DoctorAdvice{}).
661 687
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
662 688
 			Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno,way,drug_id,drug_name_id, IF(parent_id > 0, parent_id, id) as advice_order").
663 689
 			Order("start_time asc, groupno desc, advice_order desc, id asc").
@@ -674,9 +700,11 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
674 700
 				doctor_advices_str, err := json.Marshal(records)
675 701
 				if err == nil {
676 702
 					redis.Set(key, doctor_advices_str, time.Second*60*60*18)
703
+					return records, nil
677 704
 				}
678 705
 			} else {
679 706
 				redis.Set(key, " ", time.Second*60*60*18)
707
+				return records, nil
680 708
 			}
681 709
 			return records, nil
682 710
 		}
@@ -924,7 +952,7 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
924 952
 	// cur_date := time.Now().Format("2006-01-02")
925 953
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":treatment_summary"
926 954
 	treatment_summary_str, _ := redis.Get(key).Result()
927
-
955
+	fmt.Println("质量洗哦啊稼23323232323232323233232322332", treatment_summary_str)
928 956
 	if len(treatment_summary_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
929 957
 		err := readDb.Model(&models.TreatmentSummary{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
930 958
 		if err != nil {
@@ -1298,14 +1326,13 @@ func MobileGetScheduleDoctorAdvicesTwo(orgID int64, scheduleDate int64, adviceTy
1298 1326
 
1299 1327
 	db := readDb.
1300 1328
 		Table("xt_schedule").
1301
-		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1302
-		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1303
-			return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1304
-		}).
1329
+		//Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1330
+		//Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1331
+		//	return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1332
+		//}).
1305 1333
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1306 1334
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1307
-		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1308
-		//Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
1335
+		//Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1309 1336
 		Preload("DoctorAdvices", adviceCondition...).
1310 1337
 		Where("status = 1 AND user_org_id = ?", orgID)
1311 1338
 	if scheduleDate != 0 {
@@ -1482,46 +1509,55 @@ func GetHisDoctorAdvicesTwo(orgID int64, scheduleDate int64, deliverWay string,
1482 1509
 
1483 1510
 func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
1484 1511
 	var vms []*HisMScheduleProjectVM
1485
-	if patientType == 0 {
1486
-		db := readDb.
1487
-			Table("xt_schedule").
1488
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1489
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1490
-				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1491
-			}).
1492
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1493
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1494
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1495
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1496
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1497
-			}).
1498
-			Where("status = 1 AND user_org_id = ?", orgID)
1499
-		if scheduleDate != 0 {
1500
-			db = db.Where("schedule_date = ?", scheduleDate)
1501
-		}
1502
-		err = db.Find(&vms).Error
1503
-	}
1512
+	//if patientType == 0 {
1513
+	//	db := readDb.
1514
+	//		Table("xt_schedule").
1515
+	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1516
+	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1517
+	//			return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1518
+	//		}).
1519
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1520
+	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1521
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1522
+	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1523
+	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1524
+	//		}).
1525
+	//		Where("status = 1 AND user_org_id = ?", orgID)
1526
+	//	if scheduleDate != 0 {
1527
+	//		db = db.Where("schedule_date = ?", scheduleDate)
1528
+	//	}
1529
+	//	err = db.Find(&vms).Error
1530
+	//}
1504 1531
 
1505
-	if patientType > 0 {
1506
-		db := readDb.
1507
-			Table("xt_schedule").
1508
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1509
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1510
-				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1511
-			}).
1512
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1513
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1514
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1515
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1516
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1517
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1518
-			}).
1519
-			Where("status = 1 AND user_org_id = ?", orgID)
1520
-		if scheduleDate != 0 {
1521
-			db = db.Where("schedule_date = ?", scheduleDate)
1522
-		}
1523
-		err = db.Find(&vms).Error
1532
+	//if patientType > 0 {
1533
+	//	db := readDb.
1534
+	//		Table("xt_schedule").
1535
+	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1536
+	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1537
+	//			return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1538
+	//		}).
1539
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1540
+	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1541
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1542
+	//		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1543
+	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1544
+	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1545
+	//		}).
1546
+	//		Where("status = 1 AND user_org_id = ?", orgID)
1547
+	//	if scheduleDate != 0 {
1548
+	//		db = db.Where("schedule_date = ?", scheduleDate)
1549
+	//	}
1550
+	//	err = db.Find(&vms).Error
1551
+	//}
1552
+
1553
+	db := readDb.Table("xt_schedule").Where("status = 1")
1554
+	if orgID > 0 {
1555
+		db = db.Where("user_org_id = ?", orgID)
1556
+	}
1557
+	if scheduleDate > 0 {
1558
+		db = db.Where("schedule_date =?", scheduleDate)
1524 1559
 	}
1560
+	err = db.Find(&vms).Error
1525 1561
 
1526 1562
 	return vms, err
1527 1563
 }
@@ -1783,9 +1819,11 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
1783 1819
 				last_dry_weight_str, err := json.Marshal(record)
1784 1820
 				if err == nil {
1785 1821
 					redis.Set(key, last_dry_weight_str, time.Second*60*60*18)
1822
+					return nil, err
1786 1823
 				}
1787 1824
 			} else {
1788 1825
 				redis.Set(key, " ", time.Second*60*60*18)
1826
+				return nil, err
1789 1827
 			}
1790 1828
 			return &record, nil
1791 1829
 		}
@@ -1839,7 +1877,7 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1839 1877
 
1840 1878
 	// cur_date := time.Now().Format("2006-01-02")
1841 1879
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1842
-	fmt.Println("透析处方中的keyzhi", key)
1880
+
1843 1881
 	dialysis_prescribe_str, _ := redis.Get(key).Result()
1844 1882
 
1845 1883
 	if len(dialysis_prescribe_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -1886,14 +1924,18 @@ func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordD
1886 1924
 				return nil, err
1887 1925
 			}
1888 1926
 		} else {
1927
+
1889 1928
 			if record.ID > 0 {
1890 1929
 				//缓存数据
1891 1930
 				dialysis_prescribe_by_mode_str, err := json.Marshal(record)
1931
+
1892 1932
 				if err == nil {
1893 1933
 					redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
1934
+					return nil, err
1894 1935
 				}
1895 1936
 			} else {
1896 1937
 				redis.Set(key, " ", time.Second*60*60*18)
1938
+				return nil, err
1897 1939
 			}
1898 1940
 			return &record, nil
1899 1941
 		}
@@ -1917,16 +1959,52 @@ func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.Dialy
1917 1959
 }
1918 1960
 
1919 1961
 func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
1962
+	//var record models.DialysisPrescription
1963
+	//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
1964
+	//if err != nil {
1965
+	//	if err == gorm.ErrRecordNotFound {
1966
+	//		return nil, nil
1967
+	//	} else {
1968
+	//		return nil, err
1969
+	//	}
1970
+	//}
1971
+	//return &record, nil
1972
+
1920 1973
 	var record models.DialysisPrescription
1921
-	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
1922
-	if err != nil {
1923
-		if err == gorm.ErrRecordNotFound {
1924
-			return nil, nil
1974
+	redis := RedisClient()
1975
+	defer redis.Close()
1976
+
1977
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_by_mode"
1978
+	dialysis_prescribe_by_mode_id, _ := redis.Get(key).Result()
1979
+
1980
+	if len(dialysis_prescribe_by_mode_id) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1981
+		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
+		if err != nil {
1983
+			if err == gorm.ErrRecordNotFound {
1984
+				return nil, nil
1985
+			} else {
1986
+				return nil, err
1987
+			}
1925 1988
 		} else {
1926
-			return nil, err
1989
+
1990
+			if record.ID > 0 {
1991
+				//缓存数据
1992
+				dialysis_prescribe_by_mode_str, err := json.Marshal(record)
1993
+
1994
+				if err == nil {
1995
+					redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
1996
+					return nil, err
1997
+				}
1998
+			} else {
1999
+				redis.Set(key, " ", time.Second*60*60*18)
2000
+				return nil, err
2001
+			}
2002
+			return &record, nil
1927 2003
 		}
2004
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2005
+		json.Unmarshal([]byte(dialysis_prescribe_by_mode_id), &record)
2006
+		return &record, nil
1928 2007
 	}
1929
-	return &record, nil
1930 2008
 }
1931 2009
 
1932 2010
 //func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate int64,mode_id int64) (*models.DialysisPrescription, error) {
@@ -2909,45 +2987,55 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
2909 2987
 
2910 2988
 func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
2911 2989
 	var vms []*HisMScheduleProjectVM
2912
-	if patientType == 0 {
2913
-		db := readDb.
2914
-			Table("xt_schedule").
2915
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2916
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2917
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2918
-			}).
2919
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2920
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2921
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2922
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2923
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2924
-			}).Where("status = 1 AND user_org_id = ?", orgID)
2925
-		if scheduleDate != 0 {
2926
-			db = db.Where("schedule_date = ?", scheduleDate)
2927
-		}
2928
-		err = db.Find(&vms).Error
2929
-	}
2990
+	//if patientType == 0 {
2991
+	//	db := readDb.
2992
+	//		Table("xt_schedule").
2993
+	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2994
+	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2995
+	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2996
+	//		}).
2997
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2998
+	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2999
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3000
+	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3001
+	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3002
+	//		}).Where("status = 1 AND user_org_id = ?", orgID)
3003
+	//	if scheduleDate != 0 {
3004
+	//		db = db.Where("schedule_date = ?", scheduleDate)
3005
+	//	}
3006
+	//	err = db.Find(&vms).Error
3007
+	//}
3008
+	//
3009
+	//if patientType > 0 {
3010
+	//	db := readDb.
3011
+	//		Table("xt_schedule").
3012
+	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
3013
+	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3014
+	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3015
+	//		}).
3016
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
3017
+	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
3018
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3019
+	//		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
3020
+	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3021
+	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3022
+	//		}).
3023
+	//		Where("status = 1 AND user_org_id = ?", orgID)
3024
+	//	if scheduleDate != 0 {
3025
+	//		db = db.Where("schedule_date = ?", scheduleDate)
3026
+	//	}
3027
+	//	err = db.Find(&vms).Error
3028
+	//}
2930 3029
 
2931
-	if patientType > 0 {
2932
-		db := readDb.
2933
-			Table("xt_schedule").
2934
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2935
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2936
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2937
-			}).
2938
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2939
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2940
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2941
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
2942
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2943
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2944
-			}).
2945
-			Where("status = 1 AND user_org_id = ?", orgID)
2946
-		if scheduleDate != 0 {
2947
-			db = db.Where("schedule_date = ?", scheduleDate)
2948
-		}
2949
-		err = db.Find(&vms).Error
3030
+	db := readDb.Table("xt_schedule").Where("status = 1")
3031
+	if scheduleDate > 0 {
3032
+		db = db.Where("schedule_date = ?", scheduleDate)
2950 3033
 	}
3034
+	if orgID > 0 {
3035
+		db = db.Where("user_org_id = ?", orgID)
3036
+	}
3037
+
3038
+	err = db.Find(&vms).Error
2951 3039
 
2952 3040
 	return vms, err
2953 3041
 }

+ 645 - 46
service/patient_service.go Näytä tiedosto

@@ -236,9 +236,10 @@ func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders
236 236
 	defer redis.Close()
237 237
 	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
238 238
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
239
-
239
+	fmt.Println("hhhhhahdhaf3e2323323223", len(dialysis_orders_list_all))
240 240
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
241 241
 		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
242
+		fmt.Println("err2332233232323232232323", err)
242 243
 		if err != nil {
243 244
 			if err == gorm.ErrRecordNotFound {
244 245
 				return nil, nil
@@ -430,7 +431,7 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
430 431
 	redis := RedisClient()
431 432
 	defer redis.Close()
432 433
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(id, 10) + ":patient_info"
433
-	fmt.Println("keyw233223322332332233232323232323223233", key)
434
+
434 435
 	patient_info_str, _ := redis.Get(key).Result()
435 436
 
436 437
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -445,6 +446,7 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
445 446
 			if patient.ID > 0 {
446 447
 				//缓存数据
447 448
 				patient_info_json, err := json.Marshal(&patient)
449
+
448 450
 				if err == nil {
449 451
 					redis.Set(key, patient_info_json, time.Second*60*60*18)
450 452
 				}
@@ -1318,56 +1320,69 @@ func GetPatientScheduleList(orgID int64, patientID int64, page int64, limit int6
1318 1320
 
1319 1321
 func GetMonitorRecord(orgID int64, date int64, partition int64, patientId int64) ([]*models.NewVMMonitorDialysisSchedule, error) {
1320 1322
 	var mds []*models.NewVMMonitorDialysisSchedule
1321
-
1322
-	if patientId == 0 {
1323
-		db := readDb.
1324
-			Model(&models.NewVMMonitorDialysisSchedule{}).
1325
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1326
-			Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1327
-			Preload("TreatmentMode", "status = 1").
1328
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, date).
1329
-			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, date).
1330
-			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ? ", orgID, date).
1331
-			Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? AND monitoring_date = ?", orgID, date).
1332
-			Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, date).
1333
-			Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1334
-			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1335
-			Where("status = 1 AND user_org_id = ?", orgID)
1336
-		if date != 0 {
1337
-			db = db.Where("schedule_date = ? ", date)
1338
-		}
1339
-		if partition != 0 {
1340
-			db = db.Where("partition_id = ? ", partition)
1341
-		}
1342
-		err := db.Find(&mds).Error
1343
-		fmt.Println("err", err)
1323
+	//
1324
+	//if patientId == 0 {
1325
+	//	db := readDb.
1326
+	//		Model(&models.NewVMMonitorDialysisSchedule{}).
1327
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1328
+	//		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1329
+	//		Preload("TreatmentMode", "status = 1").
1330
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, date).
1331
+	//		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, date).
1332
+	//		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ? ", orgID, date).
1333
+	//		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? AND monitoring_date = ?", orgID, date).
1334
+	//		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, date).
1335
+	//		Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1336
+	//		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1337
+	//		Where("status = 1 AND user_org_id = ?", orgID)
1338
+	//	if date != 0 {
1339
+	//		db = db.Where("schedule_date = ? ", date)
1340
+	//	}
1341
+	//	if partition != 0 {
1342
+	//		db = db.Where("partition_id = ? ", partition)
1343
+	//	}
1344
+	//	err := db.Find(&mds).Error
1345
+	//	fmt.Println("err", err)
1346
+
1347
+	//if patientId > 0 {
1348
+	//	db := readDb.Table("xt_schedule as x").Where("x.status = 1")
1349
+	//	db = db.
1350
+	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1351
+	//		Preload("TreatmentMode", "status = 1").
1352
+	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1353
+	//		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ?", orgID, patientId).
1354
+	//		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ? ", orgID, patientId).
1355
+	//		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?  AND patient_id = ?", orgID, patientId).
1356
+	//		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1357
+	//		Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1358
+	//		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1359
+	//		Where("status = 1 AND user_org_id = ?", orgID)
1360
+	//	if partition != 0 {
1361
+	//		db = db.Where("partition_id = ? ", partition)
1362
+	//	}
1363
+	//
1364
+	//	db = db.Where("schedule_date <= ? ", time.Now().Unix())
1365
+	//
1366
+	//	db = db.Where("patient_id = ?", patientId)
1367
+	//	db = db.Order("schedule_date desc")
1368
+	//	err := db.Find(&mds).Error
1369
+	//	fmt.Println("err", err)
1370
+	//}
1371
+
1372
+	db := readDb.Model(&models.NewVMMonitorDialysisSchedule{})
1373
+	if date > 0 {
1374
+		db = db.Where("schedule_date = ?", date)
1375
+	}
1376
+	if partition > 0 {
1377
+		db = db.Where("partition_id = ?", partition)
1344 1378
 	}
1345
-
1346 1379
 	if patientId > 0 {
1347
-		db := readDb.Table("xt_schedule as x").Where("x.status = 1")
1348
-		db = db.
1349
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1350
-			Preload("TreatmentMode", "status = 1").
1351
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1352
-			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ?", orgID, patientId).
1353
-			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ? ", orgID, patientId).
1354
-			Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?  AND patient_id = ?", orgID, patientId).
1355
-			Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1356
-			Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1357
-			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1358
-			Where("status = 1 AND user_org_id = ?", orgID)
1359
-		if partition != 0 {
1360
-			db = db.Where("partition_id = ? ", partition)
1361
-		}
1362
-
1363
-		db = db.Where("schedule_date <= ? ", time.Now().Unix())
1364 1380
 
1365 1381
 		db = db.Where("patient_id = ?", patientId)
1366
-		db = db.Order("schedule_date desc")
1367
-		err := db.Find(&mds).Error
1368
-		fmt.Println("err", err)
1369 1382
 	}
1370 1383
 
1384
+	err = db.Where("status = 1 and user_org_id = ?", orgID).Find(&mds).Error
1385
+
1371 1386
 	return mds, err
1372 1387
 }
1373 1388
 
@@ -1812,3 +1827,587 @@ func UpdateScheduleItemByPatientId(id int64) error {
1812 1827
 	err := XTWriteDB().Model(models.PatientScheduleTemplateItem{}).Where("patient_id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1813 1828
 	return err
1814 1829
 }
1830
+
1831
+func GetAllDeviceNumberByList(orgID int64) (number []*models.DeviceNumber, err error) {
1832
+	redis := RedisClient()
1833
+	defer redis.Close()
1834
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_number_all"
1835
+	number_info_str, _ := redis.Get(key).Result()
1836
+	if len(number_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1837
+		err = readDb.Model(&models.DeviceNumber{}).Where("org_id=? and status=1", orgID).Find(&number).Error
1838
+		if err != nil {
1839
+			if err == gorm.ErrRecordNotFound {
1840
+				return nil, nil
1841
+			} else {
1842
+				return nil, err
1843
+			}
1844
+		} else {
1845
+			if len(number) > 0 {
1846
+				//缓存数据
1847
+				device_number_json, err := json.Marshal(&number)
1848
+				if err == nil {
1849
+					redis.Set(key, device_number_json, time.Second*60*60*18)
1850
+				}
1851
+			}
1852
+			return number, nil
1853
+		}
1854
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1855
+		json.Unmarshal([]byte(number_info_str), &number)
1856
+		return number, nil
1857
+	}
1858
+}
1859
+
1860
+func GetAllZoneByList(orgID int64) (zone []*models.DeviceZone, err error) {
1861
+
1862
+	redis := RedisClient()
1863
+	defer redis.Close()
1864
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_zone_all"
1865
+	zone_info_str, _ := redis.Get(key).Result()
1866
+	if len(zone_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1867
+		err = readDb.Model(&models.DeviceZone{}).Where("org_id=? and status=1", orgID).Find(&zone).Error
1868
+		if err != nil {
1869
+			if err == gorm.ErrRecordNotFound {
1870
+				return nil, nil
1871
+			} else {
1872
+				return nil, err
1873
+			}
1874
+		} else {
1875
+			if len(zone) > 0 {
1876
+				//缓存数据
1877
+				zone_number_json, err := json.Marshal(&zone)
1878
+				if err == nil {
1879
+					redis.Set(key, zone_number_json, time.Second*60*60*18)
1880
+				}
1881
+			}
1882
+			return zone, nil
1883
+		}
1884
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1885
+		json.Unmarshal([]byte(zone_info_str), &zone)
1886
+		return zone, nil
1887
+	}
1888
+}
1889
+
1890
+func GetAllPrescriptionByList(orgID int64, scheduleDate int64) (prescriptions []*models.VMDialysisPrescription, err error) {
1891
+
1892
+	redis := RedisClient()
1893
+	defer redis.Close()
1894
+	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
1895
+	prescriptions_list_all, _ := redis.Get(key).Result()
1896
+
1897
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1898
+		err = readDb.Model(&models.VMDialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
1899
+		if err != nil {
1900
+			if err == gorm.ErrRecordNotFound {
1901
+				return nil, nil
1902
+			} else {
1903
+				return nil, err
1904
+			}
1905
+		} else {
1906
+			if len(prescriptions) > 0 {
1907
+				//缓存数据
1908
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
1909
+				if err == nil {
1910
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
1911
+				}
1912
+			}
1913
+			return prescriptions, nil
1914
+		}
1915
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1916
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
1917
+		return prescriptions, nil
1918
+	}
1919
+}
1920
+
1921
+func GetAllAssessmentBeforesByListOne(orgID int64, scheduleDate int64) (assessmentBefores []*models.VMPredialysisEvaluation, err error) {
1922
+	redis := RedisClient()
1923
+	defer redis.Close()
1924
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_befores_list_all"
1925
+	assessment_befores_list_all, _ := redis.Get(key).Result()
1926
+
1927
+	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1928
+		err = readDb.Model(&models.VMPredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
1929
+		if err != nil {
1930
+			if err == gorm.ErrRecordNotFound {
1931
+				return nil, nil
1932
+			} else {
1933
+				return nil, err
1934
+			}
1935
+		} else {
1936
+			if len(assessmentBefores) > 0 {
1937
+				//缓存数据
1938
+				assessment_befores_list_all, err := json.Marshal(&assessmentBefores)
1939
+				if err == nil {
1940
+					redis.Set(key, assessment_befores_list_all, time.Second*60*60*18)
1941
+				}
1942
+			}
1943
+			return assessmentBefores, nil
1944
+		}
1945
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1946
+		json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
1947
+		return assessmentBefores, nil
1948
+	}
1949
+}
1950
+
1951
+func GetAllDialysisOrdersByListOne(orgID int64, scheduleDate int64) (dialysisOrders []*models.VMMonitorDialysisOrder, err error) {
1952
+	redis := RedisClient()
1953
+	defer redis.Close()
1954
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
1955
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
1956
+
1957
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1958
+		err = readDb.Model(&models.VMMonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
1959
+		if err != nil {
1960
+			if err == gorm.ErrRecordNotFound {
1961
+				return nil, nil
1962
+			} else {
1963
+				return nil, err
1964
+			}
1965
+		} else {
1966
+			if len(dialysisOrders) > 0 {
1967
+				//缓存数据
1968
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
1969
+				if err == nil {
1970
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
1971
+				}
1972
+			}
1973
+			return dialysisOrders, nil
1974
+		}
1975
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1976
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
1977
+		return dialysisOrders, nil
1978
+	}
1979
+}
1980
+
1981
+func GetAllAssessmentAfterDislysisByListOne(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.VMAssessmentAfterDislysis, err error) {
1982
+	redis := RedisClient()
1983
+	defer redis.Close()
1984
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
1985
+	assessment_after_dislysis__all, _ := redis.Get(key).Result()
1986
+
1987
+	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1988
+		err = readDb.Model(&models.VMAssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
1989
+		if err != nil {
1990
+			if err == gorm.ErrRecordNotFound {
1991
+				return nil, nil
1992
+			} else {
1993
+				return nil, err
1994
+			}
1995
+		} else {
1996
+			if len(assessmentAfterDislysis) > 0 {
1997
+				//缓存数据
1998
+				assessment_after_dislysis__all, err := json.Marshal(&assessmentAfterDislysis)
1999
+				if err == nil {
2000
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2001
+				}
2002
+			}
2003
+			return assessmentAfterDislysis, nil
2004
+		}
2005
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2006
+		json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
2007
+		return assessmentAfterDislysis, nil
2008
+	}
2009
+}
2010
+
2011
+func GetAllMonitorList(orgID int64, scheduleDate int64) (monitor []*models.VMMonitoringRecord, err error) {
2012
+
2013
+	//db := XTReadDB().Model(&monitor).Where("status = 1")
2014
+	//if orgID > 0 {
2015
+	//  db = db.Where("user_org_id = ?", orgID)
2016
+	//}
2017
+	//if scheduleDate > 0 {
2018
+	//  db = db.Where("monitoring_date = ?", scheduleDate)
2019
+	//}
2020
+	//
2021
+	//err = db.Find(&monitor).Error
2022
+	//return  monitor,err
2023
+
2024
+	redis := RedisClient()
2025
+	defer redis.Close()
2026
+	key := strconv.FormatInt(orgID, 10) + ":" + ":monitor_record_list_all"
2027
+	monitor_record_list_all, _ := redis.Get(key).Result()
2028
+
2029
+	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2030
+		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2031
+		if err != nil {
2032
+			if err == gorm.ErrRecordNotFound {
2033
+				return nil, nil
2034
+			} else {
2035
+				return nil, err
2036
+			}
2037
+		} else {
2038
+			if len(monitor) > 0 {
2039
+				//缓存数据
2040
+				assessment_after_dislysis__all, err := json.Marshal(&monitor)
2041
+				if err == nil {
2042
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2043
+				}
2044
+			}
2045
+			return monitor, nil
2046
+		}
2047
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2048
+		json.Unmarshal([]byte(monitor_record_list_all), &monitor)
2049
+		return monitor, nil
2050
+	}
2051
+}
2052
+
2053
+func GetAllPatientListByListOne(orgID int64) (patients []*models.VMMonitorPatients, err error) {
2054
+	redis := RedisClient()
2055
+	defer redis.Close()
2056
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2057
+	patient_info_str, _ := redis.Get(key).Result()
2058
+
2059
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2060
+		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2061
+		if err != nil {
2062
+			if err == gorm.ErrRecordNotFound {
2063
+				return nil, nil
2064
+			} else {
2065
+				return nil, err
2066
+			}
2067
+		} else {
2068
+			if len(patients) > 0 {
2069
+				//缓存数据
2070
+				patient_info_json, err := json.Marshal(&patients)
2071
+				if err == nil {
2072
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2073
+				}
2074
+			}
2075
+			return patients, nil
2076
+		}
2077
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2078
+		json.Unmarshal([]byte(patient_info_str), &patients)
2079
+		return patients, nil
2080
+	}
2081
+}
2082
+
2083
+func GetAllTreatModeByList(orgID int64) (treatement []*models.TreatmentMode, err error) {
2084
+	redis := RedisClient()
2085
+	defer redis.Close()
2086
+	key := strconv.FormatInt(orgID, 10) + ":" + ":treatement_mode_all"
2087
+	treatment_info_str, _ := redis.Get(key).Result()
2088
+
2089
+	if len(treatment_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2090
+		err = readDb.Model(&models.TreatmentMode{}).Where("status=1").Find(&treatement).Error
2091
+		if err != nil {
2092
+			if err == gorm.ErrRecordNotFound {
2093
+				return nil, nil
2094
+			} else {
2095
+				return nil, err
2096
+			}
2097
+		} else {
2098
+			if len(treatement) > 0 {
2099
+				//缓存数据
2100
+				patient_info_json, err := json.Marshal(&treatement)
2101
+				if err == nil {
2102
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2103
+				}
2104
+			}
2105
+			return treatement, nil
2106
+		}
2107
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2108
+		json.Unmarshal([]byte(treatment_info_str), &treatement)
2109
+		return treatement, nil
2110
+	}
2111
+}
2112
+
2113
+func GetAllPatientListByListTwo(orgID int64) (patients []*MSchedualPatientVM, err error) {
2114
+	redis := RedisClient()
2115
+	defer redis.Close()
2116
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2117
+	patient_info_str, _ := redis.Get(key).Result()
2118
+
2119
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2120
+		err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2121
+		if err != nil {
2122
+			if err == gorm.ErrRecordNotFound {
2123
+				return nil, nil
2124
+			} else {
2125
+				return nil, err
2126
+			}
2127
+		} else {
2128
+			if len(patients) > 0 {
2129
+				//缓存数据
2130
+				patient_info_json, err := json.Marshal(&patients)
2131
+				if err == nil {
2132
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2133
+				}
2134
+			}
2135
+			return patients, nil
2136
+		}
2137
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2138
+		json.Unmarshal([]byte(patient_info_str), &patients)
2139
+		return patients, nil
2140
+	}
2141
+}
2142
+
2143
+func GetAllDeviceNumberByListOne(orgID int64) (number []*MDeviceNumberVM, err error) {
2144
+	redis := RedisClient()
2145
+	defer redis.Close()
2146
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_number_all"
2147
+	number_info_str, _ := redis.Get(key).Result()
2148
+	if len(number_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2149
+		err = readDb.Model(&MDeviceNumberVM{}).Where("org_id=? and status=1", orgID).Find(&number).Error
2150
+		if err != nil {
2151
+			if err == gorm.ErrRecordNotFound {
2152
+				return nil, nil
2153
+			} else {
2154
+				return nil, err
2155
+			}
2156
+		} else {
2157
+			if len(number) > 0 {
2158
+				//缓存数据
2159
+				device_number_json, err := json.Marshal(&number)
2160
+				if err == nil {
2161
+					redis.Set(key, device_number_json, time.Second*60*60*18)
2162
+				}
2163
+			}
2164
+			return number, nil
2165
+		}
2166
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2167
+		json.Unmarshal([]byte(number_info_str), &number)
2168
+		return number, nil
2169
+	}
2170
+}
2171
+
2172
+func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
2173
+
2174
+	redis := RedisClient()
2175
+	defer redis.Close()
2176
+	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
2177
+	prescriptions_list_all, _ := redis.Get(key).Result()
2178
+
2179
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2180
+		err = readDb.Model(&models.DialysisPrescriptionList{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2181
+		if err != nil {
2182
+			if err == gorm.ErrRecordNotFound {
2183
+				return nil, nil
2184
+			} else {
2185
+				return nil, err
2186
+			}
2187
+		} else {
2188
+			if len(prescriptions) > 0 {
2189
+				//缓存数据
2190
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
2191
+				if err == nil {
2192
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
2193
+				}
2194
+			}
2195
+			return prescriptions, nil
2196
+		}
2197
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2198
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
2199
+		return prescriptions, nil
2200
+	}
2201
+}
2202
+
2203
+func GetAllDialysisOrdersByListTwo(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVM, err error) {
2204
+	redis := RedisClient()
2205
+	defer redis.Close()
2206
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2207
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
2208
+
2209
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2210
+		err = readDb.Model(&MDialysisOrderVM{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2211
+		if err != nil {
2212
+			if err == gorm.ErrRecordNotFound {
2213
+				return nil, nil
2214
+			} else {
2215
+				return nil, err
2216
+			}
2217
+		} else {
2218
+			if len(dialysisOrders) > 0 {
2219
+				//缓存数据
2220
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
2221
+				if err == nil {
2222
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
2223
+				}
2224
+			}
2225
+			return dialysisOrders, nil
2226
+		}
2227
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2228
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
2229
+		return dialysisOrders, nil
2230
+	}
2231
+}
2232
+
2233
+func GetAllPatientListByListThree(orgID int64) (patients []*models.MonitorPatients, err error) {
2234
+	redis := RedisClient()
2235
+	defer redis.Close()
2236
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2237
+	patient_info_str, _ := redis.Get(key).Result()
2238
+
2239
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2240
+		err = readDb.Model(&models.MonitorPatients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2241
+		if err != nil {
2242
+			if err == gorm.ErrRecordNotFound {
2243
+				return nil, nil
2244
+			} else {
2245
+				return nil, err
2246
+			}
2247
+		} else {
2248
+			if len(patients) > 0 {
2249
+				//缓存数据
2250
+				patient_info_json, err := json.Marshal(&patients)
2251
+				if err == nil {
2252
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2253
+				}
2254
+			}
2255
+			return patients, nil
2256
+		}
2257
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2258
+		json.Unmarshal([]byte(patient_info_str), &patients)
2259
+		return patients, nil
2260
+	}
2261
+}
2262
+
2263
+func GetAllPrescriptionByListTwo(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescription, err error) {
2264
+
2265
+	redis := RedisClient()
2266
+	defer redis.Close()
2267
+	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
2268
+	prescriptions_list_all, _ := redis.Get(key).Result()
2269
+
2270
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2271
+		err = readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2272
+		if err != nil {
2273
+			if err == gorm.ErrRecordNotFound {
2274
+				return nil, nil
2275
+			} else {
2276
+				return nil, err
2277
+			}
2278
+		} else {
2279
+			if len(prescriptions) > 0 {
2280
+				//缓存数据
2281
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
2282
+				if err == nil {
2283
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
2284
+				}
2285
+			}
2286
+			return prescriptions, nil
2287
+		}
2288
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2289
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
2290
+		return prescriptions, nil
2291
+	}
2292
+}
2293
+
2294
+func GetAllAssessmentBeforesByListThree(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluation, err error) {
2295
+	redis := RedisClient()
2296
+	defer redis.Close()
2297
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_befores_list_all"
2298
+	assessment_befores_list_all, _ := redis.Get(key).Result()
2299
+
2300
+	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2301
+		err = readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
2302
+		if err != nil {
2303
+			if err == gorm.ErrRecordNotFound {
2304
+				return nil, nil
2305
+			} else {
2306
+				return nil, err
2307
+			}
2308
+		} else {
2309
+			if len(assessmentBefores) > 0 {
2310
+				//缓存数据
2311
+				assessment_befores_list_all, err := json.Marshal(&assessmentBefores)
2312
+				if err == nil {
2313
+					redis.Set(key, assessment_befores_list_all, time.Second*60*60*18)
2314
+				}
2315
+			}
2316
+			return assessmentBefores, nil
2317
+		}
2318
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2319
+		json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
2320
+		return assessmentBefores, nil
2321
+	}
2322
+}
2323
+
2324
+func GetAllDialysisOrdersByListThree(orgID int64, scheduleDate int64) (dialysisOrders []*models.MonitorDialysisOrder, err error) {
2325
+	redis := RedisClient()
2326
+	defer redis.Close()
2327
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2328
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
2329
+
2330
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2331
+		err = readDb.Model(&models.MonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2332
+		if err != nil {
2333
+			if err == gorm.ErrRecordNotFound {
2334
+				return nil, nil
2335
+			} else {
2336
+				return nil, err
2337
+			}
2338
+		} else {
2339
+			if len(dialysisOrders) > 0 {
2340
+				//缓存数据
2341
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
2342
+				if err == nil {
2343
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
2344
+				}
2345
+			}
2346
+			return dialysisOrders, nil
2347
+		}
2348
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2349
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
2350
+		return dialysisOrders, nil
2351
+	}
2352
+}
2353
+
2354
+func GetAllAssessmentAfterDislysisByListThree(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.AssessmentAfterDislysis, err error) {
2355
+	redis := RedisClient()
2356
+	defer redis.Close()
2357
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
2358
+	assessment_after_dislysis__all, _ := redis.Get(key).Result()
2359
+
2360
+	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2361
+		err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
2362
+		if err != nil {
2363
+			if err == gorm.ErrRecordNotFound {
2364
+				return nil, nil
2365
+			} else {
2366
+				return nil, err
2367
+			}
2368
+		} else {
2369
+			if len(assessmentAfterDislysis) > 0 {
2370
+				//缓存数据
2371
+				assessment_after_dislysis__all, err := json.Marshal(&assessmentAfterDislysis)
2372
+				if err == nil {
2373
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2374
+				}
2375
+			}
2376
+			return assessmentAfterDislysis, nil
2377
+		}
2378
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2379
+		json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
2380
+		return assessmentAfterDislysis, nil
2381
+	}
2382
+}
2383
+
2384
+func GetAllMonitorListThree(orgID int64, scheduleDate int64) (monitor []*models.MonitoringRecord, err error) {
2385
+
2386
+	redis := RedisClient()
2387
+	defer redis.Close()
2388
+	key := strconv.FormatInt(orgID, 10) + ":" + ":monitor_record_list_all"
2389
+	monitor_record_list_all, _ := redis.Get(key).Result()
2390
+
2391
+	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2392
+		err = readDb.Model(&models.MonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2393
+		if err != nil {
2394
+			if err == gorm.ErrRecordNotFound {
2395
+				return nil, nil
2396
+			} else {
2397
+				return nil, err
2398
+			}
2399
+		} else {
2400
+			if len(monitor) > 0 {
2401
+				//缓存数据
2402
+				assessment_after_dislysis__all, err := json.Marshal(&monitor)
2403
+				if err == nil {
2404
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2405
+				}
2406
+			}
2407
+			return monitor, nil
2408
+		}
2409
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2410
+		json.Unmarshal([]byte(monitor_record_list_all), &monitor)
2411
+		return monitor, nil
2412
+	}
2413
+}

+ 7 - 5
service/patientmanage_service.go Näytä tiedosto

@@ -2,12 +2,12 @@ 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 10
 	"time"
10
-	"encoding/json"
11 11
 )
12 12
 
13 13
 func GetIllnessListTwo() (ills []*models.Illness, err error) {
@@ -1575,9 +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
-				return assessment,nil
1578
+				return assessment, nil
1579 1579
 			} else {
1580
-				return assessment,err
1580
+				return assessment, err
1581 1581
 			}
1582 1582
 		} else {
1583 1583
 			if assessment.ID > 0 {
@@ -1585,15 +1585,17 @@ func GetLastPassWayAssessment(orgid int64, patientId int64) (models.XtPatientVas
1585 1585
 				pass_way_assessment_last_str, err := json.Marshal(assessment)
1586 1586
 				if err == nil {
1587 1587
 					redis.Set(key, pass_way_assessment_last_str, time.Second*60*60*18)
1588
+					return assessment, nil
1588 1589
 				}
1589 1590
 			} else {
1590 1591
 				redis.Set(key, " ", time.Second*60*60*18)
1592
+				return assessment, nil
1591 1593
 			}
1592
-			return assessment,nil
1594
+			return assessment, nil
1593 1595
 		}
1594 1596
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1595 1597
 		json.Unmarshal([]byte(pass_way_assessment_last_str), &assessment)
1596
-		return assessment,nil
1598
+		return assessment, nil
1597 1599
 	}
1598 1600
 }
1599 1601
 

+ 2 - 1
service/redis.go Näytä tiedosto

@@ -9,10 +9,11 @@ import (
9 9
 
10 10
 func RedisClient() *redis.Client {
11 11
 	address := fmt.Sprintf("%s:%s", beego.AppConfig.String("redishost"), beego.AppConfig.String("redisport"))
12
+	dbs, _ := beego.AppConfig.Int("redisdb")
12 13
 	client := redis.NewClient(&redis.Options{
13 14
 		Addr:     address,
14 15
 		Password: beego.AppConfig.String("redispasswrod"), // no password set
15
-		DB:       0,                                       // use default DB
16
+		DB:       dbs,                                     // use default DB
16 17
 	})
17 18
 	pong, err := client.Ping().Result()
18 19
 	fmt.Println(pong, err)