28169 2 mēnešus atpakaļ
vecāks
revīzija
338d35ec0b
43 mainītis faili ar 2092 papildinājumiem un 777 dzēšanām
  1. Binārs
      XT_New.exe
  2. 8 8
      controllers/base_api_controller.go
  3. 16 7
      controllers/dialysis_api_controller.go
  4. 10 0
      controllers/dialysis_record_api_controller.go
  5. 6 1
      controllers/doctors_api_controller.go
  6. 2 0
      controllers/drug_pharmacy_management_controller.go
  7. 32 10
      controllers/drug_stock_api_contorller.go
  8. 8 4
      controllers/gobal_config_api_controller.go
  9. 576 459
      controllers/his_api_controller.go
  10. 0 1
      controllers/inspection_api_controller.go
  11. 6 2
      controllers/mobile_api_controllers/check_weight_api_controller.go
  12. 42 7
      controllers/mobile_api_controllers/dialysis_api_controller.go
  13. 322 56
      controllers/mobile_api_controllers/patient_api_controller.go
  14. 0 1
      controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go
  15. 6 4
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  16. 2 0
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  17. 22 9
      controllers/print_data_api_controller.go
  18. 8 1
      controllers/schedule_api_controller.go
  19. 2 0
      controllers/self_drug_api_congtroller.go
  20. 143 0
      controllers/sign_api_controller.go
  21. 34 7
      controllers/stock_in_api_controller.go
  22. 3 0
      enums/error_code.go
  23. 80 79
      models/good_models.go
  24. 62 0
      models/new_stock_models.go
  25. 17 0
      models/patient_models.go
  26. 83 83
      models/stock_models.go
  27. 3 3
      service/dialysis_parameter_service.go
  28. 23 0
      service/dialysis_service.go
  29. 1 0
      service/dialysis_solution_service.go
  30. 14 2
      service/drug_stock_service.go
  31. 24 4
      service/gobal_config_service.go
  32. 9 0
      service/inspection_service.go
  33. 1 0
      service/mobile_dialysis_service.go
  34. 37 8
      service/new_warehouse_service.go
  35. 14 5
      service/patient_service.go
  36. 2 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  37. 42 2
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  38. 9 0
      service/schedule_service.go
  39. 7 0
      service/self_drug_service.go
  40. 15 0
      service/sign_service.go
  41. 6 6
      service/statistis_qc_service.go
  42. 120 7
      service/stock_service.go
  43. 275 1
      service/warhouse_service.go

Binārs
XT_New.exe Parādīt failu


+ 8 - 8
controllers/base_api_controller.go Parādīt failu

72
 	this.BaseAPIController.Prepare()
72
 	this.BaseAPIController.Prepare()
73
 	if this.GetAdminUserInfo() == nil {
73
 	if this.GetAdminUserInfo() == nil {
74
 		var userAdmin models.AdminUser
74
 		var userAdmin models.AdminUser
75
-		userAdmin.Id = 2301
75
+		userAdmin.Id = 4522
76
 		userAdmin.Mobile = "13318599895"
76
 		userAdmin.Mobile = "13318599895"
77
 
77
 
78
-		userAdmin.Id = 2301 //4,809
78
+		userAdmin.Id = 4522 //4,809
79
 		userAdmin.Mobile = "12222222222"
79
 		userAdmin.Mobile = "12222222222"
80
 		userAdmin.IsSuperAdmin = true
80
 		userAdmin.IsSuperAdmin = true
81
 		userAdmin.Status = 1
81
 		userAdmin.Status = 1
83
 		userAdmin.ModifyTime = 1530786071
83
 		userAdmin.ModifyTime = 1530786071
84
 		var subscibe models.ServeSubscibe
84
 		var subscibe models.ServeSubscibe
85
 		subscibe.ID = 11
85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10164 //机构id
86
+		subscibe.OrgId = 10028 //机构id
87
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodStart = 1547447814
88
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.PeriodEnd = 1550039814
89
 		subscibe.State = 1
89
 		subscibe.State = 1
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94
 		subscibes[4] = &subscibe
94
 		subscibes[4] = &subscibe
95
 		var adminUserInfo service.AdminUserInfo
95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10028 //机构id小英9675或4
97
 		adminUserInfo.CurrentAppId = 12123 //4
97
 		adminUserInfo.CurrentAppId = 12123 //4
98
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.AdminUser = &userAdmin
99
 		adminUserInfo.Subscibes = subscibes
99
 		adminUserInfo.Subscibes = subscibes
318
 	this.BaseAPIController.Prepare()
318
 	this.BaseAPIController.Prepare()
319
 	if this.GetAdminUserInfo() == nil {
319
 	if this.GetAdminUserInfo() == nil {
320
 		var userAdmin models.AdminUser
320
 		var userAdmin models.AdminUser
321
-		userAdmin.Id = 2301
321
+		userAdmin.Id = 4522
322
 		userAdmin.Mobile = "13318599895"
322
 		userAdmin.Mobile = "13318599895"
323
 
323
 
324
-		userAdmin.Id = 2301 //4,809
324
+		userAdmin.Id = 4522 //4,809
325
 		userAdmin.Mobile = "12222222222"
325
 		userAdmin.Mobile = "12222222222"
326
 		userAdmin.IsSuperAdmin = false
326
 		userAdmin.IsSuperAdmin = false
327
 		userAdmin.Status = 1
327
 		userAdmin.Status = 1
329
 		userAdmin.ModifyTime = 1530786071
329
 		userAdmin.ModifyTime = 1530786071
330
 		var subscibe models.ServeSubscibe
330
 		var subscibe models.ServeSubscibe
331
 		subscibe.ID = 11
331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10164 //机构id小英9675或4
332
+		subscibe.OrgId = 10028 //机构id小英9675或4
333
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodStart = 1538035409
334
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.PeriodEnd = 1569571409
335
 		subscibe.State = 1
335
 		subscibe.State = 1
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
 		subscibes[4] = &subscibe
340
 		subscibes[4] = &subscibe
341
 		var adminUserInfo service.AdminUserInfo
341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10028 //机构id小英9675或4
343
 		adminUserInfo.CurrentAppId = 12123 //4
343
 		adminUserInfo.CurrentAppId = 12123 //4
344
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.AdminUser = &userAdmin
345
 		adminUserInfo.Subscibes = subscibes
345
 		adminUserInfo.Subscibes = subscibes

+ 16 - 7
controllers/dialysis_api_controller.go Parādīt failu

2858
 			service.CreateDialysisFinish(finish)
2858
 			service.CreateDialysisFinish(finish)
2859
 		}
2859
 		}
2860
 
2860
 
2861
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10731 || adminUserInfo.CurrentOrgId == 10727 {
2861
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 {
2862
 			var dewater_amount float64
2862
 			var dewater_amount float64
2863
 			dewater_amount = 0
2863
 			dewater_amount = 0
2864
 			if dry_weight > 0 {
2864
 			if dry_weight > 0 {
3227
 		dewater_amount = 0
3227
 		dewater_amount = 0
3228
 		if evaluation.DryWeight > 0 {
3228
 		if evaluation.DryWeight > 0 {
3229
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3229
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3230
-			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 {
3231
-				if adminUserInfo.CurrentOrgId != 10551 {
3230
+			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 {
3231
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3232
 					dewater_amount = dewater_amount * 1000
3232
 					dewater_amount = dewater_amount * 1000
3233
 				}
3233
 				}
3234
 
3234
 
3505
 		}
3505
 		}
3506
 
3506
 
3507
 		//针对孝昌康桥超滤率计算问题
3507
 		//针对孝昌康桥超滤率计算问题
3508
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 {
3508
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 {
3509
 			if assessmentBeforeDislysis.ID == 0 {
3509
 			if assessmentBeforeDislysis.ID == 0 {
3510
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3510
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3511
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3511
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3512
 					dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3512
 					dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3513
-
3513
+					if adminUserInfo.CurrentOrgId == 10751 {
3514
+						dewater_amount = dewater_amount * 1000
3515
+					}
3514
 					service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
3516
 					service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
3515
 				}
3517
 				}
3516
 			}
3518
 			}
3519
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3521
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3520
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3522
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3521
 					dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3523
 					dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3522
-
3524
+					if adminUserInfo.CurrentOrgId == 10751 {
3525
+						dewater_amount = dewater_amount * 1000
3526
+					}
3523
 					service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
3527
 					service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
3524
 				}
3528
 				}
3525
 			}
3529
 			}
6004
 				var dewater_amount float64
6008
 				var dewater_amount float64
6005
 
6009
 
6006
 				dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
6010
 				dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
6011
+				if adminUserInfo.CurrentOrgId != 10702 {
6012
+					service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
6013
+				}
6014
+				if adminUserInfo.CurrentOrgId == 10702 {
6015
+					service.UpdatePatientDialysisPrscriptionOne(dialysisPrescription.ID, dewater_amount)
6016
+				}
6007
 
6017
 
6008
-				service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
6009
 				//获取key,清空redis
6018
 				//获取key,清空redis
6010
 				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
6019
 				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
6011
 				redis := service.RedisClient()
6020
 				redis := service.RedisClient()

+ 10 - 0
controllers/dialysis_record_api_controller.go Parādīt failu

87
 		redis.Set(key, scheduals_json_str, time.Second*60)
87
 		redis.Set(key, scheduals_json_str, time.Second*60)
88
 	}
88
 	}
89
 
89
 
90
+	redis.Set(key, "", time.Second)
91
+
90
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
92
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
91
 
93
 
92
 		scheduals, err := service.GetDialysisSchedualsOne(orgID, date.Unix())
94
 		scheduals, err := service.GetDialysisSchedualsOne(orgID, date.Unix())
111
 
113
 
112
 				inforMation, _ := service.GetTodayInforMation(orgID, date.Unix())
114
 				inforMation, _ := service.GetTodayInforMation(orgID, date.Unix())
113
 
115
 
116
+				solution, _ := service.GetDialysisSolutionByDate(orgID)
117
+
114
 				for key, item := range scheduals {
118
 				for key, item := range scheduals {
115
 
119
 
116
 					for _, infor := range inforMation {
120
 					for _, infor := range inforMation {
173
 							break
177
 							break
174
 						}
178
 						}
175
 					}
179
 					}
180
+
181
+					for _, solut := range solution {
182
+						if solut.PatientId == item.PatientId && solut.ModeId == item.ModeId {
183
+							scheduals[key].DialysisSolution = solut
184
+						}
185
+					}
176
 				}
186
 				}
177
 
187
 
178
 				//缓存数据
188
 				//缓存数据

+ 6 - 1
controllers/doctors_api_controller.go Parādīt failu

372
 
372
 
373
 			dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
373
 			dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
374
 
374
 
375
-			service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
375
+			if adminUserInfo.CurrentOrgId != 10702 {
376
+				service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
377
+			}
378
+			if adminUserInfo.CurrentOrgId == 10702 {
379
+				service.UpdatePatientDialysisPrscriptionOne(dialysisPrescription.ID, dewater_amount)
380
+			}
376
 			//获取key,清空redis
381
 			//获取key,清空redis
377
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
382
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
378
 			redis := service.RedisClient()
383
 			redis := service.RedisClient()

+ 2 - 0
controllers/drug_pharmacy_management_controller.go Parādīt failu

46
 	//获取药房发药药品库数据
46
 	//获取药房发药药品库数据
47
 	appId := this.GetAdminUserInfo().CurrentAppId
47
 	appId := this.GetAdminUserInfo().CurrentAppId
48
 	doctorlist, err := service.GetAllDoctorSix(orgId, appId)
48
 	doctorlist, err := service.GetAllDoctorSix(orgId, appId)
49
+	drug, _ := service.GetAllBaseDrugList(orgId)
49
 	if err == nil {
50
 	if err == nil {
50
 		this.ServeSuccessJSON(map[string]interface{}{
51
 		this.ServeSuccessJSON(map[string]interface{}{
51
 			"doctorlist": doctorlist,
52
 			"doctorlist": doctorlist,
53
+			"drug":       drug,
52
 		})
54
 		})
53
 	} else {
55
 	} else {
54
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
56
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 32 - 10
controllers/drug_stock_api_contorller.go Parādīt failu

3169
 	order_type, _ := c.GetInt64("order_type")
3169
 	order_type, _ := c.GetInt64("order_type")
3170
 
3170
 
3171
 	storehouse_id, _ := c.GetInt64("storehouse_id")
3171
 	storehouse_id, _ := c.GetInt64("storehouse_id")
3172
+	drug_id, _ := c.GetInt64("drug_id")
3172
 	timeLayout := "2006-01-02"
3173
 	timeLayout := "2006-01-02"
3173
 	loc, _ := time.LoadLocation("Local")
3174
 	loc, _ := time.LoadLocation("Local")
3174
 
3175
 
3195
 	adminUserInfo := c.GetAdminUserInfo()
3196
 	adminUserInfo := c.GetAdminUserInfo()
3196
 	orgId := adminUserInfo.CurrentOrgId
3197
 	orgId := adminUserInfo.CurrentOrgId
3197
 	if order_type == 1 {
3198
 	if order_type == 1 {
3198
-		list, err := service.GetDrugWarehouseInfoPrint(startTime, endTime, orgId, storehouse_id)
3199
+		list, err := service.GetDrugWarehouseInfoPrint(startTime, endTime, orgId, storehouse_id, drug_id)
3199
 		manufacturerList, _ := service.GetAllManufacturerList(orgId)
3200
 		manufacturerList, _ := service.GetAllManufacturerList(orgId)
3200
 		dealerList, _ := service.GetAllDealerList(orgId)
3201
 		dealerList, _ := service.GetAllDealerList(orgId)
3201
 		if err == nil {
3202
 		if err == nil {
3215
 	end_time := c.GetString("end_time")
3216
 	end_time := c.GetString("end_time")
3216
 	order_type, _ := c.GetInt64("order_type")
3217
 	order_type, _ := c.GetInt64("order_type")
3217
 	storehouse_id, _ := c.GetInt64("storehouse_id")
3218
 	storehouse_id, _ := c.GetInt64("storehouse_id")
3219
+	drug_id, _ := c.GetInt64("drug_id")
3220
+	order_way, _ := c.GetInt64("order_way")
3218
 	timeLayout := "2006-01-02"
3221
 	timeLayout := "2006-01-02"
3219
 	loc, _ := time.LoadLocation("Local")
3222
 	loc, _ := time.LoadLocation("Local")
3220
 
3223
 
3243
 	dealerList, _ := service.GetAllDealerList(orgId)
3246
 	dealerList, _ := service.GetAllDealerList(orgId)
3244
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3247
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3245
 	if order_type == 2 {
3248
 	if order_type == 2 {
3246
-		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id)
3249
+		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id, drug_id, order_way)
3247
 		if err == nil {
3250
 		if err == nil {
3248
 			c.ServeSuccessJSON(map[string]interface{}{
3251
 			c.ServeSuccessJSON(map[string]interface{}{
3249
 				"list":             list,
3252
 				"list":             list,
3388
 			DrugCode:                item.DrugCode,
3391
 			DrugCode:                item.DrugCode,
3389
 		}
3392
 		}
3390
 		service.CreateNewDrugFlowTwo(flow, tx)
3393
 		service.CreateNewDrugFlowTwo(flow, tx)
3394
+
3395
+		infoLog := models.XtDrugWarehouseInfoLog{
3396
+
3397
+			DrugId:          item.DrugId,
3398
+			WarehouseInfoId: item.ID,
3399
+			RecordDate:      time.Now().Unix(),
3400
+			UserOrgId:       item.OrgId,
3401
+			Status:          1,
3402
+			Ctime:           time.Now().Unix(),
3403
+			Mtime:           time.Now().Unix(),
3404
+		}
3405
+
3406
+		service.CreateInfoLog(infoLog, tx)
3407
+
3391
 		//更新基础库剩余库存
3408
 		//更新基础库剩余库存
3392
 		service.UpdateNewMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId, tx)
3409
 		service.UpdateNewMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId, tx)
3393
 
3410
 
3569
 
3586
 
3570
 func (c *StockDrugApiController) CheckDrugOut() {
3587
 func (c *StockDrugApiController) CheckDrugOut() {
3571
 
3588
 
3572
-	warehouse_out_id, _ := c.GetInt64("warehouse_out_id")
3589
+	warehouseOutId, _ := c.GetInt64("warehouse_out_id")
3573
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3590
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3574
 	// 开始外部循环的事务
3591
 	// 开始外部循环的事务
3575
 	db := service.XTWriteDB()
3592
 	db := service.XTWriteDB()
3582
 		}
3599
 		}
3583
 	}()
3600
 	}()
3584
 
3601
 
3585
-	warehousingOutInfoList, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3586
-	drugWarehouseOut, _ := service.GetNewDrugWarehouseOutByLastId(warehouse_out_id, tx)
3602
+	warehousingOutInfoList, _ := service.GetNewDrugWarehouseOutListById(warehouseOutId, orgId, tx)
3603
+	drugWarehouseOut, _ := service.GetNewDrugWarehouseOutByLastId(warehouseOutId, tx)
3587
 
3604
 
3588
 	for _, it := range warehousingOutInfoList {
3605
 	for _, it := range warehousingOutInfoList {
3589
 		var total_count int64
3606
 		var total_count int64
3628
 			return
3645
 			return
3629
 		}
3646
 		}
3630
 	}
3647
 	}
3631
-	warehousingOutInfoListTwo, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3648
+	warehousingOutInfoListTwo, _ := service.GetNewDrugWarehouseOutListById(warehouseOutId, orgId, tx)
3632
 
3649
 
3633
 	for _, it := range warehousingOutInfoListTwo {
3650
 	for _, it := range warehousingOutInfoListTwo {
3634
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3651
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3650
 		service.AddNewDrugCount(it.DrugId, it.OrgId, it.StorehouseId, out_count_one, tx)
3667
 		service.AddNewDrugCount(it.DrugId, it.OrgId, it.StorehouseId, out_count_one, tx)
3651
 
3668
 
3652
 	}
3669
 	}
3653
-	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3670
+	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouseOutId, orgId, tx)
3654
 
3671
 
3655
 	var is_success = 2
3672
 	var is_success = 2
3656
 	for _, it := range warehousingOutInfoListThree {
3673
 	for _, it := range warehousingOutInfoListThree {
3699
 			}
3716
 			}
3700
 
3717
 
3701
 			var flow_count int64
3718
 			var flow_count int64
3702
-
3719
+			var flow_count_one int64
3703
 			//查询该药品的出库数量
3720
 			//查询该药品的出库数量
3704
 			drugflowlist, _ := service.GetDrugOutFlowByWarehouseOut(it.DrugId, it.ID, it.OrgId, tx)
3721
 			drugflowlist, _ := service.GetDrugOutFlowByWarehouseOut(it.DrugId, it.ID, it.OrgId, tx)
3705
 			if len(drugflowlist) > 0 {
3722
 			if len(drugflowlist) > 0 {
3707
 
3724
 
3708
 					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3725
 					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3709
 						flow_count = items.Count * medical.MinNumber
3726
 						flow_count = items.Count * medical.MinNumber
3727
+						flow_count_one += flow_count
3710
 					}
3728
 					}
3711
 					if items.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3729
 					if items.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3712
 						flow_count = items.Count
3730
 						flow_count = items.Count
3731
+						flow_count_one += flow_count
3713
 					}
3732
 					}
3714
 					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3733
 					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3715
 						flow_count = items.Count
3734
 						flow_count = items.Count
3735
+						flow_count_one += flow_count
3716
 					}
3736
 					}
3717
 				}
3737
 				}
3718
 			}
3738
 			}
3719
 
3739
 
3720
-			if now_count != flow_count {
3740
+			if now_count != flow_count_one {
3721
 				is_success = 1
3741
 				is_success = 1
3722
 				tx.Rollback()
3742
 				tx.Rollback()
3723
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3743
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3731
 		IsCheck: 1,
3751
 		IsCheck: 1,
3732
 	}
3752
 	}
3733
 	//更新审核状态
3753
 	//更新审核状态
3734
-	service.UpdateNewCheckDrugOut(out, warehouse_out_id, tx)
3754
+	service.UpdateNewCheckDrugOut(out, warehouseOutId, tx)
3735
 
3755
 
3736
 	//查询
3756
 	//查询
3737
 	if is_success != 1 {
3757
 	if is_success != 1 {
3883
 
3903
 
3884
 		service.UpdateNewDrugStockCount(item.DrugId, item.OrgId, item.StorehouseId, over_count, tx)
3904
 		service.UpdateNewDrugStockCount(item.DrugId, item.OrgId, item.StorehouseId, over_count, tx)
3885
 
3905
 
3906
+		service.UpdateDrugWarehouseOutInfoLog(item.ID, item.DrugId, tx)
3907
+
3886
 	}
3908
 	}
3887
 	tx.Commit()
3909
 	tx.Commit()
3888
 	c.ServeSuccessJSON(map[string]interface{}{
3910
 	c.ServeSuccessJSON(map[string]interface{}{

+ 8 - 4
controllers/gobal_config_api_controller.go Parādīt failu

1734
 	start_time := c.GetString("start_time")
1734
 	start_time := c.GetString("start_time")
1735
 	end_time := c.GetString("end_time")
1735
 	end_time := c.GetString("end_time")
1736
 	storehouse_id, _ := c.GetInt64("storehouse_id")
1736
 	storehouse_id, _ := c.GetInt64("storehouse_id")
1737
+	drug_id, _ := c.GetInt64("drug_id")
1737
 	timeLayout := "2006-01-02"
1738
 	timeLayout := "2006-01-02"
1738
 	loc, _ := time.LoadLocation("Local")
1739
 	loc, _ := time.LoadLocation("Local")
1739
 	var startTime int64
1740
 	var startTime int64
1763
 	page, _ := c.GetInt64("page")
1764
 	page, _ := c.GetInt64("page")
1764
 	limit, _ := c.GetInt64("limit")
1765
 	limit, _ := c.GetInt64("limit")
1765
 
1766
 
1766
-	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1767
+	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id)
1767
 
1768
 
1768
 	var drugType = "药品类型"
1769
 	var drugType = "药品类型"
1769
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1770
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1858
 	keyword := c.GetString("keyword")
1859
 	keyword := c.GetString("keyword")
1859
 	limit, _ := c.GetInt64("limit")
1860
 	limit, _ := c.GetInt64("limit")
1860
 	page, _ := c.GetInt64("page")
1861
 	page, _ := c.GetInt64("page")
1861
-	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1862
+	drug_id, _ := c.GetInt64("drug_id")
1863
+	order_way, _ := c.GetInt64("order_way")
1864
+	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id, order_way)
1862
 
1865
 
1863
 	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1866
 	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1864
 	patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
1867
 	patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
1911
 	keyword := c.GetString("keyword")
1914
 	keyword := c.GetString("keyword")
1912
 	limit, _ := c.GetInt64("limit")
1915
 	limit, _ := c.GetInt64("limit")
1913
 	page, _ := c.GetInt64("page")
1916
 	page, _ := c.GetInt64("page")
1914
-	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, storehouse_id)
1915
-	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id)
1917
+	drug_id, _ := c.GetInt64("drug_id")
1918
+	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, storehouse_id, drug_id)
1919
+	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id)
1916
 	var drugType = "药品类型"
1920
 	var drugType = "药品类型"
1917
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1921
 	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1918
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1922
 	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 576 - 459
controllers/his_api_controller.go


+ 0 - 1
controllers/inspection_api_controller.go Parādīt failu

1142
 
1142
 
1143
 	inspection.ID = id
1143
 	inspection.ID = id
1144
 
1144
 
1145
-	fmt.Println("id------------------------------", id)
1146
 }
1145
 }
1147
 
1146
 
1148
 func (c *InspectionApiController) GetInpsectionByPatientGroup() {
1147
 func (c *InspectionApiController) GetInpsectionByPatientGroup() {

+ 6 - 2
controllers/mobile_api_controllers/check_weight_api_controller.go Parādīt failu

326
 
326
 
327
 	}
327
 	}
328
 
328
 
329
-	if adminUserInfo.Org.Id == 10727 {
329
+	if adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 {
330
 		dewater_amount = dewater_amount * 1000
330
 		dewater_amount = dewater_amount * 1000
331
 	}
331
 	}
332
 
332
 
930
 				evaluation.DialysisCount = lastPredialysisEvaluation.DialysisCount             //呼吸频次
930
 				evaluation.DialysisCount = lastPredialysisEvaluation.DialysisCount             //呼吸频次
931
 				evaluation.Phinholing = lastPredialysisEvaluation.Phinholing                   //针眼
931
 				evaluation.Phinholing = lastPredialysisEvaluation.Phinholing                   //针眼
932
 
932
 
933
+				if adminUserInfo.Org.Id == 10742 {
934
+					evaluation.BeforSymptoms = lastPredialysisEvaluation.BeforSymptoms
935
+				}
936
+
933
 				if adminUserInfo.Org.Id == 10702 {
937
 				if adminUserInfo.Org.Id == 10702 {
934
 					evaluation.PreDialysisDrugs = "无"
938
 					evaluation.PreDialysisDrugs = "无"
935
 				}
939
 				}
977
 		}
981
 		}
978
 
982
 
979
 		//针对患者称重两次没有数据的问题
983
 		//针对患者称重两次没有数据的问题
980
-		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10745 {
984
+		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
981
 
985
 
982
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
986
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
983
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
987
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)

+ 42 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

570
 	//var index int64 = 0
570
 	//var index int64 = 0
571
 	for _, item := range temp_team_projects {
571
 	for _, item := range temp_team_projects {
572
 		//组套里面非检验项目的
572
 		//组套里面非检验项目的
573
-		if item.HisProject.CostClassify != 3 {
573
+		if item.HisProject.CostClassify != 3 && item.HisProject.CostClassify != 104 {
574
 			projects = append(projects, item)
574
 			projects = append(projects, item)
575
 		}
575
 		}
576
 		//组套里面检验项目的
576
 		//组套里面检验项目的
577
-		if item.HisProject.CostClassify == 3 {
577
+		if item.HisProject.CostClassify == 3 || item.HisProject.CostClassify == 104 {
578
 			team_projects = append(team_projects, item)
578
 			team_projects = append(team_projects, item)
579
 		}
579
 		}
580
 	}
580
 	}
3051
 
3051
 
3052
 	}
3052
 	}
3053
 
3053
 
3054
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10693 || adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10735 {
3054
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10693 || adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10735 || adminUserInfo.Org.Id == 10742 {
3055
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
3055
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
3056
 
3056
 
3057
 		if adminUserInfo.Org.Id != 10702 {
3057
 		if adminUserInfo.Org.Id != 10702 {
3687
 
3687
 
3688
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3688
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3689
 
3689
 
3690
+	if adminUserInfo.Org.Id == 10679 || adminUserInfo.Org.Id == 10164 {
3691
+
3692
+		record, _ := service.GetDialysisPrescriptionByRecord(adminUserInfo.Org.Id, patientID, schedulestartTime)
3693
+		if record.ID == 0 {
3694
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescription)
3695
+			return
3696
+		}
3697
+	}
3698
+
3690
 	//查询该床位是否有人用了
3699
 	//查询该床位是否有人用了
3691
 	order, _ := service.GetDialysisOrderByBedIdTwo(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3700
 	order, _ := service.GetDialysisOrderByBedIdTwo(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3692
 
3701
 
3980
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3989
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3981
 			}
3990
 			}
3982
 
3991
 
3983
-			if adminUserInfo.Org.Id == 10644 {
3992
+			if adminUserInfo.Org.Id == 10644 || adminUserInfo.Org.Id == 10751 {
3984
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3993
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3985
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3994
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3986
 			}
3995
 			}
3987
 
3996
 
3997
+			if adminUserInfo.Org.Id == 10751 {
3998
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3999
+				ultrafiltration_rate = ultrafiltration_rate / 1000
4000
+			}
4001
+
3988
 			if adminUserInfo.Org.Id == 10667 {
4002
 			if adminUserInfo.Org.Id == 10667 {
3989
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
4003
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3990
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4004
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4103
 	}
4117
 	}
4104
 
4118
 
4105
 	//只针对广慈医院
4119
 	//只针对广慈医院
4106
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10517 || adminUserInfo.Org.Id == 10679 {
4120
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10517 || adminUserInfo.Org.Id == 10679 || adminUserInfo.Org.Id == 10742 {
4107
 		// 查询病人是否有透前评估数据
4121
 		// 查询病人是否有透前评估数据
4108
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
4122
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
4109
 
4123
 
5276
 
5290
 
5277
 			}
5291
 			}
5278
 
5292
 
5293
+			if adminInfo.Org.Id == 10751 {
5294
+
5295
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5296
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5297
+
5298
+			}
5299
+
5279
 			if adminInfo.Org.Id == 10551 || adminInfo.Org.Id == 10617 || adminInfo.Org.Id == 10580 || adminInfo.Org.Id == 10629 {
5300
 			if adminInfo.Org.Id == 10551 || adminInfo.Org.Id == 10617 || adminInfo.Org.Id == 10580 || adminInfo.Org.Id == 10629 {
5280
 
5301
 
5281
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 1000 / float64(totalMin) * 60 * 1000)
5302
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 1000 / float64(totalMin) * 60 * 1000)
5379
 		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5400
 		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5380
 	}
5401
 	}
5381
 
5402
 
5403
+	if adminInfo.Org.Id == 10751 {
5404
+
5405
+		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5406
+
5407
+		record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5408
+	}
5409
+
5382
 	if adminInfo.Org.Id == 10551 || adminInfo.Org.Id == 10617 || adminInfo.Org.Id == 10580 {
5410
 	if adminInfo.Org.Id == 10551 || adminInfo.Org.Id == 10617 || adminInfo.Org.Id == 10580 {
5383
 		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5411
 		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5384
 
5412
 
6733
 				var dewater_amount float64
6761
 				var dewater_amount float64
6734
 
6762
 
6735
 				dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
6763
 				dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
6764
+				if adminUserInfo.Org.Id != 10702 {
6765
+					service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
6766
+				}
6767
+				if adminUserInfo.Org.Id == 10702 {
6768
+					service.UpdatePatientDialysisPrscriptionOne(dialysisPrescription.ID, dewater_amount)
6769
+				}
6736
 
6770
 
6737
-				service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
6738
 				//获取key,清空redis
6771
 				//获取key,清空redis
6739
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
6772
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
6740
 				redis := service.RedisClient()
6773
 				redis := service.RedisClient()
12126
 		StopTime:              0,
12159
 		StopTime:              0,
12127
 		StopReason:            "",
12160
 		StopReason:            "",
12128
 		StopDoctor:            0,
12161
 		StopDoctor:            0,
12129
-		StopState:             0,
12162
+		StopState:             2,
12130
 		ParentId:              parent_id,
12163
 		ParentId:              parent_id,
12131
 		ExecutionTime:         0,
12164
 		ExecutionTime:         0,
12132
 		ExecutionStaff:        0,
12165
 		ExecutionStaff:        0,
12610
 
12643
 
12611
 		advice.AdviceDoctor = advice_doctor
12644
 		advice.AdviceDoctor = advice_doctor
12612
 
12645
 
12646
+		advice.StopState = 2
12647
+
12613
 		advices = append(advices, &advice)
12648
 		advices = append(advices, &advice)
12614
 	}
12649
 	}
12615
 
12650
 

+ 322 - 56
controllers/mobile_api_controllers/patient_api_controller.go Parādīt failu

676
 		if groupno > 0 {
676
 		if groupno > 0 {
677
 			advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
677
 			advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
678
 
678
 
679
-			fmt.Println("advices---------------------------------------------", advices)
680
 			for _, item := range advices {
679
 			for _, item := range advices {
681
 
680
 
682
 				//自备药
681
 				//自备药
683
 				selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
682
 				selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
684
 
683
 
685
 				if selfPrescriptionOutOpenOne.IsOpen == 1 {
684
 				if selfPrescriptionOutOpenOne.IsOpen == 1 {
685
+
686
 					//查询库存是否
686
 					//查询库存是否
687
 					selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
687
 					selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
688
 
688
 
709
 							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
709
 							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
710
 							prescribing_number_total_one = count
710
 							prescribing_number_total_one = count
711
 						}
711
 						}
712
-						if prescribing_number_total_one > selfDrugStockCount.FlushCount {
713
-							c.ServeSuccessJSON(map[string]interface{}{
714
-								"msg":    "2",
715
-								"advice": advice,
716
-								"ids":    ids,
717
-							})
718
-							return
712
+						if advice.UserOrgId != 10164 && advice.UserOrgId != 10744 {
713
+
714
+							if prescribing_number_total_one > selfDrugStockCount.FlushCount {
715
+								c.ServeSuccessJSON(map[string]interface{}{
716
+									"msg":    "2",
717
+									"advice": advice,
718
+									"ids":    ids,
719
+								})
720
+								return
719
 
721
 
722
+							}
720
 						}
723
 						}
724
+
721
 					}
725
 					}
722
 
726
 
723
 				}
727
 				}
770
 						}
774
 						}
771
 					}()
775
 					}()
772
 
776
 
777
+					if strings.Contains(item.AdviceName, "自备") {
778
+						fmt.Println("hahhahahahahhh")
779
+						if item.DrugId == 0 {
780
+							c.ServeSuccessJSON(map[string]interface{}{
781
+								"msg":    "12",
782
+								"advice": item,
783
+								"ids":    ids,
784
+							})
785
+							return
786
+						}
787
+					}
788
+
773
 					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
789
 					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
774
 
790
 
775
 					if selfBasedrug.IsSelfDrug == 1 {
791
 					if selfBasedrug.IsSelfDrug == 1 {
787
 							total_count += items.StockMaxNumber + items.StockMinNumber
803
 							total_count += items.StockMaxNumber + items.StockMinNumber
788
 						}
804
 						}
789
 
805
 
790
-						if total_count == 0 {
791
-							c.ServeSuccessJSON(map[string]interface{}{
792
-								"msg":    "2",
793
-								"advice": item,
794
-								"ids":    ids,
795
-							})
796
-							return
806
+						if item.UserOrgId != 10740 && item.UserOrgId != 10164 {
807
+							if total_count == 0 {
808
+								c.ServeSuccessJSON(map[string]interface{}{
809
+									"msg":    "2",
810
+									"advice": item,
811
+									"ids":    ids,
812
+								})
813
+								return
814
+							}
797
 						}
815
 						}
798
 
816
 
799
 						//判断单位是否相等
817
 						//判断单位是否相等
818
 
836
 
819
 						}
837
 						}
820
 
838
 
821
-						if prescribing_number_total > total_count {
822
-							c.ServeSuccessJSON(map[string]interface{}{
823
-								"msg":    "3",
824
-								"advice": item,
825
-							})
826
-							return
839
+						if item.UserOrgId != 10740 && item.UserOrgId != 10164 {
840
+
841
+							if prescribing_number_total > total_count {
842
+								c.ServeSuccessJSON(map[string]interface{}{
843
+									"msg":    "3",
844
+									"advice": item,
845
+								})
846
+								return
847
+							}
827
 						}
848
 						}
849
+
828
 						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
850
 						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
829
-						//出库
830
-						if prescribing_number_total <= total_count {
851
+
852
+						if item.UserOrgId != 10164 {
853
+							//出库
854
+							if prescribing_number_total <= total_count {
855
+								timeStr := time.Now().Format("2006-01-02")
856
+								timeArr := strings.Split(timeStr, "-")
857
+								total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
858
+
859
+								total = total + 1
860
+								warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
861
+								number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
862
+								number = number + total
863
+								warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
864
+								operation_time := time.Now().Unix()
865
+
866
+								creater := c.GetMobileAdminUserInfo().AdminUser.Id
867
+								//创建一个出库单
868
+								drugWarehouseOut := models.XtSelfDrugWarehouseOut{
869
+									WarehouseOutOrderNumber: warehousing_out_order,
870
+									OperationTime:           operation_time,
871
+									OrgId:                   adminUserInfo.Org.Id,
872
+									Creater:                 creater,
873
+									Ctime:                   time.Now().Unix(),
874
+									Status:                  1,
875
+									WarehouseOutTime:        item.AdviceDate,
876
+									Type:                    0,
877
+									PatientId:               advice.PatientId,
878
+									IsCheck:                 1,
879
+									IsSys:                   1,
880
+								}
881
+
882
+								//查询今日是否有出库数据
883
+								lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
884
+
885
+								if lastWarehouseOut.ID == 0 {
886
+									service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
887
+								}
888
+
889
+								//查询今日是否有出库数据
890
+								lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
891
+
892
+								var warehousing_out_order_str string
893
+								if lastWarehouseOut.ID == 0 {
894
+									warehousing_out_order_str = warehousing_out_order
895
+								} else {
896
+									warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
897
+								}
898
+
899
+								//出库
900
+								warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
901
+									WarehouseOutId:          lastWarehouseOutOne.ID,
902
+									WarehouseOutOrderNumber: warehousing_out_order_str,
903
+									DrugId:                  item.DrugId,
904
+									Count:                   prescribing_number_total,
905
+									Price:                   0,
906
+									TotalPrice:              0,
907
+									Status:                  1,
908
+									Ctime:                   item.AdviceDate,
909
+									Mtime:                   item.AdviceDate,
910
+									Remark:                  "",
911
+									OrgId:                   item.UserOrgId,
912
+									Type:                    0,
913
+									Manufacturer:            selfBasedrug.Manufacturer,
914
+									Dealer:                  selfBasedrug.Dealer,
915
+									RetailPrice:             0,
916
+									RetailTotalPrice:        0,
917
+									CountUnit:               selfBasedrug.MinUnit,
918
+									ExpiryDate:              0,
919
+									ProductDate:             0,
920
+									Number:                  "",
921
+									BatchNumber:             "",
922
+									IsSys:                   0,
923
+									WarehouseInfoId:         0,
924
+									AdminUserId:             0,
925
+									StockCount:              "",
926
+									IsCheck:                 1,
927
+									SysRecordTime:           item.AdviceDate,
928
+									PatientId:               item.PatientId,
929
+									AdviceId:                item.ID,
930
+									ClassType:               "",
931
+								}
932
+								warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
933
+
934
+								for _, it := range warehousingOutInfo {
935
+
936
+									medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
937
+									drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
938
+
939
+									//出库逻辑
940
+									service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
941
+
942
+									//查询剩余库存
943
+									stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
944
+									var sum_count int64
945
+									for _, its := range stockInfo {
946
+										if its.MaxUnit == medical.MaxUnit {
947
+											its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
948
+										}
949
+										sum_count += its.StockMaxNumber + its.StockMinNumber
950
+									}
951
+									service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
952
+								}
953
+							}
954
+						}
955
+
956
+						//重庆
957
+						if item.UserOrgId == 10164 {
958
+							//出库
831
 							timeStr := time.Now().Format("2006-01-02")
959
 							timeStr := time.Now().Format("2006-01-02")
832
 							timeArr := strings.Split(timeStr, "-")
960
 							timeArr := strings.Split(timeStr, "-")
833
 							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
961
 							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
911
 
1039
 
912
 								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1040
 								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
913
 								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1041
 								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1042
+
914
 								//出库逻辑
1043
 								//出库逻辑
915
-								service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1044
+								service.AutoNewSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
916
 
1045
 
917
 								//查询剩余库存
1046
 								//查询剩余库存
918
 								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1047
 								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
925
 								}
1054
 								}
926
 								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1055
 								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
927
 							}
1056
 							}
1057
+
928
 						}
1058
 						}
929
 
1059
 
930
 					}
1060
 					}
967
 							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1097
 							count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
968
 							prescribing_number_total_one = count
1098
 							prescribing_number_total_one = count
969
 						}
1099
 						}
970
-						if prescribing_number_total_one > selfDrugStockCount.FlushCount {
971
-							c.ServeSuccessJSON(map[string]interface{}{
972
-								"msg":    "2",
973
-								"advice": advice,
974
-								"ids":    ids,
975
-							})
976
-							return
1100
+
1101
+						if advice.UserOrgId != 10164 && advice.UserOrgId != 10740 {
1102
+
1103
+							if prescribing_number_total_one > selfDrugStockCount.FlushCount {
1104
+								c.ServeSuccessJSON(map[string]interface{}{
1105
+									"msg":    "2",
1106
+									"advice": advice,
1107
+									"ids":    ids,
1108
+								})
1109
+								return
1110
+							}
977
 						}
1111
 						}
1112
+
978
 					}
1113
 					}
979
 
1114
 
980
 				}
1115
 				}
1027
 							total_count += items.StockMaxNumber + items.StockMinNumber
1162
 							total_count += items.StockMaxNumber + items.StockMinNumber
1028
 						}
1163
 						}
1029
 
1164
 
1030
-						if total_count == 0 {
1031
-							c.ServeSuccessJSON(map[string]interface{}{
1032
-								"msg":    "2",
1033
-								"advice": item,
1034
-								"ids":    ids,
1035
-							})
1036
-							return
1165
+						if item.UserOrgId != 10740 && item.UserOrgId != 10164 {
1166
+
1167
+							if total_count == 0 {
1168
+								c.ServeSuccessJSON(map[string]interface{}{
1169
+									"msg":    "2",
1170
+									"advice": item,
1171
+									"ids":    ids,
1172
+								})
1173
+								return
1174
+							}
1037
 						}
1175
 						}
1038
 
1176
 
1039
 						//判断单位是否相等
1177
 						//判断单位是否相等
1058
 
1196
 
1059
 						}
1197
 						}
1060
 
1198
 
1061
-						if prescribing_number_total > total_count {
1062
-							c.ServeSuccessJSON(map[string]interface{}{
1063
-								"msg":    "3",
1064
-								"advice": item,
1065
-							})
1066
-							return
1199
+						if item.UserOrgId != 10164 && item.UserOrgId != 10740 {
1200
+							if prescribing_number_total > total_count {
1201
+								c.ServeSuccessJSON(map[string]interface{}{
1202
+									"msg":    "3",
1203
+									"advice": item,
1204
+								})
1205
+								return
1206
+							}
1067
 						}
1207
 						}
1208
+
1068
 						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
1209
 						var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
1069
-						//出库
1070
-						if prescribing_number_total <= total_count {
1210
+
1211
+						if item.UserOrgId != 10164 && item.UserOrgId != 10740 {
1212
+
1213
+							//出库
1214
+							if prescribing_number_total <= total_count {
1215
+								timeStr := time.Now().Format("2006-01-02")
1216
+								timeArr := strings.Split(timeStr, "-")
1217
+								total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
1218
+
1219
+								total = total + 1
1220
+								warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1221
+								number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1222
+								number = number + total
1223
+								warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1224
+								operation_time := time.Now().Unix()
1225
+
1226
+								creater := c.GetMobileAdminUserInfo().AdminUser.Id
1227
+
1228
+								//创建一个出库单
1229
+								drugWarehouseOut := models.XtSelfDrugWarehouseOut{
1230
+									WarehouseOutOrderNumber: warehousing_out_order,
1231
+									OperationTime:           operation_time,
1232
+									OrgId:                   adminUserInfo.Org.Id,
1233
+									Creater:                 creater,
1234
+									Ctime:                   time.Now().Unix(),
1235
+									Status:                  1,
1236
+									WarehouseOutTime:        item.AdviceDate,
1237
+									Type:                    0,
1238
+									PatientId:               advice.PatientId,
1239
+									IsCheck:                 1,
1240
+									IsSys:                   1,
1241
+								}
1242
+
1243
+								//查询今日是否有出库数据
1244
+								lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
1245
+
1246
+								if lastWarehouseOut.ID == 0 {
1247
+									service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
1248
+								}
1249
+
1250
+								//查询今日是否有出库数据
1251
+								lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
1252
+
1253
+								var warehousing_out_order_str string
1254
+								if lastWarehouseOut.ID == 0 {
1255
+									warehousing_out_order_str = warehousing_out_order
1256
+								} else {
1257
+									warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
1258
+								}
1259
+
1260
+								//出库
1261
+								warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
1262
+									WarehouseOutId:          lastWarehouseOutOne.ID,
1263
+									WarehouseOutOrderNumber: warehousing_out_order_str,
1264
+									DrugId:                  item.DrugId,
1265
+									Count:                   prescribing_number_total,
1266
+									Price:                   0,
1267
+									TotalPrice:              0,
1268
+									Status:                  1,
1269
+									Ctime:                   item.AdviceDate,
1270
+									Mtime:                   item.AdviceDate,
1271
+									Remark:                  "",
1272
+									OrgId:                   item.UserOrgId,
1273
+									Type:                    0,
1274
+									Manufacturer:            selfBasedrug.Manufacturer,
1275
+									Dealer:                  selfBasedrug.Dealer,
1276
+									RetailPrice:             0,
1277
+									RetailTotalPrice:        0,
1278
+									CountUnit:               selfBasedrug.MinUnit,
1279
+									ExpiryDate:              0,
1280
+									ProductDate:             0,
1281
+									Number:                  "",
1282
+									BatchNumber:             "",
1283
+									IsSys:                   0,
1284
+									WarehouseInfoId:         0,
1285
+									AdminUserId:             0,
1286
+									StockCount:              "",
1287
+									IsCheck:                 1,
1288
+									SysRecordTime:           item.AdviceDate,
1289
+									PatientId:               item.PatientId,
1290
+									AdviceId:                item.ID,
1291
+									ClassType:               "",
1292
+								}
1293
+								warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1294
+
1295
+								for _, it := range warehousingOutInfo {
1296
+
1297
+									medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1298
+									drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1299
+									//出库逻辑
1300
+									service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1301
+
1302
+									//查询剩余库存
1303
+									stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1304
+									var sum_count int64
1305
+									for _, its := range stockInfo {
1306
+										if its.MaxUnit == medical.MaxUnit {
1307
+											its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1308
+										}
1309
+										sum_count += its.StockMaxNumber + its.StockMinNumber
1310
+									}
1311
+									service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1312
+								}
1313
+							}
1314
+						}
1315
+
1316
+						//重庆
1317
+						if item.UserOrgId == 10164 || item.UserOrgId == 10740 {
1318
+
1071
 							timeStr := time.Now().Format("2006-01-02")
1319
 							timeStr := time.Now().Format("2006-01-02")
1072
 							timeArr := strings.Split(timeStr, "-")
1320
 							timeArr := strings.Split(timeStr, "-")
1073
 							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
1321
 							total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
1153
 								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1401
 								medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1154
 								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1402
 								drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1155
 								//出库逻辑
1403
 								//出库逻辑
1156
-								service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1404
+								service.AutoNewSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1157
 
1405
 
1158
 								//查询剩余库存
1406
 								//查询剩余库存
1159
 								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1407
 								stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1167
 								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1415
 								service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1168
 							}
1416
 							}
1169
 						}
1417
 						}
1170
-
1171
 					}
1418
 					}
1172
 
1419
 
1173
 				}
1420
 				}
1187
 
1434
 
1188
 		//针对普宁
1435
 		//针对普宁
1189
 		if adminUserInfo.Org.Id != 10599 {
1436
 		if adminUserInfo.Org.Id != 10599 {
1190
-			fmt.Println("开始时间--------------------", advice.StartTime)
1191
-			fmt.Println("theTime---------------------", theTime.Unix())
1437
+
1192
 			if advice.StartTime > theTime.Unix() {
1438
 			if advice.StartTime > theTime.Unix() {
1193
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1439
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
1194
 				return
1440
 				return
2814
 			Mtime:         time.Now().Unix(),
3060
 			Mtime:         time.Now().Unix(),
2815
 		}
3061
 		}
2816
 		service.ModifyHisPrescriptionProject(&project, ids)
3062
 		service.ModifyHisPrescriptionProject(&project, ids)
3063
+
3064
+		if adminUserInfo.Org.Id == 10644 {
3065
+			projectList, _ := service.GetHisPrescriptionProjectByIds(ids)
3066
+			if len(projectList) > 0 {
3067
+				for _, item := range projectList {
3068
+					if item.TeamId > 0 {
3069
+						service.ModfifyProjectListByIds(item.TeamId, theTime.Unix(), item.RecordDate, item.PatientId)
3070
+					}
3071
+
3072
+				}
3073
+			}
3074
+		}
3075
+
2817
 		//记录日志
3076
 		//记录日志
2818
 		projectquerst, _ := json.Marshal(project)
3077
 		projectquerst, _ := json.Marshal(project)
2819
 		projectLog := models.XtDoctorAdviceLog{
3078
 		projectLog := models.XtDoctorAdviceLog{
3494
 	if evaluation.DryWeight > 0 {
3753
 	if evaluation.DryWeight > 0 {
3495
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3754
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3496
 
3755
 
3497
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 {
3756
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 {
3498
 
3757
 
3499
 			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
3758
 			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
3500
 				dewater_amount = dewater_amount * 1000
3759
 				dewater_amount = dewater_amount * 1000
4219
 	}
4478
 	}
4220
 
4479
 
4221
 	//针对孝昌康桥超滤率计算问题
4480
 	//针对孝昌康桥超滤率计算问题
4222
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 {
4481
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 {
4223
 		if evaluation.ID == 0 {
4482
 		if evaluation.ID == 0 {
4224
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4483
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4225
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4484
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4226
 				dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4485
 				dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4486
+				if adminUserInfo.Org.Id == 10751 {
4487
+					dewater_amount = dewater_amount * 1000
4488
+				}
4227
 				service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
4489
 				service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
4228
 			}
4490
 			}
4229
 		}
4491
 		}
4232
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4494
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4233
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4495
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4234
 				dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4496
 				dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4497
+				if adminUserInfo.Org.Id == 10751 {
4498
+					dewater_amount = dewater_amount * 1000
4499
+				}
4235
 				service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
4500
 				service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
4236
 			}
4501
 			}
4237
 		}
4502
 		}
4238
 
4503
 
4239
 	}
4504
 	}
4240
 
4505
 
4241
-	//古镇乐生
4242
-	if adminUserInfo.Org.Id == 10731 {
4506
+	// 小尹
4507
+	if adminUserInfo.Org.Id == 10164 {
4243
 		if evaluation.ID == 0 {
4508
 		if evaluation.ID == 0 {
4244
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4509
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4245
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4510
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4302
 	}
4567
 	}
4303
 
4568
 
4304
 	//揭阳
4569
 	//揭阳
4305
-	if adminUserInfo.Org.Id == 10597 {
4570
+	if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10742 {
4306
 		if evaluation.ID == 0 {
4571
 		if evaluation.ID == 0 {
4307
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4572
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4308
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4573
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4312
 		}
4577
 		}
4313
 	}
4578
 	}
4314
 
4579
 
4315
-	if adminUserInfo.Org.Id == 10597 {
4580
+	if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10742 {
4316
 
4581
 
4317
 		if evaluation.ID > 0 {
4582
 		if evaluation.ID > 0 {
4318
 
4583
 
6985
 				ids = append(ids, items.ID)
7250
 				ids = append(ids, items.ID)
6986
 			}
7251
 			}
6987
 			err := service.UpdateTeamProjectExceStatus(ids, adminInfo.AdminUser.Id, theTime.Unix())
7252
 			err := service.UpdateTeamProjectExceStatus(ids, adminInfo.AdminUser.Id, theTime.Unix())
7253
+
6988
 			if err == nil {
7254
 			if err == nil {
6989
 				c.ServeSuccessJSON(map[string]interface{}{
7255
 				c.ServeSuccessJSON(map[string]interface{}{
6990
 					"project": project,
7256
 					"project": project,

+ 0 - 1
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go Parādīt failu

71
 	} else {
71
 	} else {
72
 		dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
72
 		dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
73
 
73
 
74
-		fmt.Println("dialysisSchedule------------------------", dialysisSchedule)
75
 		//查询今日排班的病人
74
 		//查询今日排班的病人
76
 		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
75
 		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
77
 
76
 

+ 6 - 4
controllers/new_mobile_api_controllers/mobile_his_api_controller.go Parādīt failu

1
 package new_mobile_api_controllers
1
 package new_mobile_api_controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
-	"XT_New/utils"
8
 	"encoding/json"
4
 	"encoding/json"
9
 	"fmt"
5
 	"fmt"
10
 	"math/rand"
6
 	"math/rand"
12
 	"strconv"
8
 	"strconv"
13
 	"strings"
9
 	"strings"
14
 	"time"
10
 	"time"
11
+
12
+	"XT_New/enums"
13
+	"XT_New/models"
14
+	"XT_New/service"
15
+	"XT_New/utils"
15
 )
16
 )
16
 
17
 
17
 type MobileHisApiController struct {
18
 type MobileHisApiController struct {
328
 	}
329
 	}
329
 }
330
 }
330
 func (c *MobileHisApiController) DeleteDoctorAdvice() {
331
 func (c *MobileHisApiController) DeleteDoctorAdvice() {
332
+
331
 	id, _ := c.GetInt64("id")
333
 	id, _ := c.GetInt64("id")
332
 	advice, _ := service.GetHisDoctorAdvicesById(id)
334
 	advice, _ := service.GetHisDoctorAdvicesById(id)
333
 	err := service.DelelteDoctorAdvice(id, c.GetMobileAdminUserInfo().Org.Id)
335
 	err := service.DelelteDoctorAdvice(id, c.GetMobileAdminUserInfo().Org.Id)

+ 2 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Parādīt failu

1398
 
1398
 
1399
 	deathtime := dataBody["death_time"].(string)
1399
 	deathtime := dataBody["death_time"].(string)
1400
 
1400
 
1401
+	fmt.Println("deathTime=-------------------", deathtime)
1402
+
1401
 	deathtimes, err := time.ParseInLocation(timeLayouts+" 15:04:05", deathtime+" 00:00:00", loc)
1403
 	deathtimes, err := time.ParseInLocation(timeLayouts+" 15:04:05", deathtime+" 00:00:00", loc)
1402
 	//times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
1404
 	//times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
1403
 	death_time := deathtimes.Unix()
1405
 	death_time := deathtimes.Unix()

+ 22 - 9
controllers/print_data_api_controller.go Parādīt failu

162
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
162
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
163
 			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
163
 			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
164
 				if this.GetAdminUserInfo().CurrentOrgId == 10445 {
164
 				if this.GetAdminUserInfo().CurrentOrgId == 10445 {
165
-					if item.ScheduleDate <= 1703952000 {
165
+
166
+					if item.ScheduleDate >= 1640966400 && item.ScheduleDate <= 1672416000 {
167
+						listOne, _ := service.GetDialysisOrderCountNewTen(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
168
+						item.Patient.TotalDialysis = listOne.Count
169
+						item.Count = listOne.Count
170
+					}
171
+
172
+					if item.ScheduleDate >= 1672502400 && item.ScheduleDate <= 1703952000 {
173
+						listOne, _ := service.GetDialysisOrderCountTwenty(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
174
+						item.Patient.TotalDialysis = listOne.Count
175
+						item.Count = listOne.Count
176
+					}
177
+
178
+					if item.ScheduleDate >= 1704038400 && item.ScheduleDate <= 1735574400 {
179
+
166
 						listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
180
 						listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
167
 
181
 
168
 						item.Patient.TotalDialysis = listOne.Count
182
 						item.Patient.TotalDialysis = listOne.Count
169
 						item.Count = listOne.Count
183
 						item.Count = listOne.Count
170
 					}
184
 					}
171
 
185
 
172
-					if item.ScheduleDate >= 1704038400 {
173
-						fmt.Println("寄哪里地方阿道夫阿道夫")
174
-						//listOrder, _ := service.GetDialysisOrderCountNight(item.PatientID, item.ScheduleDate)
175
-						//fmt.Println("")
176
-						//item.Count = listOrder.DialysisTotal
186
+					if item.ScheduleDate >= 1735660800 {
177
 
187
 
178
 						listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
188
 						listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
179
 
189
 
339
 	start_time := this.GetString("start_time")
349
 	start_time := this.GetString("start_time")
340
 	end_time := this.GetString("end_time")
350
 	end_time := this.GetString("end_time")
341
 	storehouse_id, _ := this.GetInt64("storehouse_id")
351
 	storehouse_id, _ := this.GetInt64("storehouse_id")
352
+	good_id, _ := this.GetInt64("good_id")
342
 	adminUserInfo := this.GetAdminUserInfo()
353
 	adminUserInfo := this.GetAdminUserInfo()
343
 
354
 
355
+	order_way, _ := this.GetInt64("order_way")
356
+
344
 	timeLayout := "2006-01-02"
357
 	timeLayout := "2006-01-02"
345
 	loc, _ := time.LoadLocation("Local")
358
 	loc, _ := time.LoadLocation("Local")
346
 	var startTime int64
359
 	var startTime int64
367
 
380
 
368
 	//入库详情
381
 	//入库详情
369
 	if types == 1 {
382
 	if types == 1 {
370
-		list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page, storehouse_id)
383
+		list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page, storehouse_id, good_id)
371
 		if err != nil {
384
 		if err != nil {
372
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
385
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
373
 			return
386
 			return
380
 	//出库详情
393
 	//出库详情
381
 	if types == 2 {
394
 	if types == 2 {
382
 		//list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
395
 		//list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
383
-		list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
396
+		list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, good_id, order_way)
384
 
397
 
385
-		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
398
+		stockTotal, err := service.GetOutStockTotalCountThree(startTime, endTime, adminUserInfo.CurrentOrgId, good_id)
386
 		if err != nil {
399
 		if err != nil {
387
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
400
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
388
 			return
401
 			return

+ 8 - 1
controllers/schedule_api_controller.go Parādīt failu

4859
 	}
4859
 	}
4860
 
4860
 
4861
 	//查询排班里面的空透析器
4861
 	//查询排班里面的空透析器
4862
-	if adminInfo.CurrentOrgId == 10375 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 9538 {
4862
+	if adminInfo.CurrentOrgId == 10375 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 9538 || adminInfo.CurrentOrgId == 10742 || adminInfo.CurrentOrgId == 10387 || adminInfo.CurrentOrgId == 10740 {
4863
 
4863
 
4864
 		schedulesFive, _ := service.GetWeekScheduleFive(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4864
 		schedulesFive, _ := service.GetWeekScheduleFive(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4865
 
4865
 
4877
 				if len(solution.DialysisIrrigation) > 0 {
4877
 				if len(solution.DialysisIrrigation) > 0 {
4878
 					DialysisMachineName = DialysisMachineName + "," + solution.DialysisIrrigation
4878
 					DialysisMachineName = DialysisMachineName + "," + solution.DialysisIrrigation
4879
 				}
4879
 				}
4880
+				if len(solution.DialysisStrainer) > 0 {
4881
+					DialysisMachineName = DialysisMachineName + "," + solution.DialysisStrainer
4882
+				}
4880
 				item.DialysisMachineName = DialysisMachineName
4883
 				item.DialysisMachineName = DialysisMachineName
4881
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4884
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4885
+
4882
 			}
4886
 			}
4883
 			if item.ScheduleDate < timeNewDate.Unix() {
4887
 			if item.ScheduleDate < timeNewDate.Unix() {
4884
 				prescriptionList, _ := service.GetDialysisPrescriptionList(item.PatientId, item.UserOrgId, item.ScheduleDate)
4888
 				prescriptionList, _ := service.GetDialysisPrescriptionList(item.PatientId, item.UserOrgId, item.ScheduleDate)
4893
 				if len(prescriptionList.DialysisIrrigation) > 0 {
4897
 				if len(prescriptionList.DialysisIrrigation) > 0 {
4894
 					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisIrrigation
4898
 					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisIrrigation
4895
 				}
4899
 				}
4900
+				if len(prescriptionList.DialysisStrainer) > 0 {
4901
+					DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisStrainer
4902
+				}
4896
 				item.DialysisMachineName = DialysisMachineName
4903
 				item.DialysisMachineName = DialysisMachineName
4897
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4904
 				service.UpdateSchOne(item.ID, item.DialysisMachineName)
4898
 			}
4905
 			}

+ 2 - 0
controllers/self_drug_api_congtroller.go Parādīt failu

4079
 
4079
 
4080
 	limit, _ := this.GetInt64("limit")
4080
 	limit, _ := this.GetInt64("limit")
4081
 
4081
 
4082
+	fmt.Println("lismt", limit)
4083
+
4082
 	start_time := this.GetString("start_time")
4084
 	start_time := this.GetString("start_time")
4083
 	end_time := this.GetString("end_time")
4085
 	end_time := this.GetString("end_time")
4084
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4086
 	orgId := this.GetAdminUserInfo().CurrentOrgId

+ 143 - 0
controllers/sign_api_controller.go Parādīt failu

1296
 	//	}
1296
 	//	}
1297
 	//}
1297
 	//}
1298
 
1298
 
1299
+	//advice, _ := service.GetDoctorAdviceListByUserOrgId(10740, 1736179200)
1300
+	//
1301
+	//db := service.XTWriteDB()
1302
+	//tx := db.Begin()
1303
+	//defer func() {
1304
+	//	if r := recover(); r != nil {
1305
+	//		tx.Rollback()
1306
+	//	} else {
1307
+	//		tx.Commit()
1308
+	//	}
1309
+	//}()
1310
+	//for _, item := range advice {
1311
+	//
1312
+	//	//查找该患者是否出库了
1313
+	//	outInfo, _ := service.GetSelfDrugWarehouseOutInfo(item.PatientId, item.DrugId, item.AdviceDate)
1314
+	//	if outInfo.ID == 0 {
1315
+	//		timeStr := time.Now().Format("2006-01-02")
1316
+	//		timeArr := strings.Split(timeStr, "-")
1317
+	//		total, _ := service.FindAllSelfDrugWarehouseOut(10740, tx)
1318
+	//
1319
+	//		total = total + 1
1320
+	//		warehousing_out_order := strconv.FormatInt(10740, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1321
+	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1322
+	//		number = number + total
1323
+	//		warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1324
+	//		operation_time := time.Now().Unix()
1325
+	//
1326
+	//		creater := this.GetAdminUserInfo().AdminUser.Id
1327
+	//
1328
+	//		//创建一个出库单
1329
+	//		drugWarehouseOut := models.XtSelfDrugWarehouseOut{
1330
+	//			WarehouseOutOrderNumber: warehousing_out_order,
1331
+	//			OperationTime:           operation_time,
1332
+	//			OrgId:                   10740,
1333
+	//			Creater:                 creater,
1334
+	//			Ctime:                   time.Now().Unix(),
1335
+	//			Status:                  1,
1336
+	//			WarehouseOutTime:        item.AdviceDate,
1337
+	//			Type:                    0,
1338
+	//			PatientId:               item.PatientId,
1339
+	//			IsCheck:                 1,
1340
+	//			IsSys:                   1,
1341
+	//		}
1342
+	//
1343
+	//		//查询今日是否有出库数据
1344
+	//		lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(10740, item.AdviceDate, tx, 1)
1345
+	//
1346
+	//		if lastWarehouseOut.ID == 0 {
1347
+	//			service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
1348
+	//		}
1349
+	//
1350
+	//		//查询今日是否有出库数据
1351
+	//		lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(10740, item.AdviceDate, tx, 1)
1352
+	//
1353
+	//		var warehousing_out_order_str string
1354
+	//		if lastWarehouseOut.ID == 0 {
1355
+	//			warehousing_out_order_str = warehousing_out_order
1356
+	//		} else {
1357
+	//			warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
1358
+	//		}
1359
+	//
1360
+	//		//查询库存是否
1361
+	//		selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(item.DrugId, item.UserOrgId)
1362
+	//		var prescribing_number_total_one int64
1363
+	//		//判断单位是否相等
1364
+	//		if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1365
+	//			prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1366
+	//			count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1367
+	//			//转化为最小单位
1368
+	//			prescribing_number_total_one = count * selfBasedrug.MinNumber
1369
+	//		}
1370
+	//
1371
+	//		if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
1372
+	//			prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1373
+	//			count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1374
+	//			prescribing_number_total_one = count
1375
+	//
1376
+	//		}
1377
+	//
1378
+	//		if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
1379
+	//			prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1380
+	//			count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1381
+	//			prescribing_number_total_one = count
1382
+	//		}
1383
+	//
1384
+	//		//出库
1385
+	//		warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
1386
+	//			WarehouseOutId:          lastWarehouseOutOne.ID,
1387
+	//			WarehouseOutOrderNumber: warehousing_out_order_str,
1388
+	//			DrugId:                  item.DrugId,
1389
+	//			Count:                   prescribing_number_total_one,
1390
+	//			Price:                   0,
1391
+	//			TotalPrice:              0,
1392
+	//			Status:                  1,
1393
+	//			Ctime:                   item.AdviceDate,
1394
+	//			Mtime:                   item.AdviceDate,
1395
+	//			Remark:                  "",
1396
+	//			OrgId:                   item.UserOrgId,
1397
+	//			Type:                    0,
1398
+	//			Manufacturer:            selfBasedrug.Manufacturer,
1399
+	//			Dealer:                  selfBasedrug.Dealer,
1400
+	//			RetailPrice:             0,
1401
+	//			RetailTotalPrice:        0,
1402
+	//			CountUnit:               selfBasedrug.MinUnit,
1403
+	//			ExpiryDate:              0,
1404
+	//			ProductDate:             0,
1405
+	//			Number:                  "",
1406
+	//			BatchNumber:             "",
1407
+	//			IsSys:                   0,
1408
+	//			WarehouseInfoId:         0,
1409
+	//			AdminUserId:             0,
1410
+	//			StockCount:              "",
1411
+	//			IsCheck:                 1,
1412
+	//			SysRecordTime:           item.AdviceDate,
1413
+	//			PatientId:               item.PatientId,
1414
+	//			AdviceId:                item.ID,
1415
+	//			ClassType:               "",
1416
+	//		}
1417
+	//		var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
1418
+	//		warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1419
+	//
1420
+	//		for _, it := range warehousingOutInfo {
1421
+	//
1422
+	//			medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
1423
+	//			drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
1424
+	//			//出库逻辑
1425
+	//			service.AutoNewSelfDrugDeliverInfoFourtyTwo(item.UserOrgId, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
1426
+	//
1427
+	//			//查询剩余库存
1428
+	//			stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
1429
+	//			var sum_count int64
1430
+	//			for _, its := range stockInfo {
1431
+	//				if its.MaxUnit == medical.MaxUnit {
1432
+	//					its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1433
+	//				}
1434
+	//				sum_count += its.StockMaxNumber + its.StockMinNumber
1435
+	//			}
1436
+	//			service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
1437
+	//		}
1438
+	//	}
1439
+	//}
1440
+	//tx.Commit()
1441
+
1299
 	this.ServeSuccessJSON(map[string]interface{}{
1442
 	this.ServeSuccessJSON(map[string]interface{}{
1300
 		"msg": "ok",
1443
 		"msg": "ok",
1301
 	})
1444
 	})

+ 34 - 7
controllers/stock_in_api_controller.go Parādīt failu

2957
 
2957
 
2958
 	storehouse_id, _ := this.GetInt64("storehouse_id")
2958
 	storehouse_id, _ := this.GetInt64("storehouse_id")
2959
 
2959
 
2960
+	good_id, _ := this.GetInt64("good_id")
2961
+
2962
+	order_way, _ := this.GetInt64("order_way")
2963
+
2960
 	timeLayout := "2006-01-02"
2964
 	timeLayout := "2006-01-02"
2961
 	loc, _ := time.LoadLocation("Local")
2965
 	loc, _ := time.LoadLocation("Local")
2962
 	var startTime int64
2966
 	var startTime int64
2993
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2997
 	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
2994
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
2998
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
2995
 	patientsList, _ := service.GetAllpatient(adminUserInfo.CurrentOrgId)
2999
 	patientsList, _ := service.GetAllpatient(adminUserInfo.CurrentOrgId)
3000
+	var goodKind = "耗材种类"
3001
+	goodKindParent, _ := service.GetDrugDataConfig(0, goodKind)
3002
+	goodKindList, _ := service.GetParentDataConfig(goodKindParent.ID, adminUserInfo.CurrentOrgId)
2996
 	if types == 1 {
3003
 	if types == 1 {
2997
-		list, total, err = service.FindStockInDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
2998
-		_, total_price = service.GetStockInDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
3004
+		list, total, err = service.FindStockInDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
3005
+		_, total_price = service.GetStockInDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
2999
 
3006
 
3000
 		if err == nil {
3007
 		if err == nil {
3001
 			this.ServeSuccessJSON(map[string]interface{}{
3008
 			this.ServeSuccessJSON(map[string]interface{}{
3006
 				"manufacturerList": manufacturerList,
3013
 				"manufacturerList": manufacturerList,
3007
 				"dealerList":       dealerList,
3014
 				"dealerList":       dealerList,
3008
 				"patientsList":     patientsList,
3015
 				"patientsList":     patientsList,
3016
+				"goodKindList":     goodKindList,
3009
 			})
3017
 			})
3010
 		} else {
3018
 		} else {
3011
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3019
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3012
 		}
3020
 		}
3013
 
3021
 
3014
 	} else if types == 2 {
3022
 	} else if types == 2 {
3015
-		list1, total, err = service.FindStockOutDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
3016
-		_, total_price = service.GetStockOutDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
3023
+		list1, total, err = service.FindStockOutDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id, order_way)
3024
+		_, total_price = service.GetStockOutDetailTotal(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id, order_way)
3017
 		if err == nil {
3025
 		if err == nil {
3018
 			this.ServeSuccessJSON(map[string]interface{}{
3026
 			this.ServeSuccessJSON(map[string]interface{}{
3019
 				"list":             list1,
3027
 				"list":             list1,
3023
 				"manufacturerList": manufacturerList,
3031
 				"manufacturerList": manufacturerList,
3024
 				"dealerList":       dealerList,
3032
 				"dealerList":       dealerList,
3025
 				"patientsList":     patientsList,
3033
 				"patientsList":     patientsList,
3034
+				"goodKindList":     goodKindList,
3026
 			})
3035
 			})
3027
 		} else {
3036
 		} else {
3028
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3037
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3037
 				"manufacturerList": manufacturerList,
3046
 				"manufacturerList": manufacturerList,
3038
 				"dealerList":       dealerList,
3047
 				"dealerList":       dealerList,
3039
 				"patientsList":     patientsList,
3048
 				"patientsList":     patientsList,
3049
+				"goodKindList":     goodKindList,
3040
 			})
3050
 			})
3041
 		} else {
3051
 		} else {
3042
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3052
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3043
 		}
3053
 		}
3044
 	} else if types == 4 {
3054
 	} else if types == 4 {
3045
-		list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
3046
-		listGroup, err := service.FindeCancelGroup(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id)
3055
+		list3, total, err = service.FindCancelDetailList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
3056
+		listGroup, err := service.FindeCancelGroup(adminUserInfo.CurrentOrgId, startTime, endTime, keywords, manufacturer, order_type, dealer, storehouse_id, good_id)
3047
 		if err == nil {
3057
 		if err == nil {
3048
 			this.ServeSuccessJSON(map[string]interface{}{
3058
 			this.ServeSuccessJSON(map[string]interface{}{
3049
 				"list":             list3,
3059
 				"list":             list3,
3053
 				"manufacturerList": manufacturerList,
3063
 				"manufacturerList": manufacturerList,
3054
 				"dealerList":       dealerList,
3064
 				"dealerList":       dealerList,
3055
 				"patientsList":     patientsList,
3065
 				"patientsList":     patientsList,
3066
+				"goodKindList":     goodKindList,
3056
 			})
3067
 			})
3057
 		} else {
3068
 		} else {
3058
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3069
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
7413
 	// 查询出库数据
7424
 	// 查询出库数据
7414
 	list, err := service.GetNewWarehouseOutById(id, orgId, tx)
7425
 	list, err := service.GetNewWarehouseOutById(id, orgId, tx)
7415
 	for _, item := range list {
7426
 	for _, item := range list {
7427
+
7428
+		service.ModifyGoodOutInfoLog(item.GoodId, item.ID, tx)
7416
 		//回退库存
7429
 		//回退库存
7417
 		service.UpdateaNewGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId, tx)
7430
 		service.UpdateaNewGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId, tx)
7418
 
7431
 
7541
 			//创建出库流水
7554
 			//创建出库流水
7542
 			service.CreateNewStockFlowOne(stockFlow, tx)
7555
 			service.CreateNewStockFlowOne(stockFlow, tx)
7543
 
7556
 
7557
+			infoLog := models.XtGoodWarehouseInfoLog{
7558
+
7559
+				GoodId:          item.GoodId,
7560
+				WarehouseInfoId: item.ID,
7561
+				RecordDate:      time.Now().Unix(),
7562
+				UserOrgId:       item.OrgId,
7563
+				Status:          1,
7564
+				Ctime:           time.Now().Unix(),
7565
+				Mtime:           time.Now().Unix(),
7566
+			}
7567
+
7568
+			service.CreateGoodWarehouseInfoLog(infoLog, tx)
7569
+
7544
 			//查询该仓库是否有数据
7570
 			//查询该仓库是否有数据
7545
 			stockCount, _ := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7571
 			stockCount, _ := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7546
 			if stockCount.ID == 0 {
7572
 			if stockCount.ID == 0 {
7625
 	}
7651
 	}
7626
 
7652
 
7627
 	err := service.UpdateNewWarehouseInfoMap(list, warehousing_info_id, orgId, tx)
7653
 	err := service.UpdateNewWarehouseInfoMap(list, warehousing_info_id, orgId, tx)
7654
+
7628
 	tx.Commit()
7655
 	tx.Commit()
7629
 	if err == nil {
7656
 	if err == nil {
7630
 		this.ServeSuccessJSON(map[string]interface{}{
7657
 		this.ServeSuccessJSON(map[string]interface{}{
8130
 	//	service.UpdateDealerManufacturerOne(item.ID, manufacturer.ManufacturerName)
8157
 	//	service.UpdateDealerManufacturerOne(item.ID, manufacturer.ManufacturerName)
8131
 	//}
8158
 	//}
8132
 
8159
 
8133
-	drugList, _ := service.GetAllBaseDrugListTwentyOne(10215)
8160
+	drugList, _ := service.GetAllBaseDrugListTwentyOne(10480)
8134
 
8161
 
8135
 	for _, item := range drugList {
8162
 	for _, item := range drugList {
8136
 		var drug_spec = item.Dose + item.DoseUnit + "*" + strconv.FormatInt(item.MinNumber, 10) + item.MinUnit + "/" + item.MaxUnit
8163
 		var drug_spec = item.Dose + item.DoseUnit + "*" + strconv.FormatInt(item.MinNumber, 10) + item.MinUnit + "/" + item.MaxUnit

+ 3 - 0
enums/error_code.go Parādīt failu

289
 	ErrorCodeAuthWrong = 600000013
289
 	ErrorCodeAuthWrong = 600000013
290
 
290
 
291
 	ErrorCodeFlow = 600000014
291
 	ErrorCodeFlow = 600000014
292
+
293
+	ErrorCodePrescription = 600000015
292
 )
294
 )
293
 
295
 
294
 var ErrCodeMsgs = map[int]string{
296
 var ErrCodeMsgs = map[int]string{
555
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
557
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
556
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
558
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
557
 	ErrorCodeFlow:           "网络错误,数据异常,审核失败",
559
 	ErrorCodeFlow:           "网络错误,数据异常,审核失败",
560
+	ErrorCodePrescription:   "请先开处方",
558
 }
561
 }
559
 
562
 
560
 type SGJError struct {
563
 type SGJError struct {

+ 80 - 79
models/good_models.go Parādīt failu

238
 }
238
 }
239
 
239
 
240
 type XtGoodInformationFourty struct {
240
 type XtGoodInformationFourty struct {
241
-	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
242
-	GoodCode                    string  `gorm:"column:good_code" json:"good_code" form:"good_code"`
243
-	SpecificationName           string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
244
-	GoodTypeId                  int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
245
-	GoodUnit                    int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
246
-	BuyPrice                    float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
247
-	SellPrice                   float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
248
-	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
249
-	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
250
-	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
251
-	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
252
-	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
253
-	ExpiryDateWarnDayCount      int64   `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
254
-	StockWarnCount              int64   `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
255
-	IsReuse                     int64   `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
256
-	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
257
-	FilmArea                    string  `gorm:"column:film_area" json:"film_area" form:"film_area"`
258
-	IsUse                       int64   `gorm:"column:is_use" json:"is_use" form:"is_use"`
259
-	FilmMaterialQuality         string  `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
260
-	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
261
-	Modifier                    int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
262
-	Creater                     int64   `gorm:"column:creater" json:"creater" form:"creater"`
263
-	GoodName                    string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
264
-	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
265
-	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
266
-	GoodKind                    int64   `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
267
-	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
268
-	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
269
-	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
270
-	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
271
-	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
272
-	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
273
-	GoodStatus                  string  `gorm:"column:good_status" json:"good_status" form:"good_status"`
274
-	DefaultCount                int64   `gorm:"column:default_count" json:"default_count" form:"default_count"`
275
-	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
276
-	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
277
-	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
278
-	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
279
-	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
280
-	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
281
-	IsDoctorUse                 int64   `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
282
-	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
283
-	GoodNumber                  string  `gorm:"column:good_number" json:"good_number" form:"good_number"`
284
-	CommdityCode                string  `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
285
-	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
286
-	ProductionType              string  `gorm:"column:production_type" json:"production_type" form:"production_type"`
287
-	SpecialMedical              string  `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
288
-	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
289
-	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
290
-	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
291
-	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
292
-	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
293
-	DefaultCountUnit            string  `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
294
-	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
295
-	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
296
-	ProvincesCode               string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
297
-	IsUser                      int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
298
-	Number                      string  `gorm:"column:number" json:"number" form:"number"`
299
-	IsWarehouse                 int64   `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
300
-	BatchRetaiPrice             float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
301
-	SumCount                    int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
302
-	SumInCount                  int64   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
303
-	TotalCount                  int64   `gorm:"column:total_count" json:"total_count" form:"total_count"`
304
-	SumOutCount                 int64   `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
305
-	SumCancelCount              int64   `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
306
-	IsPrint                     int64   `gorm:"column:is_print" json:"is_print" form:"is_print"`
307
-	FirstLetter                 string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
308
-	ZuobiaoId                   string  `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
309
-	Bck01b                      string  `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
310
-	Bby01                       string  `gorm:"column:bby01" json:"bby01" form:"bby01"`
311
-	Bbx01                       string  `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
312
-	TotalCountOne               int64   `gorm:"column:total_count_one" json:"total_count_one" form:"total_count_one"`
313
-	DepartMent                  string  `gorm:"column:depart_ment" json:"depart_ment" form:"depart_ment"`
314
-	DepartMentCode              string  `gorm:"column:depart_ment_code" json:"depart_ment_code" form:"depart_ment_code"`
315
-	TotalCountTwo               int64   `gorm:"column:total_count_two" json:"total_count_two" form:"total_count_two"`
316
-	CodeName                    string  `gorm:"column:code_name" json:"code_name" form:"code_name"`
317
-	OrgName                     string  `gorm:"column:org_name" json:"org_name" form:"org_name"`
318
-	GoodTypeName                string  `gorm:"column:good_type_name" json:"good_type_name" form:"good_type_name"`
319
-	IsShow                      int64   `gorm:"column:is_show" json:"is_show" form:"is_show"`
241
+	ID                          int64     `gorm:"column:id" json:"id" form:"id"`
242
+	GoodCode                    string    `gorm:"column:good_code" json:"good_code" form:"good_code"`
243
+	SpecificationName           string    `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
244
+	GoodTypeId                  int64     `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
245
+	GoodUnit                    int64     `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
246
+	BuyPrice                    float64   `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
247
+	SellPrice                   float64   `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
248
+	Remark                      string    `gorm:"column:remark" json:"remark" form:"remark"`
249
+	Ctime                       int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
250
+	Mtime                       int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
251
+	Manufacturer                int64     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
252
+	Dealer                      int64     `gorm:"column:dealer" json:"dealer" form:"dealer"`
253
+	ExpiryDateWarnDayCount      int64     `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
254
+	StockWarnCount              int64     `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
255
+	IsReuse                     int64     `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
256
+	Status                      int64     `gorm:"column:status" json:"status" form:"status"`
257
+	FilmArea                    string    `gorm:"column:film_area" json:"film_area" form:"film_area"`
258
+	IsUse                       int64     `gorm:"column:is_use" json:"is_use" form:"is_use"`
259
+	FilmMaterialQuality         string    `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
260
+	OrgId                       int64     `gorm:"column:org_id" json:"org_id" form:"org_id"`
261
+	Modifier                    int64     `gorm:"column:modifier" json:"modifier" form:"modifier"`
262
+	Creater                     int64     `gorm:"column:creater" json:"creater" form:"creater"`
263
+	GoodName                    string    `gorm:"column:good_name" json:"good_name" form:"good_name"`
264
+	Pinyin                      string    `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
265
+	Wubi                        string    `gorm:"column:wubi" json:"wubi" form:"wubi"`
266
+	GoodKind                    int64     `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
267
+	MedicalInsuranceLevel       int64     `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
268
+	RetailPrice                 float64   `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
269
+	MedicalInsuranceNumber      string    `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
270
+	IsSpecialDiseases           int64     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
271
+	IsRecord                    int64     `gorm:"column:is_record" json:"is_record" form:"is_record"`
272
+	StatisticsCategory          int64     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
273
+	GoodStatus                  string    `gorm:"column:good_status" json:"good_status" form:"good_status"`
274
+	DefaultCount                int64     `gorm:"column:default_count" json:"default_count" form:"default_count"`
275
+	IsDefault                   int64     `gorm:"column:is_default" json:"is_default" form:"is_default"`
276
+	IsChargeUse                 int64     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
277
+	IsChargePredict             int64     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
278
+	IsStatisticsWork            int64     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
279
+	Sign                        int64     `gorm:"column:sign" json:"sign" form:"sign"`
280
+	Sort                        int64     `gorm:"column:sort" json:"sort" form:"sort"`
281
+	IsDoctorUse                 int64     `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
282
+	Agent                       string    `gorm:"column:agent" json:"agent" form:"agent"`
283
+	GoodNumber                  string    `gorm:"column:good_number" json:"good_number" form:"good_number"`
284
+	CommdityCode                string    `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
285
+	SocialSecurityDirectoryCode string    `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
286
+	ProductionType              string    `gorm:"column:production_type" json:"production_type" form:"production_type"`
287
+	SpecialMedical              string    `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
288
+	IsMark                      int64     `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
289
+	Total                       float64   `gorm:"column:total" json:"total" form:"total"`
290
+	MinNumber                   int64     `gorm:"column:min_number" json:"min_number" form:"min_number"`
291
+	PackingUnit                 string    `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
292
+	PackingPrice                float64   `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
293
+	DefaultCountUnit            string    `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
294
+	MinUnit                     string    `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
295
+	RegisterNumber              string    `gorm:"column:register_number" json:"register_number" form:"register_number"`
296
+	ProvincesCode               string    `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
297
+	IsUser                      int64     `gorm:"column:is_user" json:"is_user" form:"is_user"`
298
+	Number                      string    `gorm:"column:number" json:"number" form:"number"`
299
+	IsWarehouse                 int64     `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
300
+	BatchRetaiPrice             float64   `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
301
+	SumCount                    int64     `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
302
+	SumInCount                  int64     `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
303
+	TotalCount                  int64     `gorm:"column:total_count" json:"total_count" form:"total_count"`
304
+	SumOutCount                 int64     `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
305
+	SumCancelCount              int64     `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
306
+	IsPrint                     int64     `gorm:"column:is_print" json:"is_print" form:"is_print"`
307
+	FirstLetter                 string    `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
308
+	ZuobiaoId                   string    `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
309
+	Bck01b                      string    `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
310
+	Bby01                       string    `gorm:"column:bby01" json:"bby01" form:"bby01"`
311
+	Bbx01                       string    `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
312
+	TotalCountOne               int64     `gorm:"column:total_count_one" json:"total_count_one" form:"total_count_one"`
313
+	DepartMent                  string    `gorm:"column:depart_ment" json:"depart_ment" form:"depart_ment"`
314
+	DepartMentCode              string    `gorm:"column:depart_ment_code" json:"depart_ment_code" form:"depart_ment_code"`
315
+	TotalCountTwo               int64     `gorm:"column:total_count_two" json:"total_count_two" form:"total_count_two"`
316
+	CodeName                    string    `gorm:"column:code_name" json:"code_name" form:"code_name"`
317
+	OrgName                     string    `gorm:"column:org_name" json:"org_name" form:"org_name"`
318
+	GoodTypeName                string    `gorm:"column:good_type_name" json:"good_type_name" form:"good_type_name"`
319
+	IsShow                      int64     `gorm:"column:is_show" json:"is_show" form:"is_show"`
320
+	GoodsType                   GoodsType `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
320
 }
321
 }
321
 
322
 
322
 func (XtGoodInformationFourty) TableName() string {
323
 func (XtGoodInformationFourty) TableName() string {

+ 62 - 0
models/new_stock_models.go Parādīt failu

492
 func (DrugFlowTwenty) TableName() string {
492
 func (DrugFlowTwenty) TableName() string {
493
 	return "xt_drug_flow"
493
 	return "xt_drug_flow"
494
 }
494
 }
495
+
496
+type XtGoodWarehouseInfoLog struct {
497
+	ID              int64 `gorm:"column:id" json:"id" form:"id"`
498
+	GoodId          int64 `gorm:"column:good_id" json:"good_id" form:"good_id"`
499
+	WarehouseInfoId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
500
+	RecordDate      int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
501
+	UserOrgId       int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
502
+	Status          int64 `gorm:"column:status" json:"status" form:"status"`
503
+	Ctime           int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
504
+	Mtime           int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
505
+}
506
+
507
+func (XtGoodWarehouseInfoLog) TableName() string {
508
+	return "xt_good_warehouse_info_log"
509
+}
510
+
511
+type XtGoodWarehouseOutInfoLog struct {
512
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
513
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
514
+	GoodId             int64 `gorm:"column:good_id" json:"good_id" form:"good_id"`
515
+	RecordDate         int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
516
+	WarehouseOutInfoId int64 `gorm:"column:warehouse_out_info_id" json:"warehouse_out_info_id" form:"warehouse_out_info_id"`
517
+	Status             int64 `gorm:"column:status" json:"status" form:"status"`
518
+	Ctime              int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
519
+	Mtime              int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
520
+	BatchNumberId      int64 `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
521
+}
522
+
523
+func (XtGoodWarehouseOutInfoLog) TableName() string {
524
+	return "xt_good_warehouse_out_info_log"
525
+}
526
+
527
+type XtDrugWarehouseOutInfoLog struct {
528
+	ID                 int64 `gorm:"column:id" json:"id" form:"id"`
529
+	UserOrgId          int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
530
+	DrugId             int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
531
+	WarehouseOutInfoId int64 `gorm:"column:warehouse_out_info_id" json:"warehouse_out_info_id" form:"warehouse_out_info_id"`
532
+	RecordDate         int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
533
+	Status             int64 `gorm:"column:status" json:"status" form:"status"`
534
+	Ctime              int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
535
+	Mtime              int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
536
+	BatchNumberId      int64 `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
537
+}
538
+
539
+func (XtDrugWarehouseOutInfoLog) TableName() string {
540
+	return "xt_drug_warehouse_out_info_log"
541
+}
542
+
543
+type XtDrugWarehouseInfoLog struct {
544
+	ID              int64 `gorm:"column:id" json:"id" form:"id"`
545
+	DrugId          int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
546
+	WarehouseInfoId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
547
+	RecordDate      int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
548
+	UserOrgId       int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
549
+	Status          int64 `gorm:"column:status" json:"status" form:"status"`
550
+	Ctime           int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
551
+	Mtime           int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
552
+}
553
+
554
+func (XtDrugWarehouseInfoLog) TableName() string {
555
+	return "xt_drug_warehouse_info_log"
556
+}

+ 17 - 0
models/patient_models.go Parādīt failu

3103
 
3103
 
3104
 	return "xt_inspection"
3104
 	return "xt_inspection"
3105
 }
3105
 }
3106
+
3107
+type XtInspectionOne struct {
3108
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
3109
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3110
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3111
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
3112
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
3113
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
3114
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
3115
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
3116
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
3117
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
3118
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
3119
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
3120
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
3121
+	Count        int64
3122
+}

+ 83 - 83
models/stock_models.go Parādīt failu

143
 }
143
 }
144
 
144
 
145
 type WarehousingInfo struct {
145
 type WarehousingInfo struct {
146
-	ID                        int64       `gorm:"column:id" json:"id"`
147
-	WarehousingId             int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
148
-	GoodId                    int64       `gorm:"column:good_id" json:"good_id"`
149
-	GoodTypeId                int64       `gorm:"column:good_type_id" json:"good_type_id"`
150
-	Number                    string      `gorm:"column:number" json:"number"`
151
-	ProductDate               int64       `gorm:"column:product_date" json:"product_date"`
152
-	ExpiryDate                int64       `gorm:"column:expiry_date" json:"expiry_date"`
153
-	WarehousingCount          int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
154
-	WarehousingUnit           string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
155
-	Price                     float64     `gorm:"column:price" json:"price"`
156
-	TotalPrice                float64     `gorm:"column:total_price" json:"total_price"`
157
-	Dealer                    int64       `gorm:"column:dealer" json:"dealer"`
158
-	Manufacturer              int64       `gorm:"column:manufacturer" json:"manufacturer"`
159
-	Remark                    string      `gorm:"column:remark" json:"remark"`
160
-	Ctime                     int64       `gorm:"column:ctime" json:"ctime"`
161
-	Mtime                     int64       `gorm:"column:mtime" json:"mtime"`
162
-	Status                    int64       `gorm:"column:status" json:"status"`
163
-	OrgId                     int64       `gorm:"column:org_id" json:"org_id"`
164
-	IsReturn                  int64       `gorm:"column:is_return" json:"is_return"`
165
-	StockCount                int64       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
166
-	Warehousing               Warehousing `ForeignKey:WarehousingId json:"warehouse"`
167
-	WarehousingOrder          string      `gorm:"column:warehousing_order" json:"warehousing_order"`
168
-	GoodInfo                  GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
169
-	Type                      int64       `gorm:"column:type" json:"type"`
170
-	LicenseNumber             string      `gorm:"column:license_number" json:"license_number" form:"license_number"`
171
-	WarehouseInfoId           int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
172
-	PackingPrice              float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
173
-	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
174
-	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
175
-	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
176
-	SecondWarehouseInfoId     int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
177
-	IsCheck                   int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
178
-	RegisterNumber            string      `gorm:"column:register_number" json:"register_number" form:"register_number"`
179
-	ManafacturerName          string      `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
180
-	DealerName                string      `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
181
-	GoodCode                  string      `gorm:"column:good_code" json:"good_code" form:"good_code"`
146
+	ID                        int64                   `gorm:"column:id" json:"id"`
147
+	WarehousingId             int64                   `gorm:"column:warehousing_id" json:"warehousing_id"`
148
+	GoodId                    int64                   `gorm:"column:good_id" json:"good_id"`
149
+	GoodTypeId                int64                   `gorm:"column:good_type_id" json:"good_type_id"`
150
+	Number                    string                  `gorm:"column:number" json:"number"`
151
+	ProductDate               int64                   `gorm:"column:product_date" json:"product_date"`
152
+	ExpiryDate                int64                   `gorm:"column:expiry_date" json:"expiry_date"`
153
+	WarehousingCount          int64                   `gorm:"column:warehousing_count" json:"warehousing_count"`
154
+	WarehousingUnit           string                  `gorm:"column:warehousing_unit" json:"warehousing_unit"`
155
+	Price                     float64                 `gorm:"column:price" json:"price"`
156
+	TotalPrice                float64                 `gorm:"column:total_price" json:"total_price"`
157
+	Dealer                    int64                   `gorm:"column:dealer" json:"dealer"`
158
+	Manufacturer              int64                   `gorm:"column:manufacturer" json:"manufacturer"`
159
+	Remark                    string                  `gorm:"column:remark" json:"remark"`
160
+	Ctime                     int64                   `gorm:"column:ctime" json:"ctime"`
161
+	Mtime                     int64                   `gorm:"column:mtime" json:"mtime"`
162
+	Status                    int64                   `gorm:"column:status" json:"status"`
163
+	OrgId                     int64                   `gorm:"column:org_id" json:"org_id"`
164
+	IsReturn                  int64                   `gorm:"column:is_return" json:"is_return"`
165
+	StockCount                int64                   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
166
+	Warehousing               Warehousing             `ForeignKey:WarehousingId json:"warehouse"`
167
+	WarehousingOrder          string                  `gorm:"column:warehousing_order" json:"warehousing_order"`
168
+	GoodInfo                  XtGoodInformationFourty `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId"json:"GoodInfo" `
169
+	Type                      int64                   `gorm:"column:type" json:"type"`
170
+	LicenseNumber             string                  `gorm:"column:license_number" json:"license_number" form:"license_number"`
171
+	WarehouseInfoId           int64                   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
172
+	PackingPrice              float64                 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
173
+	SupplyWarehouseId         int64                   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
174
+	SupplyWarehouseDetailInfo int64                   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
175
+	StorehouseId              int64                   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
176
+	SecondWarehouseInfoId     int64                   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
177
+	IsCheck                   int64                   `gorm:"column:is_check" json:"is_check" form:"is_check"`
178
+	RegisterNumber            string                  `gorm:"column:register_number" json:"register_number" form:"register_number"`
179
+	ManafacturerName          string                  `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
180
+	DealerName                string                  `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
181
+	GoodCode                  string                  `gorm:"column:good_code" json:"good_code" form:"good_code"`
182
 }
182
 }
183
 
183
 
184
 func (WarehousingInfo) TableName() string {
184
 func (WarehousingInfo) TableName() string {
262
 }
262
 }
263
 
263
 
264
 type WarehouseOutInfo struct {
264
 type WarehouseOutInfo struct {
265
-	ID                      int64                `gorm:"column:id" json:"id"`
266
-	WarehouseOutId          int64                `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
267
-	WarehouseInfotId        int64                `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
268
-	GoodId                  int64                `gorm:"column:good_id" json:"good_id"`
269
-	GoodTypeId              int64                `gorm:"column:good_type_id" json:"good_type_id"`
270
-	WarehousingOutTarget    int64                `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
271
-	Count                   int64                `gorm:"column:count" json:"count"`
272
-	Price                   float64              `gorm:"column:price" json:"price"`
273
-	TotalPrice              float64              `gorm:"column:total_price" json:"total_price"`
274
-	ProductDate             int64                `gorm:"column:product_date" json:"product_date"`
275
-	ExpiryDate              int64                `gorm:"column:expiry_date" json:"expiry_date"`
276
-	Mtime                   int64                `gorm:"column:mtime" json:"mtime"`
277
-	Ctime                   int64                `gorm:"column:ctime" json:"ctime"`
278
-	Status                  int64                `gorm:"column:status" json:"status"`
279
-	OrgId                   int64                `gorm:"column:org_id" json:"org_id"`
280
-	Remark                  string               `gorm:"column:remark" json:"remark"`
281
-	IsCancel                int64                `gorm:"column:is_cancel" json:"is_cancel"`
282
-	WarehouseOut            WarehouseOut         `ForeignKey:WarehouseOutId json:"WarehouseOut"`
283
-	WarehouseOutOrderNumber string               `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
284
-	GoodInfo                GoodInfo             `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
285
-	Type                    int64                `gorm:"column:type" json:"type"`
286
-	Dealer                  int64                `gorm:"column:dealer" json:"dealer"`
287
-	Manufacturer            int64                `gorm:"column:manufacturer" json:"manufacturer"`
288
-	IsSys                   int64                `gorm:"column:is_sys" json:"is_sys"`
289
-	SysRecordTime           int64                `gorm:"column:sys_record_time" json:"sys_record_time"`
290
-	PatientId               int64                `gorm:"column:patient_id" json:"patient_id"`
291
-	Number                  string               `gorm:"column:number" json:"number" form:"number"`
292
-	LicenseNumber           string               `gorm:"column:license_number" json:"license_number" form:"license_number"`
293
-	ConsumableType          int64                `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
294
-	ProjectId               int64                `gorm:"column:project_id" json:"project_id" form:"project_id"`
295
-	SupplyCancelOutId       int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
296
-	SupplyWarehouseId       int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
297
-	IsSource                int64                `gorm:"column:is_source" json:"is_source" form:"is_source"`
298
-	StorehouseId            int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
299
-	SecondWarehouseInfoId   int64                `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
300
-	AdminUserId             int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
301
-	BuyPrice                float64              `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
302
-	StockCount              string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
303
-	IsCheck                 int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
304
-	RegisterNumber          string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
305
-	WarehousingInfo         WarehousingInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId" `
306
-	VmStockFlow             VmStockFlow          `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId" json:"stock_flow"`
307
-	OverCount               int64                `gorm:"column:over_count" json:"over_count" form:"over_count"`
308
-	OrderId                 int64                `gorm:"column:order_id" json:"order_id" form:"order_id"`
309
-	WarehousingInfoNight    WarehousingInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId"`
310
-	DealerName              string               `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
311
-	ClassType               string               `gorm:"column:class_type" json:"class_type" form:"class_type"`
265
+	ID                      int64                   `gorm:"column:id" json:"id"`
266
+	WarehouseOutId          int64                   `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
267
+	WarehouseInfotId        int64                   `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
268
+	GoodId                  int64                   `gorm:"column:good_id" json:"good_id"`
269
+	GoodTypeId              int64                   `gorm:"column:good_type_id" json:"good_type_id"`
270
+	WarehousingOutTarget    int64                   `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
271
+	Count                   int64                   `gorm:"column:count" json:"count"`
272
+	Price                   float64                 `gorm:"column:price" json:"price"`
273
+	TotalPrice              float64                 `gorm:"column:total_price" json:"total_price"`
274
+	ProductDate             int64                   `gorm:"column:product_date" json:"product_date"`
275
+	ExpiryDate              int64                   `gorm:"column:expiry_date" json:"expiry_date"`
276
+	Mtime                   int64                   `gorm:"column:mtime" json:"mtime"`
277
+	Ctime                   int64                   `gorm:"column:ctime" json:"ctime"`
278
+	Status                  int64                   `gorm:"column:status" json:"status"`
279
+	OrgId                   int64                   `gorm:"column:org_id" json:"org_id"`
280
+	Remark                  string                  `gorm:"column:remark" json:"remark"`
281
+	IsCancel                int64                   `gorm:"column:is_cancel" json:"is_cancel"`
282
+	WarehouseOut            WarehouseOut            `ForeignKey:WarehouseOutId json:"WarehouseOut"`
283
+	WarehouseOutOrderNumber string                  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
284
+	GoodInfo                XtGoodInformationFourty `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId"json:"GoodInfo" `
285
+	Type                    int64                   `gorm:"column:type" json:"type"`
286
+	Dealer                  int64                   `gorm:"column:dealer" json:"dealer"`
287
+	Manufacturer            int64                   `gorm:"column:manufacturer" json:"manufacturer"`
288
+	IsSys                   int64                   `gorm:"column:is_sys" json:"is_sys"`
289
+	SysRecordTime           int64                   `gorm:"column:sys_record_time" json:"sys_record_time"`
290
+	PatientId               int64                   `gorm:"column:patient_id" json:"patient_id"`
291
+	Number                  string                  `gorm:"column:number" json:"number" form:"number"`
292
+	LicenseNumber           string                  `gorm:"column:license_number" json:"license_number" form:"license_number"`
293
+	ConsumableType          int64                   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
294
+	ProjectId               int64                   `gorm:"column:project_id" json:"project_id" form:"project_id"`
295
+	SupplyCancelOutId       int64                   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
296
+	SupplyWarehouseId       int64                   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
297
+	IsSource                int64                   `gorm:"column:is_source" json:"is_source" form:"is_source"`
298
+	StorehouseId            int64                   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
299
+	SecondWarehouseInfoId   int64                   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
300
+	AdminUserId             int64                   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
301
+	BuyPrice                float64                 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
302
+	StockCount              string                  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
303
+	IsCheck                 int64                   `gorm:"column:is_check" json:"is_check" form:"is_check"`
304
+	RegisterNumber          string                  `gorm:"column:register_number" json:"register_number" form:"register_number"`
305
+	WarehousingInfo         WarehousingInfo         `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId" `
306
+	VmStockFlow             VmStockFlow             `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId" json:"stock_flow"`
307
+	OverCount               int64                   `gorm:"column:over_count" json:"over_count" form:"over_count"`
308
+	OrderId                 int64                   `gorm:"column:order_id" json:"order_id" form:"order_id"`
309
+	WarehousingInfoNight    WarehousingInfoNight    `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId"`
310
+	DealerName              string                  `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
311
+	ClassType               string                  `gorm:"column:class_type" json:"class_type" form:"class_type"`
312
 }
312
 }
313
 
313
 
314
 func (WarehouseOutInfo) TableName() string {
314
 func (WarehouseOutInfo) TableName() string {

+ 3 - 3
service/dialysis_parameter_service.go Parādīt failu

122
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, schedulDate).
122
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, schedulDate).
123
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
123
 		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
124
 		Preload("DialysisSolution", "status=1 and user_org_id = ? and solution_status = 1", orgID)
124
 		Preload("DialysisSolution", "status=1 and user_org_id = ? and solution_status = 1", orgID)
125
-	db = db.Where("xt_schedule.status = 1 AND user_org_id = ?", orgID)
125
+	db = db.Where("xt_schedule.status = 1 AND xt_schedule.user_org_id = ?", orgID)
126
 	if schedulDate > 0 {
126
 	if schedulDate > 0 {
127
-		db = db.Where("schedule_date = ?", schedulDate)
127
+		db = db.Where("xt_schedule.schedule_date = ?", schedulDate)
128
 	}
128
 	}
129
 	if schedulType > 0 {
129
 	if schedulType > 0 {
130
-		db = db.Where("schedule_type = ?", schedulType)
130
+		db = db.Where("xt_schedule.schedule_type = ?", schedulType)
131
 	}
131
 	}
132
 	if partitionType > 0 {
132
 	if partitionType > 0 {
133
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ? and xt_device_number.status = 1", partitionType)
133
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ? and xt_device_number.status = 1", partitionType)

+ 23 - 0
service/dialysis_service.go Parādīt failu

1613
 	return err
1613
 	return err
1614
 }
1614
 }
1615
 
1615
 
1616
+func GetHisPrescriptionProjectByIds(ids []string) (project []*models.HisPrescriptionProject, err error) {
1617
+
1618
+	err = readDb.Where("id IN(?) and status=1", ids).Find(&project).Error
1619
+
1620
+	return project, err
1621
+}
1622
+
1623
+func ModfifyProjectListByIds(id int64, exeTime int64, record_date int64, patient_id int64) (models.HisPrescriptionProject, error) {
1624
+
1625
+	project := models.HisPrescriptionProject{}
1626
+
1627
+	err := writeDb.Model(&project).Where("team_id = ? and status=1 and execution_state = 1 and record_date = ? and patient_id=?", id, record_date, patient_id).Updates(map[string]interface{}{"execution_time": exeTime}).Error
1628
+
1629
+	return project, err
1630
+}
1631
+
1616
 func FindHisProjectById(orgID int64, id int64) (advice models.HisPrescriptionProject, err error) {
1632
 func FindHisProjectById(orgID int64, id int64) (advice models.HisPrescriptionProject, err error) {
1617
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1633
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1618
 	return
1634
 	return
2167
 	return list, err
2183
 	return list, err
2168
 }
2184
 }
2169
 
2185
 
2186
+func GetDialysisSolutionByDate(org_id int64) (solution []*models.DialysisSolution, err error) {
2187
+
2188
+	err = XTReadDB().Where("user_org_id = ? and solution_status = 1 and status=1", org_id).Find(&solution).Error
2189
+
2190
+	return solution, err
2191
+}
2192
+
2170
 func GetFiledConfig(orgid int64) (models.FiledConfig, error) {
2193
 func GetFiledConfig(orgid int64) (models.FiledConfig, error) {
2171
 
2194
 
2172
 	config := models.FiledConfig{}
2195
 	config := models.FiledConfig{}

+ 1 - 0
service/dialysis_solution_service.go Parādīt failu

601
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
601
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
602
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
602
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
603
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
603
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
604
+		Preload("DialysisSolution", "status=1 and user_org_id =? and solution_status =1", orgID).
604
 		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
605
 		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
605
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
606
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
606
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
607
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {

+ 14 - 2
service/drug_stock_service.go Parādīt failu

194
 	return info, err
194
 	return info, err
195
 }
195
 }
196
 
196
 
197
-func GetDrugWarehouseInfoPrint(startime int64, endtime int64, orgid int64, storehouse_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
197
+func GetDrugWarehouseInfoPrint(startime int64, endtime int64, orgid int64, storehouse_id int64, drug_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
198
 
198
 
199
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
199
 	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
200
 	if startime > 0 {
200
 	if startime > 0 {
209
 	if storehouse_id > 0 {
209
 	if storehouse_id > 0 {
210
 		db = db.Where("storehouse_id =?", storehouse_id)
210
 		db = db.Where("storehouse_id =?", storehouse_id)
211
 	}
211
 	}
212
+	if drug_id > 0 {
213
+		db = db.Where("drug_id = ?", drug_id)
214
+	}
212
 	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number,x.dealer,x.manufacturer").Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("x.drug_id").Find(&info).Error
215
 	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number,x.dealer,x.manufacturer").Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Group("x.drug_id").Find(&info).Error
213
 
216
 
214
 	//err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number").Group("x.drug_id").Find(&DrugWarehouseInfo{}).Error
217
 	//err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,sum(x.warehousing_count) as warehousing_count,x.price,x.total_price,x.dealer,x.manufacturer,x.remark,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.batch_number").Group("x.drug_id").Find(&DrugWarehouseInfo{}).Error
264
 	return list, err
267
 	return list, err
265
 }
268
 }
266
 
269
 
267
-func GetDrugOutOrderInfoPrintList(startime int64, endtime int64, orgid int64, storehouse_id int64) (list []*models.SgjDrugWarehouseOutInfo, err error) {
270
+func GetDrugOutOrderInfoPrintList(startime int64, endtime int64, orgid int64, storehouse_id int64, drug_id int64, order_way int64) (list []*models.SgjDrugWarehouseOutInfo, err error) {
268
 
271
 
269
 	db := XTReadDB().Table("xt_drug_warehouse_out_info").Where("status = 1 and is_check=1")
272
 	db := XTReadDB().Table("xt_drug_warehouse_out_info").Where("status = 1 and is_check=1")
270
 	if startime > 0 {
273
 	if startime > 0 {
279
 	if storehouse_id > 0 {
282
 	if storehouse_id > 0 {
280
 		db = db.Where("storehouse_id=?", storehouse_id)
283
 		db = db.Where("storehouse_id=?", storehouse_id)
281
 	}
284
 	}
285
+	if drug_id > 0 {
286
+		db = db.Where("drug_id = ?", drug_id)
287
+	}
288
+	if order_way == 1 {
289
+		db = db.Where("is_sys !=1")
290
+	}
291
+	if order_way == 2 {
292
+		db = db.Where("is_sys = 1")
293
+	}
282
 	err = db.Preload("XtDrugWarehouseInfo", "status=1 and org_id =?", orgid).Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
294
 	err = db.Preload("XtDrugWarehouseInfo", "status=1 and org_id =?", orgid).Preload("XtBaseDrug", "status = 1 and org_id = ?", orgid).Find(&list).Error
283
 	return list, err
295
 	return list, err
284
 }
296
 }

+ 24 - 4
service/gobal_config_service.go Parādīt failu

317
 	return
317
 	return
318
 }
318
 }
319
 
319
 
320
-func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
320
+func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64, drug_id int64) (drugInfo []*models.BloodDrugWarehouseInfo, total int64, err error) {
321
 
321
 
322
 	likeKey := "%" + keyword + "%"
322
 	likeKey := "%" + keyword + "%"
323
 	offset := (page - 1) * limit
323
 	offset := (page - 1) * limit
341
 	if storehouse_id > 0 {
341
 	if storehouse_id > 0 {
342
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
342
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
343
 	}
343
 	}
344
+	if drug_id > 0 {
345
+		db = db.Where("x.drug_id = ?", drug_id)
346
+	}
344
 
347
 
345
 	if len(keyword) > 0 {
348
 	if len(keyword) > 0 {
346
 		db = db.Joins("left join sgj_xt.xt_drug_warehouse as o on o.id = x.warehousing_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater")
349
 		db = db.Joins("left join sgj_xt.xt_drug_warehouse as o on o.id = x.warehousing_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater")
392
 	return returninfo, total, err
395
 	return returninfo, total, err
393
 }
396
 }
394
 
397
 
395
-func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (outinfo []*models.BloodDrugWarehouseOutInfo, total int64, err error) {
398
+func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64, drug_id int64, order_way int64) (outinfo []*models.BloodDrugWarehouseOutInfo, total int64, err error) {
396
 
399
 
397
 	likeKey := "%" + keyword + "%"
400
 	likeKey := "%" + keyword + "%"
398
 	offset := (page - 1) * limit
401
 	offset := (page - 1) * limit
419
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
422
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
420
 	}
423
 	}
421
 
424
 
425
+	if drug_id > 0 {
426
+		db = db.Where("x.drug_id = ?", drug_id)
427
+	}
428
+	if order_way == 1 {
429
+		db = db.Where("x.is_sys!=1")
430
+	}
431
+	if order_way == 2 {
432
+		db = db.Where("x.is_sys=1")
433
+	}
434
+
422
 	if len(keyword) > 0 {
435
 	if len(keyword) > 0 {
423
 		db = db.Joins("left join sgj_xt.xt_drug_warehouse_out as o on o.id = x.warehouse_out_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("x.id")
436
 		db = db.Joins("left join sgj_xt.xt_drug_warehouse_out as o on o.id = x.warehouse_out_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("x.id")
424
 		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ?  or r.user_name like ?", likeKey, likeKey, likeKey)
437
 		db = db.Where("x.warehouse_out_order_number like ? or b.drug_name like ?  or r.user_name like ?", likeKey, likeKey, likeKey)
434
 	return outinfo, total, err
447
 	return outinfo, total, err
435
 }
448
 }
436
 
449
 
437
-func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, storehouse_id int64) (info []*models.BloodDrugCancelStockInfo, err error) {
450
+func GetDrugCancelOrderPrint(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, storehouse_id int64, drug_id int64) (info []*models.BloodDrugCancelStockInfo, err error) {
438
 	likeKey := "%" + keyword + "%"
451
 	likeKey := "%" + keyword + "%"
439
 	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
452
 	db := XTReadDB().Table("xt_drug_cancel_stock_info as x").Where("x.status =1")
440
 	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
453
 	dbOne := XTReadDB().Table("xt_base_drug as s").Where("s.status =1")
459
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
472
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
460
 	}
473
 	}
461
 
474
 
475
+	if drug_id > 0 {
476
+		db = db.Where("x.drug_id = ?", drug_id)
477
+	}
478
+
462
 	if manufacturerId > 0 {
479
 	if manufacturerId > 0 {
463
 		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,s.dealer,s.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
480
 		err = db.Select("x.id,x.max_unit as unit,x.drug_id,x.cancel_stock_id,x.count,x.price,x.total,x.product_date,x.expiry_date,x.ctime,x.org_id,x.order_number,x.type,s.dealer,s.manufacturer,x.retail_price,x.retail_total_price,x.number,x.storehouse_id,s.drug_name,s.drug_type,s.drug_spec,s.min_unit,t.creater,s.dose,s.dose_unit,s.min_number,s.max_unit").Joins("left join xt_base_drug as s on s.id = x.drug_id and s.org_id = ? and s.status = 1", orgid).Joins("left join xt_drug_cancel_stock as t on t.id = x.cancel_stock_id and t.org_id = ? and t.status =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Group("x.drug_id").Scan(&info).Error
464
 	} else {
481
 	} else {
468
 	return info, err
485
 	return info, err
469
 }
486
 }
470
 
487
 
471
-func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
488
+func GetDrugCancelOrder(startime int64, endtime int64, orgid int64, orderType int64, manufacturerId int64, keyword string, page int64, limit int64, storehouse_id int64, drug_id int64) (cancel []*models.BloodDrugCancelStockInfo, total int64, err error) {
472
 
489
 
473
 	likeKey := "%" + keyword + "%"
490
 	likeKey := "%" + keyword + "%"
474
 	offset := (page - 1) * limit
491
 	offset := (page - 1) * limit
491
 	if storehouse_id > 0 {
508
 	if storehouse_id > 0 {
492
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
509
 		db = db.Where("x.storehouse_id = ?", storehouse_id)
493
 	}
510
 	}
511
+	if drug_id > 0 {
512
+		db = db.Where("x.drug_id = ?", drug_id)
513
+	}
494
 	if len(keyword) > 0 {
514
 	if len(keyword) > 0 {
495
 		db = db.Joins("left join sgj_xt.xt_drug_cancel_stock as o on o.id = x.cancel_stock_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("o.id")
515
 		db = db.Joins("left join sgj_xt.xt_drug_cancel_stock as o on o.id = x.cancel_stock_id  left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = o.creater").Group("o.id")
496
 
516
 

+ 9 - 0
service/inspection_service.go Parādīt failu

368
 	return inspection, err
368
 	return inspection, err
369
 }
369
 }
370
 
370
 
371
+func GetInspectionGroupOne(org_id int64) (inspection []*models.XtInspectionOne, err error) {
372
+
373
+	//XTReadDB().Model(&inspection).Where("(org_id = ? or org_id = 0) and status=1", patient_id, org_id).Find()
374
+
375
+	err = readDb.Raw("SELECT r.project_name,r.project_id,x.inspect_date FROM xt_inspection as x LEFT JOIN xt_inspection_reference as r on r.project_id = x.project_id WHERE (x.org_id = ? or x.org_id = 0) and x.project_id >0 GROUP BY r.project_id ", org_id).Scan(&inspection).Error
376
+
377
+	return inspection, err
378
+}
379
+
371
 func GetLastInspectionProject(patient_id int64, org_id int64, project_id int64) (models.XtInspection, error) {
380
 func GetLastInspectionProject(patient_id int64, org_id int64, project_id int64) (models.XtInspection, error) {
372
 
381
 
373
 	inspection := models.XtInspection{}
382
 	inspection := models.XtInspection{}

+ 1 - 0
service/mobile_dialysis_service.go Parādīt failu

130
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
130
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
131
 	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
131
 	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
132
 	NewDeviceInformation     *NewDeviceInformation             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"device_information"`
132
 	NewDeviceInformation     *NewDeviceInformation             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"device_information"`
133
+	DialysisSolution         *models.DialysisSolution          `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
133
 }
134
 }
134
 
135
 
135
 func (MDialysisScheduleVM) TableName() string {
136
 func (MDialysisScheduleVM) TableName() string {

+ 37 - 8
service/new_warehouse_service.go Parādīt failu

602
 	return err
602
 	return err
603
 }
603
 }
604
 
604
 
605
+func UpdateDrugWarehouseOutInfoLog(id int64, drug_id int64, tx *gorm.DB) (models.XtDrugWarehouseOutInfoLog, error) {
606
+
607
+	outInfoLog := models.XtDrugWarehouseOutInfoLog{}
608
+
609
+	err := tx.Model(&outInfoLog).Where("warehouse_out_info_id = ? and drug_id = ? and status=1", id, drug_id).Update(map[string]interface{}{"status": 0}).Error
610
+	if err != nil {
611
+		tx.Rollback()
612
+		return outInfoLog, err
613
+	}
614
+	return outInfoLog, err
615
+}
616
+
605
 func AddDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
617
 func AddDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
606
 
618
 
607
 	ut := XTWriteDB().Begin()
619
 	ut := XTWriteDB().Begin()
4496
 
4508
 
4497
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4509
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4498
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4510
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4511
+			fmt.Println("hahhahahahahhaah")
4499
 			var stockMax int64
4512
 			var stockMax int64
4500
 			var stockMin int64
4513
 			var stockMin int64
4501
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4514
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4502
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4515
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4503
 
4516
 
4504
 			ChangeNewMaxNumber(lastWarehouse.ID, stockMax, tx)
4517
 			ChangeNewMaxNumber(lastWarehouse.ID, stockMax, tx)
4518
+
4505
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
4519
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
4506
 
4520
 
4507
 		}
4521
 		}
4508
 	}
4522
 	}
4509
 
4523
 
4510
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4524
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4511
-
4525
+		fmt.Println("ooowowowowowowowowowo")
4512
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4526
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4513
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4527
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4514
 
4528
 
4533
 
4547
 
4534
 	}
4548
 	}
4535
 
4549
 
4536
-	//fmt.Println("stock_number", stock_number)
4537
-	//fmt.Println("deliver_number=============", deliver_number)
4550
+	fmt.Println("stock_number", stock_number)
4551
+	fmt.Println("deliver_number=============", deliver_number)
4538
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4552
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4539
 	if stock_number >= deliver_number {
4553
 	if stock_number >= deliver_number {
4540
 
4554
 
4544
 		maxNumber = deliver_number / drup.MinNumber
4558
 		maxNumber = deliver_number / drup.MinNumber
4545
 		minNumber = deliver_number % drup.MinNumber
4559
 		minNumber = deliver_number % drup.MinNumber
4546
 
4560
 
4561
+		fmt.Println("max_Number=====================", maxNumber)
4562
+		fmt.Println("minNumber=====================", minNumber)
4563
+
4547
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4564
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4548
 			minNumber = maxNumber
4565
 			minNumber = maxNumber
4549
 		}
4566
 		}
4556
 
4573
 
4557
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4574
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4558
 
4575
 
4576
+			fmt.Println("金1")
4577
+
4559
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4578
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4560
 		}
4579
 		}
4561
 
4580
 
4562
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4581
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4563
-
4582
+			fmt.Println("jin2")
4564
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4583
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4565
 		}
4584
 		}
4566
-		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4567
 
4585
 
4586
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4587
+			fmt.Println("jin3")
4568
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4588
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4569
 		}
4589
 		}
4570
 
4590
 
4577
 
4597
 
4578
 		warehouse.Mtime = time.Now().Unix()
4598
 		warehouse.Mtime = time.Now().Unix()
4579
 
4599
 
4580
-		//fmt.Println("hahhahahah", warehouse.StockMinNumber)
4581
-		//fmt.Println("howowowoowow", minNumber)
4600
+		fmt.Println("hahhahahah", warehouse.StockMinNumber)
4601
+		fmt.Println("howowowoowow", minNumber)
4582
 		if warehouse.StockMinNumber < minNumber {
4602
 		if warehouse.StockMinNumber < minNumber {
4583
 
4603
 
4584
-			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
4604
+			if warehouse.MaxUnit != warehouse.MinUnit {
4605
+				//改动的地方
4606
+				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
4607
+			}
4608
+
4609
+			if warehouse.MaxUnit == warehouse.MinUnit {
4610
+				//改动的地方
4611
+				warehouse.StockMaxNumber = warehouse.StockMaxNumber - minNumber
4612
+			}
4613
+
4585
 			if warehouse.MaxUnit != warehouse.MinUnit {
4614
 			if warehouse.MaxUnit != warehouse.MinUnit {
4586
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4615
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4587
 			}
4616
 			}

+ 14 - 5
service/patient_service.go Parādīt failu

83
 
83
 
84
 	}
84
 	}
85
 	if lapseto != 2 && lapseto != 3 {
85
 	if lapseto != 2 && lapseto != 3 {
86
-		if orgID != 10579 && orgID != 10600 && orgID != 10587 {
86
+		if orgID != 10579 && orgID != 10600 && orgID != 10587 && orgID != 10745 {
87
 			err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious,p.patient_type").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
87
 			err = db.Order("p.id desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious,p.patient_type").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
88
 		}
88
 		}
89
 
89
 
90
-		if orgID == 10579 || orgID == 10600 {
90
+		if orgID == 10579 || orgID == 10600 || orgID == 10745 {
91
 			err = db.Order("p.dialysis_no asc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious,p.patient_type").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
91
 			err = db.Order("p.dialysis_no asc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious,p.patient_type").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
92
 		}
92
 		}
93
 
93
 
1921
 	return prescription, err
1921
 	return prescription, err
1922
 }
1922
 }
1923
 
1923
 
1924
+func UpdatePatientDialysisPrscriptionOne(id int64, dewater_amount float64) (models.XtDialysisPrescription, error) {
1925
+
1926
+	prescription := models.XtDialysisPrescription{}
1927
+
1928
+	err := XTWriteDB().Model(&prescription).Where("id = ? and status =1", id).Update(map[string]interface{}{"target_ultrafiltration": dewater_amount}).Error
1929
+
1930
+	return prescription, err
1931
+}
1932
+
1924
 func FindLastDryWeightAdjust(orgID int64, id int64) (weight models.SgjPatientDryweight, err error) {
1933
 func FindLastDryWeightAdjust(orgID int64, id int64) (weight models.SgjPatientDryweight, err error) {
1925
 	err = readDb.Model(&models.SgjPatientDryweight{}).Where("user_org_id=? and patient_id=? and status=1", orgID, id).Order("id desc").First(&weight).Error
1934
 	err = readDb.Model(&models.SgjPatientDryweight{}).Where("user_org_id=? and patient_id=? and status=1", orgID, id).Order("id desc").First(&weight).Error
1926
 	return
1935
 	return
4602
 	if org_id > 0 {
4611
 	if org_id > 0 {
4603
 		db = db.Where("user_org_id = ?", org_id)
4612
 		db = db.Where("user_org_id = ?", org_id)
4604
 	}
4613
 	}
4605
-	err = db.Find(&berfor).Error
4614
+	err = db.Order("assessment_date asc").Find(&berfor).Error
4606
 	return berfor, err
4615
 	return berfor, err
4607
 }
4616
 }
4608
 
4617
 
4632
 
4641
 
4633
 	afterDislysis := models.XtAssessmentAfterDislysis{}
4642
 	afterDislysis := models.XtAssessmentAfterDislysis{}
4634
 
4643
 
4635
-	err := XTReadDB().Where("patient_id = ? and assessment_date <? and user_org_id =? and status=1", patient_id, assessment_date, user_org_id).Order("assessment_date asc").Last(&afterDislysis).Error
4644
+	err := XTReadDB().Where("patient_id = ? and assessment_date = ? and user_org_id =? and status=1", patient_id, assessment_date, user_org_id).Order("assessment_date asc").Last(&afterDislysis).Error
4636
 
4645
 
4637
 	return afterDislysis, err
4646
 	return afterDislysis, err
4638
 }
4647
 }
4684
 func GetPatientLastDryWeightObj(patient_id int64, start_time int64, end_time int64, org_id int64) (models.SgjPatientDryweight, error) {
4693
 func GetPatientLastDryWeightObj(patient_id int64, start_time int64, end_time int64, org_id int64) (models.SgjPatientDryweight, error) {
4685
 
4694
 
4686
 	dryweight := models.SgjPatientDryweight{}
4695
 	dryweight := models.SgjPatientDryweight{}
4687
-	err := XTReadDB().Where("patient_id =? and user_org_id = ? and status=1", patient_id, org_id).Order("id asc").Last(&dryweight).Error
4696
+	err := XTReadDB().Where("patient_id =? and user_org_id = ? and status=1", patient_id, org_id, start_time, end_time).Order("id asc").Last(&dryweight).Error
4688
 	return dryweight, err
4697
 	return dryweight, err
4689
 }
4698
 }
4690
 
4699
 

+ 2 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go Parādīt failu

112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
113
 	BloodDrawing       int64           `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
113
 	BloodDrawing       int64           `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
114
 	DialysisStrainer   string          `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
114
 	DialysisStrainer   string          `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
115
+	ChangeNurse        int64           `gorm:"column:change_nurse" json:"change_nurse" form:"change_nurse"`
115
 }
116
 }
116
 
117
 
117
 func (DialysisOrderVM) TableName() string {
118
 func (DialysisOrderVM) TableName() string {
311
 	LienNecessary                  int64   `gorm:"column:lien_necessary" json:"lien_necessary" form:"lien_necessary"`
312
 	LienNecessary                  int64   `gorm:"column:lien_necessary" json:"lien_necessary" form:"lien_necessary"`
312
 	PathwayFormationTime           int64   `gorm:"column:pathway_formation_time" json:"pathway_formation_time" form:"pathway_formation_time"`
313
 	PathwayFormationTime           int64   `gorm:"column:pathway_formation_time" json:"pathway_formation_time" form:"pathway_formation_time"`
313
 	PunctureNeedleDirection        string  `gorm:"column:puncture_needle_direction" json:"puncture_needle_direction" form:"puncture_needle_direction"`
314
 	PunctureNeedleDirection        string  `gorm:"column:puncture_needle_direction" json:"puncture_needle_direction" form:"puncture_needle_direction"`
315
+	BeforSymptoms                  string  `gorm:"column:befor_symptoms" json:"befor_symptoms" form:"befor_symptoms"`
314
 }
316
 }
315
 
317
 
316
 func (AssessmentBeforeDislysisVM) TableName() string {
318
 func (AssessmentBeforeDislysisVM) TableName() string {

+ 42 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Parādīt failu

234
 //	return
234
 //	return
235
 //}
235
 //}
236
 
236
 
237
+func GetDialysisOrderCountNewTen(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
238
+
239
+	order := models.VmDialysisOrder{}
240
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
241
+	return order, err
242
+}
243
+
244
+func GetDialysisOrderCountTwenty(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
245
+	order := models.VmDialysisOrder{}
246
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1672502400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
247
+	return order, err
248
+}
249
+
237
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
250
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
238
 	order := models.VmDialysisOrder{}
251
 	order := models.VmDialysisOrder{}
239
 	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
252
 	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
253
 	return autoMatic, err
266
 	return autoMatic, err
254
 }
267
 }
255
 
268
 
269
+func GetOutStockTotalCountThree(startime int64, endtime int64, orgid int64, good_id int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
270
+
271
+	db := p_service.XTReadDB()
272
+
273
+	if good_id > 0 {
274
+		err = db.Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and x.`status` = 1 and x.good_id=?)  as b GROUP BY good_id", orgid, startime, endtime, good_id).Scan(&autoMatic).Error
275
+	} else {
276
+		err = db.Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and x.`status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
277
+	}
278
+
279
+	return autoMatic, err
280
+}
281
+
256
 func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
282
 func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
257
 
283
 
258
 	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
284
 	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
266
 	return goodInfo, err
292
 	return goodInfo, err
267
 }
293
 }
268
 
294
 
269
-func GetWarehouseInfoGoodDetailPrintList(orgid int64, startime int64, endtime int64, limit int64, page int64, storehouse_id int64) (info []*models.VmWarehousingInfo, err error) {
295
+func GetWarehouseInfoGoodDetailPrintList(orgid int64, startime int64, endtime int64, limit int64, page int64, storehouse_id int64, good_id int64) (info []*models.VmWarehousingInfo, err error) {
270
 	//offset := (page - 1) * limit
296
 	//offset := (page - 1) * limit
271
 	db := p_service.XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
297
 	db := p_service.XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
272
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
298
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
273
 	fmt.Println(table)
299
 	fmt.Println(table)
300
+
301
+	if good_id > 0 {
302
+		db = db.Where("x.good_id = ?", good_id)
303
+	}
304
+
274
 	if orgid > 0 {
305
 	if orgid > 0 {
275
 		db = db.Where("x.org_id = ?", orgid)
306
 		db = db.Where("x.org_id = ?", orgid)
276
 	}
307
 	}
309
 
340
 
310
 }
341
 }
311
 
342
 
312
-func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (out []*models.SgjWarehouseOutInfo, err error) {
343
+func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64, good_id int64, order_way int64) (out []*models.SgjWarehouseOutInfo, err error) {
313
 
344
 
314
 	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
345
 	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
315
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
346
 	table := p_service.XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
317
 	tableOne := p_service.XTReadDB().Table("xt_warehouse_info as p").Where("p.status = 1")
348
 	tableOne := p_service.XTReadDB().Table("xt_warehouse_info as p").Where("p.status = 1")
318
 	fmt.Println(table)
349
 	fmt.Println(table)
319
 	fmt.Println("tableOne", tableOne)
350
 	fmt.Println("tableOne", tableOne)
351
+	if good_id > 0 {
352
+		db = db.Where("x.good_id = ?", good_id)
353
+	}
354
+	if order_way == 1 {
355
+		db = db.Where("x.is_sys!=1")
356
+	}
357
+	if order_way == 2 {
358
+		db = db.Where("x.is_sys==1")
359
+	}
320
 	if orgid > 0 {
360
 	if orgid > 0 {
321
 		db = db.Where("x.org_id = ?", orgid)
361
 		db = db.Where("x.org_id = ?", orgid)
322
 	}
362
 	}

+ 9 - 0
service/schedule_service.go Parādīt failu

235
 	return
235
 	return
236
 }
236
 }
237
 
237
 
238
+func GetDialysisPrescriptionByRecord(orgID int64, patient_id int64, record_date int64) (models.DialysisPrescription, error) {
239
+
240
+	prescription := models.DialysisPrescription{}
241
+
242
+	err = readDb.Where("user_org_id = ? and patient_id = ? and record_date = ? and status=1", orgID, patient_id, record_date).Find(&prescription).Error
243
+
244
+	return prescription, err
245
+}
246
+
238
 func GetDayScheduleByOrder(orgID, start, bed_id int64, schedule_type int64) (schedule models.DialysisOrder, err error) {
247
 func GetDayScheduleByOrder(orgID, start, bed_id int64, schedule_type int64) (schedule models.DialysisOrder, err error) {
239
 	err = readDb.Model(&models.DialysisOrder{}).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).First(&schedule).Error
248
 	err = readDb.Model(&models.DialysisOrder{}).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).First(&schedule).Error
240
 	return
249
 	return

+ 7 - 0
service/self_drug_service.go Parādīt failu

138
 	return drug, err
138
 	return drug, err
139
 }
139
 }
140
 
140
 
141
+func GetLastDrugWarehouseInfoList(drug_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
142
+
143
+	err = XTReadDB().Where("drug_id = ? and status=1 and (stock_max_number > 0 or stock_min_number>0) and is_check =1", drug_id).Find(&info).Error
144
+
145
+	return info, err
146
+}
147
+
141
 func GetNewBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
148
 func GetNewBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
142
 	drug := models.XtBaseDrug{}
149
 	drug := models.XtBaseDrug{}
143
 	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
150
 	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error

+ 15 - 0
service/sign_service.go Parādīt failu

2385
 
2385
 
2386
 	return err
2386
 	return err
2387
 }
2387
 }
2388
+
2389
+func GetDoctorAdviceListByUserOrgId(user_org_id int64, advice_date int64) (advice []*models.DoctorAdvice, err error) {
2390
+
2391
+	err = XTReadDB().Where("user_org_id  = ? and advice_date = ? and status=1", user_org_id, advice_date).Find(&advice).Error
2392
+
2393
+	return advice, err
2394
+}
2395
+
2396
+func GetSelfDrugWarehouseOutInfo(patient_id int64, drug_id int64, advice_Date int64) (models.XtSelfDrugWarehouseOutInfo, error) {
2397
+
2398
+	outInfo := models.XtSelfDrugWarehouseOutInfo{}
2399
+	err := XTReadDB().Where("patient_id = ? and drug_id = ? and sys_record_time = ? and status=1", patient_id, drug_id, advice_Date).Find(&outInfo).Error
2400
+
2401
+	return outInfo, err
2402
+}

+ 6 - 6
service/statistis_qc_service.go Parādīt failu

718
         SELECT
718
         SELECT
719
             CASE
719
             CASE
720
                 WHEN ABS(TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0))) <= 15 THEN '达到透析处方时间'
720
                 WHEN ABS(TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0))) <= 15 THEN '达到透析处方时间'
721
-                WHEN TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15 THEN '超出处方时间'
722
-                ELSE '未达到处方时间'
721
+                WHEN TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15 THEN '未达到处方时间'
722
+                ELSE '超出处方时间'
723
             END AS dialysis_status,
723
             END AS dialysis_status,
724
             COUNT(*) AS count
724
             COUNT(*) AS count
725
         FROM
725
         FROM
845
 	   JOIN
845
 	   JOIN
846
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
846
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
847
 	   WHERE
847
 	   WHERE
848
-	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15
848
+	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15
849
 	`
849
 	`
850
 		readDb.Table("xt_dialysis_order o").
850
 		readDb.Table("xt_dialysis_order o").
851
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
851
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
852
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
852
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
853
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
853
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
854
-			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < 0", org_id, start_time, end_time).Count(&total)
854
+			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15", org_id, start_time, end_time).Count(&total)
855
 
855
 
856
 	} else if mode == 3 {
856
 	} else if mode == 3 {
857
 		query = `
857
 		query = `
874
 	   JOIN
874
 	   JOIN
875
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
875
 	       xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?
876
 	   WHERE
876
 	   WHERE
877
-	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15
877
+	       o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < -15
878
 	`
878
 	`
879
 		readDb.Table("xt_dialysis_order o").
879
 		readDb.Table("xt_dialysis_order o").
880
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
880
 			Joins("JOIN xt_patients pp ON o.patient_id = pp.id AND pp.user_org_id = ?", org_id).
881
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
881
 			Joins("JOIN xt_dialysis_prescription p ON o.dialysis_date = p.record_date AND o.patient_id = p.patient_id AND p.user_org_id = ?", org_id).
882
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
882
 			Joins("JOIN xt_assessment_after_dislysis a ON o.dialysis_date = a.assessment_date AND o.patient_id = a.patient_id AND a.user_org_id = ?", org_id).
883
-			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) > 15", org_id, start_time, end_time).Count(&total)
883
+			Where("o.stage = 2 AND o.user_org_id = ? AND o.dialysis_date >= ? AND o.dialysis_date <= ? and TIMESTAMPDIFF(MINUTE, MAKETIME(p.dialysis_duration_hour, p.dialysis_duration_minute, 0), MAKETIME(a.actual_treatment_hour, a.actual_treatment_minute, 0)) < 0", org_id, start_time, end_time).Count(&total)
884
 
884
 
885
 	}
885
 	}
886
 
886
 

+ 120 - 7
service/stock_service.go Parādīt failu

933
 	}
933
 	}
934
 	return err
934
 	return err
935
 }
935
 }
936
+func CreateDrugOutInfoLog(log models.XtDrugWarehouseOutInfoLog, tx *gorm.DB) error {
937
+
938
+	err := tx.Create(&log).Error
939
+	if err != nil {
940
+		tx.Rollback()
941
+		return err
942
+	}
943
+	return err
944
+}
936
 
945
 
937
 func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64, id int64) (models.DrugAutomaticReduceDetail, error) {
946
 func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64, id int64) (models.DrugAutomaticReduceDetail, error) {
938
 	detail := models.DrugAutomaticReduceDetail{}
947
 	detail := models.DrugAutomaticReduceDetail{}
982
 	return err
991
 	return err
983
 }
992
 }
984
 
993
 
994
+func CreateInfoLog(log models.XtDrugWarehouseInfoLog, tx *gorm.DB) error {
995
+	err := tx.Create(&log).Error
996
+	if err != nil {
997
+		tx.Rollback()
998
+		return err
999
+	}
1000
+
1001
+	return err
1002
+}
1003
+
985
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
1004
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
986
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
1005
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
987
 
1006
 
3427
 	Types            int64   `gorm:"types" json:"types"`
3446
 	Types            int64   `gorm:"types" json:"types"`
3428
 }
3447
 }
3429
 
3448
 
3430
-func FindStockInDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehousingInfo, total int64, err error) {
3449
+func FindStockInDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64) (list []*models.WarehousingInfo, total int64, err error) {
3431
 
3450
 
3432
 	db := readDb.Model(&models.WarehousingInfo{})
3451
 	db := readDb.Model(&models.WarehousingInfo{})
3433
 	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1 AND xt_warehouse_info.is_check = 1", orgId)
3452
 	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1 AND xt_warehouse_info.is_check = 1", orgId)
3453
+
3454
+	if good_id > 0 {
3455
+
3456
+		db = db.Where("xt_warehouse_info.good_id = ?", good_id)
3457
+	}
3434
 	if len(keywords) > 0 {
3458
 	if len(keywords) > 0 {
3435
 		likeKey := "%" + keywords + "%"
3459
 		likeKey := "%" + keywords + "%"
3436
 		//db = db.Joins("join xt_warehouse on xt_warehouse.id = xt_warehouse_info.warehousing_id AND ")
3460
 		//db = db.Joins("join xt_warehouse on xt_warehouse.id = xt_warehouse_info.warehousing_id AND ")
3463
 	return
3487
 	return
3464
 }
3488
 }
3465
 
3489
 
3466
-func GetStockInDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (err error, totalPrice float64) {
3490
+func GetStockInDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64) (err error, totalPrice float64) {
3467
 	db := readDb.Model(&models.WarehousingInfo{})
3491
 	db := readDb.Model(&models.WarehousingInfo{})
3468
 	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1", orgId)
3492
 	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1", orgId)
3493
+	if good_id > 0 {
3494
+		db = db.Where("good_id = ?", good_id)
3495
+	}
3469
 	if len(keywords) > 0 {
3496
 	if len(keywords) > 0 {
3470
 		likeKey := "%" + keywords + "%"
3497
 		likeKey := "%" + keywords + "%"
3471
 		//db = db.Joins("join xt_warehouse on xt_warehouse.id = xt_warehouse_info.warehousing_id AND ")
3498
 		//db = db.Joins("join xt_warehouse on xt_warehouse.id = xt_warehouse_info.warehousing_id AND ")
3504
 	return res
3531
 	return res
3505
 }
3532
 }
3506
 
3533
 
3507
-func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehouseOutInfo, total int64, err error) {
3534
+func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64, order_way int64) (list []*models.WarehouseOutInfo, total int64, err error) {
3508
 
3535
 
3509
 	if orgId == 9671 {
3536
 	if orgId == 9671 {
3510
 		db := readDb.Model(&models.WarehouseOutInfo{})
3537
 		db := readDb.Model(&models.WarehouseOutInfo{})
3543
 	} else {
3570
 	} else {
3544
 		db := readDb.Model(&models.WarehouseOutInfo{})
3571
 		db := readDb.Model(&models.WarehouseOutInfo{})
3545
 		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.count <> 0 ", orgId)
3572
 		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.count <> 0 ", orgId)
3546
-
3573
+		if good_id > 0 {
3574
+			db = db.Where("good_id = ?", good_id)
3575
+		}
3576
+		if order_way == 1 {
3577
+			db = db.Where("xt_warehouse_out_info.is_sys =0")
3578
+		}
3579
+		if order_way == 2 {
3580
+			db = db.Where("xt_warehouse_out_info.is_sys !=0")
3581
+		}
3547
 		if len(keywords) > 0 {
3582
 		if len(keywords) > 0 {
3548
 			likeKey := "%" + keywords + "%"
3583
 			likeKey := "%" + keywords + "%"
3549
 			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3584
 			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3578
 
3613
 
3579
 }
3614
 }
3580
 
3615
 
3581
-func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (err error, totalPrice float64) {
3616
+func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64, order_way int64) (err error, totalPrice float64) {
3582
 	db := readDb.Model(&models.WarehouseOutInfo{})
3617
 	db := readDb.Model(&models.WarehouseOutInfo{})
3583
 	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.count > 0", orgId)
3618
 	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.count > 0", orgId)
3584
 
3619
 
3593
 		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and   xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3628
 		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and   xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3594
 	}
3629
 	}
3595
 
3630
 
3631
+	if good_id > 0 {
3632
+		db = db.Where("xt_warehouse_out_info.good_id = ?", good_id)
3633
+	}
3634
+
3635
+	if order_way == 1 {
3636
+		db = db.Where("xt_warehouse_out_info.is_sys = ?", 0)
3637
+	}
3638
+
3639
+	if order_way == 2 {
3640
+		db = db.Where("xt_warehouse_out_info.is_sys != ?", 0)
3641
+	}
3642
+
3596
 	if manufacturer > 0 {
3643
 	if manufacturer > 0 {
3597
 		db = db.Joins("join xt_warehouse_out as wa on wa.id = xt_warehouse_out_info.warehouse_out_id AND wa.manufacturer =?", manufacturer)
3644
 		db = db.Joins("join xt_warehouse_out as wa on wa.id = xt_warehouse_out_info.warehouse_out_id AND wa.manufacturer =?", manufacturer)
3598
 	}
3645
 	}
3651
 	return
3698
 	return
3652
 }
3699
 }
3653
 
3700
 
3654
-func FindeCancelGroup(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.CancelStockInfo, err error) {
3701
+func FindeCancelGroup(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64) (list []*models.CancelStockInfo, err error) {
3655
 	db := readDb.Model(&models.CancelStockInfo{})
3702
 	db := readDb.Model(&models.CancelStockInfo{})
3656
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
3703
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
3657
 	if len(keywords) > 0 {
3704
 	if len(keywords) > 0 {
3676
 	if storehouse_id > 0 {
3723
 	if storehouse_id > 0 {
3677
 		db = db.Where("xt_cancel_stock_info.storehouse_id = ?", order_type)
3724
 		db = db.Where("xt_cancel_stock_info.storehouse_id = ?", order_type)
3678
 	}
3725
 	}
3726
+	if good_id > 0 {
3727
+		db = db.Where("xt_cancel_stock_info.good_id = ?", good_id)
3728
+	}
3679
 
3729
 
3680
 	db = db.Preload("CancelStock", "status = 1 AND org_id = ?", orgId)
3730
 	db = db.Preload("CancelStock", "status = 1 AND org_id = ?", orgId)
3681
 	db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
3731
 	db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
3684
 	return
3734
 	return
3685
 }
3735
 }
3686
 
3736
 
3687
-func FindCancelDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.CancelStockInfo, total int64, err error) {
3737
+func FindCancelDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64, good_id int64) (list []*models.CancelStockInfo, total int64, err error) {
3688
 	db := readDb.Model(&models.CancelStockInfo{})
3738
 	db := readDb.Model(&models.CancelStockInfo{})
3689
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
3739
 	db = db.Where("xt_cancel_stock_info.org_id = ? AND xt_cancel_stock_info.status = 1", orgId)
3690
 	if len(keywords) > 0 {
3740
 	if len(keywords) > 0 {
3708
 	if storehouse_id > 0 {
3758
 	if storehouse_id > 0 {
3709
 		db = db.Where("xt_cancel_stock_info.storehouse_id = ?", storehouse_id)
3759
 		db = db.Where("xt_cancel_stock_info.storehouse_id = ?", storehouse_id)
3710
 	}
3760
 	}
3761
+	if good_id > 0 {
3762
+		db = db.Where("xt_cancel_stock_info.good_id =?", good_id)
3763
+	}
3711
 
3764
 
3712
 	db = db.Preload("CancelStock", "status = 1 AND org_id = ?", orgId)
3765
 	db = db.Preload("CancelStock", "status = 1 AND org_id = ?", orgId)
3713
 	db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
3766
 	db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
5925
 	return err
5978
 	return err
5926
 }
5979
 }
5927
 
5980
 
5981
+func CreateOutInfoLog(log models.XtGoodWarehouseOutInfoLog, tx *gorm.DB) error {
5982
+
5983
+	err := tx.Create(&log).Error
5984
+	if err != nil {
5985
+		tx.Rollback()
5986
+		return err
5987
+	}
5988
+	return err
5989
+}
5990
+
5991
+func CreateGoodWarehouseInfoLog(log models.XtGoodWarehouseInfoLog, tx *gorm.DB) error {
5992
+
5993
+	err := tx.Create(&log).Error
5994
+	if err != nil {
5995
+		tx.Rollback()
5996
+		return err
5997
+	}
5998
+	return err
5999
+}
6000
+
5928
 func CreateStockFlowSix(flow *models.VmStockFlow) error {
6001
 func CreateStockFlowSix(flow *models.VmStockFlow) error {
5929
 
6002
 
5930
 	err := XTWriteDB().Create(&flow).Error
6003
 	err := XTWriteDB().Create(&flow).Error
8510
 
8583
 
8511
 }
8584
 }
8512
 
8585
 
8586
+func ModifyGoodOutInfoLog(good_id int64, id int64, tx *gorm.DB) (models.XtGoodWarehouseOutInfoLog, error) {
8587
+
8588
+	outInfoLog := models.XtGoodWarehouseOutInfoLog{}
8589
+
8590
+	err := tx.Model(&outInfoLog).Where("good_id = ? and warehouse_out_info_id = ?", good_id, id).Updates(map[string]interface{}{"status": 0}).Error
8591
+
8592
+	if err != nil {
8593
+		tx.Rollback()
8594
+		return outInfoLog, err
8595
+	}
8596
+	return outInfoLog, err
8597
+
8598
+}
8599
+
8513
 func UpdateaNewGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64, tx *gorm.DB) error {
8600
 func UpdateaNewGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64, tx *gorm.DB) error {
8514
 
8601
 
8515
 	err := tx.Model(&models.WarehousingInfo{}).Where("good_id = ?  and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
8602
 	err := tx.Model(&models.WarehousingInfo{}).Where("good_id = ?  and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
8569
 		tx.Rollback()
8656
 		tx.Rollback()
8570
 		return err
8657
 		return err
8571
 	}
8658
 	}
8659
+
8572
 	return err
8660
 	return err
8573
 }
8661
 }
8574
 
8662
 
8926
 		tx.Rollback()
9014
 		tx.Rollback()
8927
 		return err
9015
 		return err
8928
 	}
9016
 	}
9017
+
9018
+	err = tx.Model(models.XtDrugWarehouseInfoLog{}).Where("warehouse_info_id = ? and status=1", id).Update(map[string]interface{}{"status": 0}).Error
9019
+	if err != nil {
9020
+		tx.Rollback()
9021
+		return err
9022
+	}
8929
 	return err
9023
 	return err
8930
 }
9024
 }
8931
 
9025
 
9936
 	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
10030
 	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
9937
 	return config, nil
10031
 	return config, nil
9938
 }
10032
 }
10033
+func GetGoodWareHouseOutInfoByGood(good_id int64, sys_record_time int64, user_org_id int64) (info []*models.WarehouseOutInfo, err error) {
10034
+
10035
+	err = XTReadDB().Where("good_id= ? and sys_record_time = ? and org_id = ? and status=1", good_id, sys_record_time, user_org_id).Find(&info).Error
10036
+
10037
+	return info, err
10038
+}
9939
 
10039
 
9940
 func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty, error) {
10040
 func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty, error) {
9941
 
10041
 
9944
 	return info, err
10044
 	return info, err
9945
 }
10045
 }
9946
 
10046
 
10047
+func GetGoodWarehouseInfoByGoodList(good_id int64) (info []*models.WarehousingInfo, err error) {
10048
+
10049
+	err = XTReadDB().Where("good_id = ? and status =1 and stock_count>0 and is_check = 1", good_id).Find(&info).Error
10050
+
10051
+	return info, err
10052
+}
10053
+
9947
 func GetAllWarehouseInfo(good_id int64, user_org_id int64) (info []*models.WarehousingInfo, err error) {
10054
 func GetAllWarehouseInfo(good_id int64, user_org_id int64) (info []*models.WarehousingInfo, err error) {
9948
 
10055
 
9949
 	err = XTReadDB().Where("good_id = ? and user_org_id =? and status=1 and is_check =1", good_id, user_org_id).Find(&info).Error
10056
 	err = XTReadDB().Where("good_id = ? and user_org_id =? and status=1 and is_check =1", good_id, user_org_id).Find(&info).Error
10441
 			return err
10548
 			return err
10442
 		}
10549
 		}
10443
 
10550
 
10551
+		err = tx.Model(models.XtGoodWarehouseInfoLog{}).Where("warehouse_info_id = ? and status=1", item.ID).Update(map[string]interface{}{"status": 0}).Error
10552
+		if err != nil {
10553
+			tx.Rollback()
10554
+			return err
10555
+		}
10556
+
10444
 	}
10557
 	}
10445
 	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
10558
 	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", warehousing_info_id).Update(map[string]interface{}{"is_check": 2}).Error
10446
 	if err != nil {
10559
 	if err != nil {

+ 275 - 1
service/warhouse_service.go Parādīt failu

10910
 		//创建出库流水
10910
 		//创建出库流水
10911
 		CreateNewStockFlowOne(stockFlow, tx)
10911
 		CreateNewStockFlowOne(stockFlow, tx)
10912
 
10912
 
10913
+		outInfoLog := models.XtGoodWarehouseOutInfoLog{
10914
+
10915
+			UserOrgId:          goods.OrgId,
10916
+			GoodId:             goods.GoodId,
10917
+			RecordDate:         record_time,
10918
+			WarehouseOutInfoId: goods.ID,
10919
+			Status:             1,
10920
+			Ctime:              time.Now().Unix(),
10921
+			Mtime:              time.Now().Unix(),
10922
+			BatchNumberId:      warehouse.ID,
10923
+		}
10924
+
10925
+		CreateOutInfoLog(outInfoLog, tx)
10926
+
10913
 		//添加入库ID
10927
 		//添加入库ID
10914
 		UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, goods.OrgId, sum_count, tx)
10928
 		UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, goods.OrgId, sum_count, tx)
10915
 
10929
 
10975
 		//创建出库流水
10989
 		//创建出库流水
10976
 		CreateNewStockFlowOne(stockFlow, tx)
10990
 		CreateNewStockFlowOne(stockFlow, tx)
10977
 
10991
 
10992
+		outInfoLog := models.XtGoodWarehouseOutInfoLog{
10993
+			UserOrgId:          goods.OrgId,
10994
+			GoodId:             goods.GoodId,
10995
+			RecordDate:         record_time,
10996
+			WarehouseOutInfoId: goods.ID,
10997
+			Status:             1,
10998
+			Ctime:              time.Now().Unix(),
10999
+			Mtime:              time.Now().Unix(),
11000
+			BatchNumberId:      warehouse.ID,
11001
+		}
11002
+
11003
+		CreateOutInfoLog(outInfoLog, tx)
11004
+
10978
 		UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, goods.OrgId, sum_count, tx)
11005
 		UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, goods.OrgId, sum_count, tx)
10979
 
11006
 
10980
 		//更新出库数量
11007
 		//更新出库数量
11205
 			drugflow.Price = advice.Price
11232
 			drugflow.Price = advice.Price
11206
 		}
11233
 		}
11207
 
11234
 
11208
-		CreateDrugFlowOne(drugflow)
11235
+		CreateNewDrugFlowOne(drugflow, tx)
11236
+
11237
+		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11238
+			UserOrgId:          advice.OrgId,
11239
+			DrugId:             advice.DrugId,
11240
+			WarehouseOutInfoId: drugWareInfo.ID,
11241
+			RecordDate:         advice.SysRecordTime,
11242
+			Status:             1,
11243
+			Ctime:              time.Now().Unix(),
11244
+			Mtime:              time.Now().Unix(),
11245
+			BatchNumberId:      warehouse.ID,
11246
+		}
11247
+
11248
+		CreateDrugOutInfoLog(outInfoLog, tx)
11209
 
11249
 
11210
 		//更新出库id
11250
 		//更新出库id
11211
 		UpdateNewDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price, tx)
11251
 		UpdateNewDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price, tx)
11275
 		}
11315
 		}
11276
 
11316
 
11277
 		CreateNewDrugFlowOne(drugflow, tx)
11317
 		CreateNewDrugFlowOne(drugflow, tx)
11318
+
11319
+		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11320
+			UserOrgId:          advice.OrgId,
11321
+			DrugId:             advice.DrugId,
11322
+			WarehouseOutInfoId: drugWareInfo.ID,
11323
+			RecordDate:         advice.SysRecordTime,
11324
+			Status:             1,
11325
+			Ctime:              time.Now().Unix(),
11326
+			Mtime:              time.Now().Unix(),
11327
+			BatchNumberId:      warehouse.ID,
11328
+		}
11329
+		CreateDrugOutInfoLog(outInfoLog, tx)
11278
 		//更新出库id
11330
 		//更新出库id
11279
 		UpdateNewDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price, tx)
11331
 		UpdateNewDrugWarehouseOutInfo(advice.ID, warehouse.ID, advice.OrgId, over_count, drug_price, tx)
11280
 		// 出库完成后,要将该批次库存清零
11332
 		// 出库完成后,要将该批次库存清零
11288
 
11340
 
11289
 	return
11341
 	return
11290
 }
11342
 }
11343
+
11344
+// 药品手动出库 递归方式
11345
+func AutoNewSelfDrugDeliverInfoFourtyTwo(orgID int64, prescribingNumber int64, warehouseout *models.XtSelfDrugWarehouseOut, drup *models.BaseDrugLib, advice *models.XtSelfDrugWarehouseOutInfo, unit string, tx *gorm.DB) (err error) {
11346
+
11347
+	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
11348
+	var deliver_number int64 = 0
11349
+
11350
+	var drug_price float64
11351
+	if advice.CountUnit == drup.MaxUnit {
11352
+		deliver_number = prescribingNumber * drup.MinNumber
11353
+
11354
+	} else {
11355
+		deliver_number = prescribingNumber
11356
+
11357
+	}
11358
+	if advice.CountUnit == drup.MaxUnit {
11359
+		drug_price = drup.RetailPrice
11360
+	}
11361
+	fmt.Println(drug_price)
11362
+
11363
+	if advice.CountUnit == drup.MinUnit {
11364
+		drug_price = drup.MinPrice
11365
+	}
11366
+
11367
+	if advice.CountUnit != drup.MaxUnit || advice.CountUnit != drup.MinUnit {
11368
+		drug_price = drup.RetailPrice
11369
+	}
11370
+
11371
+	// 根据先进先出原则,查询最先入库的批次,进行出库
11372
+	// 如果没有对应的库存,则报错
11373
+	lastWarehouse, _ := FindSelfLastDrugWarehousingInfoByID(advice.DrugId, advice.PatientId, tx)
11374
+
11375
+	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11376
+		if lastWarehouse.StockMinNumber >= drup.MinNumber {
11377
+			var stockMax int64
11378
+			var stockMin int64
11379
+			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
11380
+			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
11381
+
11382
+			ChangeSelfMaxNumber(lastWarehouse.ID, stockMax, tx)
11383
+			UpdateSelfMinNumber(lastWarehouse.ID, stockMin, tx)
11384
+
11385
+		}
11386
+	}
11387
+
11388
+	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11389
+
11390
+		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
11391
+		ChangeSelfMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
11392
+
11393
+	}
11394
+
11395
+	warehouse, err := FindSelfLastDrugWarehousingInfoByID(advice.DrugId, advice.PatientId, tx)
11396
+
11397
+	var maxNumber int64 = 0
11398
+	var minNumber int64 = 0
11399
+
11400
+	maxNumber = deliver_number / drup.MinNumber
11401
+	minNumber = deliver_number % drup.MinNumber
11402
+
11403
+	if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
11404
+		minNumber = maxNumber
11405
+	}
11406
+
11407
+	if drup.MaxUnit != drup.MinUnit {
11408
+		if warehouse.StockMaxNumber < maxNumber && warehouse.StockMinNumber < minNumber {
11409
+			return errors.New("库存数量不足")
11410
+		}
11411
+	}
11412
+
11413
+	if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11414
+
11415
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
11416
+	}
11417
+
11418
+	if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11419
+
11420
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11421
+	}
11422
+	if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
11423
+
11424
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11425
+	}
11426
+
11427
+	if warehouse.StockMaxNumber < 0 {
11428
+		warehouse.StockMaxNumber = 0
11429
+	}
11430
+	if warehouse.StockMinNumber < 0 {
11431
+		warehouse.StockMinNumber = 0
11432
+	}
11433
+
11434
+	warehouse.Mtime = time.Now().Unix()
11435
+
11436
+	if warehouse.StockMinNumber < minNumber {
11437
+
11438
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11439
+		if warehouse.MaxUnit != warehouse.MinUnit {
11440
+			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
11441
+		}
11442
+		if minNumber == 2 && warehouse.MaxUnit == warehouse.MinUnit && warehouse.StockMinNumber == 0 {
11443
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11444
+		}
11445
+	} else {
11446
+
11447
+		if minNumber > 0 {
11448
+			if (warehouse.StockMinNumber - minNumber) >= 0 {
11449
+				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
11450
+			}
11451
+
11452
+		}
11453
+
11454
+		if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
11455
+
11456
+			if warehouse.StockMinNumber > 0 {
11457
+				if warehouse.StockMinNumber-deliver_number >= 0 {
11458
+					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11459
+				}
11460
+
11461
+			}
11462
+
11463
+		}
11464
+
11465
+	}
11466
+
11467
+	if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
11468
+		if (warehouse.StockMinNumber - deliver_number) >= 0 {
11469
+			warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11470
+		}
11471
+
11472
+	}
11473
+
11474
+	if drup.MaxUnit != drup.MinUnit {
11475
+		if warehouse.StockMaxNumber < 0 && warehouse.StockMinNumber < 0 {
11476
+			return errors.New("库存数量不足")
11477
+		}
11478
+	}
11479
+	if warehouse.StockMinNumber <= 0 {
11480
+		warehouse.StockMinNumber = 0
11481
+	}
11482
+
11483
+	errThree := UpDateSelfDrugWarehouseInfoByStock(&warehouse, tx)
11484
+
11485
+	if errThree != nil {
11486
+		return errors.New("扣减库存失败")
11487
+	}
11488
+
11489
+	//查询该药品剩余库存
11490
+	infolist, _ := FindSelfDrugWarehouseInfoFlushCount(advice.DrugId, advice.OrgId, tx)
11491
+	var over_count int64
11492
+	for _, its := range infolist {
11493
+		if its.MaxUnit == drup.MaxUnit {
11494
+			its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
11495
+		}
11496
+		over_count += its.StockMaxNumber + its.StockMinNumber
11497
+	}
11498
+
11499
+	//更新出库id
11500
+	//查询今日该药品该患者是否有出库数据
11501
+	lastDrugOutInfo, _ := GetSelfNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.SysRecordTime, advice.OrgId, advice.AdviceId, warehouse.ID, tx)
11502
+
11503
+	if lastDrugOutInfo.ID == 0 {
11504
+		advice.WarehouseInfoId = lastWarehouse.ID
11505
+		AddSelfSigleDrugWarehouseOutInfo(advice, tx)
11506
+	}
11507
+	if lastDrugOutInfo.ID > 0 {
11508
+		advice.WarehouseInfoId = lastWarehouse.ID
11509
+		//删除在新增
11510
+		UpdateSelfDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID, tx)
11511
+
11512
+		AddSelfSigleDrugWarehouseOutInfo(advice, tx)
11513
+
11514
+	}
11515
+
11516
+	drugWareInfo, _ := GetSelfLastWarehouseOutInfoById(advice.DrugId, tx)
11517
+	drugflow := models.XtSelfDrugFlow{
11518
+		WarehouseOutId:          warehouseout.ID,
11519
+		WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
11520
+		DrugId:                  advice.DrugId,
11521
+		Number:                  warehouse.Number,
11522
+		ProductDate:             advice.ProductDate,
11523
+		ExpireDate:              advice.ExpiryDate,
11524
+		Count:                   deliver_number,
11525
+		Price:                   warehouse.RetailPrice,
11526
+		Status:                  1,
11527
+		Ctime:                   advice.SysRecordTime,
11528
+		Mtime:                   time.Now().Unix(),
11529
+		UserOrgId:               advice.OrgId,
11530
+		Manufacturer:            advice.Manufacturer,
11531
+		Dealer:                  advice.Dealer,
11532
+		BatchNumber:             warehouse.BatchNumber,
11533
+		MaxUnit:                 drup.MinUnit,
11534
+		ConsumableType:          3,
11535
+		IsEdit:                  1,
11536
+		Creator:                 0,
11537
+		IsSys:                   0,
11538
+		WarehouseOutDetailId:    drugWareInfo.ID,
11539
+		AdviceId:                advice.ID,
11540
+		SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11541
+		StorehouseId:            advice.StorehouseId,
11542
+		AdminUserId:             advice.AdminUserId,
11543
+		LastPrice:               warehouse.Price,
11544
+		StockCount:              advice.StockCount,
11545
+		WarehousingDetailId:     warehouse.ID,
11546
+		OverCount:               over_count,
11547
+		RetailPrice:             drug_price, //手动出库出库价格
11548
+		WarehousingId:           warehouse.ID,
11549
+		SystemTime:              advice.SysRecordTime,
11550
+		PatientId:               advice.PatientId,
11551
+		Remark:                  advice.Remark,
11552
+		OperateTime:             time.Now().Unix(),
11553
+	}
11554
+	if warehouse.RetailPrice == 0 {
11555
+		drugflow.Price = advice.Price
11556
+	}
11557
+
11558
+	CreateSelfDrugFlowOne(drugflow, tx)
11559
+
11560
+	//出库数量相加
11561
+	AddSelfDrugCount(advice.DrugId, orgID, advice.PatientId, drugflow.Count, tx)
11562
+
11563
+	return
11564
+}