Bladeren bron

11月8日库存管理

XMLWAN 2 jaren geleden
bovenliggende
commit
99e9438cf9
3 gewijzigde bestanden met toevoegingen van 69 en 34 verwijderingen
  1. 52 26
      controllers/supply_order_api_contorller.go
  2. 9 6
      models/supply.models.go
  3. 8 2
      service/supply_service.go

+ 52 - 26
controllers/supply_order_api_contorller.go Bestand weergeven

@@ -1982,6 +1982,7 @@ func (this *SupplyOrderApiController) UpdateGoodOrder() {
1982 1982
 		err = service.CreateSupplyWarehousOutOrder(item)
1983 1983
 	}
1984 1984
 	for _, item := range updateWarehout {
1985
+		service.UpdateGoodWarehouseOutOrder(item)
1985 1986
 		//查询该商品是否来源于采购订单,如果存在则关联, 如果不存在则取消关联
1986 1987
 		_, errcode := service.GetGoodIsSource(item.WarehousingId, item.ProjectId, orgId)
1987 1988
 		if errcode == gorm.ErrRecordNotFound {
@@ -1989,7 +1990,7 @@ func (this *SupplyOrderApiController) UpdateGoodOrder() {
1989 1990
 			item.WarehouseInfoId = 0
1990 1991
 			item.Type = 2
1991 1992
 			item.OrderNumber = ""
1992
-			service.UpdateGoodWarehouseOutOrder(item)
1993
+
1993 1994
 			//更新采购单
1994 1995
 			service.ModfySupplyWarehouseOut(item.WarehousingId, orgId)
1995 1996
 		}
@@ -2456,12 +2457,12 @@ func (this *SupplyOrderApiController) SaveGoodReturnOrder() {
2456 2457
 				}
2457 2458
 				supply_count := int64(items["supply_count"].(float64))
2458 2459
 
2459
-				if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
2460
+				if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
2460 2461
 					utils.ErrorLog("count")
2461 2462
 					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2462 2463
 					return
2463 2464
 				}
2464
-				count := int64(items["count"].(float64))
2465
+				count := items["count"].(string)
2465 2466
 
2466 2467
 				if items["manufacturer_id"] == nil || reflect.TypeOf(items["manufacturer_id"]).String() != "float64" {
2467 2468
 					utils.ErrorLog("manufacturer_id")
@@ -2604,13 +2605,17 @@ func (this *SupplyOrderApiController) SaveGoodReturnOrder() {
2604 2605
 					return
2605 2606
 				}
2606 2607
 				id := int64(items["id"].(float64))
2608
+
2609
+				deposit_rate := items["deposit_rate"].(string)
2610
+
2611
+				deposit_rate_float, _ := strconv.ParseFloat(deposit_rate, 64)
2607 2612
 				cancelOrder := &models.SpSupplierWarehousingCancelOrder{
2608 2613
 					ManufacturerId:            manufacturer_id,
2609 2614
 					OrderNumber:               order_number,
2610 2615
 					ProjectId:                 project_id,
2611 2616
 					GoodNumber:                good_number,
2612 2617
 					IsSource:                  is_source,
2613
-					Count:                     supply_count,
2618
+					Count:                     count,
2614 2619
 					Price:                     price_float,
2615 2620
 					Remark:                    supply_remake,
2616 2621
 					RateOfConcession:          rate_of_concession_float,
@@ -2637,6 +2642,8 @@ func (this *SupplyOrderApiController) SaveGoodReturnOrder() {
2637 2642
 					WarehousingId:             warehousing_id,
2638 2643
 					SourceCount:               count,
2639 2644
 					SupplyWarehouseDetailInfo: id,
2645
+					SupplyCount:               supply_count,
2646
+					DepositRate:               deposit_rate_float,
2640 2647
 				}
2641 2648
 				warehouseCancel = append(warehouseCancel, cancelOrder)
2642 2649
 			}
@@ -2903,6 +2910,20 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2903 2910
 				}
2904 2911
 				supply_manufacturer := items["supply_manufacturer"].(string)
2905 2912
 
2913
+				if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
2914
+					utils.ErrorLog("count")
2915
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2916
+					return
2917
+				}
2918
+				count := items["count"].(string)
2919
+
2920
+				if items["deposit_rate"] == nil || reflect.TypeOf(items["deposit_rate"]).String() != "string" {
2921
+					utils.ErrorLog("deposit_rate")
2922
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2923
+					return
2924
+				}
2925
+				deposit_rate := items["deposit_rate"].(string)
2926
+				deposit_rate_float, _ := strconv.ParseFloat(deposit_rate, 64)
2906 2927
 				if id > 0 {
2907 2928
 					cancelOrder := &models.SpSupplierWarehousingCancelOrder{
2908 2929
 						ID:                      id,
@@ -2911,7 +2932,7 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2911 2932
 						ProjectId:               project_id,
2912 2933
 						GoodNumber:              good_number,
2913 2934
 						IsSource:                is_source,
2914
-						Count:                   supply_count,
2935
+						Count:                   count,
2915 2936
 						Price:                   price_float,
2916 2937
 						Remark:                  supply_remake,
2917 2938
 						RateOfConcession:        rate_of_concession_float,
@@ -2931,6 +2952,8 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2931 2952
 						Name:                    name,
2932 2953
 						SupplyUnit:              supply_unit,
2933 2954
 						SupplyLicenseNumber:     supply_license_number,
2955
+						SupplyCount:             supply_count,
2956
+						DepositRate:             deposit_rate_float,
2934 2957
 					}
2935 2958
 					updateWarehouseCancel = append(updateWarehouseCancel, cancelOrder)
2936 2959
 				}
@@ -2942,7 +2965,7 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2942 2965
 						ProjectId:               project_id,
2943 2966
 						GoodNumber:              good_number,
2944 2967
 						IsSource:                is_source,
2945
-						Count:                   supply_count,
2968
+						Count:                   count,
2946 2969
 						Price:                   price_float,
2947 2970
 						Remark:                  supply_remake,
2948 2971
 						RateOfConcession:        rate_of_concession_float,
@@ -2962,6 +2985,8 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2962 2985
 						Name:                    name,
2963 2986
 						SupplyUnit:              supply_unit,
2964 2987
 						SupplyLicenseNumber:     supply_license_number,
2988
+						SupplyCount:             supply_count,
2989
+						DepositRate:             deposit_rate_float,
2965 2990
 					}
2966 2991
 					warehouseCancel = append(warehouseCancel, cancelOrder)
2967 2992
 				}
@@ -2992,12 +3017,13 @@ func (this *SupplyOrderApiController) UpdateGoodReturn() {
2992 3017
 func (this *SupplyOrderApiController) ModefyGoodOrder() {
2993 3018
 
2994 3019
 	id, _ := this.GetInt64("id")
3020
+	warehousing_id, _ := this.GetInt64("warehousing_id")
2995 3021
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2996 3022
 
2997 3023
 	//获取购货订单的数据
2998
-	purcaseOrder, _ := service.GetAllPurcaseOrderById(id, orgId)
3024
+	purcaseOrder, _ := service.GetAllPurcaseOrderById(warehousing_id, orgId)
2999 3025
 	//获取购货单的数据
3000
-	goodOrder, _ := service.GetAllGoodOrderById(id, orgId)
3026
+	goodOrder, _ := service.GetAllGoodOrderById(warehousing_id, orgId)
3001 3027
 	drugList, _ := service.GetSupplyDrugList(orgId)
3002 3028
 	//获取已有关联的退货单
3003 3029
 	cancelList, _ := service.GetSupplyCancelWarehouse(id, orgId)
@@ -3169,10 +3195,10 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3169 3195
 			//判断单位是否相等
3170 3196
 			if medical.MaxUnit == item.SupplyUnit {
3171 3197
 				//转化为最小单位
3172
-				prescribing_number_total = item.Count * medical.MinNumber
3198
+				prescribing_number_total = item.SupplyCount * medical.MinNumber
3173 3199
 			}
3174 3200
 			if medical.MinUnit == item.SupplyUnit {
3175
-				prescribing_number_total = item.Count
3201
+				prescribing_number_total = item.SupplyCount
3176 3202
 			}
3177 3203
 
3178 3204
 			//判断单位
@@ -3247,7 +3273,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3247 3273
 				WarehouseOutOrderNumber: lastDrug.WarehouseOutOrderNumber,
3248 3274
 				WarehouseOutId:          lastDrug.ID,
3249 3275
 				DrugId:                  item.ProjectId,
3250
-				Count:                   item.Count,
3276
+				Count:                   item.SupplyCount,
3251 3277
 				Price:                   item.Price,
3252 3278
 				Status:                  1,
3253 3279
 				Ctime:                   ctime,
@@ -3269,15 +3295,15 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3269 3295
 
3270 3296
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
3271 3297
 			if drup.ID > 0 {
3272
-				prescribingNumber := item.Count
3298
+				prescribingNumber := item.SupplyCount
3273 3299
 				service.AutoDrugDeliverInfoNight(orgId, prescribingNumber, &warehouseOut, &drup, warehouseOutInfo)
3274 3300
 			}
3275 3301
 
3276 3302
 			//修改原数据
3277
-			orderInfo := models.SpSupplierWarehousingCancelOrder{
3278
-				SourceCount: item.Count - item.SourceCount,
3279
-			}
3280
-			service.UpdateSupplyCancelById(item.ID, orderInfo)
3303
+			/*	orderInfo := models.SpSupplierWarehousingCancelOrder{
3304
+					SourceCount: item.SupplyCount - item.SourceCount,
3305
+				}
3306
+				service.UpdateSupplyCancelById(item.ID, orderInfo)*/
3281 3307
 		}
3282 3308
 
3283 3309
 		//耗材
@@ -3286,7 +3312,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3286 3312
 			warehouseOne, _ := service.FindWarehousingInfoTwenTy(item.ProjectId, item.SupplyWarehouseDetailInfo)
3287 3313
 
3288 3314
 			// 如果出库数量大于该批次剩余库存数量
3289
-			if item.Count > warehouseOne.StockCount {
3315
+			if item.SupplyCount > warehouseOne.StockCount {
3290 3316
 
3291 3317
 				goodObj, _ := service.GetGoodInformationByGoodId(item.ProjectId)
3292 3318
 				this.ServeSuccessJSON(map[string]interface{}{
@@ -3340,7 +3366,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3340 3366
 				WarehouseInfotId:        0,
3341 3367
 				GoodId:                  item.ProjectId,
3342 3368
 				GoodTypeId:              goodObj.GoodTypeId,
3343
-				Count:                   item.Count,
3369
+				Count:                   item.SupplyCount,
3344 3370
 				Price:                   item.Price,
3345 3371
 				TotalPrice:              0,
3346 3372
 				ProductDate:             item.SupplyProductDate,
@@ -3358,7 +3384,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3358 3384
 				SupplyWarehouseId:       warehouse_out_id,
3359 3385
 			}
3360 3386
 			//出库逻辑
3361
-			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.Count, creater, warehouse_out_id, id)
3387
+			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)
3362 3388
 
3363 3389
 			if parseDateErr != nil {
3364 3390
 				utils.ErrorLog(parseDateErr.Error())
@@ -3366,10 +3392,10 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3366 3392
 				return
3367 3393
 			}
3368 3394
 			//更改原退库数据
3369
-			order := models.SpSupplierWarehousingCancelOrder{
3370
-				SourceCount: item.SourceCount - item.Count,
3371
-			}
3372
-			service.UpdateSupplyCancelById(item.ID, order)
3395
+			//order := models.SpSupplierWarehousingCancelOrder{
3396
+			//	SourceCount: item.SourceCount - item.SupplyCount,
3397
+			//}
3398
+			//service.UpdateSupplyCancelById(item.ID, order)
3373 3399
 		}
3374 3400
 	}
3375 3401
 	cancel := models.SpSupplierWarehouseCancel{
@@ -3465,13 +3491,13 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3465 3491
 				if item.SupplyUnit == base.MaxUnit {
3466 3492
 					//退库
3467 3493
 					drugInfo := models.DrugWarehouseInfo{
3468
-						StockMaxNumber: item.Count,
3494
+						StockMaxNumber: item.SupplyCount,
3469 3495
 					}
3470 3496
 					service.UpdateDrugWasehousring(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3471 3497
 				}
3472 3498
 				if item.SupplyType == base.MinUnit {
3473 3499
 					drugInfo := models.DrugWarehouseInfo{
3474
-						StockMinNumber: item.Count,
3500
+						StockMinNumber: item.SupplyCount,
3475 3501
 					}
3476 3502
 					service.UpdateDrugWasehousringOne(item.ProjectId, item.SupplyWarehouseDetailInfo, drugInfo)
3477 3503
 				}
@@ -3483,7 +3509,7 @@ func (this *SupplyOrderApiController) ModefyReturnOrder() {
3483 3509
 
3484 3510
 				//退库
3485 3511
 				info := models.WarehousingInfo{
3486
-					StockCount: item.Count,
3512
+					StockCount: item.SupplyCount,
3487 3513
 				}
3488 3514
 				//更改库存
3489 3515
 				err := service.UpdateWarehousingInfoById(item.ProjectId, item.SupplyWarehouseDetailInfo, info)

+ 9 - 6
models/supply.models.go Bestand weergeven

@@ -343,7 +343,7 @@ type SpSupplierWarehousingCancelOrder struct {
343 343
 	ProjectId                 int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
344 344
 	GoodNumber                string  `gorm:"column:good_number" json:"good_number" form:"good_number"`
345 345
 	IsSource                  int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
346
-	Count                     int64   `gorm:"column:count" json:"count" form:"count"`
346
+	Count                     string  `gorm:"column:count" json:"count" form:"count"`
347 347
 	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
348 348
 	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
349 349
 	RateOfConcession          float64 `gorm:"column:rate_of_concession" json:"rate_of_concession" form:"rate_of_concession"`
@@ -368,8 +368,10 @@ type SpSupplierWarehousingCancelOrder struct {
368 368
 	SupplyExpiryDate          int64   `gorm:"column:supply_expiry_date" json:"supply_expiry_date" form:"supply_expiry_date"`
369 369
 	WarehousingId             int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
370 370
 	WarehouseInfoId           int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
371
-	SourceCount               int64   `gorm:"column:source_count" json:"source_count" form:"source_count"`
371
+	SourceCount               string  `gorm:"column:source_count" json:"source_count" form:"source_count"`
372 372
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
373
+	SupplyCount               int64   `gorm:"column:supply_count" json:"supply_count" form:"supply_count"`
374
+	DepositRate               float64 `gorm:"column:deposit_rate" json:"deposit_rate" form:"deposit_rate"`
373 375
 }
374 376
 
375 377
 func (SpSupplierWarehousingCancelOrder) TableName() string {
@@ -416,10 +418,11 @@ func (VmSpSupplierWarehousingOutOrder) TableName() string {
416 418
 }
417 419
 
418 420
 type VmSpSupplierWarehousingCancelOrder struct {
419
-	ProjectId  int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
420
-	IsSource   int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
421
-	Count      int64  `gorm:"column:count" json:"count" form:"count"`
422
-	SupplyUnit string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
421
+	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
422
+	IsSource    int64  `gorm:"column:is_source" json:"is_source" form:"is_source"`
423
+	Count       string `gorm:"column:count" json:"count" form:"count"`
424
+	SupplyUnit  string `gorm:"column:supply_unit" json:"supply_unit" form:"supply_unit"`
425
+	SupplyCount int64  `gorm:"column:supply_count" json:"supply_count" form:"supply_count"`
423 426
 }
424 427
 
425 428
 func (VmSpSupplierWarehousingCancelOrder) TableName() string {

+ 8 - 2
service/supply_service.go Bestand weergeven

@@ -655,7 +655,7 @@ func GetReturnCancelOrder(id int64, orgid int64) (models.SpSupplierWarehouseCanc
655 655
 	return cancel, err
656 656
 }
657 657
 
658
-func GetReturnCancelOrderList(id int64, orgid int64) (order models.SpSupplierWarehousingCancelOrder, err error) {
658
+func GetReturnCancelOrderList(id int64, orgid int64) (order []*models.SpSupplierWarehousingCancelOrder, err error) {
659 659
 
660 660
 	err = XTReadDB().Where("warehouse_cancel_id = ? and user_org_id =? and status = 1", id, orgid).Find(&order).Error
661 661
 	return order, err
@@ -715,7 +715,7 @@ func GetGoodReturnOrderDetail(id int64, orgid int64) (order []*models.SpSupplier
715 715
 
716 716
 func UpdateWarehouseCancelOrder(order *models.SpSupplierWarehousingCancelOrder) error {
717 717
 
718
-	err = XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"manufacturer_id": order.ManufacturerId, "order_number": order.OrderNumber, "project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Price, "remark": order.Remark, "rate_of_concession": order.RateOfConcession, "discount_amount": order.DiscountAmount, "type": order.Type, "supply_specification_name": order.SupplySpecificationName, "supply_type": order.SupplyType, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "supply_license_number": order.SupplyLicenseNumber}).Error
718
+	err = XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"manufacturer_id": order.ManufacturerId, "order_number": order.OrderNumber, "project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Price, "remark": order.Remark, "rate_of_concession": order.RateOfConcession, "discount_amount": order.DiscountAmount, "type": order.Type, "supply_specification_name": order.SupplySpecificationName, "supply_type": order.SupplyType, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "supply_license_number": order.SupplyLicenseNumber, "supply_count": order.SupplyCount, "deposit_rate": order.DepositRate}).Error
719 719
 	return err
720 720
 }
721 721
 
@@ -1054,3 +1054,9 @@ func ModfySupplyCancel(id int64, orgid int64) error {
1054 1054
 	err = XTWriteDB().Model(models.SpSupplierWarehousingCancelOrder{}).Where("warehouse_cancel_id = ? and user_org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"warehouse_info_id": 0, "warehouse_out_id": 0, "warehousing_id": 0, "good_number": "", "order_number": ""}).Error
1055 1055
 	return err
1056 1056
 }
1057
+
1058
+func UpdateSupplyWarehouseInfo(id int64) error {
1059
+
1060
+	err = XTWriteDB().Model(&models.SupplierWarehouseInfo{}).Where("id = ? and status= 1").Updates(map[string]interface{}{"is_warehouse": 2}).Error
1061
+	return err
1062
+}