瀏覽代碼

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

csx 2 年之前
父節點
當前提交
bbedb68e91
共有 39 個文件被更改,包括 8858 次插入943 次删除
  1. 1 1
      conf/app.conf
  2. 200 4
      controllers/dialysis_api_controller.go
  3. 243 9
      controllers/drug_stock_api_contorller.go
  4. 55 3
      controllers/gobal_config_api_controller.go
  5. 323 172
      controllers/his_api_controller.go
  6. 13 0
      controllers/mobile_api_controllers/check_weight_api_controller.go
  7. 740 110
      controllers/mobile_api_controllers/dialysis_api_controller.go
  8. 3 1
      controllers/mobile_api_controllers/mobile_api_router_register.go
  9. 82 0
      controllers/patient_api_controller.go
  10. 1 0
      controllers/pharmacy_controller.go
  11. 1 1
      controllers/schedule_api_controller.go
  12. 220 3
      controllers/secondary_order_api_contorller.go
  13. 639 40
      controllers/self_drug_api_congtroller.go
  14. 0 4
      controllers/sign_weigh_api_controller.go
  15. 425 21
      controllers/stock_in_api_controller.go
  16. 76 5
      controllers/supply_order_api_contorller.go
  17. 2 0
      models/dialysis.go
  18. 102 0
      models/drug.go
  19. 32 0
      models/drug_stock.go
  20. 76 38
      models/good_models.go
  21. 179 0
      models/new_stock_models.go
  22. 1 0
      models/patient_models.go
  23. 53 0
      models/schedule_models.go
  24. 76 0
      models/self_drug_models.go
  25. 256 135
      models/stock_models.go
  26. 13 0
      service/admin_service.go
  27. 13 1
      service/dialysis_service.go
  28. 130 0
      service/dialysis_solution_service.go
  29. 47 4
      service/gobal_config_service.go
  30. 25 10
      service/manage_center_service.go
  31. 18 7
      service/mobile_dialysis_service.go
  32. 340 0
      service/new_stock_service.go
  33. 2013 0
      service/new_warehouse_service.go
  34. 32 1
      service/patient_service.go
  35. 1 0
      service/pharmacy_service.go
  36. 1 1
      service/secondary_service.go
  37. 1169 80
      service/self_drug_service.go
  38. 430 71
      service/stock_service.go
  39. 827 221
      service/warhouse_service.go

+ 1 - 1
conf/app.conf 查看文件

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode =dev
4 4
 #dev/prod
5 5
 

+ 200 - 4
controllers/dialysis_api_controller.go 查看文件

@@ -73,6 +73,14 @@ func DialysisApiRegistRouters() {
73 73
 
74 74
 	beego.Router("/api/getinitprintdateone", &DialysisApiController{}, "Get:GetInitPrintDataOne")
75 75
 
76
+	//新接口
77
+	beego.Router("/api/patient/getpatientdialysissolutiongrouplist", &DialysisApiController{}, "Get:GetPatientDialysisSolutionGroupList")
78
+
79
+	beego.Router("/api/patient/getdialysisadvicetemplatelist", &DialysisApiController{}, "Get:GetDialysisAdviceTemplateList")
80
+
81
+	beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
82
+
83
+	beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
76 84
 }
77 85
 
78 86
 func (c *DialysisApiController) GetQueueCall() {
@@ -393,6 +401,17 @@ func (c *DialysisApiController) PostPrescription() {
393 401
 		}
394 402
 
395 403
 		prescription.Creater = adminUserInfo.AdminUser.Id
404
+
405
+		//针对河间咸得
406
+		if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
407
+
408
+			if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
409
+
410
+				prescription.DisplaceLiquiPart = 0
411
+				prescription.DisplaceLiquiValue = 0
412
+			}
413
+		}
414
+
396 415
 		err := service.AddSigleRecord(&prescription)
397 416
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
398 417
 		redis := service.RedisClient()
@@ -874,8 +893,36 @@ func (c *DialysisApiController) PostSoulution() {
874 893
 		OxygenFlow:                 oxygen_flow,
875 894
 		OxygenTime:                 oxygen_time,
876 895
 		PreImpulse:                 preImpules,
896
+		SolutionStatus:             1,
897
+	}
898
+
899
+	//针对河间咸得
900
+	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
901
+
902
+		if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
903
+
904
+			prescription.DisplaceLiquiPart = 0
905
+			prescription.DisplaceLiquiValue = 0
906
+		}
877 907
 	}
908
+
909
+	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
910
+
911
+		if solution.ModeId != 2 && solution.ModeId != 5 && solution.ModeId != 12 {
912
+
913
+			solution.DisplaceLiquiPart = 0
914
+			solution.DisplaceLiquiValue = 0
915
+		}
916
+	}
917
+
878 918
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
919
+
920
+	//获取最新1条
921
+	dialysisSolution, _ := service.GetLastPatientDialysisSolution(patient, adminUserInfo.CurrentOrgId)
922
+
923
+	//更新状态
924
+	service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
925
+
879 926
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
880 927
 	redis := service.RedisClient()
881 928
 
@@ -1413,10 +1460,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1413 1460
 	blood_access_noise, _ := c.GetInt64("blood_access_noise", 0)
1414 1461
 	internal_fistula_other := c.GetString("internal_fistula_other")
1415 1462
 	blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
1416
-
1417
-	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
1418 1463
 	breathing_rate := c.GetString("breathing_rate")
1419
-
1420 1464
 	is_infect, _ := c.GetInt64("is_infect", 0)
1421 1465
 	exposed, _ := c.GetFloat("exposed", 0)
1422 1466
 	skin := c.GetString("skin")
@@ -2394,7 +2438,6 @@ func (c *DialysisApiController) CreateMonitor() {
2394 2438
 	operate_time, _ := c.GetInt64("operate_time", 0)
2395 2439
 	// monitoring_time := c.GetString("monitoring_time")
2396 2440
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
2397
-	//breathing_rated, _ := c.GetFloat("breathing_rated", 0)
2398 2441
 	breathing_rated := c.GetString("breathing_rated")
2399 2442
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
2400 2443
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
@@ -4179,3 +4222,156 @@ func (c *DialysisApiController) GetInitPrintDataOne() {
4179 4222
 		return
4180 4223
 	}
4181 4224
 }
4225
+
4226
+//新接口
4227
+func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4228
+
4229
+	keyword := this.GetString("keywords")
4230
+
4231
+	limit, _ := this.GetInt64("limit")
4232
+
4233
+	page, _ := this.GetInt64("page")
4234
+
4235
+	partition_id, _ := this.GetInt64("partition_id")
4236
+
4237
+	schedule_type, _ := this.GetInt64("schedule_type")
4238
+
4239
+	start_time := this.GetString("schedule_date")
4240
+	timeLayout := "2006-01-02"
4241
+	loc, _ := time.LoadLocation("Local")
4242
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4243
+
4244
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4245
+
4246
+	list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4247
+
4248
+	if err == nil {
4249
+		this.ServeSuccessJSON(map[string]interface{}{
4250
+			"list":  list,
4251
+			"total": total,
4252
+		})
4253
+		return
4254
+
4255
+	} else {
4256
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4257
+		return
4258
+	}
4259
+}
4260
+
4261
+func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4262
+
4263
+	keyword := this.GetString("keywords")
4264
+
4265
+	limit, _ := this.GetInt64("limit")
4266
+
4267
+	page, _ := this.GetInt64("page")
4268
+
4269
+	partition_id, _ := this.GetInt64("partition_id")
4270
+
4271
+	schedule_type, _ := this.GetInt64("schedule_type")
4272
+
4273
+	start_time := this.GetString("schedule_date")
4274
+	timeLayout := "2006-01-02"
4275
+	loc, _ := time.LoadLocation("Local")
4276
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4277
+
4278
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4279
+
4280
+	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4281
+
4282
+	//获取长期医嘱
4283
+	adviceList, _ := service.GetAllLongAdviceList(orgId)
4284
+
4285
+	//获取医嘱模版
4286
+	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4287
+	if err == nil {
4288
+		this.ServeSuccessJSON(map[string]interface{}{
4289
+			"list":         list,
4290
+			"total":        total,
4291
+			"adviceList":   adviceList,
4292
+			"templateList": templateList,
4293
+		})
4294
+		return
4295
+
4296
+	} else {
4297
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4298
+		return
4299
+	}
4300
+}
4301
+
4302
+func (this *DialysisApiController) SaveDialysisSetting() {
4303
+
4304
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4305
+	device_number_set, _ := this.GetInt64("device_number_set")
4306
+	device_type_set, _ := this.GetInt64("device_type_set")
4307
+	name_set, _ := this.GetInt64("name_set")
4308
+	admission_number_set, _ := this.GetInt64("admission_number_set")
4309
+	dialysis_no_set, _ := this.GetInt64("dialysis_no_set")
4310
+	weight_befor_set, _ := this.GetInt64("weight_befor_set")
4311
+	dry_weight_set, _ := this.GetInt64("dry_weight_set")
4312
+	blood_pressure_set, _ := this.GetInt64("blood_pressure_set")
4313
+	ultrafiltration_volume_set, _ := this.GetInt64("ultrafiltration_volume_set")
4314
+	internal_fistula_set, _ := this.GetInt64("internal_fistula_set")
4315
+	blood_flow_volume_set, _ := this.GetInt64("blood_flow_volume_set")
4316
+	anticoagulant_set, _ := this.GetInt64("anticoagulant_set")
4317
+	sealing_fluid_dispose_set, _ := this.GetInt64("sealing_fluid_dispose_set")
4318
+	mode_id_set, _ := this.GetInt64("mode_id_set")
4319
+	dialysis_time_set, _ := this.GetInt64("dialysis_time_set")
4320
+	dialysis_dialyszers_set, _ := this.GetInt64("dialysis_dialyszers_set")
4321
+	dialysis_irrigation_set, _ := this.GetInt64("dialysis_irrigation_set")
4322
+	gaijiliang_set, _ := this.GetInt64("gaijiliang_set")
4323
+	kalium_set, _ := this.GetInt64("kalium_set")
4324
+	displace_liqui_value_set, _ := this.GetInt64("displace_liqui_value_set")
4325
+	bicarbonate_set, _ := this.GetInt64("bicarbonate_set")
4326
+	glucose_set, _ := this.GetInt64("glucose_set")
4327
+
4328
+	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(),
4355
+	}
4356
+	err := service.SaveDialysisSetting(dialysisSetting)
4357
+	if err == nil {
4358
+		this.ServeSuccessJSON(map[string]interface{}{
4359
+			"dialysisSetting": dialysisSetting,
4360
+		})
4361
+		return
4362
+
4363
+	} else {
4364
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4365
+		return
4366
+	}
4367
+}
4368
+
4369
+func (this *DialysisApiController) GetDialysisSetting() {
4370
+
4371
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4372
+	dialysisSett, _ := service.GetDialysisSetting(orgId)
4373
+	this.ServeSuccessJSON(map[string]interface{}{
4374
+		"dialysisSett": dialysisSett,
4375
+	})
4376
+	return
4377
+}

+ 243 - 9
controllers/drug_stock_api_contorller.go 查看文件

@@ -8,6 +8,7 @@ import (
8 8
 	"encoding/json"
9 9
 	"fmt"
10 10
 	"github.com/astaxie/beego"
11
+	"github.com/jinzhu/gorm"
11 12
 	"reflect"
12 13
 	"strconv"
13 14
 	"strings"
@@ -3615,6 +3616,39 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3615 3616
 			}
3616 3617
 			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3617 3618
 
3619
+			drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3620
+			var total_count int64 // 入库总数量
3621
+			var over_count int64  //剩余库存
3622
+			for _, it := range drugInfolist {
3623
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3624
+				if it.MaxUnit == baseDrug.MaxUnit {
3625
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3626
+				}
3627
+				total_count += it.WarehousingCount
3628
+				over_count += it.StockMaxNumber*baseDrug.MinNumber + it.StockMinNumber
3629
+			}
3630
+			//查询该仓库是否有默认数据
3631
+			_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3632
+			if errcode == gorm.ErrRecordNotFound {
3633
+				drugStock := models.XtDrugStockCount{
3634
+					UserOrgId:      item.OrgId,
3635
+					StorehouseId:   item.StorehouseId,
3636
+					SumInCount:     total_count,
3637
+					SumOutCount:    0,
3638
+					SumCancelCount: 0,
3639
+					DrugId:         item.DrugId,
3640
+					Ctime:          time.Now().Unix(),
3641
+					Mtime:          0,
3642
+					Status:         1,
3643
+					FlushCount:     over_count,
3644
+					SumActOutCount: 0,
3645
+				}
3646
+				service.CreateDrugStockSum(drugStock)
3647
+
3648
+			} else if errcode == nil {
3649
+				service.UpdateDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
3650
+			}
3651
+
3618 3652
 		}
3619 3653
 
3620 3654
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -3675,6 +3709,25 @@ func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
3675 3709
 			}
3676 3710
 		}
3677 3711
 		service.UpdateBaseDrugSumInfo(sum_count, item.DrugId, item.OrgId, sum_in_count)
3712
+
3713
+		var total_count int64
3714
+		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3715
+			total_count = item.WarehousingCount * medical.MinNumber
3716
+		}
3717
+		if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3718
+			total_count = item.WarehousingCount
3719
+		}
3720
+		if item.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
3721
+			total_count = item.WarehousingCount * medical.MinNumber
3722
+		}
3723
+		drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3724
+		var over_count int64 //剩余库存
3725
+		for _, it := range drugInfolist {
3726
+			over_count += it.StockMaxNumber*medical.MinNumber + it.StockMinNumber
3727
+		}
3728
+		//扣减库存
3729
+		service.ReduceDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
3730
+
3678 3731
 	}
3679 3732
 	//更新审核
3680 3733
 	err := service.ReturnCheckWarehouseingInfo(warehousing_id, orgId)
@@ -3710,12 +3763,24 @@ func (c *StockDrugApiController) CheckDrugOut() {
3710 3763
 			total_count += item.StockMaxNumber + item.StockMinNumber
3711 3764
 		}
3712 3765
 
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
+		//出库数量累加
3713 3772
 		if it.CountUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
3714
-			it.Count = it.Count * drup.MinNumber
3773
+			out_count = it.Count * drup.MinNumber
3715 3774
 		}
3716
-		out_count += it.Count
3717
-		fmt.Println("出库数量23232323232我", out_count)
3718
-		fmt.Println("总库存", total_count)
3775
+
3776
+		if it.CountUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
3777
+			out_count = it.Count
3778
+		}
3779
+
3780
+		if it.CountUnit == drup.MinUnit && drup.MaxUnit == drup.MinUnit {
3781
+			out_count = it.Count
3782
+		}
3783
+
3719 3784
 		if out_count > total_count {
3720 3785
 			c.ServeSuccessJSON(map[string]interface{}{
3721 3786
 				"warehousingOutInfoList": warehousingOutInfoList,
@@ -3742,8 +3807,35 @@ func (c *StockDrugApiController) CheckDrugOut() {
3742 3807
 		var sum_count int64
3743 3808
 		for _, its := range stockInfo {
3744 3809
 			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3810
+
3745 3811
 		}
3746 3812
 		service.UpdateBaseDrugSumTwo(it.DrugId, sum_count, it.OrgId)
3813
+
3814
+		////出库数量累加
3815
+		var out_count_one int64
3816
+		if it.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3817
+			out_count_one = it.Count * medical.MinNumber
3818
+		}
3819
+
3820
+		if it.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3821
+			out_count_one = it.Count
3822
+		}
3823
+
3824
+		if it.CountUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
3825
+			out_count_one = it.Count
3826
+		}
3827
+
3828
+		fmt.Println("out_count23233232323woede", out_count_one)
3829
+		//增加出库数量
3830
+		service.AddDrugCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, out_count_one)
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
3837
+		}
3838
+		service.UpdateDrugStockCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, over_count)
3747 3839
 	}
3748 3840
 
3749 3841
 	out := models.DrugWarehouseOut{
@@ -3781,6 +3873,7 @@ func (c *StockDrugApiController) ToReturnCheck() {
3781 3873
 		IsCheck: 2,
3782 3874
 	}
3783 3875
 	service.UpdateCheckDrugOutInfoList(outInfo, warehouse_out_id)
3876
+	creater := c.GetAdminUserInfo().AdminUser.Id
3784 3877
 
3785 3878
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3786 3879
 	list, _ := service.GetDrugWarehouseOutListById(warehouse_out_id, orgId)
@@ -3790,14 +3883,51 @@ func (c *StockDrugApiController) ToReturnCheck() {
3790 3883
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
3791 3884
 		if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3792 3885
 			service.UpdateDrugMaxNumber(item.Count, item.WarehouseInfoId)
3886
+			var sum_out_count int64
3887
+			sum_out_count = item.Count * medical.MinNumber
3888
+			service.ModifyReduceDrugInformation(item.DrugId, sum_out_count, item.OrgId)
3889
+			drugInfoList, _ := service.FindDrugWarehouseInfoList(item.DrugId, item.OrgId)
3890
+			var drug_max_number int64
3891
+			var drug_min_number int64
3892
+			for _, item := range drugInfoList {
3893
+				drug_max_number += item.StockMaxNumber
3894
+				drug_min_number += item.StockMinNumber
3895
+			}
3896
+			drugFlushInfo := models.XtDrugWarehouseFlushInfo{
3897
+				DrugMaxNumber:           drug_max_number,
3898
+				UserOrgId:               item.OrgId,
3899
+				WarehouseOutId:          item.ID,
3900
+				Type:                    2,
3901
+				SystemTime:              item.SysRecordTime,
3902
+				PatientId:               0,
3903
+				Ctime:                   time.Now().Unix(),
3904
+				Mtime:                   0,
3905
+				BatchNumberId:           item.WarehouseInfoId,
3906
+				DrugId:                  item.DrugId,
3907
+				Count:                   item.Count,
3908
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
3909
+				Creater:                 creater,
3910
+				DrugMinNumber:           drug_min_number,
3911
+				Unit:                    item.CountUnit,
3912
+				Status:                  1,
3913
+			}
3914
+			service.CreatedDrugFlushInfo(drugFlushInfo)
3793 3915
 			service.DeleteDrugOutFlow(item.ID, item.OrgId)
3794 3916
 		}
3795 3917
 		if item.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3796 3918
 			service.UpdateDrugMaxNumber(item.Count, item.WarehouseInfoId)
3919
+			var sum_out_count int64
3920
+			sum_out_count = item.Count * medical.MinNumber
3921
+			service.ModifyReduceDrugInformation(item.DrugId, sum_out_count, item.OrgId)
3922
+
3797 3923
 			service.DeleteDrugOutFlow(item.ID, item.OrgId)
3798 3924
 		}
3799 3925
 		if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3800 3926
 			service.UpdateDrugMinNumber(item.Count, item.WarehouseInfoId)
3927
+			var sum_out_count int64
3928
+			sum_out_count = item.Count
3929
+			service.ModifyReduceDrugInformation(item.DrugId, sum_out_count, item.OrgId)
3930
+
3801 3931
 			service.DeleteDrugOutFlow(item.ID, item.OrgId)
3802 3932
 		}
3803 3933
 
@@ -3807,6 +3937,31 @@ func (c *StockDrugApiController) ToReturnCheck() {
3807 3937
 			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3808 3938
 		}
3809 3939
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
3940
+
3941
+		//出库数量累加
3942
+		var out_count int64
3943
+		if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3944
+			out_count = item.Count * medical.MinNumber
3945
+		}
3946
+
3947
+		if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3948
+			out_count = item.Count
3949
+		}
3950
+
3951
+		if item.CountUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
3952
+			out_count = item.Count
3953
+		}
3954
+		//增加出库数量
3955
+		service.ReduceDrugCount(item.DrugId, item.OrgId, storeHouseConfig.DrugStorehouseOut, out_count)
3956
+
3957
+		//查询该药品剩余库存
3958
+		infolist, _ := service.FindDrugWarehouseInfoFlushCountByStorehouse(item.DrugId, item.OrgId, storeHouseConfig.DrugStorehouseOut)
3959
+		var over_count int64
3960
+		for _, its := range infolist {
3961
+			over_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3962
+		}
3963
+		service.UpdateDrugStockCount(item.DrugId, item.OrgId, storeHouseConfig.DrugStorehouseOut, over_count)
3964
+
3810 3965
 	}
3811 3966
 	c.ServeSuccessJSON(map[string]interface{}{
3812 3967
 		"out": out,
@@ -3871,6 +4026,7 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3871 4026
 			})
3872 4027
 			return
3873 4028
 		}
4029
+
3874 4030
 	}
3875 4031
 	for _, its := range list {
3876 4032
 		for _, item := range manufacturerList {
@@ -3887,7 +4043,7 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3887 4043
 		//查询该批次的退库数量
3888 4044
 		drugFlow := models.DrugFlow{
3889 4045
 			ID:                        0,
3890
-			WarehousingId:             0,
4046
+			WarehousingId:             its.BatchNumberId,
3891 4047
 			DrugId:                    its.DrugId,
3892 4048
 			Number:                    its.Number,
3893 4049
 			BatchNumber:               "",
@@ -3911,7 +4067,7 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3911 4067
 			Ctime:                     time.Now().Unix(),
3912 4068
 			Mtime:                     0,
3913 4069
 			Price:                     its.Price,
3914
-			WarehousingDetailId:       0,
4070
+			WarehousingDetailId:       its.BatchNumberId,
3915 4071
 			WarehouseOutDetailId:      0,
3916 4072
 			CancelOutDetailId:         its.ID,
3917 4073
 			ExpireDate:                its.ExpiryDate,
@@ -3934,6 +4090,31 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3934 4090
 			PharmacyId:                0,
3935 4091
 		}
3936 4092
 		service.CreateDrugFlowOne(drugFlow)
4093
+
4094
+		medical, _ := service.GetBaseDrugMedical(its.DrugId)
4095
+		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4096
+			var sum_cancel_count int64
4097
+			sum_cancel_count += its.Count * medical.MinNumber
4098
+			//退库数量增加
4099
+			//service.ModifyAddCancelAddInfomation(its.DrugId,sum_cancel_count,its.OrgId,its.StorehouseId)
4100
+			//出库数量减少
4101
+			service.ModifyAddDrugOutReduceInfomation(its.DrugId, sum_cancel_count, its.OrgId, its.StorehouseId)
4102
+		}
4103
+
4104
+		if its.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4105
+			//退库数量增加
4106
+			//service.ModifyAddCancelAddInfomation(its.DrugId,its.Count,its.OrgId,its.StorehouseId)
4107
+			//出库数量减少
4108
+			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4109
+		}
4110
+
4111
+		if its.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4112
+			//退库数量增加
4113
+			//service.ModifyAddCancelAddInfomation(its.DrugId,its.Count,its.OrgId,its.StorehouseId)
4114
+			//出库数量减少
4115
+			service.ModifyAddDrugOutReduceInfomation(its.DrugId, its.Count, its.OrgId, its.StorehouseId)
4116
+		}
4117
+
3937 4118
 	}
3938 4119
 	for _, its := range cancelList {
3939 4120
 		medical, _ := service.GetBaseDrugMedical(its.DrugId)
@@ -3941,6 +4122,7 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3941 4122
 		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3942 4123
 
3943 4124
 			service.ModifyDrugWarehouseInfoStockMaxNumber(its.Count, its.DrugId, its.OrgId, its.BatchNumberId)
4125
+
3944 4126
 		}
3945 4127
 		if its.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3946 4128
 
@@ -3949,6 +4131,7 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3949 4131
 		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3950 4132
 
3951 4133
 			service.ModifyDrugWarehouseInfoStockMaxNumber(its.Count, its.DrugId, its.OrgId, its.BatchNumberId)
4134
+
3952 4135
 		}
3953 4136
 
3954 4137
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, its.OrgId, its.DrugId)
@@ -3957,9 +4140,27 @@ func (c *StockDrugApiController) CheckCancelDrugStock() {
3957 4140
 			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3958 4141
 		}
3959 4142
 		service.UpdateBaseDrugSumTwo(its.DrugId, sum_count, its.OrgId)
3960
-	}
3961
-	service.ModifyCancelStock(cancelstock_id, cancelStock, orgId)
3962 4143
 
4144
+		var cancel_count int64
4145
+		if its.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4146
+			cancel_count = its.Count * medical.MinNumber
4147
+		}
4148
+		if its.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4149
+			cancel_count = its.Count
4150
+		}
4151
+
4152
+		if its.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4153
+			cancel_count = its.Count * medical.MinNumber
4154
+		}
4155
+		cancelInfo, _ := service.GetDrugAllStockInfo(its.StorehouseId, its.OrgId, its.DrugId)
4156
+		var over_count int64
4157
+		for _, items := range cancelInfo {
4158
+			over_count += items.StockMaxNumber*medical.MinNumber + items.StockMinNumber
4159
+		}
4160
+		service.AddCancelSumCount(its.StorehouseId, its.DrugId, its.OrgId, cancel_count, over_count)
4161
+
4162
+		service.ModifyCancelStock(cancelstock_id, cancelStock, orgId)
4163
+	}
3963 4164
 	//新增库存
3964 4165
 	c.ServeSuccessJSON(map[string]interface{}{
3965 4166
 		"drug_name":  "",
@@ -3990,15 +4191,29 @@ func (c *StockDrugApiController) ReturnDrugCancelStock() {
3990 4191
 		//扣减库存
3991 4192
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
3992 4193
 		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3993
-
4194
+			var sum_cancel_count int64
4195
+			sum_cancel_count += item.Count * medical.MinNumber
3994 4196
 			service.ModifyDrugMaxNumberWarehouseInfo(item.BatchNumberId, item.Count, item.OrgId)
4197
+			//退库数量减少
4198
+			//service.ModifyDrugCancelWarehouseInfo(item.DrugId,sum_cancel_count,item.OrgId,item.StorehouseId)
4199
+			//出库数量增加
4200
+			service.ModifyAddDrugOutAddInfomation(item.DrugId, sum_cancel_count, item.OrgId, item.StorehouseId)
4201
+
3995 4202
 		}
3996 4203
 		if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3997 4204
 
3998 4205
 			service.ModifyDrugMinNumberWarehouseInfo(item.BatchNumberId, item.Count, item.OrgId)
4206
+			//退库数量减少
4207
+			//service.ModifyDrugCancelWarehouseInfo(item.DrugId,item.Count,item.OrgId,item.StorehouseId)
4208
+			//出库数量增加
4209
+			service.ModifyAddDrugOutAddInfomation(item.DrugId, item.Count, item.OrgId, item.StorehouseId)
3999 4210
 		}
4000 4211
 		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
4001 4212
 			service.ModifyDrugMaxNumberWarehouseInfo(item.BatchNumberId, item.Count, item.OrgId)
4213
+			//退库数量减少
4214
+			//service.ModifyDrugCancelWarehouseInfo(item.DrugId,item.Count,item.OrgId,item.StorehouseId)
4215
+			//出库数量增加
4216
+			service.ModifyAddDrugOutAddInfomation(item.DrugId, item.Count, item.OrgId, item.StorehouseId)
4002 4217
 		}
4003 4218
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
4004 4219
 		var sum_count int64
@@ -4006,6 +4221,25 @@ func (c *StockDrugApiController) ReturnDrugCancelStock() {
4006 4221
 			sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
4007 4222
 		}
4008 4223
 		service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.OrgId)
4224
+
4225
+		var cancel_count int64
4226
+		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4227
+			cancel_count = item.Count * medical.MinNumber
4228
+		}
4229
+		if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4230
+			cancel_count = item.Count
4231
+		}
4232
+
4233
+		if item.MaxUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4234
+			cancel_count = item.Count * medical.MinNumber
4235
+		}
4236
+		cancelInfo, _ := service.GetDrugAllStockInfo(item.StorehouseId, item.OrgId, item.DrugId)
4237
+		var over_count int64
4238
+		for _, items := range cancelInfo {
4239
+			over_count += items.StockMaxNumber*medical.MinNumber + items.StockMinNumber
4240
+		}
4241
+		//退库数量减少,更新剩余库存
4242
+		service.ReduceCancelSumCount(item.StorehouseId, item.DrugId, item.OrgId, cancel_count, over_count)
4009 4243
 	}
4010 4244
 	if err == nil {
4011 4245
 		c.ServeSuccessJSON(map[string]interface{}{

+ 55 - 3
controllers/gobal_config_api_controller.go 查看文件

@@ -2080,7 +2080,7 @@ func (c *GobalConfigApiController) GetDrugOutStockFlow() {
2080 2080
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2081 2081
 
2082 2082
 	outList, total, err := service.GetDrugStockOutFlow(drug_id, startTime, endTime, page, limit, orgId, stock_type)
2083
-	fmt.Println("outList22233333333333333333333", outList)
2083
+
2084 2084
 	if err != nil {
2085 2085
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2086 2086
 		return
@@ -2098,7 +2098,52 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
2098 2098
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2099 2099
 	limit, _ := c.GetInt64("limit")
2100 2100
 	page, _ := c.GetInt64("page")
2101
-	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit)
2101
+	start_time := c.GetString("start_time")
2102
+	end_time := c.GetString("end_time")
2103
+	start_first_time := c.GetString("start_first_time")
2104
+	end_first_time := c.GetString("end_first_time")
2105
+	timeLayout := "2006-01-02"
2106
+	loc, _ := time.LoadLocation("Local")
2107
+	var startTime int64
2108
+	if len(start_time) > 0 {
2109
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2110
+		if err != nil {
2111
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2112
+			return
2113
+		}
2114
+		startTime = theTime.Unix()
2115
+	}
2116
+	var endTime int64
2117
+	if len(end_time) > 0 {
2118
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2119
+		if err != nil {
2120
+			utils.ErrorLog(err.Error())
2121
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2122
+			return
2123
+		}
2124
+		endTime = theTime.Unix()
2125
+	}
2126
+
2127
+	var startFistTime int64
2128
+	if len(start_first_time) > 0 {
2129
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_first_time+" 00:00:00", loc)
2130
+		if err != nil {
2131
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2132
+			return
2133
+		}
2134
+		startFistTime = theTime.Unix()
2135
+	}
2136
+	var endFirstTime int64
2137
+	if len(end_first_time) > 0 {
2138
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_first_time+" 23:59:59", loc)
2139
+		if err != nil {
2140
+			utils.ErrorLog(err.Error())
2141
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2142
+			return
2143
+		}
2144
+		endFirstTime = theTime.Unix()
2145
+	}
2146
+	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit, startTime, endTime, startFistTime, endFirstTime)
2102 2147
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2103 2148
 
2104 2149
 	drug, _ := service.GetBaseDrugMedical(drug_id)
@@ -2173,11 +2218,14 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2173 2218
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2174 2219
 
2175 2220
 	list, err := service.GetSingleOrderDetail(id, orgId)
2176
-
2221
+	drugoutlist, _ := service.GetDrugWarehouseOutDetailSeventy(id, orgId)
2177 2222
 	dealerList, err := service.GetAllDealerList(orgId)
2178 2223
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2179 2224
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2180 2225
 	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2226
+	drugList, _ := service.GetDrugFlowList(id, orgId)
2227
+	drugListOne, _ := service.GetDrugFlowListGroupByIdOne(id, orgId)
2228
+	drugListFlow, err := service.GetDrugFlowListGroupById(id, orgId)
2181 2229
 
2182 2230
 	if err != nil {
2183 2231
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
@@ -2189,6 +2237,10 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2189 2237
 		"manufacturerList": manufacturerList,
2190 2238
 		"drugFlowList":     drugFlowList,
2191 2239
 		"flowlist":         flowlist,
2240
+		"drugList":         drugList,
2241
+		"drugListFlow":     drugListFlow,
2242
+		"drugListOne":      drugListOne,
2243
+		"drugoutlist":      drugoutlist,
2192 2244
 	})
2193 2245
 }
2194 2246
 

+ 323 - 172
controllers/his_api_controller.go 查看文件

@@ -1314,6 +1314,8 @@ func (c *HisApiController) CreateHisPrescription() {
1314 1314
 
1315 1315
 											}
1316 1316
 											pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
1317
+											fmt.Println("device_number2333233232323222323232323323322332", device_number)
1318
+											fmt.Println("number_count99999999999999999999999999999999999", number_count)
1317 1319
 											if pharmacyConfig.IsOpen != 1 {
1318 1320
 												if device_number != number_count {
1319 1321
 
@@ -1324,6 +1326,7 @@ func (c *HisApiController) CreateHisPrescription() {
1324 1326
 													if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1325 1327
 
1326 1328
 														service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
1329
+
1327 1330
 													}
1328 1331
 													if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1329 1332
 														var stock_max_number int64
@@ -1333,17 +1336,20 @@ func (c *HisApiController) CreateHisPrescription() {
1333 1336
 
1334 1337
 															stock_max_number = device_number / drug.MinNumber
1335 1338
 															service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
1339
+
1336 1340
 															stock_min_number = device_number % drug.MinNumber
1337 1341
 															service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
1338 1342
 
1339 1343
 														} else {
1340 1344
 
1341 1345
 															service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
1346
+
1342 1347
 														}
1343 1348
 													}
1344 1349
 
1345 1350
 													if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1346 1351
 														service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
1352
+
1347 1353
 													}
1348 1354
 													//删除记录
1349 1355
 													service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
@@ -1612,10 +1618,38 @@ func (c *HisApiController) CreateHisPrescription() {
1612 1618
 
1613 1619
 										for _, item := range goodList {
1614 1620
 											//回退库存
1615
-											service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1621
+											//service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1622
+
1623
+											//service.ModifyReduceGoodSumCount(item.StorehouseId,item.Count,item.OrgId,item.GoodId)
1624
+
1625
+											goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1626
+											var flush_count int64
1627
+											for _, it := range goodListSix {
1628
+												flush_count += it.StockCount
1629
+											}
1630
+											errs := service.UpdateSumGood(item.OrgId, item.StorehouseId, item.GoodId, flush_count)
1631
+											creater := adminInfo.AdminUser.Id
1632
+											if errs != nil {
1633
+												goodErrcode := models.XtGoodErrcode{
1634
+													UserOrgId:      item.OrgId,
1635
+													Errcode:        "手动出库更新剩余出库失败",
1636
+													GoodId:         item.GoodId,
1637
+													Status:         1,
1638
+													Ctime:          time.Now().Unix(),
1639
+													Mtime:          0,
1640
+													Count:          0,
1641
+													StockCount:     0,
1642
+													Creater:        creater,
1643
+													BatchNumberId:  0,
1644
+													WarehouseOutId: 0,
1645
+												}
1646
+												service.CreateGoodErrcode(goodErrcode)
1647
+											}
1648
+
1616 1649
 										}
1617 1650
 										//删除记录
1618 1651
 										service.DeleteAutoWarehouse(patient_id, recordDateTime)
1652
+
1619 1653
 									}
1620 1654
 									if len(goodWarehouseInfo) > 0 {
1621 1655
 										//查询该患者耗材的历史数据
@@ -1630,8 +1664,35 @@ func (c *HisApiController) CreateHisPrescription() {
1630 1664
 
1631 1665
 											for _, item := range goodList {
1632 1666
 												//回退库存
1633
-												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1634
-
1667
+												//service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1668
+												//扣减出库数量
1669
+												//service.ModifyReduceGoodSumCount(item.StorehouseId,item.Count,item.OrgId,item.GoodId)
1670
+
1671
+												goodListSix, _ := service.GetSumGoodList(item.OrgId, item.StorehouseId, item.GoodId)
1672
+												var flush_count int64
1673
+												for _, it := range goodListSix {
1674
+													flush_count += it.StockCount
1675
+												}
1676
+												errs := service.UpdateSumGood(item.OrgId, item.StorehouseId, item.GoodId, flush_count)
1677
+
1678
+												//减少出库数量
1679
+												creater := adminInfo.AdminUser.Id
1680
+												if errs != nil {
1681
+													goodErrcode := models.XtGoodErrcode{
1682
+														UserOrgId:      item.OrgId,
1683
+														Errcode:        "手动出库更新剩余出库失败",
1684
+														GoodId:         item.GoodId,
1685
+														Status:         1,
1686
+														Ctime:          time.Now().Unix(),
1687
+														Mtime:          0,
1688
+														Count:          0,
1689
+														StockCount:     0,
1690
+														Creater:        creater,
1691
+														BatchNumberId:  0,
1692
+														WarehouseOutId: 0,
1693
+													}
1694
+													service.CreateGoodErrcode(goodErrcode)
1695
+												}
1635 1696
 												//查询默认仓库
1636 1697
 												stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeConfig.StorehouseOutInfo, item.OrgId)
1637 1698
 												var total_count int64
@@ -1641,6 +1702,7 @@ func (c *HisApiController) CreateHisPrescription() {
1641 1702
 												//基础库插入数据
1642 1703
 												service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, item.OrgId)
1643 1704
 											}
1705
+
1644 1706
 											//删除记录
1645 1707
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1646 1708
 
@@ -2066,20 +2128,25 @@ func (c *HisApiController) CreateHisPrescription() {
2066 2128
 					for _, it := range druginfo {
2067 2129
 
2068 2130
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
2131
+
2069 2132
 							service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
2133
+
2070 2134
 						}
2071 2135
 						if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
2072 2136
 							service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
2137
+
2073 2138
 						}
2074 2139
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
2075 2140
 
2076 2141
 							service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
2142
+
2077 2143
 						}
2078 2144
 					}
2079 2145
 				}
2080 2146
 
2081 2147
 				//删除记录
2082 2148
 				service.DeleteDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID)
2149
+				//查询最后一次数据
2083 2150
 				if drugOutConfig.IsOpen == 1 {
2084 2151
 					//出库
2085 2152
 					if drug.IsUse == 2 {
@@ -2091,9 +2158,15 @@ func (c *HisApiController) CreateHisPrescription() {
2091 2158
 					stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
2092 2159
 					var sum_count int64
2093 2160
 					for _, its := range stockInfo {
2094
-						sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
2161
+						baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
2162
+						if its.MaxUnit == baseDrug.MaxUnit {
2163
+							its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
2164
+						}
2165
+						sum_count += its.StockMaxNumber + its.StockMinNumber
2095 2166
 					}
2096 2167
 					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2168
+					//剩余库存
2169
+					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count)
2097 2170
 				}
2098 2171
 			}
2099 2172
 		}
@@ -2484,6 +2557,25 @@ func (c *HisApiController) DeletePrescription() {
2484 2557
 					info, _ := service.GetLastWarehoseByGoodId(item.ProjectId, item.PatientId, item.RecordDate)
2485 2558
 					manufacturer, _ := service.GetManufactureById(info.Manufacturer)
2486 2559
 					deaerler, _ := service.GetDealerById(info.Dealer)
2560
+
2561
+					//查询今日该患者开了多少耗材
2562
+					//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2563
+					//
2564
+					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)
2571
+					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)
2575
+					var flush_count int64
2576
+					for _, it := range goodList {
2577
+						flush_count += it.StockCount
2578
+					}
2487 2579
 					if info.ID > 0 {
2488 2580
 						cancelStockInfo := models.CancelStockInfo{
2489 2581
 							GoodId:          item.ProjectId,
@@ -2516,7 +2608,7 @@ func (c *HisApiController) DeletePrescription() {
2516 2608
 						cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.ProjectId)
2517 2609
 
2518 2610
 						flow := models.VmStockFlow{
2519
-							WarehousingId:           0,
2611
+							WarehousingId:           info.WarehouseInfotId,
2520 2612
 							GoodId:                  item.ProjectId,
2521 2613
 							Number:                  info.Number,
2522 2614
 							LicenseNumber:           info.LicenseNumber,
@@ -2527,7 +2619,7 @@ func (c *HisApiController) DeletePrescription() {
2527 2619
 							ConsumableType:          7,
2528 2620
 							IsSys:                   0,
2529 2621
 							WarehousingOrder:        "",
2530
-							WarehouseOutId:          0,
2622
+							WarehouseOutId:          info.WarehouseOutId,
2531 2623
 							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2532 2624
 							IsEdit:                  0,
2533 2625
 							CancelStockId:           cancel.ID,
@@ -2541,98 +2633,108 @@ func (c *HisApiController) DeletePrescription() {
2541 2633
 							Mtime:                   0,
2542 2634
 							Price:                   info.Price,
2543 2635
 							WarehousingDetailId:     info.WarehouseInfotId,
2544
-							WarehouseOutDetailId:    0,
2636
+							WarehouseOutDetailId:    info.ID,
2545 2637
 							CancelOutDetailId:       cancelInfo.ID,
2546 2638
 							ProductDate:             info.ProductDate,
2547 2639
 							ExpireDate:              info.ExpiryDate,
2548 2640
 							StorehouseId:            houseConfig.StorehouseOutInfo,
2641
+							OverCount:               flush_count,
2549 2642
 						}
2550 2643
 						service.CreateStockFlowOne(flow)
2551 2644
 
2552
-						//删除出库表
2553
-						service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2554
-
2555
-						//查询今日该患者开了多少耗材
2556
-						projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2645
+						//查询已出库数量
2646
+						dialysisInfo, _ := service.GetGoodDialysisOutInfo(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2557 2647
 
2558
-						var total_count int64
2559
-						var cha_count int64
2560
-						for _, item := range projectList {
2561
-							count, _ := strconv.ParseInt(item.Count, 10, 64)
2562
-							total_count += count
2648
+						if prescribingNumber < dialysisInfo.Count {
2649
+							//改变数量
2650
+							service.UpdateAutoGood(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId, item.ID, prescribingNumber)
2563 2651
 						}
2564
-						//回退库存
2565
-						service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2566 2652
 
2567
-						//查询今日该耗材退库数量
2568
-						cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2569
-						var cancel_Count int64
2570
-						for _, items := range cancelInfoOne {
2571
-							cancel_Count += items.Count
2653
+						if prescribingNumber == dialysisInfo.Count {
2654
+							//删除出库表
2655
+							service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2572 2656
 						}
2573 2657
 
2574
-						cha_count = total_count - cancel_Count
2575
-
2576
-						if total_count > cancel_Count {
2577
-
2578
-							out, err := service.FindStockOutByIsSys(c.GetAdminUserInfo().CurrentOrgId, 1, info.SysRecordTime)
2579
-							if err == gorm.ErrRecordNotFound {
2580
-								//没有记录,则创建出库单
2581
-								timeStr := time.Now().Format("2006-01-02")
2582
-								timeArr := strings.Split(timeStr, "-")
2583
-								total, _ := service.FindAllWarehouseOut(c.GetAdminUserInfo().CurrentOrgId)
2584
-								total = total + 1
2585
-								warehousing_out_order := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2586
-								number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2587
-								number = number + total
2588
-								warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
2589
-								warehouseOut := models.WarehouseOut{
2590
-									WarehouseOutOrderNumber: warehousing_out_order,
2591
-									OperationTime:           time.Now().Unix(),
2592
-									OrgId:                   c.GetAdminUserInfo().CurrentOrgId,
2593
-									Creater:                 creater,
2594
-									Ctime:                   time.Now().Unix(),
2595
-									Status:                  1,
2596
-									WarehouseOutTime:        info.SysRecordTime,
2597
-									Dealer:                  0,
2598
-									Manufacturer:            0,
2599
-									Type:                    1,
2600
-									IsSys:                   1,
2601
-									StorehouseId:            houseConfig.StorehouseOutInfo,
2602
-									IsCheck:                 1,
2603
-								}
2604
-								err := service.AddSigleWarehouseOut(&warehouseOut)
2605
-								if err != nil {
2606
-									utils.TraceLog("创建出库单失败 err = %v", err)
2607
-									return
2608
-								}
2609
-								prepare := &models.DialysisBeforePrepare{
2610
-									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2611
-									PatientId:    info.PatientId,
2612
-									RecordDate:   info.SysRecordTime,
2613
-									GoodId:       item.ProjectId,
2614
-									GoodTypeId:   info.GoodTypeId,
2615
-									Count:        cha_count,
2616
-									StorehouseId: houseConfig.StorehouseOutInfo,
2617
-								}
2618
-								//出库
2619
-								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2620
-							} else if err == nil {
2621
-
2622
-								prepare := &models.DialysisBeforePrepare{
2623
-									UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2624
-									PatientId:    info.PatientId,
2625
-									RecordDate:   info.SysRecordTime,
2626
-									GoodId:       item.ProjectId,
2627
-									GoodTypeId:   info.GoodTypeId,
2628
-									Count:        cha_count,
2629
-									StorehouseId: houseConfig.StorehouseOutInfo,
2630
-								}
2631
-								//出库
2632
-								service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2633
-							}
2658
+						////删除出库表
2659
+						//service.DeleteAutoRedeceDetailTen(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
2634 2660
 
2635
-						}
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
+						//更新库存
2667
+						service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, flush_count)
2668
+
2669
+						//查询今日该耗材退库数量
2670
+						//cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, item.ProjectId, info.SysRecordTime)
2671
+						//var cancel_Count int64
2672
+						//for _, items := range cancelInfoOne {
2673
+						//	cancel_Count += items.Count
2674
+						//}
2675
+						//
2676
+						//cha_count = total_count - cancel_Count
2677
+						//
2678
+						//if total_count > cancel_Count {
2679
+						//
2680
+						//	out, err := service.FindStockOutByIsSys(c.GetAdminUserInfo().CurrentOrgId, 1, info.SysRecordTime)
2681
+						//	if err == gorm.ErrRecordNotFound {
2682
+						//		//没有记录,则创建出库单
2683
+						//		timeStr := time.Now().Format("2006-01-02")
2684
+						//		timeArr := strings.Split(timeStr, "-")
2685
+						//		total, _ := service.FindAllWarehouseOut(c.GetAdminUserInfo().CurrentOrgId)
2686
+						//		total = total + 1
2687
+						//		warehousing_out_order := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2688
+						//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2689
+						//		number = number + total
2690
+						//		warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
2691
+						//		warehouseOut := models.WarehouseOut{
2692
+						//			WarehouseOutOrderNumber: warehousing_out_order,
2693
+						//			OperationTime:           time.Now().Unix(),
2694
+						//			OrgId:                   c.GetAdminUserInfo().CurrentOrgId,
2695
+						//			Creater:                 creater,
2696
+						//			Ctime:                   time.Now().Unix(),
2697
+						//			Status:                  1,
2698
+						//			WarehouseOutTime:        info.SysRecordTime,
2699
+						//			Dealer:                  0,
2700
+						//			Manufacturer:            0,
2701
+						//			Type:                    1,
2702
+						//			IsSys:                   1,
2703
+						//			StorehouseId:            houseConfig.StorehouseOutInfo,
2704
+						//			IsCheck:                 1,
2705
+						//		}
2706
+						//		err := service.AddSigleWarehouseOut(&warehouseOut)
2707
+						//		if err != nil {
2708
+						//			utils.TraceLog("创建出库单失败 err = %v", err)
2709
+						//			return
2710
+						//		}
2711
+						//		prepare := &models.DialysisBeforePrepare{
2712
+						//			UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2713
+						//			PatientId:    info.PatientId,
2714
+						//			RecordDate:   info.SysRecordTime,
2715
+						//			GoodId:       item.ProjectId,
2716
+						//			GoodTypeId:   info.GoodTypeId,
2717
+						//			Count:        cha_count,
2718
+						//			StorehouseId: houseConfig.StorehouseOutInfo,
2719
+						//		}
2720
+						//		//出库
2721
+						//		service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2722
+						//	} else if err == nil {
2723
+						//
2724
+						//		prepare := &models.DialysisBeforePrepare{
2725
+						//			UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
2726
+						//			PatientId:    info.PatientId,
2727
+						//			RecordDate:   info.SysRecordTime,
2728
+						//			GoodId:       item.ProjectId,
2729
+						//			GoodTypeId:   info.GoodTypeId,
2730
+						//			Count:        cha_count,
2731
+						//			StorehouseId: houseConfig.StorehouseOutInfo,
2732
+						//		}
2733
+						//		//出库
2734
+						//		service.ConsumablesDelivery(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
2735
+						//	}
2736
+						//
2737
+						//}
2636 2738
 
2637 2739
 					}
2638 2740
 
@@ -2657,7 +2759,6 @@ func (c *HisApiController) DeletePrescription() {
2657 2759
 		}
2658 2760
 	}
2659 2761
 	if drugStockConfig.IsOpen == 1 {
2660
-		fmt.Println("woowowowowowowowowowowowowowo", len(advices))
2661 2762
 		if len(advices) > 0 {
2662 2763
 			for _, item := range advices {
2663 2764
 				creater := c.GetAdminUserInfo().AdminUser.Id
@@ -2737,18 +2838,22 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2737 2838
 	redis.Set(keyOne, "", time.Second)
2738 2839
 
2739 2840
 	defer redis.Close()
2841
+
2740 2842
 	if err == nil {
2741 2843
 		if drugStockConfig.IsOpen == 1 {
2742 2844
 
2743 2845
 			//查询是否在处方中出库
2744 2846
 			openConfig, _ := service.GetDrugOpenConfigOne(c.GetAdminUserInfo().CurrentOrgId)
2847
+
2745 2848
 			if openConfig.IsOpen != 1 {
2746 2849
 
2747 2850
 				//判断该医嘱是否执行了
2748 2851
 				if advice.ExecutionState == 1 {
2749 2852
 					creater := c.GetAdminUserInfo().AdminUser.Id
2750 2853
 					service.DrugAutoAddCancelInfo(&advice, creater)
2854
+
2751 2855
 				}
2856
+
2752 2857
 			}
2753 2858
 
2754 2859
 			//开启保存处方扣减功能
@@ -2845,6 +2950,7 @@ func (c *HisApiController) DeleteProject() {
2845 2950
 				ReturnTime:   project.RecordDate,
2846 2951
 				Type:         1,
2847 2952
 				StorehouseId: houseConfig.StorehouseOutInfo,
2953
+				IsCheck:      1,
2848 2954
 			}
2849 2955
 			_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(project.RecordDate, adminInfo.CurrentOrgId)
2850 2956
 			if msgerrkonde == gorm.ErrRecordNotFound {
@@ -2853,7 +2959,7 @@ func (c *HisApiController) DeleteProject() {
2853 2959
 			cancel, _ := service.GetLastCancelStockById(adminInfo.CurrentOrgId)
2854 2960
 			floatPrescrip := strconv.FormatFloat(f_count, 'f', -1, 32)
2855 2961
 			prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
2856
-			//获取该耗材有库存的第一条数据
2962
+			//获取出库数据
2857 2963
 			info, _ := service.GetLastWarehoseByGoodId(project.ProjectId, project.PatientId, project.RecordDate)
2858 2964
 
2859 2965
 			manufacturer, _ := service.GetManufactureById(info.Manufacturer)
@@ -2882,14 +2988,22 @@ func (c *HisApiController) DeleteProject() {
2882 2988
 					PatientId:       info.PatientId,
2883 2989
 					RecordDate:      info.SysRecordTime,
2884 2990
 					StorehouseId:    houseConfig.StorehouseOutInfo,
2991
+					IsCheck:         1,
2885 2992
 				}
2886 2993
 
2887 2994
 				service.CreateCancelStockInfoOne(&cancelStockInfo)
2888 2995
 
2889 2996
 				cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(project.ProjectId)
2890 2997
 
2998
+				//回退库存
2999
+				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, prescribingNumber, info.PatientId, info.SysRecordTime, project.ProjectId)
3000
+				goodList, _ := service.GetSumGoodList(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId)
3001
+				var over_count int64
3002
+				for _, it := range goodList {
3003
+					over_count += it.StockCount
3004
+				}
2891 3005
 				flow := models.VmStockFlow{
2892
-					WarehousingId:           0,
3006
+					WarehousingId:           info.WarehouseInfotId,
2893 3007
 					GoodId:                  project.ProjectId,
2894 3008
 					Number:                  info.Number,
2895 3009
 					LicenseNumber:           info.LicenseNumber,
@@ -2900,8 +3014,8 @@ func (c *HisApiController) DeleteProject() {
2900 3014
 					ConsumableType:          7,
2901 3015
 					IsSys:                   0,
2902 3016
 					WarehousingOrder:        "",
2903
-					WarehouseOutId:          0,
2904
-					WarehouseOutOrderNumber: "",
3017
+					WarehouseOutId:          info.WarehouseOutId,
3018
+					WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2905 3019
 					IsEdit:                  0,
2906 3020
 					CancelStockId:           cancel.ID,
2907 3021
 					CancelOrderNumber:       cancel.OrderNumber,
@@ -2914,104 +3028,143 @@ func (c *HisApiController) DeleteProject() {
2914 3028
 					Mtime:                   0,
2915 3029
 					Price:                   info.Price,
2916 3030
 					WarehousingDetailId:     info.WarehouseInfotId,
2917
-					WarehouseOutDetailId:    0,
3031
+					WarehouseOutDetailId:    info.ID,
2918 3032
 					CancelOutDetailId:       cancelInfo.ID,
2919 3033
 					ProductDate:             info.ProductDate,
2920 3034
 					ExpireDate:              info.ExpiryDate,
2921 3035
 					StorehouseId:            houseConfig.StorehouseOutInfo,
3036
+					OverCount:               over_count,
2922 3037
 				}
2923 3038
 				service.CreateStockFlowOne(flow)
2924 3039
 
2925
-				//删除出库表
2926
-				service.DeleteAutoRedeceDetailTen(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3040
+				//查询已出库数量
3041
+				dialysisInfo, _ := service.GetGoodDialysisOutInfo(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
2927 3042
 
2928
-				//查询今日该患者开了多少耗材
2929
-				projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2930
-
2931
-				var total_count int64
2932
-				var cha_count int64
2933
-				for _, item := range projectList {
2934
-					count, _ := strconv.ParseInt(item.Count, 10, 64)
2935
-					total_count += count
3043
+				if prescribingNumber < dialysisInfo.Count {
3044
+					//改变数量
3045
+					service.UpdateAutoGood(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId, id, prescribingNumber)
2936 3046
 				}
2937
-				//回退库存
2938
-				service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count)
2939
-
2940
-				//查询今日该耗材退库数量
2941
-				cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
2942
-				var cancel_count int64
2943
-				for _, items := range cancelInfoOne {
2944
-					cancel_count += items.Count
2945
-				}
2946
-
2947
-				cha_count = total_count - cancel_count
2948
-
2949
-				if total_count > cancel_count {
2950
-
2951
-					out, err := service.FindStockOutByIsSys(adminInfo.CurrentOrgId, 1, info.SysRecordTime)
2952
-					if err == gorm.ErrRecordNotFound {
2953
-						//没有记录,则创建出库单
2954
-						timeStr := time.Now().Format("2006-01-02")
2955
-						timeArr := strings.Split(timeStr, "-")
2956
-						total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
2957
-						total = total + 1
2958
-						warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2959
-						number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2960
-						number = number + total
2961
-						warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
2962
-						warehouseOut := models.WarehouseOut{
2963
-							WarehouseOutOrderNumber: warehousing_out_order,
2964
-							OperationTime:           time.Now().Unix(),
2965
-							OrgId:                   adminInfo.CurrentOrgId,
2966
-							Creater:                 creater,
2967
-							Ctime:                   time.Now().Unix(),
2968
-							Status:                  1,
2969
-							WarehouseOutTime:        info.SysRecordTime,
2970
-							Dealer:                  0,
2971
-							Manufacturer:            0,
2972
-							Type:                    1,
2973
-							IsSys:                   1,
2974
-							StorehouseId:            houseConfig.StorehouseOutInfo,
2975
-						}
2976
-						err := service.AddSigleWarehouseOut(&warehouseOut)
2977
-						if err != nil {
2978
-							utils.TraceLog("创建出库单失败 err = %v", err)
2979
-							return
2980
-						}
2981
-						prepare := &models.DialysisBeforePrepare{
2982
-							UserOrgId:    adminInfo.CurrentOrgId,
2983
-							PatientId:    info.PatientId,
2984
-							RecordDate:   info.SysRecordTime,
2985
-							GoodId:       project.ProjectId,
2986
-							GoodTypeId:   info.GoodTypeId,
2987
-							Count:        cha_count,
2988
-							StorehouseId: houseConfig.StorehouseOutInfo,
2989
-						}
2990
-						//出库
2991
-						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
2992
-					} else if err == nil {
2993
-						prepare := &models.DialysisBeforePrepare{
2994
-							UserOrgId:    adminInfo.CurrentOrgId,
2995
-							PatientId:    info.PatientId,
2996
-							RecordDate:   info.SysRecordTime,
2997
-							GoodId:       project.ProjectId,
2998
-							GoodTypeId:   info.GoodTypeId,
2999
-							Count:        cha_count,
3000
-							StorehouseId: houseConfig.StorehouseOutInfo,
3001
-						}
3002
-						//出库
3003
-						service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
3004
-					}
3005 3047
 
3048
+				if prescribingNumber == dialysisInfo.Count {
3049
+					//删除出库表
3050
+					service.DeleteAutoRedeceDetailTen(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3006 3051
 				}
3007 3052
 
3053
+				//退库数量增加
3054
+				service.UpdateSumAddCancelCount(adminInfo.CurrentOrgId, project.ProjectId, houseConfig.StorehouseOutInfo, prescribingNumber)
3055
+				//出库数量减少
3056
+				service.UpdateSumCount(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, prescribingNumber)
3057
+
3058
+				//更新剩余库存
3059
+				service.UpdateSumGood(adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, over_count)
3060
+				//查询今日该患者开了多少耗材
3061
+				//projectList, _ := service.GetHisPrepscritionByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
3062
+				//
3063
+				//var total_count int64
3064
+				//var cha_count int64
3065
+				//for _, item := range projectList {
3066
+				//	count, _ := strconv.ParseInt(item.Count, 10, 64)
3067
+				//	total_count += count
3068
+				//}
3069
+				//
3070
+				////查询今日该耗材退库数量
3071
+				//cancelInfoOne, _ := service.GetCancelStockInfoByPatientId(info.PatientId, project.ProjectId, info.SysRecordTime)
3072
+				//var cancel_count int64
3073
+				//for _, items := range cancelInfoOne {
3074
+				//	cancel_count += items.Count
3075
+				//}
3076
+				//
3077
+				//cha_count = total_count - cancel_count
3078
+				//
3079
+				//if total_count > cancel_count {
3080
+				//
3081
+				//	out, err := service.FindStockOutByIsSys(adminInfo.CurrentOrgId, 1, info.SysRecordTime)
3082
+				//	if err == gorm.ErrRecordNotFound {
3083
+				//		//没有记录,则创建出库单
3084
+				//		timeStr := time.Now().Format("2006-01-02")
3085
+				//		timeArr := strings.Split(timeStr, "-")
3086
+				//		total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
3087
+				//		total = total + 1
3088
+				//		warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
3089
+				//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
3090
+				//		number = number + total
3091
+				//		warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
3092
+				//		warehouseOut := models.WarehouseOut{
3093
+				//			WarehouseOutOrderNumber: warehousing_out_order,
3094
+				//			OperationTime:           time.Now().Unix(),
3095
+				//			OrgId:                   adminInfo.CurrentOrgId,
3096
+				//			Creater:                 creater,
3097
+				//			Ctime:                   time.Now().Unix(),
3098
+				//			Status:                  1,
3099
+				//			WarehouseOutTime:        info.SysRecordTime,
3100
+				//			Dealer:                  0,
3101
+				//			Manufacturer:            0,
3102
+				//			Type:                    1,
3103
+				//			IsSys:                   1,
3104
+				//			StorehouseId:            houseConfig.StorehouseOutInfo,
3105
+				//		}
3106
+				//		err := service.AddSigleWarehouseOut(&warehouseOut)
3107
+				//		if err != nil {
3108
+				//			utils.TraceLog("创建出库单失败 err = %v", err)
3109
+				//			return
3110
+				//		}
3111
+				//		prepare := &models.DialysisBeforePrepare{
3112
+				//			UserOrgId:    adminInfo.CurrentOrgId,
3113
+				//			PatientId:    info.PatientId,
3114
+				//			RecordDate:   info.SysRecordTime,
3115
+				//			GoodId:       project.ProjectId,
3116
+				//			GoodTypeId:   info.GoodTypeId,
3117
+				//			Count:        cha_count,
3118
+				//			StorehouseId: houseConfig.StorehouseOutInfo,
3119
+				//		}
3120
+				//		//出库
3121
+				//		service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &warehouseOut, cha_count)
3122
+				//	} else if err == nil {
3123
+				//		prepare := &models.DialysisBeforePrepare{
3124
+				//			UserOrgId:    adminInfo.CurrentOrgId,
3125
+				//			PatientId:    info.PatientId,
3126
+				//			RecordDate:   info.SysRecordTime,
3127
+				//			GoodId:       project.ProjectId,
3128
+				//			GoodTypeId:   info.GoodTypeId,
3129
+				//			Count:        cha_count,
3130
+				//			StorehouseId: houseConfig.StorehouseOutInfo,
3131
+				//		}
3132
+				//		//出库
3133
+				//		service.ConsumablesDelivery(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, prepare, &out, cha_count)
3134
+				//	}
3135
+				//
3136
+				//}
3137
+
3008 3138
 				stockList, _ := service.GetStockCountByGoodId(project.ProjectId, houseConfig.StorehouseOutInfo, project.UserOrgId)
3009 3139
 				var total_count_one int64
3010 3140
 				for _, it := range stockList {
3011 3141
 					total_count_one += it.StockCount
3012 3142
 				}
3013 3143
 				//基础库插入数据
3014
-				service.UpdateGoodInfoSumCount(project.ProjectId, total_count_one, project.UserOrgId)
3144
+				service.UpdateGoodInfoSumCountSix(project.ProjectId, total_count_one, project.UserOrgId)
3145
+
3146
+				goodListOne, _ := service.GetSumGoodList(project.UserOrgId, houseConfig.StorehouseOutInfo, project.ProjectId)
3147
+				var flush_count int64
3148
+				for _, it := range goodListOne {
3149
+					flush_count += it.StockCount
3150
+				}
3151
+				errs := service.UpdateSumGood(project.UserOrgId, houseConfig.StorehouseOutInfo, project.ProjectId, flush_count)
3152
+				if errs != nil {
3153
+					goodErrcode := models.XtGoodErrcode{
3154
+						UserOrgId:      project.UserOrgId,
3155
+						Errcode:        "手动出库更新剩余出库失败",
3156
+						GoodId:         project.ProjectId,
3157
+						Status:         1,
3158
+						Ctime:          time.Now().Unix(),
3159
+						Mtime:          0,
3160
+						Count:          0,
3161
+						StockCount:     0,
3162
+						Creater:        creater,
3163
+						BatchNumberId:  0,
3164
+						WarehouseOutId: 0,
3165
+					}
3166
+					service.CreateGoodErrcode(goodErrcode)
3167
+				}
3015 3168
 			}
3016 3169
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
3017 3170
 			fmt.Println(err)
@@ -6172,8 +6325,6 @@ func (c *HisApiController) GetFaPiaoData() {
6172 6325
 
6173 6326
 	patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
6174 6327
 
6175
-	//prescriptions, _ := service.GetHisPrescriptionThree(adminUser.CurrentOrgId, patient_id, order.Number)
6176
-
6177 6328
 	var bedCostTotal float64 = 0         //床位总费
6178 6329
 	var bedCostSelfTotal float64 = 0     //床位自费
6179 6330
 	var bedCostPartSelfTotal float64 = 0 //床位部分项目自费

+ 13 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go 查看文件

@@ -297,6 +297,19 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
297 297
 			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
298 298
 			system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
299 299
 			lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
300
+
301
+			//判断透析模式,针对河间咸的
302
+			if adminUserInfo.Org.Id == 10090 {
303
+				if dialysisSolution.ModeId != 2 && dialysisSolution.ModeId != 5 && dialysisSolution.ModeId != 12 {
304
+					dialysisSolution.DisplaceLiquiPart = 0
305
+					dialysisSolution.DisplaceLiquiValue = 0
306
+				}
307
+				if lastDialysisPrescribe.ModeId != 2 && lastDialysisPrescribe.ModeId != 5 && lastDialysisPrescribe.ModeId != 12 {
308
+					dialysisSolution.DisplaceLiquiPart = 0
309
+					dialysisSolution.DisplaceLiquiValue = 0
310
+				}
311
+			}
312
+
300 313
 			mode_id = schedual.ModeId
301 314
 		} else {
302 315
 			// 获取透析模版

文件差異過大導致無法顯示
+ 740 - 110
controllers/mobile_api_controllers/dialysis_api_controller.go


+ 3 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go 查看文件

@@ -131,7 +131,6 @@ func MobileAPIControllersRegisterRouters() {
131 131
 	beego.Router("/m/api/dialysisbeforeprepare/edit", &DialysisAPIController{}, "Post:EditConsumables")
132 132
 
133 133
 	beego.Router("/m/api/stockout/create", &DialysisAPIController{}, "Post:CreateStockOutInfo")
134
-	//beego.Router("/m/api/stockout/edit", &DialysisAPIController{}, "Post:EditStockOutInfo")
135 134
 
136 135
 	beego.Router("/m/api/otherstockout/create", &DialysisAPIController{}, "Post:CreateOtherStockOutInfo")
137 136
 
@@ -168,4 +167,7 @@ func MobileAPIControllersRegisterRouters() {
168 167
 
169 168
 	beego.Router("/m/api/getrolelist", &DialysisAPIController{}, "Get:GetRoleList")
170 169
 
170
+	beego.Router("/m/api/savepatientsign", &DialysisAPIController{}, "Post:SavePatientSign")
171
+	beego.Router("/m/api/getpatientsign", &DialysisAPIController{}, "Get:GetPatientSign")
172
+
171 173
 }

+ 82 - 0
controllers/patient_api_controller.go 查看文件

@@ -78,6 +78,10 @@ func PatientApiRegistRouters() {
78 78
 
79 79
 	beego.Router("/api/patients/banner", &PatientApiController{}, "Get:GetBanner")
80 80
 
81
+	//长期医嘱新接口
82
+	beego.Router("/api/patient/findepatientdialysislongsolutions", &PatientApiController{}, "Get:GetPatientDialysisLongSolution")
83
+	beego.Router("/api/patient/getdialysissolutiondetaillist", &PatientApiController{}, "Get:GetDialysisSolutionDetailList")
84
+
81 85
 }
82 86
 
83 87
 //GetPatientsList 取患者列表
@@ -833,8 +837,16 @@ func (c *PatientApiController) CreateDialysisSolution() {
833 837
 	solution.UpdatedTime = time.Now().Unix()
834 838
 	solution.SubName = ""
835 839
 	solution.ParentId = 0
840
+	solution.SolutionStatus = 1
836 841
 
837 842
 	err := service.CreatePatientDialysisSolution(&solution)
843
+
844
+	//获取最新1条
845
+	dialysisSolution, _ := service.GetLastPatientDialysisSolution(id, adminUserInfo.CurrentOrgId)
846
+
847
+	//更新状态
848
+	service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
849
+
838 850
 	if err != nil {
839 851
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionCreate)
840 852
 		return
@@ -1979,10 +1991,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1979 1991
 							if medical.IsUse == 2 {
1980 1992
 								//是通过药房发药
1981 1993
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1994
+									//执行出库
1982 1995
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1983 1996
 								}
1984 1997
 								//不通过药房发药
1985 1998
 								if pharmacyConfig.IsOpen != 1 {
1999
+									//执行出库
1986 2000
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1987 2001
 								}
1988 2002
 
@@ -2316,6 +2330,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2316 2330
 								fmt.Println("pharmacyConfig23232332322323", pharmacyConfig.IsOpen, medical.IsPharmacy)
2317 2331
 								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
2318 2332
 									service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2333
+
2319 2334
 								}
2320 2335
 								//不通过药房发药
2321 2336
 								if pharmacyConfig.IsOpen != 1 {
@@ -2330,6 +2345,11 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2330 2345
 									sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
2331 2346
 								}
2332 2347
 								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
2348
+
2349
+								//出库数量累加
2350
+								//service.AddDrugCount(item.DrugId,item.UserOrgId,storeHouseConfig.DrugStorehouseOut,prescribing_number_total)
2351
+								//剩余库存
2352
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
2333 2353
 								break
2334 2354
 								c.ServeSuccessJSON(map[string]interface{}{
2335 2355
 									"msg":    "1",
@@ -5133,3 +5153,65 @@ func (c *PatientApiController) GetBanner() {
5133 5153
 		})
5134 5154
 	}
5135 5155
 }
5156
+
5157
+func (c *PatientApiController) GetPatientDialysisLongSolution() {
5158
+
5159
+	patient_id, _ := c.GetInt64("id", 0)
5160
+	page, _ := c.GetInt64("page", 0)
5161
+	limit, _ := c.GetInt64("limit", 0)
5162
+	if patient_id <= 0 {
5163
+		c.ServeSuccessJSON(map[string]interface{}{
5164
+			"solutions": nil,
5165
+		})
5166
+		return
5167
+	}
5168
+	if page <= 0 {
5169
+		page = 1
5170
+	}
5171
+	if limit <= 0 {
5172
+		limit = 10
5173
+	}
5174
+
5175
+	adminUserInfo := c.GetAdminUserInfo()
5176
+
5177
+	//获取该患者分组的透析模式
5178
+	list, _ := service.GetPatientSolutionGroupList(patient_id, adminUserInfo.CurrentOrgId)
5179
+
5180
+	for _, item := range list {
5181
+		//获取该模式最新的1条数据
5182
+		solution, _ := service.GetNewPatientSolutionByModeId(patient_id, item.ModeId, adminUserInfo.CurrentOrgId)
5183
+
5184
+		//更新状态值
5185
+		service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, adminUserInfo.CurrentOrgId, patient_id)
5186
+	}
5187
+
5188
+	solution, total, err := service.GetPatientDialysisLongSolution(patient_id, page, limit, adminUserInfo.CurrentOrgId)
5189
+	stockType, _ := service.GetStockType(adminUserInfo.CurrentOrgId)
5190
+	if err != nil {
5191
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5192
+		return
5193
+	}
5194
+	c.ServeSuccessJSON(map[string]interface{}{
5195
+		"solutions": solution,
5196
+		"total":     total,
5197
+		"stockType": stockType,
5198
+	})
5199
+}
5200
+
5201
+func (c *PatientApiController) GetDialysisSolutionDetailList() {
5202
+
5203
+	patient_id, _ := c.GetInt64("patient_id")
5204
+	mode_id, _ := c.GetInt64("mode_id")
5205
+	page, _ := c.GetInt64("page")
5206
+	limit, _ := c.GetInt64("limit")
5207
+	orgId := c.GetAdminUserInfo().CurrentOrgId
5208
+	list, total, err := service.GetDialysisSolutionDetailList(orgId, patient_id, mode_id, page, limit)
5209
+	if err != nil {
5210
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
5211
+		return
5212
+	}
5213
+	c.ServeSuccessJSON(map[string]interface{}{
5214
+		"list":  list,
5215
+		"total": total,
5216
+	})
5217
+}

+ 1 - 0
controllers/pharmacy_controller.go 查看文件

@@ -564,6 +564,7 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
564 564
 		return
565 565
 	}
566 566
 	total, err := service.CalculateTheTotalAmount(listll, drug_id)
567
+	fmt.Println("total2322332232323232332322wo", total)
567 568
 	if err != nil {
568 569
 		utils.ErrorLog(err.Error())
569 570
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 1 - 1
controllers/schedule_api_controller.go 查看文件

@@ -204,7 +204,7 @@ func (c *ScheduleApiController) GetPatients() {
204 204
 	weekEnd := theEndTime.Unix()
205 205
 
206 206
 	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
207
-
207
+	fmt.Println("patinets23233232323232232322323wode", patients)
208 208
 	c.ServeSuccessJSON(map[string]interface{}{
209 209
 		"patients": patients,
210 210
 	})

+ 220 - 3
controllers/secondary_order_api_contorller.go 查看文件

@@ -278,8 +278,8 @@ func (this *SecondaryOrderApiController) AddStorehouse() {
278 278
 		return
279 279
 	}
280 280
 	defer func() {
281
-		if err != nil{
282
-			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId,this.Ctx.Input,err)
281
+		if err != nil {
282
+			service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
283 283
 		}
284 284
 	}()
285 285
 	var storehouse_status, admin_id int64
@@ -1199,6 +1199,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1199 1199
 					}
1200 1200
 					service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1201 1201
 				}
1202
+
1202 1203
 			}
1203 1204
 
1204 1205
 			//耗材
@@ -1322,8 +1323,116 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1322 1323
 					total_count += it.StockCount
1323 1324
 				}
1324 1325
 				//基础库插入数据
1325
-				service.UpdateGoodInfoSumCount(item.ProjectId, total_count, orgId)
1326
+				service.UpdateGoodInfoSumCountSix(item.ProjectId, total_count, orgId)
1327
+			}
1328
+		}
1329
+	}
1330
+
1331
+	//获取所有的入库仓库
1332
+	druglist, _ := service.GetDrugWarehouseInfoStorehouseList(orgId)
1333
+	for _, item := range druglist {
1334
+		//查询该药品该仓库是否有数据
1335
+		drug, _ := service.GetDrugStockCout(item.DrugId, item.StorehouseId, item.OrgId)
1336
+
1337
+		//查询该仓库该药品的入库数量
1338
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1339
+
1340
+		var sum_in_count int64
1341
+		var flush_count int64
1342
+		var sum_out_count int64
1343
+		var cancel_out_count int64
1344
+		//查询入库数量和剩余库存
1345
+		infolist, _ := service.GetDrugWarehouseInfoByStorehouseId(item.StorehouseId, item.DrugId, item.OrgId)
1346
+		for _, it := range infolist {
1347
+			if it.MaxUnit == medical.MaxUnit {
1348
+				it.WarehousingCount = it.WarehousingCount * medical.MinNumber
1349
+				it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
1350
+			}
1351
+			sum_in_count += it.WarehousingCount
1352
+			flush_count += it.StockMaxNumber + it.StockMinNumber
1353
+		}
1354
+
1355
+		//获取出库数量
1356
+		outinfolist, _ := service.GetDrugFlowStockOutCount(item.StorehouseId, item.DrugId, item.OrgId)
1357
+		for _, it := range outinfolist {
1358
+			if it.MaxUnit == medical.MaxUnit {
1359
+				it.Count = it.Count * medical.MinNumber
1360
+			}
1361
+			sum_out_count += it.Count
1362
+		}
1363
+
1364
+		//获取退库数量
1365
+		cancelinfolist, _ := service.GetDrugFlowStockCancelCount(item.StorehouseId, item.DrugId, item.OrgId)
1366
+		for _, it := range cancelinfolist {
1367
+			if it.MaxUnit == medical.MaxUnit {
1368
+				it.Count = it.Count * medical.MinNumber
1369
+			}
1370
+			cancel_out_count += it.Count
1371
+		}
1372
+
1373
+		//新增
1374
+		if drug.ID == 0 {
1375
+			drugstock := models.XtDrugStockCount{
1376
+				UserOrgId:      orgId,
1377
+				StorehouseId:   item.StorehouseId,
1378
+				SumInCount:     sum_in_count,
1379
+				SumOutCount:    sum_out_count - cancel_out_count,
1380
+				SumCancelCount: cancel_out_count,
1381
+				DrugId:         item.DrugId,
1382
+				Ctime:          time.Now().Unix(),
1383
+				Mtime:          0,
1384
+				Status:         1,
1385
+				FlushCount:     flush_count,
1386
+				SumActOutCount: sum_out_count,
1387
+			}
1388
+			service.CreateDrugStockCount(drugstock)
1389
+		}
1390
+	}
1391
+
1392
+	//获取入库数据
1393
+	goodlist, _ := service.GetSendGoodInformation(orgId)
1394
+	for _, it := range goodlist {
1395
+		//查询是否有数据
1396
+		_, errcode := service.GetStockFlush(it.StorehouseId, it.GoodId, it.OrgId)
1397
+		//获取总退库数量
1398
+		var cancel_count int64
1399
+		var out_count int64
1400
+		var act_count int64
1401
+		//退库总数量
1402
+		cancellist, _ := service.GetAllCancelCount(it.StorehouseId, it.GoodId, it.OrgId)
1403
+		for _, item := range cancellist {
1404
+			cancel_count += item.Count
1405
+		}
1406
+		//出库总数量
1407
+		outlist, _ := service.GetAllStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
1408
+		for _, item := range outlist {
1409
+			out_count += item.Count
1410
+		}
1411
+
1412
+		//实际出库总数量
1413
+		actlist, _ := service.GetActStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
1414
+		for _, item := range actlist {
1415
+			act_count += item.Count
1416
+		}
1417
+
1418
+		if errcode == gorm.ErrRecordNotFound {
1419
+			good := models.XtGoodStockCount{
1420
+				UserOrgId:        it.OrgId,
1421
+				GoodId:           it.GoodId,
1422
+				StorehouseId:     it.StorehouseId,
1423
+				Status:           1,
1424
+				Ctime:            time.Now().Unix(),
1425
+				Mtime:            0,
1426
+				StockInCount:     it.WarehousingCount,
1427
+				StockOutCount:    out_count - cancel_count,
1428
+				StockCancelCount: cancel_count,
1429
+				FlushCount:       it.StockCount,
1430
+				StockActOutCount: act_count,
1326 1431
 			}
1432
+			service.CreateGoodCountSix(good)
1433
+		}
1434
+		if errcode == nil {
1435
+			service.UpdateGoodCount(it.WarehousingCount, it.StockCount, out_count, it.StorehouseId, it.GoodId, it.OrgId, cancel_count, act_count)
1327 1436
 		}
1328 1437
 	}
1329 1438
 
@@ -1542,6 +1651,114 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1542 1651
 		}
1543 1652
 	}
1544 1653
 
1654
+	//获取所有的入库仓库
1655
+	druglist, _ := service.GetDrugWarehouseInfoStorehouseList(orgId)
1656
+	for _, item := range druglist {
1657
+		//查询该药品该仓库是否有数据
1658
+		drug, _ := service.GetDrugStockCout(item.DrugId, item.StorehouseId, item.OrgId)
1659
+
1660
+		//查询该仓库该药品的入库数量
1661
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
1662
+
1663
+		var sum_in_count int64
1664
+		var flush_count int64
1665
+		var sum_out_count int64
1666
+		var cancel_out_count int64
1667
+		//查询入库数量和剩余库存
1668
+		infolist, _ := service.GetDrugWarehouseInfoByStorehouseId(item.StorehouseId, item.DrugId, item.OrgId)
1669
+		for _, it := range infolist {
1670
+			if it.MaxUnit == medical.MaxUnit {
1671
+				it.WarehousingCount = it.WarehousingCount * medical.MinNumber
1672
+				it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
1673
+			}
1674
+			sum_in_count += it.WarehousingCount
1675
+			flush_count += it.StockMaxNumber + it.StockMinNumber
1676
+		}
1677
+
1678
+		//获取出库数量
1679
+		outinfolist, _ := service.GetDrugFlowStockOutCount(item.StorehouseId, item.DrugId, item.OrgId)
1680
+		for _, it := range outinfolist {
1681
+			if it.MaxUnit == medical.MaxUnit {
1682
+				it.Count = it.Count * medical.MinNumber
1683
+			}
1684
+			sum_out_count += it.Count
1685
+		}
1686
+
1687
+		//获取退库数量
1688
+		cancelinfolist, _ := service.GetDrugFlowStockCancelCount(item.StorehouseId, item.DrugId, item.OrgId)
1689
+		for _, it := range cancelinfolist {
1690
+			if it.MaxUnit == medical.MaxUnit {
1691
+				it.Count = it.Count * medical.MinNumber
1692
+			}
1693
+			cancel_out_count += it.Count
1694
+		}
1695
+
1696
+		//新增
1697
+		if drug.ID == 0 {
1698
+			drugstock := models.XtDrugStockCount{
1699
+				UserOrgId:      orgId,
1700
+				StorehouseId:   item.StorehouseId,
1701
+				SumInCount:     sum_in_count,
1702
+				SumOutCount:    sum_out_count - cancel_out_count,
1703
+				SumCancelCount: cancel_out_count,
1704
+				DrugId:         item.DrugId,
1705
+				Ctime:          time.Now().Unix(),
1706
+				Mtime:          0,
1707
+				Status:         1,
1708
+				FlushCount:     flush_count,
1709
+				SumActOutCount: sum_out_count,
1710
+			}
1711
+			service.CreateDrugStockCount(drugstock)
1712
+		}
1713
+	}
1714
+
1715
+	//获取入库数据
1716
+	goodlist, _ := service.GetSendGoodInformation(orgId)
1717
+	for _, it := range goodlist {
1718
+		//查询是否有数据
1719
+		_, errcode := service.GetStockFlush(it.StorehouseId, it.GoodId, it.OrgId)
1720
+		//获取总退库数量
1721
+		var cancel_count int64
1722
+		var out_count int64
1723
+		var act_count int64
1724
+		//退库总数量
1725
+		cancellist, _ := service.GetAllCancelCount(it.StorehouseId, it.GoodId, it.OrgId)
1726
+		for _, item := range cancellist {
1727
+			cancel_count += item.Count
1728
+		}
1729
+		//出库总数量
1730
+		outlist, _ := service.GetAllStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
1731
+		for _, item := range outlist {
1732
+			out_count += item.Count
1733
+		}
1734
+
1735
+		//实际出库总数量
1736
+		actlist, _ := service.GetActStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
1737
+		for _, item := range actlist {
1738
+			act_count += item.Count
1739
+		}
1740
+
1741
+		if errcode == gorm.ErrRecordNotFound {
1742
+			good := models.XtGoodStockCount{
1743
+				UserOrgId:        it.OrgId,
1744
+				GoodId:           it.GoodId,
1745
+				StorehouseId:     it.StorehouseId,
1746
+				Status:           1,
1747
+				Ctime:            time.Now().Unix(),
1748
+				Mtime:            0,
1749
+				StockInCount:     it.WarehousingCount,
1750
+				StockOutCount:    out_count - cancel_count,
1751
+				StockCancelCount: cancel_count,
1752
+				FlushCount:       it.StockCount,
1753
+				StockActOutCount: act_count,
1754
+			}
1755
+			service.CreateGoodCountSix(good)
1756
+		}
1757
+		if errcode == nil {
1758
+			service.UpdateGoodCount(it.WarehousingCount, it.StockCount, out_count, it.StorehouseId, it.GoodId, it.OrgId, cancel_count, act_count)
1759
+		}
1760
+	}
1761
+
1545 1762
 	this.ServeSuccessJSON(map[string]interface{}{
1546 1763
 		"msg": "1",
1547 1764
 	})

+ 639 - 40
controllers/self_drug_api_congtroller.go 查看文件

@@ -98,7 +98,14 @@ func SelfDrugRouters() {
98 98
 	//药品库存优化接口
99 99
 	beego.Router("/api/good/getdrugwarehouseoutdetailbypatientid", &SelfDrugApiController{}, "Get:GetDrugWarehouseOutDetailByPatientId")
100 100
 	beego.Router("/api/drug/getdrugexpirydatequery", &SelfDrugApiController{}, "Get:GetDrugExpiryDateQuery")
101
+	beego.Router("/api/drug/getpurchasedrugquery", &SelfDrugApiController{}, "Get:GetPurchaseDrugQuery")
102
+	beego.Router("/api/drug/getdrugnewquery", &SelfDrugApiController{}, "Get:GetDrugNewQuery")
103
+	beego.Router("/api/drug/getdrugwarehouseoutinfobyid", &SelfDrugApiController{}, "Get:GetDrugWarehouseInfoById")
101 104
 
105
+	//耗材脚本
106
+	beego.Router("/api/stock/tosendgoodinfomation", &SelfDrugApiController{}, "Get:GetSendGoodInformation")
107
+	//药品脚本
108
+	beego.Router("/api/drug/getdruginitdatalist", &SelfDrugApiController{}, "Get:GetDrugInitDetailList")
102 109
 }
103 110
 
104 111
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -2572,6 +2579,8 @@ func (this *SelfDrugApiController) SaveInventoryList() {
2572 2579
 			}
2573 2580
 			service.UpdateMedicalSumCount(drugInfo.DrugId, sum_count, sum_in_count, drugInfo.OrgId)
2574 2581
 
2582
+			//更新剩余库存
2583
+			service.UpdateDrugStockCount(drugInfo.DrugId, drugInfo.OrgId, houseConfig.DrugStorehouseOut, sum_count)
2575 2584
 			inventory := models.XtDrugInventory{
2576 2585
 				DrugName:           drug_name,
2577 2586
 				SpecificationName:  specification_name,
@@ -2728,40 +2737,101 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2728 2737
 	keyword := this.GetString("keyword")
2729 2738
 	page, _ := this.GetInt64("page")
2730 2739
 	limit, _ := this.GetInt64("limit")
2731
-	start_time := this.GetString("start_time")
2732
-	end_time := this.GetString("end_time")
2733
-	timeLayout := "2006-01-02"
2734
-	loc, _ := time.LoadLocation("Local")
2735
-	var startTime int64
2736
-	if len(start_time) > 0 {
2737
-		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2738
-		if err != nil {
2739
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2740
-			return
2741
-		}
2742
-		startTime = theTime.Unix()
2743
-	}
2744
-	var endTime int64
2745
-	if len(end_time) > 0 {
2746
-		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2747
-		if err != nil {
2748
-			utils.ErrorLog(err.Error())
2749
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2750
-			return
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
+
2764
+	// 查询该机构所有耗材入库信息
2765
+	goodList, _ := service.GetAllGoodListSeven(orgId)
2766
+
2767
+	for _, it := range goodList {
2768
+		var sum_total int64
2769
+		//查询该耗材入库信息
2770
+		warehouseinfo, _ := service.GetGoodInformationWarehouseInfo(it.ID, orgId)
2771
+		for _, item := range warehouseinfo {
2772
+			sum_total += item.StockCount
2751 2773
 		}
2752
-		endTime = theTime.Unix()
2753
-	}
2774
+		service.UpdateGoodInformation(it.ID, orgId, sum_total)
2775
+	}
2776
+
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
+
2754 2789
 	var ids []int64
2755 2790
 	var goodIds []int64
2756 2791
 	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2757
-	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId)
2758 2792
 	for _, it := range manufacturerList {
2759 2793
 		ids = append(ids, it.ID)
2760 2794
 	}
2795
+	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId, storehouse_id)
2761 2796
 	for _, it := range infoList {
2762 2797
 		goodIds = append(goodIds, it.GoodId)
2763 2798
 	}
2764
-	list, total, err := service.GetGoodNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
2799
+	//list, _, err := service.GetGoodNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
2800
+
2801
+	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
+
2765 2835
 	if err != nil {
2766 2836
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
2767 2837
 		return
@@ -2769,7 +2839,8 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2769 2839
 
2770 2840
 	this.ServeSuccessJSON(map[string]interface{}{
2771 2841
 		"total": total,
2772
-		"list":  list,
2842
+		//"list":  list,
2843
+		"stockList": stockList,
2773 2844
 	})
2774 2845
 }
2775 2846
 
@@ -2780,6 +2851,7 @@ func (this *SelfDrugApiController) GetGoodWarehouseOutInfoByIdList() {
2780 2851
 	page, _ := this.GetInt64("page")
2781 2852
 	start_time := this.GetString("start_first_time")
2782 2853
 	end_time := this.GetString("end_first_time")
2854
+	storehouse_id, _ := this.GetInt64("storehouse_id")
2783 2855
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2784 2856
 	timeLayout := "2006-01-02"
2785 2857
 	loc, _ := time.LoadLocation("Local")
@@ -2802,7 +2874,13 @@ func (this *SelfDrugApiController) GetGoodWarehouseOutInfoByIdList() {
2802 2874
 		}
2803 2875
 		endTime = theTime.Unix()
2804 2876
 	}
2805
-	list, total, err := service.GetGoodWarehouseOutInfoByIdList(good_id, limit, page, orgId, startTime, endTime)
2877
+	list, total, err := service.GetGoodWarehouseOutInfoByIdList(good_id, limit, page, orgId, startTime, endTime, storehouse_id)
2878
+	//flushList, _ := service.GetStockFlushByGoodId(good_id, orgId, startTime, endTime)
2879
+
2880
+	//warehouseInfoByList, _ := service.GetGoodWarehouseInfoByList(good_id, orgId, startTime, endTime)
2881
+	//cancelStockInfoByList, _ := service.GetGoodCancelStockInfoByList(good_id, orgId, startTime, endTime)
2882
+	//warehouseOutByList,_ := service.GetGoodWarehouseOutInfoByIdListTwenty(good_id, limit, page, orgId, startTime, endTime)
2883
+
2806 2884
 	if err != nil {
2807 2885
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查寻出库信息失败")
2808 2886
 		return
@@ -2811,6 +2889,10 @@ func (this *SelfDrugApiController) GetGoodWarehouseOutInfoByIdList() {
2811 2889
 	this.ServeSuccessJSON(map[string]interface{}{
2812 2890
 		"total": total,
2813 2891
 		"list":  list,
2892
+		//"warehouseInfoByList":warehouseInfoByList,
2893
+		//"cancelStockInfoByList":cancelStockInfoByList,
2894
+		//"warehouseOutByList":warehouseOutByList,
2895
+		//"flushList":flushList,
2814 2896
 	})
2815 2897
 }
2816 2898
 
@@ -2832,8 +2914,8 @@ func (this *SelfDrugApiController) GetGoodPatientList() {
2832 2914
 func (this *SelfDrugApiController) GetWarehouseOutDetailByPatientId() {
2833 2915
 
2834 2916
 	patient_id, _ := this.GetInt64("patient_id")
2835
-	start_time := this.GetString("start_first_time")
2836
-	end_time := this.GetString("end_first_time")
2917
+	start_time := this.GetString("start_time")
2918
+	end_time := this.GetString("end_time")
2837 2919
 	limit, _ := this.GetInt64("limit")
2838 2920
 	page, _ := this.GetInt64("page")
2839 2921
 	orgId := this.GetAdminUserInfo().CurrentOrgId
@@ -2858,7 +2940,8 @@ func (this *SelfDrugApiController) GetWarehouseOutDetailByPatientId() {
2858 2940
 		}
2859 2941
 		endTime = theTime.Unix()
2860 2942
 	}
2861
-	list, total, err := service.GetWarehouseOutDetailByPatientId(orgId, patient_id, startTime, endTime, limit, page)
2943
+	list, total, err := service.GetWarehouseOutDetailByPatientIdOne(orgId, patient_id, startTime, endTime, limit, page)
2944
+	outlist, _ := service.GetWarehouseOutDetailByPatientId(orgId, patient_id, startTime, endTime)
2862 2945
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2863 2946
 	if err != nil {
2864 2947
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
@@ -2869,6 +2952,7 @@ func (this *SelfDrugApiController) GetWarehouseOutDetailByPatientId() {
2869 2952
 		"list":             list,
2870 2953
 		"manufacturerList": manufacturerList,
2871 2954
 		"total":            total,
2955
+		"outlist":          outlist,
2872 2956
 	})
2873 2957
 }
2874 2958
 
@@ -2909,6 +2993,7 @@ func (this *SelfDrugApiController) GetGoodExpiryDateQuery() {
2909 2993
 		goodIds = append(goodIds, it.ID)
2910 2994
 	}
2911 2995
 	list, total, err := service.GetGoodExpiryDateQuery(storehouse_id, expiry_type, keyword, page, limit, orgId, ids, goodIds, nowtime, endTime)
2996
+	fmt.Println("total233223322332323232323223", total)
2912 2997
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2913 2998
 
2914 2999
 	if err != nil {
@@ -2934,8 +3019,8 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
2934 3019
 
2935 3020
 	limit, _ := this.GetInt64("limit")
2936 3021
 
2937
-	start_time := this.GetString("start_first_time")
2938
-	end_time := this.GetString("end_first_time")
3022
+	start_time := this.GetString("start_time")
3023
+	end_time := this.GetString("end_time")
2939 3024
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2940 3025
 	timeLayout := "2006-01-02"
2941 3026
 	loc, _ := time.LoadLocation("Local")
@@ -2948,6 +3033,7 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
2948 3033
 		}
2949 3034
 		startTime = theTime.Unix()
2950 3035
 	}
3036
+
2951 3037
 	var endTime int64
2952 3038
 	if len(end_time) > 0 {
2953 3039
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
@@ -2959,19 +3045,129 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
2959 3045
 		endTime = theTime.Unix()
2960 3046
 	}
2961 3047
 	var ids []int64
2962
-	var infoIds []int64
3048
+	var goodIds []int64
3049
+	infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
3050
+	for _, it := range infoList {
3051
+		goodIds = append(goodIds, it.GoodId)
3052
+	}
2963 3053
 
2964 3054
 	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
2965 3055
 	for _, it := range manufacturers {
2966 3056
 		ids = append(ids, it.ID)
2967 3057
 	}
2968
-	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId)
2969
-	for _, it := range infoList {
2970
-		infoIds = append(infoIds, it.GoodId)
2971
-	}
2972 3058
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2973
-	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
2974
-	fmt.Println("list233323233233232332233232", list)
3059
+	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3060
+	for _, item := range list {
3061
+
3062
+		//获取期初结余数量
3063
+		infoList, _ := service.GetStartGoodWarehouseInfoList(item.ID, orgId, startTime)
3064
+		for _, it := range infoList {
3065
+			item.WarehousingInfoStart = append(item.WarehousingInfoStart, it)
3066
+		}
3067
+
3068
+		//获取期末结余数量
3069
+		warehouseInfoList, _ := service.GetEndGoodWarehouseInfoList(item.ID, orgId, endTime)
3070
+		for _, it := range warehouseInfoList {
3071
+			item.WarehousingInfoEnd = append(item.WarehousingInfoEnd, it)
3072
+		}
3073
+
3074
+		//获取期间增加
3075
+		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3076
+		for _, it := range goodWarehouseInfoList {
3077
+			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3078
+		}
3079
+
3080
+		//获取本期增加
3081
+		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3082
+		for _, it := range WarehouseInfoFlowList {
3083
+			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3084
+		}
3085
+		//获取本期减少
3086
+		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3087
+		for _, it := range reduceWarehouseInfoList {
3088
+			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3089
+		}
3090
+
3091
+		//获取期中减少退库
3092
+		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3093
+		for _, it := range lowInfo {
3094
+			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3095
+		}
3096
+		//
3097
+		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3098
+		for _, it := range outInfo {
3099
+			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3100
+		}
3101
+
3102
+		//获取期初结余
3103
+		info, _ := service.FindeStartFlowInfo(item.ID, orgId, startTime)
3104
+		for _, it := range info {
3105
+			item.StartFlowInfo = append(item.StartFlowInfo, it)
3106
+		}
3107
+		//获取期初结余
3108
+		flowOutInfo, _ := service.FindeStartFlowOutInfo(item.ID, orgId, startTime)
3109
+		for _, it := range flowOutInfo {
3110
+			item.StartOutFlowInfo = append(item.StartOutFlowInfo, it)
3111
+		}
3112
+
3113
+		//获取期初退库
3114
+		cancelInfo, _ := service.FindeStartCancelInfo(item.ID, orgId, startTime)
3115
+		for _, it := range cancelInfo {
3116
+			item.StartCancelFlowInfo = append(item.StartCancelFlowInfo, it)
3117
+		}
3118
+
3119
+		//获取期末结余
3120
+		flowInfo, _ := service.FindEndStartFlowInfo(item.ID, orgId, endTime)
3121
+		for _, it := range flowInfo {
3122
+			item.EndFlowInfo = append(item.EndFlowInfo, it)
3123
+		}
3124
+
3125
+		//获取期末出库
3126
+		lowOutInfo, _ := service.FindeEndFLowOutInfo(item.ID, orgId, endTime)
3127
+		for _, it := range lowOutInfo {
3128
+			item.EndFlowOutInfo = append(item.EndFlowOutInfo, it)
3129
+		}
3130
+
3131
+		//获取期末退库
3132
+		endCancelInfo, _ := service.FindEndCancelInfo(item.ID, orgId, endTime)
3133
+		for _, it := range endCancelInfo {
3134
+			item.EndCancelFLowInfo = append(item.EndCancelFLowInfo, it)
3135
+		}
3136
+
3137
+		//期初盘赢
3138
+		inventory, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, startTime)
3139
+		for _, it := range inventory {
3140
+			item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
3141
+		}
3142
+		//期初盘亏
3143
+		stockInventory, _ := service.FindStartStockInventoryLosses(item.ID, orgId, startTime)
3144
+		for _, it := range stockInventory {
3145
+			item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
3146
+		}
3147
+
3148
+		//期末盘盈
3149
+		inventoryProfit, _ := service.FindeStartStockInventoryProfit(item.ID, orgId, endTime)
3150
+		for _, it := range inventoryProfit {
3151
+			item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
3152
+		}
3153
+		//期末盘亏
3154
+		inventoryLosses, _ := service.FindStartStockInventoryLosses(item.ID, orgId, endTime)
3155
+		for _, it := range inventoryLosses {
3156
+			item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
3157
+		}
3158
+
3159
+		//期中盘盈
3160
+		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3161
+		for _, it := range profit {
3162
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3163
+		}
3164
+		//期中盘亏
3165
+		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3166
+		for _, it := range losses {
3167
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3168
+		}
3169
+	}
3170
+
2975 3171
 	if err != nil {
2976 3172
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
2977 3173
 		return
@@ -3013,13 +3209,14 @@ func (this *SelfDrugApiController) GetDrugWarehouseOutDetailByPatientId() {
3013 3209
 		}
3014 3210
 		endTime = theTime.Unix()
3015 3211
 	}
3016
-
3017
-	list, total, _ := service.GetDrugWarehouseOutDetailByPatientId(patient_id, orgId, startTime, endTime, page, limit)
3212
+	list, total, _ := service.GetDrugWarehouseOutDetailByPatientIdOne(patient_id, orgId, startTime, endTime, page, limit)
3213
+	outlist, _ := service.GetDrugWarehouseOutDetailByPatientId(patient_id, orgId, startTime, endTime)
3018 3214
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3019 3215
 	this.ServeSuccessJSON(map[string]interface{}{
3020 3216
 		"list":             list,
3021 3217
 		"total":            total,
3022 3218
 		"manufacturerList": manufacturerList,
3219
+		"outlist":          outlist,
3023 3220
 	})
3024 3221
 }
3025 3222
 
@@ -3076,3 +3273,405 @@ func (this *SelfDrugApiController) GetDrugExpiryDateQuery() {
3076 3273
 		"drugTypeList":     drugTypeList,
3077 3274
 	})
3078 3275
 }
3276
+
3277
+func (this *SelfDrugApiController) GetPurchaseDrugQuery() {
3278
+	good_type, _ := this.GetInt64("good_type")
3279
+
3280
+	keyword := this.GetString("keyword")
3281
+
3282
+	page, _ := this.GetInt64("page")
3283
+
3284
+	limit, _ := this.GetInt64("limit")
3285
+
3286
+	start_time := this.GetString("start_time")
3287
+	end_time := this.GetString("end_time")
3288
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3289
+	timeLayout := "2006-01-02"
3290
+	loc, _ := time.LoadLocation("Local")
3291
+
3292
+	var startTime int64
3293
+
3294
+	if len(start_time) > 0 {
3295
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3296
+		if err != nil {
3297
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3298
+			return
3299
+		}
3300
+		startTime = theTime.Unix()
3301
+	}
3302
+
3303
+	var endTime int64
3304
+	if len(end_time) > 0 {
3305
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3306
+		if err != nil {
3307
+			utils.ErrorLog(err.Error())
3308
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3309
+			return
3310
+		}
3311
+		endTime = theTime.Unix()
3312
+	}
3313
+	var ids []int64
3314
+	var infoIds []int64
3315
+
3316
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3317
+	for _, it := range manufacturers {
3318
+		ids = append(ids, it.ID)
3319
+	}
3320
+	infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
3321
+	for _, it := range infoList {
3322
+		infoIds = append(infoIds, it.DrugId)
3323
+	}
3324
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3325
+	list, total, err := service.GetDrugPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
3326
+
3327
+	for _, item := range list {
3328
+
3329
+		//获取期初结余入库数量
3330
+		startDrugInfo, _ := service.GetDrugWarehouseInfoStart(item.ID, orgId, startTime)
3331
+		for _, it := range startDrugInfo {
3332
+			item.DrugWarehouseInfoStart = append(item.DrugWarehouseInfoStart, it)
3333
+		}
3334
+
3335
+		//获取期初结余出库数量
3336
+		flowOutList, _ := service.GetDrugFlowOut(item.ID, orgId, startTime)
3337
+		for _, it := range flowOutList {
3338
+			item.DrugWarehouseOutInfoStart = append(item.DrugWarehouseOutInfoStart, it)
3339
+		}
3340
+
3341
+		//获取期初结余退库数量
3342
+		cancelInfo, _ := service.GetStartDrugFlowCancelInfo(item.ID, orgId, startTime)
3343
+		for _, it := range cancelInfo {
3344
+			item.WareStartStockCancelInfo = append(item.WareStartStockCancelInfo, it)
3345
+		}
3346
+
3347
+		//获取期末结余入库数量
3348
+		drugwarehouseinfoend, _ := service.DrugWarehouseInfoEnd(item.ID, orgId, endTime)
3349
+		for _, it := range drugwarehouseinfoend {
3350
+			item.DrugWarehouseInfoEnd = append(item.DrugWarehouseInfoEnd, it)
3351
+		}
3352
+
3353
+		//获取期末出库结余
3354
+		endDrugInfo, _ := service.DrugWarehouseOutInfoEnd(item.ID, orgId, endTime)
3355
+		for _, it := range endDrugInfo {
3356
+			item.DrugWarehouseOutInfoEnd = append(item.DrugWarehouseOutInfoEnd, it)
3357
+		}
3358
+
3359
+		//获取期末退库数量
3360
+		flowCancelInfo, _ := service.GetEndDrugFlowCancelInfo(item.ID, orgId, endTime)
3361
+		for _, it := range flowCancelInfo {
3362
+			item.WareEndStockCancelInfo = append(item.WareEndStockCancelInfo, it)
3363
+		}
3364
+
3365
+		//期中增加
3366
+		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
3367
+		for _, it := range drugWarehouse {
3368
+			item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
3369
+		}
3370
+
3371
+		//期中减少
3372
+		outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
3373
+		for _, it := range outInfo {
3374
+			item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
3375
+		}
3376
+
3377
+		//期中退库
3378
+		cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
3379
+		for _, it := range cancelstartInfo {
3380
+			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
3381
+		}
3382
+
3383
+		//获取期初盘盈
3384
+		startProfit, _ := service.GetDrugFlowStartProfit(item.ID, orgId, startTime)
3385
+		for _, it := range startProfit {
3386
+			item.WareStartStockInventoryProfit = append(item.WareStartStockInventoryProfit, it)
3387
+		}
3388
+		//获取期初盘亏
3389
+		startLosses, _ := service.GetDrugFlowStartLosses(item.ID, orgId, startTime)
3390
+		for _, it := range startLosses {
3391
+			item.WareStartStockInventoryLosses = append(item.WareStartStockInventoryLosses, it)
3392
+		}
3393
+		//获取期末盘盈
3394
+		endProfit, _ := service.GetDrugFlowEndProfit(item.ID, orgId, endTime)
3395
+		for _, it := range endProfit {
3396
+			item.WareEndStockInventoryProfit = append(item.WareEndStockInventoryProfit, it)
3397
+		}
3398
+		//获取期末盘亏
3399
+		losses, _ := service.GetDrugFlowEndLosses(item.ID, orgId, endTime)
3400
+		for _, it := range losses {
3401
+			item.WareEndStockInventoryLosses = append(item.WareEndStockInventoryLosses, it)
3402
+		}
3403
+
3404
+		//获取期中盘盈
3405
+		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
3406
+		for _, it := range profit {
3407
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3408
+		}
3409
+
3410
+		//获取期中盘亏
3411
+		endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
3412
+		for _, it := range endLosses {
3413
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3414
+		}
3415
+	}
3416
+	if err != nil {
3417
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
3418
+		return
3419
+	}
3420
+	var drugType = "药品类型"
3421
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3422
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3423
+
3424
+	this.ServeSuccessJSON(map[string]interface{}{
3425
+		"list":             list,
3426
+		"manufacturerList": manufacturerList,
3427
+		"total":            total,
3428
+		"drugTypeList":     drugTypeList,
3429
+	})
3430
+}
3431
+
3432
+func (this *SelfDrugApiController) GetDrugNewQuery() {
3433
+
3434
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3435
+	storehouse_id, _ := this.GetInt64("storehouse_id")
3436
+	good_type, _ := this.GetInt64("good_type")
3437
+	keyword := this.GetString("keyword")
3438
+	page, _ := this.GetInt64("page")
3439
+	limit, _ := this.GetInt64("limit")
3440
+	start_time := this.GetString("start_time")
3441
+	end_time := this.GetString("end_time")
3442
+	timeLayout := "2006-01-02"
3443
+	loc, _ := time.LoadLocation("Local")
3444
+	var startTime int64
3445
+	if len(start_time) > 0 {
3446
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3447
+		if err != nil {
3448
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3449
+			return
3450
+		}
3451
+		startTime = theTime.Unix()
3452
+	}
3453
+	var endTime int64
3454
+	if len(end_time) > 0 {
3455
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3456
+		if err != nil {
3457
+			utils.ErrorLog(err.Error())
3458
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3459
+			return
3460
+		}
3461
+		endTime = theTime.Unix()
3462
+	}
3463
+	var ids []int64
3464
+	var goodIds []int64
3465
+	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
3466
+
3467
+	//查询药品库信息
3468
+	drug, _ := service.GetBaseDrugName(orgId)
3469
+
3470
+	for _, it := range drug {
3471
+		var sum_count int64
3472
+		var limit_count int64
3473
+
3474
+		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3475
+		for _, item := range drugInfo {
3476
+			sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3477
+		}
3478
+		limit_count = it.DrugStockLimitCount * it.MinNumber
3479
+		service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3480
+	}
3481
+
3482
+	for _, it := range manufacturerList {
3483
+		ids = append(ids, it.ID)
3484
+	}
3485
+	infoList, _ := service.GetDrugWarehouseInfoByOrgId(orgId, storehouse_id)
3486
+	for _, it := range infoList {
3487
+		goodIds = append(goodIds, it.DrugId)
3488
+	}
3489
+	//list, total, err := service.GetDrugNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
3490
+
3491
+	countList, total, err := service.GetDrugStockCountList(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
3492
+
3493
+	if err != nil {
3494
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
3495
+		return
3496
+	}
3497
+	var drugType = "药品类型"
3498
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3499
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3500
+
3501
+	this.ServeSuccessJSON(map[string]interface{}{
3502
+		"total": total,
3503
+		//"list":  list,
3504
+		"drugTypeList": drugTypeList,
3505
+		"countList":    countList,
3506
+	})
3507
+}
3508
+
3509
+func (this *SelfDrugApiController) GetDrugWarehouseInfoById() {
3510
+
3511
+	drug_id, _ := this.GetInt64("drug_id")
3512
+	limit, _ := this.GetInt64("limit")
3513
+	page, _ := this.GetInt64("page")
3514
+	start_time := this.GetString("start_first_time")
3515
+	end_time := this.GetString("end_first_time")
3516
+	storehouse_id, _ := this.GetInt64("storehouse_id")
3517
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3518
+	timeLayout := "2006-01-02"
3519
+	loc, _ := time.LoadLocation("Local")
3520
+	var startTime int64
3521
+	if len(start_time) > 0 {
3522
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3523
+		if err != nil {
3524
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3525
+			return
3526
+		}
3527
+		startTime = theTime.Unix()
3528
+	}
3529
+	var endTime int64
3530
+	if len(end_time) > 0 {
3531
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3532
+		if err != nil {
3533
+			utils.ErrorLog(err.Error())
3534
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3535
+			return
3536
+		}
3537
+		endTime = theTime.Unix()
3538
+	}
3539
+	list, total, err := service.GetDrugWarehouseOutInfoByIdList(drug_id, limit, page, orgId, startTime, endTime, storehouse_id)
3540
+	flushList, _ := service.GetDrugFlowFlush(drug_id, orgId, startTime, endTime)
3541
+	flushOne, _ := service.GetDrugFlowFlushOne(drug_id, orgId, startTime, endTime)
3542
+	if err != nil {
3543
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查寻出库信息失败")
3544
+		return
3545
+	}
3546
+
3547
+	this.ServeSuccessJSON(map[string]interface{}{
3548
+		"total":        total,
3549
+		"list":         list,
3550
+		"flushList":    flushList,
3551
+		"flushListOne": flushOne,
3552
+	})
3553
+}
3554
+
3555
+func (this *SelfDrugApiController) GetSendGoodInformation() {
3556
+
3557
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3558
+	//获取入库数据
3559
+	list, _ := service.GetSendGoodInformation(orgId)
3560
+	for _, it := range list {
3561
+		//查询是否有数据
3562
+		_, errcode := service.GetStockFlush(it.StorehouseId, it.GoodId, it.OrgId)
3563
+		//获取总退库数量
3564
+		var cancel_count int64
3565
+		var out_count int64
3566
+		var act_count int64
3567
+		//退库总数量
3568
+		cancellist, _ := service.GetAllCancelCount(it.StorehouseId, it.GoodId, it.OrgId)
3569
+		for _, item := range cancellist {
3570
+			cancel_count += item.Count
3571
+		}
3572
+		//出库总数量
3573
+		outlist, _ := service.GetAllStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
3574
+		for _, item := range outlist {
3575
+			out_count += item.Count
3576
+		}
3577
+
3578
+		//实际出库总数量
3579
+		actlist, _ := service.GetActStockOutCount(it.StorehouseId, it.GoodId, it.OrgId)
3580
+		for _, item := range actlist {
3581
+			act_count += item.Count
3582
+		}
3583
+
3584
+		if errcode == gorm.ErrRecordNotFound {
3585
+			good := models.XtGoodStockCount{
3586
+				UserOrgId:        it.OrgId,
3587
+				GoodId:           it.GoodId,
3588
+				StorehouseId:     it.StorehouseId,
3589
+				Status:           1,
3590
+				Ctime:            time.Now().Unix(),
3591
+				Mtime:            0,
3592
+				StockInCount:     it.WarehousingCount,
3593
+				StockOutCount:    out_count - cancel_count,
3594
+				StockCancelCount: cancel_count,
3595
+				FlushCount:       it.StockCount,
3596
+				StockActOutCount: act_count,
3597
+			}
3598
+			service.CreateGoodCountSix(good)
3599
+		}
3600
+		if errcode == nil {
3601
+			service.UpdateGoodCount(it.WarehousingCount, it.StockCount, out_count, it.StorehouseId, it.GoodId, it.OrgId, cancel_count, act_count)
3602
+		}
3603
+	}
3604
+
3605
+	this.ServeSuccessJSON(map[string]interface{}{
3606
+		"msg": "1",
3607
+	})
3608
+}
3609
+
3610
+func (this *SelfDrugApiController) GetDrugInitDetailList() {
3611
+
3612
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3613
+
3614
+	//获取所有的入库仓库
3615
+	list, _ := service.GetDrugWarehouseInfoStorehouseList(orgId)
3616
+	for _, item := range list {
3617
+		//查询该药品该仓库是否有数据
3618
+		drug, _ := service.GetDrugStockCout(item.DrugId, item.StorehouseId, item.OrgId)
3619
+
3620
+		//查询该仓库该药品的入库数量
3621
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
3622
+
3623
+		var sum_in_count int64
3624
+		var flush_count int64
3625
+		var sum_out_count int64
3626
+		var cancel_out_count int64
3627
+		//查询入库数量和剩余库存
3628
+		infolist, _ := service.GetDrugWarehouseInfoByStorehouseId(item.StorehouseId, item.DrugId, item.OrgId)
3629
+		for _, it := range infolist {
3630
+			if it.MaxUnit == medical.MaxUnit {
3631
+				it.WarehousingCount = it.WarehousingCount * medical.MinNumber
3632
+				it.StockMaxNumber = it.StockMaxNumber * medical.MinNumber
3633
+			}
3634
+			sum_in_count += it.WarehousingCount
3635
+			flush_count += it.StockMaxNumber + it.StockMinNumber
3636
+		}
3637
+
3638
+		//获取出库数量
3639
+		outinfolist, _ := service.GetDrugFlowStockOutCount(item.StorehouseId, item.DrugId, item.OrgId)
3640
+		for _, it := range outinfolist {
3641
+			if it.MaxUnit == medical.MaxUnit {
3642
+				it.Count = it.Count * medical.MinNumber
3643
+			}
3644
+			sum_out_count += it.Count
3645
+		}
3646
+
3647
+		//获取退库数量
3648
+		cancelinfolist, _ := service.GetDrugFlowStockCancelCount(item.StorehouseId, item.DrugId, item.OrgId)
3649
+		for _, it := range cancelinfolist {
3650
+			if it.MaxUnit == medical.MaxUnit {
3651
+				it.Count = it.Count * medical.MinNumber
3652
+			}
3653
+			cancel_out_count += it.Count
3654
+		}
3655
+
3656
+		//新增
3657
+		if drug.ID == 0 {
3658
+			drugstock := models.XtDrugStockCount{
3659
+				UserOrgId:      orgId,
3660
+				StorehouseId:   item.StorehouseId,
3661
+				SumInCount:     sum_in_count,
3662
+				SumOutCount:    sum_out_count - cancel_out_count,
3663
+				SumCancelCount: cancel_out_count,
3664
+				DrugId:         item.DrugId,
3665
+				Ctime:          time.Now().Unix(),
3666
+				Mtime:          0,
3667
+				Status:         1,
3668
+				FlushCount:     flush_count,
3669
+				SumActOutCount: sum_out_count,
3670
+			}
3671
+			service.CreateDrugStockCount(drugstock)
3672
+		}
3673
+	}
3674
+	this.ServeSuccessJSON(map[string]interface{}{
3675
+		"msg": "1",
3676
+	})
3677
+}

+ 0 - 4
controllers/sign_weigh_api_controller.go 查看文件

@@ -356,11 +356,9 @@ func (c *SignWeighAPIController) SaveData() {
356 356
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
357 357
 	temperature, _ := c.GetFloat("temperature", 0)
358 358
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
359
-	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
360 359
 	breathing_rate := c.GetString("breathing_rate")
361 360
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
362 361
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
363
-
364 362
 	predialysisevaluation := &models.PredialysisEvaluation{
365 363
 		WeightBefore:           weight_before,
366 364
 		DryWeight:              dry_weight,
@@ -384,11 +382,9 @@ func (c *SignWeighAPIController) EditData() {
384 382
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
385 383
 	temperature, _ := c.GetFloat("temperature", 0)
386 384
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
387
-	//breathing_rate, _ := c.GetFloat("breathing_rate", 0)
388 385
 	breathing_rate := c.GetString("breathing_rate")
389 386
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
390 387
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
391
-
392 388
 	assessmentafterdislysis := &models.AssessmentAfterDislysis{
393 389
 		WeightAfter:            weight_after,
394 390
 		DryWeight:              dry_weight,

+ 425 - 21
controllers/stock_in_api_controller.go 查看文件

@@ -4671,7 +4671,8 @@ func (this *StockManagerApiController) GetStockListById() {
4671 4671
 	loc, _ := time.LoadLocation("Local")
4672 4672
 	start_time := this.GetString("start_time")
4673 4673
 	end_time := this.GetString("end_time")
4674
-
4674
+	start_first_time := this.GetString("start_first_time")
4675
+	end_first_time := this.GetString("end_first_time")
4675 4676
 	var startTime int64
4676 4677
 	if len(start_time) > 0 {
4677 4678
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -4691,8 +4692,28 @@ func (this *StockManagerApiController) GetStockListById() {
4691 4692
 		}
4692 4693
 		endTime = theTime.Unix()
4693 4694
 	}
4695
+
4696
+	var startFistTime int64
4697
+	if len(start_first_time) > 0 {
4698
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_first_time+" 00:00:00", loc)
4699
+		if err != nil {
4700
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4701
+			return
4702
+		}
4703
+		startFistTime = theTime.Unix()
4704
+	}
4705
+	var endFirstTime int64
4706
+	if len(end_first_time) > 0 {
4707
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_first_time+" 23:59:59", loc)
4708
+		if err != nil {
4709
+			utils.ErrorLog(err.Error())
4710
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4711
+			return
4712
+		}
4713
+		endFirstTime = theTime.Unix()
4714
+	}
4694 4715
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4695
-	list, total, _ := service.GetStockListById(id, orgId, limit, page, startTime, endTime)
4716
+	list, total, _ := service.GetStockListById(id, orgId, limit, page, startTime, endTime, startFistTime, endFirstTime)
4696 4717
 	houseList, _ := service.GetAllStoreHouseList(orgId)
4697 4718
 	good, _ := service.GetGoodInformationByGoodId(id)
4698 4719
 	this.ServeSuccessJSON(map[string]interface{}{
@@ -4792,9 +4813,16 @@ func (this *StockManagerApiController) GetOrderDetialByOrderId() {
4792 4813
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4793 4814
 	order, _ := service.GetWarehouseOutOrder(idsArray, orgId)
4794 4815
 	list, _ := service.GetOrderDetialByOrderIdOne(idsArray, orgId)
4816
+	stockFlowListGroup, _ := service.GetOrderDetailStockFlowByStorehouseById(idsArray, orgId)
4817
+	stockFlowList, _ := service.GetOrderDetailStockFlow(idsArray, orgId)
4818
+	//获取耗材退库数据
4819
+	cancelInfolist, _ := service.GetOrderStockFlow(idsArray, orgId)
4795 4820
 	this.ServeSuccessJSON(map[string]interface{}{
4796
-		"list":  list,
4797
-		"order": order,
4821
+		"list":               list,
4822
+		"order":              order,
4823
+		"stockFlowList":      stockFlowList,
4824
+		"stockFlowListGroup": stockFlowListGroup,
4825
+		"cancelInfolist":     cancelInfolist,
4798 4826
 	})
4799 4827
 }
4800 4828
 
@@ -4810,13 +4838,17 @@ func (this *StockManagerApiController) GetOrderDetailById() {
4810 4838
 	//手动出库
4811 4839
 	info, _ := service.GetWarehouseOutInfoById(id, good_id)
4812 4840
 
4841
+	//出库数据
4813 4842
 	stockFlowList, err := service.GetStockFlowBatchNumberOne(id, good_id)
4843
+	//退库数据
4844
+	cancelInfo, err := service.GetStockFlowCancelInfo(id, good_id)
4814 4845
 	if err == nil {
4815 4846
 		this.ServeSuccessJSON(map[string]interface{}{
4816 4847
 			"list":          userDetails,
4817 4848
 			"total":         total,
4818 4849
 			"info":          info,
4819 4850
 			"stockFlowList": stockFlowList,
4851
+			"cancelInfo":    cancelInfo,
4820 4852
 		})
4821 4853
 	} else {
4822 4854
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -6727,6 +6759,12 @@ func (this *StockManagerApiController) SaveStockInventoryList() {
6727 6759
 			}
6728 6760
 			service.UpdateGoodByGoodId(good_id, sum_count, sum_in_count, warehosueinfos.OrgId)
6729 6761
 
6762
+			goodListOne, _ := service.GetSumGoodList(orgId, storeConfig.StorehouseOutInfo, good_id)
6763
+			var flush_count int64
6764
+			for _, it := range goodListOne {
6765
+				flush_count += it.StockCount
6766
+			}
6767
+			service.UpdateSumGood(orgId, storeConfig.StorehouseOutInfo, good_id, flush_count)
6730 6768
 			this.ServeSuccessJSON(map[string]interface{}{
6731 6769
 				"inventory": inventory,
6732 6770
 			})
@@ -6929,10 +6967,42 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
6929 6967
 
6930 6968
 	id, _ := this.GetInt64("id")
6931 6969
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6932
-
6933
-	warehouseOut, _ := service.GetWarehouseById(id)
6970
+	creater := this.GetAdminUserInfo().AdminUser.Id
6971
+	warehouseOut, errcode := service.GetWarehouseById(id)
6972
+	if errcode != nil {
6973
+		goodErrcode := models.XtGoodErrcode{
6974
+			UserOrgId:      orgId,
6975
+			Errcode:        "查询审核出库单报错",
6976
+			GoodId:         0,
6977
+			Status:         0,
6978
+			Ctime:          0,
6979
+			Mtime:          0,
6980
+			Count:          0,
6981
+			StockCount:     0,
6982
+			Creater:        creater,
6983
+			BatchNumberId:  0,
6984
+			WarehouseOutId: 0,
6985
+		}
6986
+		service.CreateGoodErrcode(goodErrcode)
6987
+	}
6934 6988
 	//查询已审核的单据
6935
-	warehousingOutInfo, _ := service.GetWarehouseOutById(id, orgId)
6989
+	warehousingOutInfo, erroce := service.GetWarehouseOutById(id, orgId)
6990
+	if erroce != nil {
6991
+		goodErrcode := models.XtGoodErrcode{
6992
+			UserOrgId:      orgId,
6993
+			Errcode:        "查询已审核出库详情单报错",
6994
+			GoodId:         0,
6995
+			Status:         0,
6996
+			Ctime:          0,
6997
+			Mtime:          0,
6998
+			Count:          0,
6999
+			StockCount:     0,
7000
+			Creater:        creater,
7001
+			BatchNumberId:  0,
7002
+			WarehouseOutId: 0,
7003
+		}
7004
+		service.CreateGoodErrcode(goodErrcode)
7005
+	}
6936 7006
 	////出库逻辑
6937 7007
 	for _, item := range warehousingOutInfo {
6938 7008
 		// 查询该耗材是否有库存
@@ -6941,6 +7011,21 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
6941 7011
 
6942 7012
 		// 如果出库数量大于该批次剩余库存数量
6943 7013
 		if item.Count > warehouseOne.StockCount {
7014
+
7015
+			goodErrcode := models.XtGoodErrcode{
7016
+				UserOrgId:      orgId,
7017
+				Errcode:        "出库数量大于该批次剩余库存",
7018
+				GoodId:         0,
7019
+				Status:         0,
7020
+				Ctime:          0,
7021
+				Mtime:          0,
7022
+				Count:          0,
7023
+				StockCount:     0,
7024
+				Creater:        creater,
7025
+				BatchNumberId:  warehouseOne.ID,
7026
+				WarehouseOutId: item.ID,
7027
+			}
7028
+			service.CreateGoodErrcode(goodErrcode)
6944 7029
 			goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
6945 7030
 			this.ServeSuccessJSON(map[string]interface{}{
6946 7031
 				"msg":                "1",
@@ -6953,8 +7038,50 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
6953 7038
 
6954 7039
 	}
6955 7040
 	for _, item := range warehousingOutInfo {
7041
+
6956 7042
 		creater := this.GetAdminUserInfo().AdminUser.Id
6957
-		service.ConsumablesDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater)
7043
+
7044
+		//出库
7045
+		err := service.ConsumablesDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater)
7046
+		if err != nil {
7047
+			goodErrcode := models.XtGoodErrcode{
7048
+				UserOrgId:      item.OrgId,
7049
+				Errcode:        "调用出库接口报错",
7050
+				GoodId:         item.GoodId,
7051
+				Status:         1,
7052
+				Ctime:          time.Now().Unix(),
7053
+				Mtime:          0,
7054
+				Count:          0,
7055
+				StockCount:     0,
7056
+				Creater:        creater,
7057
+				BatchNumberId:  0,
7058
+				WarehouseOutId: 0,
7059
+			}
7060
+			service.CreateGoodErrcode(goodErrcode)
7061
+		}
7062
+
7063
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7064
+		var flush_count int64
7065
+		for _, it := range goodList {
7066
+			flush_count += it.StockCount
7067
+		}
7068
+		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7069
+		if errs != nil {
7070
+			goodErrcode := models.XtGoodErrcode{
7071
+				UserOrgId:      item.OrgId,
7072
+				Errcode:        "手动出库更新剩余出库失败",
7073
+				GoodId:         item.GoodId,
7074
+				Status:         1,
7075
+				Ctime:          time.Now().Unix(),
7076
+				Mtime:          0,
7077
+				Count:          0,
7078
+				StockCount:     0,
7079
+				Creater:        creater,
7080
+				BatchNumberId:  0,
7081
+				WarehouseOutId: 0,
7082
+			}
7083
+			service.CreateGoodErrcode(goodErrcode)
7084
+		}
6958 7085
 
6959 7086
 		orgId := this.GetAdminUserInfo().CurrentOrgId
6960 7087
 		//查询默认仓库
@@ -6965,12 +7092,43 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
6965 7092
 			total_count += it.StockCount
6966 7093
 		}
6967 7094
 		//基础库扣减库存
6968
-		service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7095
+		errsum := service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7096
+		if errsum != nil {
7097
+			goodErrcode := models.XtGoodErrcode{
7098
+				UserOrgId:      item.OrgId,
7099
+				Errcode:        "基础库扣减库存报错",
7100
+				GoodId:         item.GoodId,
7101
+				Status:         1,
7102
+				Ctime:          time.Now().Unix(),
7103
+				Mtime:          0,
7104
+				Count:          0,
7105
+				StockCount:     0,
7106
+				Creater:        creater,
7107
+				BatchNumberId:  0,
7108
+				WarehouseOutId: 0,
7109
+			}
7110
+			service.CreateGoodErrcode(goodErrcode)
7111
+		}
6969 7112
 	}
6970 7113
 
6971 7114
 	//审核单据
6972 7115
 	err := service.UpdatedWarehouseOut(id)
6973
-
7116
+	if err != nil {
7117
+		goodErrcode := models.XtGoodErrcode{
7118
+			UserOrgId:      orgId,
7119
+			Errcode:        "审核单据报错",
7120
+			GoodId:         0,
7121
+			Status:         1,
7122
+			Ctime:          time.Now().Unix(),
7123
+			Mtime:          0,
7124
+			Count:          0,
7125
+			StockCount:     0,
7126
+			Creater:        creater,
7127
+			BatchNumberId:  0,
7128
+			WarehouseOutId: 0,
7129
+		}
7130
+		service.CreateGoodErrcode(goodErrcode)
7131
+	}
6974 7132
 	if err == nil {
6975 7133
 		this.ServeSuccessJSON(map[string]interface{}{
6976 7134
 			"msg":                "2",
@@ -6986,24 +7144,162 @@ func (this *StockManagerApiController) ReturnCheckWarehouseOut() {
6986 7144
 
6987 7145
 	id, _ := this.GetInt64("id")
6988 7146
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7147
+	creater := this.GetAdminUserInfo().AdminUser.Id
6989 7148
 	// 查询出库数据
6990 7149
 	list, err := service.GetWarehouseOutById(id, orgId)
7150
+	if err != nil {
7151
+		goodErrcode := models.XtGoodErrcode{
7152
+			UserOrgId:      orgId,
7153
+			Errcode:        "反审核查询出库单报错",
7154
+			GoodId:         0,
7155
+			Status:         1,
7156
+			Ctime:          time.Now().Unix(),
7157
+			Mtime:          0,
7158
+			Count:          0,
7159
+			StockCount:     0,
7160
+			Creater:        creater,
7161
+			BatchNumberId:  0,
7162
+			WarehouseOutId: 0,
7163
+		}
7164
+		service.CreateGoodErrcode(goodErrcode)
7165
+	}
6991 7166
 	for _, item := range list {
6992 7167
 		//回退库存
6993
-		service.UpdateaGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId)
6994
-
7168
+		err := service.UpdateaGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId)
7169
+		if err != nil {
7170
+			goodErrcode := models.XtGoodErrcode{
7171
+				UserOrgId:      orgId,
7172
+				Errcode:        "反审核回退库存报错",
7173
+				GoodId:         0,
7174
+				Status:         1,
7175
+				Ctime:          time.Now().Unix(),
7176
+				Mtime:          0,
7177
+				Count:          0,
7178
+				StockCount:     0,
7179
+				Creater:        creater,
7180
+				BatchNumberId:  0,
7181
+				WarehouseOutId: 0,
7182
+			}
7183
+			service.CreateGoodErrcode(goodErrcode)
7184
+		}
6995 7185
 		//查询默认仓库
6996
-		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
6997
-		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7186
+		storeHouseConfig, errs := service.GetAllStoreHouseConfig(orgId)
7187
+		if errs != nil {
7188
+			goodErrcode := models.XtGoodErrcode{
7189
+				UserOrgId:      orgId,
7190
+				Errcode:        "反审核查询默认仓库报错",
7191
+				GoodId:         0,
7192
+				Status:         1,
7193
+				Ctime:          time.Now().Unix(),
7194
+				Mtime:          0,
7195
+				Count:          0,
7196
+				StockCount:     0,
7197
+				Creater:        creater,
7198
+				BatchNumberId:  0,
7199
+				WarehouseOutId: 0,
7200
+			}
7201
+			service.CreateGoodErrcode(goodErrcode)
7202
+		}
7203
+		stockList, errcodes := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7204
+		if errcodes != nil {
7205
+			goodErrcode := models.XtGoodErrcode{
7206
+				UserOrgId:      orgId,
7207
+				Errcode:        "反审核查询默认仓库库存报错",
7208
+				GoodId:         0,
7209
+				Status:         1,
7210
+				Ctime:          time.Now().Unix(),
7211
+				Mtime:          0,
7212
+				Count:          0,
7213
+				StockCount:     0,
7214
+				Creater:        creater,
7215
+				BatchNumberId:  0,
7216
+				WarehouseOutId: 0,
7217
+			}
7218
+			service.CreateGoodErrcode(goodErrcode)
7219
+		}
6998 7220
 		var total_count int64
6999 7221
 		for _, it := range stockList {
7000 7222
 			total_count += it.StockCount
7001 7223
 		}
7002 7224
 		//基础库扣减库存
7003
-		service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7225
+		errs = service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
7226
+		if errs != nil {
7227
+			goodErrcode := models.XtGoodErrcode{
7228
+				UserOrgId:      orgId,
7229
+				Errcode:        "反审核基础库扣减库存报错",
7230
+				GoodId:         0,
7231
+				Status:         1,
7232
+				Ctime:          time.Now().Unix(),
7233
+				Mtime:          0,
7234
+				Count:          0,
7235
+				StockCount:     0,
7236
+				Creater:        creater,
7237
+				BatchNumberId:  0,
7238
+				WarehouseOutId: 0,
7239
+			}
7240
+			service.CreateGoodErrcode(goodErrcode)
7241
+		}
7242
+
7243
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7244
+		var flush_count int64
7245
+		for _, it := range goodList {
7246
+			flush_count += it.StockCount
7247
+		}
7248
+		erros := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7249
+		if erros != nil {
7250
+			goodErrcode := models.XtGoodErrcode{
7251
+				UserOrgId:      orgId,
7252
+				Errcode:        "手动出库更新剩余库存报错",
7253
+				GoodId:         0,
7254
+				Status:         1,
7255
+				Ctime:          time.Now().Unix(),
7256
+				Mtime:          0,
7257
+				Count:          0,
7258
+				StockCount:     0,
7259
+				Creater:        creater,
7260
+				BatchNumberId:  0,
7261
+				WarehouseOutId: 0,
7262
+			}
7263
+			service.CreateGoodErrcode(goodErrcode)
7264
+		}
7265
+		//扣减出库数据
7266
+		errcoeds := service.ModifyReduceGoodSumCount(item.StorehouseId, item.Count, orgId, item.GoodId)
7267
+		if errcoeds != nil {
7268
+			goodErrcode := models.XtGoodErrcode{
7269
+				UserOrgId:      orgId,
7270
+				Errcode:        "反审核扣减出库数据报错",
7271
+				GoodId:         0,
7272
+				Status:         1,
7273
+				Ctime:          time.Now().Unix(),
7274
+				Mtime:          0,
7275
+				Count:          0,
7276
+				StockCount:     0,
7277
+				Creater:        creater,
7278
+				BatchNumberId:  0,
7279
+				WarehouseOutId: 0,
7280
+			}
7281
+			service.CreateGoodErrcode(goodErrcode)
7282
+		}
7283
+
7004 7284
 	}
7005 7285
 	//删除流水,改变审核状态
7006
-	service.ModifyGoodWarehouseOut(id)
7286
+	errcos := service.ModifyGoodWarehouseOut(id)
7287
+	if errcos != nil {
7288
+		goodErrcode := models.XtGoodErrcode{
7289
+			UserOrgId:      orgId,
7290
+			Errcode:        "反审核删除流水,改变审核状态报错",
7291
+			GoodId:         0,
7292
+			Status:         1,
7293
+			Ctime:          time.Now().Unix(),
7294
+			Mtime:          0,
7295
+			Count:          0,
7296
+			StockCount:     0,
7297
+			Creater:        creater,
7298
+			BatchNumberId:  0,
7299
+			WarehouseOutId: 0,
7300
+		}
7301
+		service.CreateGoodErrcode(goodErrcode)
7302
+	}
7007 7303
 
7008 7304
 	if err == nil {
7009 7305
 		this.ServeSuccessJSON(map[string]interface{}{
@@ -7061,18 +7357,50 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7061 7357
 				BuyPrice:                item.Price,
7062 7358
 				StockCount:              "",
7063 7359
 				BatchNumberCount:        item.WarehousingCount,
7360
+				IsCheck:                 1,
7064 7361
 			}
7065 7362
 			//创建出库流水
7066 7363
 			service.CreateStockFlowOne(stockFlow)
7364
+
7067 7365
 			orgId := this.GetAdminUserInfo().CurrentOrgId
7068 7366
 			//查询该耗材剩余库存库
7069 7367
 			stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7070 7368
 			var total_count int64
7369
+			var sum_in_count int64
7071 7370
 			for _, it := range stockList {
7072 7371
 				total_count += it.StockCount
7372
+				sum_in_count += it.WarehousingCount
7073 7373
 			}
7074 7374
 			//基础库插入数据
7075
-			service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId)
7375
+			service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count)
7376
+
7377
+			//查询该仓库是否有数据
7378
+			_, errcode := service.GetGoodStockCount(orgId, item.StorehouseId, item.GoodId)
7379
+			goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7380
+			var flush_count int64
7381
+			for _, it := range goodList {
7382
+				flush_count += it.StockCount
7383
+			}
7384
+			if errcode == gorm.ErrRecordNotFound {
7385
+
7386
+				goodCount := models.XtGoodStockCount{
7387
+					UserOrgId:        orgId,
7388
+					GoodId:           item.GoodId,
7389
+					StorehouseId:     item.StorehouseId,
7390
+					Status:           1,
7391
+					Ctime:            time.Now().Unix(),
7392
+					Mtime:            time.Now().Unix(),
7393
+					StockInCount:     item.WarehousingCount,
7394
+					StockOutCount:    0,
7395
+					StockCancelCount: 0,
7396
+					FlushCount:       flush_count,
7397
+					StockActOutCount: 0,
7398
+				}
7399
+				service.CreateGoodCount(goodCount)
7400
+			}
7401
+			if errcode == nil {
7402
+				service.UpdateGoodStockCount(orgId, item.StorehouseId, item.GoodId, item.WarehousingCount, flush_count)
7403
+			}
7076 7404
 		}
7077 7405
 	}
7078 7406
 
@@ -7100,20 +7428,32 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
7100 7428
 	}
7101 7429
 	for _, item := range list {
7102 7430
 
7103
-		//退库
7431
+		//扣减数量
7104 7432
 		service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
7433
+
7105 7434
 		//删除流水
7106 7435
 		service.UpdateWarehouseInfoFlow(item.ID)
7107 7436
 
7437
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7438
+		var flush_count int64
7439
+		for _, it := range goodList {
7440
+			flush_count += it.StockCount
7441
+		}
7442
+
7443
+		//扣减数量
7444
+		service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
7445
+
7108 7446
 		//查询默认仓库
7109 7447
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7110 7448
 		//查询该耗材剩余多少库存
7111 7449
 		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
7112 7450
 		var sum_count int64
7451
+		var sum_in_count int64
7113 7452
 		for _, it := range stockList {
7114 7453
 			sum_count += it.StockCount
7454
+			sum_in_count += it.WarehousingCount
7115 7455
 		}
7116
-		service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId)
7456
+		service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
7117 7457
 	}
7118 7458
 	err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
7119 7459
 	if err == nil {
@@ -7170,7 +7510,7 @@ func (this *StockManagerApiController) CheckStockWarehouseInfo() {
7170 7510
 
7171 7511
 		stockFlow := models.VmStockFlow{
7172 7512
 			ID:                        0,
7173
-			WarehousingId:             0,
7513
+			WarehousingId:             item.WarehouseInfoId,
7174 7514
 			GoodId:                    item.GoodId,
7175 7515
 			Number:                    item.Number,
7176 7516
 			LicenseNumber:             "",
@@ -7194,7 +7534,7 @@ func (this *StockManagerApiController) CheckStockWarehouseInfo() {
7194 7534
 			Ctime:                     time.Now().Unix(),
7195 7535
 			Mtime:                     0,
7196 7536
 			Price:                     item.Price,
7197
-			WarehousingDetailId:       0,
7537
+			WarehousingDetailId:       item.WarehouseInfoId,
7198 7538
 			WarehouseOutDetailId:      0,
7199 7539
 			CancelOutDetailId:         item.ID,
7200 7540
 			ProductDate:               item.ProductDate,
@@ -7211,6 +7551,7 @@ func (this *StockManagerApiController) CheckStockWarehouseInfo() {
7211 7551
 			StockCount:                "",
7212 7552
 		}
7213 7553
 		service.CreateStockFlowOne(stockFlow)
7554
+		service.ModifyAddCancelCount(item.Count, item.GoodId)
7214 7555
 	}
7215 7556
 
7216 7557
 	cancelStock := models.CancelStock{
@@ -7222,7 +7563,36 @@ func (this *StockManagerApiController) CheckStockWarehouseInfo() {
7222 7563
 	cancellist, _ := service.GetCancelStockInfoById(cancel_stock_id, orgId)
7223 7564
 	for _, item := range cancellist {
7224 7565
 		service.UpdateCancelStockNumber(item.Count, item.WarehouseInfoId, orgId)
7566
+
7225 7567
 		service.UpdateGoodSumCount(item.Count, item.GoodId, orgId)
7568
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7569
+
7570
+		service.UpdateSumAddCancelCount(orgId, item.GoodId, item.StorehouseId, item.Count)
7571
+		var flush_count int64
7572
+		for _, it := range goodList {
7573
+			flush_count += it.StockCount
7574
+		}
7575
+		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7576
+
7577
+		//出库数量减少
7578
+		service.ModifyAddGoodSumCount(item.StorehouseId, item.Count, orgId, item.GoodId)
7579
+		if errs != nil {
7580
+			goodErrcode := models.XtGoodErrcode{
7581
+				UserOrgId:      item.OrgId,
7582
+				Errcode:        "手动退库更新剩余出库失败",
7583
+				GoodId:         item.GoodId,
7584
+				Status:         1,
7585
+				Ctime:          time.Now().Unix(),
7586
+				Mtime:          0,
7587
+				Count:          0,
7588
+				StockCount:     0,
7589
+				Creater:        creater,
7590
+				BatchNumberId:  0,
7591
+				WarehouseOutId: 0,
7592
+			}
7593
+			service.CreateGoodErrcode(goodErrcode)
7594
+		}
7595
+
7226 7596
 	}
7227 7597
 	this.ServeSuccessJSON(map[string]interface{}{
7228 7598
 		"msg":                "1",
@@ -7235,15 +7605,49 @@ func (this *StockManagerApiController) CheckStockWarehouseInfo() {
7235 7605
 func (this *StockManagerApiController) CheckReturnStockWarehouseInfo() {
7236 7606
 
7237 7607
 	cancel_stock_id, _ := this.GetInt64("cancel_stock_id")
7608
+
7238 7609
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7239 7610
 	cancelStock := models.CancelStock{
7240 7611
 		IsCheck: 2,
7241 7612
 	}
7242 7613
 	list, _ := service.GetCancelStockInfoListById(cancel_stock_id, orgId)
7614
+	creater := this.GetAdminUserInfo().AdminUser.Id
7243 7615
 	for _, item := range list {
7244 7616
 		//回退库存
7245 7617
 		service.UpdateStockNumberWarehouseInfo(item.WarehouseInfoId, item.GoodId, item.OrgId, item.Count)
7618
+
7246 7619
 		service.UpdateStockWarehouseInfoStockFlow(item.ID, orgId, item.GoodId)
7620
+
7621
+		//退库数量增加
7622
+		service.UpdateSumReduceCancelCount(orgId, item.GoodId, item.StorehouseId, item.Count)
7623
+
7624
+		goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
7625
+		var flush_count int64
7626
+		for _, it := range goodList {
7627
+			flush_count += it.StockCount
7628
+		}
7629
+		errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
7630
+
7631
+		//出库数量增加
7632
+		service.UpdateSumAddOutCount(orgId, item.GoodId, item.StorehouseId, item.Count)
7633
+
7634
+		if errs != nil {
7635
+			goodErrcode := models.XtGoodErrcode{
7636
+				UserOrgId:      item.OrgId,
7637
+				Errcode:        "手动退库反审核更新剩余出库失败",
7638
+				GoodId:         item.GoodId,
7639
+				Status:         1,
7640
+				Ctime:          time.Now().Unix(),
7641
+				Mtime:          0,
7642
+				Count:          0,
7643
+				StockCount:     0,
7644
+				Creater:        creater,
7645
+				BatchNumberId:  0,
7646
+				WarehouseOutId: 0,
7647
+			}
7648
+			service.CreateGoodErrcode(goodErrcode)
7649
+		}
7650
+
7247 7651
 	}
7248 7652
 	err := service.UpdateStockWarehouseInfo(cancel_stock_id, orgId, cancelStock)
7249 7653
 

+ 76 - 5
controllers/supply_order_api_contorller.go 查看文件

@@ -2391,6 +2391,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2391 2391
 
2392 2392
 	for _, item := range warehousingInfo {
2393 2393
 		service.CreatedWarehouseingDetail(item)
2394
+
2394 2395
 		//查询该机构默认仓库
2395 2396
 		storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
2396 2397
 		//查询剩余库存
@@ -2402,7 +2403,11 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2402 2403
 			sum_in_count += item.WarehousingCount
2403 2404
 		}
2404 2405
 		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
2406
+		//增加入库数量
2407
+		service.AddGoodSumInCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, item.WarehousingCount)
2405 2408
 
2409
+		//更新剩余库存
2410
+		service.UpdateGoodFlushCount(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId, sum_count)
2406 2411
 		warehousinginfo, _ := service.GetLastWarehousingInfo(item.GoodId)
2407 2412
 		flow := models.VmStockFlow{
2408 2413
 			WarehousingOrder:          item.WarehousingOrder,
@@ -2453,6 +2458,8 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2453 2458
 		}
2454 2459
 		service.UpdateMedicalSumCount(items.DrugId, sum_count, sum_in_count, items.OrgId)
2455 2460
 
2461
+		//更新入库数量和剩余库存
2462
+		service.UpdateDrugCount(houseConfig.DrugStorehouseOut, items.OrgId, items.DrugId, sum_in_count, sum_count)
2456 2463
 	}
2457 2464
 	fmt.Println(errs)
2458 2465
 	for _, items := range drugFlow {
@@ -3246,6 +3253,9 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
3246 3253
 					sum_in_count += it.WarehousingCount
3247 3254
 				}
3248 3255
 				service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3256
+
3257
+				//更新库存
3258
+				service.UpdateDrugCount(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId, sum_in_count, sum_count)
3249 3259
 			}
3250 3260
 		} else {
3251 3261
 			for _, it := range goodOrder {
@@ -3540,11 +3550,24 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3540 3550
 				service.AutoDrugDeliverInfoNight(orgId, prescribingNumber, &warehouseOut, &drup, warehouseOutInfo, warehouse_out_id, id)
3541 3551
 			}
3542 3552
 
3543
-			//修改原数据
3544
-			/*	orderInfo := models.SpSupplierWarehousingCancelOrder{
3545
-					SourceCount: item.SupplyCount - item.SourceCount,
3546
-				}
3547
-				service.UpdateSupplyCancelById(item.ID, orderInfo)*/
3553
+			//查询默认仓库
3554
+			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3555
+			//查询默认仓库剩余多少库存
3556
+			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, drup.ID)
3557
+			var sum_count int64
3558
+			var sum_in_count int64
3559
+			for _, it := range list {
3560
+				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3561
+				if it.MaxUnit == baseDrug.MaxUnit {
3562
+					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3563
+					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3564
+
3565
+				}
3566
+				sum_count += it.StockMaxNumber + it.StockMinNumber
3567
+				sum_in_count += it.WarehousingCount
3568
+			}
3569
+			service.UpdateDrugCountOne(houseConfig.DrugStorehouseOut, orgId, drup.ID, sum_count)
3570
+
3548 3571
 		}
3549 3572
 
3550 3573
 		//耗材
@@ -3638,6 +3661,17 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3638 3661
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
3639 3662
 				return
3640 3663
 			}
3664
+			//查询该机构默认仓库
3665
+			storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3666
+			//查询剩余库存
3667
+			goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.ProjectId, orgId)
3668
+			var sum_count int64
3669
+			for _, item := range goodList {
3670
+				sum_count += item.StockCount
3671
+			}
3672
+			//更新剩余库存
3673
+			service.UpdateGoodFlushCount(storeConfig.StorehouseOutInfo, item.ProjectId, orgId, sum_count)
3674
+
3641 3675
 		}
3642 3676
 	}
3643 3677
 	cancel := models.SpSupplierWarehouseCancel{
@@ -3723,6 +3757,8 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3723 3757
 	//获取退库单据日期
3724 3758
 	cancel, _ := service.GetReturnOrderById(id)
3725 3759
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3760
+
3761
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3726 3762
 	if err == nil {
3727 3763
 		//获取退库单详情
3728 3764
 		list, _ := service.GetSupplyCancelOrderDetail(id, orgId)
@@ -3742,6 +3778,8 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3742 3778
 					var sum_count int64
3743 3779
 					sum_count = item.SupplyCount * base.MinNumber
3744 3780
 					service.ModifyDrugAddInformation(item.ProjectId, sum_count, orgId)
3781
+					//出库数量减少
3782
+					service.ReduceDrugSumOut(houseConfig.DrugStorehouseOut, orgId, item.ProjectId, sum_count)
3745 3783
 				}
3746 3784
 
3747 3785
 				if item.SupplyType == base.MinUnit && base.MaxUnit != base.MinUnit {
@@ -3750,6 +3788,9 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3750 3788
 					}
3751 3789
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3752 3790
 					service.ModifyDrugAddInformation(item.ProjectId, item.SupplyCount, orgId)
3791
+					//出库数量减少
3792
+					service.ReduceDrugSumOut(houseConfig.DrugStorehouseOut, orgId, item.ProjectId, item.SupplyCount)
3793
+
3753 3794
 				}
3754 3795
 
3755 3796
 				//删除流水
@@ -3761,6 +3802,23 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3761 3802
 				if len(drugOutList) == 0 {
3762 3803
 					service.UpdateDrugWarehouseById(drugOut.ID)
3763 3804
 				}
3805
+
3806
+				//查询默认仓库剩余多少库存
3807
+				list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, item.ProjectId)
3808
+				var sum_count int64
3809
+				var sum_in_count int64
3810
+				for _, it := range list {
3811
+					baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3812
+					if it.MaxUnit == baseDrug.MaxUnit {
3813
+						it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3814
+						it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3815
+
3816
+					}
3817
+					sum_count += it.StockMaxNumber + it.StockMinNumber
3818
+					sum_in_count += it.WarehousingCount
3819
+				}
3820
+				service.UpdateDrugCountOne(houseConfig.DrugStorehouseOut, orgId, item.ProjectId, sum_count)
3821
+
3764 3822
 			}
3765 3823
 			//耗材
3766 3824
 			if item.IsSource == 2 {
@@ -3772,7 +3830,20 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3772 3830
 
3773 3831
 				//更改库存
3774 3832
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)
3833
+
3775 3834
 				service.ModifyGoodAddInformation(item.ProjectId, item.SupplyCount, item.UserOrgId)
3835
+
3836
+				//扣减出库数量
3837
+				service.ReduceGoodSumOutCount(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId, item.SupplyCount)
3838
+
3839
+				//查询剩余库存
3840
+				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
3841
+				var sum_count int64
3842
+				for _, item := range goodList {
3843
+					sum_count += item.StockCount
3844
+				}
3845
+				//更新剩余库存
3846
+				service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId, sum_count)
3776 3847
 				fmt.Println(err)
3777 3848
 				//删除出库记录
3778 3849
 				service.DeleteGoodWarehouseOut(item.ProjectId, item.WarehouseCancelId, orgId)

+ 2 - 0
models/dialysis.go 查看文件

@@ -832,6 +832,8 @@ type DialysisOrder struct {
832 832
 	BloodAccessInternalFistula string        `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula" form:"blood_access_internal_fistula"`
833 833
 	Catheter                   string        `gorm:"column:catheter" json:"catheter" form:"catheter"`
834 834
 	Cruor                      string        `gorm:"column:cruor" json:"cruor" form:"cruor"`
835
+	Url                        string        `gorm:"column:url" json:"url" form:"url"`
836
+	Hash                       string        `gorm:"column:hash" json:"hash" form:"hash"`
835 837
 }
836 838
 
837 839
 func (DialysisOrder) TableName() string {

+ 102 - 0
models/drug.go 查看文件

@@ -75,6 +75,10 @@ type BaseDrugLib struct {
75 75
 	SumCount              int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
76 76
 	SumInCount            int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
77 77
 	IsPharmacy            int64                  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
78
+	TotalCount            int64                  `gorm:"column:total_count" json:"total_count" form:"total_count"`
79
+	DrugStockLimitCount   int64                  `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
80
+	SumOutCount           int64                  `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
81
+	SumCancelCount        int64                  `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
78 82
 }
79 83
 
80 84
 func (BaseDrugLib) TableName() string {
@@ -129,3 +133,101 @@ type MedicineInsurancePercentage struct {
129 133
 func (MedicineInsurancePercentage) TableName() string {
130 134
 	return "xt_medicine_insurance_percentage"
131 135
 }
136
+
137
+type BaseDrugLibNight struct {
138
+	ID                          int64                   `gorm:"column:id" json:"id" form:"id"`
139
+	DrugName                    string                  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
140
+	Pinyin                      string                  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
141
+	Wubi                        string                  `gorm:"column:wubi" json:"wubi" form:"wubi"`
142
+	DrugAlias                   string                  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
143
+	DrugAliasPinyin             string                  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
144
+	DrugAliasWubi               string                  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
145
+	DrugCategory                int64                   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
146
+	DrugSpec                    string                  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
147
+	DrugType                    int64                   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
148
+	DrugStockLimit              string                  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
149
+	DrugOriginPlace             string                  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
150
+	DrugDosageForm              int64                   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
151
+	MedicalInsuranceLevel       int64                   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
152
+	MaxUnit                     string                  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
153
+	MinNumber                   int64                   `gorm:"column:min_number" json:"min_number" form:"min_number"`
154
+	MinUnit                     string                  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
155
+	Dose                        string                  `gorm:"column:dose" json:"dose" form:"dose"`
156
+	DoseUnit                    string                  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
157
+	MinPrice                    float64                 `gorm:"column:min_price" json:"min_price" form:"min_price"`
158
+	UnitMatrixing               string                  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
159
+	RetailPrice                 float64                 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
160
+	LastPrice                   float64                 `gorm:"column:last_price" json:"last_price" form:"last_price"`
161
+	DrugControl                 int64                   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
162
+	Number                      string                  `gorm:"column:number" json:"number" form:"number"`
163
+	DrugClassify                string                  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
164
+	DrugDose                    float64                 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
165
+	DrugDoseUnit                int64                   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
166
+	MedicalInsuranceNumber      string                  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
167
+	ProvincesCode               string                  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
168
+	Manufacturer                int64                   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
169
+	PharmacologyCategory        int64                   `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
170
+	StatisticsCategory          int64                   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
171
+	Code                        string                  `gorm:"column:code" json:"code" form:"code"`
172
+	IsSpecialDiseases           int64                   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
173
+	IsRecord                    int64                   `gorm:"column:is_record" json:"is_record" form:"is_record"`
174
+	Agent                       string                  `gorm:"column:agent" json:"agent" form:"agent"`
175
+	DrugStatus                  string                  `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
176
+	LimitRemark                 string                  `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
177
+	DeliveryWay                 string                  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
178
+	ExecutionFrequency          string                  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
179
+	SingleDose                  float64                 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
180
+	PrescribingNumber           float64                 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
181
+	Label                       int64                   `gorm:"column:label" json:"label" form:"label"`
182
+	Sort                        int64                   `gorm:"column:sort" json:"sort" form:"sort"`
183
+	IsUseDoctorAdvice           int64                   `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
184
+	IsDefault                   int64                   `gorm:"column:is_default" json:"is_default" form:"is_default"`
185
+	IsChargePredict             int64                   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
186
+	IsStatisticsWork            int64                   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
187
+	IsChargeUse                 int64                   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
188
+	Status                      int64                   `gorm:"column:status" json:"status" form:"status"`
189
+	Ctime                       int64                   `gorm:"column:ctime" json:"ctime" form:"ctime"`
190
+	Mtime                       int64                   `gorm:"column:mtime" json:"mtime" form:"mtime"`
191
+	OrgId                       int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
192
+	DrugCode                    string                  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
193
+	Dealer                      int64                   `gorm:"column:dealer" json:"dealer" form:"dealer"`
194
+	PrescriptionMark            int64                   `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
195
+	RecordDate                  int64                   `gorm:"column:record_date" json:"record_date" form:"record_date"`
196
+	DrugRemark                  string                  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
197
+	SocialSecurityDirectoryCode string                  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
198
+	DoseCode                    string                  `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
199
+	IsMark                      int64                   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
200
+	HospApprFlag                int64                   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
201
+	LmtUsedFlag                 int64                   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
202
+	DrugDay                     string                  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
203
+	Total                       float64                 `gorm:"column:total" json:"total" form:"total"`
204
+	PrescribingNumberUnit       string                  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
205
+	DrugWarehouseInfo           []*XtDrugWarehouseInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
206
+	XtDrugWarehouseInfo         []*XtDrugWarehouseInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
207
+	DrugWarehouseOutInfo        []*DrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
208
+	DrugCancelStockInfo         []*DrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_info"`
209
+	IsUse                       int64                   `gorm:"column:is_user" json:"is_user" form:"is_user"`
210
+	BatchRetaiPrice             float64                 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
211
+	SumCount                    int64                   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
212
+	SumInCount                  int64                   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
213
+	IsPharmacy                  int64                   `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
214
+}
215
+
216
+func (BaseDrugLibNight) TableName() string {
217
+	return "xt_base_drug"
218
+}
219
+
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"`
229
+}
230
+
231
+func (BaseDrugLibTwenty) TableName() string {
232
+	return "xt_base_drug"
233
+}

+ 32 - 0
models/drug_stock.go 查看文件

@@ -175,6 +175,7 @@ type DrugWarehouseOutInfo struct {
175 175
 	PharmacyId              int64       `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
176 176
 	IsCheck                 int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
177 177
 	BaseDrugLib             BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
178
+	OverCount               int64       `gorm:"column:over_count" json:"over_count" form:"over_count"`
178 179
 }
179 180
 
180 181
 func (DrugWarehouseOutInfo) TableName() string {
@@ -427,6 +428,11 @@ type DrugFlow struct {
427 428
 	LastPrice                 float64              `gorm:"column:last_price" json:"last_price" form:"last_price"`
428 429
 	StockCount                string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
429 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"`
430 436
 }
431 437
 
432 438
 func (DrugFlow) TableName() string {
@@ -548,3 +554,29 @@ type DrugWarehouseInfoTwenty struct {
548 554
 func (DrugWarehouseInfoTwenty) TableName() string {
549 555
 	return "xt_drug_warehouse_info"
550 556
 }
557
+
558
+type XtDrugWarehouseFlushInfo struct {
559
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
560
+	DrugMaxNumber           int64  `gorm:"column:drug_max_number" json:"drug_max_number" form:"drug_max_number"`
561
+	UserOrgId               int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
562
+	WarehouseOutId          int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
563
+	Type                    int64  `gorm:"column:type" json:"type" form:"type"`
564
+	SystemTime              int64  `gorm:"column:system_time" json:"system_time" form:"system_time"`
565
+	PatientId               int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
566
+	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
567
+	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
568
+	BatchNumberId           int64  `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
569
+	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
570
+	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
571
+	WarehouseOutOrderNumber string `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
572
+	Creater                 int64  `gorm:"column:creater" json:"creater" form:"creater"`
573
+	DrugMinNumber           int64  `gorm:"column:drug_min_number" json:"drug_min_number" form:"drug_min_number"`
574
+	Unit                    string `gorm:"column:unit" json:"unit" form:"unit"`
575
+	AdviceId                int64  `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
576
+	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
577
+	WarehouseOutDetailId    int64  `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
578
+}
579
+
580
+func (XtDrugWarehouseFlushInfo) TableName() string {
581
+	return "xt_drug_warehouse_flush_info"
582
+}

+ 76 - 38
models/good_models.go 查看文件

@@ -53,44 +53,82 @@ type GoodInfo struct {
53 53
 	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
54 54
 	ProvincesCode          string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
55 55
 
56
-	IsSpecialDiseases           int64                `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
57
-	IsRecord                    int64                `gorm:"column:is_record" json:"is_record" form:"is_record"`
58
-	StatisticsCategory          int64                `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
59
-	GoodStatus                  string               `gorm:"column:good_status" json:"good_status" form:"good_status"`
60
-	DefaultCount                int64                `gorm:"column:default_count" json:"default_count" form:"default_count"`
61
-	Sign                        int64                `gorm:"column:sign" json:"sign" form:"sign"`
62
-	IsDefault                   int64                `gorm:"column:is_default" json:"is_default" form:"is_default"`
63
-	IsChargeUse                 int64                `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
64
-	IsChargePredict             int64                `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
65
-	IsStatisticsWork            int64                `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
66
-	Sort                        int64                `gorm:"column:sort" json:"sort" form:"sort"`
67
-	IsDoctorUse                 int64                `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
68
-	Agent                       string               `gorm:"column:agent" json:"agent" form:"agent"`
69
-	GoodNumber                  string               `gorm:"column:good_number" json:"good_number" form:"good_number"`
70
-	GoodsType                   GoodsType            `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
71
-	CommdityCode                string               `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
72
-	SocialSecurityDirectoryCode string               `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
73
-	ProductionType              string               `gorm:"column:production_type" json:"production_type" form:"production_type"`
74
-	SpecialMedical              string               `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
75
-	IsMark                      int64                `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
76
-	MinNumber                   int64                `gorm:"column:min_number" json:"min_number" form:"min_number"`
77
-	PackingUnit                 string               `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
78
-	PackingPrice                float64              `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
79
-	DefaultCountUnit            string               `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
80
-	MinUnit                     string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
81
-	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
82
-	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
83
-	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
84
-	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
85
-	GoodSotckInfo               []*GoodSotckInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
86
-	IsUser                      int64                `gorm:"column:is_user" json:"is_user" form:"is_user"`
87
-	Number                      string               `gorm:"column:number" json:"number" form:"number"`
88
-	IsWarehouse                 int64                `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
89
-	SumCount                    int64                `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
90
-	BatchRetaiPrice             float64              `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
91
-	SumInCount                  int64                `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
92
-	WarehousingInfo             []*WarehousingInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
93
-	WarehouseOutInfo            []*WarehouseOutInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_out_info"`
56
+	IsSpecialDiseases           int64                   `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
57
+	IsRecord                    int64                   `gorm:"column:is_record" json:"is_record" form:"is_record"`
58
+	StatisticsCategory          int64                   `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
59
+	GoodStatus                  string                  `gorm:"column:good_status" json:"good_status" form:"good_status"`
60
+	DefaultCount                int64                   `gorm:"column:default_count" json:"default_count" form:"default_count"`
61
+	Sign                        int64                   `gorm:"column:sign" json:"sign" form:"sign"`
62
+	IsDefault                   int64                   `gorm:"column:is_default" json:"is_default" form:"is_default"`
63
+	IsChargeUse                 int64                   `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
64
+	IsChargePredict             int64                   `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
65
+	IsStatisticsWork            int64                   `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
66
+	Sort                        int64                   `gorm:"column:sort" json:"sort" form:"sort"`
67
+	IsDoctorUse                 int64                   `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
68
+	Agent                       string                  `gorm:"column:agent" json:"agent" form:"agent"`
69
+	GoodNumber                  string                  `gorm:"column:good_number" json:"good_number" form:"good_number"`
70
+	GoodsType                   GoodsType               `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
71
+	CommdityCode                string                  `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
72
+	SocialSecurityDirectoryCode string                  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
73
+	ProductionType              string                  `gorm:"column:production_type" json:"production_type" form:"production_type"`
74
+	SpecialMedical              string                  `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
75
+	IsMark                      int64                   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
76
+	MinNumber                   int64                   `gorm:"column:min_number" json:"min_number" form:"min_number"`
77
+	PackingUnit                 string                  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
78
+	PackingPrice                float64                 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
79
+	DefaultCountUnit            string                  `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
80
+	MinUnit                     string                  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
81
+	Total                       float64                 `gorm:"column:total" json:"total" form:"total"`
82
+	StWarehousingInfo           []*StWarehousingInfo    `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
83
+	CancelStockInfo             []*CancelStockInfo      `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
84
+	RegisterNumber              string                  `gorm:"column:register_number" json:"register_number" form:"register_number"`
85
+	GoodSotckInfo               []*GoodSotckInfo        `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
86
+	IsUser                      int64                   `gorm:"column:is_user" json:"is_user" form:"is_user"`
87
+	Number                      string                  `gorm:"column:number" json:"number" form:"number"`
88
+	IsWarehouse                 int64                   `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
89
+	SumCount                    int64                   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
90
+	BatchRetaiPrice             float64                 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
91
+	SumInCount                  int64                   `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
92
+	WarehousingInfoOne          []*StartWarehousingInfo `gorm:"json:"warehouse_info"` //期间增加
93
+
94
+	WarehousingInfoStart []*StartWarehousingInfo `gorm:"json:"warehouse_info_start"`
95
+
96
+	WarehousingInfoEnd []*StartWarehousingInfo `gorm:"json:"warehouse_info_end"`
97
+	WarehousingInfo    []*WarehousingInfo      `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
98
+	WarehouseOutInfo   []*WarehouseOutInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_out_info"`
99
+
100
+	WarehouseOutInfoEnd   []*VmStockFlow
101
+	WarehouseOutInfoStart []*VmStockFlow
102
+	WarehouseInfoEnd      []*VmStockFlow //期末入库量
103
+
104
+	StartFlowWarehouseInfo []*VmStockFlow //本期增加
105
+
106
+	//期初结余
107
+	StartFlowInfo    []*VmStockFlow
108
+	StartOutFlowInfo []*VmStockFlow
109
+
110
+	//期末结余
111
+	EndFlowInfo    []*VmStockFlow
112
+	EndFlowOutInfo []*VmStockFlow
113
+
114
+	//期初退库
115
+	StartCancelFlowInfo []*VmStockFlow
116
+	//期末退库
117
+	EndCancelFLowInfo []*VmStockFlow
118
+
119
+	StartEndCancelFLowInfo []*VmStockFlow
120
+
121
+	WareStartStockInventoryProfit []*VmStockFlow //期初盘盈
122
+	WareStartStockInventoryLosses []*VmStockFlow //期初盘亏
123
+
124
+	WareEndStockInventoryProfit []*VmStockFlow //期末盘盈
125
+	WareEndStockInventoryLosses []*VmStockFlow //期末盘亏
126
+
127
+	WareStartEndStockInventoryProfit []*VmStockFlow //期间盘盈
128
+	WareStartEndStockInventoryLosses []*VmStockFlow //期间盘亏
129
+	SumOutCount                      int64          `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
130
+	SumCancelCount                   int64          `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
131
+	TotalCount                       int64          `gorm:"column:total_count" json:"total_count" form:"total_count"`
94 132
 }
95 133
 
96 134
 func (GoodInfo) TableName() string {

+ 179 - 0
models/new_stock_models.go 查看文件

@@ -0,0 +1,179 @@
1
+package models
2
+
3
+type XtGoodStockCount struct {
4
+	ID               int64 `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId        int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	GoodId           int64 `gorm:"column:good_id" json:"good_id" form:"good_id"`
7
+	StorehouseId     int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
8
+	Status           int64 `gorm:"column:status" json:"status" form:"status"`
9
+	Ctime            int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
+	Mtime            int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
11
+	StockInCount     int64 `gorm:"column:stock_in_count" json:"stock_in_count" form:"stock_in_count"`
12
+	StockOutCount    int64 `gorm:"column:stock_out_count" json:"stock_out_count" form:"stock_out_count"`
13
+	StockCancelCount int64 `gorm:"column:stock_cancel_count" json:"stock_cancel_count" form:"stock_cancel_count"`
14
+	FlushCount       int64 `gorm:"column:flush_count" json:"flush_count" form:"flush_count"`
15
+	StockActOutCount int64 `gorm:"column:stock_act_out_count" json:"stock_act_out_count" form:"stock_act_out_count"`
16
+}
17
+
18
+func (XtGoodStockCount) TableName() string {
19
+	return "xt_good_stock_count"
20
+}
21
+
22
+type XtGoodErrcode struct {
23
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
24
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
25
+	Errcode        string `gorm:"column:errcode" json:"errcode" form:"errcode"`
26
+	GoodId         int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
27
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
28
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
29
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
30
+	Count          int64  `gorm:"column:count" json:"count" form:"count"`
31
+	StockCount     int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
32
+	Creater        int64  `gorm:"column:creater" json:"creater" form:"creater"`
33
+	BatchNumberId  int64  `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
34
+	WarehouseOutId int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
35
+	PatientId      int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
36
+	Code           string `gorm:"column:code" json:"code" form:"code"`
37
+}
38
+
39
+func (XtGoodErrcode) TableName() string {
40
+	return "xt_good_errcode"
41
+}
42
+
43
+type XtDrugStockCount struct {
44
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
45
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
46
+	StorehouseId   int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
47
+	SumInCount     int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
48
+	SumOutCount    int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
49
+	SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
50
+	DrugId         int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
51
+	Ctime          int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
52
+	Mtime          int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
53
+	Status         int64 `gorm:"column:status" json:"status" form:"status"`
54
+	FlushCount     int64 `gorm:"column:flush_count" json:"flush_count" form:"flush_count"`
55
+	SumActOutCount int64 `gorm:"column:sum_act_out_count" json:"sum_act_out_count" form:"sum_act_out_count"`
56
+}
57
+
58
+func (XtDrugStockCount) TableName() string {
59
+	return "xt_drug_stock_count"
60
+}
61
+
62
+type NewBaseDrug struct {
63
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
64
+	DrugName               string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
65
+	Pinyin                 string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
66
+	Wubi                   string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
67
+	DrugAlias              string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
68
+	DrugAliasPinyin        string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
69
+	DrugAliasWubi          string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
70
+	DrugCategory           int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
71
+	DrugSpec               string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
72
+	DrugType               int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
73
+	DrugStockLimit         string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
74
+	DrugOriginPlace        string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
75
+	DrugDosageForm         int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
76
+	MedicalInsuranceLevel  int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
77
+	MaxUnit                string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
78
+	MinNumber              int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
79
+	MinUnit                string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
80
+	Dose                   string  `gorm:"column:dose" json:"dose" form:"dose"`
81
+	DoseUnit               string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
82
+	UnitMatrixing          string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
83
+	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
84
+	MinPrice               float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
85
+	LastPrice              float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
86
+	DrugControl            int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
87
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
88
+	DrugClassify           string  `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
89
+	DrugDose               float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
90
+	DrugDoseUnit           int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
91
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
92
+	ProvincesCode          string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
93
+
94
+	Manufacturer                int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
95
+	PharmacologyCategory        int64                  `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
96
+	StatisticsCategory          int64                  `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
97
+	Code                        string                 `gorm:"column:code" json:"code" form:"code"`
98
+	IsSpecialDiseases           int64                  `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
99
+	IsRecord                    int64                  `gorm:"column:is_record" json:"is_record" form:"is_record"`
100
+	Agent                       string                 `gorm:"column:agent" json:"agent" form:"agent"`
101
+	DrugStatus                  string                 `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
102
+	LimitRemark                 string                 `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
103
+	DeliveryWay                 string                 `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
104
+	ExecutionFrequency          string                 `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
105
+	SingleDose                  float64                `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
106
+	PrescribingNumber           float64                `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
107
+	Label                       int64                  `gorm:"column:label" json:"label" form:"label"`
108
+	Sort                        int64                  `gorm:"column:sort" json:"sort" form:"sort"`
109
+	IsUseDoctorAdvice           int64                  `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
110
+	IsDefault                   int64                  `gorm:"column:is_default" json:"is_default" form:"is_default"`
111
+	IsChargePredict             int64                  `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
112
+	IsStatisticsWork            int64                  `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
113
+	IsChargeUse                 int64                  `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
114
+	Status                      int64                  `gorm:"column:status" json:"status" form:"status"`
115
+	Ctime                       int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
116
+	Mtime                       int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
117
+	OrgId                       int64                  `gorm:"column:org_id" json:"org_id" form:"org_id"`
118
+	DrugCode                    string                 `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
119
+	Dealer                      int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
120
+	PrescriptionMark            int64                  `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
121
+	RecordDate                  int64                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
122
+	DrugRemark                  string                 `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
123
+	SocialSecurityDirectoryCode string                 `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
124
+	DoseCode                    string                 `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
125
+	IsMark                      int64                  `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
126
+	HospApprFlag                int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
127
+	LmtUsedFlag                 int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
128
+	DrugDay                     string                 `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
129
+	Total                       float64                `gorm:"column:total" json:"total" form:"total"`
130
+	PrescribingNumberUnit       string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
131
+	DrugWarehouseInfo           []*VsDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
132
+	XtDrugStockCount            []*XtDrugStockCount    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_stock_count"`
133
+	DrugStockCount              []*XtDrugStockCount    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_stock_info"`
134
+	TotalCount                  int64                  `gorm:"column:total_count" json:"total_count" form:"total_count"`
135
+	IsUser                      int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
136
+	BatchRetaiPrice             float64                `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
137
+	DrugStockLimitCount         int64                  `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
138
+	SumCount                    int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
139
+	SumInCount                  int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
140
+	IsPharmacy                  int64                  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
141
+}
142
+
143
+func (NewBaseDrug) TableName() string {
144
+	return "xt_base_drug"
145
+}
146
+
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"`
175
+}
176
+
177
+func (XtDialysisSetting) TableName() string {
178
+	return "xt_dialysis_setting"
179
+}

+ 1 - 0
models/patient_models.go 查看文件

@@ -523,6 +523,7 @@ type DialysisSolution struct {
523 523
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
524 524
 	MaxUltrafiltrationRate     float64 `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
525 525
 	PreImpulse                 float64 `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
526
+	SolutionStatus             int64   `gorm:"column:solution_status" json:"solution_status" form:"solution_status"`
526 527
 }
527 528
 
528 529
 func (DialysisSolution) TableName() string {

+ 53 - 0
models/schedule_models.go 查看文件

@@ -288,3 +288,56 @@ type VmBloodPatients struct {
288 288
 func (VmBloodPatients) TableName() string {
289 289
 	return "xt_patients"
290 290
 }
291
+
292
+type VmBloodSchedule struct {
293
+	ID               int64                      `gorm:"column:id" json:"id" form:"id"`
294
+	UserOrgId        int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
295
+	PartitionId      int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
296
+	BedId            int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
297
+	PatientId        int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
298
+	ScheduleDate     int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
299
+	ScheduleType     int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
300
+	ScheduleWeek     int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
301
+	ModeId           int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
302
+	Status           int64                      `gorm:"column:status" json:"status" form:"status"`
303
+	CreatedTime      int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
304
+	UpdatedTime      int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
305
+	IsExport         int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
306
+	DeviceNumber     *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
307
+	SchedualPatient  *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
308
+	DialysisSolution DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
309
+}
310
+
311
+func (VmBloodSchedule) TableName() string {
312
+	return "xt_schedule"
313
+}
314
+
315
+type NewMDeviceNumberVM struct {
316
+	DeviceNumber
317
+
318
+	Zone *DeviceZone `gorm:"ForeignKey:ZoneID" json:"zone"`
319
+}
320
+
321
+func (NewMDeviceNumberVM) TableName() string {
322
+	return "xt_device_number"
323
+}
324
+
325
+type NewMSchedualPatientVMList struct {
326
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
327
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
328
+	UserId             int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
329
+	PatientType        int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
330
+	DialysisNo         string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
331
+	Avatar             string `gorm:"column:avatar" json:"avatar" form:"avatar"`
332
+	Gender             int64  `gorm:"column:gender" json:"gender" form:"gender"`
333
+	Birthday           int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
334
+	Age                int64  `gorm:"column:age" json:"age"`
335
+	Name               string `gorm:"column:name" json:"name" form:"name"`
336
+	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
337
+	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
338
+	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
339
+}
340
+
341
+func (NewMSchedualPatientVMList) TableName() string {
342
+	return "xt_patients"
343
+}

+ 76 - 0
models/self_drug_models.go 查看文件

@@ -359,6 +359,7 @@ type XtDrugWarehouseOutInfo struct {
359 359
 	BatchNumber             string     `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
360 360
 	XtBaseDrug              XtBaseDrug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
361 361
 	StorehouseId            int64      `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
362
+	AdviceId                int64      `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
362 363
 }
363 364
 
364 365
 func (XtDrugWarehouseOutInfo) TableName() string {
@@ -1049,8 +1050,83 @@ type NewGoodInformation struct {
1049 1050
 	CancelStockInfo             []*CancelStockInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
1050 1051
 	WarehousingInfo             []*WarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_info"`
1051 1052
 	WarehouseOutInfo            []*WarehouseOutInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"warehouse_out_info"`
1053
+	FlowOutInfo                 []*VmStockFlow      `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"stock_flow_out_info"`
1054
+	FlowCancelInfo              []*VmStockFlow      `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"stock_flow_cancel_info"`
1052 1055
 }
1053 1056
 
1054 1057
 func (NewGoodInformation) TableName() string {
1055 1058
 	return "xt_good_information"
1056 1059
 }
1060
+
1061
+type GoodInformation struct {
1062
+	ID                          int64               `gorm:"column:id" json:"id" form:"id"`
1063
+	GoodCode                    string              `gorm:"column:good_code" json:"good_code" form:"good_code"`
1064
+	SpecificationName           string              `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1065
+	GoodTypeId                  int64               `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1066
+	GoodUnit                    int64               `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
1067
+	BuyPrice                    float64             `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
1068
+	SellPrice                   float64             `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
1069
+	Remark                      string              `gorm:"column:remark" json:"remark" form:"remark"`
1070
+	Ctime                       int64               `gorm:"column:ctime" json:"ctime" form:"ctime"`
1071
+	Mtime                       int64               `gorm:"column:mtime" json:"mtime" form:"mtime"`
1072
+	Manufacturer                int64               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1073
+	Dealer                      int64               `gorm:"column:dealer" json:"dealer" form:"dealer"`
1074
+	ExpiryDateWarnDayCount      int64               `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
1075
+	StockWarnCount              int64               `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
1076
+	IsReuse                     int64               `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
1077
+	Status                      int64               `gorm:"column:status" json:"status" form:"status"`
1078
+	FilmArea                    string              `gorm:"column:film_area" json:"film_area" form:"film_area"`
1079
+	IsUse                       int64               `gorm:"column:is_use" json:"is_use" form:"is_use"`
1080
+	FilmMaterialQuality         string              `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
1081
+	OrgId                       int64               `gorm:"column:org_id" json:"org_id" form:"org_id"`
1082
+	Modifier                    int64               `gorm:"column:modifier" json:"modifier" form:"modifier"`
1083
+	Creater                     int64               `gorm:"column:creater" json:"creater" form:"creater"`
1084
+	GoodName                    string              `gorm:"column:good_name" json:"good_name" form:"good_name"`
1085
+	Pinyin                      string              `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1086
+	Wubi                        string              `gorm:"column:wubi" json:"wubi" form:"wubi"`
1087
+	GoodKind                    int64               `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
1088
+	MedicalInsuranceLevel       int64               `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
1089
+	RetailPrice                 float64             `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1090
+	MedicalInsuranceNumber      string              `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
1091
+	IsSpecialDiseases           int64               `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
1092
+	IsRecord                    int64               `gorm:"column:is_record" json:"is_record" form:"is_record"`
1093
+	StatisticsCategory          int64               `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
1094
+	GoodStatus                  string              `gorm:"column:good_status" json:"good_status" form:"good_status"`
1095
+	DefaultCount                int64               `gorm:"column:default_count" json:"default_count" form:"default_count"`
1096
+	IsDefault                   int64               `gorm:"column:is_default" json:"is_default" form:"is_default"`
1097
+	IsChargeUse                 int64               `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
1098
+	IsChargePredict             int64               `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
1099
+	IsStatisticsWork            int64               `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
1100
+	Sign                        int64               `gorm:"column:sign" json:"sign" form:"sign"`
1101
+	Sort                        int64               `gorm:"column:sort" json:"sort" form:"sort"`
1102
+	IsDoctorUse                 int64               `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
1103
+	Agent                       string              `gorm:"column:agent" json:"agent" form:"agent"`
1104
+	GoodNumber                  string              `gorm:"column:good_number" json:"good_number" form:"good_number"`
1105
+	CommdityCode                string              `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1106
+	SocialSecurityDirectoryCode string              `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
1107
+	ProductionType              string              `gorm:"column:production_type" json:"production_type" form:"production_type"`
1108
+	SpecialMedical              string              `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
1109
+	IsMark                      int64               `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
1110
+	Total                       float64             `gorm:"column:total" json:"total" form:"total"`
1111
+	MinNumber                   int64               `gorm:"column:min_number" json:"min_number" form:"min_number"`
1112
+	PackingUnit                 string              `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1113
+	PackingPrice                float64             `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1114
+	DefaultCountUnit            string              `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
1115
+	MinUnit                     string              `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
1116
+	RegisterNumber              string              `gorm:"column:register_number" json:"register_number" form:"register_number"`
1117
+	ProvincesCode               string              `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
1118
+	IsUser                      int64               `gorm:"column:is_user" json:"is_user" form:"is_user"`
1119
+	Number                      string              `gorm:"column:number" json:"number" form:"number"`
1120
+	IsWarehouse                 string              `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
1121
+	BatchRetaiPrice             float64             `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
1122
+	SumCount                    int64               `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
1123
+	SumInCount                  int64               `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
1124
+	ManufacturerName            string              `gorm:"column:manufacturer_name" json:"manufacturer_name" form:"manufacturer_name"`
1125
+	XtGoodStockCount            []*XtGoodStockCount `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_good_stock"`
1126
+	GoodStockCount              []*XtGoodStockCount `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_good_stock_info"`
1127
+	WarehousingInfo             []*WarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
1128
+}
1129
+
1130
+func (GoodInformation) TableName() string {
1131
+	return "xt_good_information"
1132
+}

+ 256 - 135
models/stock_models.go 查看文件

@@ -226,46 +226,49 @@ func (WarehouseOut) TableName() string {
226 226
 }
227 227
 
228 228
 type WarehouseOutInfo struct {
229
-	ID                      int64        `gorm:"column:id" json:"id"`
230
-	WarehouseOutId          int64        `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
231
-	WarehouseInfotId        int64        `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
232
-	GoodId                  int64        `gorm:"column:good_id" json:"good_id"`
233
-	GoodTypeId              int64        `gorm:"column:good_type_id" json:"good_type_id"`
234
-	WarehousingOutTarget    int64        `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
235
-	Count                   int64        `gorm:"column:count" json:"count"`
236
-	Price                   float64      `gorm:"column:price" json:"price"`
237
-	TotalPrice              float64      `gorm:"column:total_price" json:"total_price"`
238
-	ProductDate             int64        `gorm:"column:product_date" json:"product_date"`
239
-	ExpiryDate              int64        `gorm:"column:expiry_date" json:"expiry_date"`
240
-	Mtime                   int64        `gorm:"column:mtime" json:"mtime"`
241
-	Ctime                   int64        `gorm:"column:ctime" json:"ctime"`
242
-	Status                  int64        `gorm:"column:status" json:"status"`
243
-	OrgId                   int64        `gorm:"column:org_id" json:"org_id"`
244
-	Remark                  string       `gorm:"column:remark" json:"remark"`
245
-	IsCancel                int64        `gorm:"column:is_cancel" json:"is_cancel"`
246
-	WarehouseOut            WarehouseOut `ForeignKey:WarehouseOutId json:"WarehouseOut"`
247
-	WarehouseOutOrderNumber string       `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
248
-	GoodInfo                GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
249
-	Type                    int64        `gorm:"column:type" json:"type"`
250
-	Dealer                  int64        `gorm:"column:dealer" json:"dealer"`
251
-	Manufacturer            int64        `gorm:"column:manufacturer" json:"manufacturer"`
252
-	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
253
-	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
254
-	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
255
-	Number                  string       `gorm:"column:number" json:"number" form:"number"`
256
-	LicenseNumber           string       `gorm:"column:license_number" json:"license_number" form:"license_number"`
257
-	ConsumableType          int64        `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
258
-	ProjectId               int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
259
-	SupplyCancelOutId       int64        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
260
-	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
261
-	IsSource                int64        `gorm:"column:is_source" json:"is_source" form:"is_source"`
262
-	StorehouseId            int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
263
-	SecondWarehouseInfoId   int64        `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
264
-	AdminUserId             int64        `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
265
-	BuyPrice                float64      `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
266
-	StockCount              string       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
267
-	IsCheck                 int64        `gorm:"column:is_check" json:"is_check" form:"is_check"`
268
-	RegisterNumber          string       `gorm:"column:register_number" json:"register_number" form:"register_number"`
229
+	ID                      int64           `gorm:"column:id" json:"id"`
230
+	WarehouseOutId          int64           `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
231
+	WarehouseInfotId        int64           `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
232
+	GoodId                  int64           `gorm:"column:good_id" json:"good_id"`
233
+	GoodTypeId              int64           `gorm:"column:good_type_id" json:"good_type_id"`
234
+	WarehousingOutTarget    int64           `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
235
+	Count                   int64           `gorm:"column:count" json:"count"`
236
+	Price                   float64         `gorm:"column:price" json:"price"`
237
+	TotalPrice              float64         `gorm:"column:total_price" json:"total_price"`
238
+	ProductDate             int64           `gorm:"column:product_date" json:"product_date"`
239
+	ExpiryDate              int64           `gorm:"column:expiry_date" json:"expiry_date"`
240
+	Mtime                   int64           `gorm:"column:mtime" json:"mtime"`
241
+	Ctime                   int64           `gorm:"column:ctime" json:"ctime"`
242
+	Status                  int64           `gorm:"column:status" json:"status"`
243
+	OrgId                   int64           `gorm:"column:org_id" json:"org_id"`
244
+	Remark                  string          `gorm:"column:remark" json:"remark"`
245
+	IsCancel                int64           `gorm:"column:is_cancel" json:"is_cancel"`
246
+	WarehouseOut            WarehouseOut    `ForeignKey:WarehouseOutId json:"WarehouseOut"`
247
+	WarehouseOutOrderNumber string          `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
248
+	GoodInfo                GoodInfo        `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
249
+	Type                    int64           `gorm:"column:type" json:"type"`
250
+	Dealer                  int64           `gorm:"column:dealer" json:"dealer"`
251
+	Manufacturer            int64           `gorm:"column:manufacturer" json:"manufacturer"`
252
+	IsSys                   int64           `gorm:"column:is_sys" json:"is_sys"`
253
+	SysRecordTime           int64           `gorm:"column:sys_record_time" json:"sys_record_time"`
254
+	PatientId               int64           `gorm:"column:patient_id" json:"patient_id"`
255
+	Number                  string          `gorm:"column:number" json:"number" form:"number"`
256
+	LicenseNumber           string          `gorm:"column:license_number" json:"license_number" form:"license_number"`
257
+	ConsumableType          int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
258
+	ProjectId               int64           `gorm:"column:project_id" json:"project_id" form:"project_id"`
259
+	SupplyCancelOutId       int64           `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
260
+	SupplyWarehouseId       int64           `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
261
+	IsSource                int64           `gorm:"column:is_source" json:"is_source" form:"is_source"`
262
+	StorehouseId            int64           `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
263
+	SecondWarehouseInfoId   int64           `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
264
+	AdminUserId             int64           `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
265
+	BuyPrice                float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
266
+	StockCount              string          `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
267
+	IsCheck                 int64           `gorm:"column:is_check" json:"is_check" form:"is_check"`
268
+	RegisterNumber          string          `gorm:"column:register_number" json:"register_number" form:"register_number"`
269
+	WarehousingInfo         WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfotId" `
270
+	VmStockFlow             VmStockFlow     `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId" json:"stock_flow"`
271
+	OverCount               int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
269 272
 }
270 273
 
271 274
 func (WarehouseOutInfo) TableName() string {
@@ -273,16 +276,26 @@ func (WarehouseOutInfo) TableName() string {
273 276
 }
274 277
 
275 278
 type WarehouseOutInfoNight struct {
276
-	ID               int64 `gorm:"column:id" json:"id"`
277
-	Count            int64 `gorm:"column:count" json:"count"`
278
-	GoodId           int64 `gorm:"column:good_id" json:"good_id"`
279
-	SysRecordTime    int64 `gorm:"column:sys_record_time" json:"sys_record_time"`
280
-	PatientId        int64 `gorm:"column:patient_id" json:"patient_id"`
281
-	ProjectId        int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
282
-	WarehouseInfotId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
283
-	IsSys            int64 `gorm:"column:is_sys" json:"is_sys"`
284
-	Status           int64 `gorm:"column:status" json:"status"`
285
-	OrgId            int64 `gorm:"column:org_id" json:"org_id"`
279
+	ID                      int64   `gorm:"column:id" json:"id"`
280
+	Count                   int64   `gorm:"column:count" json:"count"`
281
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id"`
282
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time"`
283
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id"`
284
+	ProjectId               int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
285
+	WarehouseInfotId        int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
286
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys"`
287
+	Status                  int64   `gorm:"column:status" json:"status"`
288
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id"`
289
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
290
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
291
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
292
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
293
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
294
+	GoodTypeId              int64   `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
295
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
296
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
297
+	Number                  string  `gorm:"column:number" json:"number" form:"number"`
298
+	LicenseNumber           string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
286 299
 }
287 300
 
288 301
 func (WarehouseOutInfoNight) TableName() string {
@@ -290,8 +303,11 @@ func (WarehouseOutInfoNight) TableName() string {
290 303
 }
291 304
 
292 305
 type WarehouseOutInfoSeven struct {
293
-	ID    int64 `gorm:"column:id" json:"id"`
294
-	Count int64 `gorm:"column:count" json:"count"`
306
+	ID            int64 `gorm:"column:id" json:"id"`
307
+	Count         int64 `gorm:"column:count" json:"count"`
308
+	SysRecordTime int64 `gorm:"column:sys_record_time" json:"sys_record_time"`
309
+	PatientId     int64 `gorm:"column:patient_id" json:"patient_id"`
310
+	GoodId        int64 `gorm:"column:good_id" json:"good_id"`
295 311
 }
296 312
 
297 313
 func (WarehouseOutInfoSeven) TableName() string {
@@ -593,48 +609,52 @@ func (WarehouseOutInfoSix) TableName() string {
593 609
 }
594 610
 
595 611
 type VmStockFlow struct {
596
-	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
597
-	WarehousingId             int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
598
-	GoodId                    int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
599
-	Number                    string  `gorm:"column:number" json:"number" form:"number"`
600
-	LicenseNumber             string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
601
-	Count                     int64   `gorm:"column:count" json:"count" form:"count"`
602
-	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
603
-	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
604
-	SystemTime                int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
605
-	ConsumableType            int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
606
-	IsSys                     int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
607
-	WarehousingOrder          string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
608
-	WarehouseOutId            int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
609
-	WarehouseOutOrderNumber   string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
610
-	IsEdit                    int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
611
-	CancelStockId             int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
612
-	CancelOrderNumber         string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
613
-	Manufacturer              int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
614
-	Dealer                    int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
615
-	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
616
-	UpdateCreator             int64   `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
617
-	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
618
-	Ctime                     int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
619
-	Mtime                     int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
620
-	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
621
-	WarehousingDetailId       int64   `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
622
-	WarehouseOutDetailId      int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
623
-	CancelOutDetailId         int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
624
-	ProductDate               int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
625
-	ExpireDate                int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
626
-	ReturnCount               int64   `gorm:"column:return_count" json:"return_count" form:"return_count"`
627
-	ProjectId                 int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
628
-	SupplyWarehouseId         int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
629
-	SupplyCancelOutId         int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
630
-	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
631
-	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
632
-	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
633
-	AdminUserId               int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
634
-	BuyPrice                  float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
635
-	StockCount                string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
636
-	RegisterNumber            string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
637
-	BatchNumberCount          int64   `gorm:"column:batch_number_count" json:"batch_number_count" form:"batch_number_count"`
612
+	ID                        int64           `gorm:"column:id" json:"id" form:"id"`
613
+	WarehousingId             int64           `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
614
+	GoodId                    int64           `gorm:"column:good_id" json:"good_id" form:"good_id"`
615
+	Number                    string          `gorm:"column:number" json:"number" form:"number"`
616
+	LicenseNumber             string          `gorm:"column:license_number" json:"license_number" form:"license_number"`
617
+	Count                     int64           `gorm:"column:count" json:"count" form:"count"`
618
+	UserOrgId                 int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
619
+	PatientId                 int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
620
+	SystemTime                int64           `gorm:"column:system_time" json:"system_time" form:"system_time"`
621
+	ConsumableType            int64           `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
622
+	IsSys                     int64           `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
623
+	WarehousingOrder          string          `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
624
+	WarehouseOutId            int64           `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
625
+	WarehouseOutOrderNumber   string          `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
626
+	IsEdit                    int64           `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
627
+	CancelStockId             int64           `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
628
+	CancelOrderNumber         string          `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
629
+	Manufacturer              int64           `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
630
+	Dealer                    int64           `gorm:"column:dealer" json:"dealer" form:"dealer"`
631
+	Creator                   int64           `gorm:"column:creator" json:"creator" form:"creator"`
632
+	UpdateCreator             int64           `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
633
+	Status                    int64           `gorm:"column:status" json:"status" form:"status"`
634
+	Ctime                     int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
635
+	Mtime                     int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
636
+	Price                     float64         `gorm:"column:price" json:"price" form:"price"`
637
+	WarehousingDetailId       int64           `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
638
+	WarehouseOutDetailId      int64           `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
639
+	CancelOutDetailId         int64           `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
640
+	ProductDate               int64           `gorm:"column:product_date" json:"product_date" form:"product_date"`
641
+	ExpireDate                int64           `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
642
+	ReturnCount               int64           `gorm:"column:return_count" json:"return_count" form:"return_count"`
643
+	ProjectId                 int64           `gorm:"column:project_id" json:"project_id" form:"project_id"`
644
+	SupplyWarehouseId         int64           `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
645
+	SupplyCancelOutId         int64           `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
646
+	SupplyWarehouseDetailInfo int64           `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
647
+	StorehouseId              int64           `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
648
+	SecondWarehouseInfoId     int64           `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
649
+	AdminUserId               int64           `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
650
+	BuyPrice                  float64         `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
651
+	StockCount                string          `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
652
+	RegisterNumber            string          `gorm:"column:register_number" json:"register_number" form:"register_number"`
653
+	BatchNumberCount          int64           `gorm:"column:batch_number_count" json:"batch_number_count" form:"batch_number_count"`
654
+	WarehousingInfo           WarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
655
+	IsRead                    int64           `gorm:"column:is_read" json:"is_read" form:"is_read"`
656
+	IsCheck                   int64           `gorm:"column:is_check" json:"is_check" form:"is_check"`
657
+	OverCount                 int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
638 658
 }
639 659
 
640 660
 func (VmStockFlow) TableName() string {
@@ -708,47 +728,72 @@ type VmBaseDrug struct {
708 728
 	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
709 729
 	ProvincesCode          string  `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
710 730
 
711
-	Manufacturer                int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
712
-	PharmacologyCategory        int64                     `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
713
-	StatisticsCategory          int64                     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
714
-	Code                        string                    `gorm:"column:code" json:"code" form:"code"`
715
-	IsSpecialDiseases           int64                     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
716
-	IsRecord                    int64                     `gorm:"column:is_record" json:"is_record" form:"is_record"`
717
-	Agent                       string                    `gorm:"column:agent" json:"agent" form:"agent"`
718
-	DrugStatus                  string                    `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
719
-	LimitRemark                 string                    `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
720
-	DeliveryWay                 string                    `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
721
-	ExecutionFrequency          string                    `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
722
-	SingleDose                  float64                   `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
723
-	PrescribingNumber           float64                   `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
724
-	Label                       int64                     `gorm:"column:label" json:"label" form:"label"`
725
-	Sort                        int64                     `gorm:"column:sort" json:"sort" form:"sort"`
726
-	IsUseDoctorAdvice           int64                     `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
727
-	IsDefault                   int64                     `gorm:"column:is_default" json:"is_default" form:"is_default"`
728
-	IsChargePredict             int64                     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
729
-	IsStatisticsWork            int64                     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
730
-	IsChargeUse                 int64                     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
731
-	Status                      int64                     `gorm:"column:status" json:"status" form:"status"`
732
-	Ctime                       int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
733
-	Mtime                       int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
734
-	OrgId                       int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
735
-	DrugCode                    string                    `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
736
-	Dealer                      int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
737
-	PrescriptionMark            int64                     `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
738
-	RecordDate                  int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
739
-	DrugRemark                  string                    `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
740
-	SocialSecurityDirectoryCode string                    `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
741
-	DoseCode                    string                    `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
742
-	IsMark                      int64                     `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
743
-	HospApprFlag                int64                     `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
744
-	LmtUsedFlag                 int64                     `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
745
-	DrugDay                     string                    `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
746
-	Total                       float64                   `gorm:"column:total" json:"total" form:"total"`
747
-	PrescribingNumberUnit       string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
748
-	DrugWarehouseInfo           []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
749
-	DrugWarehouse               []*DrugWarehouseInfo      `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse"`
750
-	DrugCancelStockInfo         []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
751
-	DrugWarehouseOutInfo        []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
731
+	Manufacturer                     int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
732
+	PharmacologyCategory             int64                     `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
733
+	StatisticsCategory               int64                     `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
734
+	Code                             string                    `gorm:"column:code" json:"code" form:"code"`
735
+	IsSpecialDiseases                int64                     `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
736
+	IsRecord                         int64                     `gorm:"column:is_record" json:"is_record" form:"is_record"`
737
+	Agent                            string                    `gorm:"column:agent" json:"agent" form:"agent"`
738
+	DrugStatus                       string                    `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
739
+	LimitRemark                      string                    `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
740
+	DeliveryWay                      string                    `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
741
+	ExecutionFrequency               string                    `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
742
+	SingleDose                       float64                   `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
743
+	PrescribingNumber                float64                   `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
744
+	Label                            int64                     `gorm:"column:label" json:"label" form:"label"`
745
+	Sort                             int64                     `gorm:"column:sort" json:"sort" form:"sort"`
746
+	IsUseDoctorAdvice                int64                     `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
747
+	IsDefault                        int64                     `gorm:"column:is_default" json:"is_default" form:"is_default"`
748
+	IsChargePredict                  int64                     `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
749
+	IsStatisticsWork                 int64                     `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
750
+	IsChargeUse                      int64                     `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
751
+	Status                           int64                     `gorm:"column:status" json:"status" form:"status"`
752
+	Ctime                            int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
753
+	Mtime                            int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
754
+	OrgId                            int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
755
+	DrugCode                         string                    `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
756
+	Dealer                           int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
757
+	PrescriptionMark                 int64                     `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
758
+	RecordDate                       int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
759
+	DrugRemark                       string                    `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
760
+	SocialSecurityDirectoryCode      string                    `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
761
+	DoseCode                         string                    `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
762
+	IsMark                           int64                     `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
763
+	HospApprFlag                     int64                     `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
764
+	LmtUsedFlag                      int64                     `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
765
+	DrugDay                          string                    `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
766
+	Total                            float64                   `gorm:"column:total" json:"total" form:"total"`
767
+	PrescribingNumberUnit            string                    `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
768
+	DrugWarehouseInfo                []*VsDrugWarehouseInfo    `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
769
+	DrugWarehouse                    []*DrugWarehouseInfo      `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse"`
770
+	DrugCancelStockInfo              []*VsDrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_cancel_stock_info"`
771
+	DrugWarehouseOutInfo             []*VsDrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_out"`
772
+	TotalCount                       int64                     `gorm:"column:total_count" json:"total_count" form:"total_count"`
773
+	IsUser                           int64                     `gorm:"column:is_user" json:"is_user" form:"is_user"`
774
+	BatchRetaiPrice                  float64                   `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
775
+	DrugStockLimitCount              int64                     `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
776
+	SumCount                         int64                     `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
777
+	SumInCount                       int64                     `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
778
+	IsPharmacy                       int64                     `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
779
+	DrugFlowWarehouseInfo            []*DrugFlow               `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_flow_info"`
780
+	DrugActFlowWarehouseInfo         []*DrugFlow               `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_act_flow_info"`
781
+	DrugWarehouseInfoStart           []*DrugFlow               //期初入库结余
782
+	DrugWarehouseOutInfoStart        []*DrugFlow               //期初出库结余
783
+	DrugWarehouseOutInfoEnd          []*DrugFlow               //期末出库结余
784
+	DrugWarehouseInfoEnd             []*DrugFlow               //期末入库结余
785
+	DrugWarehouseInfoStartEnd        []*DrugFlow               //期中增加
786
+	DrugWarehouseOutInfoStartEnd     []*DrugFlow               //  期中减少
787
+	WareStartStockInventoryProfit    []*DrugFlow               //期初盘盈
788
+	WareStartStockInventoryLosses    []*DrugFlow               //期初盘亏
789
+	WareEndStockInventoryProfit      []*DrugFlow               //期末盘盈
790
+	WareEndStockInventoryLosses      []*DrugFlow               //期末盘亏
791
+	WareStartEndStockInventoryProfit []*DrugFlow               //期间盘盈
792
+	WareStartEndStockInventoryLosses []*DrugFlow               //期间盘亏
793
+	WareStartStockCancelInfo         []*DrugFlow               //期初结余退库
794
+	WareEndStockCancelInfo           []*DrugFlow               //期末结余退库
795
+	WareStartEndStockCancelInfo      []*DrugFlow               //期中减少退库
796
+
752 797
 }
753 798
 
754 799
 func (VmBaseDrug) TableName() string {
@@ -814,6 +859,7 @@ type VsDrugCancelStockInfo struct {
814 859
 	Remark           string      `gorm:"column:remark" json:"remark" form:"remark"`
815 860
 	BatchNumber      string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
816 861
 	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
862
+	StorehouseId     int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
817 863
 	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" `
818 864
 }
819 865
 
@@ -846,6 +892,7 @@ type VsDrugWarehouseOutInfo struct {
846 892
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
847 893
 	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
848 894
 	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
895
+	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
849 896
 }
850 897
 
851 898
 func (VsDrugWarehouseOutInfo) TableName() string {
@@ -870,6 +917,8 @@ type VmStockFlowOne struct {
870 917
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
871 918
 	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
872 919
 	Name                    string  `gorm:"column:name" json:"name" form:"name"`
920
+	IsRead                  int64   `gorm:"column:is_read" json:"is_read" form:"is_read"`
921
+	ConsumableType          int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
873 922
 }
874 923
 
875 924
 type BloodWarehouseInfo struct {
@@ -1447,3 +1496,75 @@ type VmWarehousingInfoSix struct {
1447 1496
 func (VmWarehousingInfoSix) TableName() string {
1448 1497
 	return "xt_warehouse_info"
1449 1498
 }
1499
+
1500
+type WarehousingInfoTen struct {
1501
+	ID         int64 `gorm:"column:id" json:"id"`
1502
+	GoodId     int64 `gorm:"column:good_id" json:"good_id"`
1503
+	Status     int64 `gorm:"column:status" json:"status"`
1504
+	OrgId      int64 `gorm:"column:org_id" json:"org_id"`
1505
+	StockCount int64 `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1506
+	IsCheck    int64 `gorm:"column:is_check" json:"is_check" form:"is_check"`
1507
+}
1508
+
1509
+func (WarehousingInfoTen) TableName() string {
1510
+	return "xt_warehouse_info"
1511
+}
1512
+
1513
+type XtWarehouseFlushInfo struct {
1514
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
1515
+	FlushCount              int64   `gorm:"column:flush_count" json:"flush_count" form:"flush_count"`
1516
+	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1517
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
1518
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
1519
+	SystemTime              int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
1520
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1521
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1522
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1523
+	BatchNumberId           int64   `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
1524
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id" form:"good_id"`
1525
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
1526
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
1527
+	Creater                 int64   `gorm:"column:creater" json:"creater" form:"creater"`
1528
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
1529
+	WarehouseOutDetailId    int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
1530
+	PackingPrice            float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1531
+	BuyPrice                float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
1532
+}
1533
+
1534
+func (XtWarehouseFlushInfo) TableName() string {
1535
+	return "xt_warehouse_flush_info"
1536
+}
1537
+
1538
+type StartWarehousingInfo struct {
1539
+	GoodId           int64   `gorm:"column:good_id" json:"good_id"`
1540
+	StockCount       int64   `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1541
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1542
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1543
+	IsCheck          int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
1544
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
1545
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1546
+	WarehousingUnit  string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1547
+	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1548
+}
1549
+
1550
+func (StartWarehousingInfo) TableName() string {
1551
+	return "xt_warehouse_info"
1552
+}
1553
+
1554
+type StartDrugWarehouseInfo struct {
1555
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1556
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1557
+	Number           string  `gorm:"column:number" json:"number" form:"number"`
1558
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1559
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
1560
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
1561
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
1562
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
1563
+	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1564
+	IsCheck          int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
1565
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1566
+}
1567
+
1568
+func (StartDrugWarehouseInfo) TableName() string {
1569
+	return "xt_drug_warehouse_info"
1570
+}

+ 13 - 0
service/admin_service.go 查看文件

@@ -300,6 +300,19 @@ func GetAdminUserElectronicSignature(orgID int64, appID int64, userID int64) (*m
300 300
 	return &es, nil
301 301
 }
302 302
 
303
+func GetPatientSignature(orgID int64, patientid int64, dialysis_date int64) (*models.DialysisOrder, error) {
304
+	var es models.DialysisOrder
305
+	err := XTReadDB().Model(&models.DialysisOrder{}).Where("user_org_id=? and patient_id=? and dialysis_date=? and status=1", orgID, patientid, dialysis_date).First(&es).Error
306
+
307
+	if err == gorm.ErrRecordNotFound {
308
+		return nil, nil
309
+	}
310
+	if err != nil {
311
+		return nil, err
312
+	}
313
+	return &es, nil
314
+}
315
+
303 316
 func GetPatinentHead(orgid int64, appid int64, userid int64) (*models.SgjUserAdminPatientHead, error) {
304 317
 	var es models.SgjUserAdminPatientHead
305 318
 	err := readUserDb.Model(&models.SgjUserAdminPatientHead{}).Where("org_id = ? and app_id = ? and creator=? and status =1", orgid, appid, userid).First(&es).Error

+ 13 - 1
service/dialysis_service.go 查看文件

@@ -131,7 +131,7 @@ func GetTotalDialysisCout(orgid int64, patientid int64) (order []*models.Dialysi
131 131
 //临时医嘱
132 132
 func FindDoctorAdviceOrderById(orgID int64, patientsId int64, recordDate int64) (patient []*models.DoctorAdvice, err error) {
133 133
 	err = readDb.Model(&models.DoctorAdvice{}).
134
-		Where("patient_id = ? and user_org_id=? and status=1 and advice_date = ? and advice_type = 2", patientsId, orgID, recordDate).
134
+		Where("patient_id = ? and user_org_id=? and status=1 and record_date = ? and (advice_type = 2 or advice_type = 3)", patientsId, orgID, recordDate).
135 135
 		Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").Order("start_time asc, groupno desc, advice_order desc, id asc").
136 136
 		Find(&patient).Error
137 137
 	return
@@ -1786,3 +1786,15 @@ func GetOrgFollowIsExist(orgid int64) (*models.SgjOrgFollowOne, error) {
1786 1786
 	}
1787 1787
 	return &follow, nil
1788 1788
 }
1789
+
1790
+func UpdatePatientSign(patient_id int64, dialysis_date int64, order models.DialysisOrder, orgid int64) error {
1791
+
1792
+	err := XTWriteDB().Model(&order).Where("patient_id = ? and dialysis_date= ? and status = 1 and user_org_id = ?", patient_id, dialysis_date, orgid).Update(map[string]interface{}{"url": order.Url, "hash": order.Hash}).Error
1793
+	return err
1794
+}
1795
+
1796
+func GetPatientSign(patient_id int64, dialysis_date int64, orgid int64) (models.DialysisOrder, error) {
1797
+	order := models.DialysisOrder{}
1798
+	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
1800
+}

+ 130 - 0
service/dialysis_solution_service.go 查看文件

@@ -0,0 +1,130 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+)
6
+
7
+func GetPatientSolutionGroupList(patient_id int64, orgid int64) (solution []*models.DialysisSolution, err error) {
8
+
9
+	err = XTReadDB().Where("patient_id = ? and status = 1 and user_org_id = ?", patient_id, orgid).Group("mode_id").Find(&solution).Error
10
+
11
+	return solution, err
12
+}
13
+
14
+func GetNewPatientSolutionByModeId(patient_id int64, mode_id int64, orgid int64) (models.DialysisSolution, error) {
15
+
16
+	solution := models.DialysisSolution{}
17
+	err := XTReadDB().Where("patient_id = ? and mode_id = ? and user_org_id = ? and status = 1", patient_id, mode_id, orgid).Order("updated_time desc").First(&solution).Error
18
+	return solution, err
19
+}
20
+
21
+func UpdateDialysisSolutionStatus(id int64, mode_id int64, orgid int64, patient_id int64) error {
22
+
23
+	err := XTWriteDB().Model(&models.DialysisSolution{}).Where("id = ? and status = 1 and user_org_id = ?", id, orgid).Update(map[string]interface{}{"solution_status": 1}).Error
24
+
25
+	err = XTWriteDB().Model(&models.DialysisSolution{}).Where("id <> ? and mode_id = ? and user_org_id = ? and status = 1 and patient_id = ?", id, mode_id, orgid, patient_id).Update(map[string]interface{}{"solution_status": 2}).Error
26
+	return err
27
+}
28
+
29
+func UpdateDialysisSolutionStatusTwo(id int64, mode_id int64, orgid int64, patient_id int64) error {
30
+
31
+	err = XTWriteDB().Model(&models.DialysisSolution{}).Where("id <> ? and mode_id = ? and user_org_id = ? and status = 1 and patient_id = ?", id, mode_id, orgid, patient_id).Update(map[string]interface{}{"solution_status": 2}).Error
32
+	return err
33
+}
34
+
35
+func GetLastPatientDialysisSolution(patient_id int64, orgid int64) (models.DialysisSolution, error) {
36
+
37
+	solution := models.DialysisSolution{}
38
+	err := XTReadDB().Where("patient_id = ? and user_org_id = ? and status = 1", patient_id, orgid).Last(&solution).Error
39
+	return solution, err
40
+}
41
+
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) {
43
+
44
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
45
+	offset := (page - 1) * limit
46
+	if scheduleDate > 0 {
47
+		db = db.Where("schedule_date = ?", scheduleDate)
48
+	}
49
+	if schedule_type > 0 {
50
+		db = db.Where("schedule_type = ?", schedule_type)
51
+	}
52
+	if partition_id > 0 {
53
+		db = db.Where("partition_id = ?", partition_id)
54
+	}
55
+	if orgID > 0 {
56
+		db = db.Where("user_org_id  = ?", orgID)
57
+	}
58
+
59
+	if len(keywords) > 0 {
60
+		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
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
64
+			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
+	} else {
67
+		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).
69
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
70
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).Find(&schedule).Error
71
+	}
72
+
73
+	return schedule, total, err
74
+}
75
+
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")
78
+	offset := (page - 1) * limit
79
+	if scheduleDate > 0 {
80
+		db = db.Where("schedule_date = ?", scheduleDate)
81
+	}
82
+	if schedule_type > 0 {
83
+		db = db.Where("schedule_type = ?", schedule_type)
84
+	}
85
+	if partition_id > 0 {
86
+		db = db.Where("partition_id = ?", partition_id)
87
+	}
88
+	if orgID > 0 {
89
+		db = db.Where("user_org_id  = ?", orgID)
90
+	}
91
+
92
+	if len(keywords) > 0 {
93
+		keywords = "%" + keywords + "%"
94
+		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)
95
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
96
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
97
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
98
+	} else {
99
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
100
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
101
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
102
+	}
103
+
104
+	return schedule, total, err
105
+}
106
+
107
+func GetAllLongAdviceList(user_org_id int64) (advice []*models.DoctorAdvice, err error) {
108
+
109
+	err = XTReadDB().Where("user_org_id = ? and advice_type = 1 and status = 1", user_org_id).Find(&advice).Error
110
+	return advice, err
111
+}
112
+
113
+func GetAllHisAdviceTemplateList(user_org_id int64) (advice []*models.HisPrescriptionAdviceTemplate, err error) {
114
+
115
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&advice).Error
116
+	return advice, err
117
+}
118
+
119
+func SaveDialysisSetting(setting models.XtDialysisSetting) error {
120
+
121
+	err := XTWriteDB().Create(&setting).Error
122
+	return err
123
+}
124
+
125
+func GetDialysisSetting(orgid int64) (models.XtDialysisSetting, error) {
126
+
127
+	setting := models.XtDialysisSetting{}
128
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
129
+	return setting, err
130
+}

+ 47 - 4
service/gobal_config_service.go 查看文件

@@ -749,9 +749,28 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
749 749
 	return list, total, err
750 750
 }
751 751
 
752
-func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
752
+func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64, startime int64, endtime int64, start_first_time int64, end_first_time int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
753 753
 	offset := (page - 1) * limit
754
-	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ? and status = 1 and is_check = 1", drugid, orgid).Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&drug).Error
754
+	db := XTReadDB().Model(&drug).Where("status = 1 and is_check = 1")
755
+	if drugid > 0 {
756
+		db = db.Where("drug_id = ?", drugid)
757
+	}
758
+	if orgid > 0 {
759
+		db = db.Where("org_id = ?", orgid)
760
+	}
761
+	if startime > 0 {
762
+		db = db.Where("ctime >=?", startime)
763
+	}
764
+	if endtime > 0 {
765
+		db = db.Where("ctime <=?", endtime)
766
+	}
767
+	if start_first_time > 0 {
768
+		db = db.Where("expiry_date >=?", start_first_time)
769
+	}
770
+	if end_first_time > 0 {
771
+		db = db.Where("expiry_date <=?", end_first_time)
772
+	}
773
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&drug).Error
755 774
 	return drug, total, err
756 775
 }
757 776
 
@@ -863,13 +882,19 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
863 882
 		db = db.Where("x.org_id = ?", orgid)
864 883
 	}
865 884
 	if id > 0 {
866
-		db = db.Where("x.warehouse_out_id = ?", id)
885
+		db = db.Where("x.warehouse_out_id in(?)", id)
867 886
 	}
868 887
 
869 888
 	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price as total_price,x.retail_total_price,x.storehouse_id,x.stock_count,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,x.admin_user_id,t.dose,t.dose_unit,t.last_price,t.min_price,t.medical_insurance_number,t.retail_price ,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
870 889
 	return info, err
871 890
 }
872 891
 
892
+func GetDrugWarehouseOutDetailSeventy(id int64, org_id int64) (info []*models.DrugWarehouseOutInfo, err error) {
893
+
894
+	err = XTReadDB().Where("warehouse_out_id in(?) and org_id = ? and status =1", id, org_id).Find(&info).Error
895
+	return info, err
896
+}
897
+
873 898
 func GetDrugStockFlowDetail(record_time int64, orgid int64) (drugflow []*models.XtDrugAutomaticReduceDetail, err error) {
874 899
 
875 900
 	err = XTReadDB().Where("record_time = ? and org_id = ? and status = 1", record_time, orgid).Preload("XtBaseDrug", "status = 1").Find(&drugflow).Error
@@ -887,7 +912,7 @@ func GetSingeOrderFlow(id int64, orgid int64) (outInfo []*models.VmDrugWarehouse
887 912
 		db = db.Where("x.warehouse_out_id in(?)", id)
888 913
 	}
889 914
 
890
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.retail_price,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&outInfo).Error
915
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.retail_price,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&outInfo).Error
891 916
 	return outInfo, err
892 917
 }
893 918
 
@@ -907,6 +932,24 @@ func GetAllSingleDrugDetail(id int64, orgid int64) (outInfo []*models.VmDrugWare
907 932
 	return outInfo, err
908 933
 }
909 934
 
935
+func GetDrugFlowList(id int64, orgid int64) (stockflow []*models.DrugFlow, err error) {
936
+
937
+	err = XTReadDB().Where("warehouse_out_id in(?) and user_org_id = ? and status = 1", id, orgid).Preload("BaseDrugLib", "org_id = ? and status = 1", orgid).Preload("DrugWarehouseInfoOne", "org_id = ? and status = 1", orgid).Find(&stockflow).Error
938
+	return stockflow, err
939
+}
940
+
941
+func GetDrugFlowListGroupById(id int64, orgid int64) (drugFlow []*models.DrugFlow, err error) {
942
+
943
+	err = XTReadDB().Where("warehouse_out_id in(?) and user_org_id = ? and status = 1", id, orgid).Group("warehousing_detail_id").Find(&drugFlow).Error
944
+	return drugFlow, err
945
+}
946
+
947
+func GetDrugFlowListGroupByIdOne(id int64, orgid int64) (drugFlow []*models.DrugFlow, err error) {
948
+
949
+	err = XTReadDB().Where("warehouse_out_id in(?) and user_org_id = ? and status = 1", id, orgid).Group("batch_number").Find(&drugFlow).Error
950
+	return drugFlow, err
951
+}
952
+
910 953
 func FindDrugStockUserDetailByIdThree(id int64, record_time int64, org_id int64) (user []*DrugAutomaticReduceDetail, err error, total int64) {
911 954
 
912 955
 	db := readDb.Model(&user)

+ 25 - 10
service/manage_center_service.go 查看文件

@@ -439,7 +439,6 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
439 439
 	storeHouseConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
440 440
 	//退库
441 441
 	drug, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
442
-	fmt.Println("list223323232233223322323323223", len(list))
443 442
 
444 443
 	//如果剩余数量 + 退库数量 < 总入库数量
445 444
 	if len(list) > 0 {
@@ -476,9 +475,6 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
476 475
 				sum_count = druginfo.WarehousingCount
477 476
 			}
478 477
 
479
-			fmt.Println("该批次剩余库存", over_count)
480
-			fmt.Println("该批次退库数量", out_count)
481
-			fmt.Println("该批次总入库数量", sum_count)
482 478
 			if (over_count + out_count) <= sum_count {
483 479
 				if its.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
484 480
 					fmt.Println("进来1", its.Count)
@@ -487,6 +483,12 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
487 483
 						StockMinNumber: its.Count,
488 484
 					}
489 485
 					UpdateDrugWarehouse(its.WarehouseInfoId, warehouseInfo)
486
+
487
+					//增加退库数量
488
+					AddCancelSumCountOne(storeHouseConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, its.Count)
489
+					//出库数量减少
490
+					UpdateSumOutDrug(advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, advice.DrugId, its.Count)
491
+
490 492
 				}
491 493
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
492 494
 					fmt.Println("进来2", its.Count)
@@ -494,6 +496,11 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
494 496
 						StockMaxNumber: its.Count,
495 497
 					}
496 498
 					UpdateDrugWarehouseOne(its.WarehouseInfoId, warehouseInfo)
499
+
500
+					//增加退库数量
501
+					AddCancelSumCountOne(storeHouseConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, its.Count*drug.MinNumber)
502
+					//出库数量减少
503
+					UpdateSumOutDrug(advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, advice.DrugId, its.Count*drug.MinNumber)
497 504
 				}
498 505
 
499 506
 				if its.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
@@ -502,6 +509,10 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
502 509
 						StockMaxNumber: its.Count,
503 510
 					}
504 511
 					UpdateDrugWarehouseOne(its.WarehouseInfoId, warehouseInfo)
512
+					//增加退库数量
513
+					AddCancelSumCountOne(storeHouseConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, its.Count*drug.MinNumber)
514
+					//出库数量减少
515
+					UpdateSumOutDrug(advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, advice.DrugId, its.Count*drug.MinNumber)
505 516
 				}
506 517
 
507 518
 			}
@@ -566,7 +577,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
566 577
 			}
567 578
 
568 579
 			flow := models.DrugFlow{
569
-				WarehousingId:           0,
580
+				WarehousingId:           info.WarehouseInfoId,
570 581
 				DrugId:                  info.DrugId,
571 582
 				Number:                  "",
572 583
 				BatchNumber:             info.BatchNumber,
@@ -590,7 +601,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
590 601
 				Ctime:                   time.Now().Unix(),
591 602
 				Mtime:                   0,
592 603
 				Price:                   info.Price,
593
-				WarehousingDetailId:     0,
604
+				WarehousingDetailId:     info.WarehouseInfoId,
594 605
 				WarehouseOutDetailId:    0,
595 606
 				CancelOutDetailId:       0,
596 607
 				ExpireDate:              info.ExpiryDate,
@@ -666,7 +677,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
666 677
 			}
667 678
 
668 679
 			flow := models.DrugFlow{
669
-				WarehousingId:           0,
680
+				WarehousingId:           info.WarehouseInfoId,
670 681
 				DrugId:                  info.DrugId,
671 682
 				Number:                  "",
672 683
 				BatchNumber:             info.BatchNumber,
@@ -690,7 +701,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
690 701
 				Ctime:                   time.Now().Unix(),
691 702
 				Mtime:                   0,
692 703
 				Price:                   info.Price,
693
-				WarehousingDetailId:     0,
704
+				WarehousingDetailId:     info.WarehouseInfoId,
694 705
 				WarehouseOutDetailId:    0,
695 706
 				CancelOutDetailId:       0,
696 707
 				ExpireDate:              info.ExpiryDate,
@@ -766,7 +777,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
766 777
 			}
767 778
 
768 779
 			flow := models.DrugFlow{
769
-				WarehousingId:           0,
780
+				WarehousingId:           info.WarehouseInfoId,
770 781
 				DrugId:                  info.DrugId,
771 782
 				Number:                  "",
772 783
 				BatchNumber:             info.BatchNumber,
@@ -790,7 +801,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
790 801
 				Ctime:                   time.Now().Unix(),
791 802
 				Mtime:                   0,
792 803
 				Price:                   info.Price,
793
-				WarehousingDetailId:     0,
804
+				WarehousingDetailId:     info.WarehouseInfoId,
794 805
 				WarehouseOutDetailId:    0,
795 806
 				CancelOutDetailId:       0,
796 807
 				ExpireDate:              info.ExpiryDate,
@@ -817,6 +828,10 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
817 828
 			sum_count_one += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
818 829
 		}
819 830
 		UpdateBaseDrugSumTwo(advice.DrugId, sum_count_one, advice.UserOrgId)
831
+
832
+		//更新库存
833
+		UpdateSumDrug(advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, advice.DrugId, sum_count_one)
834
+
820 835
 	}
821 836
 	return err
822 837
 }

+ 18 - 7
service/mobile_dialysis_service.go 查看文件

@@ -761,9 +761,10 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
761 761
 
762 762
 	// cur_date := time.Now().Format("2006-01-02")
763 763
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
764
-
764
+	fmt.Println("key23233232323323wi", key)
765 765
 	doctor_advices_str, _ := redis.Get(key).Result()
766
-
766
+	redis.Set(doctor_advices_str, "", time.Second)
767
+	redis.Set(doctor_advices_str, "", time.Second)
767 768
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
768 769
 
769 770
 		err := readDb.Model(&models.DoctorAdvice{}).
@@ -2707,6 +2708,7 @@ type MDialysisGoodsVM struct {
2707 2708
 	DialysisBeforePrepare     []*DialysisBeforePrepare         `gorm:"ForeignKey:PatientId,ScheduleDate;AssociationForeignKey:PatientId,RecordDate" json:"good_user_detail"`
2708 2709
 	LastDialysisBeforePrepare []*DialysisBeforePrepare         `gorm:"-" json:"last_good_user_detail"`
2709 2710
 	Project                   []*models.HisPrescriptionProject `gorm:"-" json:"project"`
2711
+	//WarehouseOutInfo          []*models.WarehouseOutInfoSeven   `gorm:"ForeignKey:PatientId,ScheduleDate;AssociationForeignKey:PatientId,SysRecordTime" json:"ware_house_out_info"`
2710 2712
 }
2711 2713
 
2712 2714
 func (MDialysisGoodsVM) TableName() string {
@@ -2771,10 +2773,7 @@ func MobileGetDialysisGoods(orgID int64, scheduleDate int64, schedule_type int64
2771 2773
 	if patient_id != 0 {
2772 2774
 		db = db.Where("patient_id = ?", patient_id)
2773 2775
 	}
2774
-	//db = db.Count(&total)
2775
-	//offset := (page - 1) * limit
2776
-	//
2777
-	//db = db.Offset(offset).Limit(limit)
2776
+
2778 2777
 	err := db.Find(&vms).Error
2779 2778
 
2780 2779
 	return vms, err, total
@@ -2801,6 +2800,12 @@ func GetLastDialysisBeforePrepare(patient_id int64, orgID int64, record_time int
2801 2800
 	return
2802 2801
 }
2803 2802
 
2803
+func GetAllWarehouseOutSumList(patient_id int64, orgID int64, record_time int64) (info []*models.WarehouseOutInfoSeven, err error) {
2804
+
2805
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and sys_record_time = ? and status = 1", patient_id, orgID, record_time).Find(&info).Error
2806
+	return info, err
2807
+}
2808
+
2804 2809
 func MobileGetGoodsStatistics(orgID int64, start_time int64, end_time int64) (list []*models.StockInfo, err error) {
2805 2810
 	db := readDb.Model(&models.StockInfo{})
2806 2811
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgID)
@@ -2920,7 +2925,7 @@ func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his
2920 2925
 	his_doctor_advice_str, _ := redis.Get(key).Result()
2921 2926
 	redis.Set(key, "", time.Second)
2922 2927
 	if len(his_doctor_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2923
-		err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patientid, orgid, recorddate).Find(&his).Error
2928
+		err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ?", patientid, orgid, recorddate).Order("created_time asc").Find(&his).Error
2924 2929
 		if err != nil {
2925 2930
 			if err == gorm.ErrRecordNotFound {
2926 2931
 				if len(his) <= 0 {
@@ -4098,3 +4103,9 @@ func GetDialysisGood(orgID int64, scheduleDate int64) (auto []*models.AutomaticR
4098 4103
 	err = readDb.Where("org_id = ? and status = 1 and record_time >= ?", orgID, scheduleDate).Group("patient_id").Find(&auto).Error
4099 4104
 	return auto, err
4100 4105
 }
4106
+
4107
+func GetGoodWarehouseOutInfo(orgId int64, patient_id int64, sys_record_time int64) (outifno []*models.WarehouseOutInfoSeven, err error) {
4108
+
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
4110
+	return outifno, err
4111
+}

+ 340 - 0
service/new_stock_service.go 查看文件

@@ -0,0 +1,340 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetGoodStockCount(user_org_id int64, storehouse_id int64, good_id int64) (*models.XtGoodStockCount, error) {
9
+
10
+	goodStock := models.XtGoodStockCount{}
11
+	var err error
12
+	err = XTReadDB().Where("user_org_id = ? and storehouse_id = ? and good_id = ?", user_org_id, storehouse_id, good_id).Find(&goodStock).Error
13
+	if err == gorm.ErrRecordNotFound {
14
+		return nil, err
15
+	}
16
+	if err != nil {
17
+		return nil, err
18
+	}
19
+	return &goodStock, nil
20
+}
21
+
22
+func CreateGoodCount(good models.XtGoodStockCount) error {
23
+
24
+	db := writeDb.Begin()
25
+	err := db.Create(&good).Error
26
+	if err != nil {
27
+		db.Rollback()
28
+		return err
29
+	}
30
+	db.Commit()
31
+	return err
32
+}
33
+
34
+func UpdateGoodStockCount(user_org_id int64, storehouse_id int64, good_id int64, count int64, flush_count int64) error {
35
+
36
+	db := writeDb.Begin()
37
+	err = db.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and good_id  = ? and status = 1", user_org_id, storehouse_id, good_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count + ?", count)).Error
38
+	if err != nil {
39
+		db.Rollback()
40
+		return err
41
+	}
42
+	err = db.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and storehouse_id = ? and good_id = ? and status = 1", user_org_id, storehouse_id, good_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
43
+	if err != nil {
44
+		db.Rollback()
45
+		return err
46
+	}
47
+	db.Commit()
48
+	return err
49
+}
50
+
51
+func UpdateGoodInCount(count int64, user_org_id int64, good_id int64, storehouse_id int64, flush_count int64) error {
52
+	db := writeDb.Begin()
53
+	err := db.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id  = ? and storehouse_id = ? and status = 1", user_org_id, good_id, storehouse_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count - ?", count)).Error
54
+	if err != nil {
55
+		db.Rollback()
56
+		return err
57
+	}
58
+	err = db.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and good_id = ? and storehouse_id = ? and status = 1", user_org_id, good_id, storehouse_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
59
+	if err != nil {
60
+		db.Rollback()
61
+		return err
62
+	}
63
+	db.Commit()
64
+	return err
65
+}
66
+
67
+func CreateGoodErrcode(errcode models.XtGoodErrcode) error {
68
+
69
+	db := writeDb.Begin()
70
+	err := db.Create(&errcode).Error
71
+	if err != nil {
72
+		db.Rollback()
73
+		return err
74
+	}
75
+	db.Commit()
76
+	return err
77
+}
78
+
79
+func GetGoodStockList(orgId int64, storehouse_id int64, good_type int64, keyword string, page int64, limit int64, ids []int64) (good []*models.GoodInformation, total int64, err error) {
80
+	offset := (page - 1) * limit
81
+	likeKey := "%" + keyword + "%"
82
+
83
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1 and x.total_count > 0 and x.org_id =?", orgId)
84
+
85
+	if good_type == 2 {
86
+		db = db.Where(" x.total_count<=x.stock_warn_count")
87
+	}
88
+
89
+	if len(keyword) > 0 {
90
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
91
+	}
92
+
93
+	db = db.Preload("XtGoodStockCount", func(db *gorm.DB) *gorm.DB {
94
+		if storehouse_id > 0 {
95
+			db = db.Where("storehouse_id = ?", storehouse_id)
96
+		}
97
+		return db.Where("status = 1 and user_org_id = ?", orgId)
98
+	})
99
+
100
+	db = db.Preload("GoodStockCount", func(db *gorm.DB) *gorm.DB {
101
+		if storehouse_id > 0 {
102
+			db = db.Where("storehouse_id = ?", storehouse_id)
103
+		}
104
+		return db.Where("status = 1 and user_org_id = ?", orgId).Group("good_id,storehouse_id")
105
+	})
106
+
107
+	db = db.Preload("WarehousingInfo", func(db *gorm.DB) *gorm.DB {
108
+		if storehouse_id > 0 {
109
+			db = db.Where("storehouse_id = ?", storehouse_id)
110
+		}
111
+		return db.Where("status = 1 and org_id = ? and is_check = 1", orgId)
112
+	})
113
+
114
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Find(&good).Error
115
+
116
+	return good, total, err
117
+}
118
+
119
+func GetSumGoodList(orgid int64, storehouse_id int64, good_id int64) (info []*models.WarehousingInfo, err error) {
120
+
121
+	err = XTReadDB().Where("org_id = ? and storehouse_id = ? and good_id = ? and status =1  and is_check = 1", orgid, storehouse_id, good_id).Find(&info).Error
122
+	return info, err
123
+}
124
+
125
+func UpdateSumGood(orgid int64, storehouse_id int64, good_id int64, flush_count int64) error {
126
+	db := writeDb.Begin()
127
+	err := db.Model(&models.XtGoodStockCount{}).Where("user_org_id = ? and storehouse_id = ? and good_id = ? and status = 1", orgid, storehouse_id, good_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
128
+	if err != nil {
129
+		db.Rollback()
130
+		return err
131
+	}
132
+	db.Commit()
133
+	return err
134
+}
135
+
136
+func UpdateSumCount(user_org_id int64, storehouse_id int64, good_id int64, count int64) error {
137
+	ut := XTWriteDB().Begin()
138
+
139
+	err = ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count - ?", count)).Error
140
+	if err != nil {
141
+		ut.Rollback()
142
+		return err
143
+	}
144
+	ut.Commit()
145
+	return err
146
+}
147
+
148
+func GetSendGoodInformation(org_id int64) (info []*models.WarehousingInfo, err error) {
149
+
150
+	err = XTReadDB().Where("org_id = ? and is_check = 1 and status = 1", org_id).Find(&info).Error
151
+	return info, err
152
+}
153
+
154
+func GetStockFlush(storehouse_id int64, good_id int64, orgid int64) (*models.XtGoodStockCount, error) {
155
+
156
+	stockCount := models.XtGoodStockCount{}
157
+	var err error
158
+	err = XTReadDB().Where("storehouse_id  =? and good_id = ? and user_org_id = ?", storehouse_id, good_id, orgid).Find(&stockCount).Error
159
+	if err == gorm.ErrRecordNotFound {
160
+		return nil, err
161
+	}
162
+	if err != nil {
163
+		return nil, err
164
+	}
165
+	return &stockCount, nil
166
+}
167
+
168
+func CreateGoodCountSix(good models.XtGoodStockCount) error {
169
+
170
+	err := XTWriteDB().Create(&good).Error
171
+	return err
172
+}
173
+
174
+func UpdateGoodCount(warehousingCount int64, stock_count int64, out_count int64, storehouse_id int64, good_id int64, orgid int64, cancel_count int64, act_count int64) error {
175
+
176
+	err := XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and good_id = ? and status =1 and user_org_id = ?", storehouse_id, good_id, orgid).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count+?", warehousingCount)).Error
177
+	err = XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and good_id = ? and status =1 and user_org_id = ?", storehouse_id, good_id, orgid).Update(map[string]interface{}{"stock_out_count": out_count}).Error
178
+	err = XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and good_id = ? and status =1 and user_org_id = ?", storehouse_id, good_id, orgid).UpdateColumn("flush_count", gorm.Expr("flush_count + ?", stock_count)).Error
179
+	err = XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and good_id = ? and status =1 and user_org_id = ?", storehouse_id, good_id, orgid).Update(map[string]interface{}{"stock_cancel_count": cancel_count}).Error
180
+	err = XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and good_id = ? and status =1 and user_org_id = ?", storehouse_id, good_id, orgid).Update(map[string]interface{}{"stock_act_out_count": act_count}).Error
181
+	return err
182
+}
183
+
184
+func GetAllCancelCount(storehouse_id int64, good_id int64, org_id int64) (flow []*models.VmStockFlow, err error) {
185
+
186
+	err = XTReadDB().Where("storehouse_id = ? and good_id = ? and user_org_id = ? and (consumable_type = 4 or consumable_type= 7) and status = 1", storehouse_id, good_id, org_id).Find(&flow).Error
187
+	return flow, err
188
+}
189
+
190
+func GetAllStockOutCount(storehouse_id int64, good_id int64, org_id int64) (flow []*models.VmStockFlow, err error) {
191
+
192
+	err = XTReadDB().Where("storehouse_id = ? and good_id = ? and user_org_id = ? and (consumable_type = 2 or consumable_type= 3) and is_read = 0", storehouse_id, good_id, org_id).Find(&flow).Error
193
+	return flow, err
194
+}
195
+
196
+func GetActStockOutCount(storehouse_id int64, good_id int64, org_id int64) (flow []*models.VmStockFlow, err error) {
197
+	err = XTReadDB().Where("storehouse_id = ? and good_id = ? and user_org_id = ? and (consumable_type = 2 or consumable_type= 3) and status = 1", storehouse_id, good_id, org_id).Find(&flow).Error
198
+	return flow, err
199
+}
200
+
201
+func GetDrugStockCount(storehouse_id int64, drug_id int64, org_id int64) (*models.XtDrugStockCount, error) {
202
+	drugStockCount := models.XtDrugStockCount{}
203
+	var err error
204
+	err = XTReadDB().Where("storehouse_id = ? and drug_id = ? and user_org_id  = ? and status = 1", storehouse_id, drug_id, org_id).Find(&drugStockCount).Error
205
+	if err == gorm.ErrRecordNotFound {
206
+		return nil, err
207
+	}
208
+	if err != nil {
209
+		return nil, err
210
+	}
211
+	return &drugStockCount, nil
212
+}
213
+
214
+func CreateDrugStockSum(drug models.XtDrugStockCount) error {
215
+
216
+	ut := XTWriteDB().Begin()
217
+	err := ut.Create(&drug).Error
218
+	if err != nil {
219
+		ut.Rollback()
220
+		return err
221
+	}
222
+	ut.Commit()
223
+	return err
224
+}
225
+
226
+func AddDrugStockSum(storehouse_id int64, drug_id int64, user_org_id int64, waresing_count int64, over_count int64) error {
227
+
228
+	db := writeDb.Begin()
229
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id  = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", waresing_count)).Error
230
+	if err != nil {
231
+		db.Rollback()
232
+		return err
233
+	}
234
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
235
+	if err != nil {
236
+		db.Rollback()
237
+		return err
238
+	}
239
+	db.Commit()
240
+	return err
241
+}
242
+
243
+func UpdateDrugStockSum(storehouse_id int64, drug_id int64, user_org_id int64, waresing_count int64, over_count int64) error {
244
+	db := writeDb.Begin()
245
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id  = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"sum_in_count": waresing_count}).Error
246
+	if err != nil {
247
+		db.Rollback()
248
+		return err
249
+	}
250
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
251
+	if err != nil {
252
+		db.Rollback()
253
+		return err
254
+	}
255
+	db.Commit()
256
+	return err
257
+}
258
+
259
+func ReduceDrugStockCount(storehouse_id int64, drug_id int64, user_org_id int64, waresing_count int64, over_count int64) error {
260
+	db := writeDb.Begin()
261
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count - ?", waresing_count)).Error
262
+	if err != nil {
263
+		db.Rollback()
264
+		return err
265
+	}
266
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
267
+	if err != nil {
268
+		db.Rollback()
269
+		return err
270
+	}
271
+	db.Commit()
272
+	return err
273
+}
274
+
275
+func AddCancelSumCount(storehouse_id int64, drug_id int64, user_org_id int64, cancel_count int64, over_count int64) error {
276
+
277
+	db := writeDb.Begin()
278
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_cancel_count", gorm.Expr("sum_cancel_count + ?", cancel_count)).Error
279
+	if err != nil {
280
+		db.Rollback()
281
+		return err
282
+	}
283
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
284
+	if err != nil {
285
+		db.Rollback()
286
+		return err
287
+	}
288
+	db.Commit()
289
+	return err
290
+}
291
+
292
+func AddCancelSumCountOne(storehouse_id int64, drug_id int64, user_org_id int64, cancel_count int64) error {
293
+
294
+	db := writeDb.Begin()
295
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_cancel_count", gorm.Expr("sum_cancel_count + ?", cancel_count)).Error
296
+	if err != nil {
297
+		db.Rollback()
298
+		return err
299
+	}
300
+	db.Commit()
301
+	return err
302
+}
303
+
304
+func ReduceCancelSumCount(storehouse_id int64, drug_id int64, user_org_id int64, cancel_count int64, over_count int64) error {
305
+	db := writeDb.Begin()
306
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_cancel_count", gorm.Expr("sum_cancel_count - ?", cancel_count)).Error
307
+	if err != nil {
308
+		db.Rollback()
309
+		return err
310
+	}
311
+	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": over_count}).Error
312
+	if err != nil {
313
+		db.Rollback()
314
+		return err
315
+	}
316
+	db.Commit()
317
+	return err
318
+}
319
+
320
+func UpdateSumDrug(orgid int64, storehouse_id int64, drug_id int64, flush_count int64) error {
321
+	db := writeDb.Begin()
322
+	err := db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", orgid, storehouse_id, drug_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
323
+	if err != nil {
324
+		db.Rollback()
325
+		return err
326
+	}
327
+	db.Commit()
328
+	return err
329
+}
330
+
331
+func UpdateSumOutDrug(orgid int64, storehouse_id int64, drug_id int64, sum_out_count int64) error {
332
+	db := writeDb.Begin()
333
+	err := db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id = ? and drug_id = ? and status = 1", orgid, storehouse_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count - ?", sum_out_count)).Error
334
+	if err != nil {
335
+		db.Rollback()
336
+		return err
337
+	}
338
+	db.Commit()
339
+	return err
340
+}

文件差異過大導致無法顯示
+ 2013 - 0
service/new_warehouse_service.go


+ 32 - 1
service/patient_service.go 查看文件

@@ -129,7 +129,7 @@ func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientLi
129 129
 
130 130
 func GetAllDevicetByListSix(orgID int64) (devices []*models.MDeviceNumberForList, err error) {
131 131
 
132
-	err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=? and status=1 ", orgID).Find(&devices).Error
132
+	err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=?", orgID).Find(&devices).Error
133 133
 	return devices, err
134 134
 }
135 135
 
@@ -2636,3 +2636,34 @@ func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*mod
2636 2636
 	err = XTReadDB().Where("user_org_id = ? and record_date = ? and status = 1", orgid, recorddate).Find(&project).Error
2637 2637
 	return project, err
2638 2638
 }
2639
+
2640
+func GetPatientDialysisLongSolution(patient_id int64, page int64, limit int64, orgid int64) (solution []*models.DialysisSolution, total int64, err error) {
2641
+
2642
+	db := XTReadDB().Model(&solution).Where("status = 1 and solution_status = 1")
2643
+	if patient_id > 0 {
2644
+		db = db.Where("patient_id = ?", patient_id)
2645
+	}
2646
+	if orgid > 0 {
2647
+		db = db.Where("user_org_id = ?", orgid)
2648
+	}
2649
+	offset := (page - 1) * limit
2650
+
2651
+	err = db.Group("mode_id").Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&solution).Error
2652
+	return solution, total, err
2653
+}
2654
+
2655
+func GetDialysisSolutionDetailList(orgid int64, patient_id int64, mode_id int64, page int64, limit int64) (solution []*models.DialysisSolution, total int64, err error) {
2656
+	offset := (page - 1) * limit
2657
+	db := XTReadDB().Model(&solution).Where("status = 1")
2658
+	if orgid > 0 {
2659
+		db = db.Where("user_org_id = ?", orgid)
2660
+	}
2661
+	if patient_id > 0 {
2662
+		db = db.Where("patient_id = ?", patient_id)
2663
+	}
2664
+	if mode_id > 0 {
2665
+		db = db.Where("mode_id = ?", mode_id)
2666
+	}
2667
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&solution).Order("created_time desc").Error
2668
+	return solution, total, err
2669
+}

+ 1 - 0
service/pharmacy_service.go 查看文件

@@ -1851,6 +1851,7 @@ func CalculateTheTotalAmount(tmp []*models.PatientInformation, drug_id int64) (t
1851 1851
 	minmunber := t.MinNumber                               //拆零数量
1852 1852
 	terrUnit := ""
1853 1853
 	for _, v := range tmp {
1854
+		fmt.Println("v2332233232322323", v.Quantity)
1854 1855
 		switch v.Unit {
1855 1856
 		case t.MaxUnit:
1856 1857
 			maxunit = maxunit + v.Quantity

+ 1 - 1
service/secondary_service.go 查看文件

@@ -1086,7 +1086,7 @@ func GetStoreHouseDrugWarehouseingInfo(id int64) (models.DrugWarehouseInfo, erro
1086 1086
 
1087 1087
 func GetDrugSumCountByStorehouseId(storehouse_id int64, orgid int64, drug_id int64) (info []*models.DrugWarehouseInfo, err error) {
1088 1088
 
1089
-	err = XTReadDB().Where("storehouse_id = ? and org_id = ? and status = 1 and (stock_max_number >0 or stock_min_number>0) and drug_id =? and is_check = 1", storehouse_id, orgid, drug_id).Find(&info).Error
1089
+	err = XTReadDB().Where("storehouse_id = ? and org_id = ? and status = 1  and drug_id =? and is_check = 1", storehouse_id, orgid, drug_id).Find(&info).Error
1090 1090
 	return info, err
1091 1091
 }
1092 1092
 

文件差異過大導致無法顯示
+ 1169 - 80
service/self_drug_service.go


+ 430 - 71
service/stock_service.go 查看文件

@@ -734,8 +734,13 @@ func UpdateDrugWarehouseingInfo(id int64, info models.XtDrugWarehouseInfo) error
734 734
 }
735 735
 
736 736
 func CreateDrugFlowOne(flow models.DrugFlow) error {
737
-
738
-	err := XTWriteDB().Create(&flow).Error
737
+	ut := writeDb.Begin()
738
+	err := ut.Create(&flow).Error
739
+	if err != nil {
740
+		ut.Rollback()
741
+		return err
742
+	}
743
+	ut.Commit()
739 744
 	return err
740 745
 }
741 746
 
@@ -748,7 +753,7 @@ func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice
748 753
 
749 754
 func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64) (models.DrugFlow, error) {
750 755
 	flow := models.DrugFlow{}
751
-	err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1 and advice_id =?", patientid, warehouse_out_number, drug_id, advice_id).Updates(map[string]interface{}{"status": 0}).Error
756
+	err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1 and advice_id =?", patientid, warehouse_out_number, drug_id, advice_id).Updates(map[string]interface{}{"is_read": 1}).Error
752 757
 	return flow, err
753 758
 }
754 759
 
@@ -3179,7 +3184,7 @@ func GetStockInRecoredByGoodIdOne(goodid int64, goodtypeid int64, recordtime int
3179 3184
 
3180 3185
 func UpdateAutoMaticReduceDetail(goodid int64, goodtypeid int64, recordtime int64, patientid int64, orgid int64, prepare *models.WarehouseOutInfo) error {
3181 3186
 
3182
-	err := XTWriteDB().Model(&prepare).Where("good_id = ? and good_type_id = ? and sys_record_time = ? and patient_id = ? and org_id = ? and status =1", goodid, goodtypeid, recordtime, patientid, orgid).Updates(map[string]interface{}{"count": prepare.Count}).Error
3187
+	err := XTWriteDB().Model(&prepare).Where("good_id = ? and good_type_id = ? and sys_record_time = ? and patient_id = ? and org_id = ? and status =1", goodid, goodtypeid, recordtime, patientid, orgid).Updates(map[string]interface{}{"count": prepare.Count, "over_count": prepare.OverCount}).Error
3183 3188
 	return err
3184 3189
 }
3185 3190
 
@@ -3837,6 +3842,12 @@ func GetAutoMaticReduceDetail(orgid int64, patient_id int64, recordtime int64, g
3837 3842
 	return &autoreduece, nil
3838 3843
 }
3839 3844
 
3845
+func GetAutoMaticReduceDetailTwenty(orgid int64, patient_id int64, recordtime int64, goodid int64, goodtypeid int64) (models.BloodAutomaticReduceDetail, error) {
3846
+	auto := models.BloodAutomaticReduceDetail{}
3847
+	err = XTReadDB().Model(&auto).Where("org_id = ? and patient_id = ?  and status = 1 and record_time = ? and good_id = ? and good_type_id = ? and count>0", orgid, patient_id, recordtime, goodid, goodtypeid).Find(&auto).Error
3848
+	return auto, err
3849
+}
3850
+
3840 3851
 func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64, goodid int64, goodtypeid int64) error {
3841 3852
 
3842 3853
 	detail := models.BloodAutomaticReduceDetail{}
@@ -3850,6 +3861,16 @@ func GetWarehosueOutByStockFlow(patient_id int64, recrod_date int64, goodid int6
3850 3861
 	return stockflow, err
3851 3862
 }
3852 3863
 
3864
+func UpdateAutoGood(orgid int64, patient_id int64, recordtime int64, goodid int64, project_id int64, count int64) (err error) {
3865
+
3866
+	err = XTWriteDB().Model(models.BloodAutomaticReduceDetail{}).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ?", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3867
+	err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3868
+	//err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("over_count", gorm.Expr("over_count + ?", count)).Error
3869
+	err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3870
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1 and project_id = ?", orgid, patient_id, recordtime, goodid, project_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3871
+	return err
3872
+}
3873
+
3853 3874
 func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64, goodid int64) error {
3854 3875
 
3855 3876
 	detail := models.BloodAutomaticReduceDetail{}
@@ -3859,14 +3880,15 @@ func DeleteAutoRedeceDetailTen(orgid int64, patient_id int64, recordtime int64,
3859 3880
 	prepare := models.DialysisBeforePrepare{}
3860 3881
 	err = XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3861 3882
 	flow := models.VmStockFlow{}
3862
-	err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3883
+	err = XTWriteDB().Model(&flow).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).Updates(map[string]interface{}{"is_read": 1}).Error
3863 3884
 	return err
3864 3885
 
3865 3886
 }
3866 3887
 
3867
-func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3888
+func UpDateWarehouseInfoByStockDelete(id int64, count int64, patient_id int64, record_time int64, goodid int64) (err error) {
3868 3889
 
3869 3890
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
3891
+	err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", id, patient_id, record_time, goodid).UpdateColumn("over_count", gorm.Expr("over_count + ?", count)).Error
3870 3892
 	return err
3871 3893
 }
3872 3894
 
@@ -3932,18 +3954,11 @@ func GetHisProjectPrescriptionByPatientIdOne(id int64) (models.HisPrescriptionPr
3932 3954
 
3933 3955
 func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfoNight, err error) {
3934 3956
 
3935
-	err = XTReadDB().Select("count,warehouse_info_id,good_id,org_id").Where(" patient_id = ? and sys_record_time = ?  and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error
3957
+	err = XTReadDB().Select("count,warehouse_info_id,good_id,org_id,sys_record_time,patient_id,project_id,warehouse_info_id,warehouse_out_order_number,storehouse_id,price,dealer,manufacturer,good_type_id,product_date,expiry_date,number,license_number").Where(" patient_id = ? and sys_record_time = ?  and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error
3936 3958
 	return auto, err
3937 3959
 
3938 3960
 }
3939 3961
 
3940
-//func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.VmStockFlow, err error) {
3941
-//
3942
-//	err = XTReadDB().Select("count,warehousing_id").Where(" patient_id = ? and system_time = ?  and status = 1 and is_sys = 1 and count>0",patientid,recorddate).Find(&auto).Error
3943
-//	return auto, err
3944
-//
3945
-//}
3946
-
3947 3962
 func ModefyWarehouseInfo(count int64, id int64) error {
3948 3963
 
3949 3964
 	err := XTWriteDB().Model(models.WarehousingInfo{}).Where(" id =? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
@@ -3954,9 +3969,9 @@ func DeleteAutoWarehouse(patient_id int64, record_time int64) error {
3954 3969
 
3955 3970
 	err := XTWriteDB().Model(models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3956 3971
 	err = XTWriteDB().Model(models.DialysisBeforePrepare{}).Where("patient_id = ? and record_date = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3957
-	err = XTWriteDB().Model(models.VmStockFlow{}).Where("patient_id = ? and system_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3958
-	err = XTWriteDB().Model(models.WarehouseOutInfoNight{}).Where("patient_id = ? and sys_record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3959
-	fmt.Println("err2332332322323322323232323232332", err)
3972
+	err = XTWriteDB().Model(models.VmStockFlow{}).Where("patient_id = ? and system_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"is_read": 1}).Error
3973
+	//err = XTWriteDB().Model(models.WarehouseOutInfoNight{}).Where("patient_id = ? and sys_record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3974
+
3960 3975
 	return err
3961 3976
 }
3962 3977
 
@@ -4069,7 +4084,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
4069 4084
 	return info, total, err
4070 4085
 }
4071 4086
 
4072
-func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
4087
+func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64, startfirsttime int64, endfirsttime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
4073 4088
 
4074 4089
 	offset := (page - 1) * limit
4075 4090
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1 and x.is_check = 1")
@@ -4082,6 +4097,12 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
4082 4097
 	if endtime > 0 {
4083 4098
 		db = db.Where("x.ctime<=?", endtime)
4084 4099
 	}
4100
+	if startfirsttime > 0 {
4101
+		db = db.Where("x.expiry_date >=?", startfirsttime)
4102
+	}
4103
+	if endfirsttime > 0 {
4104
+		db = db.Where("x.expiry_date <=?", endfirsttime)
4105
+	}
4085 4106
 
4086 4107
 	if orgid > 0 {
4087 4108
 		db = db.Where("x.org_id = ?", orgid)
@@ -4089,7 +4110,7 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
4089 4110
 	if good_id > 0 {
4090 4111
 		db = db.Where("x.good_id = ?", good_id)
4091 4112
 	}
4092
-	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price,f.batch_number_count").Joins("left join xt_good_information as t on t.id = x.good_id").Joins("left join xt_stock_flow as f on f.warehousing_detail_id = x.id").Count(&total).Offset(offset).Limit(limit).Order("x.id desc").Scan(&info).Error
4113
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.packing_price,t.manufacturer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,x.storehouse_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.buy_price,f.batch_number_count").Joins("left join xt_good_information as t on t.id = x.good_id").Joins("left join xt_stock_flow as f on f.warehousing_detail_id = x.id").Count(&total).Offset(offset).Limit(limit).Group("x.id").Order("x.id desc").Scan(&info).Error
4093 4114
 	return info, total, err
4094 4115
 
4095 4116
 }
@@ -4199,9 +4220,7 @@ func GetWarehouseOutOrder(id []string, orgid int64) (out []*models.WarehouseOut,
4199 4220
 	if orgid > 0 {
4200 4221
 		db = db.Where("x.org_id= ?", orgid)
4201 4222
 	}
4202
-	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Preload("WarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
4203
-		return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid)
4204
-	}).Find(&out).Error
4223
+	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Find(&out).Error
4205 4224
 	return out, err
4206 4225
 }
4207 4226
 
@@ -4218,11 +4237,49 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4218 4237
 		db = db.Where("x.org_id = ?", orgid)
4219 4238
 	}
4220 4239
 
4221
-	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,t.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,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").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
4222 4241
 
4223 4242
 	return out, err
4224 4243
 }
4225 4244
 
4245
+func GetOrderDetailStockFlowByStorehouseById(id []string, orgid int64) (list []*models.VmStockFlow, err error) {
4246
+	db := XTReadDB().Model(&list).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
4247
+	if len(id) > 0 {
4248
+		db = db.Where("warehouse_out_id in (?)", id)
4249
+	}
4250
+	if orgid > 0 {
4251
+		db = db.Where("user_org_id = ?", orgid)
4252
+	}
4253
+	err = db.Group("warehousing_id").Find(&list).Error
4254
+	return list, err
4255
+}
4256
+
4257
+func GetOrderDetailStockFlow(id []string, orgid int64) (list []*models.VmStockFlow, err error) {
4258
+
4259
+	db := XTReadDB().Model(&list).Where("status = 1 and (consumable_type = 2 or consumable_type = 3)")
4260
+	if len(id) > 0 {
4261
+		db = db.Where("warehouse_out_id in (?)", id)
4262
+	}
4263
+	if orgid > 0 {
4264
+		db = db.Where("user_org_id = ?", orgid)
4265
+	}
4266
+	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&list).Error
4267
+	return list, err
4268
+}
4269
+
4270
+func GetOrderStockFlow(id []string, orgid int64) (list []*models.VmStockFlow, err error) {
4271
+
4272
+	db := XTReadDB().Model(&list).Where("status = 1 and consumable_type = 7 and patient_id > 0")
4273
+	if len(id) > 0 {
4274
+		db = db.Where("warehouse_out_id in (?)", id)
4275
+	}
4276
+	if orgid > 0 {
4277
+		db = db.Where("user_org_id = ?", orgid)
4278
+	}
4279
+	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&list).Error
4280
+	return list, err
4281
+}
4282
+
4226 4283
 func GetLastWarehouseOutInfo(ids []string, orgId int64) (info []*models.WarehouseOutInfoSix, err error) {
4227 4284
 
4228 4285
 	db := XTReadDB().Model(&info)
@@ -4727,7 +4784,24 @@ func GetStockFlowBatchNumber(id int64, goodid int64) (stock []*models.VmStockFlo
4727 4784
 
4728 4785
 func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
4729 4786
 
4730
-	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and count > 0")
4787
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and x.count > 0 and (x.consumable_type = 3 or x.consumable_type = 2)")
4788
+	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
4789
+	fmt.Println(table)
4790
+	tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
4791
+	fmt.Println(tableone)
4792
+	if id > 0 {
4793
+		db = db.Where("x.warehouse_out_id = ?", id)
4794
+	}
4795
+	if goodid > 0 {
4796
+		db = db.Where("x.good_id = ?", goodid)
4797
+	}
4798
+
4799
+	err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
4800
+	return stock, err
4801
+}
4802
+
4803
+func GetStockFlowCancelInfo(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
4804
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and x.count > 0 and x.consumable_type = 7")
4731 4805
 	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
4732 4806
 	fmt.Println(table)
4733 4807
 	tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
@@ -4740,7 +4814,6 @@ func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStock
4740 4814
 	}
4741 4815
 
4742 4816
 	err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
4743
-	//err =XTReadDB()()()()().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
4744 4817
 	return stock, err
4745 4818
 }
4746 4819
 
@@ -4782,7 +4855,7 @@ func GetExportOutOrderDrugListOne(warehouse_out_id []string) (out []*models.StDr
4782 4855
 	if len(warehouse_out_id) > 0 {
4783 4856
 		db = db.Where("x.warehouse_out_id in(?)", warehouse_out_id)
4784 4857
 	}
4785
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.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,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
4786 4859
 	return out, err
4787 4860
 }
4788 4861
 
@@ -4901,13 +4974,13 @@ func CreateStockFlow(warehousingInfo []*models.VmStockFlow) (err error) {
4901 4974
 }
4902 4975
 
4903 4976
 func CreateStockFlowOne(flow models.VmStockFlow) error {
4904
-	tx := XTWriteDB().Begin()
4905
-	err := tx.Create(&flow).Error
4977
+	utx := XTWriteDB().Begin()
4978
+	err := utx.Create(&flow).Error
4906 4979
 	if err != nil {
4907
-		tx.Rollback()
4980
+		utx.Rollback()
4908 4981
 		return err
4909 4982
 	}
4910
-	tx.Commit()
4983
+	utx.Commit()
4911 4984
 	return err
4912 4985
 }
4913 4986
 
@@ -4924,7 +4997,7 @@ func UpdatedStockFlow(flow models.VmStockFlow) error {
4924 4997
 
4925 4998
 func UpdatedStockFlowOne(flow models.VmStockFlow, warehousing_id int64, patient_id int64, record_time int64, good_id int64) error {
4926 4999
 
4927
-	err = XTWriteDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer}).Error
5000
+	err = XTWriteDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "over_count": flow.OverCount}).Error
4928 5001
 	return err
4929 5002
 }
4930 5003
 
@@ -4932,7 +5005,7 @@ func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int
4932 5005
 
4933 5006
 	stock := models.VmStockFlow{}
4934 5007
 	var err error
4935
-	err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
5008
+	err = XTReadDB().Model(&stock).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1 and is_read = 0", warehousing_id, patient_id, record_time, good_id).Find(&stock).Error
4936 5009
 	if err == gorm.ErrRecordNotFound {
4937 5010
 		return nil, err
4938 5011
 	}
@@ -4942,6 +5015,24 @@ func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int
4942 5015
 	return &stock, nil
4943 5016
 }
4944 5017
 
5018
+func GetStockFlowIsBatchNumber(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (flow []*models.VmStockFlow, err error) {
5019
+
5020
+	err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and status = 1 and consumable_type = 3", patient_id, record_time, good_id).Find(&flow).Error
5021
+	return flow, nil
5022
+}
5023
+
5024
+func GetStockFlowIsBatchNumberTwo(patient_id int64, record_time int64, good_id int64) (flow []*models.WarehouseOutInfo, err error) {
5025
+
5026
+	err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and good_id = ? and status = 1 ", patient_id, record_time, good_id).Find(&flow).Error
5027
+	return flow, nil
5028
+}
5029
+
5030
+func GetStockFlowIsBatchNumberThree(patient_id int64, record_time int64, good_id int64) (flow []*models.VmStockFlow, err error) {
5031
+
5032
+	err = XTReadDB().Where("patient_id = ? and system_time = ? and good_id = ? and status = 1 and consumable_type =7", patient_id, record_time, good_id).Find(&flow).Error
5033
+	return flow, nil
5034
+}
5035
+
4945 5036
 func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
4946 5037
 
4947 5038
 	info := models.WarehouseOutInfo{}
@@ -4956,7 +5047,7 @@ func GetWarehouseOutInfoIsExist(id int64) (*models.WarehouseOutInfo, error) {
4956 5047
 	return &info, nil
4957 5048
 }
4958 5049
 
4959
-func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time int64) (*models.WarehouseOutInfo, error) {
5050
+func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time int64, project_id int64) (*models.WarehouseOutInfo, error) {
4960 5051
 
4961 5052
 	info := models.WarehouseOutInfo{}
4962 5053
 	var err error
@@ -4970,6 +5061,12 @@ func GetWarehouseOutInfoIsExistOne(good_id int64, patient_id int64, record_time
4970 5061
 	return &info, nil
4971 5062
 }
4972 5063
 
5064
+func GetWarehouseOutInfoIsExistTwo(good_id int64, patient_id int64, record_time int64, project_id int64) (models.WarehouseOutInfo, error) {
5065
+	info := models.WarehouseOutInfo{}
5066
+	err := XTReadDB().Where("good_id = ? and sys_record_time = ? and status = 1 and patient_id = ?", good_id, record_time, patient_id).Find(&info).Error
5067
+	return info, err
5068
+}
5069
+
4973 5070
 func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int64, startTime int64, endTime int64, good_id int64) (flow []*models.VmStockFlow, total int64, err error) {
4974 5071
 
4975 5072
 	offset := (page - 1) * limit
@@ -4994,6 +5091,10 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4994 5091
 		if consumable_type == 4 {
4995 5092
 			db = db.Where(" consumable_type = ?", consumable_type)
4996 5093
 		}
5094
+		//自动退库
5095
+		if consumable_type == 7 {
5096
+			db = db.Where(" consumable_type = ?", consumable_type)
5097
+		}
4997 5098
 
4998 5099
 		if consumable_type == 10 {
4999 5100
 			db = db.Where(" consumable_type = ?", consumable_type)
@@ -5047,7 +5148,14 @@ func GetLastGoodListByPatientIdOne(recordtime int64, patientid int64, goodid int
5047 5148
 	return detail, err
5048 5149
 }
5049 5150
 
5050
-func UpdatedWarehouseOutInfo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64) error {
5151
+func UpdatedWarehouseOutInfo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64, project_id int64) error {
5152
+
5153
+	outInfo := models.WarehouseOutInfo{}
5154
+	err := XTWriteDB().Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time  =? and status = 1", good_id, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": info.WarehouseOutId, "WarehouseOutOrderNumber": info.WarehouseOutOrderNumber, "sys_record_time": info.SysRecordTime, "good_type_id": info.GoodTypeId, "patient_id": info.PatientId, "consumable_type": info.ConsumableType, "count": info.Count, "price": info.Price, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "over_count": info.OverCount}).Error
5155
+	return err
5156
+}
5157
+
5158
+func UpdatedWarehouseOutInfoTwo(info *models.WarehouseOutInfo, good_id int64, patient_id int64, record_time int64) error {
5051 5159
 
5052 5160
 	outInfo := models.WarehouseOutInfo{}
5053 5161
 	err := XTWriteDB().Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time  =? and status = 1", good_id, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": info.WarehouseOutId, "WarehouseOutOrderNumber": info.WarehouseOutOrderNumber, "sys_record_time": info.SysRecordTime, "good_type_id": info.GoodTypeId, "patient_id": info.PatientId, "consumable_type": info.ConsumableType, "count": info.Count, "price": info.Price, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber}).Error
@@ -5286,8 +5394,8 @@ func DeleteDrugAutoWarehouse(drugid int64, patient_id int64, record_time int64)
5286 5394
 func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5287 5395
 
5288 5396
 	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5289
-	err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5290
-	err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5397
+	//err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5398
+	//err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5291 5399
 	return err
5292 5400
 }
5293 5401
 
@@ -5977,7 +6085,7 @@ func ModifyDrugWarehouseInfoSix(info *models.DrugWarehouseInfo, id int64) error
5977 6085
 
5978 6086
 func GetGoodInventoryWarehouseList(id int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
5979 6087
 
5980
-	err = XTReadDB().Model(&info).Where("good_id = ? and status = 1 and storehouse_id=?", id, storehouse_id).Preload("GoodInfo", "status = 1").Find(&info).Error
6088
+	err = XTReadDB().Model(&info).Where("good_id = ? and status = 1 and storehouse_id=? and is_check= 1", id, storehouse_id).Preload("GoodInfo", "status = 1").Find(&info).Error
5981 6089
 	return info, err
5982 6090
 }
5983 6091
 
@@ -6411,6 +6519,7 @@ func ModifyDrugReduceInformationSix(drug_id int64, sum_count int64, orgid int64,
6411 6519
 
6412 6520
 	err = XTWriteDB().Model(&info).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", sum_count)).Error
6413 6521
 	err = XTWriteDB().Model(&info).Where("id=? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"batch_retai_price": batch_retai_price}).Error
6522
+
6414 6523
 	return info, err
6415 6524
 }
6416 6525
 
@@ -7019,8 +7128,13 @@ func UpdatedWarehouseOut(id int64) error {
7019 7128
 
7020 7129
 func UpdatedSigleWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
7021 7130
 
7022
-	err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
7023
-
7131
+	tx := XTWriteDB().Begin()
7132
+	err := tx.Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
7133
+	if err != nil {
7134
+		tx.Rollback()
7135
+		return err
7136
+	}
7137
+	tx.Commit()
7024 7138
 	return err
7025 7139
 
7026 7140
 }
@@ -7059,17 +7173,40 @@ func GetLastGoodWarehouseOutTwenty(orgid int64) (models.WarehouseOut, error) {
7059 7173
 
7060 7174
 func UpdateaGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64) error {
7061 7175
 
7062
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("good_id = ?  and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7063
-
7176
+	ut := writeDb.Begin()
7177
+	err := ut.Model(&models.WarehousingInfo{}).Where("good_id = ?  and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7178
+	if err != nil {
7179
+		ut.Rollback()
7180
+		return err
7181
+	}
7182
+	ut.Commit()
7064 7183
 	return err
7184
+
7065 7185
 }
7066 7186
 
7067 7187
 func ModifyGoodWarehouseOut(id int64) error {
7068
-
7069
-	err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
7070
-	err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7071
-	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
7072
-
7188
+	ut := writeDb.Begin()
7189
+	err := ut.Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
7190
+	if err != nil {
7191
+		ut.Rollback()
7192
+		return err
7193
+	}
7194
+	err = ut.Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7195
+	if err != nil {
7196
+		ut.Rollback()
7197
+		return err
7198
+	}
7199
+	err = ut.Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
7200
+	if err != nil {
7201
+		ut.Rollback()
7202
+		return err
7203
+	}
7204
+	err = ut.Model(&models.XtWarehouseFlushInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
7205
+	if err != nil {
7206
+		ut.Rollback()
7207
+		return err
7208
+	}
7209
+	ut.Commit()
7073 7210
 	return err
7074 7211
 }
7075 7212
 
@@ -7095,6 +7232,7 @@ func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
7095 7232
 }
7096 7233
 
7097 7234
 func UpdateCheckWarehouseInfo(id int64) error {
7235
+
7098 7236
 	tx := XTWriteDB().Begin()
7099 7237
 	err := tx.Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7100 7238
 	if err != nil {
@@ -7112,6 +7250,7 @@ func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo
7112 7250
 }
7113 7251
 
7114 7252
 func UpdateWarehouseInfoByIdList(count int64, id int64) error {
7253
+
7115 7254
 	tx := XTWriteDB().Begin()
7116 7255
 	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
7117 7256
 	if err != nil {
@@ -7128,6 +7267,7 @@ func UpdateWarehouseInfoByIdList(count int64, id int64) error {
7128 7267
 }
7129 7268
 
7130 7269
 func ReturnCheckWarehouseInfo(id int64) error {
7270
+
7131 7271
 	tx := XTWriteDB().Begin()
7132 7272
 	err := tx.Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7133 7273
 	if err != nil {
@@ -7140,6 +7280,7 @@ func ReturnCheckWarehouseInfo(id int64) error {
7140 7280
 }
7141 7281
 
7142 7282
 func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
7283
+
7143 7284
 	tx := XTWriteDB().Begin()
7144 7285
 	err := tx.Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
7145 7286
 	if err != nil {
@@ -7156,8 +7297,9 @@ func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
7156 7297
 }
7157 7298
 
7158 7299
 func UpdateWarehouseInfoFlow(id int64) error {
7300
+
7159 7301
 	tx := XTWriteDB().Begin()
7160
-	err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7302
+	err := tx.Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0, "is_check": 2}).Error
7161 7303
 
7162 7304
 	if err != nil {
7163 7305
 		tx.Rollback()
@@ -7165,6 +7307,12 @@ func UpdateWarehouseInfoFlow(id int64) error {
7165 7307
 	}
7166 7308
 	tx.Commit()
7167 7309
 	return err
7310
+	if err != nil {
7311
+		tx.Rollback()
7312
+		return err
7313
+	}
7314
+	tx.Commit()
7315
+	return err
7168 7316
 }
7169 7317
 
7170 7318
 func FindLastWarehousingSix(org_id int64) (info models.Warehousing, err error) {
@@ -7252,7 +7400,7 @@ func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
7252 7400
 
7253 7401
 func AddDrugWarehouseStockMinNumber(count int64, id int64) error {
7254 7402
 	tx := XTWriteDB().Begin()
7255
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7403
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7256 7404
 	if err != nil {
7257 7405
 		tx.Rollback()
7258 7406
 		return err
@@ -7413,19 +7561,38 @@ func UpdateGoodInfoSumCount(goodid int64, sum_count int64, orgid int64) error {
7413 7561
 	return err
7414 7562
 }
7415 7563
 
7564
+func UpdateGoodInfoSumCountSix(goodid int64, sum_count int64, orgid int64) error {
7565
+
7566
+	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7567
+	return err
7568
+}
7569
+
7416 7570
 func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) error {
7571
+	tx := XTWriteDB().Begin()
7572
+	err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7573
+	if err != nil {
7574
+		tx.Rollback()
7575
+		return err
7576
+	}
7577
+	tx.Commit()
7578
+	return err
7417 7579
 
7418 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
7419 7581
 	return err
7420 7582
 }
7421 7583
 
7422
-func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64) error {
7584
+func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
7423 7585
 	tx := XTWriteDB().Begin()
7424 7586
 	err := tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7425 7587
 	if err != nil {
7426 7588
 		tx.Rollback()
7427 7589
 		return err
7428 7590
 	}
7591
+	err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7592
+	if err != nil {
7593
+		tx.Rollback()
7594
+		return err
7595
+	}
7429 7596
 	tx.Commit()
7430 7597
 	return err
7431 7598
 }
@@ -7461,9 +7628,18 @@ func GetCancelWarehouseList(orgId int64, goodId int64, warehouseInfoId int64) (i
7461 7628
 }
7462 7629
 
7463 7630
 func CheckCancelStock(stock models.CancelStock, cancel_stock_id int64, orgid int64) error {
7464
-
7465
-	err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7466
-	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7631
+	ut := writeDb.Begin()
7632
+	err := ut.Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7633
+	if err != nil {
7634
+		ut.Rollback()
7635
+		return err
7636
+	}
7637
+	err = ut.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7638
+	if err != nil {
7639
+		ut.Rollback()
7640
+		return err
7641
+	}
7642
+	ut.Commit()
7467 7643
 	return err
7468 7644
 }
7469 7645
 
@@ -7474,33 +7650,67 @@ func GetCancelStockInfoById(cancel_stock_id int64, orgid int64) (info []*models.
7474 7650
 }
7475 7651
 
7476 7652
 func UpdateCancelStockNumber(stock_count int64, warehouse_info_id int64, orgid int64) error {
7477
-
7478
-	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
7653
+	ut := writeDb.Begin()
7654
+	err := ut.Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
7655
+	if err != nil {
7656
+		ut.Rollback()
7657
+		return err
7658
+	}
7659
+	ut.Commit()
7479 7660
 	return err
7480 7661
 }
7481 7662
 
7482 7663
 func UpdateGoodSumCount(sum_count int64, good_id int64, orgid int64) error {
7483
-
7484
-	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7664
+	ut := writeDb.Begin()
7665
+	err := ut.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7666
+	if err != nil {
7667
+		ut.Rollback()
7668
+		return err
7669
+	}
7670
+	ut.Commit()
7485 7671
 	return err
7486 7672
 }
7487 7673
 
7488 7674
 func UpdateStockWarehouseInfo(cancel_stock_id int64, orgid int64, stock models.CancelStock) error {
7489
-
7490
-	err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7491
-	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7675
+	ut := writeDb.Begin()
7676
+	err := ut.Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7677
+	if err != nil {
7678
+		ut.Rollback()
7679
+		return err
7680
+	}
7681
+	err = ut.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7682
+	if err != nil {
7683
+		ut.Rollback()
7684
+		return err
7685
+	}
7686
+	ut.Commit()
7492 7687
 	return err
7493 7688
 }
7494 7689
 
7495 7690
 func UpdateStockWarehouseInfoStockFlow(id int64, orgid int64, goodid int64) error {
7496
-	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
7691
+	ut := writeDb.Begin()
7692
+	err = ut.Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
7693
+	if err != nil {
7694
+		ut.Rollback()
7695
+		return err
7696
+	}
7697
+	ut.Commit()
7497 7698
 	return err
7498 7699
 }
7499 7700
 
7500 7701
 func UpdateStockNumberWarehouseInfo(warehouse_info_id int64, good_id int64, org_id int64, stock_count int64) error {
7501
-
7702
+	ut := writeDb.Begin()
7502 7703
 	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and good_id = ? and org_id = ? and status = 1", warehouse_info_id, good_id, org_id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", stock_count)).Error
7704
+	if err != nil {
7705
+		ut.Rollback()
7706
+		return err
7707
+	}
7503 7708
 	err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and status = 1 and org_id = ?", good_id, org_id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", stock_count)).Error
7709
+	if err != nil {
7710
+		ut.Rollback()
7711
+		return err
7712
+	}
7713
+	ut.Commit()
7504 7714
 	return err
7505 7715
 }
7506 7716
 
@@ -7531,24 +7741,29 @@ func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info [
7531 7741
 }
7532 7742
 
7533 7743
 func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
7534
-	tx := XTWriteDB().Begin()
7535
-	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7744
+	ut := XTWriteDB().Begin()
7745
+	err := ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7536 7746
 	if err != nil {
7537
-		tx.Rollback()
7747
+		ut.Rollback()
7538 7748
 		return err
7539 7749
 	}
7540
-	err = tx.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7750
+	err = ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7541 7751
 	if err != nil {
7542
-		tx.Rollback()
7752
+		ut.Rollback()
7543 7753
 		return err
7544 7754
 	}
7545
-	tx.Commit()
7755
+	ut.Commit()
7546 7756
 	return err
7547 7757
 }
7548 7758
 
7549 7759
 func UpdateBaseDrugSumTwo(drugid int64, sum_count int64, orgid int64) error {
7550
-
7551
-	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7760
+	ut := writeDb.Begin()
7761
+	err = ut.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7762
+	if err != nil {
7763
+		ut.Rollback()
7764
+		return err
7765
+	}
7766
+	ut.Commit()
7552 7767
 	return err
7553 7768
 }
7554 7769
 
@@ -7632,9 +7847,15 @@ func ModifyDrugFlowByCancelId(cancelstock_id int64, drugId int64, orgid int64) e
7632 7847
 }
7633 7848
 
7634 7849
 func ModifyDrugMaxNumberWarehouseInfo(id int64, count int64, orgid int64) error {
7635
-
7636
-	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7850
+	ut := XTWriteDB().Begin()
7851
+	err := ut.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7852
+	if err != nil {
7853
+		ut.Rollback()
7854
+		return err
7855
+	}
7856
+	ut.Commit()
7637 7857
 	return err
7858
+
7638 7859
 }
7639 7860
 
7640 7861
 func ModifyDrugMinNumberWarehouseInfo(id int64, count int64, orgid int64) error {
@@ -7664,3 +7885,141 @@ func GetPrintList(storehouse_id int64, good_name string, orgid int64, limit int6
7664 7885
 	err = XTReadDB().Preload("GoodInfo", "status = 1 and org_id = ?", orgid).Preload("WarehousingInfo", "status = 1 and org_id=?", orgid).Find(&storeinventory).Error
7665 7886
 	return storeinventory, err
7666 7887
 }
7888
+
7889
+func GetGoodDialysisOutInfo(orgid int64, patient_id int64, sys_record_time int64, good_id int64) (models.AutomaticReduceDetail, error) {
7890
+
7891
+	detail := models.AutomaticReduceDetail{}
7892
+	err := XTReadDB().Where("org_id =? and patient_id = ? and record_time = ? and good_id = ? and status= 1", orgid, patient_id, sys_record_time, good_id).Find(&detail).Error
7893
+	return detail, err
7894
+}
7895
+
7896
+func AddGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7897
+
7898
+	ut := XTWriteDB().Begin()
7899
+
7900
+	err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count + ?", count)).Error
7901
+	if err != nil {
7902
+		ut.Rollback()
7903
+		return err
7904
+	}
7905
+	ut.Commit()
7906
+	return err
7907
+}
7908
+
7909
+func ReduceGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7910
+
7911
+	ut := XTWriteDB().Begin()
7912
+
7913
+	err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count - ?", count)).Error
7914
+	if err != nil {
7915
+		ut.Rollback()
7916
+		return err
7917
+	}
7918
+	ut.Commit()
7919
+	return err
7920
+}
7921
+
7922
+func UpdateGoodFlushCount(storehouse_id int64, good_id int64, user_org_id int64, flush_count int64) error {
7923
+	ut := XTWriteDB().Begin()
7924
+
7925
+	err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
7926
+	if err != nil {
7927
+		ut.Rollback()
7928
+		return err
7929
+	}
7930
+	ut.Commit()
7931
+	return err
7932
+}
7933
+
7934
+func UpdateDrugCount(storehouse_id int64, user_org_id int64, drug_id int64, sum_in_count int64, flush_count int64) error {
7935
+
7936
+	ut := XTWriteDB().Begin()
7937
+	err := ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7938
+	if err != nil {
7939
+		ut.Rollback()
7940
+		return err
7941
+	}
7942
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
7943
+	if err != nil {
7944
+		ut.Rollback()
7945
+		return err
7946
+	}
7947
+
7948
+	ut.Commit()
7949
+	return err
7950
+}
7951
+
7952
+func UpdateDrugCountOne(storehouse_id int64, user_org_id int64, drug_id int64, flush_count int64) error {
7953
+
7954
+	ut := XTWriteDB().Begin()
7955
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
7956
+	if err != nil {
7957
+		ut.Rollback()
7958
+		return err
7959
+	}
7960
+
7961
+	ut.Commit()
7962
+	return err
7963
+}
7964
+
7965
+func AddDrugSumOutCount(storehouse_id int64, sum_out_count int64, user_org_id int64, drug_id int64) error {
7966
+
7967
+	ut := XTWriteDB().Begin()
7968
+	err := ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count + ?", sum_out_count)).Error
7969
+	if err != nil {
7970
+		ut.Rollback()
7971
+		return err
7972
+	}
7973
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count + ?", sum_out_count)).Error
7974
+	if err != nil {
7975
+		ut.Rollback()
7976
+		return err
7977
+	}
7978
+	ut.Commit()
7979
+	return err
7980
+}
7981
+
7982
+func ReduceDrugSumOut(storehouse_id int64, user_org_id int64, drug_id int64, sum_out_count int64) error {
7983
+	ut := XTWriteDB().Begin()
7984
+	err := ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_act_out_count", gorm.Expr("sum_act_out_count + ?", sum_out_count)).Error
7985
+	if err != nil {
7986
+		ut.Rollback()
7987
+		return err
7988
+	}
7989
+	ut.Commit()
7990
+	return err
7991
+}
7992
+
7993
+func AddGoodSumOutCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7994
+	ut := XTWriteDB().Begin()
7995
+	err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count + ?", count)).Error
7996
+	if err != nil {
7997
+		ut.Rollback()
7998
+		return err
7999
+	}
8000
+	err = ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("sum_act_out_count", gorm.Expr("sum_act_out_count + ?", count)).Error
8001
+	if err != nil {
8002
+		ut.Rollback()
8003
+		return err
8004
+	}
8005
+
8006
+	ut.Commit()
8007
+	return err
8008
+}
8009
+
8010
+func ReduceGoodSumOutCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
8011
+	ut := XTWriteDB().Begin()
8012
+	err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count - ?", count)).Error
8013
+	if err != nil {
8014
+		ut.Rollback()
8015
+		return err
8016
+	}
8017
+	err = ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("sum_act_out_count", gorm.Expr("sum_act_out_count - ?", count)).Error
8018
+	if err != nil {
8019
+		ut.Rollback()
8020
+		return err
8021
+	}
8022
+
8023
+	ut.Commit()
8024
+	return err
8025
+}

文件差異過大導致無法顯示
+ 827 - 221
service/warhouse_service.go