Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

XMLWAN 3 years ago
parent
commit
7cd53e0089

+ 13 - 3
controllers/his_api_controller.go View File

@@ -540,14 +540,16 @@ func (c *HisApiController) CreateHisPrescription() {
540 540
 
541 541
 								if prescribingNumberUnit == drug.MinUnit {
542 542
 									if prescribing_number > drug.Total {
543
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
543
+										c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
544
+										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
544 545
 										return
545 546
 									}
546 547
 								} else {
547 548
 									if prescribingNumberUnit == drug.MaxUnit {
548 549
 										num := prescribing_number * float64(drug.MinNumber)
549 550
 										if num > drug.Total {
550
-											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
551
+											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
552
+											//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
551 553
 											return
552 554
 										}
553 555
 									}
@@ -591,7 +593,9 @@ func (c *HisApiController) CreateHisPrescription() {
591 593
 										return
592 594
 									}
593 595
 									if totals > good.Total {
594
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
596
+										c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
597
+
598
+										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
595 599
 										return
596 600
 									}
597 601
 
@@ -1860,6 +1864,11 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
1860 1864
 		}
1861 1865
 	}
1862 1866
 
1867
+	if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
1868
+		groupno := int64(json["groupno"].(float64))
1869
+		advice.Groupno = groupno
1870
+	}
1871
+
1863 1872
 	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
1864 1873
 		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
1865 1874
 		advice.PrescribingNumber = prescribingNumber
@@ -1884,6 +1893,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
1884 1893
 					advice.Checker = hisAdvice.Checker
1885 1894
 					advice.CheckState = hisAdvice.CheckState
1886 1895
 					advice.StartTime = hisAdvice.StartTime
1896
+					//advice.Groupno = hisAdvice.Groupno
1887 1897
 
1888 1898
 				}
1889 1899
 			}

+ 0 - 7
controllers/mobile_api_controllers/advice_api_controller.go View File

@@ -1,7 +0,0 @@
1
-package mobile_api_controllers
2
-
3
-type AdviceAPIController struct {
4
-	MobileBaseAPIAuthController
5
-}
6
-
7
-// /m/api/dialysis/advices [get]

+ 118 - 109
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -849,6 +849,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
849 849
 		})
850 850
 		return
851 851
 	} else if origin == 2 {
852
+		var ids []string
853
+		advice_ids := c.GetString("advice_id")
854
+		ids = strings.Split(advice_ids, ",")
852 855
 
853 856
 		if len(execution_time) <= 0 {
854 857
 			utils.ErrorLog("execution_time")
@@ -865,107 +868,117 @@ func (c *PatientApiController) ExecDoctorAdvice() {
865 868
 		}
866 869
 		adminInfo := c.GetMobileAdminUserInfo()
867 870
 		creater := c.GetMobileAdminUserInfo().AdminUser.Id
868
-		advice_id, _ := c.GetInt64("advice_id")
869
-		advices, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, advice_id)
870
-		if advices.ExecutionState == 1 {
871
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
872
-			return
873
-		}
874
-		if advices.Checker >= 0 && advices.Checker == adminInfo.AdminUser.Id {
875
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
876
-			return
877
-		}
878
-		if advices.StartTime > theTime.Unix() {
879
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
880
-			return
871
+		advices, _ := service.FindHisDoctorAdviceByIds(adminInfo.Org.Id, ids)
872
+		var err error
873
+		for _, item := range advices {
874
+			if item.ExecutionState == 1 {
875
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
876
+				return
877
+			}
878
+
879
+			if item.Checker >= 0 && item.Checker == adminInfo.AdminUser.Id {
880
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
881
+				return
882
+			}
883
+
884
+			if item.StartTime > theTime.Unix() {
885
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
886
+				return
887
+			}
888
+
889
+			item.ExecutionState = 1
890
+			item.ExecutionStaff = adminInfo.AdminUser.Id
891
+			item.ExecutionTime = theTime.Unix()
892
+			err = service.SaveHisDoctorAdvice(item)
881 893
 		}
882
-		advices.ExecutionState = 1
883
-		advices.ExecutionStaff = adminInfo.AdminUser.Id
884
-		advices.ExecutionTime = theTime.Unix()
885
-		err := service.SaveHisDoctorAdvice(&advices)
886
-		var ids []string
887
-		ids = append(ids, strconv.FormatInt(advices.ID, 10))
894
+
888 895
 		if err == nil {
896
+
889 897
 			//药品管理信息
890 898
 			_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
891 899
 			if drugStockConfig.IsOpen == 1 {
892
-				advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, advice_id)
893
-				//查询该药品是否有库存
894
-				//  list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
895
-				//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
896
-				//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
897
-				//  if list.Count == 0 {
898
-				//    c.ServeSuccessJSON(map[string]interface{}{
899
-				//      "msg":    "1",
900
-				//      "advice": advice,
901
-				//      "ids":    ids,
902
-				//    })
903
-				//    return
904
-				//  }
905
-				//  if count > list.Count {
906
-				//    c.ServeSuccessJSON(map[string]interface{}{
907
-				//      "msg":    "2",
908
-				//      "advice": advice,
909
-				//      "ids":    ids,
910
-				//    })
911
-				//    return
912
-				//}
913
-				var total int64
914
-				var prescribing_number_total int64
915
-				//查询该药品是否有库存
916
-				list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
917
-
918
-				//查询改药品信息
919
-				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
920
-				//判断单位是否相等
921
-				if medical.MaxUnit == advice.PrescribingNumberUnit {
922
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
923
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
924
-					//转化为最小单位
925
-					total = list.Count * medical.MinNumber
926
-					prescribing_number_total = count * medical.MinNumber
927
-				}
928
-				if medical.MinUnit == advice.PrescribingNumberUnit {
929
-					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
930
-					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
931
-					total = list.Count*medical.MinNumber + list.StockMinNumber
932
-					prescribing_number_total = count
933
-				}
900
+				for _, item := range advices {
901
+
902
+					advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
903
+					//查询该药品是否有库存
904
+					//  list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
905
+					//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
906
+					//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
907
+					//  if list.Count == 0 {
908
+					//    c.ServeSuccessJSON(map[string]interface{}{
909
+					//      "msg":    "1",
910
+					//      "advice": advice,
911
+					//      "ids":    ids,
912
+					//    })
913
+					//    return
914
+					//  }
915
+					//  if count > list.Count {
916
+					//    c.ServeSuccessJSON(map[string]interface{}{
917
+					//      "msg":    "2",
918
+					//      "advice": advice,
919
+					//      "ids":    ids,
920
+					//    })
921
+					//    return
922
+					//}
923
+					var total int64
924
+					var prescribing_number_total int64
925
+					//查询该药品是否有库存
926
+					list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
927
+
928
+					//查询改药品信息
929
+					medical, _ := service.GetBaseDrugMedical(advice.DrugId)
930
+					//判断单位是否相等
931
+					if medical.MaxUnit == advice.PrescribingNumberUnit {
932
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
933
+						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
934
+						//转化为最小单位
935
+						total = list.Count * medical.MinNumber
936
+						prescribing_number_total = count * medical.MinNumber
937
+					}
938
+					if medical.MinUnit == advice.PrescribingNumberUnit {
939
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
940
+						count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
941
+						total = list.Count*medical.MinNumber + list.StockMinNumber
942
+						prescribing_number_total = count
943
+					}
934 944
 
935
-				fmt.Println("数量一", prescribing_number_total)
936
-				fmt.Println("数量二", total)
945
+					fmt.Println("数量一", prescribing_number_total)
946
+					fmt.Println("数量二", total)
937 947
 
938
-				if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
939
-					c.ServeSuccessJSON(map[string]interface{}{
940
-						"msg":    "3",
941
-						"advice": advice,
942
-						"ids":    ids,
943
-					})
944
-					return
945
-				}
946
-				if prescribing_number_total > total {
947
-					c.ServeSuccessJSON(map[string]interface{}{
948
-						"msg":    "2",
949
-						"advice": advice,
950
-						"ids":    ids,
951
-					})
952
-					return
953
-				}
954
-				if prescribing_number_total <= total {
955
-					service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
956
-					c.ServeSuccessJSON(map[string]interface{}{
957
-						"msg":    "1",
958
-						"advice": advice,
959
-						"ids":    ids,
960
-					})
961
-					return
948
+					if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
949
+						c.ServeSuccessJSON(map[string]interface{}{
950
+							"msg":    "3",
951
+							"advice": advice,
952
+							"ids":    ids,
953
+						})
954
+						return
955
+					}
956
+					if prescribing_number_total > total {
957
+						c.ServeSuccessJSON(map[string]interface{}{
958
+							"msg":    "2",
959
+							"advice": advice,
960
+							"ids":    ids,
961
+						})
962
+						return
963
+					}
964
+					if prescribing_number_total <= total {
965
+						service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
966
+						c.ServeSuccessJSON(map[string]interface{}{
967
+							"msg":    "1",
968
+							"advice": advice,
969
+							"ids":    ids,
970
+						})
971
+						return
972
+					}
962 973
 				}
963 974
 			}
975
+
964 976
 			c.ServeSuccessJSON(map[string]interface{}{
965 977
 				"msg":    "ok",
966 978
 				"advice": advices,
967 979
 				"ids":    ids,
968 980
 			})
981
+
969 982
 		} else {
970 983
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
971 984
 		}
@@ -1176,41 +1189,37 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1176 1189
 			"advice": advice,
1177 1190
 		})
1178 1191
 	} else if origin == 2 {
1179
-		fmt.Println("金鳌地方 大房贷首付地方阿凡达阿方")
1180 1192
 		adminInfo := c.GetMobileAdminUserInfo()
1181
-		advice_id, _ := c.GetInt64("advice_id")
1182
-		advices, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, advice_id)
1183
-
1184
-		if advices.CheckState == 1 {
1185
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
1186
-			return
1187
-		}
1188
-		if advices.ExecutionStaff >= 0 && advices.ExecutionStaff == adminInfo.AdminUser.Id {
1189
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1190
-			return
1193
+		var ids []string
1194
+		advice_ids := c.GetString("advice_id")
1195
+		ids = strings.Split(advice_ids, ",")
1196
+		advices, _ := service.FindHisDoctorAdviceByIds(adminInfo.Org.Id, ids)
1197
+		var err error
1198
+		for _, item := range advices {
1199
+			if item.CheckState == 1 {
1200
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
1201
+				return
1202
+			}
1203
+			if item.ExecutionStaff >= 0 && item.ExecutionStaff == adminInfo.AdminUser.Id {
1204
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
1205
+				return
1206
+			}
1207
+			item.Checker = adminInfo.AdminUser.Id
1208
+			item.CheckTime = time.Now().Unix()
1209
+			item.CheckState = 1
1210
+			err = service.SaveHisDoctorAdvice(item)
1191 1211
 		}
1192
-
1193
-		advices.Checker = adminInfo.AdminUser.Id
1194
-		advices.CheckTime = time.Now().Unix()
1195
-		advices.CheckState = 1
1196
-
1197
-		err := service.SaveHisDoctorAdvice(&advices)
1198
-
1199 1212
 		if err == nil {
1200 1213
 			c.ServeSuccessJSON(map[string]interface{}{
1201 1214
 				"msg":    "ok",
1202 1215
 				"advice": advices,
1203 1216
 			})
1204
-
1205 1217
 		} else {
1206 1218
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1207 1219
 			return
1208
-
1209 1220
 		}
1210
-
1211 1221
 	}
1212 1222
 	return
1213
-
1214 1223
 }
1215 1224
 
1216 1225
 func (c *PatientApiController) EditAssessmentBeforeDislysis() {

+ 14 - 3
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -324,14 +324,17 @@ func (c *MobileHisApiController) CreateHisPrescription() {
324 324
 
325 325
 								if prescribingNumberUnit == drug.MinUnit {
326 326
 									if prescribing_number > drug.Total {
327
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
327
+										c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
328
+										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
328 329
 										return
329 330
 									}
330 331
 								} else {
331 332
 									if prescribingNumberUnit == drug.MaxUnit {
332 333
 										num := prescribing_number * float64(drug.MinNumber)
333 334
 										if num > drug.Total {
334
-											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
335
+											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
336
+
337
+											//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
335 338
 											return
336 339
 										}
337 340
 									}
@@ -374,7 +377,9 @@ func (c *MobileHisApiController) CreateHisPrescription() {
374 377
 										return
375 378
 									}
376 379
 									if totals > good.Total {
377
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
380
+										c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
381
+
382
+										//c.ServeFailJSONWithSGJErro,rCode(enums.ErrorCodeOutOfStockParamWrong)
378 383
 										return
379 384
 									}
380 385
 
@@ -706,6 +711,11 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
706 711
 			advice.DrugId = drug_id
707 712
 		}
708 713
 	}
714
+	if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
715
+		groupno := int64(json["groupno"].(float64))
716
+		advice.Groupno = groupno
717
+	}
718
+
709 719
 	if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
710 720
 		advice_id := int64(json["advice_id"].(float64))
711 721
 		advice.ID = advice_id
@@ -719,6 +729,7 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
719 729
 					advice.CheckTime = hisAdvice.CheckTime
720 730
 					advice.Checker = hisAdvice.Checker
721 731
 					advice.CheckState = hisAdvice.CheckState
732
+					//advice.Groupno = hisAdvice.Groupno
722 733
 					//advice.StartTime = hisAdvice.StartTime
723 734
 
724 735
 				}

+ 0 - 9
controllers/new_mobile_api_controllers/new_self_drug_api_router.go View File

@@ -1,9 +0,0 @@
1
-package new_mobile_api_controllers
2
-
3
-import "github.com/astaxie/beego"
4
-
5
-func NewDrugApiControllersRegisterRouters() {
6
-
7
-	beego.Router("/m/api/drug/getselfmedicallist", &NewDrugApiController{}, "Get:GetSelfMedicalList")
8
-	beego.Router("/m/api/getdrugdescbydrugname", &NewDrugApiController{}, "Get:GetDrugDescByDrugName")
9
-}

+ 1 - 1
controllers/schedule_api_controller.go View File

@@ -2363,7 +2363,7 @@ func (this *ScheduleApiController) GetBloodScheduleList() {
2363 2363
 
2364 2364
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2365 2365
 	if week_type > 0 {
2366
-		list, err := service.GetWeekDayScheduleById(orgId, targetDay.Unix(), week_time)
2366
+		list, err := service.GetWeekDayScheduleById(orgId, targetDay.Unix(), week_time, zone)
2367 2367
 		if err != nil {
2368 2368
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2369 2369
 			return

+ 7 - 0
enums/error_code.go View File

@@ -489,6 +489,13 @@ func MakeFailResponseJSON(errMsg string, errCode int) map[string]interface{} {
489 489
 	return json
490 490
 }
491 491
 
492
+func MakeDynamicFailResponseJSON(errMsg string) map[string]interface{} {
493
+	json := make(map[string]interface{})
494
+	json["msg"] = errMsg
495
+	json["state"] = 0
496
+	return json
497
+}
498
+
492 499
 func MakeFailResponseJSONWithSGJError(err *SGJError) map[string]interface{} {
493 500
 	if err == nil {
494 501
 		utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")

+ 0 - 1
routers/router.go View File

@@ -2,7 +2,6 @@ package routers
2 2
 
3 3
 import (
4 4
 	"XT_New/controllers"
5
-	//admin_api "XT_New/controllers/admin_api_controllers"
6 5
 	m_api "XT_New/controllers/mobile_api_controllers"
7 6
 	new_m_api "XT_New/controllers/new_mobile_api_controllers"
8 7
 	"github.com/astaxie/beego"

+ 5 - 0
service/dialysis_service.go View File

@@ -1150,6 +1150,11 @@ func FindHisDoctorAdviceById(orgID int64, id int64) (advice models.HisDoctorAdvi
1150 1150
 	return
1151 1151
 }
1152 1152
 
1153
+func FindHisDoctorAdviceByIds(orgID int64, ids []string) (advice []*models.HisDoctorAdviceInfo, err error) {
1154
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id=? and status=1 and id in (?)", orgID, ids).Find(&advice).Error
1155
+	return
1156
+}
1157
+
1153 1158
 func SaveHisDoctorAdvice(advice *models.HisDoctorAdviceInfo) (err error) {
1154 1159
 	err = writeDb.Save(&advice).Error
1155 1160
 	return

+ 10 - 5
service/schedule_service.go View File

@@ -564,7 +564,7 @@ func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Tim
564 564
 	return
565 565
 }
566 566
 
567
-func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64) (list []*models.VmSchedulesRemind, err error) {
567
+func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64, zone int64) (list []*models.VmSchedulesRemind, err error) {
568 568
 
569 569
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
570 570
 	if orgid > 0 {
@@ -576,17 +576,20 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64)
576 576
 	if scheduleType > 0 {
577 577
 		db = db.Where("x.schedule_type = ?", scheduleType)
578 578
 	}
579
+	if zone > 0 {
580
+		db = db.Where("x.partition_id = ?", zone)
581
+	}
579 582
 
580 583
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
581 584
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
582 585
 	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
583
-		return db.Where("status =1").Order("id asc")
586
+		return db.Where("status =1").Order("id desc")
584 587
 	}).Find(&list).Error
585 588
 
586 589
 	return list, err
587 590
 }
588 591
 
589
-func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone int64) (list []*models.VmSchedules, err error) {
592
+func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone int64) (list []*models.VmSchedulesRemind, err error) {
590 593
 
591 594
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
592 595
 	if orgid > 0 {
@@ -599,12 +602,14 @@ func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int
599 602
 		db = db.Where("x.schedule_type = ?", scheduleType)
600 603
 	}
601 604
 	if zone > 0 {
602
-		db = db.Where("s.partition_id = ?", zone)
605
+		db = db.Where("x.partition_id = ?", zone)
603 606
 	}
604 607
 
605 608
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
606 609
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
607
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "user_org_id =? and status = 1", orgid).Find(&list).Error
610
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
611
+		return db.Where("status =1").Order("id desc")
612
+	}).Find(&list).Error
608 613
 
609 614
 	return list, err
610 615
 }