Browse Source

库存调拨修改

28169 2 years ago
parent
commit
33f9656ec1
3 changed files with 29 additions and 15 deletions
  1. 11 4
      controllers/his_api_controller.go
  2. 17 10
      service/stock_service.go
  3. 1 1
      service/warhouse_service.go

+ 11 - 4
controllers/his_api_controller.go View File

@@ -878,6 +878,8 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
878 878
 		diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
879 879
 		additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
880 880
 
881
+		//获取是否开启保存耗材出库的开关
882
+		goodOutOpen, _ := service.GetGoodOutOpenConfigOne(adminInfo.CurrentOrgId)
881 883
 		c.ServeSuccessJSON(map[string]interface{}{
882 884
 			"drugs":            drugs,
883 885
 			"advices_template": advices,
@@ -889,6 +891,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
889 891
 			"additions":        additions,
890 892
 			"diagnose":         diagnose,
891 893
 			"manufacturers":    manufacturers,
894
+			"goodOutOpen":      goodOutOpen,
892 895
 		})
893 896
 	}
894 897
 	if adminInfo.CurrentOrgId != 9675 && adminInfo.CurrentOrgId != 9671 && adminInfo.CurrentOrgId != 10215 {
@@ -919,6 +922,8 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
919 922
 		sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
920 923
 		diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
921 924
 		additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
925
+		//获取是否开启保存耗材出库的开关
926
+		goodOutOpen, _ := service.GetGoodOutOpenConfigOne(adminInfo.CurrentOrgId)
922 927
 
923 928
 		c.ServeSuccessJSON(map[string]interface{}{
924 929
 			"drugs":            drugs,
@@ -931,6 +936,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
931 936
 			"additions":        additions,
932 937
 			"diagnose":         diagnose,
933 938
 			"manufacturers":    manufacturers,
939
+			"goodOutOpen":      goodOutOpen,
934 940
 		})
935 941
 	}
936 942
 }
@@ -2344,6 +2350,7 @@ func (c *HisApiController) CreateHisPrescription() {
2344 2350
 					}
2345 2351
 					//查询是否生成出库单
2346 2352
 					out, _ := service.FindPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
2353
+
2347 2354
 					if out.ID == 0 {
2348 2355
 						service.AddSigleWarehouseOut(&warehouseOut)
2349 2356
 					}
@@ -5539,7 +5546,7 @@ type Custom struct {
5539 5546
 	ItemId           int64
5540 5547
 }
5541 5548
 
5542
-//获取个人信息----挂号-----上传就诊信息
5549
+// 获取个人信息----挂号-----上传就诊信息
5543 5550
 func (c *HisApiController) GetRegisterInfo() {
5544 5551
 	id, _ := c.GetInt64("id")
5545 5552
 	record_time := c.GetString("record_time")
@@ -5710,7 +5717,7 @@ func (c *HisApiController) GetRegisterInfo() {
5710 5717
 
5711 5718
 }
5712 5719
 
5713
-//上传明细----结算
5720
+// 上传明细----结算
5714 5721
 func (c *HisApiController) GetUploadInfo() {
5715 5722
 	id, _ := c.GetInt64("id")
5716 5723
 	record_time := c.GetString("record_time")
@@ -6555,7 +6562,7 @@ func (c *HisApiController) GetUploadInfo() {
6555 6562
 	}
6556 6563
 }
6557 6564
 
6558
-//退款
6565
+// 退款
6559 6566
 func (c *HisApiController) Refund() {
6560 6567
 	order_id, _ := c.GetInt64("order_id")
6561 6568
 	order, _ := service.GetHisOrderByID(order_id)
@@ -9359,7 +9366,7 @@ func RemoveRepeatedTeam(arr []*models.HisOrderInfoTwo) (newArr []*models.HisOrde
9359 9366
 	return
9360 9367
 }
9361 9368
 
9362
-//修改处方退库操作 参数传修改之前的处方数据
9369
+// 修改处方退库操作 参数传修改之前的处方数据
9363 9370
 func DeleteDrugWarehosueInfo(advice models.HisDoctorAdviceInfo) (err error) {
9364 9371
 
9365 9372
 	if advice.ExecutionState == 1 {

+ 17 - 10
service/stock_service.go View File

@@ -39,7 +39,7 @@ func FindAllDealerTotal(orgId int64) (total int64) {
39 39
 	return
40 40
 }
41 41
 
42
-//获取经销商的名称
42
+// 获取经销商的名称
43 43
 func FindAllDealerName(orgId int64) (tmp []*models.Dealer, err error) {
44 44
 	err = readDb.Model(&models.Dealer{}).Where("org_id = ? and status = 1", orgId).Find(&tmp).Error
45 45
 	return
@@ -91,7 +91,7 @@ func ModifyManufacturer(manufacturer *models.Manufacturer) error {
91 91
 	return err
92 92
 }
93 93
 
94
-//获取生产厂商名称
94
+// 获取生产厂商名称
95 95
 func FindAllManufacturerName(orgid int64) (tmp []*models.Manufacturer, err error) {
96 96
 	err = readDb.Model(&models.Manufacturer{}).Where("org_id = ? and status = 1", orgid).Find(&tmp).Error
97 97
 	return
@@ -3606,10 +3606,10 @@ func GetAllDealerList(orgid int64) (list []*models.Dealer, err error) {
3606 3606
 	return list, err
3607 3607
 }
3608 3608
 
3609
-//func GetAllDealerListTX(orgid int64,tx *gorm.DB) (list []*models.Dealer, err error) {
3610
-//	err = tx.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3611
-//	return list, err
3612
-//}
3609
+//	func GetAllDealerListTX(orgid int64,tx *gorm.DB) (list []*models.Dealer, err error) {
3610
+//		err = tx.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3611
+//		return list, err
3612
+//	}
3613 3613
 func GetDealerByName(orgid int64, name string) (*models.Dealer, error) {
3614 3614
 	var dealer models.Dealer
3615 3615
 	var err error
@@ -6515,7 +6515,7 @@ func GetAllDrugFlowById(drugid int64, patient_id int64, advicedate int64, orgid
6515 6515
 	return info, err
6516 6516
 }
6517 6517
 
6518
-//耗材加库存
6518
+// 耗材加库存
6519 6519
 func ModifyGoodAddInformation(good_id int64, sum_count int64, orgid int64) (models.GoodInfo, error) {
6520 6520
 
6521 6521
 	info := models.GoodInfo{}
@@ -6583,7 +6583,7 @@ func GetWarehouseInfoByIdTwenty(id int64, orgid int64) (models.WarehousingInfo,
6583 6583
 	return info, err
6584 6584
 }
6585 6585
 
6586
-//药品加库存
6586
+// 药品加库存
6587 6587
 func ModifyDrugAddInformation(drug_id int64, sum_count int64, orgid int64) (models.BaseDrugLib, error) {
6588 6588
 
6589 6589
 	info := models.BaseDrugLib{}
@@ -8372,7 +8372,7 @@ func DeleteGoodFlow(good_id int64, sys_record_time int64, org_id int64, project_
8372 8372
 func FindPrescriptionWarehouseOut(org_id int64, warehouse_out_time int64) (models.WarehouseOut, error) {
8373 8373
 
8374 8374
 	out := models.WarehouseOut{}
8375
-	err = readDb.Model(&models.WarehouseOut{}).Where("org_id = ?  and status = 1 and warehouse_out_time = ?", org_id, warehouse_out_time).Find(&out).Error
8375
+	err = readDb.Model(&models.WarehouseOut{}).Where("org_id = ?  and status = 1 and warehouse_out_time = ? and is_sys=1", org_id, warehouse_out_time).Find(&out).Error
8376 8376
 	return out, err
8377 8377
 
8378 8378
 }
@@ -8380,7 +8380,7 @@ func FindPrescriptionWarehouseOut(org_id int64, warehouse_out_time int64) (model
8380 8380
 func FindLastPrescriptionWarehouseOut(org_id int64, warehouse_out_time int64) (models.WarehouseOut, error) {
8381 8381
 
8382 8382
 	out := models.WarehouseOut{}
8383
-	err = readDb.Model(&models.WarehouseOut{}).Where("org_id = ?  and status = 1 and warehouse_out_time = ?", org_id, warehouse_out_time).Last(&out).Error
8383
+	err = readDb.Model(&models.WarehouseOut{}).Where("org_id = ?  and status = 1 and warehouse_out_time = ? and is_sys=1", org_id, warehouse_out_time).Last(&out).Error
8384 8384
 	return out, err
8385 8385
 
8386 8386
 }
@@ -8495,3 +8495,10 @@ func GetNewWarehouseOutInfoList(start_time int64, end_time int64, orgid int64, g
8495 8495
 	err = db.Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&info).Error
8496 8496
 	return info, err
8497 8497
 }
8498
+
8499
+func GetGoodOutOpenConfigOne(user_org_id int64) (models.XtGoodOutConfig, error) {
8500
+
8501
+	config := models.XtGoodOutConfig{}
8502
+	err := XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
8503
+	return config, err
8504
+}

+ 1 - 1
service/warhouse_service.go View File

@@ -9884,7 +9884,7 @@ func ConsumablesDeliveryTwelve(orgID int64, record_time int64, goods *models.War
9884 9884
 	//	return errors.New("库存数量不足")
9885 9885
 	//}
9886 9886
 
9887
-	if warehouse.StockCount-maxNumber > 0 {
9887
+	if warehouse.StockCount-maxNumber >= 0 {
9888 9888
 		warehouse.StockCount = warehouse.StockCount - maxNumber
9889 9889
 	} else {
9890 9890
 		warehouse.StockCount = warehouse.StockCount