Pārlūkot izejas kodu

11月9日库存管理

XMLWAN 2 gadus atpakaļ
vecāks
revīzija
be6919f915

+ 36 - 0
controllers/dialysis_api_controller.go Parādīt failu

@@ -81,6 +81,8 @@ func DialysisApiRegistRouters() {
81 81
 	beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
82 82
 
83 83
 	beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
84
+
85
+	beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
84 86
 }
85 87
 
86 88
 func (c *DialysisApiController) GetQueueCall() {
@@ -4375,3 +4377,37 @@ func (this *DialysisApiController) GetDialysisSetting() {
4375 4377
 	})
4376 4378
 	return
4377 4379
 }
4380
+
4381
+func (this *DialysisApiController) GetDialysisParameterList() {
4382
+
4383
+	keyword := this.GetString("keywords")
4384
+
4385
+	limit, _ := this.GetInt64("limit")
4386
+
4387
+	page, _ := this.GetInt64("page")
4388
+
4389
+	partition_id, _ := this.GetInt64("partition_id")
4390
+
4391
+	schedule_type, _ := this.GetInt64("schedule_type")
4392
+
4393
+	start_time := this.GetString("schedule_date")
4394
+	timeLayout := "2006-01-02"
4395
+	loc, _ := time.LoadLocation("Local")
4396
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4397
+
4398
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4399
+
4400
+	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4401
+
4402
+	if err == nil {
4403
+		this.ServeSuccessJSON(map[string]interface{}{
4404
+			"list":  list,
4405
+			"total": total,
4406
+		})
4407
+		return
4408
+
4409
+	} else {
4410
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4411
+		return
4412
+	}
4413
+}

+ 5 - 72
controllers/self_drug_api_congtroller.go Parādīt failu

@@ -2737,29 +2737,6 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2737 2737
 	keyword := this.GetString("keyword")
2738 2738
 	page, _ := this.GetInt64("page")
2739 2739
 	limit, _ := this.GetInt64("limit")
2740
-	//start_time := this.GetString("start_time")
2741
-	//end_time := this.GetString("end_time")
2742
-	//timeLayout := "2006-01-02"
2743
-	//loc, _ := time.LoadLocation("Local")
2744
-	//var startTime int64
2745
-	//if len(start_time) > 0 {
2746
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
2747
-	//	if err != nil {
2748
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2749
-	//		return
2750
-	//	}
2751
-	//	startTime = theTime.Unix()
2752
-	//}
2753
-	//var endTime int64
2754
-	//if len(end_time) > 0 {
2755
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
2756
-	//	if err != nil {
2757
-	//		utils.ErrorLog(err.Error())
2758
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2759
-	//		return
2760
-	//	}
2761
-	//	endTime = theTime.Unix()
2762
-	//}
2763 2740
 
2764 2741
 	// 查询该机构所有耗材入库信息
2765 2742
 	goodList, _ := service.GetAllGoodListSeven(orgId)
@@ -2774,18 +2751,6 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2774 2751
 		service.UpdateGoodInformation(it.ID, orgId, sum_total)
2775 2752
 	}
2776 2753
 
2777
-	//查询删除的耗材数据
2778
-	//listOne, _ := service.GetHisPrescriptionProjectByOrgId(orgId)
2779
-	//for _, item := range listOne {
2780
-	// //查询流水
2781
-	// flowDetail, _ := service.GetPatientStockFlow(item.PatientId, item.RecordDate, item.ProjectId)
2782
-	// formatInt, _ := strconv.ParseInt(item.Count, 10, 64)
2783
-	// vmFlow := models.VmStockFlow{
2784
-	//   Count:  formatInt,
2785
-	// }
2786
-	// service.ModifyPatientStockFlow(flowDetail.ID,vmFlow)
2787
-	//}
2788
-
2789 2754
 	var ids []int64
2790 2755
 	var goodIds []int64
2791 2756
 	manufacturerList, _ := service.GetManufacturerListByKeyword(orgId, keyword)
@@ -2796,41 +2761,8 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2796 2761
 	for _, it := range infoList {
2797 2762
 		goodIds = append(goodIds, it.GoodId)
2798 2763
 	}
2799
-	//list, _, err := service.GetGoodNewQuery(orgId, storehouse_id, good_type, keyword, page, limit, ids, goodIds, startTime, endTime)
2800 2764
 
2801 2765
 	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 2766
 
2835 2767
 	if err != nil {
2836 2768
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取查询信息失败")
@@ -2838,8 +2770,7 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2838 2770
 	}
2839 2771
 
2840 2772
 	this.ServeSuccessJSON(map[string]interface{}{
2841
-		"total": total,
2842
-		//"list":  list,
2773
+		"total":     total,
2843 2774
 		"stockList": stockList,
2844 2775
 	})
2845 2776
 }
@@ -3470,12 +3401,14 @@ func (this *SelfDrugApiController) GetDrugNewQuery() {
3470 3401
 	for _, it := range drug {
3471 3402
 		var sum_count int64
3472 3403
 		var limit_count int64
3473
-
3404
+		fmt.Println("it233323323232323223", it.DrugName)
3474 3405
 		drugInfo, _ := service.GetDrugWarehouseInfoName(it.ID, orgId)
3475 3406
 		for _, item := range drugInfo {
3407
+
3476 3408
 			sum_count += item.StockMaxNumber*it.MinNumber + item.StockMinNumber
3477 3409
 		}
3478
-		limit_count = it.DrugStockLimitCount * it.MinNumber
3410
+		stockInt, _ := strconv.ParseInt(it.DrugStockLimit, 10, 64)
3411
+		limit_count = stockInt * it.MinNumber
3479 3412
 		service.UpdateDrugById(it.ID, orgId, limit_count, sum_count)
3480 3413
 	}
3481 3414
 

+ 57 - 6
controllers/supply_order_api_contorller.go Parādīt failu

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

+ 8 - 8
models/drug.go Parādīt failu

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

+ 18 - 16
models/schedule_models.go Parādīt failu

@@ -290,22 +290,24 @@ func (VmBloodPatients) TableName() string {
290 290
 }
291 291
 
292 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"`
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
+	DialysisPrescription       DialysisPrescription       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,RecordDate" json:"dialysis_prescription"`
310
+	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,AssessmentDate" json:"assessment_befor_dislysis"`
309 311
 }
310 312
 
311 313
 func (VmBloodSchedule) TableName() string {

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

@@ -128,3 +128,38 @@ func GetDialysisSetting(orgid int64) (models.XtDialysisSetting, error) {
128 128
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&setting).Error
129 129
 	return setting, err
130 130
 }
131
+
132
+func GetDialysisParameterList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
133
+	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
134
+	offset := (page - 1) * limit
135
+	if scheduleDate > 0 {
136
+		db = db.Where("schedule_date = ?", scheduleDate)
137
+	}
138
+	if schedule_type > 0 {
139
+		db = db.Where("schedule_type = ?", schedule_type)
140
+	}
141
+	if partition_id > 0 {
142
+		db = db.Where("partition_id = ?", partition_id)
143
+	}
144
+	if orgID > 0 {
145
+		db = db.Where("user_org_id  = ?", orgID)
146
+	}
147
+
148
+	if len(keywords) > 0 {
149
+		keywords = "%" + keywords + "%"
150
+		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)
151
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
152
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
153
+			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
154
+			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
155
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
156
+	} else {
157
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
158
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
159
+			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
160
+			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
161
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
162
+	}
163
+
164
+	return schedule, total, err
165
+}

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

@@ -211,6 +211,13 @@ func GetDrugStockCount(storehouse_id int64, drug_id int64, org_id int64) (*model
211 211
 	return &drugStockCount, nil
212 212
 }
213 213
 
214
+func GetDrugStockCountSix(storehouse_id int64, drug_id int64, org_id int64) (models.XtDrugStockCount, error) {
215
+
216
+	drugStockCount := models.XtDrugStockCount{}
217
+	err = XTReadDB().Where("storehouse_id = ? and drug_id = ? and user_org_id  = ? and status = 1", storehouse_id, drug_id, org_id).Find(&drugStockCount).Error
218
+	return drugStockCount, err
219
+}
220
+
214 221
 func CreateDrugStockSum(drug models.XtDrugStockCount) error {
215 222
 
216 223
 	ut := XTWriteDB().Begin()

+ 19 - 0
service/stock_service.go Parādīt failu

@@ -7893,6 +7893,19 @@ func GetGoodDialysisOutInfo(orgid int64, patient_id int64, sys_record_time int64
7893 7893
 	return detail, err
7894 7894
 }
7895 7895
 
7896
+func GetGoodSumCount(storehouse_id int64, good_id int64, orgid int64) (models.XtGoodStockCount, error) {
7897
+
7898
+	stock := models.XtGoodStockCount{}
7899
+	err := XTReadDB().Where("storehouse_id = ? and good_id = ? and user_org_id = ? and status = 1", storehouse_id, good_id, orgid).Find(&stock).Error
7900
+	return stock, err
7901
+}
7902
+
7903
+func CreateGoodStockCount(stock models.XtGoodStockCount) error {
7904
+
7905
+	err := XTWriteDB().Create(&stock).Error
7906
+	return err
7907
+}
7908
+
7896 7909
 func AddGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
7897 7910
 
7898 7911
 	ut := XTWriteDB().Begin()
@@ -7931,6 +7944,12 @@ func UpdateGoodFlushCount(storehouse_id int64, good_id int64, user_org_id int64,
7931 7944
 	return err
7932 7945
 }
7933 7946
 
7947
+func CreateDrugStock(stock models.XtDrugStockCount) error {
7948
+
7949
+	err := XTWriteDB().Create(&stock).Error
7950
+	return err
7951
+}
7952
+
7934 7953
 func UpdateDrugCount(storehouse_id int64, user_org_id int64, drug_id int64, sum_in_count int64, flush_count int64) error {
7935 7954
 
7936 7955
 	ut := XTWriteDB().Begin()