|
@@ -79,6 +79,8 @@ func SelfDrugRouters() {
|
79
|
79
|
beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
|
80
|
80
|
beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
|
81
|
81
|
beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
|
|
82
|
+
|
|
83
|
+ beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
|
82
|
84
|
}
|
83
|
85
|
|
84
|
86
|
func (this *SelfDrugApiController) GetCurrentPatient() {
|
|
@@ -1726,6 +1728,7 @@ func (this *SelfDrugApiController) GetWarehoseInfoById() {
|
1726
|
1728
|
|
1727
|
1729
|
id, _ := this.GetInt64("id")
|
1728
|
1730
|
list, _ := service.GetWarehoseInfoById(id)
|
|
1731
|
+
|
1729
|
1732
|
this.ServeSuccessJSON(map[string]interface{}{
|
1730
|
1733
|
"list": list,
|
1731
|
1734
|
})
|
|
@@ -2386,3 +2389,179 @@ func (this *StockManagerApiController) GetDrugWarehouseInfoTotal() {
|
2386
|
2389
|
"list": list,
|
2387
|
2390
|
})
|
2388
|
2391
|
}
|
|
2392
|
+
|
|
2393
|
+//新改造
|
|
2394
|
+
|
|
2395
|
+func (this *SelfDrugApiController) SaveInventoryList() {
|
|
2396
|
+
|
|
2397
|
+ dataBody := make(map[string]interface{}, 0)
|
|
2398
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
2399
|
+ fmt.Println(err)
|
|
2400
|
+
|
|
2401
|
+ tableData, _ := dataBody["tableData"].([]interface{})
|
|
2402
|
+ fmt.Println("999939433443", tableData)
|
|
2403
|
+ if len(tableData) > 0 {
|
|
2404
|
+ for _, item := range tableData {
|
|
2405
|
+ items := item.(map[string]interface{})
|
|
2406
|
+ drug_name := items["drug_name"].(string)
|
|
2407
|
+ if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
|
|
2408
|
+ utils.ErrorLog("drug_name")
|
|
2409
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2410
|
+ return
|
|
2411
|
+ }
|
|
2412
|
+ fmt.Println("drug_name", drug_name)
|
|
2413
|
+ specification_name := items["specification_name"].(string)
|
|
2414
|
+ if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
|
|
2415
|
+ utils.ErrorLog("specification_name")
|
|
2416
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2417
|
+ return
|
|
2418
|
+ }
|
|
2419
|
+
|
|
2420
|
+ max_unit := items["max_unit"].(string)
|
|
2421
|
+ if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
|
|
2422
|
+ utils.ErrorLog("max_unit")
|
|
2423
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2424
|
+ return
|
|
2425
|
+ }
|
|
2426
|
+
|
|
2427
|
+ min_unit := items["min_unit"].(string)
|
|
2428
|
+ if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
|
|
2429
|
+ utils.ErrorLog("min_unit")
|
|
2430
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2431
|
+ return
|
|
2432
|
+ }
|
|
2433
|
+
|
|
2434
|
+ drug_id := int64(items["drug_id"].(float64))
|
|
2435
|
+
|
|
2436
|
+ min_number := int64(items["min_number"].(float64))
|
|
2437
|
+
|
|
2438
|
+ stock_max_number := int64(items["stock_max_number"].(float64))
|
|
2439
|
+
|
|
2440
|
+ stock_min_number := int64(items["stock_min_number"].(float64))
|
|
2441
|
+
|
|
2442
|
+ last_stock_max_number := int64(items["last_stock_max_number"].(float64))
|
|
2443
|
+
|
|
2444
|
+ last_stock_min_number := int64(items["last_stock_min_number"].(float64))
|
|
2445
|
+
|
|
2446
|
+ warehousing_order := items["warehousing_order"].(string)
|
|
2447
|
+
|
|
2448
|
+ price := items["price"].(float64)
|
|
2449
|
+
|
|
2450
|
+ manufacturer_name := items["manufacturer_name"].(string)
|
|
2451
|
+
|
|
2452
|
+ batch_number := items["batch_number"].(string)
|
|
2453
|
+
|
|
2454
|
+ id := int64(items["id"].(float64))
|
|
2455
|
+
|
|
2456
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
2457
|
+
|
|
2458
|
+ if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
|
|
2459
|
+ utils.ErrorLog("expiry_date")
|
|
2460
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
2461
|
+ return
|
|
2462
|
+ }
|
|
2463
|
+ expiry_date := int64(items["expiry_date"].(float64))
|
|
2464
|
+
|
|
2465
|
+ manufacturer := int64(items["manufacturer"].(float64))
|
|
2466
|
+
|
|
2467
|
+ var consumable_type int64
|
|
2468
|
+ var ord_total int64
|
|
2469
|
+ var new_total int64
|
|
2470
|
+ ord_total = stock_max_number*min_number + stock_min_number
|
|
2471
|
+ new_total = last_stock_max_number*min_number + last_stock_min_number
|
|
2472
|
+ if ord_total > new_total {
|
|
2473
|
+ consumable_type = 11
|
|
2474
|
+ }
|
|
2475
|
+ if ord_total < new_total {
|
|
2476
|
+ consumable_type = 10
|
|
2477
|
+ }
|
|
2478
|
+
|
|
2479
|
+ inventory := models.XtDrugInventory{
|
|
2480
|
+ DrugName: drug_name,
|
|
2481
|
+ SpecificationName: specification_name,
|
|
2482
|
+ WarehousingUnit: max_unit,
|
|
2483
|
+ Count: 0,
|
|
2484
|
+ LastPrice: price,
|
|
2485
|
+ RetailPrice: 0,
|
|
2486
|
+ NewPrice: 0,
|
|
2487
|
+ Manufacturer: manufacturer_name,
|
|
2488
|
+ Dealer: "",
|
|
2489
|
+ Remark: "",
|
|
2490
|
+ DrugId: drug_id,
|
|
2491
|
+ UserOrgId: orgId,
|
|
2492
|
+ Ctime: time.Now().Unix(),
|
|
2493
|
+ Mtime: 0,
|
|
2494
|
+ Status: 1,
|
|
2495
|
+ WarehousingOrder: warehousing_order,
|
|
2496
|
+ LicenseNumber: "",
|
|
2497
|
+ StartTime: 0,
|
|
2498
|
+ Creater: this.GetAdminUserInfo().AdminUser.Id,
|
|
2499
|
+ Checker: 0,
|
|
2500
|
+ CheckerStatus: 0,
|
|
2501
|
+ CheckerTime: 0,
|
|
2502
|
+ ExpiryDate: expiry_date,
|
|
2503
|
+ ProductDate: 0,
|
|
2504
|
+ Number: "",
|
|
2505
|
+ BatchNumber: batch_number,
|
|
2506
|
+ Total: "",
|
|
2507
|
+ DrugOriginPlace: "",
|
|
2508
|
+ WarehouseInfoId: id,
|
|
2509
|
+ ProofCount: 0,
|
|
2510
|
+ StockMaxNumber: stock_max_number,
|
|
2511
|
+ StockMinNumber: stock_min_number,
|
|
2512
|
+ MinCount: 0,
|
|
2513
|
+ MinUnit: min_unit,
|
|
2514
|
+ LastStockMaxNumber: last_stock_max_number,
|
|
2515
|
+ LastStockMinNumber: last_stock_min_number,
|
|
2516
|
+ }
|
|
2517
|
+
|
|
2518
|
+ err = service.CreateDrugInventory(inventory)
|
|
2519
|
+
|
|
2520
|
+ flow := models.DrugFlow{
|
|
2521
|
+ WarehousingId: id,
|
|
2522
|
+ DrugId: drug_id,
|
|
2523
|
+ Number: "",
|
|
2524
|
+ BatchNumber: batch_number,
|
|
2525
|
+ Count: 0,
|
|
2526
|
+ UserOrgId: orgId,
|
|
2527
|
+ PatientId: 0,
|
|
2528
|
+ SystemTime: time.Now().Unix(),
|
|
2529
|
+ ConsumableType: consumable_type,
|
|
2530
|
+ IsSys: 1,
|
|
2531
|
+ WarehousingOrder: warehousing_order,
|
|
2532
|
+ WarehouseOutId: 0,
|
|
2533
|
+ WarehouseOutOrderNumber: "",
|
|
2534
|
+ IsEdit: 0,
|
|
2535
|
+ CancelStockId: 0,
|
|
2536
|
+ CancelOrderNumber: "",
|
|
2537
|
+ Manufacturer: manufacturer,
|
|
2538
|
+ Dealer: 0,
|
|
2539
|
+ Creator: this.GetAdminUserInfo().AdminUser.Id,
|
|
2540
|
+ UpdateCreator: 0,
|
|
2541
|
+ Status: 1,
|
|
2542
|
+ Ctime: time.Now().Unix(),
|
|
2543
|
+ Mtime: 0,
|
|
2544
|
+ Price: price,
|
|
2545
|
+ WarehousingDetailId: id,
|
|
2546
|
+ WarehouseOutDetailId: 0,
|
|
2547
|
+ CancelOutDetailId: 0,
|
|
2548
|
+ ExpireDate: expiry_date,
|
|
2549
|
+ ProductDate: 0,
|
|
2550
|
+ MaxUnit: max_unit,
|
|
2551
|
+ MinUnit: min_unit,
|
|
2552
|
+ }
|
|
2553
|
+
|
|
2554
|
+ service.CreateDrugFlowOne(flow)
|
|
2555
|
+
|
|
2556
|
+ //改变库存
|
|
2557
|
+ info := models.DrugWarehouseInfo{
|
|
2558
|
+ DrugId: drug_id,
|
|
2559
|
+ StockMaxNumber: last_stock_max_number,
|
|
2560
|
+ StockMinNumber: last_stock_min_number,
|
|
2561
|
+ }
|
|
2562
|
+
|
|
2563
|
+ err = service.ModifyDrugWarehouseInfo(&info, drug_id)
|
|
2564
|
+ fmt.Println(err)
|
|
2565
|
+ }
|
|
2566
|
+ }
|
|
2567
|
+}
|