csx 3 年 前
コミット
8c7181dfea

+ 4 - 2
controllers/gobal_config_api_controller.go ファイルの表示

@@ -1969,13 +1969,15 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
1969 1969
 	limit, _ := c.GetInt64("limit")
1970 1970
 	page, _ := c.GetInt64("page")
1971 1971
 	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit)
1972
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1972 1973
 	if err != nil {
1973 1974
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1974 1975
 		return
1975 1976
 	}
1976 1977
 	c.ServeSuccessJSON(map[string]interface{}{
1977
-		"detail": detail,
1978
-		"total":  total,
1978
+		"detail":           detail,
1979
+		"total":            total,
1980
+		"manufacturerList": manufacturerList,
1979 1981
 	})
1980 1982
 }
1981 1983
 

+ 200 - 0
controllers/self_drug_api_congtroller.go ファイルの表示

@@ -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() {
@@ -1450,6 +1452,8 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1450 1452
 	limit, _ := this.GetInt64("limit")
1451 1453
 	page, _ := this.GetInt64("page")
1452 1454
 	list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
1455
+
1456
+	damagelist, _ := service.GetDrugDamageByOrgId(orgId)
1453 1457
 	doctorList, err := service.GetAllDoctorThree(orgId)
1454 1458
 	if err != nil {
1455 1459
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
@@ -1459,6 +1463,7 @@ func (this *SelfDrugApiController) GetDrugDamageList() {
1459 1463
 	this.ServeSuccessJSON(map[string]interface{}{
1460 1464
 		"total":      total,
1461 1465
 		"list":       list,
1466
+		"damagelist": damagelist,
1462 1467
 		"doctorList": doctorList,
1463 1468
 	})
1464 1469
 }
@@ -1726,6 +1731,7 @@ func (this *SelfDrugApiController) GetWarehoseInfoById() {
1726 1731
 
1727 1732
 	id, _ := this.GetInt64("id")
1728 1733
 	list, _ := service.GetWarehoseInfoById(id)
1734
+
1729 1735
 	this.ServeSuccessJSON(map[string]interface{}{
1730 1736
 		"list": list,
1731 1737
 	})
@@ -2386,3 +2392,197 @@ func (this *StockManagerApiController) GetDrugWarehouseInfoTotal() {
2386 2392
 		"list": list,
2387 2393
 	})
2388 2394
 }
2395
+
2396
+//新改造
2397
+
2398
+func (this *SelfDrugApiController) SaveInventoryList() {
2399
+
2400
+	dataBody := make(map[string]interface{}, 0)
2401
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
2402
+	fmt.Println(err)
2403
+
2404
+	tableData, _ := dataBody["tableData"].([]interface{})
2405
+	fmt.Println("999939433443", tableData)
2406
+	if len(tableData) > 0 {
2407
+		for _, item := range tableData {
2408
+			items := item.(map[string]interface{})
2409
+			drug_name := items["drug_name"].(string)
2410
+			if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
2411
+				utils.ErrorLog("drug_name")
2412
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2413
+				return
2414
+			}
2415
+			fmt.Println("drug_name", drug_name)
2416
+			specification_name := items["specification_name"].(string)
2417
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
2418
+				utils.ErrorLog("specification_name")
2419
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2420
+				return
2421
+			}
2422
+
2423
+			max_unit := items["max_unit"].(string)
2424
+			if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
2425
+				utils.ErrorLog("max_unit")
2426
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2427
+				return
2428
+			}
2429
+
2430
+			min_unit := items["min_unit"].(string)
2431
+			if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
2432
+				utils.ErrorLog("min_unit")
2433
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2434
+				return
2435
+			}
2436
+
2437
+			drug_id := int64(items["drug_id"].(float64))
2438
+
2439
+			min_number := int64(items["min_number"].(float64))
2440
+
2441
+			stock_max_number := int64(items["stock_max_number"].(float64))
2442
+
2443
+			stock_min_number := int64(items["stock_min_number"].(float64))
2444
+
2445
+			last_stock_max_number := int64(items["last_stock_max_number"].(float64))
2446
+
2447
+			last_stock_min_number := int64(items["last_stock_min_number"].(float64))
2448
+
2449
+			warehousing_order := items["warehousing_order"].(string)
2450
+
2451
+			price := items["price"].(float64)
2452
+
2453
+			manufacturer_name := items["manufacturer_name"].(string)
2454
+
2455
+			batch_number := items["batch_number"].(string)
2456
+
2457
+			id := int64(items["id"].(float64))
2458
+
2459
+			orgId := this.GetAdminUserInfo().CurrentOrgId
2460
+
2461
+			type_id := int64(items["type"].(float64))
2462
+
2463
+			if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
2464
+				utils.ErrorLog("expiry_date")
2465
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2466
+				return
2467
+			}
2468
+			expiry_date := int64(items["expiry_date"].(float64))
2469
+
2470
+			manufacturer := int64(items["manufacturer"].(float64))
2471
+			timeLayout := "2006-01-02"
2472
+			loc, _ := time.LoadLocation("Local")
2473
+			timeNow := time.Now().Format("2006-01-02")
2474
+			locationTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeNow+" 00:00:00", loc)
2475
+			var consumable_type int64
2476
+			var consumable_count int64
2477
+			var ord_total int64
2478
+			var new_total int64
2479
+			ord_total = stock_max_number*min_number + stock_min_number
2480
+			new_total = last_stock_max_number*min_number + last_stock_min_number
2481
+
2482
+			if ord_total > new_total {
2483
+				consumable_type = 11
2484
+				consumable_count = ord_total - new_total
2485
+			}
2486
+			if ord_total < new_total {
2487
+				consumable_type = 10
2488
+				consumable_count = new_total - ord_total
2489
+			}
2490
+
2491
+			//改变库存
2492
+			info := models.DrugWarehouseInfo{
2493
+				DrugId:         drug_id,
2494
+				StockMaxNumber: last_stock_max_number,
2495
+				StockMinNumber: last_stock_min_number,
2496
+			}
2497
+
2498
+			err = service.ModifyDrugWarehouseInfo(&info, id)
2499
+			inventory := models.XtDrugInventory{
2500
+				DrugName:           drug_name,
2501
+				SpecificationName:  specification_name,
2502
+				WarehousingUnit:    max_unit,
2503
+				Count:              consumable_count,
2504
+				LastPrice:          price,
2505
+				RetailPrice:        0,
2506
+				NewPrice:           0,
2507
+				Manufacturer:       manufacturer_name,
2508
+				Dealer:             "",
2509
+				Remark:             "",
2510
+				DrugId:             drug_id,
2511
+				UserOrgId:          orgId,
2512
+				Ctime:              time.Now().Unix(),
2513
+				Mtime:              0,
2514
+				Status:             1,
2515
+				WarehousingOrder:   warehousing_order,
2516
+				LicenseNumber:      "",
2517
+				StartTime:          locationTime.Unix(),
2518
+				Creater:            this.GetAdminUserInfo().AdminUser.Id,
2519
+				Checker:            0,
2520
+				CheckerStatus:      0,
2521
+				CheckerTime:        0,
2522
+				ExpiryDate:         expiry_date,
2523
+				ProductDate:        0,
2524
+				Number:             "",
2525
+				BatchNumber:        batch_number,
2526
+				Total:              "",
2527
+				DrugOriginPlace:    "",
2528
+				WarehouseInfoId:    id,
2529
+				ProofCount:         0,
2530
+				StockMaxNumber:     stock_max_number,
2531
+				StockMinNumber:     stock_min_number,
2532
+				MinCount:           0,
2533
+				MinUnit:            min_unit,
2534
+				LastStockMaxNumber: last_stock_max_number,
2535
+				LastStockMinNumber: last_stock_min_number,
2536
+				InventoryType:      consumable_type,
2537
+				Type:               type_id,
2538
+			}
2539
+
2540
+			err = service.CreateDrugInventory(inventory)
2541
+
2542
+			flow := models.DrugFlow{
2543
+				WarehousingId:           id,
2544
+				DrugId:                  drug_id,
2545
+				Number:                  "",
2546
+				BatchNumber:             batch_number,
2547
+				Count:                   consumable_count,
2548
+				UserOrgId:               orgId,
2549
+				PatientId:               0,
2550
+				SystemTime:              locationTime.Unix(),
2551
+				ConsumableType:          consumable_type,
2552
+				IsSys:                   1,
2553
+				WarehousingOrder:        warehousing_order,
2554
+				WarehouseOutId:          0,
2555
+				WarehouseOutOrderNumber: "",
2556
+				IsEdit:                  0,
2557
+				CancelStockId:           0,
2558
+				CancelOrderNumber:       "",
2559
+				Manufacturer:            manufacturer,
2560
+				Dealer:                  0,
2561
+				Creator:                 this.GetAdminUserInfo().AdminUser.Id,
2562
+				UpdateCreator:           0,
2563
+				Status:                  1,
2564
+				Ctime:                   time.Now().Unix(),
2565
+				Mtime:                   0,
2566
+				Price:                   price,
2567
+				WarehousingDetailId:     id,
2568
+				WarehouseOutDetailId:    0,
2569
+				CancelOutDetailId:       0,
2570
+				ExpireDate:              expiry_date,
2571
+				ProductDate:             0,
2572
+				MaxUnit:                 max_unit,
2573
+				MinUnit:                 min_unit,
2574
+			}
2575
+
2576
+			service.CreateDrugFlowOne(flow)
2577
+
2578
+			if err != nil {
2579
+				this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2580
+				return
2581
+			}
2582
+
2583
+			this.ServeSuccessJSON(map[string]interface{}{
2584
+				"inventory": inventory,
2585
+			})
2586
+		}
2587
+	}
2588
+}

+ 38 - 32
models/drug_stock.go ファイルの表示

@@ -327,38 +327,44 @@ type StDrugWarehouseOutInfo struct {
327 327
 }
328 328
 
329 329
 type DrugFlow struct {
330
-	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
331
-	WarehousingId           int64   `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
332
-	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
333
-	Number                  string  `gorm:"column:number" json:"number" form:"number"`
334
-	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
335
-	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
336
-	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
337
-	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
338
-	SystemTime              int64   `gorm:"column:system_time" json:"system_time" form:"system_time"`
339
-	ConsumableType          int64   `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
340
-	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
341
-	WarehousingOrder        string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
342
-	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
343
-	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
344
-	IsEdit                  int64   `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
345
-	CancelStockId           int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
346
-	CancelOrderNumber       string  `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
347
-	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
-	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
349
-	Creator                 int64   `gorm:"column:creator" json:"creator" form:"creator"`
350
-	UpdateCreator           int64   `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
351
-	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
352
-	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
353
-	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
354
-	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
355
-	WarehousingDetailId     int64   `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
356
-	WarehouseOutDetailId    int64   `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
357
-	CancelOutDetailId       int64   `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
358
-	ExpireDate              int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
359
-	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
360
-	MaxUnit                 string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
361
-	MinUnit                 string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
330
+	ID                      int64                `gorm:"column:id" json:"id" form:"id"`
331
+	WarehousingId           int64                `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
332
+	DrugId                  int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
333
+	Number                  string               `gorm:"column:number" json:"number" form:"number"`
334
+	BatchNumber             string               `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
335
+	Count                   int64                `gorm:"column:count" json:"count" form:"count"`
336
+	UserOrgId               int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
337
+	PatientId               int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
338
+	SystemTime              int64                `gorm:"column:system_time" json:"system_time" form:"system_time"`
339
+	ConsumableType          int64                `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
340
+	IsSys                   int64                `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
341
+	WarehousingOrder        string               `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
342
+	WarehouseOutId          int64                `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
343
+	WarehouseOutOrderNumber string               `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
344
+	IsEdit                  int64                `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
345
+	CancelStockId           int64                `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
346
+	CancelOrderNumber       string               `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
347
+	Manufacturer            int64                `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
348
+	Dealer                  int64                `gorm:"column:dealer" json:"dealer" form:"dealer"`
349
+	Creator                 int64                `gorm:"column:creator" json:"creator" form:"creator"`
350
+	UpdateCreator           int64                `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
351
+	Status                  int64                `gorm:"column:status" json:"status" form:"status"`
352
+	Ctime                   int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
353
+	Mtime                   int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
354
+	Price                   float64              `gorm:"column:price" json:"price" form:"price"`
355
+	WarehousingDetailId     int64                `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
356
+	WarehouseOutDetailId    int64                `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
357
+	CancelOutDetailId       int64                `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
358
+	ExpireDate              int64                `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
359
+	ProductDate             int64                `gorm:"column:product_date" json:"product_date" form:"product_date"`
360
+	MaxUnit                 string               `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
361
+	MinUnit                 string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
362
+	StockMaxNumber          int64                `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
363
+	StockMinNumber          int64                `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
364
+	LastStockMaxNumber      int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
365
+	LastStockMinNumber      int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
366
+	DrugWarehouseInfo       []*DrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" `
367
+	BaseDrugLib             BaseDrugLib          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
362 368
 }
363 369
 
364 370
 func (DrugFlow) TableName() string {

+ 79 - 68
models/self_drug_models.go ファイルの表示

@@ -768,41 +768,45 @@ func (XtDrugDamage) TableName() string {
768 768
 }
769 769
 
770 770
 type XtDrugInventory struct {
771
-	ID                int64   `gorm:"column:id" json:"id" form:"id"`
772
-	DrugName          string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
773
-	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
774
-	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
775
-	Count             int64   `gorm:"column:count" json:"count" form:"count"`
776
-	LastPrice         float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
777
-	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
778
-	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
779
-	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
780
-	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
781
-	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
782
-	DrugId            int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
783
-	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
784
-	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
785
-	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
786
-	Status            int64   `gorm:"column:status" json:"status" form:"status"`
787
-	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
788
-	LicenseNumber     string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
789
-	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
790
-	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
791
-	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
792
-	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
793
-	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
794
-	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
795
-	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
796
-	Number            string  `gorm:"column:number" json:"number" form:"number"`
797
-	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
798
-	Total             string  `gorm:"column:total" json:"total" form:"total"`
799
-	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
800
-	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
801
-	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
802
-	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
803
-	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
804
-	MinCount          int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
805
-	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
771
+	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
772
+	DrugName           string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
773
+	SpecificationName  string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
774
+	WarehousingUnit    string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
775
+	Count              int64   `gorm:"column:count" json:"count" form:"count"`
776
+	LastPrice          float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
777
+	RetailPrice        float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
778
+	NewPrice           float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
779
+	Manufacturer       string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
780
+	Dealer             string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
781
+	Remark             string  `gorm:"column:remark" json:"remark" form:"remark"`
782
+	DrugId             int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
783
+	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
784
+	Ctime              int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
785
+	Mtime              int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
786
+	Status             int64   `gorm:"column:status" json:"status" form:"status"`
787
+	WarehousingOrder   string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
788
+	LicenseNumber      string  `gorm:"column:license_number" json:"license_number" form:"license_number"`
789
+	StartTime          int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
790
+	Creater            int64   `gorm:"column:creater" json:"creater" form:"creater"`
791
+	Checker            int64   `gorm:"column:checker" json:"checker" form:"checker"`
792
+	CheckerStatus      int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
793
+	CheckerTime        int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
794
+	ExpiryDate         int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
795
+	ProductDate        int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
796
+	Number             string  `gorm:"column:number" json:"number" form:"number"`
797
+	BatchNumber        string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
798
+	Total              string  `gorm:"column:total" json:"total" form:"total"`
799
+	DrugOriginPlace    string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
800
+	WarehouseInfoId    int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
801
+	ProofCount         int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
802
+	StockMaxNumber     int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
803
+	StockMinNumber     int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
804
+	MinCount           int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
805
+	MinUnit            string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
806
+	LastStockMaxNumber int64   `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
807
+	LastStockMinNumber int64   `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
808
+	InventoryType      int64   `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
809
+	Type               int64   `gorm:"column:type" json:"type" form:"type"`
806 810
 }
807 811
 
808 812
 func (XtDrugInventory) TableName() string {
@@ -810,39 +814,46 @@ func (XtDrugInventory) TableName() string {
810 814
 }
811 815
 
812 816
 type VmDrugInventory struct {
813
-	ID                int64   `gorm:"column:id" json:"id" form:"id"`
814
-	DrugName          string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
815
-	SpecificationName string  `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
816
-	WarehousingUnit   string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
817
-	Count             int64   `gorm:"column:count" json:"count" form:"count"`
818
-	LastPrice         float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
819
-	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
820
-	NewPrice          float64 `gorm:"column:new_price" json:"new_price" form:"new_price"`
821
-	Manufacturer      string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
822
-	Dealer            string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
823
-	Remark            string  `gorm:"column:remark" json:"remark" form:"remark"`
824
-	DrugId            int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
825
-	UserOrgId         int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
826
-	Ctime             int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
827
-	Mtime             int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
828
-	Status            int64   `gorm:"column:status" json:"status" form:"status"`
829
-	WarehousingOrder  string  `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
830
-	Number            string  `gorm:"column:number" json:"number" form:"number"`
831
-	StartTime         int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
832
-	Creater           int64   `gorm:"column:creater" json:"creater" form:"creater"`
833
-	Checker           int64   `gorm:"column:checker" json:"checker" form:"checker"`
834
-	CheckerStatus     int64   `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
835
-	CheckerTime       int64   `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
836
-	MinNumber         int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
837
-	Dose              float64 `gorm:"column:dose" json:"dose" form:"dose"`
838
-	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
839
-	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
840
-	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
841
-	MinCount          int64   `gorm:"column:min_count" json:"min_count" form:"min_count"`
842
-	Total             string  `gorm:"column:total" json:"total" form:"total"`
843
-	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
844
-	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
845
-	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
817
+	ID                 int64              `gorm:"column:id" json:"id" form:"id"`
818
+	DrugName           string             `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
819
+	SpecificationName  string             `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
820
+	WarehousingUnit    string             `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
821
+	Count              int64              `gorm:"column:count" json:"count" form:"count"`
822
+	LastPrice          float64            `gorm:"column:last_price" json:"last_price" form:"last_price"`
823
+	RetailPrice        float64            `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
824
+	NewPrice           float64            `gorm:"column:new_price" json:"new_price" form:"new_price"`
825
+	Manufacturer       string             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
826
+	Dealer             string             `gorm:"column:dealer" json:"dealer" form:"dealer"`
827
+	Remark             string             `gorm:"column:remark" json:"remark" form:"remark"`
828
+	DrugId             int64              `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
829
+	UserOrgId          int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
830
+	Ctime              int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
831
+	Mtime              int64              `gorm:"column:mtime" json:"mtime" form:"mtime"`
832
+	Status             int64              `gorm:"column:status" json:"status" form:"status"`
833
+	WarehousingOrder   string             `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
834
+	Number             string             `gorm:"column:number" json:"number" form:"number"`
835
+	StartTime          int64              `gorm:"column:start_time" json:"start_time" form:"start_time"`
836
+	Creater            int64              `gorm:"column:creater" json:"creater" form:"creater"`
837
+	Checker            int64              `gorm:"column:checker" json:"checker" form:"checker"`
838
+	CheckerStatus      int64              `gorm:"column:checker_status" json:"checker_status" form:"checker_status"`
839
+	CheckerTime        int64              `gorm:"column:checker_time" json:"checker_time" form:"checker_time"`
840
+	MinNumber          int64              `gorm:"column:min_number" json:"min_number" form:"min_number"`
841
+	Dose               float64            `gorm:"column:dose" json:"dose" form:"dose"`
842
+	DoseUnit           string             `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
843
+	MaxUnit            string             `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
844
+	MinUnit            string             `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
845
+	MinCount           int64              `gorm:"column:min_count" json:"min_count" form:"min_count"`
846
+	Total              string             `gorm:"column:total" json:"total" form:"total"`
847
+	ExpiryDate         int64              `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
848
+	ProductDate        int64              `gorm:"column:product_date" json:"product_date" form:"product_date"`
849
+	DrugOriginPlace    string             `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
850
+	LastStockMaxNumber int64              `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
851
+	LastStockMinNumber int64              `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
852
+	InventoryType      int64              `gorm:"column:inventory_type" json:"inventory_type" form:"inventory_type"`
853
+	StockMaxNumber     int64              `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
854
+	StockMinNumber     int64              `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
855
+	WarehouseInfoId    int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
856
+	Children           []*XtDrugInventory `gorm:"column:children" json:"children" form:"children"`
846 857
 }
847 858
 
848 859
 type SgjDrugWarehouseOutInfo struct {

+ 76 - 0
service/app_version.go ファイルの表示

@@ -361,3 +361,79 @@ func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplat
361 361
 func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
362 362
 	writeDb.Save(&advice)
363 363
 }
364
+
365
+func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
366
+	err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
367
+	return
368
+}
369
+
370
+type HisPrescriptionProjectTemplate struct {
371
+	ID                 int64   `gorm:"column:id" json:"id" form:"id"`
372
+	ProjectId          int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
373
+	Price              float64 `gorm:"column:price" json:"price" form:"price"`
374
+	UserOrgId          int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
375
+	Status             int64   `gorm:"column:status" json:"status" form:"status"`
376
+	Ctime              int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
377
+	Mtime              int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
378
+	PatientId          int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
379
+	HisPatientId       int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
380
+	RecordDate         int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
381
+	Count              int64   `gorm:"column:count" json:"count" form:"count"`
382
+	FeedetlSn          string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
383
+	MedListCodg        string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
384
+	SingleDose         string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
385
+	DeliveryWay        string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
386
+	ExecutionFrequency string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
387
+	Day                string  `gorm:"column:day" json:"day" form:"day"`
388
+	Remark             string  `gorm:"column:remark" json:"remark" form:"remark"`
389
+	Unit               string  `gorm:"column:unit" json:"unit" form:"unit"`
390
+	Type               int64   `gorm:"column:type" json:"type" form:"type"`
391
+	PrescriptionId     int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
392
+	FrequencyType      int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
393
+	DayCount           int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
394
+	WeekDay            string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
395
+}
396
+
397
+func (HisPrescriptionProjectTemplate) TableName() string {
398
+	return "his_prescription_project_template"
399
+}
400
+
401
+type HisPrescriptionInfoTemplateTHree struct {
402
+	ID                             int64                            `gorm:"column:id" json:"id" form:"id"`
403
+	UserOrgId                      int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
404
+	RecordDate                     int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
405
+	PatientId                      int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
406
+	Status                         int64                            `gorm:"column:status" json:"status" form:"status"`
407
+	Ctime                          int64                            `gorm:"column:ctime" json:"ctime" form:"ctime"`
408
+	Mtime                          int64                            `gorm:"column:mtime" json:"mtime" form:"mtime"`
409
+	Type                           int64                            `gorm:"column:type" json:"type" form:"type"`
410
+	Creator                        int64                            `gorm:"column:creator" json:"creator" form:"creator"`
411
+	Modifier                       int64                            `gorm:"column:modifier" json:"modifier" form:"modifier"`
412
+	PType                          int64                            `gorm:"column:p_type" json:"p_type" form:"p_type"`
413
+	PTemplateId                    int64                            `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
414
+	HisPrescriptionAdviceTemplate  []HisPrescriptionAdviceTemplate  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
415
+	HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
416
+	MedType                        string                           `gorm:"column:med_type" json:"med_type" form:"med_type"`
417
+}
418
+
419
+func (HisPrescriptionInfoTemplateTHree) TableName() string {
420
+	return "his_prescription_info_template"
421
+}
422
+
423
+func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
424
+	err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
425
+		return db.Where("status = 1")
426
+	}).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
427
+		return db.Where("status = 1")
428
+	}).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
429
+	return
430
+}
431
+
432
+func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
433
+	err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
434
+	return
435
+}
436
+func UpdateStatus(project_id int64, p_id int64) {
437
+	writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
438
+	writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
439
+}

+ 18 - 3
service/auto_create_drug.go ファイルの表示

@@ -43,7 +43,6 @@ func AutoCreateDrugJob() {
43 43
 
44 44
 	var total int64
45 45
 	for _, item := range org {
46
-		fmt.Println("hhhh2h3h2323232323232323", item.UserOrgId)
47 46
 		//查询该机构下的所有药品信息
48 47
 		list, _ := FindAllDrugList(item.UserOrgId)
49 48
 		for _, ite := range list {
@@ -56,10 +55,10 @@ func AutoCreateDrugJob() {
56 55
 					total = it.StockMaxNumber + it.StockMinNumber
57 56
 					fmt.Println(it.StockMaxNumber)
58 57
 					fmt.Println(it.StockMinNumber)
59
-					fmt.Println("total223232323232323232323", total)
58
+
60 59
 					formatInt := strconv.FormatInt(total, 10)
61 60
 					float, _ := strconv.ParseFloat(formatInt, 64)
62
-					fmt.Println("min_number2323232323232", float)
61
+
63 62
 					lib := models.BaseDrugLib{
64 63
 						Total: float,
65 64
 					}
@@ -108,3 +107,19 @@ func UpdateDrugTotal(id int64, lib models.BaseDrugLib) error {
108 107
 	err := XTWriteDB().Model(&lib).Where("id=? and status = 1", id).Updates(map[string]interface{}{"total": lib.Total}).Error
109 108
 	return err
110 109
 }
110
+
111
+func FindAllDrugWarehouseInfo(drug_id int64) (models.DrugWarehouseInfoSix, error) {
112
+
113
+	info := models.DrugWarehouseInfoSix{}
114
+
115
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
116
+	table := XTReadDB().Table("xt_base_drug as b").Where("b.status = 1")
117
+	fmt.Println(table)
118
+	if drug_id > 0 {
119
+		db = db.Where("x.drug_id = ?", drug_id)
120
+	}
121
+
122
+	err = db.Select("x.drug_id,sum(x.warehousing_count) as warehousing_count,b.min_number").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&info).Error
123
+
124
+	return info, err
125
+}

+ 2 - 2
service/auto_create_stock.go ファイルの表示

@@ -14,8 +14,8 @@ var createStockCronJob *cron.Cron
14 14
 func init() {
15 15
 	utils.InfoLog("开启自动更新耗材库存定时任务")
16 16
 	createStockCronJob = cron.New()
17
-	spec := "0 */5 * * * ?" // 每1分钟执行一次
18
-	//spec := "0 55 23 * * ?" // 每天23点55执行一次
17
+	//spec := "0 */5 * * * ?" // 每1分钟执行一次
18
+	spec := "0 55 23 * * ?" // 每天23点55执行一次
19 19
 	//spec := "0 0 0 ? * Sun"
20 20
 	createStockCronJob.AddFunc(spec, func() {
21 21
 		AutoCreateStockJob()

+ 3 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go ファイルの表示

@@ -211,6 +211,9 @@ type PrescriptionVM struct {
211 211
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
212 212
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
213 213
 	MaxUltrafiltrationRate     float64 `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
214
+	OxygenUptake               int64   `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
215
+	OxygenFlow                 string  `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
216
+	OxygenTime                 string  `gorm:"column:oxygen_time" json:"oxygen_time" form:"oxygen_time"`
214 217
 }
215 218
 
216 219
 func (PrescriptionVM) TableName() string {

+ 11 - 3
service/schedule_service.go ファイルの表示

@@ -715,9 +715,17 @@ func FindSchedualTemplateExportLog(org_id int64, export_time int64) (errLogs []*
715 715
 	return
716 716
 }
717 717
 
718
-func GetDialysisOrderByBedId(orgID, start, bed_id int64, schedule_type int64) (schedule models.DialysisOrder, err error) {
719
-	err = readDb.Model(&models.DialysisOrder{}).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).First(&schedule).Error
720
-	return
718
+func GetDialysisOrderByBedId(orgID, start, bed_id int64, schedule_type int64) (*models.DialysisOrder, error) {
719
+	order := models.DialysisOrder{}
720
+	err = readDb.Model(&order).Where("user_org_id=?  and dialysis_date=? and bed_id=? and status=1 AND schedual_type = ?", orgID, start, bed_id, schedule_type).Find(&order).Error
721
+	if err == gorm.ErrRecordNotFound {
722
+		return nil, err
723
+	}
724
+	if err != nil {
725
+		return nil, err
726
+	}
727
+	return &order, nil
728
+
721 729
 }
722 730
 
723 731
 type VMDeviceNumber struct {

+ 11 - 6
service/self_drug_service.go ファイルの表示

@@ -876,10 +876,10 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
876 876
 	return err
877 877
 }
878 878
 
879
-func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.XtDrugDamage, total int64, err error) {
879
+func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
880 880
 	likeKey := "%" + keyword + "%"
881 881
 	offset := (page - 1) * limit
882
-	db := XTReadDB().Table("xt_drug_damage as x").Where("x.status = 1")
882
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and inventory_type = 10")
883 883
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
884 884
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
885 885
 	fmt.Println(table, tab)
@@ -895,10 +895,15 @@ func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword strin
895 895
 	if endtime > 0 {
896 896
 		db = db.Where("x.ctime <=?", endtime)
897 897
 	}
898
-	err = db.Group("x.id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehousing_info_id,x.batch_number,x.stock_max_number,x.stock_min_number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
898
+	err = db.Group("x.drug_id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehouse_info_id,x.batch_number,x.stock_max_number,x.stock_min_number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
899 899
 	return adjust, total, err
900 900
 }
901 901
 
902
+func GetDrugDamageByOrgId(orgid int64) (list []*models.XtDrugInventory, err error) {
903
+	err = XTReadDB().Model(&list).Where("user_org_id = ? and inventory_type = 10 and status = 1", orgid).Find(&list).Error
904
+	return list, err
905
+}
906
+
902 907
 func UpdateDrugDamage(ids []string, damage models.XtDrugDamage) error {
903 908
 
904 909
 	err := XTWriteDB().Model(&damage).Where("id in(?)", ids).Updates(map[string]interface{}{"checker": damage.Checker, "checker_status": damage.CheckerStatus, "checker_time": damage.CheckerTime}).Error
@@ -950,7 +955,7 @@ func GetDrugDamagePrint(ids []string) (damage []*models.XtDrugDamage, err error)
950 955
 
951 956
 func GetWarehoseInfoById(id int64) (info []*models.XtDrugWarehouseInfo, err error) {
952 957
 
953
-	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1", id).Find(&info).Error
958
+	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1", id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
954 959
 	return info, err
955 960
 }
956 961
 
@@ -1077,12 +1082,12 @@ func GetDrugInventoryDetailList(keyword string, page int64, limit int64, orgid i
1077 1082
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
1078 1083
 	fmt.Println(table, tab)
1079 1084
 	if len(keyword) > 0 {
1080
-		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
1085
+		db = db.Where("x.warehousing_order = ? or r.user_name like ? or t.drug_name like ?", keyword, likeKey, likeKey)
1081 1086
 	}
1082 1087
 	if orgid > 0 {
1083 1088
 		db = db.Where("x.user_org_id = ?", orgid)
1084 1089
 	}
1085
-	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1090
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1086 1091
 	return list, total, err
1087 1092
 }
1088 1093
 

+ 14 - 3
service/stock_service.go ファイルの表示

@@ -4201,8 +4201,15 @@ func GetDrugFlow(drugid int64, orgid int64, limit int64, page int64, startTime i
4201 4201
 		if stock_type == 4 {
4202 4202
 			db = db.Where("consumable_type = 4")
4203 4203
 		}
4204
+		if stock_type == 10 {
4205
+			db = db.Where("consumable_type = 10")
4206
+		}
4207
+		if stock_type == 11 {
4208
+			db = db.Where("consumable_type = 11")
4209
+		}
4210
+
4204 4211
 	}
4205
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&drug_flow).Error
4212
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("BaseDrugLib", "status = 1").Preload("DrugWarehouseInfo", "status = 1").Find(&drug_flow).Error
4206 4213
 	return drug_flow, total, err
4207 4214
 }
4208 4215
 
@@ -4282,8 +4289,6 @@ func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
4282 4289
 
4283 4290
 func UpdateDrugWarehouseInfo(info *models.XtDrugWarehouseInfo, id int64) error {
4284 4291
 
4285
-	//err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber}).Error
4286
-	//return err
4287 4292
 	err = writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", info.StockMaxNumber)).Error
4288 4293
 	return err
4289 4294
 }
@@ -4760,3 +4765,9 @@ func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
4760 4765
 	err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
4761 4766
 	return info, err
4762 4767
 }
4768
+
4769
+func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
4770
+
4771
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber}).Error
4772
+	return err
4773
+}