Ver código fonte

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

csx 2 anos atrás
pai
commit
809cc61863
50 arquivos alterados com 4015 adições e 954 exclusões
  1. 352 40
      controllers/dialysis_api_controller.go
  2. 73 3
      controllers/dialysis_record_api_controller.go
  3. 4 2
      controllers/doctors_api_controller.go
  4. 153 116
      controllers/drug_stock_api_contorller.go
  5. 3 3
      controllers/gobal_config_api_controller.go
  6. 317 165
      controllers/his_api_controller.go
  7. 8 0
      controllers/his_config_api_controller.go
  8. 14 5
      controllers/mobile_api_controllers/check_weight_api_controller.go
  9. 535 111
      controllers/mobile_api_controllers/dialysis_api_controller.go
  10. 3 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  11. 79 18
      controllers/mobile_api_controllers/patient_api_controller.go
  12. 35 7
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  13. 0 1
      controllers/new_mobile_api_controllers/new_manage_api_controller.go
  14. 132 2
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  15. 8 0
      controllers/new_mobile_api_controllers/staff_schedule_api_router.go
  16. 33 14
      controllers/patient_api_controller.go
  17. 10 2
      controllers/secondary_order_api_contorller.go
  18. 405 72
      controllers/self_drug_api_congtroller.go
  19. 86 56
      controllers/stock_in_api_controller.go
  20. 57 6
      controllers/supply_order_api_contorller.go
  21. 4 1
      enums/error_code.go
  22. 23 1
      models/device_models.go
  23. 42 0
      models/dialysis.go
  24. 8 8
      models/drug.go
  25. 55 53
      models/drug_stock.go
  26. 110 15
      models/good_models.go
  27. 1 0
      models/his_models.go
  28. 255 27
      models/new_stock_models.go
  29. 39 6
      models/patient_models.go
  30. 128 16
      models/schedule_models.go
  31. 39 0
      service/device_service.go
  32. 68 4
      service/dialysis_service.go
  33. 241 14
      service/dialysis_solution_service.go
  34. 18 2
      service/gobal_config_service.go
  35. 1 1
      service/his_project_service.go
  36. 8 0
      service/his_service.go
  37. 37 5
      service/manage_center_service.go
  38. 21 8
      service/mobile_dialysis_service.go
  39. 22 1
      service/new_stock_service.go
  40. 136 31
      service/new_warehouse_service.go
  41. 19 1
      service/patient_schedule_template_service.go
  42. 11 3
      service/patient_service.go
  43. 3 3
      service/patientmanage_service.go
  44. 19 6
      service/pharmacy_service.go
  45. 2 2
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  46. 14 0
      service/schedule_service.go
  47. 154 34
      service/self_drug_service.go
  48. 61 9
      service/stock_service.go
  49. 20 0
      service/user_service.go
  50. 149 80
      service/warhouse_service.go

+ 352 - 40
controllers/dialysis_api_controller.go Ver arquivo

81
 	beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
81
 	beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
82
 
82
 
83
 	beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
83
 	beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
84
+
85
+	beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
86
+
87
+	beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
88
+
89
+	beego.Router("/api/patient/getdialysisadvicescheduelist", &DialysisApiController{}, "Get:GetDialysisAdviceSchedulist")
90
+
91
+	beego.Router("/api/patient/getdialysisparametergoodlist", &DialysisApiController{}, "Get:GetDialysisParameterGoodList")
92
+
93
+	beego.Router("/api/patient/savehisdialysis", &DialysisApiController{}, "Get:SaveHisDialysis")
94
+
95
+	beego.Router("/api/patient/gethisdialysisgoodcount", &DialysisApiController{}, "Get:GetHisDialysisGoodCount")
96
+
97
+	beego.Router("/api/schedule/getpatientshedule", &DialysisApiController{}, "Get:GetPatientSchedule")
98
+
99
+	beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
84
 }
100
 }
85
 
101
 
86
 func (c *DialysisApiController) GetQueueCall() {
102
 func (c *DialysisApiController) GetQueueCall() {
288
 	epo := c.GetString("epo")
304
 	epo := c.GetString("epo")
289
 	epo_count, _ := c.GetFloat("epo_count", 0)
305
 	epo_count, _ := c.GetFloat("epo_count", 0)
290
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
306
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
307
+	admin_user_id, _ := c.GetInt64("admin_user_id")
308
+	is_water, _ := c.GetInt64("is_water")
309
+	drhy_water := c.GetString("drhy_water")
310
+	dry_water_hour := c.GetString("dry_water_hour")
311
+	water_machine := c.GetString("water_machine")
291
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
312
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
292
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
313
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
293
 
314
 
388
 		Epo:                        epo,
409
 		Epo:                        epo,
389
 		EpoCount:                   epo_count,
410
 		EpoCount:                   epo_count,
390
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
411
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
412
+		AdminUserId:                admin_user_id,
413
+		IsWater:                    is_water,
414
+		DrhyWater:                  drhy_water,
415
+		DryWaterHour:               dry_water_hour,
416
+		WaterMachine:               water_machine,
391
 	}
417
 	}
392
 
418
 
393
 	if appRole.UserType == 2 || appRole.UserType == 1 {
419
 	if appRole.UserType == 2 || appRole.UserType == 1 {
611
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
637
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
612
 	impulse := c.GetString("impulse")
638
 	impulse := c.GetString("impulse")
613
 	preImpules, parseDateErr := strconv.ParseFloat(impulse, 64)
639
 	preImpules, parseDateErr := strconv.ParseFloat(impulse, 64)
640
+	admin_user_id, _ := c.GetInt64("admin_user_id")
614
 	fmt.Println("", preImpules)
641
 	fmt.Println("", preImpules)
642
+	is_water, _ := c.GetInt64("is_water")
643
+	dry_water_hour := c.GetString("dry_water_hour")
644
+	drhy_water := c.GetString("drhy_water")
645
+	water_machine := c.GetString("water_machine")
615
 	var prescription_doctor int64
646
 	var prescription_doctor int64
616
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
647
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
617
 
648
 
724
 		EpoCount:                   epo_count,
755
 		EpoCount:                   epo_count,
725
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
756
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
726
 		PreImpulse:                 preImpules,
757
 		PreImpulse:                 preImpules,
758
+		AdminUserId:                admin_user_id,
759
+		IsWater:                    is_water,
760
+		DryWaterHour:               dry_water_hour,
761
+		DrhyWater:                  drhy_water,
762
+		WaterMachine:               water_machine,
727
 	}
763
 	}
728
 
764
 
729
 	//查询最近透析准备表里是否存在 透析器 灌流器
765
 	//查询最近透析准备表里是否存在 透析器 灌流器
1122
 	psychological_other := c.GetString("psychological_other")
1158
 	psychological_other := c.GetString("psychological_other")
1123
 	admission_number := c.GetString("admission_number")
1159
 	admission_number := c.GetString("admission_number")
1124
 	tumble, _ := c.GetInt64("tumble")
1160
 	tumble, _ := c.GetInt64("tumble")
1161
+	his_department := c.GetString("his_department")
1162
+	his_bed := c.GetString("his_bed")
1163
+	diacrisis := c.GetString("diacrisis")
1125
 	if id <= 0 {
1164
 	if id <= 0 {
1126
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1165
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1127
 		return
1166
 		return
1170
 		PsychologicalOther:           psychological_other,
1209
 		PsychologicalOther:           psychological_other,
1171
 		AdmissionNumber:              admission_number,
1210
 		AdmissionNumber:              admission_number,
1172
 		Tumble:                       tumble,
1211
 		Tumble:                       tumble,
1212
+		HisDepartment:                his_department,
1213
+		HisBed:                       his_bed,
1214
+		Diacrisis:                    diacrisis,
1173
 	}
1215
 	}
1174
 
1216
 
1175
 	if receiveTreatment.ID == 0 { //新增
1217
 	if receiveTreatment.ID == 0 { //新增
1493
 	urea_befor := c.GetString("urea_befor")
1535
 	urea_befor := c.GetString("urea_befor")
1494
 	suction := c.GetString("suction")
1536
 	suction := c.GetString("suction")
1495
 	weight_befor_remake := c.GetString("weight_befor_remake")
1537
 	weight_befor_remake := c.GetString("weight_befor_remake")
1496
-
1538
+	height := c.GetString("height")
1539
+	age := c.GetString("age")
1540
+	his_department := c.GetString("his_department")
1541
+	his_bed := c.GetString("his_bed")
1497
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1542
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1498
 		DialysisCount:                  dialysis_count,
1543
 		DialysisCount:                  dialysis_count,
1499
 		EmergencyTreatment:             emergency_treatment,
1544
 		EmergencyTreatment:             emergency_treatment,
1563
 		UreaBefor:                      urea_befor,
1608
 		UreaBefor:                      urea_befor,
1564
 		Suction:                        suction,
1609
 		Suction:                        suction,
1565
 		WeightBeforRemake:              weight_befor_remake,
1610
 		WeightBeforRemake:              weight_befor_remake,
1611
+		Height:                         height,
1612
+		Age:                            age,
1613
+		HisDepartment:                  his_department,
1614
+		HisBed:                         his_bed,
1566
 	}
1615
 	}
1567
 
1616
 
1568
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1617
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
3752
 				ultrafiltration_rate = value
3801
 				ultrafiltration_rate = value
3753
 				record.UltrafiltrationRate = ultrafiltration_rate
3802
 				record.UltrafiltrationRate = ultrafiltration_rate
3754
 			}
3803
 			}
3804
+
3805
+			if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 {
3806
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3807
+
3808
+				record.UltrafiltrationRate = ultrafiltration_rate
3809
+			}
3810
+
3755
 		}
3811
 		}
3756
 	}
3812
 	}
3757
 	// record.UltrafiltrationRate = ultrafiltration_rate
3813
 	// record.UltrafiltrationRate = ultrafiltration_rate
3774
 
3830
 
3775
 	}
3831
 	}
3776
 
3832
 
3833
+	if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 {
3834
+
3835
+		if ultrafiltration_rate > 0 {
3836
+			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3837
+
3838
+			record.UltrafiltrationVolume = ultrafiltration_volume
3839
+		}
3840
+	}
3841
+
3777
 	if template.TemplateId == 47 || template.TemplateId == 54 {
3842
 	if template.TemplateId == 47 || template.TemplateId == 54 {
3778
 		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3843
 		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3779
 	}
3844
 	}
4242
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4307
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4243
 
4308
 
4244
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4309
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4310
+	_, config := service.FindXTHisRecordByOrgId(orgId)
4245
 
4311
 
4246
-	list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4312
+	goodType, _ := service.GetAllGoodType(orgId)
4313
+	if config.IsOpen != 1 {
4314
+		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4315
+		fmt.Println("list2232323223332323232", list)
4316
+		if err == nil {
4317
+			this.ServeSuccessJSON(map[string]interface{}{
4318
+				"list":     list,
4319
+				"total":    total,
4320
+				"config":   config,
4321
+				"goodType": goodType,
4322
+			})
4323
+			return
4247
 
4324
 
4248
-	if err == nil {
4249
-		this.ServeSuccessJSON(map[string]interface{}{
4250
-			"list":  list,
4251
-			"total": total,
4252
-		})
4253
-		return
4325
+		} else {
4326
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4327
+			return
4328
+		}
4329
+	}
4330
+	if config.IsOpen == 1 {
4331
+		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4332
+		if err == nil {
4333
+			this.ServeSuccessJSON(map[string]interface{}{
4334
+				"list":     list,
4335
+				"total":    total,
4336
+				"config":   config,
4337
+				"goodType": goodType,
4338
+			})
4339
+			return
4340
+		}
4254
 
4341
 
4255
-	} else {
4256
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4257
-		return
4258
 	}
4342
 	}
4343
+
4259
 }
4344
 }
4260
 
4345
 
4261
 func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4346
 func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4271
 	schedule_type, _ := this.GetInt64("schedule_type")
4356
 	schedule_type, _ := this.GetInt64("schedule_type")
4272
 
4357
 
4273
 	start_time := this.GetString("schedule_date")
4358
 	start_time := this.GetString("schedule_date")
4359
+
4360
+	ids := this.GetString("ids")
4361
+	idArray := strings.Split(ids, ",")
4274
 	timeLayout := "2006-01-02"
4362
 	timeLayout := "2006-01-02"
4275
 	loc, _ := time.LoadLocation("Local")
4363
 	loc, _ := time.LoadLocation("Local")
4276
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4364
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4277
 
4365
 
4278
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4366
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4279
-
4280
-	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4281
-
4367
+	fmt.Println("idArray", idArray)
4368
+	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4369
+	fmt.Println("list2323223323223323323223wi", list)
4282
 	//获取长期医嘱
4370
 	//获取长期医嘱
4283
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4371
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4284
 
4372
 
4285
 	//获取医嘱模版
4373
 	//获取医嘱模版
4286
 	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4374
 	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4375
+
4376
+	_, config := service.FindXTHisRecordByOrgId(orgId)
4377
+
4378
+	drugList, _ := service.GetAllBaseDrugList(orgId)
4287
 	if err == nil {
4379
 	if err == nil {
4288
 		this.ServeSuccessJSON(map[string]interface{}{
4380
 		this.ServeSuccessJSON(map[string]interface{}{
4289
 			"list":         list,
4381
 			"list":         list,
4290
 			"total":        total,
4382
 			"total":        total,
4291
 			"adviceList":   adviceList,
4383
 			"adviceList":   adviceList,
4292
 			"templateList": templateList,
4384
 			"templateList": templateList,
4385
+			"config":       config,
4386
+			"drugList":     drugList,
4293
 		})
4387
 		})
4294
 		return
4388
 		return
4295
 
4389
 
4325
 	bicarbonate_set, _ := this.GetInt64("bicarbonate_set")
4419
 	bicarbonate_set, _ := this.GetInt64("bicarbonate_set")
4326
 	glucose_set, _ := this.GetInt64("glucose_set")
4420
 	glucose_set, _ := this.GetInt64("glucose_set")
4327
 
4421
 
4422
+	sodium_set, _ := this.GetInt64("sodium_set")
4423
+	calcium_set, _ := this.GetInt64("calcium_set")
4424
+	blood_access_set, _ := this.GetInt64("blood_access_set")
4425
+	dialyzer_perfusion_apparatus_set, _ := this.GetInt64("dialyzer_perfusion_apparatus_set")
4426
+	displace_liqui_part_set, _ := this.GetInt64("displace_liqui_part_set")
4328
 	dialysisSetting := models.XtDialysisSetting{
4427
 	dialysisSetting := models.XtDialysisSetting{
4329
-		UserOrgId:             orgId,
4330
-		Status:                1,
4331
-		DeviceNumber:          device_number_set,
4332
-		DeviceType:            device_type_set,
4333
-		Name:                  name_set,
4334
-		AdmissionNumber:       admission_number_set,
4335
-		DialysisNo:            dialysis_no_set,
4336
-		WeightBefor:           weight_befor_set,
4337
-		DryWeight:             dry_weight_set,
4338
-		BloodPressure:         blood_pressure_set,
4339
-		UltrafiltrationVolume: ultrafiltration_volume_set,
4340
-		InternalFistula:       internal_fistula_set,
4341
-		BloodFlowVolume:       blood_flow_volume_set,
4342
-		Anticoagulant:         anticoagulant_set,
4343
-		SealingFluidDispose:   sealing_fluid_dispose_set,
4344
-		ModeId:                mode_id_set,
4345
-		DialysisTime:          dialysis_time_set,
4346
-		DialysisDialyszers:    dialysis_dialyszers_set,
4347
-		DialysisIrrigation:    dialysis_irrigation_set,
4348
-		Gaijiliang:            gaijiliang_set,
4349
-		Kalium:                kalium_set,
4350
-		DisplaceLiquiValue:    displace_liqui_value_set,
4351
-		Bicarbonate:           bicarbonate_set,
4352
-		Glucose:               glucose_set,
4353
-		Ctime:                 time.Now().Unix(),
4354
-		Mtime:                 time.Now().Unix(),
4428
+		Sodium:                     sodium_set,
4429
+		Calcium:                    calcium_set,
4430
+		BloodAccess:                blood_access_set,
4431
+		DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus_set,
4432
+		DisplaceLiquiPart:          displace_liqui_part_set,
4433
+		UserOrgId:                  orgId,
4434
+		Status:                     1,
4435
+		DeviceNumber:               device_number_set,
4436
+		DeviceType:                 device_type_set,
4437
+		Name:                       name_set,
4438
+		AdmissionNumber:            admission_number_set,
4439
+		DialysisNo:                 dialysis_no_set,
4440
+		WeightBefor:                weight_befor_set,
4441
+		DryWeight:                  dry_weight_set,
4442
+		BloodPressure:              blood_pressure_set,
4443
+		UltrafiltrationVolume:      ultrafiltration_volume_set,
4444
+		InternalFistula:            internal_fistula_set,
4445
+		BloodFlowVolume:            blood_flow_volume_set,
4446
+		Anticoagulant:              anticoagulant_set,
4447
+		SealingFluidDispose:        sealing_fluid_dispose_set,
4448
+		ModeId:                     mode_id_set,
4449
+		DialysisTime:               dialysis_time_set,
4450
+		DialysisDialyszers:         dialysis_dialyszers_set,
4451
+		DialysisIrrigation:         dialysis_irrigation_set,
4452
+		Gaijiliang:                 gaijiliang_set,
4453
+		Kalium:                     kalium_set,
4454
+		DisplaceLiquiValue:         displace_liqui_value_set,
4455
+		Bicarbonate:                bicarbonate_set,
4456
+		Glucose:                    glucose_set,
4457
+		Ctime:                      time.Now().Unix(),
4458
+		Mtime:                      time.Now().Unix(),
4355
 	}
4459
 	}
4356
 	err := service.SaveDialysisSetting(dialysisSetting)
4460
 	err := service.SaveDialysisSetting(dialysisSetting)
4357
 	if err == nil {
4461
 	if err == nil {
4375
 	})
4479
 	})
4376
 	return
4480
 	return
4377
 }
4481
 }
4482
+
4483
+func (this *DialysisApiController) GetDialysisParameterList() {
4484
+
4485
+	keyword := this.GetString("keywords")
4486
+
4487
+	limit, _ := this.GetInt64("limit")
4488
+
4489
+	page, _ := this.GetInt64("page")
4490
+
4491
+	partition_id, _ := this.GetInt64("partition_id")
4492
+
4493
+	schedule_type, _ := this.GetInt64("schedule_type")
4494
+
4495
+	start_time := this.GetString("schedule_date")
4496
+	timeLayout := "2006-01-02"
4497
+	loc, _ := time.LoadLocation("Local")
4498
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4499
+
4500
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4501
+
4502
+	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4503
+
4504
+	dialysisSett, _ := service.GetDialysisSetting(orgId)
4505
+	if err == nil {
4506
+		this.ServeSuccessJSON(map[string]interface{}{
4507
+			"list":         list,
4508
+			"total":        total,
4509
+			"dialysisSett": dialysisSett,
4510
+		})
4511
+		return
4512
+
4513
+	} else {
4514
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4515
+		return
4516
+	}
4517
+}
4518
+
4519
+func (this *DialysisApiController) GetDialysisGoodTotalCount() {
4520
+
4521
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4522
+
4523
+	schedule_type, _ := this.GetInt64("schedule_type")
4524
+
4525
+	partion_type, _ := this.GetInt64("partion_type")
4526
+
4527
+	start_time := this.GetString("selected_date")
4528
+	timeLayout := "2006-01-02"
4529
+	loc, _ := time.LoadLocation("Local")
4530
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4531
+
4532
+	list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, partion_type, startTime.Unix())
4533
+	if err == nil {
4534
+		this.ServeSuccessJSON(map[string]interface{}{
4535
+			"list": list,
4536
+		})
4537
+		return
4538
+
4539
+	} else {
4540
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4541
+		return
4542
+	}
4543
+}
4544
+
4545
+func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
4546
+
4547
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4548
+
4549
+	schedule_type, _ := this.GetInt64("schedule_type")
4550
+
4551
+	partion_type, _ := this.GetInt64("partion_type")
4552
+
4553
+	start_time := this.GetString("selected_date")
4554
+	timeLayout := "2006-01-02"
4555
+	loc, _ := time.LoadLocation("Local")
4556
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4557
+
4558
+	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
4559
+	drug, _ := service.GetAllDrugMap(orgId)
4560
+	//获取长期医嘱
4561
+	adviceList, _ := service.GetAllLongAdviceList(orgId)
4562
+	//获取医嘱模版
4563
+	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4564
+
4565
+	_, config := service.FindXTHisRecordByOrgId(orgId)
4566
+	if err == nil {
4567
+		this.ServeSuccessJSON(map[string]interface{}{
4568
+			"list":         list,
4569
+			"drug":         drug,
4570
+			"adviceList":   adviceList,
4571
+			"templateList": templateList,
4572
+			"config":       config,
4573
+		})
4574
+		return
4575
+
4576
+	} else {
4577
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4578
+		return
4579
+	}
4580
+}
4581
+
4582
+func (this *DialysisApiController) GetDialysisParameterGoodList() {
4583
+
4584
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4585
+
4586
+	schedule_type, _ := this.GetInt64("schedule_type")
4587
+
4588
+	partion_type, _ := this.GetInt64("partion_type")
4589
+
4590
+	start_time := this.GetString("selected_date")
4591
+	timeLayout := "2006-01-02"
4592
+	loc, _ := time.LoadLocation("Local")
4593
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4594
+
4595
+	list, err := service.GetDialysisParameterGoodList(orgId, schedule_type, partion_type, startTime.Unix())
4596
+	if err == nil {
4597
+		this.ServeSuccessJSON(map[string]interface{}{
4598
+			"list": list,
4599
+		})
4600
+		return
4601
+
4602
+	} else {
4603
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4604
+		return
4605
+	}
4606
+}
4607
+
4608
+func (this *DialysisApiController) SaveHisDialysis() {
4609
+
4610
+	var ids []string
4611
+	advice_ids := this.GetString("ids")
4612
+	ids = strings.Split(advice_ids, ",")
4613
+
4614
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4615
+
4616
+	service.SaveHisDialysis(orgId, ids)
4617
+
4618
+	returnData := make(map[string]interface{}, 0)
4619
+	returnData["msg"] = "ok"
4620
+	this.ServeSuccessJSON(returnData)
4621
+	return
4622
+}
4623
+
4624
+func (this *DialysisApiController) GetHisDialysisGoodCount() {
4625
+
4626
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4627
+
4628
+	schedule_type, _ := this.GetInt64("schedule_type")
4629
+
4630
+	partion_type, _ := this.GetInt64("partion_type")
4631
+
4632
+	start_time := this.GetString("selected_date")
4633
+	timeLayout := "2006-01-02"
4634
+	loc, _ := time.LoadLocation("Local")
4635
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4636
+
4637
+	list, _ := service.GetHisDialysisGoodCount(orgId, schedule_type, partion_type, startTime.Unix())
4638
+
4639
+	this.ServeSuccessJSON(map[string]interface{}{
4640
+		"list": list,
4641
+	})
4642
+	return
4643
+}
4644
+
4645
+func (this *DialysisApiController) GetPatientSchedule() {
4646
+
4647
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4648
+
4649
+	patient_id, _ := this.GetInt64("patient_id")
4650
+	schedule_date, _ := this.GetInt64("schedule_date")
4651
+
4652
+	schedulePatient, _ := service.GetScheduleByPatient(patient_id, schedule_date, orgId)
4653
+
4654
+	this.ServeSuccessJSON(map[string]interface{}{
4655
+		"schedulePatient": schedulePatient,
4656
+	})
4657
+}
4658
+
4659
+func (c *DialysisApiController) GetSchedulePrintList() {
4660
+	page, _ := c.GetInt64("page", 1)
4661
+	limit, _ := c.GetInt64("limit", 10)
4662
+	schedulType, _ := c.GetInt64("schedule_type", 0)
4663
+	partitionType, _ := c.GetInt64("partition_type", 0)
4664
+	keywords := c.GetString("keywords")
4665
+	schedule_date := c.GetString("schedule_date")
4666
+	timeLayout := "2006-01-02"
4667
+	loc, _ := time.LoadLocation("Local")
4668
+	var theStartTime int64
4669
+	if len(schedule_date) > 0 {
4670
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
4671
+		if err != nil {
4672
+			utils.ErrorLog(err.Error())
4673
+		}
4674
+		theStartTime = theTime.Unix()
4675
+	}
4676
+	adminUserInfo := c.GetAdminUserInfo()
4677
+
4678
+	list, total, _ := service.GetSchedulePrintList(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
4679
+
4680
+	listOne, _ := service.GetSchedulePrintListOne(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
4681
+	numberList, _ := service.GetAllBedNumberSix(adminUserInfo.CurrentOrgId)
4682
+	c.ServeSuccessJSON(map[string]interface{}{
4683
+		"list":       list,
4684
+		"total":      total,
4685
+		"numberList": numberList,
4686
+		"listOne":    listOne,
4687
+	})
4688
+
4689
+}

+ 73 - 3
controllers/dialysis_record_api_controller.go Ver arquivo

394
 	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
394
 	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
395
 
395
 
396
 	lastDryWeightDislysis, getDryErr := service.GetLastDryWeight(adminInfo.CurrentOrgId, patientID)
396
 	lastDryWeightDislysis, getDryErr := service.GetLastDryWeight(adminInfo.CurrentOrgId, patientID)
397
+
398
+	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.CurrentOrgId, patientID, date.Unix())
397
 	if getDryErr != nil {
399
 	if getDryErr != nil {
398
 		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
400
 		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
399
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
401
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
447
 			"lastAssessment":              lastAssessment,
449
 			"lastAssessment":              lastAssessment,
448
 			"information":                 information,
450
 			"information":                 information,
449
 			"is_advice_open":              adviceConfig,
451
 			"is_advice_open":              adviceConfig,
452
+			"lastOrder":                   lastOrder,
450
 		}
453
 		}
451
 		this.ServeSuccessJSON(returnData)
454
 		this.ServeSuccessJSON(returnData)
452
 
455
 
483
 			"lastAssessment":              lastAssessment,
486
 			"lastAssessment":              lastAssessment,
484
 			"information":                 information,
487
 			"information":                 information,
485
 			"is_advice_open":              adviceConfig,
488
 			"is_advice_open":              adviceConfig,
489
+			"lastOrder":                   lastOrder,
486
 		}
490
 		}
487
 		this.ServeSuccessJSON(returnData)
491
 		this.ServeSuccessJSON(returnData)
488
 	}
492
 	}
775
 	change_nurse, _ := this.GetInt64("change_nurse")
779
 	change_nurse, _ := this.GetInt64("change_nurse")
776
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
780
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
777
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
781
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
782
+	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
783
+	puncture_needle := this.GetString("puncture_needle")
784
+	puncture_way := this.GetString("puncture_way")
785
+	dialysis_dialyszers := this.GetString("dialysis_dialyszers")
786
+	dialysis_irrigation := this.GetString("dialysis_irrigation")
787
+	blood_access_id, _ := this.GetInt64("blood_access_id")
778
 	bedID, _ := this.GetInt64("bed")
788
 	bedID, _ := this.GetInt64("bed")
789
+	nuclein_date := this.GetString("nuclein_date")
779
 
790
 
780
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
791
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
781
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
792
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
862
 	schedulestartTime := theStartTime.Unix()
873
 	schedulestartTime := theStartTime.Unix()
863
 	scheduleendTime := theEndTime.Unix()
874
 	scheduleendTime := theEndTime.Unix()
864
 
875
 
876
+	var theNucleinDate int64
877
+	timeLayoutOne := "2006-01-02"
878
+
879
+	if len(nuclein_date) > 0 {
880
+		theTime, err := time.ParseInLocation(timeLayoutOne+" 15:04:05", nuclein_date+" 00:00:00", loc)
881
+		if err != nil {
882
+			utils.ErrorLog(err.Error())
883
+		}
884
+		theNucleinDate = theTime.Unix()
885
+	}
886
+
865
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
887
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
866
 
888
 
867
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
889
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
972
 		ChangeNurse:            change_nurse,
994
 		ChangeNurse:            change_nurse,
973
 		DifficultPunctureNurse: difficult_puncture_nurse,
995
 		DifficultPunctureNurse: difficult_puncture_nurse,
974
 		NewFistulaNurse:        new_fistula_nurse,
996
 		NewFistulaNurse:        new_fistula_nurse,
997
+		QualityNurseId:         quality_nurse_id,
998
+		PunctureNeedle:         puncture_needle,
999
+		PunctureWay:            puncture_way,
1000
+		DialysisDialyszers:     dialysis_dialyszers,
1001
+		DialysisIrrigation:     dialysis_irrigation,
1002
+		BloodAccessId:          blood_access_id,
1003
+		NucleinDate:            theNucleinDate,
975
 	}
1004
 	}
976
 
1005
 
977
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1006
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1093
 
1122
 
1094
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
1123
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
1095
 		if newdialysisRecord.ID > 0 {
1124
 		if newdialysisRecord.ID > 0 {
1125
+
1126
+			//针对长沙南雅医院
1127
+			if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
1128
+
1129
+				record.Temperature = 36.5
1130
+				record.ArterialPressure = -100
1131
+				record.Conductivity = 14
1132
+				record.BreathingRate = "20"
1133
+				record.DialysateTemperature = 36.5
1134
+				record.VenousPressure = 80
1135
+				record.TransmembranePressure = 60
1136
+			}
1137
+
1096
 			err := service.CreateMonitor(&record)
1138
 			err := service.CreateMonitor(&record)
1097
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
1139
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
1098
 
1140
 
1143
 	internal_fistula := this.GetString("internal_fistula")
1185
 	internal_fistula := this.GetString("internal_fistula")
1144
 	catheter := this.GetString("catheter")
1186
 	catheter := this.GetString("catheter")
1145
 	cruor := this.GetString("cruor")
1187
 	cruor := this.GetString("cruor")
1188
+	mission := this.GetString("mission")
1146
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
1189
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
1147
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1190
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1148
 		return
1191
 		return
1264
 			//获取最后一条透析处方数据
1307
 			//获取最后一条透析处方数据
1265
 			prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1308
 			prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1266
 			evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1309
 			evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1267
-			tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1310
+			tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration/1000
1268
 		}
1311
 		}
1269
 		if adminUserInfo.CurrentOrgId == 10101 {
1312
 		if adminUserInfo.CurrentOrgId == 10101 {
1270
 			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
1313
 			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
1355
 
1398
 
1356
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1399
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1357
 
1400
 
1358
-	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 {
1401
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 || adminUserInfo.CurrentOrgId == 10414 {
1359
 		fmt.Println("进来2332233333333333333333333333333333333我的")
1402
 		fmt.Println("进来2332233333333333333333333333333333333我的")
1360
 		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1403
 		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1361
 		if evaluation.SystolicBloodPressure == 0 {
1404
 		if evaluation.SystolicBloodPressure == 0 {
1437
 	}()
1480
 	}()
1438
 
1481
 
1439
 	//执行下机
1482
 	//执行下机
1440
-	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
1483
+	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1441
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1484
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1442
 	redis := service.RedisClient()
1485
 	redis := service.RedisClient()
1443
 	defer redis.Close()
1486
 	defer redis.Close()
1480
 	change_nurse, _ := this.GetInt64("change_nurse")
1523
 	change_nurse, _ := this.GetInt64("change_nurse")
1481
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1524
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
1482
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1525
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
1526
+	quality_nurse, _ := this.GetInt64("quality_nurse")
1527
+	puncture_needle := this.GetString("puncture_needle")
1528
+	puncture_way := this.GetString("puncture_way")
1529
+	dialysis_dialyszers := this.GetString("dialysis_dialyszers")
1530
+	dialysis_irrigation := this.GetString("dialysis_irrigation")
1531
+	blood_access_id, _ := this.GetInt64("blood_access_id")
1532
+	nuclein_date := this.GetString("nuclein_date")
1483
 	if record_id == 0 {
1533
 	if record_id == 0 {
1484
 		this.ErrorLog("id:%v", record_id)
1534
 		this.ErrorLog("id:%v", record_id)
1485
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1535
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1550
 	schedulestartTime := theStartTime.Unix()
1600
 	schedulestartTime := theStartTime.Unix()
1551
 	scheduleendTime := theEndTime.Unix()
1601
 	scheduleendTime := theEndTime.Unix()
1552
 
1602
 
1603
+	var theNucleinDate int64
1604
+	timeLayoutOne := "2006-01-02"
1605
+
1606
+	if len(nuclein_date) > 0 {
1607
+		theTime, err := time.ParseInLocation(timeLayoutOne+" 15:04:05", nuclein_date+" 00:00:00", loc)
1608
+		if err != nil {
1609
+			utils.ErrorLog(err.Error())
1610
+		}
1611
+		theNucleinDate = theTime.Unix()
1612
+	}
1553
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
1613
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
1554
 
1614
 
1555
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
1615
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
1611
 		}
1671
 		}
1612
 
1672
 
1613
 	}
1673
 	}
1674
+	fmt.Println("theNucleinDate", theNucleinDate)
1614
 	dialysisRecord := &models.DialysisOrder{
1675
 	dialysisRecord := &models.DialysisOrder{
1615
 		ID:                     record_id,
1676
 		ID:                     record_id,
1616
 		UserOrgId:              adminUserInfo.CurrentOrgId,
1677
 		UserOrgId:              adminUserInfo.CurrentOrgId,
1625
 		ChangeNurse:            change_nurse,
1686
 		ChangeNurse:            change_nurse,
1626
 		DifficultPunctureNurse: difficult_puncture_nurse,
1687
 		DifficultPunctureNurse: difficult_puncture_nurse,
1627
 		NewFistulaNurse:        new_fistula_nurse,
1688
 		NewFistulaNurse:        new_fistula_nurse,
1689
+		QualityNurseId:         quality_nurse,
1690
+		PunctureWay:            puncture_way,
1691
+		PunctureNeedle:         puncture_needle,
1692
+		DialysisDialyszers:     dialysis_dialyszers,
1693
+		DialysisIrrigation:     dialysis_irrigation,
1694
+		BloodAccessId:          blood_access_id,
1695
+		NucleinDate:            theNucleinDate,
1628
 	}
1696
 	}
1629
 
1697
 
1630
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1698
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1703
 	internal_fistula := c.GetString("internal_fistula")
1771
 	internal_fistula := c.GetString("internal_fistula")
1704
 	catheter := c.GetString("catheter")
1772
 	catheter := c.GetString("catheter")
1705
 	cruor := c.GetString("cruor")
1773
 	cruor := c.GetString("cruor")
1774
+	mission := c.GetString("mission")
1706
 	if record_id <= 0 || nurseID <= 0 {
1775
 	if record_id <= 0 || nurseID <= 0 {
1707
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1776
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1708
 		return
1777
 		return
1749
 		BloodAccessInternalFistula: internal_fistula,
1818
 		BloodAccessInternalFistula: internal_fistula,
1750
 		Catheter:                   catheter,
1819
 		Catheter:                   catheter,
1751
 		Cruor:                      cruor,
1820
 		Cruor:                      cruor,
1821
+		Mission:                    mission,
1752
 	}
1822
 	}
1753
 
1823
 
1754
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
1824
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)

+ 4 - 2
controllers/doctors_api_controller.go Ver arquivo

199
 func (c *DoctorsApiController) GetAllDoctorAndNurse() {
199
 func (c *DoctorsApiController) GetAllDoctorAndNurse() {
200
 
200
 
201
 	adminUserInfo := c.GetAdminUserInfo()
201
 	adminUserInfo := c.GetAdminUserInfo()
202
-	doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
202
+	doctors, nursers, _ := service.GetAllDoctorAndNurseSix(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
203
 
203
 
204
 	c.ServeSuccessJSON(map[string]interface{}{
204
 	c.ServeSuccessJSON(map[string]interface{}{
205
 		"doctors": doctors,
205
 		"doctors": doctors,
211
 
211
 
212
 	adminUserInfo := c.GetAdminUserInfo()
212
 	adminUserInfo := c.GetAdminUserInfo()
213
 	users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
213
 	users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
214
+	operators, _ := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
214
 	c.ServeSuccessJSON(map[string]interface{}{
215
 	c.ServeSuccessJSON(map[string]interface{}{
215
-		"users": users,
216
+		"users":     users,
217
+		"operators": operators,
216
 	})
218
 	})
217
 	return
219
 	return
218
 }
220
 }

+ 153 - 116
controllers/drug_stock_api_contorller.go Ver arquivo

267
 					IsCheck:          2,
267
 					IsCheck:          2,
268
 					StockMinNumber:   0,
268
 					StockMinNumber:   0,
269
 				}
269
 				}
270
-				fmt.Println(warehouseInfo)
270
+				//fmt.Println(warehouseInfo)
271
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
271
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
272
 			}
272
 			}
273
 		}
273
 		}
1301
 					AdminUserId:             admin_user_id,
1301
 					AdminUserId:             admin_user_id,
1302
 					StockCount:              stock_count,
1302
 					StockCount:              stock_count,
1303
 					IsCheck:                 2,
1303
 					IsCheck:                 2,
1304
+					SysRecordTime:           warehousingOutDate.Unix(),
1304
 				}
1305
 				}
1305
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1306
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1306
 
1307
 
3563
 			}
3564
 			}
3564
 
3565
 
3565
 			Creator := c.GetAdminUserInfo().AdminUser.Id
3566
 			Creator := c.GetAdminUserInfo().AdminUser.Id
3567
+
3568
+			//查询默认仓库
3569
+
3570
+			//查询默认仓库剩余多少库存
3571
+			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3572
+			var sum_count int64
3573
+			var sum_in_count int64
3574
+			for _, it := range list {
3575
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3576
+				if it.MaxUnit == baseDrug.MaxUnit {
3577
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3578
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3579
+				}
3580
+				sum_count += it.StockMaxNumber + it.StockMinNumber
3581
+				sum_in_count += it.WarehousingCount
3582
+			}
3566
 			flow := &models.DrugFlow{
3583
 			flow := &models.DrugFlow{
3567
 				WarehousingId:           0,
3584
 				WarehousingId:           0,
3568
 				DrugId:                  item.DrugId,
3585
 				DrugId:                  item.DrugId,
3596
 				MaxUnit:                 item.MaxUnit,
3613
 				MaxUnit:                 item.MaxUnit,
3597
 				MinUnit:                 item.MinUnit,
3614
 				MinUnit:                 item.MinUnit,
3598
 				StorehouseId:            item.StorehouseId,
3615
 				StorehouseId:            item.StorehouseId,
3616
+				OverCount:               sum_count,
3599
 			}
3617
 			}
3600
 			service.CreateDrugFlowTwo(flow)
3618
 			service.CreateDrugFlowTwo(flow)
3601
-
3602
-			//查询默认仓库
3603
-
3604
-			//查询默认仓库剩余多少库存
3605
-			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3606
-			var sum_count int64
3607
-			var sum_in_count int64
3608
-			for _, it := range list {
3609
-				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3610
-				if it.MaxUnit == baseDrug.MaxUnit {
3611
-					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3612
-					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3613
-				}
3614
-				sum_count += it.StockMaxNumber + it.StockMinNumber
3615
-				sum_in_count += it.WarehousingCount
3616
-			}
3619
+			//更新基础库剩余库存
3617
 			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3620
 			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3618
 
3621
 
3619
 			drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3622
 			drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3623
 				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3626
 				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3624
 				if it.MaxUnit == baseDrug.MaxUnit {
3627
 				if it.MaxUnit == baseDrug.MaxUnit {
3625
 					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3628
 					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3629
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3626
 				}
3630
 				}
3631
+			}
3632
+			for _, it := range drugInfolist {
3627
 				total_count += it.WarehousingCount
3633
 				total_count += it.WarehousingCount
3628
-				over_count += it.StockMaxNumber*baseDrug.MinNumber + it.StockMinNumber
3634
+				over_count += it.StockMaxNumber + it.StockMinNumber
3629
 			}
3635
 			}
3630
 			//查询该仓库是否有默认数据
3636
 			//查询该仓库是否有默认数据
3631
 			_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3637
 			_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3722
 		}
3728
 		}
3723
 		drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3729
 		drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3724
 		var over_count int64 //剩余库存
3730
 		var over_count int64 //剩余库存
3731
+		for _, it := range drugInfolist {
3732
+			if it.MaxUnit == medical.MaxUnit {
3733
+				it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
3734
+			}
3735
+		}
3725
 		for _, it := range drugInfolist {
3736
 		for _, it := range drugInfolist {
3726
 			over_count += it.StockMaxNumber*medical.MinNumber + it.StockMinNumber
3737
 			over_count += it.StockMaxNumber*medical.MinNumber + it.StockMinNumber
3727
 		}
3738
 		}
3749
 	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3760
 	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3750
 
3761
 
3751
 	for _, it := range warehousingOutInfoList {
3762
 	for _, it := range warehousingOutInfoList {
3763
+		fmt.Println("countunit23322332232323wo", it.CountUnit)
3752
 		var total_count int64
3764
 		var total_count int64
3753
 		var out_count int64
3765
 		var out_count int64
3754
 		//查询剩余库存
3766
 		//查询剩余库存
3763
 			total_count += item.StockMaxNumber + item.StockMinNumber
3775
 			total_count += item.StockMaxNumber + item.StockMinNumber
3764
 		}
3776
 		}
3765
 
3777
 
3766
-		//if it.CountUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
3767
-		//	it.Count = it.Count * drup.MinNumber
3768
-		//}
3769
-		//out_count += it.Count
3770
-
3771
 		//出库数量累加
3778
 		//出库数量累加
3772
 		if it.CountUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
3779
 		if it.CountUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
3773
 			out_count = it.Count * drup.MinNumber
3780
 			out_count = it.Count * drup.MinNumber
3795
 			return
3802
 			return
3796
 		}
3803
 		}
3797
 	}
3804
 	}
3798
-	for _, it := range warehousingOutInfoList {
3799
-
3800
-		drup, _ := service.FindBaseDrugLibRecord(it.OrgId, it.DrugId)
3801
-		//出库逻辑
3802
-		service.AutoDrugDeliverInfoFourtyOne(orgId, it.Count, &drugWarehouseOut, &drup, it)
3805
+	warehousingOutInfoListTwo, _ := service.GetDrugWarehouseOutListById(warehouse_out_id, orgId)
3803
 
3806
 
3807
+	for _, it := range warehousingOutInfoListTwo {
3804
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3808
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3805
-		//查询剩余库存
3806
-		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, it.OrgId, it.DrugId)
3807
-		var sum_count int64
3808
-		for _, its := range stockInfo {
3809
-			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3810
-
3811
-		}
3812
-		service.UpdateBaseDrugSumTwo(it.DrugId, sum_count, it.OrgId)
3813
-
3814
 		////出库数量累加
3809
 		////出库数量累加
3815
 		var out_count_one int64
3810
 		var out_count_one int64
3811
+		fmt.Println("it.count", it.CountUnit)
3812
+		fmt.Println("MaxUnit", medical.MaxUnit)
3813
+		fmt.Println("MinUnit", medical.MinUnit)
3814
+		fmt.Println("count", it.Count)
3815
+		fmt.Println("number", medical.MinNumber)
3816
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3816
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3817
 			out_count_one = it.Count * medical.MinNumber
3817
 			out_count_one = it.Count * medical.MinNumber
3818
 		}
3818
 		}
3821
 			out_count_one = it.Count
3821
 			out_count_one = it.Count
3822
 		}
3822
 		}
3823
 
3823
 
3824
-		if it.CountUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
3824
+		if it.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3825
 			out_count_one = it.Count
3825
 			out_count_one = it.Count
3826
 		}
3826
 		}
3827
-
3828
-		fmt.Println("out_count23233232323woede", out_count_one)
3827
+		fmt.Println("countone3232232323323232332332wo", out_count_one)
3829
 		//增加出库数量
3828
 		//增加出库数量
3830
 		service.AddDrugCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, out_count_one)
3829
 		service.AddDrugCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, out_count_one)
3830
+		fmt.Println("countunit23322332232323", it.CountUnit)
3831
 
3831
 
3832
-		//查询该药品剩余库存
3833
-		infolist, _ := service.FindDrugWarehouseInfoFlushCountByStorehouse(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut)
3834
-		var over_count int64
3835
-		for _, its := range infolist {
3836
-			over_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3832
+	}
3833
+	warehousingOutInfoListThree, _ := service.GetDrugWarehouseOutListById(warehouse_out_id, orgId)
3834
+	for _, it := range warehousingOutInfoListThree {
3835
+		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3836
+		drup, _ := service.FindBaseDrugLibRecord(it.OrgId, it.DrugId)
3837
+		//出库逻辑
3838
+		service.AutoDrugDeliverInfoFourtyOne(orgId, it.Count, &drugWarehouseOut, &drup, it)
3839
+
3840
+		//查询剩余库存
3841
+		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, it.OrgId, it.DrugId)
3842
+		var sum_count int64
3843
+		for _, its := range stockInfo {
3844
+			if its.MaxUnit == medical.MaxUnit {
3845
+				its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
3846
+			}
3847
+			sum_count += its.StockMaxNumber + its.StockMinNumber
3837
 		}
3848
 		}
3838
-		service.UpdateDrugStockCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, over_count)
3849
+		//更新基础库库存
3850
+		service.UpdateBaseDrugSumTwo(it.DrugId, sum_count, it.OrgId)
3851
+
3852
+		//查询该药品剩余库存
3853
+		//infolist, _ := service.FindDrugWarehouseInfoFlushCountByStorehouse(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut)
3854
+		//var over_count int64
3855
+		//for _, its := range infolist {
3856
+		//  over_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3857
+		//}
3858
+		//更新剩余库存
3859
+		service.UpdateDrugStockCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
3860
+
3839
 	}
3861
 	}
3840
 
3862
 
3841
 	out := models.DrugWarehouseOut{
3863
 	out := models.DrugWarehouseOut{
3842
 		IsCheck: 1,
3864
 		IsCheck: 1,
3843
 	}
3865
 	}
3844
-
3866
+	//更新审核状态
3845
 	service.UpdateCheckDrugOut(out, warehouse_out_id)
3867
 	service.UpdateCheckDrugOut(out, warehouse_out_id)
3846
-	info := models.DrugWarehouseOutInfo{
3847
-		IsCheck: 1,
3848
-	}
3849
-	service.UpdateCheckDrugOutInfo(info, warehouse_out_id)
3868
+	//info := models.DrugWarehouseOutInfo{
3869
+	//	IsCheck: 1,
3870
+	//}
3871
+	//service.UpdateCheckDrugOutInfo(info, warehouse_out_id)
3850
 
3872
 
3851
 	c.ServeSuccessJSON(map[string]interface{}{
3873
 	c.ServeSuccessJSON(map[string]interface{}{
3852
 		"warehousingOutInfoList": warehousingOutInfoList,
3874
 		"warehousingOutInfoList": warehousingOutInfoList,
3934
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3956
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3935
 		var sum_count int64
3957
 		var sum_count int64
3936
 		for _, its := range stockInfo {
3958
 		for _, its := range stockInfo {
3937
-			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3959
+			baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
3960
+			if its.MaxUnit == baseDrug.MaxUnit {
3961
+				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3962
+			}
3963
+			sum_count += its.StockMaxNumber + its.StockMinNumber
3938
 		}
3964
 		}
3939
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
3965
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
3940
 
3966
 
4040
 			}
4066
 			}
4041
 		}
4067
 		}
4042
 
4068
 
4043
-		//查询该批次的退库数量
4044
-		drugFlow := models.DrugFlow{
4045
-			ID:                        0,
4046
-			WarehousingId:             its.BatchNumberId,
4047
-			DrugId:                    its.DrugId,
4048
-			Number:                    its.Number,
4049
-			BatchNumber:               "",
4050
-			Count:                     its.Count,
4051
-			UserOrgId:                 its.OrgId,
4052
-			PatientId:                 0,
4053
-			SystemTime:                cancelDrugStock.ReturnTime,
4054
-			ConsumableType:            4,
4055
-			IsSys:                     0,
4056
-			WarehousingOrder:          "",
4057
-			WarehouseOutId:            0,
4058
-			WarehouseOutOrderNumber:   "",
4059
-			IsEdit:                    0,
4060
-			CancelStockId:             0,
4061
-			CancelOrderNumber:         its.OrderNumber,
4062
-			Manufacturer:              manufacturer_id,
4063
-			Dealer:                    dealer_id,
4064
-			Creator:                   creater,
4065
-			UpdateCreator:             0,
4066
-			Status:                    1,
4067
-			Ctime:                     time.Now().Unix(),
4068
-			Mtime:                     0,
4069
-			Price:                     its.Price,
4070
-			WarehousingDetailId:       its.BatchNumberId,
4071
-			WarehouseOutDetailId:      0,
4072
-			CancelOutDetailId:         its.ID,
4073
-			ExpireDate:                its.ExpiryDate,
4074
-			ProductDate:               its.ProductDate,
4075
-			MaxUnit:                   its.MaxUnit,
4076
-			MinUnit:                   "",
4077
-			StockMaxNumber:            0,
4078
-			StockMinNumber:            0,
4079
-			LastStockMaxNumber:        0,
4080
-			LastStockMinNumber:        0,
4081
-			AdviceId:                  0,
4082
-			SupplyWarehouseId:         0,
4083
-			SupplyCancelOutId:         0,
4084
-			SupplyWarehouseDetailInfo: 0,
4085
-			StorehouseId:              its.StorehouseId,
4086
-			SecondWarehouseInfoId:     0,
4087
-			AdminUserId:               0,
4088
-			LastPrice:                 0,
4089
-			StockCount:                "",
4090
-			PharmacyId:                0,
4091
-		}
4092
-		service.CreateDrugFlowOne(drugFlow)
4093
-
4094
 		medical, _ := service.GetBaseDrugMedical(its.DrugId)
4069
 		medical, _ := service.GetBaseDrugMedical(its.DrugId)
4095
 		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4070
 		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4096
 			var sum_cancel_count int64
4071
 			var sum_cancel_count int64
4097
 			sum_cancel_count += its.Count * medical.MinNumber
4072
 			sum_cancel_count += its.Count * medical.MinNumber
4098
-			//退库数量增加
4099
-			//service.ModifyAddCancelAddInfomation(its.DrugId,sum_cancel_count,its.OrgId,its.StorehouseId)
4100
 			//出库数量减少
4073
 			//出库数量减少
4101
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, sum_cancel_count, its.OrgId, its.StorehouseId)
4074
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, sum_cancel_count, its.OrgId, its.StorehouseId)
4102
 		}
4075
 		}
4103
 
4076
 
4104
 		if its.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4077
 		if its.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4105
-			//退库数量增加
4106
-			//service.ModifyAddCancelAddInfomation(its.DrugId,its.Count,its.OrgId,its.StorehouseId)
4107
 			//出库数量减少
4078
 			//出库数量减少
4108
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4079
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4109
 		}
4080
 		}
4110
 
4081
 
4111
 		if its.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4082
 		if its.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4112
-			//退库数量增加
4113
-			//service.ModifyAddCancelAddInfomation(its.DrugId,its.Count,its.OrgId,its.StorehouseId)
4114
 			//出库数量减少
4083
 			//出库数量减少
4115
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4084
 			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4116
 		}
4085
 		}
4137
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, its.OrgId, its.DrugId)
4106
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, its.OrgId, its.DrugId)
4138
 		var sum_count int64
4107
 		var sum_count int64
4139
 		for _, its := range stockInfo {
4108
 		for _, its := range stockInfo {
4140
-			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
4109
+			baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
4110
+			if its.MaxUnit == baseDrug.MaxUnit {
4111
+				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
4112
+			}
4113
+			sum_count += its.StockMaxNumber + its.StockMinNumber
4141
 		}
4114
 		}
4115
+		//更新剩余库存
4142
 		service.UpdateBaseDrugSumTwo(its.DrugId, sum_count, its.OrgId)
4116
 		service.UpdateBaseDrugSumTwo(its.DrugId, sum_count, its.OrgId)
4143
 
4117
 
4144
 		var cancel_count int64
4118
 		var cancel_count int64
4154
 		}
4128
 		}
4155
 		cancelInfo, _ := service.GetDrugAllStockInfo(its.StorehouseId, its.OrgId, its.DrugId)
4129
 		cancelInfo, _ := service.GetDrugAllStockInfo(its.StorehouseId, its.OrgId, its.DrugId)
4156
 		var over_count int64
4130
 		var over_count int64
4157
-		for _, items := range cancelInfo {
4158
-			over_count += items.StockMaxNumber*medical.MinNumber + items.StockMinNumber
4131
+		for _, its := range cancelInfo {
4132
+			if its.MaxUnit == medical.MaxUnit {
4133
+				its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
4134
+			}
4135
+			over_count += its.StockMaxNumber + its.StockMinNumber
4159
 		}
4136
 		}
4137
+		//查询该批次的退库数量
4138
+		drugFlow := models.DrugFlow{
4139
+			ID:                        0,
4140
+			WarehousingId:             its.BatchNumberId,
4141
+			DrugId:                    its.DrugId,
4142
+			Number:                    its.Number,
4143
+			BatchNumber:               "",
4144
+			Count:                     its.Count,
4145
+			UserOrgId:                 its.OrgId,
4146
+			PatientId:                 0,
4147
+			SystemTime:                cancelDrugStock.ReturnTime,
4148
+			ConsumableType:            4,
4149
+			IsSys:                     0,
4150
+			WarehousingOrder:          "",
4151
+			WarehouseOutId:            0,
4152
+			WarehouseOutOrderNumber:   "",
4153
+			IsEdit:                    0,
4154
+			CancelStockId:             0,
4155
+			CancelOrderNumber:         its.OrderNumber,
4156
+			Manufacturer:              manufacturer_id,
4157
+			Dealer:                    dealer_id,
4158
+			Creator:                   creater,
4159
+			UpdateCreator:             0,
4160
+			Status:                    1,
4161
+			Ctime:                     time.Now().Unix(),
4162
+			Mtime:                     0,
4163
+			Price:                     its.Price,
4164
+			WarehousingDetailId:       its.BatchNumberId,
4165
+			WarehouseOutDetailId:      0,
4166
+			CancelOutDetailId:         its.ID,
4167
+			ExpireDate:                its.ExpiryDate,
4168
+			ProductDate:               its.ProductDate,
4169
+			MaxUnit:                   its.MaxUnit,
4170
+			MinUnit:                   "",
4171
+			StockMaxNumber:            0,
4172
+			StockMinNumber:            0,
4173
+			LastStockMaxNumber:        0,
4174
+			LastStockMinNumber:        0,
4175
+			AdviceId:                  0,
4176
+			SupplyWarehouseId:         0,
4177
+			SupplyCancelOutId:         0,
4178
+			SupplyWarehouseDetailInfo: 0,
4179
+			StorehouseId:              its.StorehouseId,
4180
+			SecondWarehouseInfoId:     0,
4181
+			AdminUserId:               0,
4182
+			LastPrice:                 0,
4183
+			StockCount:                "",
4184
+			PharmacyId:                0,
4185
+			OverCount:                 over_count,
4186
+		}
4187
+		service.CreateDrugFlowOne(drugFlow)
4188
+		//增加退库数量 更新剩余库存
4160
 		service.AddCancelSumCount(its.StorehouseId, its.DrugId, its.OrgId, cancel_count, over_count)
4189
 		service.AddCancelSumCount(its.StorehouseId, its.DrugId, its.OrgId, cancel_count, over_count)
4161
-
4190
+		//更改审核状态
4162
 		service.ModifyCancelStock(cancelstock_id, cancelStock, orgId)
4191
 		service.ModifyCancelStock(cancelstock_id, cancelStock, orgId)
4163
 	}
4192
 	}
4164
 	//新增库存
4193
 	//新增库存
4218
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
4247
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
4219
 		var sum_count int64
4248
 		var sum_count int64
4220
 		for _, its := range stockInfo {
4249
 		for _, its := range stockInfo {
4221
-			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
4250
+			if its.MaxUnit == medical.MaxUnit {
4251
+				its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
4252
+			}
4253
+			sum_count += its.StockMaxNumber + its.StockMinNumber
4222
 		}
4254
 		}
4255
+
4223
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
4256
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
4224
 
4257
 
4225
 		var cancel_count int64
4258
 		var cancel_count int64
4235
 		}
4268
 		}
4236
 		cancelInfo, _ := service.GetDrugAllStockInfo(item.StorehouseId, item.OrgId, item.DrugId)
4269
 		cancelInfo, _ := service.GetDrugAllStockInfo(item.StorehouseId, item.OrgId, item.DrugId)
4237
 		var over_count int64
4270
 		var over_count int64
4238
-		for _, items := range cancelInfo {
4239
-			over_count += items.StockMaxNumber*medical.MinNumber + items.StockMinNumber
4271
+		for _, its := range cancelInfo {
4272
+			if its.MaxUnit == medical.MaxUnit {
4273
+				its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
4274
+			}
4275
+			over_count += its.StockMaxNumber + its.StockMinNumber
4240
 		}
4276
 		}
4277
+
4241
 		//退库数量减少,更新剩余库存
4278
 		//退库数量减少,更新剩余库存
4242
 		service.ReduceCancelSumCount(item.StorehouseId, item.DrugId, item.OrgId, cancel_count, over_count)
4279
 		service.ReduceCancelSumCount(item.StorehouseId, item.DrugId, item.OrgId, cancel_count, over_count)
4243
 	}
4280
 	}

+ 3 - 3
controllers/gobal_config_api_controller.go Ver arquivo

70
 	beego.Router("/api/hisstockpriceconfig/get", &GobalConfigApiController{}, "get:GetHisStockPriceConfig")
70
 	beego.Router("/api/hisstockpriceconfig/get", &GobalConfigApiController{}, "get:GetHisStockPriceConfig")
71
 	beego.Router("/api/hisstockpriceconfig/isopen", &GobalConfigApiController{}, "post:PostHisStockPriceConfig")
71
 	beego.Router("/api/hisstockpriceconfig/isopen", &GobalConfigApiController{}, "post:PostHisStockPriceConfig")
72
 
72
 
73
-	beego.Router("/api/xtconfig/get", &GobalConfigApiController{}, "get:GetXTHisConfig")
74
-	beego.Router("/api/xtconfig/isopen", &GobalConfigApiController{}, "post:PostXTHisConfig")
75
-
76
 	beego.Router("/api/xtconfigproject/isopen", &GobalConfigApiController{}, "post:PostXTHisProjectConfig")
73
 	beego.Router("/api/xtconfigproject/isopen", &GobalConfigApiController{}, "post:PostXTHisProjectConfig")
77
 
74
 
78
 	beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
75
 	beego.Router("/api/isopen/init", &GobalConfigApiController{}, "get:GetAllIsOpenConfig")
2338
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2335
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2339
 	//list, _ := service.GetExportOutOrderDrugList(ids)
2336
 	//list, _ := service.GetExportOutOrderDrugList(ids)
2340
 	list, _ := service.GetExportOutOrderDrugListOne(ids)
2337
 	list, _ := service.GetExportOutOrderDrugListOne(ids)
2338
+	outInfoList, _ := service.GetDrugOutListFlow(ids, orgId)
2341
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2339
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2342
 	dealerList, _ := service.GetAllDealerList(orgId)
2340
 	dealerList, _ := service.GetAllDealerList(orgId)
2343
 	c.ServeSuccessJSON(map[string]interface{}{
2341
 	c.ServeSuccessJSON(map[string]interface{}{
2344
 		"list":             list,
2342
 		"list":             list,
2345
 		"manufacturerList": manufacturerList,
2343
 		"manufacturerList": manufacturerList,
2346
 		"dealerList":       dealerList,
2344
 		"dealerList":       dealerList,
2345
+		"outInfoList":      outInfoList,
2347
 	})
2346
 	})
2348
 }
2347
 }
2349
 
2348
 
2381
 	stock_type, _ := c.GetInt64("stock_type")
2380
 	stock_type, _ := c.GetInt64("stock_type")
2382
 
2381
 
2383
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2382
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2383
+	fmt.Println("listwowoowowowowowo", list)
2384
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2384
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2385
 	dealerList, _ := service.GetAllDealerList(orgId)
2385
 	dealerList, _ := service.GetAllDealerList(orgId)
2386
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2386
 	medical, _ := service.GetBaseDrugMedical(drug_id)

+ 317 - 165
controllers/his_api_controller.go Ver arquivo

1269
 														c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1269
 														c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
1270
 														return
1270
 														return
1271
 													}
1271
 													}
1272
-													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 {
1272
+													if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 3877 || adminInfo.CurrentOrgId == 9671 {
1273
 														// 查询该药品最后一次出库记录
1273
 														// 查询该药品最后一次出库记录
1274
 														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1274
 														outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
1275
 
1275
 
1358
 													var sum_count int64
1358
 													var sum_count int64
1359
 													stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1359
 													stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
1360
 													for _, its := range stockInfo {
1360
 													for _, its := range stockInfo {
1361
-														sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
1361
+														if its.MaxUnit == drug.MaxUnit {
1362
+															its.StockMaxNumber = its.StockMaxNumber * drug.MinNumber
1363
+														}
1364
+														sum_count += its.StockMaxNumber + its.StockMinNumber
1362
 													}
1365
 													}
1366
+
1363
 													service.UpdateBaseDrugSumTwo(drug_id, sum_count, druginfo.OrgId)
1367
 													service.UpdateBaseDrugSumTwo(drug_id, sum_count, druginfo.OrgId)
1364
 
1368
 
1365
 												}
1369
 												}
1617
 										goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
1621
 										goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
1618
 
1622
 
1619
 										for _, item := range goodList {
1623
 										for _, item := range goodList {
1620
-											//回退库存
1621
-											//service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1622
-
1623
-											//service.ModifyReduceGoodSumCount(item.StorehouseId,item.Count,item.OrgId,item.GoodId)
1624
 
1624
 
1625
 											goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1625
 											goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1626
 											var flush_count int64
1626
 											var flush_count int64
1663
 											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
1663
 											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
1664
 
1664
 
1665
 											for _, item := range goodList {
1665
 											for _, item := range goodList {
1666
-												//回退库存
1667
-												//service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1668
-												//扣减出库数量
1669
-												//service.ModifyReduceGoodSumCount(item.StorehouseId,item.Count,item.OrgId,item.GoodId)
1670
 
1666
 
1671
 												goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1667
 												goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1672
 												var flush_count int64
1668
 												var flush_count int64
1994
 					projects := items["project"].([]interface{})
1990
 					projects := items["project"].([]interface{})
1995
 					if len(projects) > 0 {
1991
 					if len(projects) > 0 {
1996
 						for _, project := range projects {
1992
 						for _, project := range projects {
1993
+
1997
 							var p models.HisPrescriptionProject
1994
 							var p models.HisPrescriptionProject
1998
 							p.PrescriptionId = tempPrescription.ID
1995
 							p.PrescriptionId = tempPrescription.ID
1999
 							p.Ctime = time.Now().Unix()
1996
 							p.Ctime = time.Now().Unix()
2011
 								c.ServeFailJSONWithSGJErrorCode(errcode)
2008
 								c.ServeFailJSONWithSGJErrorCode(errcode)
2012
 								return
2009
 								return
2013
 							}
2010
 							}
2014
-
2011
+							fmt.Println("projext22222222222222", p.ID)
2012
+							if p.ID == 0 {
2013
+								p.IsOut = 2
2014
+							}
2015
+							if p.ID > 0 {
2016
+								projectDetail, _ := service.GetHisPrescriptonProjectById(p.ID)
2017
+								p.IsOut = projectDetail.IsOut
2018
+							}
2015
 							service.CreateHisProjectTwo(&p)
2019
 							service.CreateHisProjectTwo(&p)
2016
 							projectList = append(projectList, p)
2020
 							projectList = append(projectList, p)
2017
 							var randNum int
2021
 							var randNum int
2164
 						}
2168
 						}
2165
 						sum_count += its.StockMaxNumber + its.StockMinNumber
2169
 						sum_count += its.StockMaxNumber + its.StockMinNumber
2166
 					}
2170
 					}
2171
+					//更新基础库存
2167
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2172
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2168
 					//剩余库存
2173
 					//剩余库存
2169
 					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count)
2174
 					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count)
2520
 		for _, item := range projects {
2525
 		for _, item := range projects {
2521
 			service.DeletePrintInfo(item.ID) //删除打印信息
2526
 			service.DeletePrintInfo(item.ID) //删除打印信息
2522
 			if stockConfig.IsOpen == 1 {
2527
 			if stockConfig.IsOpen == 1 {
2523
-				if item.Type == 3 {
2528
+				if item.Type == 3 && item.IsOut == 1 {
2524
 					good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
2529
 					good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
2525
 					f_count, _ := strconv.ParseFloat(item.Count, 64)
2530
 					f_count, _ := strconv.ParseFloat(item.Count, 64)
2526
 					good.Total = good.Total + f_count
2531
 					good.Total = good.Total + f_count
2558
 					manufacturer, _ := service.GetManufactureById(info.Manufacturer)
2563
 					manufacturer, _ := service.GetManufactureById(info.Manufacturer)
2559
 					deaerler, _ := service.GetDealerById(info.Dealer)
2564
 					deaerler, _ := service.GetDealerById(info.Dealer)
2560
 
2565
 
2561
-					//查询今日该患者开了多少耗材
2562
-					//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2563
-					//
2564
 					var total_count int64
2566
 					var total_count int64
2565
-					//var cha_count int64
2566
-					//for _, item := range projectList {
2567
-					//  count, _ := strconv.ParseInt(item.Count, 10, 64)
2568
-					//  total_count += count
2569
-					//}
2570
 					count, _ := strconv.ParseInt(item.Count, 10, 64)
2567
 					count, _ := strconv.ParseInt(item.Count, 10, 64)
2571
 					total_count += count
2568
 					total_count += count
2572
-					//回退库存
2573
-					service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count, info.PatientId, info.SysRecordTime, info.ProjectId)
2574
-					goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, info.ProjectId)
2569
+
2570
+					goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId)
2575
 					var flush_count int64
2571
 					var flush_count int64
2576
 					for _, it := range goodList {
2572
 					for _, it := range goodList {
2577
 						flush_count += it.StockCount
2573
 						flush_count += it.StockCount
2578
 					}
2574
 					}
2579
 					if info.ID > 0 {
2575
 					if info.ID > 0 {
2580
-						cancelStockInfo := models.CancelStockInfo{
2581
-							GoodId:          item.ProjectId,
2582
-							CancelStockId:   cancel.ID,
2583
-							GoodTypeId:      good.GoodTypeId,
2584
-							Count:           prescribingNumber,
2585
-							Price:           info.Price,
2586
-							Total:           0,
2587
-							ProductDate:     info.ProductDate,
2588
-							ExpiryDate:      info.ExpiryDate,
2589
-							Ctime:           time.Now().Unix(),
2590
-							Status:          1,
2591
-							OrgId:           c.GetAdminUserInfo().CurrentOrgId,
2592
-							OrderNumber:     cancel.OrderNumber,
2593
-							Type:            0,
2594
-							Dealer:          deaerler.DealerName,
2595
-							Manufacturer:    manufacturer.ManufacturerName,
2596
-							Number:          info.Number,
2597
-							RegisterAccount: "",
2598
-							Remark:          "",
2599
-							WarehouseInfoId: info.WarehouseInfotId,
2600
-							PatientId:       info.PatientId,
2601
-							RecordDate:      info.SysRecordTime,
2602
-							StorehouseId:    houseConfig.StorehouseOutInfo,
2603
-							IsCheck:         1,
2576
+						if info.Count >= total_count {
2577
+
2578
+							//回退库存
2579
+							service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count, info.PatientId, info.SysRecordTime, item.ProjectId)
2580
+							cancelStockInfo := models.CancelStockInfo{
2581
+								GoodId:          item.ProjectId,
2582
+								CancelStockId:   cancel.ID,
2583
+								GoodTypeId:      good.GoodTypeId,
2584
+								Count:           prescribingNumber,
2585
+								Price:           info.Price,
2586
+								Total:           0,
2587
+								ProductDate:     info.ProductDate,
2588
+								ExpiryDate:      info.ExpiryDate,
2589
+								Ctime:           time.Now().Unix(),
2590
+								Status:          1,
2591
+								OrgId:           c.GetAdminUserInfo().CurrentOrgId,
2592
+								OrderNumber:     cancel.OrderNumber,
2593
+								Type:            0,
2594
+								Dealer:          deaerler.DealerName,
2595
+								Manufacturer:    manufacturer.ManufacturerName,
2596
+								Number:          info.Number,
2597
+								RegisterAccount: "",
2598
+								Remark:          "",
2599
+								WarehouseInfoId: info.WarehouseInfotId,
2600
+								PatientId:       info.PatientId,
2601
+								RecordDate:      info.SysRecordTime,
2602
+								StorehouseId:    houseConfig.StorehouseOutInfo,
2603
+								IsCheck:         1,
2604
+							}
2605
+
2606
+							service.CreateCancelStockInfoOne(&cancelStockInfo)
2607
+
2608
+							cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.ProjectId)
2609
+
2610
+							flow := models.VmStockFlow{
2611
+								WarehousingId:           info.WarehouseInfotId,
2612
+								GoodId:                  item.ProjectId,
2613
+								Number:                  info.Number,
2614
+								LicenseNumber:           info.LicenseNumber,
2615
+								Count:                   prescribingNumber,
2616
+								UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
2617
+								PatientId:               item.PatientId,
2618
+								SystemTime:              info.SysRecordTime,
2619
+								ConsumableType:          7,
2620
+								IsSys:                   0,
2621
+								WarehousingOrder:        "",
2622
+								WarehouseOutId:          info.WarehouseOutId,
2623
+								WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2624
+								IsEdit:                  0,
2625
+								CancelStockId:           cancel.ID,
2626
+								CancelOrderNumber:       cancel.OrderNumber,
2627
+								Manufacturer:            manufacturer.ID,
2628
+								Dealer:                  0,
2629
+								Creator:                 c.GetAdminUserInfo().CurrentOrgId,
2630
+								UpdateCreator:           0,
2631
+								Status:                  1,
2632
+								Ctime:                   time.Now().Unix(),
2633
+								Mtime:                   0,
2634
+								Price:                   info.Price,
2635
+								WarehousingDetailId:     info.WarehouseInfotId,
2636
+								WarehouseOutDetailId:    info.ID,
2637
+								CancelOutDetailId:       cancelInfo.ID,
2638
+								ProductDate:             info.ProductDate,
2639
+								ExpireDate:              info.ExpiryDate,
2640
+								StorehouseId:            houseConfig.StorehouseOutInfo,
2641
+								OverCount:               flush_count,
2642
+							}
2643
+							service.CreateStockFlowOne(flow)
2644
+
2645
+							//退库数量增加
2646
+							service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
2647
+							//出库数量减少
2648
+							service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, total_count)
2604
 						}
2649
 						}
2605
 
2650
 
2606
-						service.CreateCancelStockInfoOne(&cancelStockInfo)
2607
-
2608
-						cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.ProjectId)
2609
-
2610
-						flow := models.VmStockFlow{
2611
-							WarehousingId:           info.WarehouseInfotId,
2612
-							GoodId:                  item.ProjectId,
2613
-							Number:                  info.Number,
2614
-							LicenseNumber:           info.LicenseNumber,
2615
-							Count:                   prescribingNumber,
2616
-							UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
2617
-							PatientId:               item.PatientId,
2618
-							SystemTime:              info.SysRecordTime,
2619
-							ConsumableType:          7,
2620
-							IsSys:                   0,
2621
-							WarehousingOrder:        "",
2622
-							WarehouseOutId:          info.WarehouseOutId,
2623
-							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2624
-							IsEdit:                  0,
2625
-							CancelStockId:           cancel.ID,
2626
-							CancelOrderNumber:       cancel.OrderNumber,
2627
-							Manufacturer:            manufacturer.ID,
2628
-							Dealer:                  0,
2629
-							Creator:                 c.GetAdminUserInfo().CurrentOrgId,
2630
-							UpdateCreator:           0,
2631
-							Status:                  1,
2632
-							Ctime:                   time.Now().Unix(),
2633
-							Mtime:                   0,
2634
-							Price:                   info.Price,
2635
-							WarehousingDetailId:     info.WarehouseInfotId,
2636
-							WarehouseOutDetailId:    info.ID,
2637
-							CancelOutDetailId:       cancelInfo.ID,
2638
-							ProductDate:             info.ProductDate,
2639
-							ExpireDate:              info.ExpiryDate,
2640
-							StorehouseId:            houseConfig.StorehouseOutInfo,
2641
-							OverCount:               flush_count,
2651
+						if info.Count < total_count {
2652
+							//回退库存
2653
+							service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, info.Count, info.PatientId, info.SysRecordTime, item.ProjectId)
2654
+							cancelStockInfo := models.CancelStockInfo{
2655
+								GoodId:          item.ProjectId,
2656
+								CancelStockId:   cancel.ID,
2657
+								GoodTypeId:      good.GoodTypeId,
2658
+								Count:           info.Count,
2659
+								Price:           info.Price,
2660
+								Total:           0,
2661
+								ProductDate:     info.ProductDate,
2662
+								ExpiryDate:      info.ExpiryDate,
2663
+								Ctime:           time.Now().Unix(),
2664
+								Status:          1,
2665
+								OrgId:           c.GetAdminUserInfo().CurrentOrgId,
2666
+								OrderNumber:     cancel.OrderNumber,
2667
+								Type:            0,
2668
+								Dealer:          deaerler.DealerName,
2669
+								Manufacturer:    manufacturer.ManufacturerName,
2670
+								Number:          info.Number,
2671
+								RegisterAccount: "",
2672
+								Remark:          "",
2673
+								WarehouseInfoId: info.WarehouseInfotId,
2674
+								PatientId:       info.PatientId,
2675
+								RecordDate:      info.SysRecordTime,
2676
+								StorehouseId:    houseConfig.StorehouseOutInfo,
2677
+								IsCheck:         1,
2678
+							}
2679
+
2680
+							service.CreateCancelStockInfoOne(&cancelStockInfo)
2681
+
2682
+							cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.ProjectId)
2683
+
2684
+							flow := models.VmStockFlow{
2685
+								WarehousingId:           info.WarehouseInfotId,
2686
+								GoodId:                  item.ProjectId,
2687
+								Number:                  info.Number,
2688
+								LicenseNumber:           info.LicenseNumber,
2689
+								Count:                   info.Count,
2690
+								UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
2691
+								PatientId:               item.PatientId,
2692
+								SystemTime:              info.SysRecordTime,
2693
+								ConsumableType:          7,
2694
+								IsSys:                   0,
2695
+								WarehousingOrder:        "",
2696
+								WarehouseOutId:          info.WarehouseOutId,
2697
+								WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2698
+								IsEdit:                  0,
2699
+								CancelStockId:           cancel.ID,
2700
+								CancelOrderNumber:       cancel.OrderNumber,
2701
+								Manufacturer:            manufacturer.ID,
2702
+								Dealer:                  0,
2703
+								Creator:                 c.GetAdminUserInfo().CurrentOrgId,
2704
+								UpdateCreator:           0,
2705
+								Status:                  1,
2706
+								Ctime:                   time.Now().Unix(),
2707
+								Mtime:                   0,
2708
+								Price:                   info.Price,
2709
+								WarehousingDetailId:     info.WarehouseInfotId,
2710
+								WarehouseOutDetailId:    info.ID,
2711
+								CancelOutDetailId:       cancelInfo.ID,
2712
+								ProductDate:             info.ProductDate,
2713
+								ExpireDate:              info.ExpiryDate,
2714
+								StorehouseId:            houseConfig.StorehouseOutInfo,
2715
+								OverCount:               flush_count,
2716
+							}
2717
+							service.CreateStockFlowOne(flow)
2718
+
2719
+							//退库数量增加
2720
+							service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, info.Count)
2721
+							//出库数量减少
2722
+							service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, info.Count)
2642
 						}
2723
 						}
2643
-						service.CreateStockFlowOne(flow)
2644
 
2724
 
2645
 						//查询已出库数量
2725
 						//查询已出库数量
2646
-						dialysisInfo, _ := service.GetGoodDialysisOutInfo(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2726
+						dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2647
 
2727
 
2648
 						if prescribingNumber < dialysisInfo.Count {
2728
 						if prescribingNumber < dialysisInfo.Count {
2649
 							//改变数量
2729
 							//改变数量
2650
 							service.UpdateAutoGood(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID, prescribingNumber)
2730
 							service.UpdateAutoGood(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID, prescribingNumber)
2651
 						}
2731
 						}
2652
 
2732
 
2653
-						if prescribingNumber == dialysisInfo.Count {
2733
+						if prescribingNumber >= dialysisInfo.Count {
2654
 							//删除出库表
2734
 							//删除出库表
2655
 							service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2735
 							service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2656
 						}
2736
 						}
2657
 
2737
 
2658
-						////删除出库表
2659
-						//service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2660
-
2661
-						//退库数量增加
2662
-						service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.ProjectId, houseConfig.StorehouseOutInfo, total_count)
2663
-						//出库数量减少
2664
-						service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, total_count)
2665
-
2666
 						//更新库存
2738
 						//更新库存
2667
 						service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count)
2739
 						service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count)
2668
 
2740
 
2741
+						//更新基础库库存
2742
+						service.UpdateGoodInfoSumCountSix(item.ProjectId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
2669
 						//查询今日该耗材退库数量
2743
 						//查询今日该耗材退库数量
2670
 						//cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2744
 						//cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2671
 						//var cancel_Count int64
2745
 						//var cancel_Count int64
2926
 			fmt.Println(err)
3000
 			fmt.Println(err)
2927
 		}
3001
 		}
2928
 
3002
 
2929
-		if project.Type == 3 {
3003
+		if project.Type == 3 && project.IsOut == 1 {
2930
 			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
3004
 			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2931
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3005
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2932
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
3006
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2965
 			manufacturer, _ := service.GetManufactureById(info.Manufacturer)
3039
 			manufacturer, _ := service.GetManufactureById(info.Manufacturer)
2966
 			deaerler, _ := service.GetDealerById(info.Dealer)
3040
 			deaerler, _ := service.GetDealerById(info.Dealer)
2967
 			if info.ID > 0 {
3041
 			if info.ID > 0 {
2968
-				cancelStockInfo := models.CancelStockInfo{
2969
-					GoodId:          project.ProjectId,
2970
-					CancelStockId:   cancel.ID,
2971
-					GoodTypeId:      good.GoodTypeId,
2972
-					Count:           prescribingNumber,
2973
-					Price:           info.Price,
2974
-					Total:           0,
2975
-					ProductDate:     info.ProductDate,
2976
-					ExpiryDate:      info.ExpiryDate,
2977
-					Ctime:           time.Now().Unix(),
2978
-					Status:          1,
2979
-					OrgId:           adminInfo.CurrentOrgId,
2980
-					OrderNumber:     cancel.OrderNumber,
2981
-					Type:            0,
2982
-					Dealer:          deaerler.DealerName,
2983
-					Manufacturer:    manufacturer.ManufacturerName,
2984
-					Number:          info.Number,
2985
-					RegisterAccount: "",
2986
-					Remark:          "",
2987
-					WarehouseInfoId: info.WarehouseInfotId,
2988
-					PatientId:       info.PatientId,
2989
-					RecordDate:      info.SysRecordTime,
2990
-					StorehouseId:    houseConfig.StorehouseOutInfo,
2991
-					IsCheck:         1,
2992
-				}
2993
-
2994
-				service.CreateCancelStockInfoOne(&cancelStockInfo)
2995
-
2996
 				cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(project.ProjectId)
3042
 				cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(project.ProjectId)
3043
+				if info.Count >= prescribingNumber {
3044
+					cancelStockInfo := models.CancelStockInfo{
3045
+						GoodId:          project.ProjectId,
3046
+						CancelStockId:   cancel.ID,
3047
+						GoodTypeId:      good.GoodTypeId,
3048
+						Count:           prescribingNumber,
3049
+						Price:           info.Price,
3050
+						Total:           0,
3051
+						ProductDate:     info.ProductDate,
3052
+						ExpiryDate:      info.ExpiryDate,
3053
+						Ctime:           time.Now().Unix(),
3054
+						Status:          1,
3055
+						OrgId:           adminInfo.CurrentOrgId,
3056
+						OrderNumber:     cancel.OrderNumber,
3057
+						Type:            0,
3058
+						Dealer:          deaerler.DealerName,
3059
+						Manufacturer:    manufacturer.ManufacturerName,
3060
+						Number:          info.Number,
3061
+						RegisterAccount: "",
3062
+						Remark:          "",
3063
+						WarehouseInfoId: info.WarehouseInfotId,
3064
+						PatientId:       info.PatientId,
3065
+						RecordDate:      info.SysRecordTime,
3066
+						StorehouseId:    houseConfig.StorehouseOutInfo,
3067
+						IsCheck:         1,
3068
+					}
3069
+
3070
+					service.CreateCancelStockInfoOne(&cancelStockInfo)
3071
+					//回退库存
3072
+					service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, prescribingNumber, info.PatientId, info.SysRecordTime, project.ProjectId)
3073
+					//退库数量增加
3074
+					service.UpdateSumAddCancelCount(adminInfo.CurrentOrgId, project.ProjectId, houseConfig.StorehouseOutInfo, prescribingNumber)
3075
+					//出库数量减少
3076
+					service.UpdateSumCount(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, prescribingNumber)
3077
+				}
3078
+				if info.Count < prescribingNumber {
3079
+					cancelStockInfo := models.CancelStockInfo{
3080
+						GoodId:          project.ProjectId,
3081
+						CancelStockId:   cancel.ID,
3082
+						GoodTypeId:      good.GoodTypeId,
3083
+						Count:           info.Count,
3084
+						Price:           info.Price,
3085
+						Total:           0,
3086
+						ProductDate:     info.ProductDate,
3087
+						ExpiryDate:      info.ExpiryDate,
3088
+						Ctime:           time.Now().Unix(),
3089
+						Status:          1,
3090
+						OrgId:           adminInfo.CurrentOrgId,
3091
+						OrderNumber:     cancel.OrderNumber,
3092
+						Type:            0,
3093
+						Dealer:          deaerler.DealerName,
3094
+						Manufacturer:    manufacturer.ManufacturerName,
3095
+						Number:          info.Number,
3096
+						RegisterAccount: "",
3097
+						Remark:          "",
3098
+						WarehouseInfoId: info.WarehouseInfotId,
3099
+						PatientId:       info.PatientId,
3100
+						RecordDate:      info.SysRecordTime,
3101
+						StorehouseId:    houseConfig.StorehouseOutInfo,
3102
+						IsCheck:         1,
3103
+					}
3104
+
3105
+					service.CreateCancelStockInfoOne(&cancelStockInfo)
3106
+					//回退库存
3107
+					service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, info.Count, info.PatientId, info.SysRecordTime, project.ProjectId)
3108
+					//退库数量增加
3109
+					service.UpdateSumAddCancelCount(adminInfo.CurrentOrgId, project.ProjectId, houseConfig.StorehouseOutInfo, info.Count)
3110
+					//出库数量减少
3111
+					service.UpdateSumCount(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, info.Count)
3112
+				}
2997
 
3113
 
2998
-				//回退库存
2999
-				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, prescribingNumber, info.PatientId, info.SysRecordTime, project.ProjectId)
3000
 				goodList, _ := service.GetSumGoodList(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId)
3114
 				goodList, _ := service.GetSumGoodList(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId)
3001
 				var over_count int64
3115
 				var over_count int64
3002
 				for _, it := range goodList {
3116
 				for _, it := range goodList {
3003
 					over_count += it.StockCount
3117
 					over_count += it.StockCount
3004
 				}
3118
 				}
3005
-				flow := models.VmStockFlow{
3006
-					WarehousingId:           info.WarehouseInfotId,
3007
-					GoodId:                  project.ProjectId,
3008
-					Number:                  info.Number,
3009
-					LicenseNumber:           info.LicenseNumber,
3010
-					Count:                   prescribingNumber,
3011
-					UserOrgId:               adminInfo.CurrentOrgId,
3012
-					PatientId:               project.PatientId,
3013
-					SystemTime:              time.Now().Unix(),
3014
-					ConsumableType:          7,
3015
-					IsSys:                   0,
3016
-					WarehousingOrder:        "",
3017
-					WarehouseOutId:          info.WarehouseOutId,
3018
-					WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
3019
-					IsEdit:                  0,
3020
-					CancelStockId:           cancel.ID,
3021
-					CancelOrderNumber:       cancel.OrderNumber,
3022
-					Manufacturer:            manufacturer.ID,
3023
-					Dealer:                  0,
3024
-					Creator:                 adminInfo.AdminUser.Id,
3025
-					UpdateCreator:           0,
3026
-					Status:                  1,
3027
-					Ctime:                   time.Now().Unix(),
3028
-					Mtime:                   0,
3029
-					Price:                   info.Price,
3030
-					WarehousingDetailId:     info.WarehouseInfotId,
3031
-					WarehouseOutDetailId:    info.ID,
3032
-					CancelOutDetailId:       cancelInfo.ID,
3033
-					ProductDate:             info.ProductDate,
3034
-					ExpireDate:              info.ExpiryDate,
3035
-					StorehouseId:            houseConfig.StorehouseOutInfo,
3036
-					OverCount:               over_count,
3119
+				if info.Count >= prescribingNumber {
3120
+					flow := models.VmStockFlow{
3121
+						WarehousingId:           info.WarehouseInfotId,
3122
+						GoodId:                  project.ProjectId,
3123
+						Number:                  info.Number,
3124
+						LicenseNumber:           info.LicenseNumber,
3125
+						Count:                   prescribingNumber,
3126
+						UserOrgId:               adminInfo.CurrentOrgId,
3127
+						PatientId:               project.PatientId,
3128
+						SystemTime:              info.SysRecordTime,
3129
+						ConsumableType:          7,
3130
+						IsSys:                   0,
3131
+						WarehousingOrder:        "",
3132
+						WarehouseOutId:          info.WarehouseOutId,
3133
+						WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
3134
+						IsEdit:                  0,
3135
+						CancelStockId:           cancel.ID,
3136
+						CancelOrderNumber:       cancel.OrderNumber,
3137
+						Manufacturer:            manufacturer.ID,
3138
+						Dealer:                  0,
3139
+						Creator:                 adminInfo.AdminUser.Id,
3140
+						UpdateCreator:           0,
3141
+						Status:                  1,
3142
+						Ctime:                   time.Now().Unix(),
3143
+						Mtime:                   0,
3144
+						Price:                   info.Price,
3145
+						WarehousingDetailId:     info.WarehouseInfotId,
3146
+						WarehouseOutDetailId:    info.ID,
3147
+						CancelOutDetailId:       cancelInfo.ID,
3148
+						ProductDate:             info.ProductDate,
3149
+						ExpireDate:              info.ExpiryDate,
3150
+						StorehouseId:            houseConfig.StorehouseOutInfo,
3151
+						OverCount:               over_count,
3152
+					}
3153
+					service.CreateStockFlowOne(flow)
3154
+				}
3155
+
3156
+				if info.Count < prescribingNumber {
3157
+					flow := models.VmStockFlow{
3158
+						WarehousingId:           info.WarehouseInfotId,
3159
+						GoodId:                  project.ProjectId,
3160
+						Number:                  info.Number,
3161
+						LicenseNumber:           info.LicenseNumber,
3162
+						Count:                   info.Count,
3163
+						UserOrgId:               adminInfo.CurrentOrgId,
3164
+						PatientId:               project.PatientId,
3165
+						SystemTime:              info.SysRecordTime,
3166
+						ConsumableType:          7,
3167
+						IsSys:                   0,
3168
+						WarehousingOrder:        "",
3169
+						WarehouseOutId:          info.WarehouseOutId,
3170
+						WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
3171
+						IsEdit:                  0,
3172
+						CancelStockId:           cancel.ID,
3173
+						CancelOrderNumber:       cancel.OrderNumber,
3174
+						Manufacturer:            manufacturer.ID,
3175
+						Dealer:                  0,
3176
+						Creator:                 adminInfo.AdminUser.Id,
3177
+						UpdateCreator:           0,
3178
+						Status:                  1,
3179
+						Ctime:                   time.Now().Unix(),
3180
+						Mtime:                   0,
3181
+						Price:                   info.Price,
3182
+						WarehousingDetailId:     info.WarehouseInfotId,
3183
+						WarehouseOutDetailId:    info.ID,
3184
+						CancelOutDetailId:       cancelInfo.ID,
3185
+						ProductDate:             info.ProductDate,
3186
+						ExpireDate:              info.ExpiryDate,
3187
+						StorehouseId:            houseConfig.StorehouseOutInfo,
3188
+						OverCount:               over_count,
3189
+					}
3190
+					service.CreateStockFlowOne(flow)
3037
 				}
3191
 				}
3038
-				service.CreateStockFlowOne(flow)
3039
 
3192
 
3040
 				//查询已出库数量
3193
 				//查询已出库数量
3041
-				dialysisInfo, _ := service.GetGoodDialysisOutInfo(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3194
+				dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3042
 
3195
 
3043
 				if prescribingNumber < dialysisInfo.Count {
3196
 				if prescribingNumber < dialysisInfo.Count {
3044
 					//改变数量
3197
 					//改变数量
3045
 					service.UpdateAutoGood(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId, id, prescribingNumber)
3198
 					service.UpdateAutoGood(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId, id, prescribingNumber)
3046
 				}
3199
 				}
3047
 
3200
 
3048
-				if prescribingNumber == dialysisInfo.Count {
3201
+				if prescribingNumber >= dialysisInfo.Count {
3049
 					//删除出库表
3202
 					//删除出库表
3050
 					service.DeleteAutoRedeceDetailTen(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3203
 					service.DeleteAutoRedeceDetailTen(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3051
 				}
3204
 				}
3052
 
3205
 
3053
-				//退库数量增加
3054
-				service.UpdateSumAddCancelCount(adminInfo.CurrentOrgId, project.ProjectId, houseConfig.StorehouseOutInfo, prescribingNumber)
3055
-				//出库数量减少
3056
-				service.UpdateSumCount(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, prescribingNumber)
3057
-
3058
 				//更新剩余库存
3206
 				//更新剩余库存
3059
 				service.UpdateSumGood(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, over_count)
3207
 				service.UpdateSumGood(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, over_count)
3208
+
3060
 				//查询今日该患者开了多少耗材
3209
 				//查询今日该患者开了多少耗材
3061
 				//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
3210
 				//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
3062
 				//
3211
 				//
3168
 			}
3317
 			}
3169
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3318
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3170
 			fmt.Println(err)
3319
 			fmt.Println(err)
3320
+		} else {
3321
+			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3322
+			fmt.Println(err)
3171
 		}
3323
 		}
3172
 
3324
 
3173
 	}
3325
 	}

+ 8 - 0
controllers/his_config_api_controller.go Ver arquivo

27
 
27
 
28
 func HisConfigApiRegistRouters() {
28
 func HisConfigApiRegistRouters() {
29
 	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
29
 	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
30
+	beego.Router("/api/his/patient/getpatientlisttwenty", &HisConfigApiController{}, "get:GetPatientListTwenty")
30
 	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
31
 	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
31
 	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
32
 	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
32
 	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate") //批量添加
33
 	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate") //批量添加
66
 	})
67
 	})
67
 }
68
 }
68
 
69
 
70
+func (c *HisConfigApiController) GetPatientListTwenty() {
71
+	patients, _, _ := service.GetAllPatientListTwenty(c.GetAdminUserInfo().CurrentOrgId)
72
+	c.ServeSuccessJSON(map[string]interface{}{
73
+		"list": patients,
74
+	})
75
+}
76
+
69
 func (c *HisConfigApiController) GetPrescriptionTemplateList() {
77
 func (c *HisConfigApiController) GetPrescriptionTemplateList() {
70
 	patient_id, _ := c.GetInt64("patient_id", 0)
78
 	patient_id, _ := c.GetInt64("patient_id", 0)
71
 	page, _ := c.GetInt64("page", 0)
79
 	page, _ := c.GetInt64("page", 0)

+ 14 - 5
controllers/mobile_api_controllers/check_weight_api_controller.go Ver arquivo

376
 			newprescribe.DewaterAmount = dewater_amount
376
 			newprescribe.DewaterAmount = dewater_amount
377
 			newprescribe.TargetUltrafiltration = dewater_amount
377
 			newprescribe.TargetUltrafiltration = dewater_amount
378
 			newprescribe.Status = 1
378
 			newprescribe.Status = 1
379
+			newprescribe.Remark = dialysisSolution.Remark
380
+			if adminUserInfo.Org.Id == 10340 {
381
+				newprescribe.TargetUltrafiltration = 0
382
+			}
379
 			//插入透析处方
383
 			//插入透析处方
380
 			err := service.AddSigleRecord(&newprescribe)
384
 			err := service.AddSigleRecord(&newprescribe)
381
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
385
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
443
 				newprescribe.DewaterAmount = dewater_amount
447
 				newprescribe.DewaterAmount = dewater_amount
444
 				newprescribe.TargetUltrafiltration = dewater_amount
448
 				newprescribe.TargetUltrafiltration = dewater_amount
445
 				newprescribe.Status = 1
449
 				newprescribe.Status = 1
446
-
450
+				newprescribe.Remark = lastDialysisPrescribe.Remark
451
+				if adminUserInfo.Org.Id == 10340 {
452
+					newprescribe.TargetUltrafiltration = 0
453
+				}
447
 				err := service.AddSigleRecord(&newprescribe)
454
 				err := service.AddSigleRecord(&newprescribe)
448
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
455
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
449
 				redis := service.RedisClient()
456
 				redis := service.RedisClient()
508
 				newprescribe.TargetUltrafiltration = dewater_amount
515
 				newprescribe.TargetUltrafiltration = dewater_amount
509
 				newprescribe.Status = 1
516
 				newprescribe.Status = 1
510
 
517
 
511
-				fmt.Println(newprescribe.DewaterAmount)
512
-				fmt.Println(newprescribe.TargetUltrafiltration)
513
-
518
+				if adminUserInfo.Org.Id == 10340 {
519
+					newprescribe.TargetUltrafiltration = 0
520
+				}
514
 				err := service.AddSigleRecord(&newprescribe)
521
 				err := service.AddSigleRecord(&newprescribe)
515
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
522
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
516
 				redis := service.RedisClient()
523
 				redis := service.RedisClient()
561
 			dialysisPrescribe.DewaterAmount = dewater_amount
568
 			dialysisPrescribe.DewaterAmount = dewater_amount
562
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
569
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
563
 			dialysisPrescribe.Status = 1
570
 			dialysisPrescribe.Status = 1
564
-
571
+			if adminUserInfo.Org.Id == 10340 {
572
+				dialysisPrescribe.TargetUltrafiltration = 0
573
+			}
565
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
574
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
566
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
575
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
567
 			redis := service.RedisClient()
576
 			redis := service.RedisClient()

+ 535 - 111
controllers/mobile_api_controllers/dialysis_api_controller.go Ver arquivo

87
 	defer redis.Close()
87
 	defer redis.Close()
88
 
88
 
89
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
89
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
90
-	fmt.Println("key22332323232232323", key)
91
 	scheduals_json_str, _ := redis.Get(key).Result()
90
 	scheduals_json_str, _ := redis.Get(key).Result()
92
-	redis.Set(key, "", time.Second)
91
+	redis.Set(scheduals_json_str, "", time.Second)
93
 	patients, _ := service.GetAllPatientListSix(orgID)
92
 	patients, _ := service.GetAllPatientListSix(orgID)
94
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
93
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
95
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
94
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
99
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
98
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
100
 		} else {
99
 		} else {
101
 			if len(scheduals) > 0 {
100
 			if len(scheduals) > 0 {
102
-
103
 				devices, _ := service.GetAllDevicetByListSix(orgID)
101
 				devices, _ := service.GetAllDevicetByListSix(orgID)
104
 				advices, _ := service.GetAllAdvicestByList(orgID, date.Unix())
102
 				advices, _ := service.GetAllAdvicestByList(orgID, date.Unix())
105
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
103
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
106
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
104
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
107
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
105
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
108
-
109
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
110
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
111
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
108
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
219
 			project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
216
 			project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
220
 		}
217
 		}
221
 
218
 
222
-		//获取今日透析准备的数据
223
-		//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
224
-		//fmt.Println("goodlist23323232323233232332233223323233", goodList, err)
225
-		//
226
-		//list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
227
-		//
228
-		//for _, item := range goodList {
229
-		//	for _, it := range list {
230
-		//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
231
-		//			item.Children = append(item.Children, it)
232
-		//		}
233
-		//	}
234
-		//}
235
-		//autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
236
 		this.ServeSuccessJSON(map[string]interface{}{
219
 		this.ServeSuccessJSON(map[string]interface{}{
237
 			"scheduals": dat,
220
 			"scheduals": dat,
238
 			"redis":     "true",
221
 			"redis":     "true",
239
 			"date":      schedualDate,
222
 			"date":      schedualDate,
240
 			"project":   project,
223
 			"project":   project,
241
-			//"goodList":  goodList,
242
-			//"autoList":  autoList,
243
 		})
224
 		})
244
 
225
 
245
 	}
226
 	}
574
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
555
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
575
 	}
556
 	}
576
 	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
557
 	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
558
+
559
+	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.Org.Id, patientID, date.Unix())
577
 	returnData := map[string]interface{}{
560
 	returnData := map[string]interface{}{
578
 		"patient":                        patient,
561
 		"patient":                        patient,
579
 		"schedual":                       schedual,
562
 		"schedual":                       schedual,
606
 		"team_projects":                  team_projects,
589
 		"team_projects":                  team_projects,
607
 		"is_advice_open":                 is_advice_open,
590
 		"is_advice_open":                 is_advice_open,
608
 		"prescription_open":              prescriptionConfig.IsOpen,
591
 		"prescription_open":              prescriptionConfig.IsOpen,
592
+		"lastOrder":                      lastOrder,
609
 	}
593
 	}
610
 	this.ServeSuccessJSON(returnData)
594
 	this.ServeSuccessJSON(returnData)
611
 }
595
 }
883
 
867
 
884
 	admission_number := c.GetString("admission_number")
868
 	admission_number := c.GetString("admission_number")
885
 	tumble, _ := c.GetInt64("tumble")
869
 	tumble, _ := c.GetInt64("tumble")
886
-
870
+	diacrisis := c.GetString("diacrisis")
871
+	his_department := c.GetString("his_department")
872
+	his_bed := c.GetString("his_bed")
887
 	if id <= 0 {
873
 	if id <= 0 {
888
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
874
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
889
 		return
875
 		return
937
 		PsychologicalOther:           psychological_other,
923
 		PsychologicalOther:           psychological_other,
938
 		AdmissionNumber:              admission_number,
924
 		AdmissionNumber:              admission_number,
939
 		Tumble:                       tumble,
925
 		Tumble:                       tumble,
926
+		Diacrisis:                    diacrisis,
927
+		HisBed:                       his_bed,
928
+		HisDepartment:                his_department,
940
 	}
929
 	}
941
 
930
 
942
 	if receiveTreatment.ID == 0 { //新增
931
 	if receiveTreatment.ID == 0 { //新增
1354
 	epo_count, _ := c.GetFloat("epo_count", 0)
1343
 	epo_count, _ := c.GetFloat("epo_count", 0)
1355
 
1344
 
1356
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
1345
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
1346
+	admin_user_id, _ := c.GetInt64("admin_user_id")
1347
+
1348
+	is_water := c.GetString("is_water")
1349
+	var is_war int64
1350
+	if is_water == "是" {
1351
+		is_war = 1
1352
+	}
1353
+	if is_water == "否" {
1354
+		is_war = 2
1355
+	}
1356
+	if is_water == "请选择" {
1357
+		is_war = 0
1358
+	}
1359
+	drhy_water := c.GetString("drhy_water")
1360
+
1361
+	dry_water_hour := c.GetString("dry_water_hour")
1362
+
1363
+	water_machine := c.GetString("water_machine")
1357
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1364
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1358
 
1365
 
1359
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1366
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1459
 		Epo:                        epo,
1466
 		Epo:                        epo,
1460
 		EpoCount:                   epo_count,
1467
 		EpoCount:                   epo_count,
1461
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
1468
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
1469
+		AdminUserId:                admin_user_id,
1470
+		IsWater:                    is_war,
1471
+		DrhyWater:                  drhy_water,
1472
+		DryWaterHour:               dry_water_hour,
1473
+		WaterMachine:               water_machine,
1462
 	}
1474
 	}
1463
 
1475
 
1464
 	//查询最近透析准备表里是否存在 透析器 灌流器
1476
 	//查询最近透析准备表里是否存在 透析器 灌流器
1681
 	internal_fistula := c.GetString("blood_access_internal_fistula")
1693
 	internal_fistula := c.GetString("blood_access_internal_fistula")
1682
 	catheter := c.GetString("catheter")
1694
 	catheter := c.GetString("catheter")
1683
 	cruor := c.GetString("cruor")
1695
 	cruor := c.GetString("cruor")
1696
+	mission := c.GetString("mission")
1684
 	if id <= 0 || nurseID <= 0 {
1697
 	if id <= 0 || nurseID <= 0 {
1685
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1698
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1686
 		return
1699
 		return
1772
 		//获取最后一条透析处方数据
1785
 		//获取最后一条透析处方数据
1773
 		prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1786
 		prescription, _ := service.GetLastDialysisPrescriptionByPatientIdTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1774
 		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1787
 		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.Org.Id, id, recordDate.Unix())
1775
-		tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration
1788
+		tempassessmentAfterDislysis.WeightAfter = evaluation.WeightBefore - prescription.TargetUltrafiltration/1000
1776
 	}
1789
 	}
1777
 
1790
 
1778
 	if dialysisOrder.Stage == 1 {
1791
 	if dialysisOrder.Stage == 1 {
1808
 
1821
 
1809
 	}
1822
 	}
1810
 
1823
 
1811
-	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 {
1824
+	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 {
1812
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1825
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1813
 		if evaluation.SystolicBloodPressure == 0 {
1826
 		if evaluation.SystolicBloodPressure == 0 {
1814
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1827
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1992
 		return
2005
 		return
1993
 	}
2006
 	}
1994
 	if dialysisOrder.Stage == 1 {
2007
 	if dialysisOrder.Stage == 1 {
1995
-		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor)
2008
+		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id, puncture_point_haematoma, internal_fistula, catheter, cruor, mission)
1996
 
2009
 
1997
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2010
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1998
 		redis := service.RedisClient()
2011
 		redis := service.RedisClient()
2081
 	change_nurse, _ := this.GetInt64("change_nurse")
2094
 	change_nurse, _ := this.GetInt64("change_nurse")
2082
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
2095
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
2083
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
2096
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
2097
+	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
2098
+	puncture_needle := this.GetString("puncture_needle")
2099
+	puncture_way := this.GetString("puncture_way")
2100
+	dialysis_dialyszers := this.GetString("dialysis_dialyszers")
2101
+	dialysis_irrigation := this.GetString("dialysis_irrigation")
2102
+	blood_access_id, _ := this.GetInt64("blood_access_id")
2084
 	zone_id, _ := this.GetInt64("zone_id")
2103
 	zone_id, _ := this.GetInt64("zone_id")
2104
+	elecsign := this.GetString("url")
2105
+	nuclein_date_str := this.GetString("nuclein_date_str")
2085
 
2106
 
2086
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2107
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2087
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2108
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2156
 	schedulestartTime := theStartTime.Unix()
2177
 	schedulestartTime := theStartTime.Unix()
2157
 	scheduleendTime := theEndTime.Unix()
2178
 	scheduleendTime := theEndTime.Unix()
2158
 
2179
 
2180
+	var theNucleinDate int64
2181
+	timeLayoutOne := "2006-01-02"
2182
+	if len(nuclein_date_str) > 0 {
2183
+		theTime, err := time.ParseInLocation(timeLayoutOne+" 15:04:05", nuclein_date_str+" 00:00:00", loc)
2184
+		if err != nil {
2185
+			utils.ErrorLog(err.Error())
2186
+		}
2187
+		theNucleinDate = theTime.Unix()
2188
+	}
2189
+	fmt.Println("wo2o3o23o2o2323oo232o3swo", theNucleinDate)
2159
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2190
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2160
 
2191
 
2161
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
2192
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
2264
 		DifficultPunctureNurse: difficult_puncture_nurse,
2295
 		DifficultPunctureNurse: difficult_puncture_nurse,
2265
 		NewFistulaNurse:        new_fistula_nurse,
2296
 		NewFistulaNurse:        new_fistula_nurse,
2266
 		ZoneId:                 zone_id,
2297
 		ZoneId:                 zone_id,
2298
+		QualityNurseId:         quality_nurse_id,
2299
+		PunctureNeedle:         puncture_needle,
2300
+		PunctureWay:            puncture_way,
2301
+		DialysisIrrigation:     dialysis_irrigation,
2302
+		DialysisDialyszers:     dialysis_dialyszers,
2303
+		BloodAccessId:          blood_access_id,
2304
+		Url:                    elecsign,
2305
+		NucleinDate:            theNucleinDate,
2267
 	}
2306
 	}
2268
 	//查询该床位是否有人用了
2307
 	//查询该床位是否有人用了
2269
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2308
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2270
 	if errorscode == gorm.ErrRecordNotFound {
2309
 	if errorscode == gorm.ErrRecordNotFound {
2310
+
2271
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2311
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2272
 
2312
 
2273
 		redis := service.RedisClient()
2313
 		redis := service.RedisClient()
2381
 
2421
 
2382
 	// 如果当天有插入数据,则不再往透析纪录里插入数据
2422
 	// 如果当天有插入数据,则不再往透析纪录里插入数据
2383
 	if newdialysisRecord.ID > 0 {
2423
 	if newdialysisRecord.ID > 0 {
2424
+		if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 {
2425
+			record.Temperature = 36.5
2426
+			record.ArterialPressure = -100
2427
+			record.DialysateTemperature = 36.5
2428
+			record.Conductivity = 14
2429
+			record.BreathingRate = "20"
2430
+			record.VenousPressure = 80
2431
+			record.TransmembranePressure = 60
2432
+		}
2384
 		err := service.CreateMonitor(&record)
2433
 		err := service.CreateMonitor(&record)
2385
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2434
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2386
 
2435
 
2526
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
2575
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
2527
 	pre_impulse := c.GetString("pre_impulse")
2576
 	pre_impulse := c.GetString("pre_impulse")
2528
 	impulse, _ := strconv.ParseFloat(pre_impulse, 64)
2577
 	impulse, _ := strconv.ParseFloat(pre_impulse, 64)
2578
+	admin_user_id, _ := c.GetInt64("admin_user_id")
2579
+
2580
+	is_water := c.GetString("is_water")
2581
+	var is_war int64
2582
+	if is_water == "是" {
2583
+		is_war = 1
2584
+	}
2585
+	if is_water == "否" {
2586
+		is_war = 2
2587
+	}
2588
+	if is_water == "请选择" {
2589
+		is_war = 0
2590
+	}
2591
+	drhy_water := c.GetString("drhy_water")
2592
+	dry_water_hour := c.GetString("dry_water_hour")
2593
+	water_machine := c.GetString("water_machine")
2529
 	if mode_id > 0 {
2594
 	if mode_id > 0 {
2530
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
2595
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
2531
 	}
2596
 	}
2632
 		EpoCount:                   epo_count,
2697
 		EpoCount:                   epo_count,
2633
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2698
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2634
 		PreImpulse:                 impulse,
2699
 		PreImpulse:                 impulse,
2700
+		AdminUserId:                admin_user_id,
2701
+		IsWater:                    is_war,
2702
+		DrhyWater:                  drhy_water,
2703
+		DryWaterHour:               dry_water_hour,
2704
+		WaterMachine:               water_machine,
2635
 	}
2705
 	}
2636
 
2706
 
2637
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2707
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2922
 			if template.TemplateId == 6 && adminInfo.Org.Id != 9538 {
2992
 			if template.TemplateId == 6 && adminInfo.Org.Id != 9538 {
2923
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2993
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2924
 				record.UltrafiltrationRate = ultrafiltration_rate
2994
 				record.UltrafiltrationRate = ultrafiltration_rate
2995
+
2925
 			}
2996
 			}
2926
-			//if template.TemplateId == 6 && adminInfo.Org.Id ==9671{
2927
-			//  dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
2928
-			//  ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
2929
-			//  record.UltrafiltrationRate = ultrafiltration_rate
2930
-			//}
2931
 
2997
 
2932
 			if template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 {
2998
 			if template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 {
2933
 
2999
 
2946
 				ultrafiltration_rate = value
3012
 				ultrafiltration_rate = value
2947
 				record.UltrafiltrationRate = ultrafiltration_rate
3013
 				record.UltrafiltrationRate = ultrafiltration_rate
2948
 			}
3014
 			}
2949
-			fmt.Println("hhh23232323223232323323232323", template.TemplateId)
3015
+
2950
 			if template.TemplateId == 41 || template.TemplateId == 47 {
3016
 			if template.TemplateId == 41 || template.TemplateId == 47 {
2951
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
3017
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin) * 1000)
2952
-				fmt.Println("prescritpin2332322323232323223", ultrafiltration_rate)
2953
 				record.UltrafiltrationRate = ultrafiltration_rate
3018
 				record.UltrafiltrationRate = ultrafiltration_rate
2954
 			}
3019
 			}
2955
 
3020
 
2963
 				record.UltrafiltrationRate = ultrafiltration_rate
3028
 				record.UltrafiltrationRate = ultrafiltration_rate
2964
 			}
3029
 			}
2965
 
3030
 
3031
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 {
3032
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3033
+				fmt.Println("ultrafiltration_rate2332323223322332q", ultrafiltration_rate)
3034
+				record.UltrafiltrationRate = ultrafiltration_rate
3035
+			}
2966
 			//if template.TemplateId == 47 {
3036
 			//if template.TemplateId == 47 {
2967
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
3037
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2968
 			//	record.UltrafiltrationRate = ultrafiltration_rate
3038
 			//	record.UltrafiltrationRate = ultrafiltration_rate
2988
 		}
3058
 		}
2989
 	}
3059
 	}
2990
 
3060
 
3061
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 {
3062
+
3063
+		if ultrafiltration_rate > 0 {
3064
+			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3065
+
3066
+			record.UltrafiltrationVolume = ultrafiltration_volume
3067
+		}
3068
+
3069
+	}
3070
+
2991
 	if template.TemplateId == 47 || template.TemplateId == 54 {
3071
 	if template.TemplateId == 47 || template.TemplateId == 54 {
2992
 		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
3072
 		record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
2993
 	}
3073
 	}
3009
 	change_nurse, _ := this.GetInt64("change_nurse")
3089
 	change_nurse, _ := this.GetInt64("change_nurse")
3010
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
3090
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
3011
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
3091
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
3092
+	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
3012
 	patient_id, _ := this.GetInt64("patient_id")
3093
 	patient_id, _ := this.GetInt64("patient_id")
3013
 	record_date, _ := this.GetInt64("record_date")
3094
 	record_date, _ := this.GetInt64("record_date")
3095
+	puncture_needle := this.GetString("puncture_needle")
3096
+	puncture_way := this.GetString("puncture_way")
3097
+	dialysis_dialyszers := this.GetString("dialysis_dialyszers")
3098
+	dialysis_irrigation := this.GetString("dialysis_irrigation")
3099
+	blood_access_id, _ := this.GetInt64("blood_access_id")
3100
+	nuclein_date_str := this.GetString("nuclein_date_str")
3014
 	if record_id == 0 {
3101
 	if record_id == 0 {
3015
 		this.ErrorLog("id:%v", record_id)
3102
 		this.ErrorLog("id:%v", record_id)
3016
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3103
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3081
 	schedulestartTime := theStartTime.Unix()
3168
 	schedulestartTime := theStartTime.Unix()
3082
 	scheduleendTime := theEndTime.Unix()
3169
 	scheduleendTime := theEndTime.Unix()
3083
 
3170
 
3171
+	var theNucleinDate int64
3172
+	timeLayoutOne := "2006-01-02"
3173
+	if len(nuclein_date_str) > 0 {
3174
+		theTime, err := time.ParseInLocation(timeLayoutOne+" 15:04:05", nuclein_date_str+" 00:00:00", loc)
3175
+		if err != nil {
3176
+			utils.ErrorLog(err.Error())
3177
+		}
3178
+		theNucleinDate = theTime.Unix()
3179
+	}
3180
+
3084
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
3181
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
3085
 
3182
 
3086
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3183
 	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
3156
 		ChangeNurse:            change_nurse,
3253
 		ChangeNurse:            change_nurse,
3157
 		DifficultPunctureNurse: difficult_puncture_nurse,
3254
 		DifficultPunctureNurse: difficult_puncture_nurse,
3158
 		NewFistulaNurse:        new_fistula_nurse,
3255
 		NewFistulaNurse:        new_fistula_nurse,
3256
+		QualityNurseId:         quality_nurse_id,
3257
+		PunctureNeedle:         puncture_needle,
3258
+		PunctureWay:            puncture_way,
3259
+		DialysisDialyszers:     dialysis_dialyszers,
3260
+		DialysisIrrigation:     dialysis_irrigation,
3261
+		BloodAccessId:          blood_access_id,
3262
+		NucleinDate:            theNucleinDate,
3159
 	}
3263
 	}
3160
 
3264
 
3161
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3265
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3235
 	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
3339
 	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
3236
 	catheter := c.GetString("catheter")
3340
 	catheter := c.GetString("catheter")
3237
 	cruor := c.GetString("cruor")
3341
 	cruor := c.GetString("cruor")
3342
+	mission := c.GetString("mission")
3238
 	if record_id <= 0 || nurseID <= 0 {
3343
 	if record_id <= 0 || nurseID <= 0 {
3239
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3344
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3240
 		return
3345
 		return
3281
 		BloodAccessInternalFistula: blood_access_internal_fistula,
3386
 		BloodAccessInternalFistula: blood_access_internal_fistula,
3282
 		Catheter:                   catheter,
3387
 		Catheter:                   catheter,
3283
 		Cruor:                      cruor,
3388
 		Cruor:                      cruor,
3389
+		Mission:                    mission,
3284
 	}
3390
 	}
3285
 
3391
 
3286
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
3392
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
3995
 	schedual_type, _ := c.GetInt64("schedual_type")
4101
 	schedual_type, _ := c.GetInt64("schedual_type")
3996
 	adminUserInfo := c.GetMobileAdminUserInfo()
4102
 	adminUserInfo := c.GetMobileAdminUserInfo()
3997
 
4103
 
3998
-	//timeLayout := "2006-01-02 15:04:05"
3999
-	//
4000
-	//date := time.Now().Format("2006-01-02") + " 00:00:00"
4001
-	//loc, _ := time.LoadLocation("Local")
4002
-	//theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
4003
-	//scheduleTime := theStartTime.Unix()
4004
 	scheduleTime, _ := c.GetInt64("record_date")
4104
 	scheduleTime, _ := c.GetInt64("record_date")
4005
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.Org.Id, scheduleTime, schedual_type)
4105
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.Org.Id, scheduleTime, schedual_type)
4006
 	list, _ := service.GetAllBedNumberSeven(adminUserInfo.Org.Id)
4106
 	list, _ := service.GetAllBedNumberSeven(adminUserInfo.Org.Id)
4875
 
4975
 
4876
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4976
 	var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
4877
 
4977
 
4978
+	var cancelbefor []*models.DialysisBeforePrepareGoods
4979
+	var outbefor []*models.DialysisBeforePrepareGoods
4980
+
4878
 	//判断是否开启自动出库
4981
 	//判断是否开启自动出库
4879
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
4982
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
4880
 
4983
 
4938
 					goodInfo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5041
 					goodInfo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
4939
 					//判断当前出库数量和最后一次出库数量的大小
5042
 					//判断当前出库数量和最后一次出库数量的大小
4940
 					//如果当前出库数量小于最后一次出库数量 正常出库后 需要退库操作
5043
 					//如果当前出库数量小于最后一次出库数量 正常出库后 需要退库操作
4941
-
4942
 					if item.Count < goodInfo.Count {
5044
 					if item.Count < goodInfo.Count {
4943
-						//退库
4944
-						err = ConsumablesDeliveryTotalSeven(adminInfo.Org.Id, patient_id, record_time, beforePrepares, adminInfo.AdminUser.Id, item.Count)
4945
-
4946
-						//查询默认仓库
4947
-						storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4948
-						stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4949
-						var total_count int64
4950
-						for _, it := range stockList {
4951
-							total_count += it.StockCount
4952
-						}
4953
-						//基础库插入数据
4954
-						service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4955
-						//更新剩余库存
4956
-						goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
4957
-						var flush_count int64
4958
-						for _, it := range goodList {
4959
-							flush_count += it.StockCount
4960
-						}
4961
-						service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
4962
-						break
5045
+						cancelbefor = append(cancelbefor, item)
4963
 					}
5046
 					}
4964
 
5047
 
4965
-					var last_total int64
4966
-
4967
 					//如果当前出库数量大于 最后一次出库数量,那么则需要去查询当前批次耗材的库存是否足够
5048
 					//如果当前出库数量大于 最后一次出库数量,那么则需要去查询当前批次耗材的库存是否足够
4968
 					if item.Count > goodInfo.Count {
5049
 					if item.Count > goodInfo.Count {
4969
 
5050
 
4970
-						//计算当前出库和最后一次出库数据相差数据
4971
-						last_total = item.Count - goodInfo.Count
4972
-
4973
-						//查询该批次剩余库存
4974
-						lastInfo, _ := service.GetLastStockOut(goodInfo.WarehouseInfotId)
4975
-
4976
-						if lastInfo.StockCount == 0 {
4977
-							//查询该耗材的总库存
4978
-							wareinfo, _ := service.GetStockGoodCount(item.GoodId)
4979
-							if wareinfo.StockCount == 0 {
4980
-								goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4981
-								c.ServeSuccessJSON(map[string]interface{}{
4982
-									"message":            "1",
4983
-									"good_name":          goodObj.GoodName,
4984
-									"specification_name": goodObj.SpecificationName,
4985
-								})
4986
-								return
5051
+						outbefor = append(outbefor, item)
5052
+					}
5053
+
5054
+					//处理编辑耗材新增不了的问题
5055
+					if goodInfo.Count == item.Count {
5056
+						lastCount, _ := service.GetAutoGoodLastCount(item.GoodId, item.Count, record_time, patient_id)
5057
+						service.UpdateLastAutoCount(lastCount.ID, item.Count)
5058
+					}
5059
+
5060
+				}
5061
+
5062
+				fmt.Println("退库长度", len(cancelbefor))
5063
+				fmt.Println("出库长度", len(outbefor))
5064
+				//退库
5065
+				for _, item := range cancelbefor {
5066
+					warehouseOut, _ := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
5067
+					creater := adminInfo.AdminUser.Id
5068
+					//退库
5069
+					//err = ConsumablesDeliveryTotalSeven(adminInfo.Org.Id, patient_id, record_time, cancelbefor, adminInfo.AdminUser.Id, item.Count)
5070
+					//查询该患者当天已经出库的耗材信息
5071
+
5072
+					warehouseOutInfos, _ := service.FindStockOutInfoByStockTwo(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, record_time, patient_id)
5073
+
5074
+					var delete_count int64 = 0
5075
+
5076
+					delete_count = warehouseOutInfos.Count - item.Count
5077
+
5078
+					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5079
+
5080
+					// 在出库记录表里记录退库详情
5081
+					warehouseOutInfo := &models.WarehouseOutInfo{
5082
+						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5083
+						WarehouseOutId:          warehouseOut.ID,
5084
+						Status:                  1,
5085
+						Ctime:                   time.Now().Unix(),
5086
+						OrgId:                   adminInfo.Org.Id,
5087
+						Type:                    1,
5088
+						IsSys:                   1,
5089
+						SysRecordTime:           record_time,
5090
+						GoodTypeId:              item.GoodTypeId,
5091
+						GoodId:                  item.GoodId,
5092
+						PatientId:               patient_id,
5093
+						ConsumableType:          2,
5094
+						StorehouseId:            houseConfig.StorehouseOutInfo,
5095
+						IsCheck:                 1,
5096
+					}
5097
+					warehouseOutInfo.Count = item.Count
5098
+
5099
+					stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
5100
+					warehouseOutInfo.Price = stockInInfo.Price
5101
+					warehouseOutInfo.Dealer = stockInInfo.Dealer
5102
+					warehouseOutInfo.Manufacturer = stockInInfo.Manufacturer
5103
+					warehouseOutInfo.ExpiryDate = stockInInfo.ExpiryDate
5104
+					warehouseOutInfo.ProductDate = stockInInfo.ProductDate
5105
+					warehouseOutInfo.Number = warehouseOutInfos.Number
5106
+					warehouseOutInfo.LicenseNumber = stockInInfo.LicenseNumber
5107
+					warehouseOutInfo.WarehouseInfotId = stockInInfo.ID
5108
+					//查找当天是否存在出库记录
5109
+
5110
+					_, errcod := service.GetWarehouseOutInfoIsExistOne(item.GoodId, patient_id, record_time, 0)
5111
+
5112
+					if errcod == gorm.ErrRecordNotFound {
5113
+						service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5114
+						//插入详情明细表
5115
+						stockFlow := models.VmStockFlow{
5116
+							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5117
+							WarehouseOutId:          warehouseOut.ID,
5118
+							GoodId:                  item.GoodId,
5119
+							Number:                  warehouseOutInfos.Number,
5120
+							ProductDate:             stockInInfo.ProductDate,
5121
+							ExpireDate:              stockInInfo.ExpiryDate,
5122
+							Count:                   item.Count,
5123
+							Price:                   stockInInfo.Price,
5124
+							Status:                  1,
5125
+							Ctime:                   time.Now().Unix(),
5126
+							UserOrgId:               adminInfo.Org.Id,
5127
+							Manufacturer:            stockInInfo.Manufacturer,
5128
+							Dealer:                  stockInInfo.Dealer,
5129
+							LicenseNumber:           stockInInfo.LicenseNumber,
5130
+							IsEdit:                  2,
5131
+							Creator:                 creater,
5132
+							SystemTime:              record_time,
5133
+							ConsumableType:          3,
5134
+							WarehousingDetailId:     0,
5135
+							IsSys:                   1,
5136
+							UpdateCreator:           creater,
5137
+							PatientId:               patient_id,
5138
+							StorehouseId:            houseConfig.StorehouseOutInfo,
5139
+						}
5140
+						exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
5141
+						if errflow == gorm.ErrRecordNotFound {
5142
+							//创建流水表
5143
+							err := service.CreateStockFlowOne(stockFlow)
5144
+							fmt.Println("err", err)
5145
+						} else if errflow == nil {
5146
+							//插入详情明细表
5147
+							stockFlow := models.VmStockFlow{
5148
+								ID:                      exsit.ID,
5149
+								WarehousingId:           warehouseOutInfos.WarehouseInfotId,
5150
+								WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5151
+								WarehouseOutId:          warehouseOut.ID,
5152
+								GoodId:                  item.GoodId,
5153
+								Number:                  warehouseOutInfos.Number,
5154
+								ProductDate:             stockInInfo.ProductDate,
5155
+								ExpireDate:              stockInInfo.ExpiryDate,
5156
+								Count:                   exsit.Count - delete_count,
5157
+								Price:                   stockInInfo.Price,
5158
+								Status:                  1,
5159
+								Ctime:                   time.Now().Unix(),
5160
+								UserOrgId:               adminInfo.Org.Id,
5161
+								Manufacturer:            stockInInfo.Manufacturer,
5162
+								Dealer:                  stockInInfo.Dealer,
5163
+								LicenseNumber:           stockInInfo.LicenseNumber,
5164
+								IsEdit:                  2,
5165
+								Creator:                 creater,
5166
+								SystemTime:              record_time,
5167
+								ConsumableType:          3,
5168
+								WarehousingDetailId:     0,
5169
+								IsSys:                   1,
5170
+								UpdateCreator:           creater,
5171
+								PatientId:               patient_id,
5172
+								StorehouseId:            houseConfig.StorehouseOutInfo,
4987
 							}
5173
 							}
4988
 
5174
 
5175
+							service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
4989
 						}
5176
 						}
4990
 
5177
 
4991
-						//比较剩余库存 和 当前相差的数量,库存剩余量大于则正常出库
5178
+					} else if errcod == nil {
5179
+						service.UpdatedWarehouseOutInfo(warehouseOutInfo, item.GoodId, patient_id, record_time, 0)
5180
+						//插入详情明细表
5181
+						stockFlow := models.VmStockFlow{
5182
+							WarehousingId:           warehouseOutInfos.WarehouseInfotId,
5183
+							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5184
+							WarehouseOutId:          warehouseOut.ID,
5185
+							GoodId:                  item.GoodId,
5186
+							Number:                  warehouseOutInfos.Number,
5187
+							ProductDate:             stockInInfo.ProductDate,
5188
+							ExpireDate:              stockInInfo.ExpiryDate,
5189
+							Count:                   item.Count,
5190
+							Price:                   stockInInfo.Price,
5191
+							Status:                  1,
5192
+							Ctime:                   time.Now().Unix(),
5193
+							UserOrgId:               adminInfo.Org.Id,
5194
+							Manufacturer:            stockInInfo.Manufacturer,
5195
+							Dealer:                  stockInInfo.Dealer,
5196
+							LicenseNumber:           stockInInfo.LicenseNumber,
5197
+							IsEdit:                  2,
5198
+							Creator:                 creater,
5199
+							SystemTime:              record_time,
5200
+							ConsumableType:          3,
5201
+							WarehousingDetailId:     0,
5202
+							IsSys:                   1,
5203
+							UpdateCreator:           creater,
5204
+							PatientId:               patient_id,
5205
+							ReturnCount:             delete_count,
5206
+							StorehouseId:            houseConfig.StorehouseOutInfo,
5207
+						}
5208
+						exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
5209
+						if errflows == gorm.ErrRecordNotFound {
5210
+							//创建流水表
5211
+							service.CreateStockFlowOne(stockFlow)
5212
+						} else if errflows == nil {
5213
+							stockFlow := models.VmStockFlow{
5214
+								WarehousingId:           warehouseOutInfos.WarehouseInfotId,
5215
+								ID:                      exsit.ID,
5216
+								WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5217
+								WarehouseOutId:          warehouseOut.ID,
5218
+								GoodId:                  item.GoodId,
5219
+								Number:                  warehouseOutInfos.Number,
5220
+								ProductDate:             stockInInfo.ProductDate,
5221
+								ExpireDate:              stockInInfo.ExpiryDate,
5222
+								Count:                   exsit.Count - delete_count,
5223
+								Price:                   stockInInfo.Price,
5224
+								Status:                  1,
5225
+								Ctime:                   time.Now().Unix(),
5226
+								UserOrgId:               adminInfo.Org.Id,
5227
+								Manufacturer:            stockInInfo.Manufacturer,
5228
+								Dealer:                  stockInInfo.Dealer,
5229
+								LicenseNumber:           stockInInfo.LicenseNumber,
5230
+								IsEdit:                  2,
5231
+								Creator:                 creater,
5232
+								SystemTime:              record_time,
5233
+								ConsumableType:          3,
5234
+								WarehousingDetailId:     0,
5235
+								IsSys:                   1,
5236
+								UpdateCreator:           creater,
5237
+								PatientId:               patient_id,
5238
+								ReturnCount:             delete_count,
5239
+								StorehouseId:            houseConfig.StorehouseOutInfo,
5240
+							}
5241
+							service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
5242
+						}
5243
+
5244
+					}
5245
+
5246
+					//更改自动出库的表格
5247
+					details := models.BloodAutomaticReduceDetail{
5248
+						WarehouseOutId:          warehouseOutInfo.ID,
5249
+						WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
5250
+						PatientId:               patient_id,
5251
+						Ctime:                   time.Now().Unix(),
5252
+						Mtime:                   time.Now().Unix(),
5253
+						Status:                  1,
5254
+						RecordTime:              record_time,
5255
+						OrgId:                   adminInfo.Org.Id,
5256
+						GoodId:                  item.GoodId,
5257
+						GoodTypeId:              item.GoodTypeId,
5258
+						Count:                   item.Count,
5259
+						StorehouseId:            houseConfig.StorehouseOutInfo,
5260
+					}
5261
+					//查询当天耗材是否已经存在数据
5262
+					_, errcode := service.GetAutoMaticReduceDetail(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
5263
+
5264
+					if errcode == gorm.ErrRecordNotFound {
5265
+						service.CreateAutoReduceRecord(&details)
5266
+
5267
+					} else if errcode == nil {
5268
+						service.DeleteAutoRedeceDetailTwo(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
5269
+						service.CreateAutoReduceRecord(&details)
5270
+
5271
+					}
5272
+
5273
+					service.ModifyGoodAddInformation(item.GoodId, delete_count, adminInfo.Org.Id)
4992
 
5274
 
5275
+					//增加出库库存数量
5276
+					service.ModifyReduceGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, adminInfo.Org.Id, item.GoodId)
5277
+
5278
+					errOne := service.UpDateWarehouStockFlowByStockDelete(warehouseOutInfos.WarehouseInfotId, record_time, item.GoodId, delete_count, patient_id)
5279
+					fmt.Println("errOne", errOne)
5280
+					// 删除出库完成后,要增加对应批次的库存数量
5281
+
5282
+					service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count, patient_id, record_time, item.GoodId)
5283
+
5284
+					//查询默认仓库
5285
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5286
+					stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
5287
+					var total_count int64
5288
+					for _, it := range stockList {
5289
+						total_count += it.StockCount
5290
+					}
5291
+					//基础库插入数据
5292
+					service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
5293
+					//更新剩余库存
5294
+					goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
5295
+					var flush_count int64
5296
+					for _, it := range goodList {
5297
+						flush_count += it.StockCount
5298
+					}
5299
+					service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
5300
+				}
5301
+
5302
+				//出库
5303
+				for _, item := range outbefor {
5304
+					fmt.Println("出库ID", item.GoodId)
5305
+					var last_total int64
5306
+					//1.查看该患者该耗材型号最后一次出库数量
5307
+					goodInfoOne, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5308
+					//计算当前出库和最后一次出库数据相差数据
5309
+					last_total = item.Count - goodInfoOne.Count
5310
+
5311
+					//查询该批次剩余库存
5312
+					lastInfo, _ := service.GetLastStockOut(goodInfoOne.WarehouseInfotId)
5313
+
5314
+					if lastInfo.StockCount == 0 {
4993
 						//查询该耗材的总库存
5315
 						//查询该耗材的总库存
4994
 						wareinfo, _ := service.GetStockGoodCount(item.GoodId)
5316
 						wareinfo, _ := service.GetStockGoodCount(item.GoodId)
4995
-						// 如果库存差大于剩余库存则提示库存不足
4996
-						if last_total > wareinfo.StockCount {
5317
+						if wareinfo.StockCount == 0 {
4997
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
5318
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
4998
 							c.ServeSuccessJSON(map[string]interface{}{
5319
 							c.ServeSuccessJSON(map[string]interface{}{
4999
 								"message":            "1",
5320
 								"message":            "1",
5001
 								"specification_name": goodObj.SpecificationName,
5322
 								"specification_name": goodObj.SpecificationName,
5002
 							})
5323
 							})
5003
 							return
5324
 							return
5004
-						} else {
5325
+						}
5326
+
5327
+					}
5005
 
5328
 
5006
-							//出库
5007
-							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
5329
+					//比较剩余库存 和 当前相差的数量,库存剩余量大于则正常出库
5008
 
5330
 
5009
-							storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5010
-							stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
5011
-							var total_count int64
5012
-							for _, it := range stockList {
5013
-								total_count += it.StockCount
5014
-							}
5015
-							//基础库插入数据
5016
-							service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
5017
-							//剩余库存
5331
+					//查询该耗材的总库存
5332
+					wareinfo, _ := service.GetStockGoodCount(item.GoodId)
5333
+					// 如果库存差大于剩余库存则提示库存不足
5334
+					if last_total > wareinfo.StockCount {
5335
+						goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
5336
+						c.ServeSuccessJSON(map[string]interface{}{
5337
+							"message":            "1",
5338
+							"good_name":          goodObj.GoodName,
5339
+							"specification_name": goodObj.SpecificationName,
5340
+						})
5341
+						return
5342
+					} else {
5018
 
5343
 
5019
-							goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
5020
-							var flush_count int64
5021
-							for _, it := range goodList {
5022
-								flush_count += it.StockCount
5344
+						fmt.Println("出库2o2o2o2o2oo2o2o2o2o2o2o", item.GoodId)
5345
+
5346
+						out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
5347
+						houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5348
+						if err == gorm.ErrRecordNotFound {
5349
+							//没有记录,则创建出库单
5350
+							timeStr := time.Now().Format("2006-01-02")
5351
+							timeArr := strings.Split(timeStr, "-")
5352
+							total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
5353
+							total = total + 1
5354
+							warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
5355
+							number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
5356
+							number = number + total
5357
+							warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
5358
+							warehouseOut := models.WarehouseOut{
5359
+								WarehouseOutOrderNumber: warehousing_out_order,
5360
+								OperationTime:           time.Now().Unix(),
5361
+								OrgId:                   adminInfo.Org.Id,
5362
+								Creater:                 adminInfo.AdminUser.Id,
5363
+								Ctime:                   time.Now().Unix(),
5364
+								Status:                  1,
5365
+								WarehouseOutTime:        record_time,
5366
+								Dealer:                  0,
5367
+								Manufacturer:            0,
5368
+								Type:                    1,
5369
+								IsSys:                   1,
5370
+								StorehouseId:            houseConfig.StorehouseOutInfo,
5371
+								IsCheck:                 1,
5023
 							}
5372
 							}
5024
-							service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
5025
-							break
5373
+							service.AddSigleWarehouseOut(&warehouseOut)
5374
+
5026
 						}
5375
 						}
5027
-					}
5376
+						//出库
5377
+						//err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, outbefor, newBeforePrepares, adminInfo.AdminUser.Id)
5378
+						//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5379
+						//1.查看该患者该耗材型号最后一次出库数量
5380
+						goodInfoTwo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5381
+
5382
+						fmt.Println("count2323323222323wi", item.Count)
5383
+						prepare := models.DialysisBeforePrepare{
5384
+							UserOrgId:    adminInfo.Org.Id,
5385
+							PatientId:    patient_id,
5386
+							RecordDate:   record_time,
5387
+							GoodId:       item.GoodId,
5388
+							GoodTypeId:   item.GoodTypeId,
5389
+							Count:        item.Count - goodInfoTwo.Count,
5390
+							Ctime:        time.Now().Unix(),
5391
+							Mtime:        0,
5392
+							Creater:      adminInfo.AdminUser.Id,
5393
+							Modifier:     adminInfo.AdminUser.Id,
5394
+							Status:       1,
5395
+							CommdityCode: "",
5396
+							NewCount:     0,
5397
+							ProjectId:    0,
5398
+							StorehouseId: houseConfig.StorehouseOutInfo,
5399
+						}
5400
+						fmt.Println("prepare", prepare.Count)
5401
+						fmt.Println("count", item.Count)
5402
+						service.ConsumablesGoodDelivery(adminInfo.Org.Id, patient_id, record_time, &prepare, &out, item.Count)
5403
+						//增加出库数量
5404
+						service.ModifyGoodSumCount(houseConfig.StorehouseOutInfo, prepare.Count, adminInfo.Org.Id, item.GoodId)
5405
+
5406
+						storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5407
+						stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
5408
+						var total_count int64
5409
+						for _, it := range stockList {
5410
+							total_count += it.StockCount
5411
+						}
5412
+						//基础库插入数据
5413
+						service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
5414
+						//剩余库存
5028
 
5415
 
5416
+						goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
5417
+						var flush_count int64
5418
+						for _, it := range goodList {
5419
+							flush_count += it.StockCount
5420
+						}
5421
+						service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
5422
+					}
5029
 				}
5423
 				}
5030
 
5424
 
5031
 				//查询今日出库数据
5425
 				//查询今日出库数据
5064
 						flush_count += it.StockCount
5458
 						flush_count += it.StockCount
5065
 					}
5459
 					}
5066
 					service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, it.GoodId, flush_count)
5460
 					service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, it.GoodId, flush_count)
5067
-					if err != nil {
5068
-						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
5069
-						c.ServeSuccessJSON(map[string]interface{}{
5070
-							"message":            "2",
5071
-							"good_name":          goodObj.GoodName,
5072
-							"specification_name": goodObj.SpecificationName,
5073
-						})
5074
-						return
5075
-					}
5461
+					//if err != nil {
5462
+					//	goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
5463
+					//	c.ServeSuccessJSON(map[string]interface{}{
5464
+					//		"message":            "2",
5465
+					//		"good_name":          goodObj.GoodName,
5466
+					//		"specification_name": goodObj.SpecificationName,
5467
+					//	})
5468
+					//	return
5469
+					//}
5076
 				}
5470
 				}
5077
 			}
5471
 			}
5078
 		}
5472
 		}
5126
 
5520
 
5127
 	project, _ := service.GetHisPrescriptionProject(adminUser.Org.Id, patient_id, date.Unix())
5521
 	project, _ := service.GetHisPrescriptionProject(adminUser.Org.Id, patient_id, date.Unix())
5128
 
5522
 
5523
+	_, config := service.FindXTHisRecordByOrgId(adminUser.Org.Id)
5129
 	//获取当天该病人的透析处方
5524
 	//获取当天该病人的透析处方
5130
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
5525
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
5131
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
5526
 	good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
5149
 			"prescribe":        prescribe,
5544
 			"prescribe":        prescribe,
5150
 			"good_info":        good_info,
5545
 			"good_info":        good_info,
5151
 			"warehouseOutList": warehouseOutList,
5546
 			"warehouseOutList": warehouseOutList,
5547
+			"config":           config,
5152
 		})
5548
 		})
5153
 		return
5549
 		return
5154
 
5550
 
5175
 				"good_info":        good_info,
5571
 				"good_info":        good_info,
5176
 				"project":          project,
5572
 				"project":          project,
5177
 				"warehouseOutList": warehouseOutList,
5573
 				"warehouseOutList": warehouseOutList,
5574
+				"config":           config,
5178
 			})
5575
 			})
5179
 			return
5576
 			return
5180
 
5577
 
5249
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
5646
 	prescribe, parseDateErr := service.GetDialysisPrescribe(adminUser.Org.Id, patient_id, date.Unix())
5250
 
5647
 
5251
 	outInfo, _ := service.GetGoodWarehouseOutInfo(adminUser.Org.Id, patient_id, date.Unix())
5648
 	outInfo, _ := service.GetGoodWarehouseOutInfo(adminUser.Org.Id, patient_id, date.Unix())
5649
+
5650
+	_, configs := service.FindXTHisRecordByOrgId(adminUser.Org.Id)
5252
 	c.ServeSuccessJSON(map[string]interface{}{
5651
 	c.ServeSuccessJSON(map[string]interface{}{
5253
 		"good_type":      goodTypes,
5652
 		"good_type":      goodTypes,
5254
 		"good_user":      goodUser,
5653
 		"good_user":      goodUser,
5257
 		"project":        project,
5656
 		"project":        project,
5258
 		"prescription":   prescribe,
5657
 		"prescription":   prescribe,
5259
 		"outInfo":        outInfo,
5658
 		"outInfo":        outInfo,
5659
+		"configs":        configs,
5260
 	})
5660
 	})
5261
 	return
5661
 	return
5262
 
5662
 
6055
 	// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
6455
 	// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
6056
 	// goods 这个数据就是需要出库的耗材的数据(新增的数据)
6456
 	// goods 这个数据就是需要出库的耗材的数据(新增的数据)
6057
 
6457
 
6458
+	fmt.Println("剩余需要出库的", len(goods))
6058
 	if len(goods) > 0 {
6459
 	if len(goods) > 0 {
6059
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
6460
 		out, err := service.FindStockOutByIsSys(orgID, 1, record_time)
6060
 		houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
6461
 		houseConfig, _ := service.GetAllStoreHouseConfig(orgID)
6106
 				StorehouseId: houseConfig.StorehouseOutInfo,
6507
 				StorehouseId: houseConfig.StorehouseOutInfo,
6107
 			}
6508
 			}
6108
 
6509
 
6109
-			fmt.Println("出库数量23333333333333333333333332😯😯😯😯", prepare.Count)
6110
 			service.ConsumablesGoodDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
6510
 			service.ConsumablesGoodDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
6111
 
6511
 
6112
 			//增加出库数量
6512
 			//增加出库数量
6143
 		} else {
6543
 		} else {
6144
 			delete_count = ware.Count
6544
 			delete_count = ware.Count
6145
 		}
6545
 		}
6146
-		// 在出库记录表里记录退库详情
6546
+
6147
 		warehouseOutInfo := &models.WarehouseOutInfo{
6547
 		warehouseOutInfo := &models.WarehouseOutInfo{
6148
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
6548
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
6149
 			WarehouseOutId:          warehouseOut.ID,
6549
 			WarehouseOutId:          warehouseOut.ID,
6235
 
6635
 
6236
 func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *models.BloodAutomaticReduceDetail, warehouseOut *models.WarehouseOut, patient_id int64, creater int64, count int64) (err error) {
6636
 func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *models.BloodAutomaticReduceDetail, warehouseOut *models.WarehouseOut, patient_id int64, creater int64, count int64) (err error) {
6237
 
6637
 
6638
+	fmt.Println("退库222322232322332232332322332232332233wo", good_yc.GoodId)
6238
 	// 先根据相关信息查询当天该耗材的出库信息
6639
 	// 先根据相关信息查询当天该耗材的出库信息
6239
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
6640
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
6240
 
6641
 
6258
 	//增加退库数量
6659
 	//增加退库数量
6259
 	service.UpdateSumAddCancelCount(orgID, good_yc.GoodId, houseConfig.StorehouseOutInfo, delete_count)
6660
 	service.UpdateSumAddCancelCount(orgID, good_yc.GoodId, houseConfig.StorehouseOutInfo, delete_count)
6260
 
6661
 
6261
-	//扣减出库数量
6662
+	//扣减出库数量
6262
 	service.ModifyAddGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, orgID, good_yc.GoodId)
6663
 	service.ModifyAddGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, orgID, good_yc.GoodId)
6263
 	//查询剩余库存
6664
 	//查询剩余库存
6264
 	goodList, _ := service.GetAllGoodSumCount(good_yc.GoodId, orgID)
6665
 	goodList, _ := service.GetAllGoodSumCount(good_yc.GoodId, orgID)
6554
 	})
6955
 	})
6555
 }
6956
 }
6556
 
6957
 
6958
+func (this *DialysisAPIController) GetScheduleByPatient() {
6959
+
6960
+	patient_id, _ := this.GetInt64("patient_id")
6961
+	schedule_date, _ := this.GetInt64("schedule_date")
6962
+	orgid := this.GetMobileAdminUserInfo().Org.Id
6963
+	schedule, _ := service.GetScheduleByPatient(patient_id, schedule_date, orgid)
6964
+	this.ServeSuccessJSON(map[string]interface{}{
6965
+		"schedule": schedule,
6966
+	})
6967
+
6968
+}
6969
+
6970
+func (this *DialysisAPIController) GetDialysisRecordOrder() {
6971
+
6972
+	org_id := this.GetMobileAdminUserInfo().Org.Id
6973
+	patient_id, _ := this.GetInt64("patient_id")
6974
+	schedule_date, _ := this.GetInt64("schedule_date")
6975
+	order, _ := service.GetDialysisRecordOrder(org_id, patient_id, schedule_date)
6976
+	this.ServeSuccessJSON(map[string]interface{}{
6977
+		"order": order,
6978
+	})
6979
+}
6980
+
6557
 func (this *DialysisAPIController) CheckSchedule() {
6981
 func (this *DialysisAPIController) CheckSchedule() {
6558
 
6982
 
6559
 	patientID, _ := this.GetInt64("patient_id")
6983
 	patientID, _ := this.GetInt64("patient_id")

+ 3 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Ver arquivo

172
 
172
 
173
 	beego.Router("/m/api/checksch/get", &DialysisAPIController{}, "Get:CheckSchedule")
173
 	beego.Router("/m/api/checksch/get", &DialysisAPIController{}, "Get:CheckSchedule")
174
 
174
 
175
+	beego.Router("/m/api/patient/getschedulebypatient", &DialysisAPIController{}, "Get:GetScheduleByPatient")
176
+
177
+	beego.Router("/m/api/getdialysisrecordeorder", &DialysisAPIController{}, "Get:GetDialysisRecordOrder")
175
 }
178
 }

+ 79 - 18
controllers/mobile_api_controllers/patient_api_controller.go Ver arquivo

684
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
684
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
685
 
685
 
686
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
686
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
687
+		fmt.Println("drugStockConfig.IsOpen32232323232", drugStockConfig.IsOpen)
687
 		if drugStockConfig.IsOpen == 1 {
688
 		if drugStockConfig.IsOpen == 1 {
688
 			if groupno > 0 {
689
 			if groupno > 0 {
689
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
690
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
699
 				if isHasWay {
700
 				if isHasWay {
700
 					var total int64
701
 					var total int64
701
 					var prescribing_number_total int64
702
 					var prescribing_number_total int64
703
+					fmt.Println("advicesssssssssssssssss", len(advices))
702
 					for _, item := range advices {
704
 					for _, item := range advices {
703
 						if item.Way == 1 {
705
 						if item.Way == 1 {
704
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
706
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
721
 								total = list.Count*medical.MinNumber + list.StockMinNumber
723
 								total = list.Count*medical.MinNumber + list.StockMinNumber
722
 								prescribing_number_total = count
724
 								prescribing_number_total = count
723
 							}
725
 							}
724
-
726
+							fmt.Println("meiddidididssddssddsdsds", medical.IsUse)
725
 							if medical.IsUse == 1 {
727
 							if medical.IsUse == 1 {
726
 								c.ServeSuccessJSON(map[string]interface{}{
728
 								c.ServeSuccessJSON(map[string]interface{}{
727
 									"msg":    "1",
729
 									"msg":    "1",
771
 											stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
773
 											stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
772
 											var sum_count int64
774
 											var sum_count int64
773
 											for _, its := range stockInfo {
775
 											for _, its := range stockInfo {
774
-												sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
776
+												if its.MaxUnit == medical.MaxUnit {
777
+													its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
778
+												}
779
+												sum_count += its.StockMaxNumber + its.StockMinNumber
775
 											}
780
 											}
776
 											service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
781
 											service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
782
+											//剩余库存
783
+											service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
777
 										}
784
 										}
778
 									}
785
 									}
779
 								} else {
786
 								} else {
789
 										stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
796
 										stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
790
 										var sum_count int64
797
 										var sum_count int64
791
 										for _, its := range stockInfo {
798
 										for _, its := range stockInfo {
792
-											sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
799
+											if its.MaxUnit == medical.MaxUnit {
800
+												its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
801
+											}
802
+											sum_count += its.StockMaxNumber + its.StockMinNumber
793
 										}
803
 										}
794
 										service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
804
 										service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
805
+										//剩余库存
806
+										service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
795
 									}
807
 									}
796
 								}
808
 								}
797
 							}
809
 							}
798
 						}
810
 						}
799
 					}
811
 					}
812
+
800
 				}
813
 				}
801
-				c.ServeSuccessJSON(map[string]interface{}{
802
-					"msg":    "1",
803
-					"advice": advice,
804
-					"ids":    ids,
805
-				})
806
-				return
807
 			} else {
814
 			} else {
808
 
815
 
809
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
816
 				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
886
 									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
893
 									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
887
 									var sum_count int64
894
 									var sum_count int64
888
 									for _, its := range stockInfo {
895
 									for _, its := range stockInfo {
889
-										sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
896
+										baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
897
+										if its.MaxUnit == baseDrug.MaxUnit {
898
+											its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
899
+										}
900
+										sum_count += its.StockMaxNumber + its.StockMinNumber
890
 									}
901
 									}
891
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
902
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
892
-									c.ServeSuccessJSON(map[string]interface{}{
893
-										"msg":    "1",
894
-										"advice": advice,
895
-										"ids":    ids,
896
-									})
897
-									return
903
+									//剩余库存
904
+									service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
898
 								}
905
 								}
899
 								if medical.IsUse == 1 {
906
 								if medical.IsUse == 1 {
900
 									c.ServeSuccessJSON(map[string]interface{}{
907
 									c.ServeSuccessJSON(map[string]interface{}{
910
 					}
917
 					}
911
 				}
918
 				}
912
 			}
919
 			}
920
+
921
+			c.ServeSuccessJSON(map[string]interface{}{
922
+				"msg":    "1",
923
+				"advice": advice,
924
+				"ids":    ids,
925
+			})
926
+			return
913
 		}
927
 		}
914
 
928
 
915
 		if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
929
 		if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
1198
 									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1212
 									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1199
 									var sum_count int64
1213
 									var sum_count int64
1200
 									for _, its := range stockInfo {
1214
 									for _, its := range stockInfo {
1201
-										sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1215
+										if its.MaxUnit == medical.MaxUnit {
1216
+											its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1217
+										}
1218
+										sum_count += its.StockMaxNumber + its.StockMinNumber
1202
 									}
1219
 									}
1203
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1220
 									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1221
+									//剩余库存
1222
+									service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1204
 								}
1223
 								}
1205
 
1224
 
1206
 							}
1225
 							}
1207
 						}
1226
 						}
1208
 					}
1227
 					}
1228
+
1229
+					//if config.IsOpen == 1 && item.UserOrgId == 10028 {
1230
+					//
1231
+					//	service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1232
+					//	//更新字典里面的库存
1233
+					//	stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1234
+					//	var sum_count int64
1235
+					//	for _, its := range stockInfo {
1236
+					//		if its.MaxUnit == medical.MaxUnit {
1237
+					//			its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1238
+					//		}
1239
+					//		sum_count += its.StockMaxNumber + its.StockMinNumber
1240
+					//	}
1241
+					//	service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1242
+					//	//剩余库存
1243
+					//	service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1244
+					//}
1245
+
1209
 				}
1246
 				}
1210
 			}
1247
 			}
1211
 			for _, item := range advices {
1248
 			for _, item := range advices {
2745
 
2782
 
2746
 		evaluation.WeightBeforRemake = weight_befor_remake
2783
 		evaluation.WeightBeforRemake = weight_befor_remake
2747
 	}
2784
 	}
2785
+
2786
+	if dataBody["height"] != nil && reflect.TypeOf(dataBody["height"]).String() == "string" {
2787
+		height := dataBody["height"].(string)
2788
+
2789
+		evaluation.Height = height
2790
+	}
2791
+
2792
+	if dataBody["age"] != nil && reflect.TypeOf(dataBody["age"]).String() == "string" {
2793
+		age := dataBody["age"].(string)
2794
+
2795
+		evaluation.Age = age
2796
+	}
2797
+
2798
+	if dataBody["his_department"] != nil && reflect.TypeOf(dataBody["his_department"]).String() == "string" {
2799
+		his_department := dataBody["his_department"].(string)
2800
+
2801
+		evaluation.HisDepartment = his_department
2802
+	}
2803
+
2804
+	if dataBody["his_bed"] != nil && reflect.TypeOf(dataBody["his_bed"]).String() == "string" {
2805
+		his_bed := dataBody["his_bed"].(string)
2806
+
2807
+		evaluation.HisBed = his_bed
2808
+	}
2748
 	return
2809
 	return
2749
 }
2810
 }
2750
 
2811
 
2893
 		if dataBody["drug_name_id"] != nil || reflect.TypeOf(dataBody["drug_name_id"]).String() == "float64" {
2954
 		if dataBody["drug_name_id"] != nil || reflect.TypeOf(dataBody["drug_name_id"]).String() == "float64" {
2894
 			drug_name_id := int64(dataBody["drug_name_id"].(float64))
2955
 			drug_name_id := int64(dataBody["drug_name_id"].(float64))
2895
 			advice.DrugNameId = drug_name_id
2956
 			advice.DrugNameId = drug_name_id
2896
-			fmt.Println("0000000000", advice.DrugNameId)
2957
+
2897
 		}
2958
 		}
2898
 	}
2959
 	}
2899
 
2960
 

+ 35 - 7
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Ver arquivo

173
 	fmt.Print(birth)
173
 	fmt.Print(birth)
174
 	phone := dataBody["phone"].(string)
174
 	phone := dataBody["phone"].(string)
175
 	relative_phone := dataBody["relative_phone"].(string)
175
 	relative_phone := dataBody["relative_phone"].(string)
176
-	fmt.Print("电话号码", phone)
176
+
177
 	patientType := dataBody["result"].([]interface{})
177
 	patientType := dataBody["result"].([]interface{})
178
 	fmt.Print("患者标签", patientType)
178
 	fmt.Print("患者标签", patientType)
179
 	dialysis := dataBody["dialysis"].(string)
179
 	dialysis := dataBody["dialysis"].(string)
241
 
241
 
242
 	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
242
 	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
243
 
243
 
244
+	remark := dataBody["remark"].(string)
245
+
246
+	treatment_plan := dataBody["treatment_plan"].(string)
244
 	//查询身份证号码是否存在
247
 	//查询身份证号码是否存在
245
 	thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
248
 	thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
246
 	if thisPatientOne.ID > 0 {
249
 	if thisPatientOne.ID > 0 {
289
 			IsInfectious:      is_infectious,
292
 			IsInfectious:      is_infectious,
290
 			RegistrarsId:      adminInfo.AdminUser.Id,
293
 			RegistrarsId:      adminInfo.AdminUser.Id,
291
 			RelativePhone:     relative_phone,
294
 			RelativePhone:     relative_phone,
295
+			Remark:            "",
296
+			SchRemark:         remark,
297
+			TreatmentPlan:     treatment_plan,
292
 		}
298
 		}
293
 		err = service.CreateOldPatient(&patients)
299
 		err = service.CreateOldPatient(&patients)
294
 		fmt.Print("报错", err)
300
 		fmt.Print("报错", err)
330
 			IdCardNo:          idCard,
336
 			IdCardNo:          idCard,
331
 			RegistrarsId:      adminInfo.AdminUser.Id,
337
 			RegistrarsId:      adminInfo.AdminUser.Id,
332
 			RelativePhone:     relative_phone,
338
 			RelativePhone:     relative_phone,
339
+			Remark:            "",
340
+			SchRemark:         remark,
341
+			TreatmentPlan:     treatment_plan,
333
 		}
342
 		}
334
 		err = service.CreateNewPatient(&patientsNew)
343
 		err = service.CreateNewPatient(&patientsNew)
335
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.ID, 10) + ":patient_info"
344
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.ID, 10) + ":patient_info"
346
 			"patient": patientsNew,
355
 			"patient": patientsNew,
347
 		})
356
 		})
348
 	}
357
 	}
349
-
350
-	fmt.Print("slowpatient", slowpatient)
351
 	//如果是慢病病人
358
 	//如果是慢病病人
352
 	if slowpatient == 1 {
359
 	if slowpatient == 1 {
353
 		_, errcodetwo := service.GetSlowPatientData(phone, orgid)
360
 		_, errcodetwo := service.GetSlowPatientData(phone, orgid)
354
-		fmt.Print("查询慢慢是吧", errcodetwo)
355
 		if errcodetwo == gorm.ErrRecordNotFound {
361
 		if errcodetwo == gorm.ErrRecordNotFound {
356
 			patients := models.CdmPatients{
362
 			patients := models.CdmPatients{
357
 				Name:        name,
363
 				Name:        name,
399
 					IsInfectious:      is_infectious,
405
 					IsInfectious:      is_infectious,
400
 					IdCardNo:          idCard,
406
 					IdCardNo:          idCard,
401
 					EquitmentId:       requipmentId,
407
 					EquitmentId:       requipmentId,
408
+					Remark:            "",
409
+					SchRemark:         remark,
410
+					TreatmentPlan:     treatment_plan,
402
 				}
411
 				}
403
 				err = service.CreateNewPatient(&patientsNew)
412
 				err = service.CreateNewPatient(&patientsNew)
404
 				if err != nil {
413
 				if err != nil {
409
 					"patient": patientsNew,
418
 					"patient": patientsNew,
410
 				})
419
 				})
411
 			} else if errcodetwo == nil {
420
 			} else if errcodetwo == nil {
412
-				fmt.Print("病人已存在")
421
+
413
 				if memberpatient == 1 {
422
 				if memberpatient == 1 {
414
-					fmt.Print("进来没有", memberpatient)
415
 					_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
423
 					_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
416
 					if errmembercode == gorm.ErrRecordNotFound {
424
 					if errmembercode == gorm.ErrRecordNotFound {
417
 						customer := models.SgjUserCustomer{
425
 						customer := models.SgjUserCustomer{
460
 								MemberPatienttype: patient_type,
468
 								MemberPatienttype: patient_type,
461
 								MemberTreatement:  treatmentmethod,
469
 								MemberTreatement:  treatmentmethod,
462
 								RelativePhone:     relative_phone,
470
 								RelativePhone:     relative_phone,
471
+								SchRemark:         remark,
472
+								Remark:            "",
473
+								TreatmentPlan:     treatment_plan,
463
 							}
474
 							}
464
 							err = service.CreateNewPatient(&patientsNew)
475
 							err = service.CreateNewPatient(&patientsNew)
465
 							fmt.Print("报错", err)
476
 							fmt.Print("报错", err)
498
 	}
509
 	}
499
 
510
 
500
 	if memberpatient == 1 {
511
 	if memberpatient == 1 {
501
-		fmt.Print("进来没有", memberpatient)
502
 		_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
512
 		_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
503
 		if errmembercode == gorm.ErrRecordNotFound {
513
 		if errmembercode == gorm.ErrRecordNotFound {
504
 			customer := models.SgjUserCustomer{
514
 			customer := models.SgjUserCustomer{
547
 					MemberPatienttype: patient_type,
557
 					MemberPatienttype: patient_type,
548
 					MemberTreatement:  treatmentmethod,
558
 					MemberTreatement:  treatmentmethod,
549
 					RelativePhone:     relative_phone,
559
 					RelativePhone:     relative_phone,
560
+					Remark:            "",
561
+					SchRemark:         remark,
562
+					TreatmentPlan:     treatment_plan,
550
 				}
563
 				}
551
 				err = service.CreateNewPatient(&patientsNew)
564
 				err = service.CreateNewPatient(&patientsNew)
552
 				fmt.Print("报错", err)
565
 				fmt.Print("报错", err)
1330
 
1343
 
1331
 	out_reason := dataBody["out_reason"].(string)
1344
 	out_reason := dataBody["out_reason"].(string)
1332
 
1345
 
1346
+	remark := dataBody["remark"].(string)
1347
+
1348
+	treatment_plan := dataBody["treatment_plan"].(string)
1333
 	fmt.Print(fisttime)
1349
 	fmt.Print(fisttime)
1334
 	//如果是血透病人
1350
 	//如果是血透病人
1335
 	if bloodPatient == 1 {
1351
 	if bloodPatient == 1 {
1384
 			DeathTime:         death_time,
1400
 			DeathTime:         death_time,
1385
 			OutReason:         out_reason,
1401
 			OutReason:         out_reason,
1386
 			RelativePhone:     relative_phone,
1402
 			RelativePhone:     relative_phone,
1403
+			Remark:            "",
1404
+			SchRemark:         remark,
1405
+			TreatmentPlan:     treatment_plan,
1387
 		}
1406
 		}
1388
 		err = service.UpdatedPatient(patients, patient.BloodId)
1407
 		err = service.UpdatedPatient(patients, patient.BloodId)
1389
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.BloodId, 10) + ":patient_info"
1408
 		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.BloodId, 10) + ":patient_info"
1414
 			OutReason:         out_reason,
1433
 			OutReason:         out_reason,
1415
 			DeathTime:         death_time,
1434
 			DeathTime:         death_time,
1416
 			RelativePhone:     relative_phone,
1435
 			RelativePhone:     relative_phone,
1436
+			Remark:            "",
1437
+			SchRemark:         remark,
1438
+			TreatmentPlan:     treatment_plan,
1417
 		}
1439
 		}
1418
 		err = service.UpdateXtPatientNew(patientsNew, id)
1440
 		err = service.UpdateXtPatientNew(patientsNew, id)
1419
 		if err != nil {
1441
 		if err != nil {
1472
 			OutReason:         out_reason,
1494
 			OutReason:         out_reason,
1473
 			DeathTime:         death_time,
1495
 			DeathTime:         death_time,
1474
 			RelativePhone:     relative_phone,
1496
 			RelativePhone:     relative_phone,
1497
+			Remark:            "",
1498
+			SchRemark:         remark,
1499
+			TreatmentPlan:     treatment_plan,
1475
 		}
1500
 		}
1476
 		err = service.UpdateXtPatientNew(xtPatientsNew, id)
1501
 		err = service.UpdateXtPatientNew(xtPatientsNew, id)
1477
 		fmt.Print("更新失败", err)
1502
 		fmt.Print("更新失败", err)
1529
 			OutReason:         out_reason,
1554
 			OutReason:         out_reason,
1530
 			DeathTime:         death_time,
1555
 			DeathTime:         death_time,
1531
 			RelativePhone:     relative_phone,
1556
 			RelativePhone:     relative_phone,
1557
+			Remark:            "",
1558
+			SchRemark:         remark,
1559
+			TreatmentPlan:     treatment_plan,
1532
 		}
1560
 		}
1533
 		err = service.UpdateXtPatientNewOne(patientsNew, id)
1561
 		err = service.UpdateXtPatientNewOne(patientsNew, id)
1534
 		if err != nil {
1562
 		if err != nil {

+ 0 - 1
controllers/new_mobile_api_controllers/new_manage_api_controller.go Ver arquivo

230
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
230
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
231
 		return
231
 		return
232
 	}
232
 	}
233
-	fmt.Println("recordDate2222222", recordDate.Unix())
234
 	//查询今日所有设备使用登记
233
 	//查询今日所有设备使用登记
235
 	information, err := service.GetDeviceInfomation(orgid, recordDate.Unix())
234
 	information, err := service.GetDeviceInfomation(orgid, recordDate.Unix())
236
 	if err != nil {
235
 	if err != nil {

+ 132 - 2
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Ver arquivo

518
 	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
518
 	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
519
 	weekStart := theStarTime.Unix()
519
 	weekStart := theStarTime.Unix()
520
 	weekEnd := theEndTime.Unix()
520
 	weekEnd := theEndTime.Unix()
521
-
522
-	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.Org.Id, keywords, weekStart, weekEnd, schedule, contagion)
521
+	patients, _ := service.GetPatientWithScheduleAndSolutionTwo(adminInfo.Org.Id, keywords, weekStart, weekEnd, schedule, contagion)
523
 
522
 
524
 	this.ServeSuccessJSON(map[string]interface{}{
523
 	this.ServeSuccessJSON(map[string]interface{}{
525
 		"patients": patients,
524
 		"patients": patients,
721
 		"schedule": schedule,
720
 		"schedule": schedule,
722
 	})
721
 	})
723
 }
722
 }
723
+
724
+func (c *StaffScheduleApiController) GetAllBedList() {
725
+
726
+	orgId := c.GetMobileAdminUserInfo().Org.Id
727
+	partition_id, _ := c.GetInt64("partition_id")
728
+	list, _ := service.GetAllBedNumberTen(orgId, partition_id)
729
+	c.ServeSuccessJSON(map[string]interface{}{
730
+		"list": list,
731
+	})
732
+}
733
+
734
+func (c *StaffScheduleApiController) ChangeScheduleById() {
735
+
736
+	id, _ := c.GetInt64("id")
737
+	mode_id, _ := c.GetInt64("mode_id")
738
+	schedule_date, _ := c.GetInt64("schedule_date")
739
+	patient_id, _ := c.GetInt64("patient_id")
740
+	org_id := c.GetMobileAdminUserInfo().Org.Id
741
+	err := service.ChangeScheduleById(id, mode_id)
742
+	fmt.Println("9999999999999999", err)
743
+	err = service.ChangeDialysisSolution(patient_id, schedule_date, org_id, mode_id)
744
+	c.ServeSuccessJSON(map[string]interface{}{
745
+		"msg": "ok",
746
+	})
747
+}
748
+
749
+func (c *StaffScheduleApiController) ChangeScheduleType() {
750
+
751
+	schedule_type, _ := c.GetInt64("schedule_type")
752
+	schedule_date, _ := c.GetInt64("schedule_date")
753
+	patient_id, _ := c.GetInt64("patient_id")
754
+	bed_id, _ := c.GetInt64("bed_id")
755
+	schedule_week, _ := c.GetInt64("schedule_week")
756
+	mode_id, _ := c.GetInt64("mode_id")
757
+	id, _ := c.GetInt64("id")
758
+	org_id := c.GetMobileAdminUserInfo().Org.Id
759
+	//查询该班次该床位是否已经存在患者
760
+	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
761
+	//查询该床位所属分区
762
+	numberlist, _ := service.GetPartionId(bed_id, org_id)
763
+	//存在
764
+	if schedule.ID > 0 {
765
+
766
+		//调换位置
767
+		sch := models.Schedule{
768
+			PatientId: schedule.PatientId,
769
+			ModeId:    schedule.ModeId,
770
+		}
771
+		service.UpdateScheduleById(id, sch)
772
+
773
+		schedu := models.Schedule{
774
+			PatientId: patient_id,
775
+			ModeId:    mode_id,
776
+		}
777
+		service.UpdateScheduleById(schedule.ID, schedu)
778
+
779
+	} else {
780
+		xtSchedule := models.Schedule{
781
+			UserOrgId:    org_id,
782
+			PartitionId:  numberlist.ZoneId,
783
+			BedId:        bed_id,
784
+			PatientId:    patient_id,
785
+			ScheduleDate: schedule_date,
786
+			ScheduleType: schedule_type,
787
+			ScheduleWeek: schedule_week,
788
+			ModeId:       mode_id,
789
+			Status:       1,
790
+			CreatedTime:  time.Now().Unix(),
791
+			UpdatedTime:  0,
792
+			IsExport:     0,
793
+		}
794
+		service.CreateSchedule(&xtSchedule)
795
+	}
796
+	c.ServeSuccessJSON(map[string]interface{}{
797
+		"msg": "ok",
798
+	})
799
+}
800
+
801
+func (c *StaffScheduleApiController) ChangeScheduleBed() {
802
+
803
+	fmt.Println("jin23323232233222323323232")
804
+	schedule_type, _ := c.GetInt64("schedule_type")
805
+	schedule_date, _ := c.GetInt64("schedule_date")
806
+	patient_id, _ := c.GetInt64("patient_id")
807
+	bed_id, _ := c.GetInt64("bed_id")
808
+	schedule_week, _ := c.GetInt64("schedule_week")
809
+	mode_id, _ := c.GetInt64("mode_id")
810
+	id, _ := c.GetInt64("id")
811
+	org_id := c.GetMobileAdminUserInfo().Org.Id
812
+
813
+	//查询该班次该床位是否已经存在患者
814
+	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
815
+	//查询该床位所属分区
816
+	numberlist, _ := service.GetPartionId(bed_id, org_id)
817
+	//存在
818
+	if schedule.ID > 0 {
819
+
820
+		//调换位置
821
+		sch := models.Schedule{
822
+			PatientId: schedule.PatientId,
823
+			ModeId:    schedule.ModeId,
824
+		}
825
+		service.UpdateScheduleById(id, sch)
826
+
827
+		schedu := models.Schedule{
828
+			PatientId: patient_id,
829
+			ModeId:    mode_id,
830
+		}
831
+		service.UpdateScheduleById(schedule.ID, schedu)
832
+	} else {
833
+		xtSchedule := models.Schedule{
834
+			UserOrgId:    org_id,
835
+			PartitionId:  numberlist.ZoneId,
836
+			BedId:        bed_id,
837
+			PatientId:    patient_id,
838
+			ScheduleDate: schedule_date,
839
+			ScheduleType: schedule_type,
840
+			ScheduleWeek: schedule_week,
841
+			ModeId:       mode_id,
842
+			Status:       1,
843
+			CreatedTime:  time.Now().Unix(),
844
+			UpdatedTime:  0,
845
+			IsExport:     0,
846
+		}
847
+		service.DeleteSchedule(id)
848
+		service.CreateSchedule(&xtSchedule)
849
+	}
850
+	c.ServeSuccessJSON(map[string]interface{}{
851
+		"msg": "ok",
852
+	})
853
+}

+ 8 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Ver arquivo

26
 	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
26
 	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
27
 	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
27
 	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
28
 	beego.Router("m/api/schedule/getsolutionschedule", &StaffScheduleApiController{}, "Get:GetSolutionSchedule")
28
 	beego.Router("m/api/schedule/getsolutionschedule", &StaffScheduleApiController{}, "Get:GetSolutionSchedule")
29
+
30
+	beego.Router("m/api/schedule/getallbedlist", &StaffScheduleApiController{}, "Get:GetAllBedList")
31
+
32
+	beego.Router("m/api/schedule/changeschedulebyid", &StaffScheduleApiController{}, "Get:ChangeScheduleById")
33
+
34
+	beego.Router("m/api/schedule/changescheduletype", &StaffScheduleApiController{}, "Get:ChangeScheduleType")
35
+
36
+	beego.Router("m/api/schedule/changeschedulebed", &StaffScheduleApiController{}, "Get:ChangeScheduleBed")
29
 }
37
 }

+ 33 - 14
controllers/patient_api_controller.go Ver arquivo

365
 		UserSysBeforeCount:           patient.UserSysBeforeCount,
365
 		UserSysBeforeCount:           patient.UserSysBeforeCount,
366
 		TrobleShoot:                  patient.TrobleShoot,
366
 		TrobleShoot:                  patient.TrobleShoot,
367
 		TreatmentPlan:                patient.TreatmentPlan,
367
 		TreatmentPlan:                patient.TreatmentPlan,
368
+		Doctor:                       patient.Doctor,
368
 	}
369
 	}
369
 
370
 
370
 	err = service.CreatePatientsNew(&patientsNew)
371
 	err = service.CreatePatientsNew(&patientsNew)
484
 	patient.UpdatedTime = time.Now().Unix()
485
 	patient.UpdatedTime = time.Now().Unix()
485
 	patient.IsInfectious = is_infectious
486
 	patient.IsInfectious = is_infectious
486
 	patient.RemindCycle = remind_cycle
487
 	patient.RemindCycle = remind_cycle
487
-	fmt.Println("hhhhh2h32322323332323232323232322323", patient.RemindCycle)
488
 	err := service.UpdatePatient(&patient, contagions, diseases)
488
 	err := service.UpdatePatient(&patient, contagions, diseases)
489
 	if err != nil {
489
 	if err != nil {
490
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdatePatient)
490
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdatePatient)
580
 		BloodPatients:             1,
580
 		BloodPatients:             1,
581
 		Lapseto:                   patient.Lapseto,
581
 		Lapseto:                   patient.Lapseto,
582
 		TrobleShoot:               patient.TrobleShoot,
582
 		TrobleShoot:               patient.TrobleShoot,
583
+		SchRemark:                 patient.SchRemark,
583
 	}
584
 	}
584
 	//	//更新病人ID获取新表病人ID
585
 	//	//更新病人ID获取新表病人ID
585
 	err = service.UpdatepatientTwo(&patientsNew, id)
586
 	err = service.UpdatepatientTwo(&patientsNew, id)
750
 
751
 
751
 	err = service.EditPatientLapseto(&patient, &lapseto)
752
 	err = service.EditPatientLapseto(&patient, &lapseto)
752
 
753
 
753
-	if lapseto.LapsetoType == 3 || lapseto.LapsetoType == 2 {
754
-		timeStr := time.Now().Format("2006-01-02")
755
-		timeLayout := "2006-01-02 15:04:05"
756
-		timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
757
-		timenow := timeStringToTime.Unix()
758
-		service.UpdateScheduleByDeathTime(id, timenow)
759
-		service.UpdateScheduleItemByPatientId(id)
760
-	}
754
+	//if lapseto.LapsetoType == 3 || lapseto.LapsetoType == 2 {
755
+	//	timeStr := time.Now().Format("2006-01-02")
756
+	//	timeLayout := "2006-01-02 15:04:05"
757
+	//	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
758
+	//	timenow := timeStringToTime.Unix()
759
+	//	service.UpdateScheduleByDeathTime(id, timenow)
760
+	//	service.UpdateScheduleItemByPatientId(id)
761
+	//}
761
 
762
 
762
 	if err != nil {
763
 	if err != nil {
763
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEditLapsetoFail)
764
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEditLapsetoFail)
1770
 					var sum_count int64
1771
 					var sum_count int64
1771
 					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1772
 					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1772
 					for _, its := range stockInfo {
1773
 					for _, its := range stockInfo {
1773
-						sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1774
+						if its.MaxUnit == medical.MaxUnit {
1775
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
1776
+						}
1777
+						sum_count += its.StockMaxNumber + its.StockMinNumber
1774
 					}
1778
 					}
1779
+
1775
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1780
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1776
 					break
1781
 					break
1777
 					c.ServeSuccessJSON(map[string]interface{}{
1782
 					c.ServeSuccessJSON(map[string]interface{}{
2007
 								//更新字典里面的库存
2012
 								//更新字典里面的库存
2008
 								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2013
 								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2009
 								for _, its := range stockInfo {
2014
 								for _, its := range stockInfo {
2010
-									sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
2015
+									if its.MaxUnit == medical.MaxUnit {
2016
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
2017
+									}
2018
+									sum_count += its.StockMaxNumber + its.StockMinNumber
2011
 								}
2019
 								}
2020
+
2012
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2021
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2013
 								break
2022
 								break
2014
 								c.ServeSuccessJSON(map[string]interface{}{
2023
 								c.ServeSuccessJSON(map[string]interface{}{
2049
 							var sum_count int64
2058
 							var sum_count int64
2050
 							stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2059
 							stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2051
 							for _, its := range stockInfo {
2060
 							for _, its := range stockInfo {
2052
-								sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
2061
+								if its.MaxUnit == medical.MaxUnit {
2062
+									its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
2063
+								}
2064
+								sum_count += its.StockMaxNumber + its.StockMinNumber
2053
 							}
2065
 							}
2054
 							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2066
 							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2055
 							break
2067
 							break
2327
 
2339
 
2328
 						if medical.IsUse == 2 {
2340
 						if medical.IsUse == 2 {
2329
 							if config.IsOpen != 1 {
2341
 							if config.IsOpen != 1 {
2330
-								fmt.Println("pharmacyConfig23232332322323", pharmacyConfig.IsOpen, medical.IsPharmacy)
2331
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2342
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2332
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2343
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2333
 
2344
 
2342
 								var sum_count int64
2353
 								var sum_count int64
2343
 								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2354
 								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2344
 								for _, its := range stockInfo {
2355
 								for _, its := range stockInfo {
2345
-									sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
2356
+									if its.MaxUnit == medical.MaxUnit {
2357
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
2358
+									}
2359
+									sum_count += its.StockMaxNumber + its.StockMinNumber
2346
 								}
2360
 								}
2347
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2361
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2348
 
2362
 
4433
 		treatment_plan := patientBody["treatment_plan"].(string)
4447
 		treatment_plan := patientBody["treatment_plan"].(string)
4434
 		patient.TreatmentPlan = treatment_plan
4448
 		patient.TreatmentPlan = treatment_plan
4435
 	}
4449
 	}
4450
+
4451
+	if patientBody["doctor"] != nil && reflect.TypeOf(patientBody["doctor"]).String() == "float64" {
4452
+		doctor := int64(patientBody["doctor"].(float64))
4453
+		patient.Doctor = doctor
4454
+	}
4436
 	return
4455
 	return
4437
 }
4456
 }
4438
 
4457
 

+ 10 - 2
controllers/secondary_order_api_contorller.go Ver arquivo

1195
 					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1195
 					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1196
 					var sum_count int64
1196
 					var sum_count int64
1197
 					for _, its := range stockInfo {
1197
 					for _, its := range stockInfo {
1198
-						sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1198
+						baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
1199
+						if its.MaxUnit == baseDrug.MaxUnit {
1200
+							its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1201
+						}
1202
+						sum_count += its.StockMaxNumber + its.StockMinNumber
1199
 					}
1203
 					}
1200
 					service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1204
 					service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1201
 				}
1205
 				}
1605
 			var sum_count int64
1609
 			var sum_count int64
1606
 			stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1610
 			stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1607
 			for _, its := range stockInfo {
1611
 			for _, its := range stockInfo {
1608
-				sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1612
+				baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
1613
+				if its.MaxUnit == baseDrug.MaxUnit {
1614
+					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1615
+				}
1616
+				sum_count += its.StockMaxNumber + its.StockMinNumber
1609
 			}
1617
 			}
1610
 			service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1618
 			service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1611
 		}
1619
 		}

+ 405 - 72
controllers/self_drug_api_congtroller.go Ver arquivo

106
 	beego.Router("/api/stock/tosendgoodinfomation", &SelfDrugApiController{}, "Get:GetSendGoodInformation")
106
 	beego.Router("/api/stock/tosendgoodinfomation", &SelfDrugApiController{}, "Get:GetSendGoodInformation")
107
 	//药品脚本
107
 	//药品脚本
108
 	beego.Router("/api/drug/getdruginitdatalist", &SelfDrugApiController{}, "Get:GetDrugInitDetailList")
108
 	beego.Router("/api/drug/getdruginitdatalist", &SelfDrugApiController{}, "Get:GetDrugInitDetailList")
109
+
110
+	//新数据
111
+	beego.Router("/api/stock/getnewpurchasestockquery", &SelfDrugApiController{}, "Get:GetGoodNewPurchaseStockQuery")
112
+	beego.Router("/api/stock/getpurchasenewdrugquery", &SelfDrugApiController{}, "Get:GetPurchaseNewDrugQuery")
113
+	beego.Router("/api/stock/getgoodovercount", &SelfDrugApiController{}, "Get:GetGoodOverCount")
114
+	beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
115
+
116
+	beego.Router("/api/stock/getdruginfolist", &SelfDrugApiController{}, "Get:GetDrugInventoryWarehouseInfoList")
109
 }
117
 }
110
 
118
 
111
 func (this *SelfDrugApiController) GetCurrentPatient() {
119
 func (this *SelfDrugApiController) GetCurrentPatient() {
2658
 				MaxUnit:                 min_unit,
2666
 				MaxUnit:                 min_unit,
2659
 				MinUnit:                 min_unit,
2667
 				MinUnit:                 min_unit,
2660
 				StorehouseId:            storehouse_id,
2668
 				StorehouseId:            storehouse_id,
2669
+				OverCount:               sum_count,
2661
 			}
2670
 			}
2662
 			if ord_total != new_total {
2671
 			if ord_total != new_total {
2663
 				service.CreateDrugFlowOne(flow)
2672
 				service.CreateDrugFlowOne(flow)
2737
 	keyword := this.GetString("keyword")
2746
 	keyword := this.GetString("keyword")
2738
 	page, _ := this.GetInt64("page")
2747
 	page, _ := this.GetInt64("page")
2739
 	limit, _ := this.GetInt64("limit")
2748
 	limit, _ := this.GetInt64("limit")
2740
-	//start_time := this.GetString("start_time")
2741
-	//end_time := this.GetString("end_time")
2742
-	//timeLayout := "2006-01-02"
2743
-	//loc, _ := time.LoadLocation("Local")
2744
-	//var startTime int64
2745
-	//if len(start_time) > 0 {
2746
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2747
-	//	if err != nil {
2748
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2749
-	//		return
2750
-	//	}
2751
-	//	startTime = theTime.Unix()
2752
-	//}
2753
-	//var endTime int64
2754
-	//if len(end_time) > 0 {
2755
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2756
-	//	if err != nil {
2757
-	//		utils.ErrorLog(err.Error())
2758
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2759
-	//		return
2760
-	//	}
2761
-	//	endTime = theTime.Unix()
2762
-	//}
2763
 
2749
 
2764
 	// 查询该机构所有耗材入库信息
2750
 	// 查询该机构所有耗材入库信息
2765
 	goodList, _ := service.GetAllGoodListSeven(orgId)
2751
 	goodList, _ := service.GetAllGoodListSeven(orgId)
2774
 		service.UpdateGoodInformation(it.ID, orgId, sum_total)
2760
 		service.UpdateGoodInformation(it.ID, orgId, sum_total)
2775
 	}
2761
 	}
2776
 
2762
 
2777
-	//查询删除的耗材数据
2778
-	//listOne, _ := service.GetHisPrescriptionProjectByOrgId(orgId)
2779
-	//for _, item := range listOne {
2780
-	// //查询流水
2781
-	// flowDetail, _ := service.GetPatientStockFlow(item.PatientId, item.RecordDate, item.ProjectId)
2782
-	// formatInt, _ := strconv.ParseInt(item.Count, 10, 64)
2783
-	// vmFlow := models.VmStockFlow{
2784
-	//   Count:  formatInt,
2785
-	// }
2786
-	// service.ModifyPatientStockFlow(flowDetail.ID,vmFlow)
2787
-	//}
2788
-
2789
 	var ids []int64
2763
 	var ids []int64
2790
 	var goodIds []int64
2764
 	var goodIds []int64
2791
 	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2765
 	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2796
 	for _, it := range infoList {
2770
 	for _, it := range infoList {
2797
 		goodIds = append(goodIds, it.GoodId)
2771
 		goodIds = append(goodIds, it.GoodId)
2798
 	}
2772
 	}
2799
-	//list, _, err := service.GetGoodNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
2800
 
2773
 
2801
 	stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
2774
 	stockList, total, err := service.GetGoodStockList(orgId, storehouse_id, good_type, keyword, page, limit, ids)
2802
-	//for _,item :=range list{
2803
-	// //查询入库信息分组
2804
-	//  warehouseInfo, _ := service.FindGoodWarehouseInfoGroup(item.ID, orgId, storehouse_id, startTime, endTime)
2805
-	//  for _,it :=range warehouseInfo {
2806
-	//    item.WarehousingInfo = append(item.WarehousingInfo, it)
2807
-	//  }
2808
-	//  //查询入库信息
2809
-	//  info, _ := service.FindGoodWarehouseInfo(item.ID, orgId, storehouse_id, startTime, endTime)
2810
-	//  for _,it :=range info {
2811
-	//    item.StWarehousingInfo = append(item.StWarehousingInfo, it)
2812
-	//  }
2813
-	//  //出库数据
2814
-	//  outInfo, _ := service.FindGoodWarehouseOutInfo(item.ID, orgId, storehouse_id, startTime, endTime)
2815
-	//  for _,it :=range outInfo {
2816
-	//    item.WarehouseOutInfo = append(item.WarehouseOutInfo, it)
2817
-	//  }
2818
-	//  //出库流水
2819
-	//  outFlow, _ := service.FindGoodStockOutFlow(item.ID, item.OrgId, storehouse_id, startTime, endTime)
2820
-	//  for _,it :=range outFlow {
2821
-	//    item.FlowOutInfo = append(item.FlowOutInfo, it)
2822
-	//  }
2823
-	//  //退库流水
2824
-	//  cancelFlow, _ := service.FindGoodCancelFlow(item.ID, item.OrgId, storehouse_id, startTime, endTime)
2825
-	//  for _,it :=range cancelFlow {
2826
-	//    item.FlowCancelInfo = append(item.FlowCancelInfo, it)
2827
-	//  }
2828
-	//  //退库数据
2829
-	//  cancelInfo, _ := service.FindCancelStockInfo(item.ID, orgId, storehouse_id, startTime, endTime)
2830
-	//  for _,it :=range cancelInfo {
2831
-	//    item.CancelStockInfo = append(item.CancelStockInfo, it)
2832
-	//  }
2833
-	//}
2834
 
2775
 
2835
 	if err != nil {
2776
 	if err != nil {
2836
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
2777
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
2838
 	}
2779
 	}
2839
 
2780
 
2840
 	this.ServeSuccessJSON(map[string]interface{}{
2781
 	this.ServeSuccessJSON(map[string]interface{}{
2841
-		"total": total,
2842
-		//"list":  list,
2782
+		"total":     total,
2843
 		"stockList": stockList,
2783
 		"stockList": stockList,
2844
 	})
2784
 	})
2845
 }
2785
 }
3470
 	for _, it := range drug {
3410
 	for _, it := range drug {
3471
 		var sum_count int64
3411
 		var sum_count int64
3472
 		var limit_count int64
3412
 		var limit_count int64
3473
-
3413
+		fmt.Println("it233323323232323223", it.DrugName)
3474
 		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3414
 		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3475
 		for _, item := range drugInfo {
3415
 		for _, item := range drugInfo {
3416
+
3476
 			sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3417
 			sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3477
 		}
3418
 		}
3478
-		limit_count = it.DrugStockLimitCount * it.MinNumber
3419
+		stockInt, _ := strconv.ParseInt(it.DrugStockLimit, 10, 64)
3420
+		limit_count = stockInt * it.MinNumber
3479
 		service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3421
 		service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3480
 	}
3422
 	}
3481
 
3423
 
3675
 		"msg": "1",
3617
 		"msg": "1",
3676
 	})
3618
 	})
3677
 }
3619
 }
3620
+
3621
+func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3622
+
3623
+	good_type, _ := this.GetInt64("good_type")
3624
+
3625
+	keyword := this.GetString("keyword")
3626
+
3627
+	page, _ := this.GetInt64("page")
3628
+
3629
+	limit, _ := this.GetInt64("limit")
3630
+
3631
+	start_time := this.GetString("start_time")
3632
+	end_time := this.GetString("end_time")
3633
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3634
+	timeLayout := "2006-01-02"
3635
+	loc, _ := time.LoadLocation("Local")
3636
+	var startTime int64
3637
+
3638
+	if len(start_time) > 0 {
3639
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3640
+		if err != nil {
3641
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3642
+			return
3643
+		}
3644
+		startTime = theTime.Unix()
3645
+	}
3646
+
3647
+	var endTime int64
3648
+	if len(end_time) > 0 {
3649
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3650
+		if err != nil {
3651
+			utils.ErrorLog(err.Error())
3652
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3653
+			return
3654
+		}
3655
+		endTime = theTime.Unix()
3656
+	}
3657
+	var ids []int64
3658
+	var goodIds []int64
3659
+	infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
3660
+	for _, it := range infoList {
3661
+		goodIds = append(goodIds, it.GoodId)
3662
+	}
3663
+
3664
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3665
+	for _, it := range manufacturers {
3666
+		ids = append(ids, it.ID)
3667
+	}
3668
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3669
+	list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3670
+
3671
+	for _, item := range list {
3672
+
3673
+		//获取期初结余
3674
+		low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3675
+
3676
+		item.GoodStartFlowInfo = low
3677
+
3678
+		//获取期末结余
3679
+		flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3680
+
3681
+		item.GoodEndFlowInfo = flow
3682
+
3683
+		//获取期初结余数量
3684
+		//infoList, _ := service.GetStartGoodWarehouseInfoList(item.ID, orgId, startTime)
3685
+		//for _, it := range infoList {
3686
+		//  item.WarehousingInfoStart = append(item.WarehousingInfoStart, it)
3687
+		//}
3688
+		//
3689
+		////获取期末结余数量
3690
+		//warehouseInfoList, _ := service.GetEndGoodWarehouseInfoList(item.ID, orgId, endTime)
3691
+		//for _, it := range warehouseInfoList {
3692
+		//  item.WarehousingInfoEnd = append(item.WarehousingInfoEnd, it)
3693
+		//}
3694
+
3695
+		//获取期间增加
3696
+		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3697
+		for _, it := range goodWarehouseInfoList {
3698
+			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3699
+		}
3700
+
3701
+		//获取本期增加
3702
+		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3703
+		for _, it := range WarehouseInfoFlowList {
3704
+			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3705
+		}
3706
+		//获取本期减少
3707
+		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3708
+		for _, it := range reduceWarehouseInfoList {
3709
+			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3710
+		}
3711
+
3712
+		//获取期中减少退库
3713
+		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3714
+		for _, it := range lowInfo {
3715
+			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3716
+		}
3717
+		//
3718
+		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3719
+		for _, it := range outInfo {
3720
+			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3721
+		}
3722
+
3723
+		////获取期初结余
3724
+		//info, _ := service.FindeStartFlowInfo(item.ID, orgId, startTime)
3725
+		//for _, it := range info {
3726
+		//  item.StartFlowInfo = append(item.StartFlowInfo, it)
3727
+		//}
3728
+		////获取期初结余
3729
+		//flowOutInfo, _ := service.FindeStartFlowOutInfo(item.ID, orgId, startTime)
3730
+		//for _, it := range flowOutInfo {
3731
+		//  item.StartOutFlowInfo = append(item.StartOutFlowInfo, it)
3732
+		//}
3733
+		//
3734
+		////获取期初退库
3735
+		//cancelInfo, _ := service.FindeStartCancelInfo(item.ID, orgId, startTime)
3736
+		//for _, it := range cancelInfo {
3737
+		//  item.StartCancelFlowInfo = append(item.StartCancelFlowInfo, it)
3738
+		//}
3739
+
3740
+		////获取期末结余
3741
+		//flowInfo, _ := service.FindEndStartFlowInfo(item.ID, orgId, endTime)
3742
+		//for _, it := range flowInfo {
3743
+		//  item.EndFlowInfo = append(item.EndFlowInfo, it)
3744
+		//}
3745
+		//
3746
+		////获取期末出库
3747
+		//lowOutInfo, _ := service.FindeEndFLowOutInfo(item.ID, orgId, endTime)
3748
+		//for _, it := range lowOutInfo {
3749
+		//  item.EndFlowOutInfo = append(item.EndFlowOutInfo, it)
3750
+		//}
3751
+		//
3752
+		////获取期末退库
3753
+		//endCancelInfo, _ := service.FindEndCancelInfo(item.ID, orgId, endTime)
3754
+		//for _, it := range endCancelInfo {
3755
+		//  item.EndCancelFLowInfo = append(item.EndCancelFLowInfo, it)
3756
+		//}
3757
+
3758
+		////期初盘赢
3759
+		//inventory, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, startTime)
3760
+		//for _, it := range inventory {
3761
+		//  item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
3762
+		//}
3763
+		////期初盘亏
3764
+		//stockInventory, _ := service.FindStartStockInventoryLosses(item.ID, orgId, startTime)
3765
+		//for _, it := range stockInventory {
3766
+		//  item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
3767
+		//}
3768
+
3769
+		////期末盘盈
3770
+		//inventoryProfit, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, endTime)
3771
+		//for _, it := range inventoryProfit {
3772
+		//  item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
3773
+		//}
3774
+		////期末盘亏
3775
+		//inventoryLosses, _ := service.FindStartStockInventoryLosses(item.ID, orgId, endTime)
3776
+		//for _, it := range inventoryLosses {
3777
+		//  item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
3778
+		//}
3779
+
3780
+		//期中盘盈
3781
+		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3782
+		for _, it := range profit {
3783
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3784
+		}
3785
+		//期中盘亏
3786
+		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3787
+		for _, it := range losses {
3788
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3789
+		}
3790
+	}
3791
+
3792
+	if err != nil {
3793
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3794
+		return
3795
+	}
3796
+
3797
+	this.ServeSuccessJSON(map[string]interface{}{
3798
+		"list":             list,
3799
+		"manufacturerList": manufacturerList,
3800
+		"total":            total,
3801
+	})
3802
+}
3803
+
3804
+func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3805
+
3806
+	good_type, _ := this.GetInt64("good_type")
3807
+
3808
+	keyword := this.GetString("keyword")
3809
+
3810
+	page, _ := this.GetInt64("page")
3811
+
3812
+	limit, _ := this.GetInt64("limit")
3813
+
3814
+	start_time := this.GetString("start_time")
3815
+	end_time := this.GetString("end_time")
3816
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3817
+	timeLayout := "2006-01-02"
3818
+	loc, _ := time.LoadLocation("Local")
3819
+
3820
+	var startTime int64
3821
+
3822
+	if len(start_time) > 0 {
3823
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3824
+		if err != nil {
3825
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3826
+			return
3827
+		}
3828
+		startTime = theTime.Unix()
3829
+	}
3830
+
3831
+	var endTime int64
3832
+	if len(end_time) > 0 {
3833
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3834
+		if err != nil {
3835
+			utils.ErrorLog(err.Error())
3836
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3837
+			return
3838
+		}
3839
+		endTime = theTime.Unix()
3840
+	}
3841
+	var ids []int64
3842
+	var infoIds []int64
3843
+
3844
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3845
+	for _, it := range manufacturers {
3846
+		ids = append(ids, it.ID)
3847
+	}
3848
+	infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
3849
+	for _, it := range infoList {
3850
+		infoIds = append(infoIds, it.DrugId)
3851
+	}
3852
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3853
+	list, total, err := service.GetDrugNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
3854
+
3855
+	for _, item := range list {
3856
+
3857
+		//获取期初结余
3858
+		flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
3859
+
3860
+		item.DrugStatFlow = flow
3861
+
3862
+		//获取期末结余
3863
+		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
3864
+
3865
+		item.DrugEndFlow = endFlow
3866
+		//获取期初结余入库数量
3867
+		//startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)
3868
+		//for _, it := range startDrugInfo {
3869
+		//  item.DrugWarehouseInfoStart = append(item.DrugWarehouseInfoStart, it)
3870
+		//}
3871
+		//
3872
+		////获取期初结余出库数量
3873
+		//flowOutList, _ := service.GetDrugFlowOut(item.ID, orgId, startTime)
3874
+		//for _, it := range flowOutList {
3875
+		//  item.DrugWarehouseOutInfoStart = append(item.DrugWarehouseOutInfoStart, it)
3876
+		//}
3877
+		//
3878
+		////获取期初结余退库数量
3879
+		//cancelInfo, _ := service.GetStartDrugFlowCancelInfo(item.ID, orgId, startTime)
3880
+		//for _, it := range cancelInfo {
3881
+		//  item.WareStartStockCancelInfo = append(item.WareStartStockCancelInfo, it)
3882
+		//}
3883
+		//
3884
+		////获取期末结余入库数量
3885
+		//drugwarehouseinfoend, _ := service.DrugWarehouseInfoEnd(item.ID, orgId, endTime)
3886
+		//for _, it := range drugwarehouseinfoend {
3887
+		//  item.DrugWarehouseInfoEnd = append(item.DrugWarehouseInfoEnd, it)
3888
+		//}
3889
+
3890
+		////获取期末出库结余
3891
+		//endDrugInfo, _ := service.DrugWarehouseOutInfoEnd(item.ID, orgId, endTime)
3892
+		//for _, it := range endDrugInfo {
3893
+		//  item.DrugWarehouseOutInfoEnd = append(item.DrugWarehouseOutInfoEnd, it)
3894
+		//}
3895
+		//
3896
+		////获取期末退库数量
3897
+		//flowCancelInfo, _ := service.GetEndDrugFlowCancelInfo(item.ID, orgId, endTime)
3898
+		//for _, it := range flowCancelInfo {
3899
+		//  item.WareEndStockCancelInfo = append(item.WareEndStockCancelInfo, it)
3900
+		//}
3901
+
3902
+		//期中增加
3903
+		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
3904
+		for _, it := range drugWarehouse {
3905
+			item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
3906
+		}
3907
+
3908
+		//期中减少
3909
+		outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
3910
+		for _, it := range outInfo {
3911
+			item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
3912
+		}
3913
+
3914
+		//期中退库
3915
+		cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
3916
+		for _, it := range cancelstartInfo {
3917
+			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
3918
+		}
3919
+
3920
+		////获取期初盘盈
3921
+		//startProfit, _ := service.GetDrugFlowStartProfit(item.ID, orgId, startTime)
3922
+		//for _, it := range startProfit {
3923
+		//  item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
3924
+		//}
3925
+		////获取期初盘亏
3926
+		//startLosses, _ := service.GetDrugFlowStartLosses(item.ID, orgId, startTime)
3927
+		//for _, it := range startLosses {
3928
+		//  item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
3929
+		//}
3930
+		////获取期末盘盈
3931
+		//endProfit, _ := service.GetDrugFlowEndProfit(item.ID, orgId, endTime)
3932
+		//for _, it := range endProfit {
3933
+		//  item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
3934
+		//}
3935
+		////获取期末盘亏
3936
+		//losses, _ := service.GetDrugFlowEndLosses(item.ID, orgId, endTime)
3937
+		//for _, it := range losses {
3938
+		//  item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
3939
+		//}
3940
+
3941
+		//获取期中盘盈
3942
+		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
3943
+		for _, it := range profit {
3944
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3945
+		}
3946
+
3947
+		//获取期中盘亏
3948
+		endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
3949
+		for _, it := range endLosses {
3950
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3951
+		}
3952
+	}
3953
+	if err != nil {
3954
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3955
+		return
3956
+	}
3957
+	var drugType = "药品类型"
3958
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3959
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3960
+
3961
+	this.ServeSuccessJSON(map[string]interface{}{
3962
+		"list":             list,
3963
+		"manufacturerList": manufacturerList,
3964
+		"total":            total,
3965
+		"drugTypeList":     drugTypeList,
3966
+	})
3967
+}
3968
+
3969
+func (this *SelfDrugApiController) GetGoodOverCount() {
3970
+
3971
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3972
+
3973
+	list, _ := service.GetAllStockCount(orgId)
3974
+	for _, item := range list {
3975
+		flow, _ := service.GetLastStockFlow(item.GoodId)
3976
+		service.ModifyStockFlowById(flow.ID, item.FlushCount)
3977
+	}
3978
+	returnData := make(map[string]interface{}, 0)
3979
+	returnData["msg"] = "ok"
3980
+	this.ServeSuccessJSON(returnData)
3981
+	return
3982
+}
3983
+
3984
+func (this *SelfDrugApiController) GetDrugOverCount() {
3985
+
3986
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3987
+	list, _ := service.GetAllDrugCount(orgId)
3988
+	for _, item := range list {
3989
+		service.GetLastDrugFlow(item.DrugId)
3990
+		service.ModifyDrugFlowById(item.ID, item.FlushCount)
3991
+	}
3992
+	returnData := make(map[string]interface{}, 0)
3993
+	returnData["msg"] = "ok"
3994
+	this.ServeSuccessJSON(returnData)
3995
+	return
3996
+}
3997
+
3998
+func (this *SelfDrugApiController) GetDrugInventoryWarehouseInfoList() {
3999
+
4000
+	storehouse_id, _ := this.GetInt64("storehouse_id")
4001
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4002
+	list, _ := service.GetDrugInventoryWarehouseInfoList(orgId, storehouse_id)
4003
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4004
+	dealerList, _ := service.GetAllDealerList(orgId)
4005
+	this.ServeSuccessJSON(map[string]interface{}{
4006
+		"list":             list,
4007
+		"manufacturerList": manufacturerList,
4008
+		"dealerList":       dealerList,
4009
+	})
4010
+}

+ 86 - 56
controllers/stock_in_api_controller.go Ver arquivo

148
 	beego.Router("/api/stock/checkreturnstockwarehouseinfo", &StockManagerApiController{}, "Get:CheckReturnStockWarehouseInfo")
148
 	beego.Router("/api/stock/checkreturnstockwarehouseinfo", &StockManagerApiController{}, "Get:CheckReturnStockWarehouseInfo")
149
 	beego.Router("/api/stock/getprintlist", &StockManagerApiController{}, "Get:GetPrintList")
149
 	beego.Router("/api/stock/getprintlist", &StockManagerApiController{}, "Get:GetPrintList")
150
 
150
 
151
+	beego.Router("/api/stock/getwarehouseinfolist", &StockManagerApiController{}, "Get:GetInvetoryWarehouseInfoList")
152
+
151
 	//结算成功后调用操作库存相关接口
153
 	//结算成功后调用操作库存相关接口
152
 	beego.Router("/api/settle/stock", &StockManagerApiController{}, "Get:HandleSettleStock")
154
 	beego.Router("/api/settle/stock", &StockManagerApiController{}, "Get:HandleSettleStock")
153
 	beego.Router("/api/settle/cancelstock", &StockManagerApiController{}, "Get:HandleRefundStock")
155
 	beego.Router("/api/settle/cancelstock", &StockManagerApiController{}, "Get:HandleRefundStock")
495
 			}
497
 			}
496
 		}
498
 		}
497
 	}
499
 	}
498
-
499
 	warehouseList, total, err := service.FindAllWarehousingList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, check_type)
500
 	warehouseList, total, err := service.FindAllWarehousingList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids, storehouse_id, check_type)
500
 	houselist, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
501
 	houselist, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
501
 	if err == nil {
502
 	if err == nil {
1293
 
1294
 
1294
 				stock_count := items["stock_count"].(string)
1295
 				stock_count := items["stock_count"].(string)
1295
 
1296
 
1297
+				register_number := items["register_number"].(string)
1298
+
1296
 				timeLayout := "2006-01-02"
1299
 				timeLayout := "2006-01-02"
1297
 				loc, _ := time.LoadLocation("Local")
1300
 				loc, _ := time.LoadLocation("Local")
1298
 				var expiryDate int64
1301
 				var expiryDate int64
1344
 					BuyPrice:                buy_price,
1347
 					BuyPrice:                buy_price,
1345
 					StockCount:              stock_count,
1348
 					StockCount:              stock_count,
1346
 					IsCheck:                 2,
1349
 					IsCheck:                 2,
1350
+					RegisterNumber:          register_number,
1347
 				}
1351
 				}
1348
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1352
 				warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1349
 
1353
 
1391
 			StockCount:              it.StockCount,
1395
 			StockCount:              it.StockCount,
1392
 			Count:                   it.Count,
1396
 			Count:                   it.Count,
1393
 			IsCheck:                 2,
1397
 			IsCheck:                 2,
1398
+			RegisterNumber:          it.RegisterNumber,
1394
 		}
1399
 		}
1395
 		if it.ID == 0 {
1400
 		if it.ID == 0 {
1396
 			service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1401
 			service.AddSigleWarehouseOutInfo(warehouseOutInfo)
1707
 
1712
 
1708
 				stock_count := items["stock_count"].(string)
1713
 				stock_count := items["stock_count"].(string)
1709
 
1714
 
1715
+				register_number := items["register_number"].(string)
1716
+
1710
 				var productDate int64
1717
 				var productDate int64
1711
 				if len(product_date) > 0 {
1718
 				if len(product_date) > 0 {
1712
 					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1719
 					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1744
 						StorehouseId:            storehouse_id,
1751
 						StorehouseId:            storehouse_id,
1745
 						AdminUserId:             admin_user_id,
1752
 						AdminUserId:             admin_user_id,
1746
 						StockCount:              stock_count,
1753
 						StockCount:              stock_count,
1754
+						RegisterNumber:          register_number,
1747
 					}
1755
 					}
1748
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1756
 					warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
1749
 
1757
 
1790
 						StorehouseId:            storehouse_id,
1798
 						StorehouseId:            storehouse_id,
1791
 						AdminUserId:             admin_user_id,
1799
 						AdminUserId:             admin_user_id,
1792
 						StockCount:              stock_count,
1800
 						StockCount:              stock_count,
1801
+						RegisterNumber:          register_number,
1793
 					}
1802
 					}
1794
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1803
 					upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
1795
 				}
1804
 				}
2511
 }
2520
 }
2512
 func (this *StockManagerApiController) DeleteCancelStockInfo() {
2521
 func (this *StockManagerApiController) DeleteCancelStockInfo() {
2513
 	id, _ := this.GetInt64("id", 0)
2522
 	id, _ := this.GetInt64("id", 0)
2514
-	fmt.Println(id)
2523
+	//fmt.Println(id)
2515
 	if id == 0 {
2524
 	if id == 0 {
2516
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2525
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2517
 		return
2526
 		return
4904
 func (this *StockManagerApiController) GetOrderDetialByOrderId() {
4913
 func (this *StockManagerApiController) GetOrderDetialByOrderId() {
4905
 
4914
 
4906
 	ids := this.GetString("id")
4915
 	ids := this.GetString("id")
4916
+
4907
 	idsArray := strings.Split(ids, ",")
4917
 	idsArray := strings.Split(ids, ",")
4908
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4918
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4909
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
4919
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
7140
 		err := service.ConsumablesDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater)
7150
 		err := service.ConsumablesDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater)
7141
 		if err != nil {
7151
 		if err != nil {
7142
 			goodErrcode := models.XtGoodErrcode{
7152
 			goodErrcode := models.XtGoodErrcode{
7143
-				UserOrgId:      item.OrgId,
7153
+				UserOrgId:      orgId,
7144
 				Errcode:        "调用出库接口报错",
7154
 				Errcode:        "调用出库接口报错",
7145
 				GoodId:         item.GoodId,
7155
 				GoodId:         item.GoodId,
7146
 				Status:         1,
7156
 				Status:         1,
7163
 		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7173
 		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7164
 		if errs != nil {
7174
 		if errs != nil {
7165
 			goodErrcode := models.XtGoodErrcode{
7175
 			goodErrcode := models.XtGoodErrcode{
7166
-				UserOrgId:      item.OrgId,
7176
+				UserOrgId:      orgId,
7167
 				Errcode:        "手动出库更新剩余出库失败",
7177
 				Errcode:        "手动出库更新剩余出库失败",
7168
 				GoodId:         item.GoodId,
7178
 				GoodId:         item.GoodId,
7169
 				Status:         1,
7179
 				Status:         1,
7190
 		errsum := service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7200
 		errsum := service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7191
 		if errsum != nil {
7201
 		if errsum != nil {
7192
 			goodErrcode := models.XtGoodErrcode{
7202
 			goodErrcode := models.XtGoodErrcode{
7193
-				UserOrgId:      item.OrgId,
7203
+				UserOrgId:      orgId,
7194
 				Errcode:        "基础库扣减库存报错",
7204
 				Errcode:        "基础库扣减库存报错",
7195
 				GoodId:         item.GoodId,
7205
 				GoodId:         item.GoodId,
7196
 				Status:         1,
7206
 				Status:         1,
7407
 
7417
 
7408
 	warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
7418
 	warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
7409
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7419
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7420
+	Creator := this.GetAdminUserInfo().AdminUser.Id
7410
 	//查询默认仓库
7421
 	//查询默认仓库
7411
 	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7422
 	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7412
 	//更改审核状态
7423
 	//更改审核状态
7413
 	err := service.UpdateCheckWarehouseInfo(warehousing_info_id)
7424
 	err := service.UpdateCheckWarehouseInfo(warehousing_info_id)
7414
 	if err == nil {
7425
 	if err == nil {
7415
 		list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7426
 		list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
7416
-		Creator := this.GetAdminUserInfo().AdminUser.Id
7427
+
7417
 		for _, item := range list {
7428
 		for _, item := range list {
7418
 			service.UpdateWarehouseInfoByIdList(item.WarehousingCount, item.ID)
7429
 			service.UpdateWarehouseInfoByIdList(item.WarehousingCount, item.ID)
7430
+
7431
+			//查询该耗材剩余库存库
7432
+			stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7433
+			var total_count int64
7434
+			var sum_in_count int64
7435
+			for _, it := range stockList {
7436
+				total_count += it.StockCount
7437
+				sum_in_count += it.WarehousingCount
7438
+			}
7439
+			//基础库插入数据
7440
+			service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count)
7441
+
7442
+			//查询该仓库是否有数据
7443
+			_, errcode := service.GetGoodStockCount(orgId, item.StorehouseId, item.GoodId)
7444
+			goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7445
+			var flush_count int64
7446
+			for _, it := range goodList {
7447
+				flush_count += it.StockCount
7448
+			}
7419
 			stockFlow := models.VmStockFlow{
7449
 			stockFlow := models.VmStockFlow{
7420
 				WarehousingId:           item.WarehousingId,
7450
 				WarehousingId:           item.WarehousingId,
7421
 				GoodId:                  item.GoodId,
7451
 				GoodId:                  item.GoodId,
7453
 				StockCount:              "",
7483
 				StockCount:              "",
7454
 				BatchNumberCount:        item.WarehousingCount,
7484
 				BatchNumberCount:        item.WarehousingCount,
7455
 				IsCheck:                 1,
7485
 				IsCheck:                 1,
7486
+				OverCount:               flush_count,
7456
 			}
7487
 			}
7457
 			//创建出库流水
7488
 			//创建出库流水
7458
 			service.CreateStockFlowOne(stockFlow)
7489
 			service.CreateStockFlowOne(stockFlow)
7459
 
7490
 
7460
-			orgId := this.GetAdminUserInfo().CurrentOrgId
7461
-			//查询该耗材剩余库存库
7462
-			stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7463
-			var total_count int64
7464
-			var sum_in_count int64
7465
-			for _, it := range stockList {
7466
-				total_count += it.StockCount
7467
-				sum_in_count += it.WarehousingCount
7468
-			}
7469
-			//基础库插入数据
7470
-			service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count)
7471
-
7472
-			//查询该仓库是否有数据
7473
-			_, errcode := service.GetGoodStockCount(orgId, item.StorehouseId, item.GoodId)
7474
-			goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7475
-			var flush_count int64
7476
-			for _, it := range goodList {
7477
-				flush_count += it.StockCount
7478
-			}
7479
 			if errcode == gorm.ErrRecordNotFound {
7491
 			if errcode == gorm.ErrRecordNotFound {
7480
 
7492
 
7481
 				goodCount := models.XtGoodStockCount{
7493
 				goodCount := models.XtGoodStockCount{
7574
 	var out_total_count int64
7586
 	var out_total_count int64
7575
 	var dealer_id int64
7587
 	var dealer_id int64
7576
 	for _, item := range list {
7588
 	for _, item := range list {
7577
-		for _, items := range manufacturerlist {
7578
-			if item.Manufacturer == items.ManufacturerName {
7579
-				manufacturer_id = items.ID
7580
-			}
7581
-		}
7582
-		for _, it := range dealerList {
7583
-			if item.Dealer == it.DealerName {
7584
-				dealer_id = it.ID
7585
-			}
7586
-		}
7589
+
7587
 		//查询该药品该批次的出库数量是否满足退库需求
7590
 		//查询该药品该批次的出库数量是否满足退库需求
7588
 		outList, _ := service.GetWarehouseOutList(item.OrgId, item.GoodId, item.WarehouseInfoId)
7591
 		outList, _ := service.GetWarehouseOutList(item.OrgId, item.GoodId, item.WarehouseInfoId)
7589
 		for _, it := range outList {
7592
 		for _, it := range outList {
7602
 			})
7605
 			})
7603
 			return
7606
 			return
7604
 		}
7607
 		}
7608
+	}
7609
+
7610
+	cancelStock := models.CancelStock{
7611
+		IsCheck: 1,
7612
+	}
7613
+	service.CheckCancelStock(cancelStock, cancel_stock_id, orgId)
7614
+
7615
+	//回退库存
7616
+	cancellist, _ := service.GetCancelStockInfoById(cancel_stock_id, orgId)
7617
+	for _, item := range cancellist {
7618
+		for _, items := range manufacturerlist {
7619
+			if item.Manufacturer == items.ManufacturerName {
7620
+				manufacturer_id = items.ID
7621
+			}
7622
+		}
7623
+		for _, it := range dealerList {
7624
+			if item.Dealer == it.DealerName {
7625
+				dealer_id = it.ID
7626
+			}
7627
+		}
7628
+		//回退库存
7629
+		service.UpdateCancelStockNumber(item.Count, item.WarehouseInfoId, orgId)
7630
+		//更新基础库库存
7631
+		service.UpdateGoodSumCount(item.Count, item.GoodId, orgId)
7632
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7633
+		//退库数量增加
7634
+		service.UpdateSumAddCancelCount(orgId, item.GoodId, item.StorehouseId, item.Count)
7635
+		var flush_count int64
7636
+		for _, it := range goodList {
7637
+			flush_count += it.StockCount
7638
+		}
7605
 
7639
 
7606
 		stockFlow := models.VmStockFlow{
7640
 		stockFlow := models.VmStockFlow{
7607
 			ID:                        0,
7641
 			ID:                        0,
7644
 			AdminUserId:               0,
7678
 			AdminUserId:               0,
7645
 			BuyPrice:                  item.Price,
7679
 			BuyPrice:                  item.Price,
7646
 			StockCount:                "",
7680
 			StockCount:                "",
7681
+			OverCount:                 flush_count,
7647
 		}
7682
 		}
7683
+		//创建流水
7648
 		service.CreateStockFlowOne(stockFlow)
7684
 		service.CreateStockFlowOne(stockFlow)
7649
-		service.ModifyAddCancelCount(item.Count, item.GoodId)
7650
-	}
7651
-
7652
-	cancelStock := models.CancelStock{
7653
-		IsCheck: 1,
7654
-	}
7655
-	service.CheckCancelStock(cancelStock, cancel_stock_id, orgId)
7656
-
7657
-	//回退库存
7658
-	cancellist, _ := service.GetCancelStockInfoById(cancel_stock_id, orgId)
7659
-	for _, item := range cancellist {
7660
-		service.UpdateCancelStockNumber(item.Count, item.WarehouseInfoId, orgId)
7661
-
7662
-		service.UpdateGoodSumCount(item.Count, item.GoodId, orgId)
7663
-		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7664
-
7665
-		service.UpdateSumAddCancelCount(orgId, item.GoodId, item.StorehouseId, item.Count)
7666
-		var flush_count int64
7667
-		for _, it := range goodList {
7668
-			flush_count += it.StockCount
7669
-		}
7685
+		//更新剩余库存
7670
 		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7686
 		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7671
 
7687
 
7672
 		//出库数量减少
7688
 		//出库数量减少
7770
 		"houseList": houseList,
7786
 		"houseList": houseList,
7771
 	})
7787
 	})
7772
 }
7788
 }
7789
+
7790
+func (this *StockManagerApiController) GetInvetoryWarehouseInfoList() {
7791
+
7792
+	storehouse_id, _ := this.GetInt64("storehouse_id")
7793
+	orgId := this.GetAdminUserInfo().CurrentOrgId
7794
+	list, _ := service.GetInvetoryWarehouseInfoList(orgId, storehouse_id)
7795
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
7796
+	dealerList, _ := service.GetAllDealerList(orgId)
7797
+	this.ServeSuccessJSON(map[string]interface{}{
7798
+		"list":             list,
7799
+		"manufacturerList": manufacturerList,
7800
+		"dealerList":       dealerList,
7801
+	})
7802
+}

+ 57 - 6
controllers/supply_order_api_contorller.go Ver arquivo

2403
 			sum_in_count += item.WarehousingCount
2403
 			sum_in_count += item.WarehousingCount
2404
 		}
2404
 		}
2405
 		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2405
 		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2406
-		//增加入库数量
2407
-		service.AddGoodSumInCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, item.WarehousingCount)
2406
+		fmt.Println("入库数量23333333333333333333333wo", item.WarehousingCount)
2407
+		//查询是否有该耗材
2408
+		goodStock, _ := service.GetGoodSumCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
2409
+		if goodStock.ID > 0 {
2410
+			//增加入库数量
2411
+			service.AddGoodSumInCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, item.WarehousingCount)
2412
+		}
2413
+		if goodStock.ID == 0 {
2414
+			stock := models.XtGoodStockCount{
2415
+				UserOrgId:        item.OrgId,
2416
+				GoodId:           item.GoodId,
2417
+				StorehouseId:     storeConfig.StorehouseOutInfo,
2418
+				Status:           1,
2419
+				Ctime:            time.Now().Unix(),
2420
+				Mtime:            0,
2421
+				StockInCount:     item.WarehousingCount,
2422
+				StockOutCount:    0,
2423
+				StockCancelCount: 0,
2424
+				FlushCount:       sum_count,
2425
+				StockActOutCount: 0,
2426
+			}
2427
+			service.CreateGoodStockCount(stock)
2428
+		}
2408
 
2429
 
2409
 		//更新剩余库存
2430
 		//更新剩余库存
2410
 		service.UpdateGoodFlushCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, sum_count)
2431
 		service.UpdateGoodFlushCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, sum_count)
2447
 		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId)
2468
 		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId)
2448
 		var sum_count int64
2469
 		var sum_count int64
2449
 		var sum_in_count int64
2470
 		var sum_in_count int64
2471
+		var sum_waresing_count int64
2472
+		baseDrug, _ := service.GetBaseDrugMedical(items.DrugId)
2450
 		for _, it := range list {
2473
 		for _, it := range list {
2451
-			baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
2452
 			if it.MaxUnit == baseDrug.MaxUnit {
2474
 			if it.MaxUnit == baseDrug.MaxUnit {
2453
 				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2475
 				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
2454
 				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2476
 				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
2456
 			sum_count += it.StockMaxNumber + it.StockMinNumber
2478
 			sum_count += it.StockMaxNumber + it.StockMinNumber
2457
 			sum_in_count += it.WarehousingCount
2479
 			sum_in_count += it.WarehousingCount
2458
 		}
2480
 		}
2481
+		if items.MaxUnit == baseDrug.MaxUnit {
2482
+			sum_waresing_count = items.WarehousingCount * baseDrug.MinNumber
2483
+		}
2484
+		if items.MaxUnit == baseDrug.MinUnit {
2485
+			sum_waresing_count = items.WarehousingCount
2486
+		}
2487
+
2459
 		service.UpdateMedicalSumCount(items.DrugId, sum_count, sum_in_count, items.OrgId)
2488
 		service.UpdateMedicalSumCount(items.DrugId, sum_count, sum_in_count, items.OrgId)
2460
 
2489
 
2461
-		//更新入库数量和剩余库存
2462
-		service.UpdateDrugCount(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId, sum_in_count, sum_count)
2490
+		//查询是否有
2491
+		drugStock, _ := service.GetDrugStockCountSix(houseConfig.DrugStorehouseOut, items.DrugId, items.OrgId)
2492
+		fmt.Println("drugStockwoowowowowoowowowo", drugStock.ID)
2493
+		if drugStock.ID == 0 {
2494
+			drug := models.XtDrugStockCount{
2495
+				UserOrgId:      items.OrgId,
2496
+				StorehouseId:   houseConfig.DrugStorehouseOut,
2497
+				SumInCount:     sum_waresing_count,
2498
+				SumOutCount:    0,
2499
+				SumCancelCount: 0,
2500
+				DrugId:         items.DrugId,
2501
+				Ctime:          time.Now().Unix(),
2502
+				Mtime:          0,
2503
+				Status:         1,
2504
+				FlushCount:     sum_count,
2505
+				SumActOutCount: 0,
2506
+			}
2507
+			service.CreateDrugStock(drug)
2508
+		}
2509
+		if drugStock.ID > 0 {
2510
+			//更新入库数量和剩余库存
2511
+			service.UpdateDrugCount(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId, sum_in_count, sum_count)
2512
+		}
2513
+
2463
 	}
2514
 	}
2464
 	fmt.Println(errs)
2515
 	fmt.Println(errs)
2465
 	for _, items := range drugFlow {
2516
 	for _, items := range drugFlow {
3830
 
3881
 
3831
 				//更改库存
3882
 				//更改库存
3832
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3883
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3833
-
3884
+				fmt.Println("更改库存3232323223322332")
3834
 				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3885
 				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3835
 
3886
 
3836
 				//扣减出库数量
3887
 				//扣减出库数量

+ 4 - 1
enums/error_code.go Ver arquivo

264
 	ErrorCodeHisPatientNoRegException = 4000000
264
 	ErrorCodeHisPatientNoRegException = 4000000
265
 
265
 
266
 	ErrorCodeCantDeleteScheduleBeforeNow = 40000001
266
 	ErrorCodeCantDeleteScheduleBeforeNow = 40000001
267
+
268
+	ErrorCodeSchedule = 50000000
267
 )
269
 )
268
 
270
 
269
 var ErrCodeMsgs = map[int]string{
271
 var ErrCodeMsgs = map[int]string{
338
 	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
340
 	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
339
 	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
341
 	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
340
 	ErrorCodeCantDeleteScheduleBeforeNow:    "不能删除今天之前的日期排班",
342
 	ErrorCodeCantDeleteScheduleBeforeNow:    "不能删除今天之前的日期排班",
341
-	ErrorCodeScheduleNotExist:               "排班不存go在",
343
+	ErrorCodeScheduleNotExist:               "排班不存在",
342
 	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
344
 	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
343
 	ErrorCodeDeleteScheduleFail:             "取消排班失败",
345
 	ErrorCodeDeleteScheduleFail:             "取消排班失败",
344
 	ErrorCodeChangeScheduleFail:             "修改排班失败",
346
 	ErrorCodeChangeScheduleFail:             "修改排班失败",
515
 	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费或已经上传的处方,无法删除",
517
 	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费或已经上传的处方,无法删除",
516
 
518
 
517
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
519
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
520
+	ErrorCodeSchedule:                 "该班次该床位已有患者",
518
 }
521
 }
519
 
522
 
520
 type SGJError struct {
523
 type SGJError struct {

+ 23 - 1
models/device_models.go Ver arquivo

145
 	Number     string     `gorm:"column:number" json:"number"`
145
 	Number     string     `gorm:"column:number" json:"number"`
146
 	GroupID    int64      `gorm:"column:group_id" json:"group_id"`
146
 	GroupID    int64      `gorm:"column:group_id" json:"group_id"`
147
 	ZoneID     int64      `gorm:"column:zone_id" json:"zone_id"`
147
 	ZoneID     int64      `gorm:"column:zone_id" json:"zone_id"`
148
-	Status     int8       `json:"-"`
148
+	Status     int64      `gorm:"column:status" json:"status" form:"status"`
149
 	CreateTime int64      `gorm:"column:ctime" json:"-"`
149
 	CreateTime int64      `gorm:"column:ctime" json:"-"`
150
 	ModifyTime int64      `gorm:"column:mtime" json:"-"`
150
 	ModifyTime int64      `gorm:"column:mtime" json:"-"`
151
 	Sort       int64      `gorm:"column:sort" json:"sort" form:"sort"`
151
 	Sort       int64      `gorm:"column:sort" json:"sort" form:"sort"`
868
 	CvcA                            float64 `gorm:"column:cvc_a" json:"cvc_a" form:"cvc_a"`
868
 	CvcA                            float64 `gorm:"column:cvc_a" json:"cvc_a" form:"cvc_a"`
869
 	CvcV                            float64 `gorm:"column:cvc_v" json:"cvc_v" form:"cvc_v"`
869
 	CvcV                            float64 `gorm:"column:cvc_v" json:"cvc_v" form:"cvc_v"`
870
 	Channel                         int64   `gorm:"column:channel" json:"channel" form:"channel"`
870
 	Channel                         int64   `gorm:"column:channel" json:"channel" form:"channel"`
871
+	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
871
 }
872
 }
872
 
873
 
873
 func (XtAssessmentAfterDislysis) TableName() string {
874
 func (XtAssessmentAfterDislysis) TableName() string {
1152
 func (SgjDeviceNumber) TableName() string {
1153
 func (SgjDeviceNumber) TableName() string {
1153
 	return "xt_device_number"
1154
 	return "xt_device_number"
1154
 }
1155
 }
1156
+
1157
+type XtScheduleSix struct {
1158
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
1159
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1160
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1161
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1162
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1163
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1164
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1165
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1166
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1167
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
1168
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
1169
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1170
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
1171
+}
1172
+
1173
+func (XtScheduleSix) TableName() string {
1174
+
1175
+	return "xt_schedule"
1176
+}

+ 42 - 0
models/dialysis.go Ver arquivo

321
 	UreaBefor                      string  `gorm:"column:urea_befor" json:"urea_befor" form:"urea_befor"`
321
 	UreaBefor                      string  `gorm:"column:urea_befor" json:"urea_befor" form:"urea_befor"`
322
 	Suction                        string  `gorm:"column:suction" json:"suction" form:"suction"`
322
 	Suction                        string  `gorm:"column:suction" json:"suction" form:"suction"`
323
 	WeightBeforRemake              string  `gorm:"column:weight_befor_remake" json:"weight_befor_remake" form:"weight_befor_remake"`
323
 	WeightBeforRemake              string  `gorm:"column:weight_befor_remake" json:"weight_befor_remake" form:"weight_befor_remake"`
324
+	Height                         string  `gorm:"column:height" json:"height" form:"height"`
325
+	Age                            string  `gorm:"column:age" json:"age" form:"age"`
326
+	HisDepartment                  string  `gorm:"column:his_department" json:"his_department" form:"his_department"`
327
+	HisBed                         string  `gorm:"column:his_bed" json:"his_bed" form:"his_bed"`
324
 }
328
 }
325
 
329
 
326
 func (PredialysisEvaluation) TableName() string {
330
 func (PredialysisEvaluation) TableName() string {
834
 	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
838
 	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
835
 	Url                        string        `gorm:"column:url" json:"url" form:"url"`
839
 	Url                        string        `gorm:"column:url" json:"url" form:"url"`
836
 	Hash                       string        `gorm:"column:hash" json:"hash" form:"hash"`
840
 	Hash                       string        `gorm:"column:hash" json:"hash" form:"hash"`
841
+	QualityNurseId             int64         `gorm:"column:quality_nurse_id" json:"quality_nurse_id" form:"quality_nurse_id"`
842
+	PunctureNeedle             string        `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
843
+	PunctureWay                string        `gorm:"column:puncture_way" json:"puncture_way" form:"puncture_way"`
844
+	DialysisDialyszers         string        `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
845
+	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
846
+	BloodAccessId              int64         `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
847
+	Mission                    string        `gorm:"column:mission" json:"mission" form:"mission"`
848
+	NucleinDate                int64         `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
837
 }
849
 }
838
 
850
 
839
 func (DialysisOrder) TableName() string {
851
 func (DialysisOrder) TableName() string {
897
 	UserName       string `gorm:"column:user_name" json:"user_name" form:"user_name"`
909
 	UserName       string `gorm:"column:user_name" json:"user_name" form:"user_name"`
898
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
910
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
899
 	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
911
 	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
912
+	QualityNurseId int64  `gorm:"column:quality_nurse_id" json:"quality_nurse_id" form:"quality_nurse_id"`
900
 }
913
 }
901
 
914
 
902
 type TreatmentMode struct {
915
 type TreatmentMode struct {
952
 	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
965
 	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
953
 	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
966
 	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
954
 	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
967
 	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
968
+	Diacrisis                    string `gorm:"column:diacrisis" json:"diacrisis" form:"diacrisis"`
955
 	Tumble                       int64  `gorm:"column:tumble" json:"tumble" form:"tumble"`
969
 	Tumble                       int64  `gorm:"column:tumble" json:"tumble" form:"tumble"`
970
+	HisDepartment                string `gorm:"column:his_department" json:"his_department" form:"his_department"`
971
+	HisBed                       string `gorm:"column:his_bed" json:"his_bed" form:"his_bed"`
956
 }
972
 }
957
 
973
 
958
 func (ReceiveTreatmentAsses) TableName() string {
974
 func (ReceiveTreatmentAsses) TableName() string {
1189
 func (HisDoctorAdvice) TableName() string {
1205
 func (HisDoctorAdvice) TableName() string {
1190
 	return "his_doctor_advice_info"
1206
 	return "his_doctor_advice_info"
1191
 }
1207
 }
1208
+
1209
+type DialysisScheduleSix struct {
1210
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1211
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1212
+	PartitionId  int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1213
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1214
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1215
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1216
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1217
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1218
+	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1219
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
1220
+	Name         string `gorm:"column:name" json:"name" form:"name"`
1221
+}
1222
+
1223
+type DialysisScheduleSeven struct {
1224
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
1225
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1226
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1227
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1228
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
1229
+}
1230
+
1231
+func (DialysisScheduleSeven) TableName() string {
1232
+	return "xt_schedule"
1233
+}

+ 8 - 8
models/drug.go Ver arquivo

218
 }
218
 }
219
 
219
 
220
 type BaseDrugLibTwenty struct {
220
 type BaseDrugLibTwenty struct {
221
-	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
222
-	DrugName            string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
223
-	Status              int64  `gorm:"column:status" json:"status" form:"status"`
224
-	OrgId               int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
225
-	MaxUnit             string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
226
-	MinNumber           int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
227
-	MinUnit             string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
228
-	DrugStockLimitCount int64  `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
221
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
222
+	DrugName       string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
223
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
224
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
225
+	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
226
+	MinNumber      int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
227
+	MinUnit        string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
228
+	DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit_count" form:"drug_stock_limit"`
229
 }
229
 }
230
 
230
 
231
 func (BaseDrugLibTwenty) TableName() string {
231
 func (BaseDrugLibTwenty) TableName() string {

+ 55 - 53
models/drug_stock.go Ver arquivo

377
 	PackingUnit             string  `json:"packing_unit"`
377
 	PackingUnit             string  `json:"packing_unit"`
378
 	Dosage                  int64   `json:"dosage"`
378
 	Dosage                  int64   `json:"dosage"`
379
 	ExpireDate              int64   `json:"expire_date"`
379
 	ExpireDate              int64   `json:"expire_date"`
380
+	ConsumableType          int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
380
 }
381
 }
381
 
382
 
382
 type DrugFlow struct {
383
 type DrugFlow struct {
383
-	ID                        int64                `gorm:"column:id" json:"id" form:"id"`
384
-	WarehousingId             int64                `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
385
-	DrugId                    int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
386
-	Number                    string               `gorm:"column:number" json:"number" form:"number"`
387
-	BatchNumber               string               `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
388
-	Count                     int64                `gorm:"column:count" json:"count" form:"count"`
389
-	UserOrgId                 int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
390
-	PatientId                 int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
391
-	SystemTime                int64                `gorm:"column:system_time" json:"system_time" form:"system_time"`
392
-	ConsumableType            int64                `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
393
-	IsSys                     int64                `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
394
-	WarehousingOrder          string               `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
395
-	WarehouseOutId            int64                `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
396
-	WarehouseOutOrderNumber   string               `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
397
-	IsEdit                    int64                `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
398
-	CancelStockId             int64                `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
399
-	CancelOrderNumber         string               `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
400
-	Manufacturer              int64                `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
401
-	Dealer                    int64                `gorm:"column:dealer" json:"dealer" form:"dealer"`
402
-	Creator                   int64                `gorm:"column:creator" json:"creator" form:"creator"`
403
-	UpdateCreator             int64                `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
404
-	Status                    int64                `gorm:"column:status" json:"status" form:"status"`
405
-	Ctime                     int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
406
-	Mtime                     int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
407
-	Price                     float64              `gorm:"column:price" json:"price" form:"price"`
408
-	WarehousingDetailId       int64                `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
409
-	WarehouseOutDetailId      int64                `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
410
-	CancelOutDetailId         int64                `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
411
-	ExpireDate                int64                `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
412
-	ProductDate               int64                `gorm:"column:product_date" json:"product_date" form:"product_date"`
413
-	MaxUnit                   string               `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
414
-	MinUnit                   string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
415
-	StockMaxNumber            int64                `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
416
-	StockMinNumber            int64                `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
417
-	LastStockMaxNumber        int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
418
-	LastStockMinNumber        int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
419
-	DrugWarehouseInfo         []*DrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
420
-	BaseDrugLib               BaseDrugLib          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
421
-	AdviceId                  int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
422
-	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
423
-	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
424
-	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
425
-	StorehouseId              int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
426
-	SecondWarehouseInfoId     int64                `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
427
-	AdminUserId               int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
428
-	LastPrice                 float64              `gorm:"column:last_price" json:"last_price" form:"last_price"`
429
-	StockCount                string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
430
-	PharmacyId                int64                `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
431
-	DrugWarehouseInfoOne      DrugWarehouseInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
432
-	IsRead                    int64                `gorm:"column:is_read" json:"is_read" form:"is_read"`
433
-	IsCheck                   int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
434
-	OverCount                 int64                `gorm:"column:over_count" json:"over_count" form:"over_count"`
435
-	RetailPrice               float64              `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
384
+	ID                        int64                  `gorm:"column:id" json:"id" form:"id"`
385
+	WarehousingId             int64                  `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
386
+	DrugId                    int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
387
+	Number                    string                 `gorm:"column:number" json:"number" form:"number"`
388
+	BatchNumber               string                 `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
389
+	Count                     int64                  `gorm:"column:count" json:"count" form:"count"`
390
+	UserOrgId                 int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
391
+	PatientId                 int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
392
+	SystemTime                int64                  `gorm:"column:system_time" json:"system_time" form:"system_time"`
393
+	ConsumableType            int64                  `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
394
+	IsSys                     int64                  `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
395
+	WarehousingOrder          string                 `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
396
+	WarehouseOutId            int64                  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
397
+	WarehouseOutOrderNumber   string                 `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
398
+	IsEdit                    int64                  `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
399
+	CancelStockId             int64                  `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
400
+	CancelOrderNumber         string                 `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
401
+	Manufacturer              int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
402
+	Dealer                    int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
403
+	Creator                   int64                  `gorm:"column:creator" json:"creator" form:"creator"`
404
+	UpdateCreator             int64                  `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
405
+	Status                    int64                  `gorm:"column:status" json:"status" form:"status"`
406
+	Ctime                     int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
407
+	Mtime                     int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
408
+	Price                     float64                `gorm:"column:price" json:"price" form:"price"`
409
+	WarehousingDetailId       int64                  `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
410
+	WarehouseOutDetailId      int64                  `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
411
+	CancelOutDetailId         int64                  `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
412
+	ExpireDate                int64                  `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
413
+	ProductDate               int64                  `gorm:"column:product_date" json:"product_date" form:"product_date"`
414
+	MaxUnit                   string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
415
+	MinUnit                   string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
416
+	StockMaxNumber            int64                  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
417
+	StockMinNumber            int64                  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
418
+	LastStockMaxNumber        int64                  `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
419
+	LastStockMinNumber        int64                  `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
420
+	DrugWarehouseInfo         []*DrugWarehouseInfo   `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
421
+	BaseDrugLib               BaseDrugLib            `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
422
+	AdviceId                  int64                  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
423
+	SupplyWarehouseId         int64                  `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
424
+	SupplyCancelOutId         int64                  `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
425
+	SupplyWarehouseDetailInfo int64                  `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
426
+	StorehouseId              int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
427
+	SecondWarehouseInfoId     int64                  `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
428
+	AdminUserId               int64                  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
429
+	LastPrice                 float64                `gorm:"column:last_price" json:"last_price" form:"last_price"`
430
+	StockCount                string                 `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
431
+	PharmacyId                int64                  `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
432
+	DrugWarehouseInfoOne      DrugWarehouseInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
433
+	IsRead                    int64                  `gorm:"column:is_read" json:"is_read" form:"is_read"`
434
+	IsCheck                   int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
435
+	OverCount                 int64                  `gorm:"column:over_count" json:"over_count" form:"over_count"`
436
+	RetailPrice               float64                `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
437
+	XtDrugWarehouseOutInfo    XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
436
 }
438
 }
437
 
439
 
438
 func (DrugFlow) TableName() string {
440
 func (DrugFlow) TableName() string {

+ 110 - 15
models/good_models.go Ver arquivo

15
 	Number         int64  `gorm:"column:number" json:"number"`
15
 	Number         int64  `gorm:"column:number" json:"number"`
16
 	OutStock       int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
16
 	OutStock       int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
17
 	StockAttribute int64  `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
17
 	StockAttribute int64  `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
18
+	IsOpen         int64  `gorm:"column:is_open" json:"is_open" form:"is_open"`
18
 }
19
 }
19
 
20
 
20
 func (GoodsType) TableName() string {
21
 func (GoodsType) TableName() string {
145
 }
146
 }
146
 
147
 
147
 type GoodsTypeOne struct {
148
 type GoodsTypeOne struct {
148
-	ID             int64       `gorm:"column:id" json:"id"`
149
-	TypeCode       string      `gorm:"column:type_code" json:"type_code"`
150
-	TypeName       string      `gorm:"column:type_name" json:"type_name"`
151
-	Remark         string      `gorm:"column:remark" json:"remark"`
152
-	Ctime          int64       `gorm:"column:ctime" json:"ctime"`
153
-	Mtime          int64       `gorm:"column:mtime" json:"mtime"`
154
-	Creater        int64       `gorm:"column:creater" json:"creater"`
155
-	Modifier       int64       `gorm:"column:modifier" json:"modifier"`
156
-	OrgId          int64       `gorm:"column:org_id" json:"org_id"`
157
-	Status         int64       `gorm:"column:status" json:"status"`
158
-	Type           int64       `gorm:"column:type" json:"type"`
159
-	Number         int64       `gorm:"column:number" json:"number"`
160
-	OutStock       int64       `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
161
-	StockAttribute int64       `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
162
-	GoodInfo       []*GoodInfo `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"GoodInfo"`
149
+	ID             int64                    `gorm:"column:id" json:"id"`
150
+	TypeCode       string                   `gorm:"column:type_code" json:"type_code"`
151
+	TypeName       string                   `gorm:"column:type_name" json:"type_name"`
152
+	Remark         string                   `gorm:"column:remark" json:"remark"`
153
+	Ctime          int64                    `gorm:"column:ctime" json:"ctime"`
154
+	Mtime          int64                    `gorm:"column:mtime" json:"mtime"`
155
+	Creater        int64                    `gorm:"column:creater" json:"creater"`
156
+	Modifier       int64                    `gorm:"column:modifier" json:"modifier"`
157
+	OrgId          int64                    `gorm:"column:org_id" json:"org_id"`
158
+	Status         int64                    `gorm:"column:status" json:"status"`
159
+	Type           int64                    `gorm:"column:type" json:"type"`
160
+	Number         int64                    `gorm:"column:number" json:"number"`
161
+	OutStock       int64                    `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
162
+	StockAttribute int64                    `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
163
+	GoodInfo       []*GoodInformationThirty `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"GoodInfo"`
163
 }
164
 }
164
 
165
 
165
 func (GoodsTypeOne) TableName() string {
166
 func (GoodsTypeOne) TableName() string {
194
 func (XtCancelStockInfo) TableName() string {
195
 func (XtCancelStockInfo) TableName() string {
195
 	return "xt_cancel_stock_info"
196
 	return "xt_cancel_stock_info"
196
 }
197
 }
198
+
199
+type BloodGoodsType struct {
200
+	ID             int64  `gorm:"column:id" json:"id"`
201
+	TypeCode       string `gorm:"column:type_code" json:"type_code"`
202
+	TypeName       string `gorm:"column:type_name" json:"type_name"`
203
+	Remark         string `gorm:"column:remark" json:"remark"`
204
+	Ctime          int64  `gorm:"column:ctime" json:"ctime"`
205
+	Mtime          int64  `gorm:"column:mtime" json:"mtime"`
206
+	Creater        int64  `gorm:"column:creater" json:"creater"`
207
+	Modifier       int64  `gorm:"column:modifier" json:"modifier"`
208
+	OrgId          int64  `gorm:"column:org_id" json:"org_id"`
209
+	Status         int64  `gorm:"column:status" json:"status"`
210
+	Type           int64  `gorm:"column:type" json:"type"`
211
+	Number         int64  `gorm:"column:number" json:"number"`
212
+	OutStock       int64  `gorm:"column:out_stock" json:"out_stock" form:"out_stock"`
213
+	StockAttribute int64  `gorm:"column:stock_attribute" json:"stock_attribute" form:"stock_attribute"`
214
+	IsOpen         int64  `gorm:"column:is_open" json:"is_open" form:"is_open"`
215
+}
216
+
217
+func (BloodGoodsType) TableName() string {
218
+	return "xt_goods_type"
219
+}
220
+
221
+type GoodInformationThirty struct {
222
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
223
+	GoodCode                    string  `gorm:"column:good_code" json:"good_code" form:"good_code"`
224
+	SpecificationName           string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
225
+	GoodTypeId                  int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
226
+	GoodUnit                    int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
227
+	BuyPrice                    float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
228
+	SellPrice                   float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
229
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
230
+	Ctime                       int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
231
+	Mtime                       int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
232
+	Manufacturer                int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
233
+	Dealer                      int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
234
+	ExpiryDateWarnDayCount      int64   `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
235
+	StockWarnCount              int64   `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
236
+	IsReuse                     int64   `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
237
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
238
+	FilmArea                    string  `gorm:"column:film_area" json:"film_area" form:"film_area"`
239
+	IsUse                       int64   `gorm:"column:is_use" json:"is_use" form:"is_use"`
240
+	FilmMaterialQuality         string  `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
241
+	OrgId                       int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
242
+	Modifier                    int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
243
+	Creater                     int64   `gorm:"column:creater" json:"creater" form:"creater"`
244
+	GoodName                    string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
245
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
246
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
247
+	GoodKind                    int64   `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
248
+	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
249
+	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
250
+	MedicalInsuranceNumber      string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
251
+	IsSpecialDiseases           int64   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
252
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
253
+	StatisticsCategory          int64   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
254
+	GoodStatus                  string  `gorm:"column:good_status" json:"good_status" form:"good_status"`
255
+	DefaultCount                int64   `gorm:"column:default_count" json:"default_count" form:"default_count"`
256
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
257
+	IsChargeUse                 int64   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
258
+	IsChargePredict             int64   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
259
+	IsStatisticsWork            int64   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
260
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
261
+	Sort                        int64   `gorm:"column:sort" json:"sort" form:"sort"`
262
+	IsDoctorUse                 int64   `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
263
+	Agent                       string  `gorm:"column:agent" json:"agent" form:"agent"`
264
+	GoodNumber                  string  `gorm:"column:good_number" json:"good_number" form:"good_number"`
265
+	CommdityCode                string  `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
266
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
267
+	ProductionType              string  `gorm:"column:production_type" json:"production_type" form:"production_type"`
268
+	SpecialMedical              string  `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
269
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
270
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
271
+	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
272
+	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
273
+	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
274
+	DefaultCountUnit            string  `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
275
+	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
276
+	RegisterNumber              string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
277
+	ProvincesCode               string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
278
+	IsUser                      int64   `gorm:"column:is_user" json:"is_user" form:"is_user"`
279
+	Number                      string  `gorm:"column:number" json:"number" form:"number"`
280
+	IsWarehouse                 string  `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
281
+	BatchRetaiPrice             float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
282
+	SumCount                    int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
283
+	SumInCount                  int64   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
284
+	TotalCount                  int64   `gorm:"column:total_count" json:"total_count" form:"total_count"`
285
+	SumOutCount                 int64   `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
286
+	SumCancelCount              int64   `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
287
+}
288
+
289
+func (GoodInformationThirty) TableName() string {
290
+	return "xt_good_information"
291
+}

+ 1 - 0
models/his_models.go Ver arquivo

859
 	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
859
 	IsCheckTeam          int64        `gorm:"-" json:"is_check_team" form:"is_check_team"`
860
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
860
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
861
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
861
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
862
+	IsOut                int64        `gorm:"column:is_out" json:"is_out" form:"is_out"` //新增字段
862
 }
863
 }
863
 
864
 
864
 func (HisPrescriptionProject) TableName() string {
865
 func (HisPrescriptionProject) TableName() string {

+ 255 - 27
models/new_stock_models.go Ver arquivo

145
 }
145
 }
146
 
146
 
147
 type XtDialysisSetting struct {
147
 type XtDialysisSetting struct {
148
-	ID                    int64 `gorm:"column:id" json:"id" form:"id"`
149
-	UserOrgId             int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
150
-	Status                int64 `gorm:"column:status" json:"status" form:"status"`
151
-	DeviceNumber          int64 `gorm:"column:device_number" json:"device_number" form:"device_number"`
152
-	DeviceType            int64 `gorm:"column:device_type" json:"device_type" form:"device_type"`
153
-	Name                  int64 `gorm:"column:name" json:"name" form:"name"`
154
-	AdmissionNumber       int64 `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
155
-	DialysisNo            int64 `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
156
-	WeightBefor           int64 `gorm:"column:weight_befor" json:"weight_befor" form:"weight_befor"`
157
-	DryWeight             int64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
158
-	BloodPressure         int64 `gorm:"column:blood_pressure" json:"blood_pressure" form:"blood_pressure"`
159
-	UltrafiltrationVolume int64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume" form:"ultrafiltration_volume"`
160
-	InternalFistula       int64 `gorm:"column:internal_fistula" json:"internal_fistula" form:"internal_fistula"`
161
-	BloodFlowVolume       int64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
162
-	Anticoagulant         int64 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
163
-	SealingFluidDispose   int64 `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
164
-	ModeId                int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
165
-	DialysisTime          int64 `gorm:"column:dialysis_time" json:"dialysis_time" form:"dialysis_time"`
166
-	DialysisDialyszers    int64 `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
167
-	DialysisIrrigation    int64 `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
168
-	Gaijiliang            int64 `gorm:"column:gaijiliang" json:"gaijiliang" form:"gaijiliang"`
169
-	Kalium                int64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
170
-	DisplaceLiquiValue    int64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
171
-	Bicarbonate           int64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
172
-	Glucose               int64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
173
-	Ctime                 int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
174
-	Mtime                 int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
148
+	ID                         int64 `gorm:"column:id" json:"id" form:"id"`
149
+	UserOrgId                  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
150
+	Status                     int64 `gorm:"column:status" json:"status" form:"status"`
151
+	DeviceNumber               int64 `gorm:"column:device_number" json:"device_number" form:"device_number"`
152
+	DeviceType                 int64 `gorm:"column:device_type" json:"device_type" form:"device_type"`
153
+	Name                       int64 `gorm:"column:name" json:"name" form:"name"`
154
+	AdmissionNumber            int64 `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
155
+	DialysisNo                 int64 `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
156
+	WeightBefor                int64 `gorm:"column:weight_befor" json:"weight_befor" form:"weight_befor"`
157
+	DryWeight                  int64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
158
+	BloodPressure              int64 `gorm:"column:blood_pressure" json:"blood_pressure" form:"blood_pressure"`
159
+	UltrafiltrationVolume      int64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume" form:"ultrafiltration_volume"`
160
+	InternalFistula            int64 `gorm:"column:internal_fistula" json:"internal_fistula" form:"internal_fistula"`
161
+	BloodFlowVolume            int64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
162
+	Anticoagulant              int64 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
163
+	SealingFluidDispose        int64 `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
164
+	ModeId                     int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
165
+	DialysisTime               int64 `gorm:"column:dialysis_time" json:"dialysis_time" form:"dialysis_time"`
166
+	DialysisDialyszers         int64 `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
167
+	DialysisIrrigation         int64 `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
168
+	Gaijiliang                 int64 `gorm:"column:gaijiliang" json:"gaijiliang" form:"gaijiliang"`
169
+	Kalium                     int64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
170
+	DisplaceLiquiValue         int64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
171
+	Bicarbonate                int64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
172
+	Glucose                    int64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
173
+	Ctime                      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
174
+	Mtime                      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
175
+	Sodium                     int64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
176
+	Calcium                    int64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
177
+	BloodAccess                int64 `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
178
+	DialyzerPerfusionApparatus int64 `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
179
+	DisplaceLiquiPart          int64 `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
175
 }
180
 }
176
 
181
 
177
 func (XtDialysisSetting) TableName() string {
182
 func (XtDialysisSetting) TableName() string {
178
 	return "xt_dialysis_setting"
183
 	return "xt_dialysis_setting"
179
 }
184
 }
185
+
186
+type VmStockFlowTwenty struct {
187
+	ID                  int64           `gorm:"column:id" json:"id" form:"id"`
188
+	WarehousingId       int64           `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
189
+	GoodId              int64           `gorm:"column:good_id" json:"good_id" form:"good_id"`
190
+	Count               int64           `gorm:"column:count" json:"count" form:"count"`
191
+	UserOrgId           int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
192
+	PatientId           int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
193
+	SystemTime          int64           `gorm:"column:system_time" json:"system_time" form:"system_time"`
194
+	ConsumableType      int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
195
+	IsSys               int64           `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
196
+	Price               float64         `gorm:"column:price" json:"price" form:"price"`
197
+	WarehousingDetailId int64           `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
198
+	BuyPrice            float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
199
+	IsRead              int64           `gorm:"column:is_read" json:"is_read" form:"is_read"`
200
+	OverCount           int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
201
+	Ctime               int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
202
+	WarehousingInfo     WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
203
+}
204
+
205
+func (VmStockFlowTwenty) TableName() string {
206
+	return "xt_stock_flow"
207
+}
208
+
209
+type GoodInfoTwenty struct {
210
+	ID                     int64                   `gorm:"column:id" json:"id" form:"id"`
211
+	SpecificationName      string                  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
212
+	GoodTypeId             int64                   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
213
+	BuyPrice               float64                 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
214
+	Manufacturer           int64                   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
215
+	Status                 int64                   `gorm:"column:status" json:"status" form:"status"`
216
+	OrgId                  int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
217
+	GoodName               string                  `gorm:"column:good_name" json:"good_name" form:"good_name"`
218
+	RetailPrice            float64                 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
219
+	Ctime                  int64                   `gorm:"column:ctime" json:"ctime" form:"ctime"`
220
+	PackingUnit            string                  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
221
+	PackingPrice           float64                 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
222
+	StWarehousingInfo      []*StWarehousingInfo    `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
223
+	WarehousingInfoOne     []*StartWarehousingInfo `gorm:"json:"warehouse_info"` //期间增加
224
+	WarehousingInfoStart   []*StartWarehousingInfo `gorm:"json:"warehouse_info_start"`
225
+	WarehousingInfoEnd     []*StartWarehousingInfo `gorm:"json:"warehouse_info_end"`
226
+	WarehouseOutInfoEnd    []*VmStockFlowTwenty
227
+	WarehouseOutInfoStart  []*VmStockFlowTwenty
228
+	WarehouseInfoEnd       []*VmStockFlowTwenty //期末入库量
229
+	StartFlowWarehouseInfo []*VmStockFlowTwenty //本期增加
230
+	//期初结余
231
+	StartFlowInfo    []*VmStockFlowTwenty
232
+	StartOutFlowInfo []*VmStockFlowTwenty
233
+	//期末结余
234
+	EndFlowInfo    []*VmStockFlowTwenty
235
+	EndFlowOutInfo []*VmStockFlowTwenty
236
+	//期初退库
237
+	StartCancelFlowInfo []*VmStockFlowTwenty
238
+	//期末退库
239
+	EndCancelFLowInfo []*VmStockFlowTwenty
240
+
241
+	StartEndCancelFLowInfo []*VmStockFlowTwenty
242
+
243
+	WareStartStockInventoryProfit []*VmStockFlowTwenty //期初盘盈
244
+	WareStartStockInventoryLosses []*VmStockFlowTwenty //期初盘亏
245
+
246
+	WareEndStockInventoryProfit []*VmStockFlowTwenty //期末盘盈
247
+	WareEndStockInventoryLosses []*VmStockFlowTwenty //期末盘亏
248
+
249
+	WareStartEndStockInventoryProfit []*VmStockFlowTwenty //期间盘盈
250
+	WareStartEndStockInventoryLosses []*VmStockFlowTwenty //期间盘亏
251
+
252
+	//期初结余
253
+	GoodStartFlowInfo VmStockFlowTwenty
254
+	//期末结余
255
+	GoodEndFlowInfo VmStockFlowTwenty
256
+}
257
+
258
+func (GoodInfoTwenty) TableName() string {
259
+	return "xt_good_information"
260
+}
261
+
262
+type CancelStockInfoTwenty struct {
263
+	ID              int64   `gorm:"column:id" json:"id"`
264
+	GoodId          int64   `gorm:"column:good_id" json:"good_id"`
265
+	Count           int64   `gorm:"column:count" json:"count"`
266
+	Price           float64 `gorm:"column:price" json:"price"`
267
+	Ctime           int64   `gorm:"column:ctime" json:"ctime"`
268
+	Mtime           int64   `gorm:"column:mtime" json:"mtime"`
269
+	Status          int64   `gorm:"column:status" json:"status"`
270
+	OrgId           int64   `gorm:"column:org_id" json:"org_id"`
271
+	Number          string  `gorm:"column:number" json:"number" form:"number"`
272
+	WarehouseInfoId int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
273
+	PatientId       int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
274
+	RecordDate      int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
275
+	IsCheck         int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
276
+}
277
+
278
+func (CancelStockInfoTwenty) TableName() string {
279
+	return "xt_cancel_stock_info"
280
+}
281
+
282
+type WarehouseOutInfoTwenty struct {
283
+	ID               int64           `gorm:"column:id" json:"id"`
284
+	WarehouseOutId   int64           `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
285
+	WarehouseInfotId int64           `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
286
+	GoodId           int64           `gorm:"column:good_id" json:"good_id"`
287
+	Count            int64           `gorm:"column:count" json:"count"`
288
+	Price            float64         `gorm:"column:price" json:"price"`
289
+	TotalPrice       float64         `gorm:"column:total_price" json:"total_price"`
290
+	Mtime            int64           `gorm:"column:mtime" json:"mtime"`
291
+	Ctime            int64           `gorm:"column:ctime" json:"ctime"`
292
+	Status           int64           `gorm:"column:status" json:"status"`
293
+	OrgId            int64           `gorm:"column:org_id" json:"org_id"`
294
+	IsSys            int64           `gorm:"column:is_sys" json:"is_sys"`
295
+	SysRecordTime    int64           `gorm:"column:sys_record_time" json:"sys_record_time"`
296
+	PatientId        int64           `gorm:"column:patient_id" json:"patient_id"`
297
+	ConsumableType   int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
298
+	ProjectId        int64           `gorm:"column:project_id" json:"project_id" form:"project_id"`
299
+	StorehouseId     int64           `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
300
+	BuyPrice         float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
301
+	StockCount       string          `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
302
+	IsCheck          int64           `gorm:"column:is_check" json:"is_check" form:"is_check"`
303
+	WarehousingInfo  WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId" `
304
+	OverCount        int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
305
+}
306
+
307
+func (WarehouseOutInfoTwenty) TableName() string {
308
+	return "xt_warehouse_out_info"
309
+}
310
+
311
+type WarehousingInfoTwenty struct {
312
+	ID               int64   `gorm:"column:id" json:"id"`
313
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id"`
314
+	GoodId           int64   `gorm:"column:good_id" json:"good_id"`
315
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count"`
316
+	Price            float64 `gorm:"column:price" json:"price"`
317
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price"`
318
+	Dealer           int64   `gorm:"column:dealer" json:"dealer"`
319
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer"`
320
+	Ctime            int64   `gorm:"column:ctime" json:"ctime"`
321
+	Mtime            int64   `gorm:"column:mtime" json:"mtime"`
322
+	Status           int64   `gorm:"column:status" json:"status"`
323
+	OrgId            int64   `gorm:"column:org_id" json:"org_id"`
324
+	StockCount       int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
325
+	WarehouseInfoId  int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
326
+	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
327
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
328
+	IsCheck          int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
329
+}
330
+
331
+func (WarehousingInfoTwenty) TableName() string {
332
+	return "xt_warehouse_info"
333
+}
334
+
335
+type VmBaseDrugTwenty struct {
336
+	ID                               int64             `gorm:"column:id" json:"id" form:"id"`
337
+	DrugType                         int64             `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
338
+	DrugName                         string            `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
339
+	MaxUnit                          string            `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
340
+	MinNumber                        int64             `gorm:"column:min_number" json:"min_number" form:"min_number"`
341
+	MinUnit                          string            `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
342
+	Dose                             string            `gorm:"column:dose" json:"dose" form:"dose"`
343
+	DoseUnit                         string            `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
344
+	RetailPrice                      float64           `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
345
+	MinPrice                         float64           `gorm:"column:min_price" json:"min_price" form:"min_price"`
346
+	LastPrice                        float64           `gorm:"column:last_price" json:"last_price" form:"last_price"`
347
+	Manufacturer                     int64             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
+	Status                           int64             `gorm:"column:status" json:"status" form:"status"`
349
+	Ctime                            int64             `gorm:"column:ctime" json:"ctime" form:"ctime"`
350
+	Mtime                            int64             `gorm:"column:mtime" json:"mtime" form:"mtime"`
351
+	OrgId                            int64             `gorm:"column:org_id" json:"org_id" form:"org_id"`
352
+	DrugFlowWarehouseInfo            []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_flow_info"`
353
+	DrugActFlowWarehouseInfo         []*DrugFlowTwenty `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_act_flow_info"`
354
+	DrugWarehouseInfoStart           []*DrugFlowTwenty //期初入库结余
355
+	DrugWarehouseOutInfoStart        []*DrugFlowTwenty //期初出库结余
356
+	DrugWarehouseOutInfoEnd          []*DrugFlowTwenty //期末出库结余
357
+	DrugWarehouseInfoEnd             []*DrugFlowTwenty //期末入库结余
358
+	DrugWarehouseInfoStartEnd        []*DrugFlowTwenty //期中增加
359
+	DrugWarehouseOutInfoStartEnd     []*DrugFlowTwenty //  期中减少
360
+	WareStartStockInventoryProfit    []*DrugFlowTwenty //期初盘盈
361
+	WareStartStockInventoryLosses    []*DrugFlowTwenty //期初盘亏
362
+	WareEndStockInventoryProfit      []*DrugFlowTwenty //期末盘盈
363
+	WareEndStockInventoryLosses      []*DrugFlowTwenty //期末盘亏
364
+	WareStartEndStockInventoryProfit []*DrugFlowTwenty //期间盘盈
365
+	WareStartEndStockInventoryLosses []*DrugFlowTwenty //期间盘亏
366
+	WareStartStockCancelInfo         []*DrugFlowTwenty //期初结余退库
367
+	WareEndStockCancelInfo           []*DrugFlowTwenty //期末结余退库
368
+	WareStartEndStockCancelInfo      []*DrugFlowTwenty //期中减少退库
369
+
370
+	DrugStatFlow DrugFlowTwenty
371
+	DrugEndFlow  DrugFlowTwenty
372
+}
373
+
374
+func (VmBaseDrugTwenty) TableName() string {
375
+	return "xt_base_drug"
376
+}
377
+
378
+type DrugFlowTwenty struct {
379
+	ID                     int64                  `gorm:"column:id" json:"id" form:"id"`
380
+	WarehousingId          int64                  `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
381
+	DrugId                 int64                  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
382
+	Count                  int64                  `gorm:"column:count" json:"count" form:"count"`
383
+	UserOrgId              int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
384
+	PatientId              int64                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
385
+	SystemTime             int64                  `gorm:"column:system_time" json:"system_time" form:"system_time"`
386
+	ConsumableType         int64                  `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
387
+	Manufacturer           int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
388
+	Status                 int64                  `gorm:"column:status" json:"status" form:"status"`
389
+	Ctime                  int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
390
+	Mtime                  int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
391
+	Price                  float64                `gorm:"column:price" json:"price" form:"price"`
392
+	WarehousingDetailId    int64                  `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
393
+	WarehouseOutDetailId   int64                  `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
394
+	CancelOutDetailId      int64                  `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
395
+	MaxUnit                string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
396
+	MinUnit                string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
397
+	StorehouseId           int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
398
+	DrugWarehouseInfoOne   DrugWarehouseInfo      `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingDetailId"json:"xt_drug_warehouse_info" `
399
+	IsRead                 int64                  `gorm:"column:is_read" json:"is_read" form:"is_read"`
400
+	IsCheck                int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
401
+	OverCount              int64                  `gorm:"column:over_count" json:"over_count" form:"over_count"`
402
+	XtDrugWarehouseOutInfo XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
403
+}
404
+
405
+func (DrugFlowTwenty) TableName() string {
406
+	return "xt_drug_flow"
407
+}

+ 39 - 6
models/patient_models.go Ver arquivo

23
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
23
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
24
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
24
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
25
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
25
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
26
+	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
26
 }
27
 }
27
 
28
 
28
 func (MSchedualPatientList) TableName() string {
29
 func (MSchedualPatientList) TableName() string {
37
 	// PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id"`
38
 	// PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id"`
38
 	Stage int64 `gorm:"column:stage" json:"stage"`
39
 	Stage int64 `gorm:"column:stage" json:"stage"`
39
 	// Remark         string `gorm:"column:remark" json:"remark"`
40
 	// Remark         string `gorm:"column:remark" json:"remark"`
40
-	BedID         int64                 `gorm:"column:bed_id" json:"bed_id"`
41
-	StartNurse    int64                 `gorm:"column:start_nurse" json:"start_nurse"`
42
-	Status        int64                 `gorm:"column:status" json:"status"`
43
-	DeviceNumber  *MDeviceNumberForList `gorm:"ForeignKey:BedID" json:"device_number"`
44
-	Creator       int64                 `gorm:"column:creator" json:"creator"`
45
-	WashpipeNurse int64                 `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
41
+	BedID              int64                 `gorm:"column:bed_id" json:"bed_id"`
42
+	StartNurse         int64                 `gorm:"column:start_nurse" json:"start_nurse"`
43
+	Status             int64                 `gorm:"column:status" json:"status"`
44
+	DeviceNumber       *MDeviceNumberForList `gorm:"ForeignKey:BedID" json:"device_number"`
45
+	Creator            int64                 `gorm:"column:creator" json:"creator"`
46
+	WashpipeNurse      int64                 `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
47
+	NucleinDate        int64                 `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
48
+	EndTime            int64                 `gorm:"column:end_time" json:"end_time" form:"end_time"`
49
+	DialysisIrrigation string                `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
50
+	DialysisDialyszers string                `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
46
 }
51
 }
47
 
52
 
48
 func (MDialysisOrderForList) TableName() string {
53
 func (MDialysisOrderForList) TableName() string {
49
 	return "xt_dialysis_order"
54
 	return "xt_dialysis_order"
50
 }
55
 }
51
 
56
 
57
+type MDialysisOrderForListSix struct {
58
+	ID                 int64  `gorm:"column:id" json:"id"`
59
+	DialysisDate       int64  `gorm:"column:dialysis_date" json:"dialysis_date"`
60
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id"`
61
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id"`
62
+	Stage              int64  `gorm:"column:stage" json:"stage"`
63
+	BedID              int64  `gorm:"column:bed_id" json:"bed_id"`
64
+	StartNurse         int64  `gorm:"column:start_nurse" json:"start_nurse"`
65
+	Status             int64  `gorm:"column:status" json:"status"`
66
+	Creator            int64  `gorm:"column:creator" json:"creator"`
67
+	WashpipeNurse      int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
68
+	NucleinDate        int64  `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
69
+	EndTime            int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
70
+	DialysisIrrigation string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
71
+	DialysisDialyszers string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
72
+}
73
+
74
+func (MDialysisOrderForListSix) TableName() string {
75
+	return "xt_dialysis_order"
76
+}
77
+
52
 type VMTreatmentSummaryForList struct {
78
 type VMTreatmentSummaryForList struct {
53
 	ID              int64  `gorm:"column:id" json:"id"`
79
 	ID              int64  `gorm:"column:id" json:"id"`
54
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id"`
80
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id"`
192
 	DryWeight                float64 `gorm:"-"`
218
 	DryWeight                float64 `gorm:"-"`
193
 	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
219
 	ZbPatientId              string  `gorm:"column:zb_patient_id" json:"zb_patient_id" form:"zb_patient_id"`
194
 	TreatmentPlan            string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
220
 	TreatmentPlan            string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
221
+	Doctor                   int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
195
 }
222
 }
196
 
223
 
197
 func (Patients) TableName() string {
224
 func (Patients) TableName() string {
320
 	Epo                        string        `gorm:"column:epo" json:"epo" form:"epo"`
347
 	Epo                        string        `gorm:"column:epo" json:"epo" form:"epo"`
321
 	EpoCount                   float64       `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
348
 	EpoCount                   float64       `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
322
 	MaxUltrafiltrationRate     float64       `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
349
 	MaxUltrafiltrationRate     float64       `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
350
+	AdminUserId                int64         `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
351
+	IsWater                    int64         `gorm:"column:is_water" json:"is_water" form:"is_water"`
352
+	DrhyWater                  string        `gorm:"column:drhy_water" json:"drhy_water" form:"drhy_water"`
353
+	DryWaterHour               string        `gorm:"column:dry_water_hour" json:"dry_water_hour" form:"dry_water_hour"`
354
+	WaterMachine               string        `gorm:"column:water_machine" json:"water_machine" form:"water_machine"`
323
 }
355
 }
324
 
356
 
325
 func (DialysisPrescription) TableName() string {
357
 func (DialysisPrescription) TableName() string {
749
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
781
 	DeathTime                    int64   `gorm:"column:death_time" json:"death_time" form:"death_time"`
750
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
782
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
751
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
783
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
784
+	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
752
 }
785
 }
753
 
786
 
754
 func (XtPatientsNew) TableName() string {
787
 func (XtPatientsNew) TableName() string {

+ 128 - 16
models/schedule_models.go Ver arquivo

292
 }
292
 }
293
 
293
 
294
 type VmBloodSchedule struct {
294
 type VmBloodSchedule struct {
295
-	ID               int64                      `gorm:"column:id" json:"id" form:"id"`
296
-	UserOrgId        int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
297
-	PartitionId      int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
298
-	BedId            int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
299
-	PatientId        int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
300
-	ScheduleDate     int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
301
-	ScheduleType     int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
302
-	ScheduleWeek     int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
303
-	ModeId           int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
304
-	Status           int64                      `gorm:"column:status" json:"status" form:"status"`
305
-	CreatedTime      int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
306
-	UpdatedTime      int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
307
-	IsExport         int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
308
-	DeviceNumber     *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
309
-	SchedualPatient  *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
310
-	DialysisSolution DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
295
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
296
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
297
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
298
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
299
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
300
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
301
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
302
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
303
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
304
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
305
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
306
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
307
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
308
+	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
309
+	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
310
+	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
311
+	DialysisPrescription       DialysisPrescription       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"dialysis_prescription"`
312
+	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"assessment_befor_dislysis"`
313
+	XtDoctorAdvice             XtDoctorAdvice             `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_doctor_advice"`
314
+	HisDoctorAdvice            HisDoctorAdvice            `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_doctor_advice"`
315
+	ReceiveTreatmentAsses      ReceiveTreatmentAsses      `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_receive_treatment_asses"`
316
+	XtAssessmentAfterDislysis  XtAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"xt_assesment_after_dislysis"`
317
+	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
311
 }
318
 }
312
 
319
 
313
 func (VmBloodSchedule) TableName() string {
320
 func (VmBloodSchedule) TableName() string {
338
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
345
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
339
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
346
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
340
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
347
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
348
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
341
 }
349
 }
342
 
350
 
343
 func (NewMSchedualPatientVMList) TableName() string {
351
 func (NewMSchedualPatientVMList) TableName() string {
344
 	return "xt_patients"
352
 	return "xt_patients"
345
 }
353
 }
354
+
355
+type VmBloodScheduleTwo struct {
356
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
357
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
358
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
359
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
360
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
361
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
362
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
363
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
364
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
365
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
366
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
367
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
368
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
369
+	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
370
+	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
371
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
372
+}
373
+
374
+func (VmBloodScheduleTwo) TableName() string {
375
+	return "xt_schedule"
376
+}
377
+
378
+type HisPrescriptionTemplateSix struct {
379
+	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
380
+	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
381
+	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
382
+	Type                           int64                             `gorm:"column:type" json:"type" form:"type"`
383
+	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
384
+	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
385
+	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
386
+	Name                           string                            `gorm:"column:name" json:"name" form:"name"`
387
+	Mode                           int64                             `gorm:"column:mode" json:"mode" form:"mode"`
388
+	HisPrescriptionInfoTemplateSix []*HisPrescriptionInfoTemplateSix `gorm:"ForeignKey:PTemplateId;AssociationForeignKey:ID" json:"his_prescription_info"`
389
+}
390
+
391
+func (HisPrescriptionTemplateSix) TableName() string {
392
+	return "his_prescription_template"
393
+}
394
+
395
+type HisPrescriptionInfoTemplateSix struct {
396
+	ID                                  int64                                  `gorm:"column:id" json:"id" form:"id"`
397
+	UserOrgId                           int64                                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
398
+	RecordDate                          int64                                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
399
+	PatientId                           int64                                  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
400
+	Status                              int64                                  `gorm:"column:status" json:"status" form:"status"`
401
+	Ctime                               int64                                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
402
+	Mtime                               int64                                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
403
+	Type                                int64                                  `gorm:"column:type" json:"type" form:"type"`
404
+	Creator                             int64                                  `gorm:"column:creator" json:"creator" form:"creator"`
405
+	Modifier                            int64                                  `gorm:"column:modifier" json:"modifier" form:"modifier"`
406
+	PType                               int64                                  `gorm:"column:p_type" json:"p_type" form:"p_type"`
407
+	PTemplateId                         int64                                  `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
408
+	HisPrescriptionProjectTemplateSeven []*HisPrescriptionProjectTemplateSeven `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
409
+	MedType                             string                                 `gorm:"column:med_type" json:"med_type" form:"med_type"`
410
+}
411
+
412
+func (HisPrescriptionInfoTemplateSix) TableName() string {
413
+	return "his_prescription_info_template"
414
+}
415
+
416
+type HisPrescriptionProjectTemplateSeven struct {
417
+	ID                 int64         `gorm:"column:id" json:"id" form:"id"`
418
+	ProjectId          int64         `gorm:"column:project_id" json:"project_id" form:"project_id"`
419
+	Price              float64       `gorm:"column:price" json:"price" form:"price"`
420
+	UserOrgId          int64         `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
421
+	Status             int64         `gorm:"column:status" json:"status" form:"status"`
422
+	Ctime              int64         `gorm:"column:ctime" json:"ctime" form:"ctime"`
423
+	Mtime              int64         `gorm:"column:mtime" json:"mtime" form:"mtime"`
424
+	PatientId          int64         `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
425
+	HisPatientId       int64         `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
426
+	RecordDate         int64         `gorm:"column:record_date" json:"record_date" form:"record_date"`
427
+	Count              string        `gorm:"column:count" json:"count" form:"count"`
428
+	FeedetlSn          string        `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
429
+	MedListCodg        string        `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
430
+	SingleDose         string        `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
431
+	DeliveryWay        string        `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
432
+	ExecutionFrequency string        `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
433
+	Day                string        `gorm:"column:day" json:"day" form:"day"`
434
+	Remark             string        `gorm:"column:remark" json:"remark" form:"remark"`
435
+	Unit               string        `gorm:"column:unit" json:"unit" form:"unit"`
436
+	Type               int64         `gorm:"column:type" json:"type" form:"type"`
437
+	PrescriptionId     int64         `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
438
+	GoodInfo           GoodInfoNight `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"good_info"`
439
+	FrequencyType      int64         `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
440
+	DayCount           int64         `gorm:"column:day_count" json:"day_count" form:"day_count"`
441
+	WeekDay            string        `gorm:"column:week_day" json:"week_day" form:"week_day"`
442
+}
443
+
444
+func (HisPrescriptionProjectTemplateSeven) TableName() string {
445
+	return "his_prescription_project_template"
446
+}
447
+
448
+type GoodInfoNight struct {
449
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
450
+	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`
451
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
452
+	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
453
+}
454
+
455
+func (GoodInfoNight) TableName() string {
456
+	return "xt_good_information"
457
+}

+ 39 - 0
service/device_service.go Ver arquivo

777
 	return devicenumber, err
777
 	return devicenumber, err
778
 }
778
 }
779
 
779
 
780
+func GetAllBedNumberTen(orgId int64, zone_id int64) (devicenumber []*models.ScheduleDeviceNumber, err error) {
781
+
782
+	err = XTReadDB().Where("org_id = ? and status = 1 and zone_id = ?", orgId, zone_id).Find(&devicenumber).Error
783
+	return devicenumber, err
784
+}
785
+
780
 func GetAllBedNumberSeven(orgId int64) (devicenumber []*models.SgjDeviceNumber, err error) {
786
 func GetAllBedNumberSeven(orgId int64) (devicenumber []*models.SgjDeviceNumber, err error) {
781
 
787
 
782
 	err = XTReadDB().Where("org_id = ? and status= 1", orgId).Preload("Zone", "status = 1").Find(&devicenumber).Error
788
 	err = XTReadDB().Where("org_id = ? and status= 1", orgId).Preload("Zone", "status = 1").Find(&devicenumber).Error
783
 	return devicenumber, err
789
 	return devicenumber, err
784
 }
790
 }
791
+
792
+func ChangeScheduleById(id int64, mode_id int64) error {
793
+
794
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"mode_id": mode_id}).Error
795
+	fmt.Println("err233322323232232323", err)
796
+	return err
797
+}
798
+
799
+func ChangeDialysisSolution(patient_id int64, schedule_date int64, org_id int64, mode_id int64) error {
800
+
801
+	err := XTWriteDB().Model(&models.DialysisPrescription{}).Where("patient_id = ? and record_date =? and user_org_id = ? and status = 1", patient_id, schedule_date, org_id).Update(map[string]interface{}{"mode_id": mode_id}).Error
802
+	return err
803
+
804
+}
805
+
806
+func GetScheduleByClassType(schedule_type int64, schedule_date int64, bed_id int64, user_org_id int64) (models.XtSchedule, error) {
807
+	schedule := models.XtSchedule{}
808
+	err := XTReadDB().Where("schedule_type = ? and schedule_date = ? and bed_id = ? and user_org_id = ? and status = 1", schedule_type, schedule_date, bed_id, user_org_id).Find(&schedule).Error
809
+	return schedule, err
810
+}
811
+
812
+func GetPartionId(bed_id int64, org_id int64) (models.XtDeviceNumber, error) {
813
+
814
+	number := models.XtDeviceNumber{}
815
+	err = XTReadDB().Where("id = ? and status = 1 and org_id = ?", bed_id, org_id).Find(&number).Error
816
+	return number, err
817
+}
818
+
819
+func UpdateScheduleById(id int64, schedule models.Schedule) error {
820
+
821
+	err := XTWriteDB().Model(&models.Schedule{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"patient_id": schedule.PatientId, "mode_id": schedule.ModeId}).Error
822
+	return err
823
+}

+ 68 - 4
service/dialysis_service.go Ver arquivo

553
 	return nil
553
 	return nil
554
 }
554
 }
555
 
555
 
556
-func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64, puncture_point_haematoma int64, internal_fistula string, catheter string, cruor string) error {
557
-	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id, "puncture_point_haematoma": puncture_point_haematoma, "blood_access_internal_fistula": internal_fistula, "catheter": catheter, "cruor": cruor}).Error
556
+func ModifyDialysisRecord(id int64, finishNurse int64, end_time int64, admin_user_id int64, puncture_point_haematoma int64, internal_fistula string, catheter string, cruor string, mission string) error {
557
+	err := writeDb.Model(&models.DialysisOrder{}).Where("id = ? AND status = 1 ", id).Updates(map[string]interface{}{"updated_time": time.Now().Unix(), "stage": 2, "finish_nurse": finishNurse, "end_time": end_time, "finish_creator": admin_user_id, "finish_modifier": admin_user_id, "puncture_point_haematoma": puncture_point_haematoma, "blood_access_internal_fistula": internal_fistula, "catheter": catheter, "cruor": cruor, "mission": mission}).Error
558
 	return err
558
 	return err
559
 
559
 
560
 }
560
 }
632
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
632
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
633
 	table := readDb.Table("xt_device_number as n")
633
 	table := readDb.Table("xt_device_number as n")
634
 	fmt.Print("table", table)
634
 	fmt.Print("table", table)
635
-	err := db.Select("o.id,o.dialysis_date,o.user_org_id,o.patient_id,o.prescription_id,o.stage,remark,o.bed_id,o.start_nurse,o.finish_nurse,o.status,o.created_time,o.updated_time,o.start_time,o.end_time,o.puncture_nurse,o.creator,o.modifier,o.finish_creator,o.finish_modifier,o.schedual_type,n.number,r.user_name").Joins("left join xt_device_number as n on n.id = o.bed_id").Joins("left join sgj_users.sgj_user_admin_role  as r on r.admin_user_id = o.start_nurse").Where("o.user_org_id = ? and o.patient_id = ? and o.dialysis_date =?", orgid, patientid, dialysisDate).Scan(&orders).Error
635
+	err := db.Select("o.id,o.dialysis_date,o.user_org_id,o.patient_id,o.prescription_id,o.stage,remark,o.bed_id,o.start_nurse,o.finish_nurse,o.status,o.created_time,o.updated_time,o.start_time,o.end_time,o.puncture_nurse,o.creator,o.modifier,o.finish_creator,o.finish_modifier,o.schedual_type,o.quality_nurse_id,n.number,r.user_name").Joins("left join xt_device_number as n on n.id = o.bed_id").Joins("left join sgj_users.sgj_user_admin_role  as r on r.admin_user_id = o.start_nurse").Where("o.user_org_id = ? and o.patient_id = ? and o.dialysis_date =?", orgid, patientid, dialysisDate).Scan(&orders).Error
636
 	return orders, err
636
 	return orders, err
637
 }
637
 }
638
 func FindPunctureNurse(adminid int64, appid int64, orgid int64) (models.App_Roles, error) {
638
 func FindPunctureNurse(adminid int64, appid int64, orgid int64) (models.App_Roles, error) {
652
 	return role, err
652
 	return role, err
653
 }
653
 }
654
 
654
 
655
+func FindeQualityNurse(adminid int64, appid int64, orgid int64) (models.App_Roles, error) {
656
+	role := models.App_Roles{}
657
+	db := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
658
+	err := db.Select("r.id,r.admin_user_id,r.org_id,r.role_id,r.user_name,r.avatar,r.user_type,r.user_title,r.intro,r.status,r.ctime,e.url").Joins("left join sgj_user_admin_electronic_signature as e on e.creator = r.admin_user_id").Where("r.admin_user_id = ? and r.app_id = ? and r.org_id = ?", adminid, appid, orgid).Find(&role).Error
659
+	return role, err
660
+}
661
+
655
 func FindDialysisWay(orgid int64, patientid int64, recorddate int64) (models.DialysisPrescription, error) {
662
 func FindDialysisWay(orgid int64, patientid int64, recorddate int64) (models.DialysisPrescription, error) {
656
 	prescription := models.DialysisPrescription{}
663
 	prescription := models.DialysisPrescription{}
657
 	err := readDb.Where("user_org_id = ? and patient_id = ? and record_date = ? and status =1", orgid, patientid, recorddate).Find(&prescription).Error
664
 	err := readDb.Where("user_org_id = ? and patient_id = ? and record_date = ? and status =1", orgid, patientid, recorddate).Find(&prescription).Error
1508
 }
1515
 }
1509
 
1516
 
1510
 func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (advice []*models.HisPrescriptionProject, err error) {
1517
 func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (advice []*models.HisPrescriptionProject, err error) {
1511
-	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1518
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1 and user_org_id = ?", orgID).Preload("GoodInfo", "status = 1 and org_id = ?", orgID).Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1512
 	return
1519
 	return
1513
 }
1520
 }
1514
 
1521
 
1798
 	err := XTReadDB().Where("patient_id=? and dialysis_date = ? and user_org_id = ? and status = 1", patient_id, dialysis_date, orgid).Find(&order).Error
1805
 	err := XTReadDB().Where("patient_id=? and dialysis_date = ? and user_org_id = ? and status = 1", patient_id, dialysis_date, orgid).Find(&order).Error
1799
 	return order, err
1806
 	return order, err
1800
 }
1807
 }
1808
+
1809
+func GetScheduleByPatient(patient_id int64, schedule_date int64, orgid int64) (models.XtScheduleSix, error) {
1810
+
1811
+	schedule := models.XtScheduleSix{}
1812
+	err := XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status = 1", patient_id, schedule_date, orgid).Find(&schedule).Error
1813
+	return schedule, err
1814
+}
1815
+
1816
+func GetSchedulePrintList(page int64, limit int64, schedulType int64, partitionType int64, keywords string, schedule_date int64, orgID int64) (list []*models.DialysisScheduleSix, total int64, err error) {
1817
+
1818
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
1819
+	table := XTReadDB().Table("xt_patients as p").Where("p.status = 1")
1820
+	fmt.Println("table", table)
1821
+	if schedulType > 0 {
1822
+		db = db.Where("x.schedule_type = ?", schedulType)
1823
+	}
1824
+	if partitionType > 0 {
1825
+		db = db.Where("x.partition_id = ?", partitionType)
1826
+	}
1827
+	if orgID > 0 {
1828
+		db = db.Where("x.user_org_id = ?", orgID)
1829
+	}
1830
+	if schedule_date > 0 {
1831
+		db = db.Where("x.schedule_date = ?", schedule_date)
1832
+	}
1833
+	db = db.Joins("left join xt_patients as p on p.id = x.patient_id")
1834
+	likeKey := "%" + keywords + "%"
1835
+	if len(keywords) > 0 {
1836
+		db = db.Where("p.name like ?", likeKey)
1837
+	}
1838
+	err = db.Count(&total).Select("x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.status,p.name").Offset(limit * (page - 1)).Limit(limit).Order("x.schedule_date desc").Find(&list).Error
1839
+
1840
+	return list, total, err
1841
+}
1842
+
1843
+func GetSchedulePrintListOne(page int64, limit int64, schedulType int64, partitionType int64, keywords string, schedule_date int64, orgID int64) (list []*models.DialysisScheduleSeven, err error) {
1844
+
1845
+	db := XTReadDB().Model(&list).Where("status = 1")
1846
+	if orgID > 0 {
1847
+		db = db.Where("user_org_id = ?", orgID)
1848
+	}
1849
+	if schedulType > 0 {
1850
+		db = db.Where("schedule_type = ?", schedulType)
1851
+	}
1852
+	if partitionType > 0 {
1853
+		db = db.Where("partition_id = ?", partitionType)
1854
+	}
1855
+	err = db.Group("schedule_type,partition_id").Find(&list).Error
1856
+	return list, err
1857
+}
1858
+
1859
+func GetDialysisRecordOrder(org_id int64, patient_id int64, dialysis_date int64) (models.MDialysisOrderForListSix, error) {
1860
+
1861
+	order := models.MDialysisOrderForListSix{}
1862
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date = ? and status =1 ", org_id, patient_id, dialysis_date).Find(&order).Error
1863
+	return order, err
1864
+}

+ 241 - 14
service/dialysis_solution_service.go Ver arquivo

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
+	"fmt"
6
+	"github.com/jinzhu/gorm"
5
 )
7
 )
6
 
8
 
7
 func GetPatientSolutionGroupList(patient_id int64, orgid int64) (solution []*models.DialysisSolution, err error) {
9
 func GetPatientSolutionGroupList(patient_id int64, orgid int64) (solution []*models.DialysisSolution, err error) {
41
 
43
 
42
 func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
44
 func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
43
 
45
 
44
-	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
46
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
45
 	offset := (page - 1) * limit
47
 	offset := (page - 1) * limit
46
 	if scheduleDate > 0 {
48
 	if scheduleDate > 0 {
47
-		db = db.Where("schedule_date = ?", scheduleDate)
49
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
48
 	}
50
 	}
49
 	if schedule_type > 0 {
51
 	if schedule_type > 0 {
50
-		db = db.Where("schedule_type = ?", schedule_type)
52
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
51
 	}
53
 	}
52
 	if partition_id > 0 {
54
 	if partition_id > 0 {
53
-		db = db.Where("partition_id = ?", partition_id)
55
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
54
 	}
56
 	}
55
 	if orgID > 0 {
57
 	if orgID > 0 {
56
-		db = db.Where("user_org_id  = ?", orgID)
58
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
57
 	}
59
 	}
58
 
60
 
59
 	if len(keywords) > 0 {
61
 	if len(keywords) > 0 {
60
 		keywords = "%" + keywords + "%"
62
 		keywords = "%" + keywords + "%"
61
-		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
62
-		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
63
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
63
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
64
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
64
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
65
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
65
-			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).Find(&schedule).Error
66
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID)
67
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
68
+		err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
66
 	} else {
69
 	} else {
67
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
70
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
68
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
71
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
73
 	return schedule, total, err
76
 	return schedule, total, err
74
 }
77
 }
75
 
78
 
76
-func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
77
-	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
79
+func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, idArray []string) (schedule []*models.VmBloodSchedule, total int64, err error) {
80
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
78
 	offset := (page - 1) * limit
81
 	offset := (page - 1) * limit
79
 	if scheduleDate > 0 {
82
 	if scheduleDate > 0 {
80
-		db = db.Where("schedule_date = ?", scheduleDate)
83
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
81
 	}
84
 	}
82
 	if schedule_type > 0 {
85
 	if schedule_type > 0 {
83
-		db = db.Where("schedule_type = ?", schedule_type)
86
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
84
 	}
87
 	}
85
 	if partition_id > 0 {
88
 	if partition_id > 0 {
86
-		db = db.Where("partition_id = ?", partition_id)
89
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
87
 	}
90
 	}
88
 	if orgID > 0 {
91
 	if orgID > 0 {
89
-		db = db.Where("user_org_id  = ?", orgID)
92
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
93
+	}
94
+	fmt.Println("idArray23233223323232233232", len(idArray))
95
+	if len(idArray) > 1 {
96
+		db = db.Where("xt_schedule.id in(?)", idArray)
90
 	}
97
 	}
91
 
98
 
92
 	if len(keywords) > 0 {
99
 	if len(keywords) > 0 {
128
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
135
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
129
 	return setting, err
136
 	return setting, err
130
 }
137
 }
138
+
139
+func GetDialysisParameterList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
140
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
141
+	offset := (page - 1) * limit
142
+	if scheduleDate > 0 {
143
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
144
+	}
145
+	if schedule_type > 0 {
146
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
147
+	}
148
+	if partition_id > 0 {
149
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
150
+	}
151
+	if orgID > 0 {
152
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
153
+	}
154
+
155
+	if len(keywords) > 0 {
156
+		keywords = "%" + keywords + "%"
157
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
158
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
159
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
160
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ?", orgID).
161
+			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
162
+			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
163
+			Preload("ReceiveTreatmentAsses", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
164
+			Preload("XtAssessmentAfterDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
165
+			Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
166
+				return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgID, scheduleDate)
167
+			}).
168
+			Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ? and advice_type = 1", orgID, scheduleDate).
169
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
170
+	} else {
171
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
172
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
173
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ?", orgID).
174
+			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
175
+			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
176
+			Preload("ReceiveTreatmentAsses", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
177
+			Preload("XtAssessmentAfterDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
178
+			Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ? and advice_type = 1", orgID, scheduleDate).
179
+			Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
180
+				return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgID, scheduleDate)
181
+			}).Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
182
+	}
183
+
184
+	return schedule, total, err
185
+}
186
+
187
+func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
188
+
189
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
190
+
191
+	if scheduleDate > 0 {
192
+		db = db.Where("schedule_date = ?", scheduleDate)
193
+	}
194
+	if schedule_type > 0 {
195
+		db = db.Where("schedule_type = ?", schedule_type)
196
+	}
197
+	if partition_id > 0 {
198
+		db = db.Where("partition_id = ?", partition_id)
199
+	}
200
+	if orgID > 0 {
201
+		db = db.Where("user_org_id  = ?", orgID)
202
+	}
203
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
204
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
205
+		Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
206
+		Preload("DialysisSolution", "status = 1 AND user_org_id = ? AND solution_status = 1", orgID).
207
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
208
+
209
+	return schedule, err
210
+
211
+}
212
+
213
+func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
214
+
215
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
216
+
217
+	if scheduleDate > 0 {
218
+		db = db.Where("schedule_date = ?", scheduleDate)
219
+	}
220
+	if schedule_type > 0 {
221
+		db = db.Where("schedule_type = ?", schedule_type)
222
+	}
223
+	if partition_id > 0 {
224
+		db = db.Where("partition_id = ?", partition_id)
225
+	}
226
+	if orgID > 0 {
227
+		db = db.Where("user_org_id  = ?", orgID)
228
+	}
229
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
230
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
231
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
232
+		Preload("HisDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
233
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
234
+
235
+	return schedule, err
236
+
237
+}
238
+
239
+func GetAllDrugMap(org_id int64) (list []*BaseDrugLib, err error) {
240
+
241
+	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
242
+	return list, err
243
+}
244
+
245
+func GetDialysisParameterGoodList(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
246
+
247
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
248
+
249
+	if scheduleDate > 0 {
250
+		db = db.Where("schedule_date = ?", scheduleDate)
251
+	}
252
+	if schedule_type > 0 {
253
+		db = db.Where("schedule_type = ?", schedule_type)
254
+	}
255
+	if partition_id > 0 {
256
+		db = db.Where("partition_id = ?", partition_id)
257
+	}
258
+	if orgID > 0 {
259
+		db = db.Where("user_org_id  = ?", orgID)
260
+	}
261
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
262
+		Preload("DialysisPrescription", "status = 1 and user_org_id = ?", orgID).
263
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
264
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
265
+		Preload("HisDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
266
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
267
+
268
+	return schedule, err
269
+}
270
+
271
+func SaveHisDialysis(orgid int64, ids []string) error {
272
+
273
+	goodsType := models.BloodGoodsType{}
274
+	err := XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 1}).Error
275
+
276
+	err = XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id not in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 0}).Error
277
+	return err
278
+}
279
+
280
+func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
281
+
282
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
283
+	offset := (page - 1) * limit
284
+	if scheduleDate > 0 {
285
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
286
+	}
287
+	if schedule_type > 0 {
288
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
289
+	}
290
+	if partition_id > 0 {
291
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
292
+	}
293
+	if orgID > 0 {
294
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
295
+	}
296
+
297
+	if len(keywords) > 0 {
298
+		keywords = "%" + keywords + "%"
299
+		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
300
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
301
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
302
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
303
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
304
+					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
305
+						return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
306
+					})
307
+				})
308
+			})
309
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
310
+		err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
311
+	} else {
312
+		err = db.Count(&total).Offset(offset).Limit(limit).
313
+			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
314
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
315
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
316
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
317
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
318
+					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
319
+						return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
320
+					})
321
+				})
322
+			}).Find(&schedule).Error
323
+	}
324
+
325
+	return schedule, total, err
326
+}
327
+
328
+func GetHisDialysisGoodCount(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
329
+
330
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
331
+	if scheduleDate > 0 {
332
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
333
+	}
334
+	if schedule_type > 0 {
335
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
336
+	}
337
+	if partition_id > 0 {
338
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
339
+	}
340
+	if orgID > 0 {
341
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
342
+	}
343
+
344
+	err = db.
345
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
346
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
347
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
348
+		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
349
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
350
+				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
351
+					return db.Where("user_org_id = ? and status = 1 and type = 3", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
352
+				})
353
+			})
354
+		}).Find(&schedule).Error
355
+
356
+	return schedule, err
357
+}

+ 18 - 2
service/gobal_config_service.go Ver arquivo

364
 	dbTwo := XTReadDB().Table("xt_drug_warehouse_out as t").Where("t.status = 1")
364
 	dbTwo := XTReadDB().Table("xt_drug_warehouse_out as t").Where("t.status = 1")
365
 	fmt.Print(dbOne, dbTwo)
365
 	fmt.Print(dbOne, dbTwo)
366
 	if startime > 0 {
366
 	if startime > 0 {
367
-		db = db.Where("x.ctime >=?", startime)
367
+		db = db.Where("x.sys_record_time >=?", startime)
368
 	}
368
 	}
369
 	if endtime > 0 {
369
 	if endtime > 0 {
370
-		db = db.Where("x.ctime <=?", endtime)
370
+		db = db.Where("x.sys_record_time <=?", endtime)
371
 	}
371
 	}
372
 
372
 
373
 	if orgid > 0 {
373
 	if orgid > 0 {
974
 	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
974
 	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
975
 	return flow, err
975
 	return flow, err
976
 }
976
 }
977
+
978
+func GetDrugWarehouseOutInfoFlow(drug_id int64, start_time int64, end_time int64, user_org_id int64) (info []*models.XtDrugWarehouseOutInfo, err error) {
979
+
980
+	db := XTReadDB().Model(&info).Where("status = 1")
981
+	if start_time > 0 {
982
+		db = db.Where("sys_record_time >=?", start_time)
983
+	}
984
+	if end_time > 0 {
985
+		db = db.Where("sys_record_time <=?", end_time)
986
+	}
987
+	if user_org_id > 0 {
988
+		db = db.Where("user_org_id = ?", user_org_id)
989
+	}
990
+	err = db.Find(&info).Error
991
+	return info, err
992
+}

+ 1 - 1
service/his_project_service.go Ver arquivo

240
 
240
 
241
 func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
241
 func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
242
 
242
 
243
-	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1", orgid).Find(&project).Error
243
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1 and medical_status!=1", orgid).Find(&project).Error
244
 	return project, err
244
 	return project, err
245
 }
245
 }
246
 
246
 

+ 8 - 0
service/his_service.go Ver arquivo

2582
 	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
2582
 	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
2583
 	return
2583
 	return
2584
 }
2584
 }
2585
+
2586
+func GetHisPrescriptonProjectById(id int64) (models.HisPrescriptionProject, error) {
2587
+
2588
+	project := models.HisPrescriptionProject{}
2589
+
2590
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&project).Error
2591
+	return project, err
2592
+}

+ 37 - 5
service/manage_center_service.go Ver arquivo

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/models"
4
 	"XT_New/models"
5
-	"fmt"
6
 	"github.com/jinzhu/gorm"
5
 	"github.com/jinzhu/gorm"
7
 	"strconv"
6
 	"strconv"
8
 	"strings"
7
 	"strings"
477
 
476
 
478
 			if (over_count + out_count) <= sum_count {
477
 			if (over_count + out_count) <= sum_count {
479
 				if its.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
478
 				if its.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
480
-					fmt.Println("进来1", its.Count)
479
+
481
 					//退库
480
 					//退库
482
 					warehouseInfo := models.DrugWarehouseInfo{
481
 					warehouseInfo := models.DrugWarehouseInfo{
483
 						StockMinNumber: its.Count,
482
 						StockMinNumber: its.Count,
491
 
490
 
492
 				}
491
 				}
493
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
492
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
494
-					fmt.Println("进来2", its.Count)
493
+
495
 					warehouseInfo := models.DrugWarehouseInfo{
494
 					warehouseInfo := models.DrugWarehouseInfo{
496
 						StockMaxNumber: its.Count,
495
 						StockMaxNumber: its.Count,
497
 					}
496
 					}
504
 				}
503
 				}
505
 
504
 
506
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
505
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
507
-					fmt.Println("进来3", its.Count)
506
+
508
 					warehouseInfo := models.DrugWarehouseInfo{
507
 					warehouseInfo := models.DrugWarehouseInfo{
509
 						StockMaxNumber: its.Count,
508
 						StockMaxNumber: its.Count,
510
 					}
509
 					}
576
 				IsCheck:          1,
575
 				IsCheck:          1,
577
 			}
576
 			}
578
 
577
 
578
+			//查询剩余库存
579
+			stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
580
+			var sum_count int64
581
+			for _, its := range stockInfo {
582
+				if its.MaxUnit == drug.MaxUnit {
583
+					its.StockMaxNumber = its.StockMaxNumber * drug.MinNumber
584
+				}
585
+				sum_count += its.StockMaxNumber + its.StockMinNumber
586
+			}
579
 			flow := models.DrugFlow{
587
 			flow := models.DrugFlow{
580
 				WarehousingId:           info.WarehouseInfoId,
588
 				WarehousingId:           info.WarehouseInfoId,
581
 				DrugId:                  info.DrugId,
589
 				DrugId:                  info.DrugId,
610
 				MinUnit:                 "",
618
 				MinUnit:                 "",
611
 				AdviceId:                info.AdviceId,
619
 				AdviceId:                info.AdviceId,
612
 				StorehouseId:            storeHouseConfig.DrugStorehouseOut,
620
 				StorehouseId:            storeHouseConfig.DrugStorehouseOut,
621
+				OverCount:               sum_count,
613
 			}
622
 			}
614
 			CreatedCancelStock(cancelStockInfo)
623
 			CreatedCancelStock(cancelStockInfo)
615
 			CreateDrugFlowOne(flow)
624
 			CreateDrugFlowOne(flow)
675
 				StorehouseId:     houseConfig.DrugStorehouseOut,
684
 				StorehouseId:     houseConfig.DrugStorehouseOut,
676
 				IsCheck:          1,
685
 				IsCheck:          1,
677
 			}
686
 			}
687
+			//查询剩余库存
688
+			stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
689
+			var sum_count int64
690
+			for _, its := range stockInfo {
691
+				if its.MaxUnit == drug.MaxUnit {
692
+					its.StockMaxNumber = its.StockMaxNumber * drug.MinNumber
693
+				}
694
+				sum_count += its.StockMaxNumber + its.StockMinNumber
695
+			}
678
 
696
 
679
 			flow := models.DrugFlow{
697
 			flow := models.DrugFlow{
680
 				WarehousingId:           info.WarehouseInfoId,
698
 				WarehousingId:           info.WarehouseInfoId,
710
 				MinUnit:                 "",
728
 				MinUnit:                 "",
711
 				AdviceId:                info.AdviceId,
729
 				AdviceId:                info.AdviceId,
712
 				StorehouseId:            houseConfig.DrugStorehouseOut,
730
 				StorehouseId:            houseConfig.DrugStorehouseOut,
731
+				OverCount:               sum_count,
713
 			}
732
 			}
714
 			CreatedCancelStock(cancelStockInfo)
733
 			CreatedCancelStock(cancelStockInfo)
715
 			CreateDrugFlowOne(flow)
734
 			CreateDrugFlowOne(flow)
775
 				StorehouseId:     houseConfig.DrugStorehouseOut,
794
 				StorehouseId:     houseConfig.DrugStorehouseOut,
776
 				IsCheck:          1,
795
 				IsCheck:          1,
777
 			}
796
 			}
797
+			//查询剩余库存
798
+			stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
799
+			var sum_count int64
800
+			for _, its := range stockInfo {
801
+				if its.MaxUnit == drug.MaxUnit {
802
+					its.StockMaxNumber = its.StockMaxNumber * drug.MinNumber
803
+				}
804
+				sum_count += its.StockMaxNumber + its.StockMinNumber
805
+			}
778
 
806
 
779
 			flow := models.DrugFlow{
807
 			flow := models.DrugFlow{
780
 				WarehousingId:           info.WarehouseInfoId,
808
 				WarehousingId:           info.WarehouseInfoId,
810
 				MinUnit:                 "",
838
 				MinUnit:                 "",
811
 				AdviceId:                info.AdviceId,
839
 				AdviceId:                info.AdviceId,
812
 				StorehouseId:            houseConfig.DrugStorehouseOut,
840
 				StorehouseId:            houseConfig.DrugStorehouseOut,
841
+				OverCount:               sum_count,
813
 			}
842
 			}
814
 			CreatedCancelStock(cancelStockInfo)
843
 			CreatedCancelStock(cancelStockInfo)
815
 			CreateDrugFlowOne(flow)
844
 			CreateDrugFlowOne(flow)
825
 		medical, _ := GetBaseDrugMedical(advice.DrugId)
854
 		medical, _ := GetBaseDrugMedical(advice.DrugId)
826
 		var sum_count_one int64
855
 		var sum_count_one int64
827
 		for _, its := range stockInfo {
856
 		for _, its := range stockInfo {
828
-			sum_count_one += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
857
+			if its.MaxUnit == medical.MaxUnit {
858
+				its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
859
+			}
860
+			sum_count_one += its.StockMaxNumber + its.StockMinNumber
829
 		}
861
 		}
830
 		UpdateBaseDrugSumTwo(advice.DrugId, sum_count_one, advice.UserOrgId)
862
 		UpdateBaseDrugSumTwo(advice.DrugId, sum_count_one, advice.UserOrgId)
831
 
863
 

+ 21 - 8
service/mobile_dialysis_service.go Ver arquivo

165
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
165
 	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
166
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
166
 	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
167
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
167
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
168
+	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
168
 }
169
 }
169
 
170
 
170
 func (MSchedualPatientVMList) TableName() string {
171
 func (MSchedualPatientVMList) TableName() string {
283
 	// PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id"`
284
 	// PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id"`
284
 	Stage int64 `gorm:"column:stage" json:"stage"`
285
 	Stage int64 `gorm:"column:stage" json:"stage"`
285
 	// Remark         string `gorm:"column:remark" json:"remark"`
286
 	// Remark         string `gorm:"column:remark" json:"remark"`
286
-	BedID         int64            `gorm:"column:bed_id" json:"bed_id"`
287
-	StartNurse    int64            `gorm:"column:start_nurse" json:"start_nurse"`
288
-	Status        int64            `gorm:"column:status" json:"status"`
289
-	DeviceNumber  *MDeviceNumberVM `gorm:"ForeignKey:BedID" json:"device_number"`
290
-	Creator       int64            `gorm:"column:creator" json:"creator"`
291
-	WashpipeNurse int64            `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
287
+	BedID              int64            `gorm:"column:bed_id" json:"bed_id"`
288
+	StartNurse         int64            `gorm:"column:start_nurse" json:"start_nurse"`
289
+	Status             int64            `gorm:"column:status" json:"status"`
290
+	DeviceNumber       *MDeviceNumberVM `gorm:"ForeignKey:BedID" json:"device_number"`
291
+	Creator            int64            `gorm:"column:creator" json:"creator"`
292
+	WashpipeNurse      int64            `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
293
+	NucleinDate        int64            `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
294
+	DialysisIrrigation string           `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
295
+	DialysisDialyszers string           `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
292
 }
296
 }
293
 
297
 
294
 func (MDialysisOrderVMList) TableName() string {
298
 func (MDialysisOrderVMList) TableName() string {
2021
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2025
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2022
 	tx := writeDb.Begin()
2026
 	tx := writeDb.Begin()
2023
 	updateTime := time.Now().Unix()
2027
 	updateTime := time.Now().Unix()
2024
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse}).Error
2028
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate}).Error
2025
 	if err != nil {
2029
 	if err != nil {
2026
 		tx.Rollback()
2030
 		tx.Rollback()
2027
 		return err
2031
 		return err
2033
 func ModifyFinishDialysisOrder(order *models.DialysisOrder) error {
2037
 func ModifyFinishDialysisOrder(order *models.DialysisOrder) error {
2034
 	tx := writeDb.Begin()
2038
 	tx := writeDb.Begin()
2035
 	updateTime := time.Now().Unix()
2039
 	updateTime := time.Now().Unix()
2036
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier, "puncture_point_haematoma": order.PuncturePointHaematoma, "blood_access_internal_fistula": order.BloodAccessInternalFistula, "catheter": order.Catheter, "cruor": order.Cruor}).Error
2040
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"finish_nurse": order.FinishNurse, "updated_time": updateTime, "end_time": order.EndTime, "finish_modifier": order.FinishModifier, "puncture_point_haematoma": order.PuncturePointHaematoma, "blood_access_internal_fistula": order.BloodAccessInternalFistula, "catheter": order.Catheter, "cruor": order.Cruor, "mission": order.Mission}).Error
2037
 	if err != nil {
2041
 	if err != nil {
2038
 		tx.Rollback()
2042
 		tx.Rollback()
2039
 		return err
2043
 		return err
4109
 	err = readDb.Where("org_id = ? and patient_id = ? and sys_record_time = ? and status = 1", orgId, patient_id, sys_record_time).Find(&outifno).Error
4113
 	err = readDb.Where("org_id = ? and patient_id = ? and sys_record_time = ? and status = 1", orgId, patient_id, sys_record_time).Find(&outifno).Error
4110
 	return outifno, err
4114
 	return outifno, err
4111
 }
4115
 }
4116
+
4117
+func GetLastDilysisOrder(orgid int64, patient_id int64, dialysis_date int64) (models.DialysisOrder, error) {
4118
+
4119
+	order := models.DialysisOrder{}
4120
+
4121
+	err = XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date < ? and status= 1", orgid, patient_id, dialysis_date).Last(&order).Error
4122
+
4123
+	return order, err
4124
+}

+ 22 - 1
service/new_stock_service.go Ver arquivo

80
 	offset := (page - 1) * limit
80
 	offset := (page - 1) * limit
81
 	likeKey := "%" + keyword + "%"
81
 	likeKey := "%" + keyword + "%"
82
 
82
 
83
-	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1 and x.total_count > 0 and x.org_id =?", orgId)
83
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1  and x.org_id =?", orgId)
84
 
84
 
85
 	if good_type == 2 {
85
 	if good_type == 2 {
86
 		db = db.Where(" x.total_count<=x.stock_warn_count")
86
 		db = db.Where(" x.total_count<=x.stock_warn_count")
211
 	return &drugStockCount, nil
211
 	return &drugStockCount, nil
212
 }
212
 }
213
 
213
 
214
+func GetDrugStockCountSix(storehouse_id int64, drug_id int64, org_id int64) (models.XtDrugStockCount, error) {
215
+
216
+	drugStockCount := models.XtDrugStockCount{}
217
+	err = XTReadDB().Where("storehouse_id = ? and drug_id = ? and user_org_id  = ? and status = 1", storehouse_id, drug_id, org_id).Find(&drugStockCount).Error
218
+	return drugStockCount, err
219
+}
220
+
214
 func CreateDrugStockSum(drug models.XtDrugStockCount) error {
221
 func CreateDrugStockSum(drug models.XtDrugStockCount) error {
215
 
222
 
216
 	ut := XTWriteDB().Begin()
223
 	ut := XTWriteDB().Begin()
338
 	db.Commit()
345
 	db.Commit()
339
 	return err
346
 	return err
340
 }
347
 }
348
+
349
+func GetAutoGoodLastCount(goodid int64, count int64, record_time int64, patient_id int64) (models.AutomaticReduceDetail, error) {
350
+
351
+	detail := models.AutomaticReduceDetail{}
352
+	err := XTReadDB().Where("good_id = ? and count = ? and record_time = ? and patient_id = ?", goodid, count, record_time, patient_id).Last(&detail).Error
353
+	return detail, err
354
+}
355
+
356
+func UpdateLastAutoCount(id int64, count int64) error {
357
+
358
+	detail := models.AutomaticReduceDetail{}
359
+	err := XTWriteDB().Model(&detail).Where("id = ?", id).Update(map[string]interface{}{"count": count, "status": 1}).Error
360
+	return err
361
+}

+ 136 - 31
service/new_warehouse_service.go Ver arquivo

14
 //耗材出库
14
 //耗材出库
15
 func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
15
 func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
16
 
16
 
17
-	fmt.Println("出库数量2333333333333333333333333333333333hhha", goods.Count)
18
 	//开事务
17
 	//开事务
19
 	var deliver_number int64 = 0
18
 	var deliver_number int64 = 0
20
 	var stock_number int64 = 0
19
 	var stock_number int64 = 0
47
 		if errThree != nil {
46
 		if errThree != nil {
48
 			return errThree
47
 			return errThree
49
 		}
48
 		}
49
+		//更新his_prescripton_project出库状态值
50
+		UpdateHisPrescriptionProjectStatus(goods.GoodId, record_time, orgID, patient_id)
50
 
51
 
51
 		//查询剩余库存
52
 		//查询剩余库存
52
 		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID)
53
 		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID)
81
 			StorehouseId:            goods.StorehouseId,
82
 			StorehouseId:            goods.StorehouseId,
82
 			IsCheck:                 1,
83
 			IsCheck:                 1,
83
 			OverCount:               sum_count,
84
 			OverCount:               sum_count,
85
+			RegisterNumber:          warehouse.RegisterNumber,
84
 		}
86
 		}
85
 		warehouseOutInfo.Count = count
87
 		warehouseOutInfo.Count = count
86
-
88
+		if orgID == 9671 || orgID == 10265 {
89
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
90
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
91
+		}
87
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
92
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
93
+		//fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
88
 		if errcodes == gorm.ErrRecordNotFound {
94
 		if errcodes == gorm.ErrRecordNotFound {
89
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
95
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
90
 			if errOne != nil {
96
 			if errOne != nil {
93
 		} else if errcodes == nil {
99
 		} else if errcodes == nil {
94
 
100
 
95
 			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
101
 			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
96
-			fmt.Println("goods.cout23323233223232323w", count)
97
-			fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
102
+			//fmt.Println("goods.cout23323233223232323w", count)
103
+			//fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
98
 			if count != outInfoOne.Count {
104
 			if count != outInfoOne.Count {
99
 				UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
105
 				UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
100
 			}
106
 			}
115
 		for _, item := range flowGoodTwo {
121
 		for _, item := range flowGoodTwo {
116
 			out_count_one += item.Count
122
 			out_count_one += item.Count
117
 		}
123
 		}
118
-		fmt.Println("deliver_number", deliver_number)
119
-		fmt.Println("out_count", out_count)
120
-		fmt.Println("count", count)
121
-		fmt.Println("cancel_out_count2333233", out_count_one)
124
+		//fmt.Println("deliver_number", deliver_number)
125
+		//fmt.Println("out_count", out_count)
126
+		//fmt.Println("count", count)
127
+		//fmt.Println("cancel_out_count2333233", out_count_one)
122
 		//如果本次出库数据大于历史出库数据 新增1条流水
128
 		//如果本次出库数据大于历史出库数据 新增1条流水
123
 		if count > (out_count - out_count_one) {
129
 		if count > (out_count - out_count_one) {
130
+
124
 			flow := models.VmStockFlow{
131
 			flow := models.VmStockFlow{
125
 				WarehouseOutId:          warehouseOut.ID,
132
 				WarehouseOutId:          warehouseOut.ID,
126
 				WarehousingId:           warehouse.ID,
133
 				WarehousingId:           warehouse.ID,
149
 				StorehouseId:            goods.StorehouseId,
156
 				StorehouseId:            goods.StorehouseId,
150
 				OverCount:               sum_count,
157
 				OverCount:               sum_count,
151
 				BuyPrice:                warehouse.Price,
158
 				BuyPrice:                warehouse.Price,
159
+				RegisterNumber:          warehouse.RegisterNumber,
160
+			}
161
+			if orgID == 9671 || orgID == 10265 {
162
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
163
+				flow.Price = goodsInfo.PackingPrice
164
+				flow.BuyPrice = goodsInfo.BuyPrice
152
 			}
165
 			}
153
 			errThre := CreateStockFlowOne(flow)
166
 			errThre := CreateStockFlowOne(flow)
154
 			if errThre != nil {
167
 			if errThre != nil {
216
 				StorehouseId:    goods.StorehouseId,
229
 				StorehouseId:    goods.StorehouseId,
217
 				IsCheck:         1,
230
 				IsCheck:         1,
218
 			}
231
 			}
219
-
232
+			if orgID == 9671 || orgID == 10265 {
233
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
234
+				cancelStockInfo.Price = goodsInfo.PackingPrice
235
+			}
220
 			CreateCancelStockInfoOne(&cancelStockInfo)
236
 			CreateCancelStockInfoOne(&cancelStockInfo)
221
 
237
 
222
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
238
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
231
 				PatientId:               patient_id,
247
 				PatientId:               patient_id,
232
 				SystemTime:              record_time,
248
 				SystemTime:              record_time,
233
 				ConsumableType:          7,
249
 				ConsumableType:          7,
234
-				IsSys:                   0,
250
+				IsSys:                   1,
235
 				WarehousingOrder:        "",
251
 				WarehousingOrder:        "",
236
-				WarehouseOutId:          0,
237
-				WarehouseOutOrderNumber: "",
252
+				WarehouseOutId:          lastOut.WarehouseOutId,
253
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
238
 				IsEdit:                  0,
254
 				IsEdit:                  0,
239
 				CancelStockId:           cancel.ID,
255
 				CancelStockId:           cancel.ID,
240
 				CancelOrderNumber:       cancel.OrderNumber,
256
 				CancelOrderNumber:       cancel.OrderNumber,
254
 				StorehouseId:            goods.StorehouseId,
270
 				StorehouseId:            goods.StorehouseId,
255
 				BuyPrice:                warehouse.Price,
271
 				BuyPrice:                warehouse.Price,
256
 				ProjectId:               goods.ProjectId,
272
 				ProjectId:               goods.ProjectId,
273
+				OverCount:               sum_count,
274
+				RegisterNumber:          warehouse.RegisterNumber,
275
+			}
276
+			if orgID == 9671 || orgID == 10265 {
277
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
278
+				flow.Price = goodsInfo.PackingPrice
279
+				flow.BuyPrice = goodsInfo.BuyPrice
257
 			}
280
 			}
258
 			CreateStockFlowOne(flow)
281
 			CreateStockFlowOne(flow)
259
 		}
282
 		}
327
 			StorehouseId:            goods.StorehouseId,
350
 			StorehouseId:            goods.StorehouseId,
328
 			IsCheck:                 1,
351
 			IsCheck:                 1,
329
 			OverCount:               sum_count,
352
 			OverCount:               sum_count,
353
+			RegisterNumber:          warehouse.RegisterNumber,
330
 		}
354
 		}
331
 		warehouseOutInfo.Count = stock_number
355
 		warehouseOutInfo.Count = stock_number
332
-
333
-		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, goods.PatientId, record_time, goods.ProjectId)
334
-
356
+		if orgID == 9671 || orgID == 10265 {
357
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
358
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
359
+		}
360
+		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
361
+		//fmt.Println("errcodes23332322332323223", errcodes, goods.ProjectId)
335
 		if errcodes == gorm.ErrRecordNotFound {
362
 		if errcodes == gorm.ErrRecordNotFound {
336
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
363
 			errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
337
 			if errOne != nil {
364
 			if errOne != nil {
389
 				StorehouseId:            goods.StorehouseId,
416
 				StorehouseId:            goods.StorehouseId,
390
 				OverCount:               sum_count,
417
 				OverCount:               sum_count,
391
 				BuyPrice:                warehouse.Price,
418
 				BuyPrice:                warehouse.Price,
419
+				RegisterNumber:          warehouse.RegisterNumber,
420
+			}
421
+			if orgID == 9671 || orgID == 10265 {
422
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
423
+				flow.Price = goodsInfo.PackingPrice
424
+				flow.BuyPrice = goodsInfo.BuyPrice
392
 			}
425
 			}
393
 			errThre := CreateStockFlowOne(flow)
426
 			errThre := CreateStockFlowOne(flow)
394
 			if errThre != nil {
427
 			if errThre != nil {
452
 				StorehouseId:    goods.StorehouseId,
485
 				StorehouseId:    goods.StorehouseId,
453
 				IsCheck:         1,
486
 				IsCheck:         1,
454
 			}
487
 			}
455
-
488
+			if orgID == 9671 || orgID == 10265 {
489
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
490
+				cancelStockInfo.Price = goodsInfo.PackingPrice
491
+			}
456
 			CreateCancelStockInfoOne(&cancelStockInfo)
492
 			CreateCancelStockInfoOne(&cancelStockInfo)
457
 
493
 
458
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
494
 			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
467
 				PatientId:               patient_id,
503
 				PatientId:               patient_id,
468
 				SystemTime:              record_time,
504
 				SystemTime:              record_time,
469
 				ConsumableType:          7,
505
 				ConsumableType:          7,
470
-				IsSys:                   0,
506
+				IsSys:                   1,
471
 				WarehousingOrder:        "",
507
 				WarehousingOrder:        "",
472
-				WarehouseOutId:          0,
473
-				WarehouseOutOrderNumber: "",
508
+				WarehouseOutId:          lastOut.WarehouseOutId,
509
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
474
 				IsEdit:                  0,
510
 				IsEdit:                  0,
475
 				CancelStockId:           cancel.ID,
511
 				CancelStockId:           cancel.ID,
476
 				CancelOrderNumber:       cancel.OrderNumber,
512
 				CancelOrderNumber:       cancel.OrderNumber,
490
 				StorehouseId:            goods.StorehouseId,
526
 				StorehouseId:            goods.StorehouseId,
491
 				BuyPrice:                warehouse.Price,
527
 				BuyPrice:                warehouse.Price,
492
 				ProjectId:               goods.ProjectId,
528
 				ProjectId:               goods.ProjectId,
529
+				OverCount:               sum_count,
530
+				RegisterNumber:          warehouse.RegisterNumber,
531
+			}
532
+			if orgID == 9671 || orgID == 10265 {
533
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
534
+				flow.Price = goodsInfo.PackingPrice
535
+				flow.BuyPrice = goodsInfo.BuyPrice
493
 			}
536
 			}
494
 			CreateStockFlowOne(flow)
537
 			CreateStockFlowOne(flow)
495
 		}
538
 		}
697
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
740
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
698
 		var sum_count int64
741
 		var sum_count int64
699
 		for _, its := range stockInfo {
742
 		for _, its := range stockInfo {
700
-			sum_count += its.StockMaxNumber*drup.MinNumber + its.StockMinNumber
743
+			if its.MaxUnit == drup.MaxUnit {
744
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
745
+			}
746
+			sum_count += its.StockMaxNumber + its.StockMinNumber
701
 		}
747
 		}
702
 
748
 
703
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
749
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
869
 				PatientId:               advice.PatientId,
915
 				PatientId:               advice.PatientId,
870
 				SystemTime:              advice.AdviceDate,
916
 				SystemTime:              advice.AdviceDate,
871
 				ConsumableType:          7,
917
 				ConsumableType:          7,
872
-				IsSys:                   0,
918
+				IsSys:                   1,
873
 				WarehousingOrder:        "",
919
 				WarehousingOrder:        "",
874
 				WarehouseOutId:          0,
920
 				WarehouseOutId:          0,
875
 				WarehouseOutOrderNumber: "",
921
 				WarehouseOutOrderNumber: "",
967
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1013
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
968
 		var sum_count int64
1014
 		var sum_count int64
969
 		for _, its := range stockInfo {
1015
 		for _, its := range stockInfo {
970
-			sum_count += its.StockMaxNumber*drup.MinNumber + its.StockMinNumber
1016
+			if its.MaxUnit == drup.MaxUnit {
1017
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
1018
+			}
1019
+			sum_count += its.StockMaxNumber + its.StockMinNumber
971
 		}
1020
 		}
972
 
1021
 
973
 		// 当该批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1022
 		// 当该批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1161
 				PatientId:               advice.PatientId,
1210
 				PatientId:               advice.PatientId,
1162
 				SystemTime:              advice.AdviceDate,
1211
 				SystemTime:              advice.AdviceDate,
1163
 				ConsumableType:          7,
1212
 				ConsumableType:          7,
1164
-				IsSys:                   0,
1213
+				IsSys:                   1,
1165
 				WarehousingOrder:        "",
1214
 				WarehousingOrder:        "",
1166
 				WarehouseOutId:          0,
1215
 				WarehouseOutId:          0,
1167
 				WarehouseOutOrderNumber: "",
1216
 				WarehouseOutOrderNumber: "",
1257
 		return err
1306
 		return err
1258
 	}
1307
 	}
1259
 	// 将该批次的剩余库存数量转换为拆零数量
1308
 	// 将该批次的剩余库存数量转换为拆零数量
1260
-	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1309
+	// 将该批次的剩余库存数量转换为拆零数量
1310
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
1311
+		fmt.Println("进来1")
1312
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1313
+		fmt.Println("剩余库存1", stock_number)
1314
+	}
1315
+	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
1316
+		fmt.Println("进来2")
1317
+		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
1318
+		fmt.Println("剩余库存2", stock_number)
1319
+	}
1320
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
1321
+		fmt.Println("进来3")
1322
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1323
+		fmt.Println("剩余库存3", stock_number)
1324
+	}
1325
+	fmt.Println("剩余库存23333333333333333333333333333wo", stock_number)
1326
+	fmt.Println("出库数量2333333333333333333333333333333333333wo", deliver_number)
1261
 
1327
 
1262
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1328
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1263
 	if stock_number >= deliver_number {
1329
 	if stock_number >= deliver_number {
1278
 			}
1344
 			}
1279
 		}
1345
 		}
1280
 
1346
 
1281
-		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
1347
+		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
1348
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
1349
+		}
1350
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
1351
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
1352
+		}
1353
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
1354
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
1355
+		}
1282
 
1356
 
1283
 		if warehouse.StockMaxNumber < 0 {
1357
 		if warehouse.StockMaxNumber < 0 {
1284
 			warehouse.StockMaxNumber = 0
1358
 			warehouse.StockMaxNumber = 0
1289
 
1363
 
1290
 		warehouse.Mtime = time.Now().Unix()
1364
 		warehouse.Mtime = time.Now().Unix()
1291
 
1365
 
1366
+		fmt.Println("minnU目标而332322323323233223323223我", minNumber)
1367
+		fmt.Println("max_number232232332232322wo", maxNumber)
1368
+		fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
1292
 		if warehouse.StockMinNumber < minNumber {
1369
 		if warehouse.StockMinNumber < minNumber {
1293
 
1370
 
1294
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
1371
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
1295
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
1372
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
1296
 		} else {
1373
 		} else {
1297
 			if minNumber > 0 {
1374
 			if minNumber > 0 {
1298
-				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
1375
+				if (warehouse.StockMinNumber - minNumber) >= 0 {
1376
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
1377
+				}
1378
+
1299
 			}
1379
 			}
1300
 
1380
 
1301
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
1381
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
1302
 				if warehouse.StockMinNumber > 0 {
1382
 				if warehouse.StockMinNumber > 0 {
1303
-					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
1383
+					if warehouse.StockMinNumber-deliver_number >= 0 {
1384
+						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
1385
+					}
1386
+
1304
 				}
1387
 				}
1305
 
1388
 
1306
 			}
1389
 			}
1308
 		}
1391
 		}
1309
 
1392
 
1310
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
1393
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
1311
-			if (warehouse.StockMinNumber - deliver_number) > 0 {
1394
+			if (warehouse.StockMinNumber - deliver_number) >= 0 {
1312
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
1395
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
1313
 			}
1396
 			}
1314
 
1397
 
1333
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1416
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1334
 		var sum_count int64
1417
 		var sum_count int64
1335
 		for _, its := range stockInfo {
1418
 		for _, its := range stockInfo {
1336
-			sum_count += its.StockMaxNumber*drup.MinNumber + its.StockMinNumber
1419
+			if its.MaxUnit == drup.MaxUnit {
1420
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
1421
+			}
1422
+			sum_count += its.StockMaxNumber + its.StockMinNumber
1337
 		}
1423
 		}
1338
 
1424
 
1339
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
1425
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
1543
 				AdviceId:                advice.ID,
1629
 				AdviceId:                advice.ID,
1544
 				StorehouseId:            storeConfig.DrugStorehouseOut,
1630
 				StorehouseId:            storeConfig.DrugStorehouseOut,
1545
 				LastPrice:               warehouse.Price,
1631
 				LastPrice:               warehouse.Price,
1632
+				OverCount:               sum_count,
1546
 			}
1633
 			}
1547
 			CreateDrugFlowOne(flow)
1634
 			CreateDrugFlowOne(flow)
1548
 			AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
1635
 			AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
1615
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1702
 		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
1616
 		var sum_count int64
1703
 		var sum_count int64
1617
 		for _, its := range stockInfo {
1704
 		for _, its := range stockInfo {
1618
-			sum_count += its.StockMaxNumber*drup.MinNumber + its.StockMinNumber
1705
+			if its.MaxUnit == drup.MaxUnit {
1706
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
1707
+			}
1708
+			sum_count += its.StockMaxNumber + its.StockMinNumber
1619
 		}
1709
 		}
1620
 
1710
 
1621
 		// 当该批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1711
 		// 当该批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
1849
 				AdviceId:                advice.ID,
1939
 				AdviceId:                advice.ID,
1850
 				StorehouseId:            storeConfig.DrugStorehouseOut,
1940
 				StorehouseId:            storeConfig.DrugStorehouseOut,
1851
 				LastPrice:               warehouse.Price,
1941
 				LastPrice:               warehouse.Price,
1942
+				OverCount:               sum_count,
1852
 			}
1943
 			}
1853
 			CreateDrugFlowOne(flow)
1944
 			CreateDrugFlowOne(flow)
1854
 
1945
 
1908
 
1999
 
1909
 func UpdateSingleDrugWarehouseOutInfoSix(patient_id int64, advice_date int64, orgid int64, info *models.DrugWarehouseOutInfo, advice_id int64) error {
2000
 func UpdateSingleDrugWarehouseOutInfoSix(patient_id int64, advice_date int64, orgid int64, info *models.DrugWarehouseOutInfo, advice_id int64) error {
1910
 
2001
 
1911
-	err := XTWriteDB().Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and advice_date = ? and org_id = ? and advice_id = ?", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
2002
+	err := XTWriteDB().Model(&models.XtDrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and advice_id = ?", patient_id, advice_date, orgid, advice_id).Update(map[string]interface{}{"count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "number": info.Number, "batch_number": info.BatchNumber, "count_unit": info.CountUnit, "warehouse_info_id": info.WarehouseInfoId, "storehouse_id": info.StorehouseId}).Error
1912
 	return err
2003
 	return err
1913
 }
2004
 }
1914
 
2005
 
2011
 	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", patient_id, advice_date, orgid).Update(map[string]interface{}{"count": info.Count, "count_unit": info.CountUnit}).Error
2102
 	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", patient_id, advice_date, orgid).Update(map[string]interface{}{"count": info.Count, "count_unit": info.CountUnit}).Error
2012
 	return err
2103
 	return err
2013
 }
2104
 }
2105
+
2106
+func FindeGoodInfo(orgid int64, id int64) (models.GoodInformation, error) {
2107
+
2108
+	information := models.GoodInformation{}
2109
+	err := XTReadDB().Where("org_id = ? and id = ? and status = 1", orgid, id).Find(&information).Error
2110
+	return information, err
2111
+}
2112
+
2113
+func UpdateHisPrescriptionProjectStatus(project_id int64, record_time int64, user_org_id int64, patient_id int64) (models.HisPrescriptionProject, error) {
2114
+
2115
+	project := models.HisPrescriptionProject{}
2116
+	err := XTWriteDB().Model(&project).Where("project_id  = ? and record_date = ? and user_org_id = ? and patient_id = ? and status = 1", project_id, record_time, user_org_id, patient_id).Update(map[string]interface{}{"is_out": 1}).Error
2117
+	return project, err
2118
+}

+ 19 - 1
service/patient_schedule_template_service.go Ver arquivo

340
 	addTemplateItems []*models.PatientScheduleTemplateItem,
340
 	addTemplateItems []*models.PatientScheduleTemplateItem,
341
 	delTemplateItems []*models.PatientScheduleTemplateItem,
341
 	delTemplateItems []*models.PatientScheduleTemplateItem,
342
 	changeTemplateItems []*models.PatientScheduleTemplateItem,
342
 	changeTemplateItems []*models.PatientScheduleTemplateItem,
343
-) error {
343
+	shouldUpdateNextWeekSchedules bool,
344
+	shouldUpdateNextSecondWeekSchedules bool) error {
344
 
345
 
345
 	now := time.Now()
346
 	now := time.Now()
346
 	tx := writeDb.Begin()
347
 	tx := writeDb.Begin()
438
 	//	}
439
 	//	}
439
 	//}
440
 	//}
440
 
441
 
442
+	if orgID != 9671 && orgID != 10340 {
443
+		if shouldUpdateNextWeekSchedules {
444
+			nextWeek := now.AddDate(0, 0, 7)
445
+			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
446
+				tx.Rollback()
447
+				return updateErr
448
+			}
449
+		}
450
+		if shouldUpdateNextSecondWeekSchedules {
451
+			nextWeek := now.AddDate(0, 0, 14)
452
+			if updateErr := _updateWeekSchedules(tx, orgID, nextWeek, addTemplateItems, delTemplateItems, changeTemplateItems, devicesMap); updateErr != nil {
453
+				tx.Rollback()
454
+				return updateErr
455
+			}
456
+		}
457
+	}
458
+
441
 	tx.Commit()
459
 	tx.Commit()
442
 	return nil
460
 	return nil
443
 }
461
 }

+ 11 - 3
service/patient_service.go Ver arquivo

80
 	return
80
 	return
81
 }
81
 }
82
 
82
 
83
+func GetAllPatientListTwenty(orgID int64) (patients []*models.Patients, total int64, err error) {
84
+
85
+	db := readDb.Table("xt_patients as p").Where("p.user_org_id=? and p.status=1 and p.lapseto = 1", orgID)
86
+
87
+	err = db.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").Count(&total).Find(&patients).Error
88
+	return
89
+}
90
+
83
 func GetAllPatientListSix(orgID int64) (patients []*models.MSchedualPatientList, err error) {
91
 func GetAllPatientListSix(orgID int64) (patients []*models.MSchedualPatientList, err error) {
84
 
92
 
85
 	err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1", orgID).Find(&patients).Error
93
 	err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1", orgID).Find(&patients).Error
296
 	defer redis.Close()
304
 	defer redis.Close()
297
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
305
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
298
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
306
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
299
-
307
+	redis.Set(dialysis_orders_list_all, "", time.Second)
300
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
308
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
301
 		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
309
 		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
302
 
310
 
722
 		return
730
 		return
723
 	}
731
 	}
724
 	// 删除排班和排班模板信息
732
 	// 删除排班和排班模板信息
725
-	if lapseto.LapsetoType == 2 {
733
+	if lapseto.LapsetoType == 2 || lapseto.LapsetoType == 3 {
726
 		now := time.Now()
734
 		now := time.Now()
727
 		deleteScheduleErr := utx.Model(&models.PatientSchedule{}).Where("patient_id = ? AND schedule_date >= ? AND status = 1", patient.ID, lapseto.LapsetoTime).Updates(map[string]interface{}{
735
 		deleteScheduleErr := utx.Model(&models.PatientSchedule{}).Where("patient_id = ? AND schedule_date >= ? AND status = 1", patient.ID, lapseto.LapsetoTime).Updates(map[string]interface{}{
728
 			"status":       0,
736
 			"status":       0,
822
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
830
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
823
 
831
 
824
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
832
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
825
-		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot}).Error
833
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark}).Error
826
 	return err
834
 	return err
827
 }
835
 }
828
 
836
 

+ 3 - 3
service/patientmanage_service.go Ver arquivo

950
 
950
 
951
 func UpdatedPatient(patients models.Patients, id int64) error {
951
 func UpdatedPatient(patients models.Patients, id int64) error {
952
 
952
 
953
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone}).Error
953
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan}).Error
954
 
954
 
955
 	return err
955
 	return err
956
 }
956
 }
957
 
957
 
958
 func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
958
 func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
959
 
959
 
960
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone}).Error
960
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "remark": patients.Remark, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan}).Error
961
 
961
 
962
 	return err
962
 	return err
963
 }
963
 }
964
 
964
 
965
 func UpdateXtPatientNewOne(patients models.XtPatientsNew, id int64) error {
965
 func UpdateXtPatientNewOne(patients models.XtPatientsNew, id int64) error {
966
 
966
 
967
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "adminssion_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "member_patienttype": patients.MemberPatienttype, "member_treatement": patients.MemberTreatement}).Error
967
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "adminssion_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "member_patienttype": patients.MemberPatienttype, "member_treatement": patients.MemberTreatement, "treatment_plan": patients.TreatmentPlan}).Error
968
 	return err
968
 	return err
969
 }
969
 }
970
 
970
 

+ 19 - 6
service/pharmacy_service.go Ver arquivo

742
 			err = fmt.Errorf("!:%v", err)
742
 			err = fmt.Errorf("!:%v", err)
743
 			return
743
 			return
744
 		}
744
 		}
745
-		drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
745
+		//drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
746
 		//查询默认仓库
746
 		//查询默认仓库
747
 		storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
747
 		storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
748
 		//查询默认仓库剩余多少库存
748
 		//查询默认仓库剩余多少库存
749
 		var sum_count int64
749
 		var sum_count int64
750
 		stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
750
 		stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
751
 		for _, its := range stockInfo {
751
 		for _, its := range stockInfo {
752
-			sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
752
+			baseDrug, _ := GetBaseDrugMedical(its.DrugId)
753
+			if its.MaxUnit == baseDrug.MaxUnit {
754
+				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
755
+			}
756
+			sum_count += its.StockMaxNumber + its.StockMinNumber
753
 		}
757
 		}
758
+
754
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
759
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
755
 	}
760
 	}
756
 
761
 
789
 			err = fmt.Errorf("!:%v", err)
794
 			err = fmt.Errorf("!:%v", err)
790
 			return
795
 			return
791
 		}
796
 		}
792
-		drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
797
+		//drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
793
 		//查询默认仓库
798
 		//查询默认仓库
794
 		storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
799
 		storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
795
 		//查询默认仓库剩余多少库存
800
 		//查询默认仓库剩余多少库存
796
 		var sum_count int64
801
 		var sum_count int64
797
 		stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
802
 		stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
798
 		for _, its := range stockInfo {
803
 		for _, its := range stockInfo {
799
-			sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
804
+			baseDrug, _ := GetBaseDrugMedical(its.DrugId)
805
+			if its.MaxUnit == baseDrug.MaxUnit {
806
+				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
807
+			}
808
+			sum_count += its.StockMaxNumber + its.StockMinNumber
800
 		}
809
 		}
801
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
810
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
802
 	}
811
 	}
1084
 		err = fmt.Errorf("!:%v", err)
1093
 		err = fmt.Errorf("!:%v", err)
1085
 		return
1094
 		return
1086
 	}
1095
 	}
1087
-	drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
1096
+	//drug, _ := FindBaseDrugLibRecordSeven(orgid, v.DrugId)
1088
 	//查询默认仓库
1097
 	//查询默认仓库
1089
 	storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
1098
 	storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
1090
 	//查询默认仓库剩余多少库存
1099
 	//查询默认仓库剩余多少库存
1091
 	var sum_count int64
1100
 	var sum_count int64
1092
 	stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
1101
 	stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, v.DrugId)
1093
 	for _, its := range stockInfo {
1102
 	for _, its := range stockInfo {
1094
-		sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
1103
+		baseDrug, _ := GetBaseDrugMedical(its.DrugId)
1104
+		if its.MaxUnit == baseDrug.MaxUnit {
1105
+			its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1106
+		}
1107
+		sum_count += its.StockMaxNumber + its.StockMinNumber
1095
 	}
1108
 	}
1096
 	UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
1109
 	UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
1097
 	return
1110
 	return

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver arquivo

295
 		db = db.Where("x.org_id = ?", orgid)
295
 		db = db.Where("x.org_id = ?", orgid)
296
 	}
296
 	}
297
 	if startime > 0 {
297
 	if startime > 0 {
298
-		db = db.Where("x.ctime >= ?", startime)
298
+		db = db.Where("x.sys_record_time >= ?", startime)
299
 	}
299
 	}
300
 	if endtime > 0 {
300
 	if endtime > 0 {
301
-		db = db.Where("x.ctime<=?", endtime)
301
+		db = db.Where("x.sys_record_time<=?", endtime)
302
 	}
302
 	}
303
 	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,x.ctime,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
303
 	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,x.ctime,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
304
 	return out, err
304
 	return out, err

+ 14 - 0
service/schedule_service.go Ver arquivo

66
 	return
66
 	return
67
 }
67
 }
68
 
68
 
69
+func GetPatientWithScheduleAndSolutionTwo(orgID int64, keywords string, weekStart, weekEnd, schedule, contagion int64) (patients []*models.Patients, err error) {
70
+	db := readDb.Table("xt_patients as p").
71
+		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
72
+		//Preload("Schedules", "user_org_id=? and schedule_date>=? and schedule_date<= ? and status=1", orgID, weekStart, weekEnd).
73
+		Where("p.user_org_id=? and p.lapseto=1 and p.status=1", orgID)
74
+	if len(keywords) > 0 {
75
+		likeKey := "%" + keywords + "%"
76
+		db = db.Where("p.name LIKE ?", likeKey)
77
+	}
78
+
79
+	err = db.Find(&patients).Error
80
+	return
81
+}
82
+
69
 func GetWeekSchedule(orgID int64, start, end int64) (schedules []*models.Schedule, err error) {
83
 func GetWeekSchedule(orgID int64, start, end int64) (schedules []*models.Schedule, err error) {
70
 
84
 
71
 	err = readDb.Table("xt_schedule as s").Preload("PatientInfectiousDiseases", "status = 1 ").
85
 	err = readDb.Table("xt_schedule as s").Preload("PatientInfectiousDiseases", "status = 1 ").

+ 154 - 34
service/self_drug_service.go Ver arquivo

1582
 	return info, total, err
1582
 	return info, total, err
1583
 }
1583
 }
1584
 
1584
 
1585
-func GetGoodPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfo, total int64, err error) {
1585
+func GetGoodPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfoTwenty, total int64, err error) {
1586
 
1586
 
1587
 	db := XTReadDB().Model(&goodinfo).Where("status = 1 and total_count > 0")
1587
 	db := XTReadDB().Model(&goodinfo).Where("status = 1 and total_count > 0")
1588
 	offset := (page - 1) * limit
1588
 	offset := (page - 1) * limit
1675
 	return info, total, err
1675
 	return info, total, err
1676
 }
1676
 }
1677
 
1677
 
1678
-func GetDrugPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrug, total int64, err error) {
1678
+func GetDrugPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
1679
 
1679
 
1680
 	db := XTReadDB().Model(&druginfo).Where("status = 1")
1680
 	db := XTReadDB().Model(&druginfo).Where("status = 1")
1681
 	offset := (page - 1) * limit
1681
 	offset := (page - 1) * limit
1819
 		db = db.Preload("DrugWarehouseInfo", "org_id = ? and status = 1 and is_check = 1", orgId)
1819
 		db = db.Preload("DrugWarehouseInfo", "org_id = ? and status = 1 and is_check = 1", orgId)
1820
 	}
1820
 	}
1821
 
1821
 
1822
-	if len(goodIds) > 0 {
1823
-		db = db.Where("id in(?)", goodIds)
1824
-	}
1822
+	//if len(goodIds) > 0 {
1823
+	//	db = db.Where("id in(?)", goodIds)
1824
+	//}
1825
 
1825
 
1826
 	if len(keyword) > 0 {
1826
 	if len(keyword) > 0 {
1827
 		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
1827
 		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
1993
 	return info, err
1993
 	return info, err
1994
 }
1994
 }
1995
 
1995
 
1996
-func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.VmStockFlow, err error) {
1996
+func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
1997
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type =1")
1997
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type =1")
1998
 	if good_id > 0 {
1998
 	if good_id > 0 {
1999
 		db = db.Where("good_id = ?", good_id)
1999
 		db = db.Where("good_id = ?", good_id)
2011
 	return info, err
2011
 	return info, err
2012
 }
2012
 }
2013
 
2013
 
2014
-func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2014
+func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2015
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2015
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2016
 	if good_id > 0 {
2016
 	if good_id > 0 {
2017
 		db = db.Where("good_id = ?", good_id)
2017
 		db = db.Where("good_id = ?", good_id)
2029
 	return outinfo, err
2029
 	return outinfo, err
2030
 }
2030
 }
2031
 
2031
 
2032
-func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2032
+func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2033
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2033
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2034
 	if good_id > 0 {
2034
 	if good_id > 0 {
2035
 		db = db.Where("good_id = ?", good_id)
2035
 		db = db.Where("good_id = ?", good_id)
2047
 	return outinfo, err
2047
 	return outinfo, err
2048
 }
2048
 }
2049
 
2049
 
2050
-func FindeStartFlowInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2050
+func FindeStartFlowInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2051
 
2051
 
2052
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2052
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2053
 	if good_id > 0 {
2053
 	if good_id > 0 {
2063
 	return info, err
2063
 	return info, err
2064
 }
2064
 }
2065
 
2065
 
2066
-func FindeStartFlowOutInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2066
+func FindeStartFlowOutInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2067
 
2067
 
2068
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2068
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2069
 	if good_id > 0 {
2069
 	if good_id > 0 {
2079
 	return info, err
2079
 	return info, err
2080
 }
2080
 }
2081
 
2081
 
2082
-func FindeStartCancelInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlow, err error) {
2082
+func FindeStartCancelInfo(good_id int64, orgid int64, startime int64) (info []*models.VmStockFlowTwenty, err error) {
2083
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2083
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2084
 	if good_id > 0 {
2084
 	if good_id > 0 {
2085
 		db = db.Where("good_id = ?", good_id)
2085
 		db = db.Where("good_id = ?", good_id)
2094
 	return info, err
2094
 	return info, err
2095
 }
2095
 }
2096
 
2096
 
2097
-func FindEndStartFlowInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2097
+func FindEndStartFlowInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2098
 
2098
 
2099
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2099
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2100
 	if good_id > 0 {
2100
 	if good_id > 0 {
2110
 	return info, err
2110
 	return info, err
2111
 }
2111
 }
2112
 
2112
 
2113
-func FindeEndFLowOutInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2113
+func FindeEndFLowOutInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2114
 
2114
 
2115
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2115
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 2 or consumable_type = 3)")
2116
 	if good_id > 0 {
2116
 	if good_id > 0 {
2126
 	return info, err
2126
 	return info, err
2127
 }
2127
 }
2128
 
2128
 
2129
-func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlow, err error) {
2129
+func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2130
 
2130
 
2131
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2131
 	db := XTReadDB().Model(&info).Where("status = 1 and  (consumable_type = 4 or consumable_type = 7)")
2132
 	if good_id > 0 {
2132
 	if good_id > 0 {
2142
 	return info, err
2142
 	return info, err
2143
 }
2143
 }
2144
 
2144
 
2145
-func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2145
+func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2146
 
2146
 
2147
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2147
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
2148
 	if good_id > 0 {
2148
 	if good_id > 0 {
2158
 	return outinfo, err
2158
 	return outinfo, err
2159
 }
2159
 }
2160
 
2160
 
2161
-func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2161
+func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2162
 
2162
 
2163
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2163
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2164
 	if good_id > 0 {
2164
 	if good_id > 0 {
2174
 	return outinfo, err
2174
 	return outinfo, err
2175
 }
2175
 }
2176
 
2176
 
2177
-func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2177
+func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2178
 
2178
 
2179
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2179
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2180
 	if good_id > 0 {
2180
 	if good_id > 0 {
2193
 	return outinfo, err
2193
 	return outinfo, err
2194
 }
2194
 }
2195
 
2195
 
2196
-func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlow, err error) {
2196
+func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2197
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2197
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2198
 	if good_id > 0 {
2198
 	if good_id > 0 {
2199
 		db = db.Where("good_id = ?", good_id)
2199
 		db = db.Where("good_id = ?", good_id)
2211
 	return outinfo, err
2211
 	return outinfo, err
2212
 }
2212
 }
2213
 
2213
 
2214
-func FindStartStockInventoryLosses(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlow, err error) {
2214
+func FindStartStockInventoryLosses(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2215
 
2215
 
2216
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2216
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2217
 	if good_id > 0 {
2217
 	if good_id > 0 {
2227
 	return outinfo, err
2227
 	return outinfo, err
2228
 }
2228
 }
2229
 
2229
 
2230
-func GetDrugWarehouseInfoStart(drug_id int64, orgid int64, startTime int64) (info []*models.DrugFlow, err error) {
2230
+func GetDrugWarehouseInfoStart(drug_id int64, orgid int64, startTime int64) (info []*models.DrugFlowTwenty, err error) {
2231
 
2231
 
2232
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type=1 ")
2232
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type=1 ")
2233
 	if drug_id > 0 {
2233
 	if drug_id > 0 {
2243
 	return info, err
2243
 	return info, err
2244
 }
2244
 }
2245
 
2245
 
2246
-func DrugWarehouseInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2246
+func DrugWarehouseInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2247
 
2247
 
2248
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2248
 	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type = 1")
2249
 	if drug_id > 0 {
2249
 	if drug_id > 0 {
2259
 	return info, err
2259
 	return info, err
2260
 }
2260
 }
2261
 
2261
 
2262
-func DrugWarehouseOutInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2262
+func DrugWarehouseOutInfoEnd(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2263
 
2263
 
2264
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 2 or consumable_type= 3)")
2264
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 2 or consumable_type= 3)")
2265
 	if drug_id > 0 {
2265
 	if drug_id > 0 {
2275
 	return info, err
2275
 	return info, err
2276
 }
2276
 }
2277
 
2277
 
2278
-func GetEndDrugFlowCancelInfo(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlow, err error) {
2278
+func GetEndDrugFlowCancelInfo(drug_id int64, orgid int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2279
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 4 or consumable_type= 7)")
2279
 	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type = 4 or consumable_type= 7)")
2280
 	if drug_id > 0 {
2280
 	if drug_id > 0 {
2281
 		db = db.Where("drug_id = ?", drug_id)
2281
 		db = db.Where("drug_id = ?", drug_id)
2290
 	return info, err
2290
 	return info, err
2291
 }
2291
 }
2292
 
2292
 
2293
-func GetDrugWarehouseStartEnd(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2293
+func GetDrugWarehouseStartEnd(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2294
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type = 1")
2294
 	db := XTReadDB().Model(&info).Where("status = 1 and  consumable_type = 1")
2295
 	if drug_id > 0 {
2295
 	if drug_id > 0 {
2296
 		db = db.Where("drug_id = ?", drug_id)
2296
 		db = db.Where("drug_id = ?", drug_id)
2308
 	return info, err
2308
 	return info, err
2309
 }
2309
 }
2310
 
2310
 
2311
-func FindeDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2311
+func FindeDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2312
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2312
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2313
 	if drug_id > 0 {
2313
 	if drug_id > 0 {
2314
 		db = db.Where("drug_id = ?", drug_id)
2314
 		db = db.Where("drug_id = ?", drug_id)
2326
 	return info, err
2326
 	return info, err
2327
 }
2327
 }
2328
 
2328
 
2329
-func FindStartEndDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlow, err error) {
2329
+func FindStartEndDrugWarehouseOutInfo(drug_id int64, orgid int64, startTime int64, endTime int64) (info []*models.DrugFlowTwenty, err error) {
2330
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type= 7)")
2330
 	db := XTReadDB().Model(&info).Where("status = 1  and (consumable_type= 7)")
2331
 	if drug_id > 0 {
2331
 	if drug_id > 0 {
2332
 		db = db.Where("drug_id = ?", drug_id)
2332
 		db = db.Where("drug_id = ?", drug_id)
2396
 	return flow, err
2396
 	return flow, err
2397
 }
2397
 }
2398
 
2398
 
2399
-func GetDrugFlowOut(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2399
+func GetDrugFlowOut(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2400
 
2400
 
2401
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2401
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 2 or consumable_type= 3)")
2402
 	if drug_id > 0 {
2402
 	if drug_id > 0 {
2412
 	return flow, err
2412
 	return flow, err
2413
 }
2413
 }
2414
 
2414
 
2415
-func GetStartDrugFlowCancelInfo(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2415
+func GetStartDrugFlowCancelInfo(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2416
 
2416
 
2417
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 4 or consumable_type = 7)")
2417
 	db := XTReadDB().Model(&flow).Where("status = 1  and (consumable_type = 4 or consumable_type = 7)")
2418
 
2418
 
2429
 	return flow, err
2429
 	return flow, err
2430
 }
2430
 }
2431
 
2431
 
2432
-func GetDrugFlowStartProfit(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2432
+func GetDrugFlowStartProfit(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2433
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10")
2433
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10")
2434
 	if drug_id > 0 {
2434
 	if drug_id > 0 {
2435
 		db = db.Where("drug_id = ?", drug_id)
2435
 		db = db.Where("drug_id = ?", drug_id)
2444
 	return flow, err
2444
 	return flow, err
2445
 }
2445
 }
2446
 
2446
 
2447
-func GetDrugFlowStartLosses(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlow, err error) {
2447
+func GetDrugFlowStartLosses(drug_id int64, user_org_id int64, ctime int64) (flow []*models.DrugFlowTwenty, err error) {
2448
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2448
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2449
 	if drug_id > 0 {
2449
 	if drug_id > 0 {
2450
 		db = db.Where("drug_id = ?", drug_id)
2450
 		db = db.Where("drug_id = ?", drug_id)
2459
 	return flow, err
2459
 	return flow, err
2460
 }
2460
 }
2461
 
2461
 
2462
-func GetDrugFlowEndProfit(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlow, err error) {
2462
+func GetDrugFlowEndProfit(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2463
 
2463
 
2464
 	db := XTReadDB().Model(&flow).Where("status = 1 and consumable_type = 10")
2464
 	db := XTReadDB().Model(&flow).Where("status = 1 and consumable_type = 10")
2465
 	if drug_id > 0 {
2465
 	if drug_id > 0 {
2475
 	return flow, err
2475
 	return flow, err
2476
 }
2476
 }
2477
 
2477
 
2478
-func GetDrugFlowEndLosses(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlow, err error) {
2478
+func GetDrugFlowEndLosses(drug_id int64, user_org_id int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2479
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11")
2479
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11")
2480
 	if drug_id > 0 {
2480
 	if drug_id > 0 {
2481
 		db = db.Where("drug_id = ?", drug_id)
2481
 		db = db.Where("drug_id = ?", drug_id)
2490
 	return flow, err
2490
 	return flow, err
2491
 }
2491
 }
2492
 
2492
 
2493
-func GetDrugFlowStartEndProfit(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlow, err error) {
2493
+func GetDrugFlowStartEndProfit(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2494
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10 ")
2494
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 10 ")
2495
 	if drug_id > 0 {
2495
 	if drug_id > 0 {
2496
 		db = db.Where("drug_id = ?", drug_id)
2496
 		db = db.Where("drug_id = ?", drug_id)
2508
 	return flow, err
2508
 	return flow, err
2509
 }
2509
 }
2510
 
2510
 
2511
-func GetDrugFlowStartEndLosses(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlow, err error) {
2511
+func GetDrugFlowStartEndLosses(drug_id int64, user_org_id int64, startime int64, endtime int64) (flow []*models.DrugFlowTwenty, err error) {
2512
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2512
 	db := XTReadDB().Model(&flow).Where("status = 1  and consumable_type = 11 ")
2513
 	if drug_id > 0 {
2513
 	if drug_id > 0 {
2514
 		db = db.Where("drug_id = ?", drug_id)
2514
 		db = db.Where("drug_id = ?", drug_id)
2561
 	err := XTWriteDB().Create(&stockCount).Error
2561
 	err := XTWriteDB().Create(&stockCount).Error
2562
 	return err
2562
 	return err
2563
 }
2563
 }
2564
+
2565
+func GetGoodNewPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfoTwenty, total int64, err error) {
2566
+
2567
+	db := XTReadDB().Model(&goodinfo).Where("status = 1 and total_count > 0")
2568
+	offset := (page - 1) * limit
2569
+	likeKey := "%" + keyword + "%"
2570
+	if good_type > 0 {
2571
+		db = db.Where("good_type_id = ?", good_type)
2572
+	}
2573
+
2574
+	if orgid > 0 {
2575
+		db = db.Where("org_id = ?", orgid)
2576
+	}
2577
+	if len(ids) > 0 {
2578
+		db = db.Where("id in(?)", goodIds)
2579
+	}
2580
+	if len(keyword) > 0 {
2581
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
2582
+	}
2583
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&goodinfo).Error
2584
+
2585
+	return goodinfo, total, err
2586
+}
2587
+
2588
+func GetStartLastFLow(goodid int64, orgid int64, startime int64) (models.VmStockFlowTwenty, error) {
2589
+
2590
+	flwo := models.VmStockFlowTwenty{}
2591
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime < ?", goodid, orgid, startime).Last(&flwo).Error
2592
+	return flwo, err
2593
+}
2594
+
2595
+func GetEndLastFlow(goodid int64, orgid int64, endtime int64) (models.VmStockFlowTwenty, error) {
2596
+	flwo := models.VmStockFlowTwenty{}
2597
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime <= ?", goodid, orgid, endtime).Last(&flwo).Error
2598
+	return flwo, err
2599
+}
2600
+
2601
+func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
2602
+
2603
+	db := XTReadDB().Model(&druginfo).Where("status = 1")
2604
+	offset := (page - 1) * limit
2605
+	likeKey := "%" + keyword + "%"
2606
+	if good_type > 0 {
2607
+		db = db.Where("drug_type = ?", good_type)
2608
+	}
2609
+
2610
+	if orgid > 0 {
2611
+		db = db.Where("org_id = ?", orgid)
2612
+	}
2613
+
2614
+	if len(keyword) > 0 {
2615
+		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
2616
+	}
2617
+	if len(infos) > 0 {
2618
+		db = db.Where("id in(?)", infos)
2619
+	}
2620
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&druginfo).Error
2621
+
2622
+	return druginfo, total, err
2623
+}
2624
+
2625
+func GetDrugStartFlow(drug_id int64, user_org_id int64, startime int64) (models.DrugFlowTwenty, error) {
2626
+
2627
+	flow := models.DrugFlowTwenty{}
2628
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<? and status = 1", drug_id, user_org_id, startime).Last(&flow).Error
2629
+	return flow, err
2630
+}
2631
+
2632
+func GetDrugEndFlow(drug_id int64, user_org_id int64, endtime int64) (models.DrugFlowTwenty, error) {
2633
+
2634
+	flow := models.DrugFlowTwenty{}
2635
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and ctime<=? and status = 1", drug_id, user_org_id, endtime).Last(&flow).Error
2636
+	return flow, err
2637
+}
2638
+
2639
+func GetAllStockCount(orgid int64) (stock []*models.XtGoodStockCount, err error) {
2640
+
2641
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&stock).Error
2642
+	return stock, err
2643
+}
2644
+func GetLastStockFlow(good_id int64) (models.VmStockFlow, error) {
2645
+
2646
+	flow := models.VmStockFlow{}
2647
+
2648
+	err := XTReadDB().Where("good_id = ? and status =1  and ctime<=1667231999", good_id).Last(&flow).Error
2649
+
2650
+	return flow, err
2651
+}
2652
+
2653
+func ModifyStockFlowById(id int64, over_count int64) error {
2654
+
2655
+	err := XTWriteDB().Model(&models.VmStockFlow{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"over_count": over_count}).Error
2656
+	return err
2657
+}
2658
+
2659
+func GetAllDrugCount(user_org_id int64) (drug []*models.XtDrugStockCount, err error) {
2660
+
2661
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&drug).Error
2662
+	return drug, err
2663
+}
2664
+
2665
+func GetLastDrugFlow(drug_id int64) (models.DrugFlow, error) {
2666
+
2667
+	flow := models.DrugFlow{}
2668
+	err := XTReadDB().Where("drug_id = ? and status =1  and ctime<=1667231999", drug_id).Last(&flow).Error
2669
+
2670
+	return flow, err
2671
+}
2672
+
2673
+func ModifyDrugFlowById(id int64, over_count int64) error {
2674
+
2675
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"over_count": over_count}).Error
2676
+	return err
2677
+}
2678
+
2679
+func GetDrugInventoryWarehouseInfoList(org_id int64, storehouse_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
2680
+
2681
+	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id = ? and is_check = 1 and org_id = ?", storehouse_id, org_id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
2682
+	return info, err
2683
+}

+ 61 - 9
service/stock_service.go Ver arquivo

4237
 		db = db.Where("x.org_id = ?", orgid)
4237
 		db = db.Where("x.org_id = ?", orgid)
4238
 	}
4238
 	}
4239
 
4239
 
4240
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4240
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4241
 
4241
 
4242
 	return out, err
4242
 	return out, err
4243
 }
4243
 }
4269
 
4269
 
4270
 func GetOrderStockFlow(id []string, orgid int64) (list []*models.VmStockFlow, err error) {
4270
 func GetOrderStockFlow(id []string, orgid int64) (list []*models.VmStockFlow, err error) {
4271
 
4271
 
4272
-	db := XTReadDB().Model(&list).Where("status = 1 and consumable_type = 7 and patient_id > 0")
4272
+	db := XTReadDB().Model(&list).Where("status = 1 and consumable_type = 7 and patient_id > 0 and count>0")
4273
 	if len(id) > 0 {
4273
 	if len(id) > 0 {
4274
 		db = db.Where("warehouse_out_id in (?)", id)
4274
 		db = db.Where("warehouse_out_id in (?)", id)
4275
 	}
4275
 	}
4855
 	if len(warehouse_out_id) > 0 {
4855
 	if len(warehouse_out_id) > 0 {
4856
 		db = db.Where("x.warehouse_out_id in(?)", warehouse_out_id)
4856
 		db = db.Where("x.warehouse_out_id in(?)", warehouse_out_id)
4857
 	}
4857
 	}
4858
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.price,x.retail_price,x.product_date,x.expire_date,x.warehouse_out_order_number,x.dealer,x.manufacturer,x.is_sys,x.number,x.batch_number,x.patient_id,x.ctime,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,b.min_price").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4858
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.price,x.retail_price,x.product_date,x.expire_date,x.warehouse_out_order_number,x.dealer,x.manufacturer,x.is_sys,x.number,x.batch_number,x.patient_id,x.ctime,x.consumable_type,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,b.min_price").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4859
 	return out, err
4859
 	return out, err
4860
 }
4860
 }
4861
 
4861
 
4862
+func GetDrugOutListFlow(warehouse_out_id []string, orgid int64) (info []*models.XtDrugWarehouseOutInfo, err error) {
4863
+
4864
+	db := XTReadDB().Model(&info).Where("status = 1")
4865
+	if len(warehouse_out_id) > 0 {
4866
+		db = db.Where("warehouse_out_id in(?)", warehouse_out_id)
4867
+	}
4868
+	if orgid > 0 {
4869
+		db = db.Where("org_id = ?", orgid)
4870
+	}
4871
+	err = db.Find(&info).Error
4872
+	return info, err
4873
+}
4874
+
4862
 func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehouseOutInfo, err error) {
4875
 func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehouseOutInfo, err error) {
4863
 
4876
 
4864
 	err = XTReadDB().Where("warehouse_out_id in(?)", warehouse_out_id).Find(&out).Error
4877
 	err = XTReadDB().Where("warehouse_out_id in(?)", warehouse_out_id).Find(&out).Error
5239
 		}
5252
 		}
5240
 
5253
 
5241
 	}
5254
 	}
5242
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Find(&drug_flow).Error
5255
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Preload("XtDrugWarehouseOutInfo", "status = 1").Find(&drug_flow).Error
5243
 	return drug_flow, total, err
5256
 	return drug_flow, total, err
5244
 }
5257
 }
5245
 
5258
 
7155
 
7168
 
7156
 func ModifyWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
7169
 func ModifyWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
7157
 
7170
 
7158
-	err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount}).Error
7171
+	err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount, "register_number": info.RegisterNumber}).Error
7159
 	return err
7172
 	return err
7160
 }
7173
 }
7161
 
7174
 
7483
 }
7496
 }
7484
 
7497
 
7485
 func UpdateCheckDrugOut(out models.DrugWarehouseOut, id int64) error {
7498
 func UpdateCheckDrugOut(out models.DrugWarehouseOut, id int64) error {
7486
-
7487
-	err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": out.IsCheck}).Error
7499
+	tx := XTWriteDB().Begin()
7500
+	err := tx.Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": out.IsCheck}).Error
7501
+	if err != nil {
7502
+		tx.Rollback()
7503
+		return err
7504
+	}
7488
 	err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7505
 	err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7506
+	if err != nil {
7507
+		tx.Rollback()
7508
+		return err
7509
+	}
7510
+	tx.Commit()
7489
 	return err
7511
 	return err
7490
 }
7512
 }
7491
 
7513
 
7577
 	tx.Commit()
7599
 	tx.Commit()
7578
 	return err
7600
 	return err
7579
 
7601
 
7580
-	err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7581
-	return err
7582
 }
7602
 }
7583
 
7603
 
7584
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
7604
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
7893
 	return detail, err
7913
 	return detail, err
7894
 }
7914
 }
7895
 
7915
 
7916
+func GetGoodDialysisOutInfoSix(orgid int64, patient_id int64, sys_record_time int64, good_id int64) (models.WarehouseOutInfo, error) {
7917
+
7918
+	detail := models.WarehouseOutInfo{}
7919
+	err := XTReadDB().Where("org_id =? and patient_id = ? and sys_record_time = ? and good_id = ? and status= 1", orgid, patient_id, sys_record_time, good_id).Find(&detail).Error
7920
+	return detail, err
7921
+}
7922
+
7923
+func GetGoodSumCount(storehouse_id int64, good_id int64, orgid int64) (models.XtGoodStockCount, error) {
7924
+
7925
+	stock := models.XtGoodStockCount{}
7926
+	err := XTReadDB().Where("storehouse_id = ? and good_id = ? and user_org_id = ? and status = 1", storehouse_id, good_id, orgid).Find(&stock).Error
7927
+	return stock, err
7928
+}
7929
+
7930
+func CreateGoodStockCount(stock models.XtGoodStockCount) error {
7931
+
7932
+	err := XTWriteDB().Create(&stock).Error
7933
+	return err
7934
+}
7935
+
7896
 func AddGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7936
 func AddGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7897
 
7937
 
7898
 	ut := XTWriteDB().Begin()
7938
 	ut := XTWriteDB().Begin()
7931
 	return err
7971
 	return err
7932
 }
7972
 }
7933
 
7973
 
7974
+func CreateDrugStock(stock models.XtDrugStockCount) error {
7975
+
7976
+	err := XTWriteDB().Create(&stock).Error
7977
+	return err
7978
+}
7979
+
7934
 func UpdateDrugCount(storehouse_id int64, user_org_id int64, drug_id int64, sum_in_count int64, flush_count int64) error {
7980
 func UpdateDrugCount(storehouse_id int64, user_org_id int64, drug_id int64, sum_in_count int64, flush_count int64) error {
7935
 
7981
 
7936
 	ut := XTWriteDB().Begin()
7982
 	ut := XTWriteDB().Begin()
8023
 	ut.Commit()
8069
 	ut.Commit()
8024
 	return err
8070
 	return err
8025
 }
8071
 }
8072
+
8073
+func GetInvetoryWarehouseInfoList(orgid int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
8074
+
8075
+	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id=? and is_check= 1 and org_id = ?", storehouse_id, orgid).Preload("GoodInfo", "status = 1").Find(&info).Error
8076
+	return info, err
8077
+}

+ 20 - 0
service/user_service.go Ver arquivo

48
 	return
48
 	return
49
 }
49
 }
50
 
50
 
51
+func GetAllDoctorAndNurseSix(orgId, appid int64) (doctors []AdminUserList, nurses []AdminUserList, err error) {
52
+
53
+	var users []AdminUserList
54
+	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("org_id=? and app_id =? and uar.user_type IN (2,3) and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&users).Error
55
+	if err != nil {
56
+		return
57
+	}
58
+	if len(users) == 0 {
59
+		return
60
+	}
61
+	for _, item := range users {
62
+		if item.UserType == 2 {
63
+			doctors = append(doctors, item)
64
+		} else {
65
+			nurses = append(nurses, item)
66
+		}
67
+	}
68
+	return
69
+}
70
+
51
 func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
71
 func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
52
 
72
 
53
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.org_id=? and uar.app_id =? and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
73
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.org_id=? and uar.app_id =? and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error

+ 149 - 80
service/warhouse_service.go Ver arquivo

143
 
143
 
144
 	if stock_number >= deliver_number {
144
 	if stock_number >= deliver_number {
145
 
145
 
146
+		var maxNumber int64 = 0
147
+		var minNumber int64 = 0
148
+		//var stock_max_number int64 = 0
149
+		//stock_max_number = warehouse.StockMaxNumber
150
+
151
+		maxNumber = deliver_number / drup.MinNumber
152
+		minNumber = deliver_number % drup.MinNumber
153
+
154
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
155
+			minNumber = maxNumber
156
+		}
157
+
158
+		if drup.MaxUnit != drup.MinUnit {
159
+			if warehouse.StockMaxNumber < maxNumber && warehouse.StockMinNumber < minNumber {
160
+				return errors.New("库存数量不足")
161
+			}
162
+		}
163
+
164
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
165
+
166
+		if warehouse.StockMaxNumber < 0 {
167
+			warehouse.StockMaxNumber = 0
168
+		}
169
+		if warehouse.StockMinNumber < 0 {
170
+			warehouse.StockMinNumber = 0
171
+		}
172
+
173
+		warehouse.Mtime = time.Now().Unix()
174
+
175
+		if warehouse.StockMinNumber < minNumber {
176
+
177
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
178
+			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
179
+		} else {
180
+			if minNumber > 0 {
181
+				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
182
+			}
183
+
184
+			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
185
+				if warehouse.StockMinNumber > 0 {
186
+					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
187
+				}
188
+
189
+			}
190
+
191
+		}
192
+
193
+		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
194
+			if (warehouse.StockMinNumber - deliver_number) > 0 {
195
+				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
196
+			}
197
+
198
+		}
199
+
200
+		if drup.MaxUnit != drup.MinUnit {
201
+			if warehouse.StockMaxNumber < 0 && warehouse.StockMinNumber < 0 {
202
+				return errors.New("库存数量不足")
203
+			}
204
+		}
205
+		if warehouse.StockMinNumber <= 0 {
206
+			warehouse.StockMinNumber = 0
207
+		}
208
+
209
+		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
210
+
211
+		if errThree != nil {
212
+			return errThree
213
+		}
214
+
215
+		//查询剩余库存
216
+		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
217
+		var sum_count int64
218
+		for _, its := range stockInfo {
219
+			if its.MaxUnit == drup.MaxUnit {
220
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
221
+			}
222
+			sum_count += its.StockMaxNumber + its.StockMinNumber
223
+		}
224
+
146
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
225
 		warehouseOutInfo := &models.DrugWarehouseOutInfo{
147
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
226
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
148
 			WarehouseOutId:          warehouseout.ID,
227
 			WarehouseOutId:          warehouseout.ID,
169
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
248
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
170
 			StorehouseId:            storeConfig.DrugStorehouseOut,
249
 			StorehouseId:            storeConfig.DrugStorehouseOut,
171
 			IsCheck:                 1,
250
 			IsCheck:                 1,
251
+			OverCount:               sum_count,
172
 		}
252
 		}
173
 
253
 
174
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
254
 		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
201
 			StorehouseId:            storeConfig.DrugStorehouseOut,
281
 			StorehouseId:            storeConfig.DrugStorehouseOut,
202
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
282
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
203
 			LastPrice:               warehouse.Price,
283
 			LastPrice:               warehouse.Price,
284
+			OverCount:               sum_count,
204
 		}
285
 		}
205
 
286
 
206
 		CreateDrugFlowOne(drugflow)
287
 		CreateDrugFlowOne(drugflow)
227
 			return errTwo
308
 			return errTwo
228
 		}
309
 		}
229
 
310
 
230
-		var maxNumber int64 = 0
231
-		var minNumber int64 = 0
232
-		//var stock_max_number int64 = 0
233
-		//stock_max_number = warehouse.StockMaxNumber
234
-
235
-		maxNumber = deliver_number / drup.MinNumber
236
-		minNumber = deliver_number % drup.MinNumber
237
-
238
-		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
239
-			minNumber = maxNumber
240
-		}
241
-
242
-		if drup.MaxUnit != drup.MinUnit {
243
-			if warehouse.StockMaxNumber < maxNumber && warehouse.StockMinNumber < minNumber {
244
-				return errors.New("库存数量不足")
245
-			}
246
-		}
247
-
248
-		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
249
-
250
-		if warehouse.StockMaxNumber < 0 {
251
-			warehouse.StockMaxNumber = 0
252
-		}
253
-		if warehouse.StockMinNumber < 0 {
254
-			warehouse.StockMinNumber = 0
255
-		}
256
-
257
-		warehouse.Mtime = time.Now().Unix()
258
-
259
-		if warehouse.StockMinNumber < minNumber {
260
-
261
-			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
262
-			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
263
-		} else {
264
-			if minNumber > 0 {
265
-				warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
266
-			}
267
-
268
-			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
269
-				if warehouse.StockMinNumber > 0 {
270
-					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
271
-				}
272
-
273
-			}
274
-
275
-		}
276
-
277
-		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
278
-			if (warehouse.StockMinNumber - deliver_number) > 0 {
279
-				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
280
-			}
281
-
282
-		}
283
-
284
-		if drup.MaxUnit != drup.MinUnit {
285
-			if warehouse.StockMaxNumber < 0 && warehouse.StockMinNumber < 0 {
286
-				return errors.New("库存数量不足")
287
-			}
288
-		}
289
-		if warehouse.StockMinNumber <= 0 {
290
-			warehouse.StockMinNumber = 0
291
-		}
292
-
293
-		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
294
-
295
-		if errThree != nil {
296
-			return errThree
311
+		var out_count int64
312
+		//查询出库数据
313
+		infoCountList, _ := FindDrugWarehouseOutInfoCount(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
314
+		for _, item := range infoCountList {
315
+			out_count += item.Count
297
 		}
316
 		}
317
+		//出库数量相加
318
+		AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
298
 
319
 
299
 		return nil
320
 		return nil
300
 	} else {
321
 	} else {
389
 			return errThree
410
 			return errThree
390
 		}
411
 		}
391
 
412
 
413
+		//查询剩余库存
414
+		stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
415
+		var sum_count int64
416
+		for _, its := range stockInfo {
417
+			if its.MaxUnit == drup.MaxUnit {
418
+				its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
419
+			}
420
+			sum_count += its.StockMaxNumber + its.StockMinNumber
421
+		}
422
+
423
+		var out_count int64
424
+
425
+		//查询出库数据
426
+		infoCountList, _ := FindDrugWarehouseOutInfoCount(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
427
+		for _, item := range infoCountList {
428
+			out_count += item.Count
429
+		}
430
+
392
 		drugflow := models.DrugFlow{
431
 		drugflow := models.DrugFlow{
393
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
432
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
394
 			WarehouseOutId:          warehouseout.ID,
433
 			WarehouseOutId:          warehouseout.ID,
415
 			StorehouseId:            storeConfig.DrugStorehouseOut,
454
 			StorehouseId:            storeConfig.DrugStorehouseOut,
416
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
455
 			WarehouseOutDetailId:    lastDrugOutInfo.ID,
417
 			LastPrice:               warehouse.Price,
456
 			LastPrice:               warehouse.Price,
457
+			OverCount:               sum_count,
418
 		}
458
 		}
419
 
459
 
420
 		CreateDrugFlowOne(drugflow)
460
 		CreateDrugFlowOne(drugflow)
461
+		//出库数量相加
462
+		AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
421
 
463
 
422
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
464
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
423
 		prescribingNumber_two_temp := deliver_number - stock_number
465
 		prescribingNumber_two_temp := deliver_number - stock_number
1270
 			}
1312
 			}
1271
 		}
1313
 		}
1272
 
1314
 
1273
-		fmt.Println("goods999923932923923923223wode", goods)
1274
 		for _, item := range goods {
1315
 		for _, item := range goods {
1275
 			var newCount int64 = 0
1316
 			var newCount int64 = 0
1276
 			for _, it := range goodOne {
1317
 			for _, it := range goodOne {
1287
 				out_count += item.Count
1328
 				out_count += item.Count
1288
 			}
1329
 			}
1289
 			cha_count = item.Count - out_count
1330
 			cha_count = item.Count - out_count
1290
-			fmt.Println("item.Count", item.Count)
1291
-			fmt.Println("item.Count", out_count)
1292
-			fmt.Println("cha_count2323223232323223", cha_count)
1331
+			//fmt.Println("item.Count", item.Count)
1332
+			//fmt.Println("item.Count", out_count)
1333
+			//fmt.Println("cha_count2323223232323223", cha_count)
1293
 			cha_count_two = out_count - item.Count
1334
 			cha_count_two = out_count - item.Count
1294
 
1335
 
1295
 			prepare := models.DialysisBeforePrepare{
1336
 			prepare := models.DialysisBeforePrepare{
5250
 			BatchNumberCount:        warehouse.StockCount - goods.Count,
5291
 			BatchNumberCount:        warehouse.StockCount - goods.Count,
5251
 			IsCheck:                 1,
5292
 			IsCheck:                 1,
5252
 			OverCount:               sum_count,
5293
 			OverCount:               sum_count,
5294
+			RegisterNumber:          goods.RegisterNumber,
5253
 		}
5295
 		}
5254
 		//创建出库流水
5296
 		//创建出库流水
5255
 		errflow := CreateStockFlowOne(stockFlow)
5297
 		errflow := CreateStockFlowOne(stockFlow)
5397
 			BatchNumberCount:        0,
5439
 			BatchNumberCount:        0,
5398
 			IsCheck:                 1,
5440
 			IsCheck:                 1,
5399
 			OverCount:               sum_count,
5441
 			OverCount:               sum_count,
5442
+			RegisterNumber:          goods.RegisterNumber,
5400
 		}
5443
 		}
5401
 		//创建出库流水
5444
 		//创建出库流水
5402
 		errflow := CreateStockFlowOne(stockFlow)
5445
 		errflow := CreateStockFlowOne(stockFlow)
5464
 
5507
 
5465
 // 药品手动出库 递归方式
5508
 // 药品手动出库 递归方式
5466
 func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DrugWarehouseOutInfo) (err error) {
5509
 func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DrugWarehouseOutInfo) (err error) {
5467
-	//开事务
5510
+
5511
+	fmt.Println("出库数量", prescribingNumber)
5512
+
5468
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
5513
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
5469
 	var deliver_number int64 = 0
5514
 	var deliver_number int64 = 0
5470
 	var stock_number int64 = 0
5515
 	var stock_number int64 = 0
5487
 		var stockMin int64
5532
 		var stockMin int64
5488
 		stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
5533
 		stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
5489
 		stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
5534
 		stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
5535
+		fmt.Println("stockmax", stockMax)
5536
+		fmt.Println("stockMin", stockMin)
5490
 		ChangeMaxNumber(lastWarehouse.ID, stockMax)
5537
 		ChangeMaxNumber(lastWarehouse.ID, stockMax)
5491
 		UpdateMinNumber(lastWarehouse.ID, stockMin)
5538
 		UpdateMinNumber(lastWarehouse.ID, stockMin)
5492
 	}
5539
 	}
5499
 	}
5546
 	}
5500
 
5547
 
5501
 	// 将该批次的剩余库存数量转换为拆零数量
5548
 	// 将该批次的剩余库存数量转换为拆零数量
5549
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
5550
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
5551
+	}
5552
+	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
5553
+		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
5554
+	}
5555
+	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
5556
+		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
5557
+	}
5502
 
5558
 
5503
-	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
5504
-
5559
+	fmt.Println("stock_number", stock_number)
5560
+	fmt.Println("deliver_number", deliver_number)
5505
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
5561
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
5506
 	if stock_number >= deliver_number {
5562
 	if stock_number >= deliver_number {
5507
 
5563
 
5523
 			}
5579
 			}
5524
 		}
5580
 		}
5525
 
5581
 
5526
-		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
5582
+		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
5583
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
5584
+		}
5585
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
5586
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
5587
+		}
5588
+		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
5589
+			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
5590
+		}
5527
 
5591
 
5528
 		if warehouse.StockMaxNumber < 0 {
5592
 		if warehouse.StockMaxNumber < 0 {
5529
 			warehouse.StockMaxNumber = 0
5593
 			warehouse.StockMaxNumber = 0
5538
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
5602
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
5539
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
5603
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
5540
 		} else {
5604
 		} else {
5605
+			fmt.Println("maxNumber23323323332322323w9", maxNumber)
5606
+			fmt.Println("maxNumber23323323332322323w9", minNumber)
5541
 			if minNumber > 0 {
5607
 			if minNumber > 0 {
5542
 				if minNumber == 1 && maxNumber == 1 && drup.MaxUnit != drup.MinUnit {
5608
 				if minNumber == 1 && maxNumber == 1 && drup.MaxUnit != drup.MinUnit {
5543
 					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5609
 					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5544
 				} else {
5610
 				} else {
5545
-					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
5611
+					if (warehouse.StockMinNumber - minNumber) >= 0 {
5612
+						warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
5613
+					}
5614
+
5546
 				}
5615
 				}
5547
 			}
5616
 			}
5548
 
5617
 
5549
 			if minNumber == 0 && maxNumber != 1 {
5618
 			if minNumber == 0 && maxNumber != 1 {
5550
 				if warehouse.StockMinNumber > 0 {
5619
 				if warehouse.StockMinNumber > 0 {
5551
-					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5620
+					if (warehouse.StockMinNumber - deliver_number) >= 0 {
5621
+						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5622
+					}
5552
 				}
5623
 				}
5553
-
5554
 			}
5624
 			}
5555
-
5556
 		}
5625
 		}
5557
 
5626
 
5558
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
5627
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
5559
-			if (warehouse.StockMinNumber - deliver_number) > 0 {
5628
+			if (warehouse.StockMinNumber - deliver_number) >= 0 {
5560
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5629
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5561
 			}
5630
 			}
5562
 
5631