Преглед на файлове

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

XMLWAN преди 4 години
родител
ревизия
66e5f1f658

+ 8 - 1
controllers/dialysis_api_controller.go Целия файл

508
 		//		}
508
 		//		}
509
 		//	}
509
 		//	}
510
 		//}
510
 		//}
511
+		if dialysisPrescription.Creater == 0 {
512
+			prescription.Creater = adminUserInfo.AdminUser.Id
513
+		} else {
514
+			prescription.Creater = dialysisPrescription.Creater
515
+		}
511
 
516
 
512
-		prescription.Creater = adminUserInfo.AdminUser.Id
513
 		prescription.CreatedTime = dialysisPrescription.CreatedTime
517
 		prescription.CreatedTime = dialysisPrescription.CreatedTime
514
 		prescription.UpdatedTime = time.Now().Unix()
518
 		prescription.UpdatedTime = time.Now().Unix()
515
 		prescription.Modifier = adminUserInfo.AdminUser.Id
519
 		prescription.Modifier = adminUserInfo.AdminUser.Id
2164
 	//上次透前评估
2168
 	//上次透前评估
2165
 	lastPredialysisEvaluation, _ := service.GetLastTimePredialysisEvaluation(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2169
 	lastPredialysisEvaluation, _ := service.GetLastTimePredialysisEvaluation(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2166
 
2170
 
2171
+	lastOrder, _ := service.GetLastTimeOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2172
+
2167
 	//透析处方
2173
 	//透析处方
2168
 	dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2174
 	dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2169
 	if dialysisPrescription.PrescriptionDoctor > 0 {
2175
 	if dialysisPrescription.PrescriptionDoctor > 0 {
2264
 		"FinishNuse":                FinishNuse,
2270
 		"FinishNuse":                FinishNuse,
2265
 		"lastPredialysisEvaluation": lastPredialysisEvaluation,
2271
 		"lastPredialysisEvaluation": lastPredialysisEvaluation,
2266
 		"dialysiscount":             dialysiscount,
2272
 		"dialysiscount":             dialysiscount,
2273
+		"last_order":                lastOrder,
2267
 	})
2274
 	})
2268
 
2275
 
2269
 }
2276
 }

+ 120 - 51
controllers/mobile_api_controllers/dialysis_api_controller.go Целия файл

1883
 		prescription.PrescriptionDoctor = prescription_doctor
1883
 		prescription.PrescriptionDoctor = prescription_doctor
1884
 
1884
 
1885
 	}
1885
 	}
1886
+
1886
 	if dialysisPrescription.ID == 0 { //新增
1887
 	if dialysisPrescription.ID == 0 { //新增
1887
 		prescription.Creater = adminUserInfo.AdminUser.Id
1888
 		prescription.Creater = adminUserInfo.AdminUser.Id
1888
 
1889
 
1889
 	} else { //修改
1890
 	} else { //修改
1890
-		prescription.Creater = dialysisPrescription.Creater
1891
+		if dialysisPrescription.Creater == 0 {
1892
+			prescription.Creater = adminUserInfo.AdminUser.Id
1893
+		} else {
1894
+			prescription.Creater = dialysisPrescription.Creater
1895
+		}
1891
 
1896
 
1892
 		//if/**/
1897
 		//if/**/
1893
 		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1898
 		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2878
 func (c *DialysisAPIController) CreateConsumables() {
2883
 func (c *DialysisAPIController) CreateConsumables() {
2879
 	record_date := c.GetString("record_time")
2884
 	record_date := c.GetString("record_time")
2880
 	patient_id, _ := c.GetInt64("patient_id", 0)
2885
 	patient_id, _ := c.GetInt64("patient_id", 0)
2886
+	adminUser := c.GetMobileAdminUserInfo()
2881
 
2887
 
2882
 	timeLayout := "2006-01-02"
2888
 	timeLayout := "2006-01-02"
2883
 	loc, _ := time.LoadLocation("Local")
2889
 	loc, _ := time.LoadLocation("Local")
2935
 					Creater:    adminUser.AdminUser.Id,
2941
 					Creater:    adminUser.AdminUser.Id,
2936
 					Modifier:   0,
2942
 					Modifier:   0,
2937
 				}
2943
 				}
2938
-				beforePrepares = append(beforePrepares, prepare)
2944
+				record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
2945
+				fmt.Println(record_count)
2946
+				if record_count == 0 {
2947
+					beforePrepares = append(beforePrepares, prepare)
2948
+				}
2939
 
2949
 
2940
 			}
2950
 			}
2941
 		}
2951
 		}
2942
 	}
2952
 	}
2943
-	errs := service.CreateDialysisBeforePrepare(beforePrepares)
2953
+
2954
+	if len(beforePrepares) > 0 {
2955
+		service.CreateDialysisBeforePrepare(beforePrepares)
2956
+	}
2957
+	var errs error
2944
 
2958
 
2945
 	if dataBody["update_goods"] != nil && reflect.TypeOf(dataBody["update_goods"]).String() == "[]interface {}" {
2959
 	if dataBody["update_goods"] != nil && reflect.TypeOf(dataBody["update_goods"]).String() == "[]interface {}" {
2946
 		goods, _ := dataBody["update_goods"].([]interface{})
2960
 		goods, _ := dataBody["update_goods"].([]interface{})
3005
 				}
3019
 				}
3006
 				ctime := int64(items["ctime"].(float64))
3020
 				ctime := int64(items["ctime"].(float64))
3007
 
3021
 
3008
-				adminUser := c.GetMobileAdminUserInfo()
3009
 				prepare := &models.DialysisBeforePrepare{
3022
 				prepare := &models.DialysisBeforePrepare{
3010
 					ID:         id,
3023
 					ID:         id,
3011
 					UserOrgId:  adminUser.Org.Id,
3024
 					UserOrgId:  adminUser.Org.Id,
3026
 		}
3039
 		}
3027
 		if len(updateBeforePrepares) > 0 {
3040
 		if len(updateBeforePrepares) > 0 {
3028
 			for _, item := range updateBeforePrepares {
3041
 			for _, item := range updateBeforePrepares {
3029
-				errs = service.UpdateDialysisBeforePrepare(item)
3042
+				errs = service.UpdateDialysisBeforePrepareTwo(item)
3030
 			}
3043
 			}
3031
 		}
3044
 		}
3032
 	}
3045
 	}
3033
-
3034
 	if errs == nil {
3046
 	if errs == nil {
3035
 		c.ServeSuccessJSON(map[string]interface{}{
3047
 		c.ServeSuccessJSON(map[string]interface{}{
3036
 			"msg": "提交成功",
3048
 			"msg": "提交成功",
3037
 		})
3049
 		})
3038
 		return
3050
 		return
3039
-
3040
 	} else {
3051
 	} else {
3041
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3052
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3042
 		return
3053
 		return
3043
 	}
3054
 	}
3044
-
3045
 }
3055
 }
3046
 
3056
 
3047
 func (c *DialysisAPIController) CreateStockOutInfo() {
3057
 func (c *DialysisAPIController) CreateStockOutInfo() {
3184
 					if outInfo.ID > 0 {
3194
 					if outInfo.ID > 0 {
3185
 						service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
3195
 						service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
3186
 					}
3196
 					}
3187
-					details := &models.AutomaticReduceDetail{
3188
-						WarehouseOutId:          outInfo.ID,
3189
-						WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
3190
-						PatientId:               patient_id,
3191
-						Ctime:                   time.Now().Unix(),
3192
-						Mtime:                   time.Now().Unix(),
3193
-						Status:                  1,
3194
-						RecordTime:              record_time,
3195
-						OrgId:                   adminInfo.Org.Id,
3196
-						GoodId:                  item.GoodId,
3197
-						GoodTypeId:              item.GoodTypeId,
3198
-						Count:                   item.Count,
3197
+
3198
+					count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3199
+					if count == 0 {
3200
+						details := &models.AutomaticReduceDetail{
3201
+							WarehouseOutId:          outInfo.ID,
3202
+							WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
3203
+							PatientId:               patient_id,
3204
+							Ctime:                   time.Now().Unix(),
3205
+							Mtime:                   time.Now().Unix(),
3206
+							Status:                  1,
3207
+							RecordTime:              record_time,
3208
+							OrgId:                   adminInfo.Org.Id,
3209
+							GoodId:                  item.GoodId,
3210
+							GoodTypeId:              item.GoodTypeId,
3211
+							Count:                   item.Count,
3212
+						}
3213
+						service.AddSigleAutoReduceRecordInfo(details)
3214
+					} else if count == 1 {
3215
+						service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3199
 					}
3216
 					}
3200
-					service.AddSigleAutoReduceRecordInfo(details)
3217
+
3201
 				}
3218
 				}
3202
 			}
3219
 			}
3203
 		}
3220
 		}
3211
 	}
3228
 	}
3212
 
3229
 
3213
 }
3230
 }
3214
-
3215
 func (c *DialysisAPIController) EditConsumables() {
3231
 func (c *DialysisAPIController) EditConsumables() {
3216
 	patient_id, _ := c.GetInt64("patient_id", 0)
3232
 	patient_id, _ := c.GetInt64("patient_id", 0)
3217
 	record_date := c.GetString("record_time")
3233
 	record_date := c.GetString("record_time")
3373
 					newBeforePrepares = append(newBeforePrepares, prepare)
3389
 					newBeforePrepares = append(newBeforePrepares, prepare)
3374
 
3390
 
3375
 				}
3391
 				}
3392
+				newBeforePrepares = RemoveRepeatedGood(newBeforePrepares)
3376
 			}
3393
 			}
3377
 			service.CreateDialysisBeforePrepare(newBeforePrepares)
3394
 			service.CreateDialysisBeforePrepare(newBeforePrepares)
3378
 		}
3395
 		}
3449
 		} else if err == nil {
3466
 		} else if err == nil {
3450
 
3467
 
3451
 			if len(newBeforePrepares) > 0 { //新增
3468
 			if len(newBeforePrepares) > 0 { //新增
3469
+
3452
 				for _, item := range newBeforePrepares {
3470
 				for _, item := range newBeforePrepares {
3453
 					outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
3471
 					outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
3454
 
3472
 
3474
 						warehouseOutInfo.Count = item.Count
3492
 						warehouseOutInfo.Count = item.Count
3475
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3493
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3476
 						if err == nil {
3494
 						if err == nil {
3495
+
3496
+							count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3497
+							if count == 0 {
3498
+								details := &models.AutomaticReduceDetail{
3499
+									WarehouseOutId:          warehouseOutInfo.ID,
3500
+									WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
3501
+									PatientId:               patient_id,
3502
+									Ctime:                   time.Now().Unix(),
3503
+									Mtime:                   time.Now().Unix(),
3504
+									Status:                  1,
3505
+									RecordTime:              record_time,
3506
+									OrgId:                   adminInfo.Org.Id,
3507
+									GoodId:                  item.GoodId,
3508
+									GoodTypeId:              item.GoodTypeId,
3509
+									Count:                   item.Count,
3510
+								}
3511
+								service.AddSigleAutoReduceRecordInfo(details)
3512
+							} else if count == 1 {
3513
+								service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3514
+							}
3515
+
3516
+						}
3517
+					} else if err == nil { //记录存在,则将加数量
3518
+						if outInfo.ID > 0 {
3519
+							service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
3520
+						}
3521
+
3522
+						count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3523
+						if count == 0 {
3477
 							details := &models.AutomaticReduceDetail{
3524
 							details := &models.AutomaticReduceDetail{
3478
-								WarehouseOutId:          warehouseOutInfo.ID,
3479
-								WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
3525
+								WarehouseOutId:          outInfo.ID,
3526
+								WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
3480
 								PatientId:               patient_id,
3527
 								PatientId:               patient_id,
3481
 								Ctime:                   time.Now().Unix(),
3528
 								Ctime:                   time.Now().Unix(),
3482
 								Mtime:                   time.Now().Unix(),
3529
 								Mtime:                   time.Now().Unix(),
3488
 								Count:                   item.Count,
3535
 								Count:                   item.Count,
3489
 							}
3536
 							}
3490
 							service.AddSigleAutoReduceRecordInfo(details)
3537
 							service.AddSigleAutoReduceRecordInfo(details)
3538
+						} else if count == 1 {
3539
+							service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3491
 						}
3540
 						}
3492
-					} else if err == nil { //记录存在,则将加数量
3493
-						if outInfo.ID > 0 {
3494
-							service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
3495
-						}
3496
-						details := &models.AutomaticReduceDetail{
3497
-							WarehouseOutId:          outInfo.ID,
3498
-							WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
3499
-							PatientId:               patient_id,
3500
-							Ctime:                   time.Now().Unix(),
3501
-							Mtime:                   time.Now().Unix(),
3502
-							Status:                  1,
3503
-							RecordTime:              record_time,
3504
-							OrgId:                   adminInfo.Org.Id,
3505
-							GoodId:                  item.GoodId,
3506
-							GoodTypeId:              item.GoodTypeId,
3507
-							Count:                   item.Count,
3508
-						}
3509
-						service.AddSigleAutoReduceRecordInfo(details)
3541
+						//details := &models.AutomaticReduceDetail{
3542
+						//	WarehouseOutId:          outInfo.ID,
3543
+						//	WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
3544
+						//	PatientId:               patient_id,
3545
+						//	Ctime:                   time.Now().Unix(),
3546
+						//	Mtime:                   time.Now().Unix(),
3547
+						//	Status:                  1,
3548
+						//	RecordTime:              record_time,
3549
+						//	OrgId:                   adminInfo.Org.Id,
3550
+						//	GoodId:                  item.GoodId,
3551
+						//	GoodTypeId:              item.GoodTypeId,
3552
+						//	Count:                   item.Count,
3553
+						//}
3554
+						//service.AddSigleAutoReduceRecordInfo(details)
3510
 					}
3555
 					}
3511
 				}
3556
 				}
3512
 
3557
 
3513
 			}
3558
 			}
3514
 
3559
 
3515
-			if len(consumables_source) > 0 { //修改
3560
+			if len(beforePrepares) > 0 { //修改
3516
 				for _, consumable := range consumables_source {
3561
 				for _, consumable := range consumables_source {
3517
 					for _, before := range beforePrepares {
3562
 					for _, before := range beforePrepares {
3518
-						if consumable.GoodId == before.GoodId && consumable.GoodTypeId == before.GoodTypeId {
3519
-							if consumable.Count != before.Count {
3520
 
3563
 
3521
-								_, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
3564
+						if consumable.GoodId == before.GoodId {
3565
+							fmt.Println(consumable.Count)
3566
+							fmt.Println(before.Count)
3522
 
3567
 
3568
+							if consumable.Count != before.Count {
3569
+								fmt.Println("111111111")
3570
+								_, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
3523
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3571
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3524
-
3525
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3572
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3526
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3573
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3527
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3574
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3575
+									fmt.Println("222222222")
3576
+
3528
 									warehouseOutInfo := &models.WarehouseOutInfo{
3577
 									warehouseOutInfo := &models.WarehouseOutInfo{
3529
 										WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
3578
 										WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
3530
 										WarehouseOutId:          out.ID,
3579
 										WarehouseOutId:          out.ID,
3571
 										}
3620
 										}
3572
 									}
3621
 									}
3573
 								} else if err == nil { //存在,则更改使用人商品信息
3622
 								} else if err == nil { //存在,则更改使用人商品信息
3623
+									fmt.Println("333333333")
3624
+
3574
 									//处理原来的数据
3625
 									//处理原来的数据
3575
 									if newOut.ID > 0 {
3626
 									if newOut.ID > 0 {
3576
 										if consumable.Count > before.Count { // 减少
3627
 										if consumable.Count > before.Count { // 减少
3609
 									}
3660
 									}
3610
 								}
3661
 								}
3611
 
3662
 
3663
+								fmt.Println("444444444")
3664
+
3612
 							}
3665
 							}
3613
 						}
3666
 						}
3614
 					}
3667
 					}
3615
 				}
3668
 				}
3616
 			}
3669
 			}
3617
 		}
3670
 		}
3671
+		fmt.Println("655555555")
3618
 
3672
 
3619
 		var errs error
3673
 		var errs error
3620
 		if len(beforePrepares) > 0 {
3674
 		if len(beforePrepares) > 0 {
3621
 			for _, item := range beforePrepares {
3675
 			for _, item := range beforePrepares {
3622
-				errs = service.UpdateDialysisBeforePrepare(item)
3676
+				errs = service.UpdateDialysisBeforePrepareTwo(item)
3623
 			}
3677
 			}
3624
 		}
3678
 		}
3625
 		if errs == nil {
3679
 		if errs == nil {
3767
 		var errs error
3821
 		var errs error
3768
 		if len(beforePrepares) > 0 {
3822
 		if len(beforePrepares) > 0 {
3769
 			for _, item := range beforePrepares {
3823
 			for _, item := range beforePrepares {
3770
-				errs = service.UpdateDialysisBeforePrepare(item)
3824
+				errs = service.UpdateDialysisBeforePrepareTwo(item)
3771
 			}
3825
 			}
3772
 		}
3826
 		}
3773
 		if errs == nil {
3827
 		if errs == nil {
3916
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
3970
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
3917
 
3971
 
3918
 	goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
3972
 	goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
3919
-	lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(patient_id, adminUser.Org.Id, date.Unix())
3973
+	lastGoodUserDetial, _ := service.GetLastDialysisGoods(patient_id, adminUser.Org.Id, date.Unix())
3920
 	c.ServeSuccessJSON(map[string]interface{}{
3974
 	c.ServeSuccessJSON(map[string]interface{}{
3921
 		"good_type":      goodTypes,
3975
 		"good_type":      goodTypes,
3922
 		"good_user":      goodUser,
3976
 		"good_user":      goodUser,
3926
 	return
3980
 	return
3927
 
3981
 
3928
 }
3982
 }
3929
-
3930
 func (c *DialysisAPIController) CreateOtherStockOutInfo() {
3983
 func (c *DialysisAPIController) CreateOtherStockOutInfo() {
3931
 	patient_id, _ := c.GetInt64("patient_id", 0)
3984
 	patient_id, _ := c.GetInt64("patient_id", 0)
3932
 	record_date := c.GetString("record_time")
3985
 	record_date := c.GetString("record_time")
4149
 	}
4202
 	}
4150
 
4203
 
4151
 }
4204
 }
4205
+func RemoveRepeatedGood(arr []*models.DialysisBeforePrepare) (newArr []*models.DialysisBeforePrepare) {
4206
+	newArr = make([]*models.DialysisBeforePrepare, 0)
4207
+	for i := 0; i < len(arr); i++ {
4208
+		repeat := false
4209
+		for j := i + 1; j < len(arr); j++ {
4210
+			if arr[i].GoodId == arr[j].GoodId && arr[i].GoodTypeId == arr[j].GoodTypeId {
4211
+				repeat = true
4212
+				break
4213
+			}
4214
+		}
4215
+		if !repeat {
4216
+			newArr = append(newArr, arr[i])
4217
+		}
4218
+	}
4219
+	return
4220
+}

+ 3 - 0
controllers/mobile_api_controllers/patient_api_controller.go Целия файл

2149
 		}
2149
 		}
2150
 	}
2150
 	}
2151
 
2151
 
2152
+	last_order, _ := service.GetLastTimeOrder(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2153
+
2152
 	//透前评估
2154
 	//透前评估
2153
 	PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2155
 	PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2154
 
2156
 
2213
 		"org_template_info":       templateInfo,
2215
 		"org_template_info":       templateInfo,
2214
 		"check":                   check,
2216
 		"check":                   check,
2215
 		"dialysiscount":           dialysiscount,
2217
 		"dialysiscount":           dialysiscount,
2218
+		"last_order":              last_order,
2216
 	})
2219
 	})
2217
 
2220
 
2218
 }
2221
 }

+ 1 - 1
controllers/verify_login_controller.go Целия файл

237
 							role, _ := service.GetRoleByRoleID(id)
237
 							role, _ := service.GetRoleByRoleID(id)
238
 							var system_ids = ""
238
 							var system_ids = ""
239
 							if role.RoleName == "子管理员" && role.IsSystem > 0 {
239
 							if role.RoleName == "子管理员" && role.IsSystem > 0 {
240
-								purviews, _ := service.GetSystemPurview()
240
+								purviews, _ := service.GetAllSystemPurview()
241
 								for _, purview := range purviews {
241
 								for _, purview := range purviews {
242
 									if len(system_ids) == 0 {
242
 									if len(system_ids) == 0 {
243
 										system_ids = strconv.FormatInt(purview.Id, 10)
243
 										system_ids = strconv.FormatInt(purview.Id, 10)

+ 27 - 0
models/monitor_models.go Целия файл

1
 package models
1
 package models
2
 
2
 
3
+type VMMonitorDialysisSchedule struct {
4
+	ID           int64 `gorm:"column:id" json:"id"`
5
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
6
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id"`
7
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id"`
8
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
9
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
10
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
11
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
12
+	Status       int64 `gorm:"column:status" json:"status"`
13
+
14
+	MonitorPatients MonitorPatients `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            MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
20
+	Prescription             DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
21
+	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
22
+	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
23
+	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
24
+}
25
+
26
+func (VMMonitorDialysisSchedule) TableName() string {
27
+	return "xt_schedule"
28
+}
29
+
3
 type MonitorDialysisSchedule struct {
30
 type MonitorDialysisSchedule struct {
4
 	ID           int64 `gorm:"column:id" json:"id"`
31
 	ID           int64 `gorm:"column:id" json:"id"`
5
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
32
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`

+ 2 - 1
service/auto_clear_schedules_service.go Целия файл

39
 				"s.user_org_id = ? AND "+
39
 				"s.user_org_id = ? AND "+
40
 				"NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where  d.`status` = 1 AND"+
40
 				"NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where  d.`status` = 1 AND"+
41
 				" d.`patient_id` = s.patient_id AND "+
41
 				" d.`patient_id` = s.patient_id AND "+
42
-				" d.user_org_id = s.user_org_id AND d.dialysis_date = s.schedule_date)", scheduleDate.Unix(), item.UserOrgId).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()})
42
+				" d.user_org_id = s.user_org_id AND d.dialysis_date = s.schedule_date)", scheduleDate.Unix(), item.UserOrgId).
43
+			Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()})
43
 	}
44
 	}
44
 	utils.SuccessLog("自动清除排班任务完成")
45
 	utils.SuccessLog("自动清除排班任务完成")
45
 }
46
 }

+ 25 - 9
service/dialysis_service.go Целия файл

36
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
36
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
37
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
37
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
38
 		Preload("TreatmentMode", "status = 1").
38
 		Preload("TreatmentMode", "status = 1").
39
-		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
40
-		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
41
-		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
42
-		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
43
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
39
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, schedulDate).
40
+		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, schedulDate).
41
+		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, schedulDate).
42
+		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? AND monitoring_date = ?", orgID, schedulDate).
43
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, schedulDate).
44
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
44
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
45
 	db = db.Where("status = 1")
45
 	db = db.Where("status = 1")
46
 	if schedulDate > 0 {
46
 	if schedulDate > 0 {
609
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
609
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
610
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
610
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
611
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
611
 		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
612
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
613
-		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ?", orgID).
614
-		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
615
-		Preload("TreatmentSummary", "status = 1 AND user_org_id = ?", orgID).
612
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
613
+		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND  assessment_date = ?", orgID, scheduleDate).
614
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
615
+		Preload("TreatmentSummary", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
616
+		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
617
+
616
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
618
 		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
617
 		Where("status = 1 AND user_org_id = ?", orgID)
619
 		Where("status = 1 AND user_org_id = ?", orgID)
618
 	if scheduleDate != 0 {
620
 	if scheduleDate != 0 {
1066
 	return err
1068
 	return err
1067
 }
1069
 }
1068
 
1070
 
1071
+func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err error) {
1072
+	err = writeDb.Model(&models.DialysisBeforePrepare{}).
1073
+		Where("status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND user_org_id = ? AND record_date = ?", info.GoodId, info.GoodTypeId, info.PatientId, info.UserOrgId, info.RecordDate).
1074
+		Updates(map[string]interface{}{"count": info.Count, "updated_time": time.Now().Unix(), "modifier": info.Modifier}).Error
1075
+
1076
+	return err
1077
+}
1078
+
1069
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1079
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1070
 	writeDb.Model(&models.WarehouseOutInfo{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, number).UpdateColumn("count", gorm.Expr("count - ?", count))
1080
 	writeDb.Model(&models.WarehouseOutInfo{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, number).UpdateColumn("count", gorm.Expr("count - ?", count))
1071
 
1081
 
1081
 	//writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber).UpdateColumn("count", count)
1091
 	//writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber).UpdateColumn("count", count)
1082
 
1092
 
1083
 }
1093
 }
1094
+
1095
+func FindDialysisBeforePrepare(patient_id int64, good_id int64, good_type_id int64, user_org_id int64, record_time int64) (count int64) {
1096
+	readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ?  AND good_id = ? AND good_type_id = ? AND record_date = ? AND status = 1", user_org_id, patient_id, good_id, good_type_id, record_time).Count(&count)
1097
+	return
1098
+
1099
+}

+ 26 - 11
service/mobile_dialysis_service.go Целия файл

30
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
30
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
31
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
31
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
32
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
32
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
33
-		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2", orgID).
33
+		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 AND advice_date = ? ", orgID, scheduleDate).
34
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
34
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
36
-		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
36
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38
-		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
39
-		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ?", orgID).
38
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
39
+		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
40
 
40
 
41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
115
 
115
 
116
 	SchedualPatient          *MSchedualPatientVMList           `gorm:"ForeignKey:PatientId" json:"patient"`
116
 	SchedualPatient          *MSchedualPatientVMList           `gorm:"ForeignKey:PatientId" json:"patient"`
117
 	DeviceNumber             *MDeviceNumberVM                  `gorm:"ForeignKey:BedId" json:"device_number"`
117
 	DeviceNumber             *MDeviceNumberVM                  `gorm:"ForeignKey:BedId" json:"device_number"`
118
-	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
119
-	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
120
-	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
121
-	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
118
+	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
119
+	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
120
+	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
121
+	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
122
 
122
 
123
-	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
124
-	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
123
+	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
124
+	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
125
 }
125
 }
126
 
126
 
127
 func (MDialysisScheduleVM) TableName() string {
127
 func (MDialysisScheduleVM) TableName() string {
290
 	Status         int64 `gorm:"column:status" json:"status" form:"status"`
290
 	Status         int64 `gorm:"column:status" json:"status" form:"status"`
291
 	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
291
 	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
292
 	RecordDate     int64 `gorm:"column:record_date" json:"record_date"`
292
 	RecordDate     int64 `gorm:"column:record_date" json:"record_date"`
293
+	CheckTime      int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
294
+	CheckState     int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
293
 }
295
 }
294
 
296
 
295
 func (VMDoctorAdvice) TableName() string {
297
 func (VMDoctorAdvice) TableName() string {
1173
 	return &record, nil
1175
 	return &record, nil
1174
 }
1176
 }
1175
 
1177
 
1178
+func GetLastTimeOrder(orgID int64, patientID int64, maxDate int64) (*models.DialysisOrder, error) {
1179
+	var record models.DialysisOrder
1180
+	err := readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? and user_org_id = ? and status = 1 and dialysis_date < ?", patientID, orgID, maxDate).Order("dialysis_date desc").First(&record).Error
1181
+	if err != nil {
1182
+		if err == gorm.ErrRecordNotFound {
1183
+			return nil, nil
1184
+		} else {
1185
+			return nil, err
1186
+		}
1187
+	}
1188
+	return &record, nil
1189
+}
1190
+
1176
 func GetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
1191
 func GetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
1177
 	var record models.MonitoringRecord
1192
 	var record models.MonitoringRecord
1178
 	err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
1193
 	err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
1301
 }
1316
 }
1302
 
1317
 
1303
 func FindConsumablesByDate(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error) {
1318
 func FindConsumablesByDate(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error) {
1304
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 	AND count > 0", orgID, patient_id, recordDate).Find(&consumables).Error
1319
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", orgID, patient_id, recordDate).Find(&consumables).Error
1305
 	return
1320
 	return
1306
 }
1321
 }
1307
 
1322
 

+ 6 - 6
service/patient_service.go Целия файл

994
 	return
994
 	return
995
 }
995
 }
996
 
996
 
997
-func GetMonitorRecord(orgID int64, date int64, partition int64) ([]*models.MonitorDialysisSchedule, error) {
998
-	var mds []*models.MonitorDialysisSchedule
997
+func GetMonitorRecord(orgID int64, date int64, partition int64) ([]*models.VMMonitorDialysisSchedule, error) {
998
+	var mds []*models.VMMonitorDialysisSchedule
999
 	db := readDb.
999
 	db := readDb.
1000
-		Model(&models.MonitorDialysisSchedule{}).
1000
+		Model(&models.VMMonitorDialysisSchedule{}).
1001
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1001
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1002
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1002
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1003
 		Preload("TreatmentMode", "status = 1").
1003
 		Preload("TreatmentMode", "status = 1").
1019
 	return mds, err
1019
 	return mds, err
1020
 }
1020
 }
1021
 
1021
 
1022
-func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*models.MonitorDialysisSchedule, error) {
1022
+func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*models.VMMonitorDialysisSchedule, error) {
1023
 	var patients []*models.Patients
1023
 	var patients []*models.Patients
1024
 	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
1024
 	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
1025
 	if getPatientErr != nil {
1025
 	if getPatientErr != nil {
1031
 	}
1031
 	}
1032
 
1032
 
1033
 	db := readDb.
1033
 	db := readDb.
1034
-		Model(&models.MonitorDialysisSchedule{}).
1034
+		Model(&models.VMMonitorDialysisSchedule{}).
1035
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1035
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1036
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1036
 		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1037
 		Preload("TreatmentMode", "status = 1").
1037
 		Preload("TreatmentMode", "status = 1").
1043
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1043
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1044
 		Where("status = 1 AND user_org_id = ? AND patient_id in (?)", orgID, patientIDs)
1044
 		Where("status = 1 AND user_org_id = ? AND patient_id in (?)", orgID, patientIDs)
1045
 
1045
 
1046
-	var schedules []*models.MonitorDialysisSchedule
1046
+	var schedules []*models.VMMonitorDialysisSchedule
1047
 	err := db.Offset(20 * (page - 1)).Limit(20).Order("schedule_date desc").Find(&schedules).Error
1047
 	err := db.Offset(20 * (page - 1)).Limit(20).Order("schedule_date desc").Find(&schedules).Error
1048
 	return schedules, err
1048
 	return schedules, err
1049
 }
1049
 }

+ 5 - 0
service/role_service.go Целия файл

761
 	err = readUserDb.Model(&models.Purview{}).Where("status = 1 AND module = 3 AND super_admin_exclusive = 1").Find(&purview).Error
761
 	err = readUserDb.Model(&models.Purview{}).Where("status = 1 AND module = 3 AND super_admin_exclusive = 1").Find(&purview).Error
762
 	return
762
 	return
763
 }
763
 }
764
+
765
+func GetAllSystemPurview() (purview []*models.Purview, err error) {
766
+	err = readUserDb.Model(&models.Purview{}).Where("status = 1 AND module = 3 ").Find(&purview).Error
767
+	return
768
+}

+ 7 - 0
service/stock_service.go Целия файл

1257
 
1257
 
1258
 }
1258
 }
1259
 
1259
 
1260
+func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
1261
+
1262
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ?", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
1263
+	return
1264
+
1265
+}
1266
+
1260
 type VMWarehousingInfo struct {
1267
 type VMWarehousingInfo struct {
1261
 	ID            int64    `gorm:"column:id" json:"id"`
1268
 	ID            int64    `gorm:"column:id" json:"id"`
1262
 	WarehousingId int64    `gorm:"column:warehousing_id" json:"warehousing_id"`
1269
 	WarehousingId int64    `gorm:"column:warehousing_id" json:"warehousing_id"`