Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
3461399c16

+ 179 - 0
controllers/self_drug_api_congtroller.go View File

@@ -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
+}

+ 1 - 1
main.go View File

@@ -16,7 +16,7 @@ func main() {
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()
18 18
 	//service.BeginAutoCreateStaffScheduleJob()
19
-	//service.BeginAutoCreateDrugJob()
19
+	service.BeginAutoCreateDrugJob()
20 20
 	service.BeginAutoCreateStockJob()
21 21
 	beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60
22 22
 	beego.Run()

+ 4 - 0
models/drug_stock.go View File

@@ -359,6 +359,10 @@ type DrugFlow struct {
359 359
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
360 360
 	MaxUnit                 string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
361 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"`
362 366
 }
363 367
 
364 368
 func (DrugFlow) TableName() string {

+ 37 - 35
models/self_drug_models.go View File

@@ -768,41 +768,43 @@ 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"`
806 808
 }
807 809
 
808 810
 func (XtDrugInventory) TableName() string {

+ 18 - 3
service/auto_create_drug.go View File

@@ -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
+}

+ 3 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -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 {

+ 1 - 1
service/self_drug_service.go View File

@@ -950,7 +950,7 @@ func GetDrugDamagePrint(ids []string) (damage []*models.XtDrugDamage, err error)
950 950
 
951 951
 func GetWarehoseInfoById(id int64) (info []*models.XtDrugWarehouseInfo, err error) {
952 952
 
953
-	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1", id).Find(&info).Error
953
+	err = XTReadDB().Model(&info).Where("drug_id=? and status = 1", id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
954 954
 	return info, err
955 955
 }
956 956
 

+ 6 - 2
service/stock_service.go View File

@@ -4282,8 +4282,6 @@ func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
4282 4282
 
4283 4283
 func UpdateDrugWarehouseInfo(info *models.XtDrugWarehouseInfo, id int64) error {
4284 4284
 
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 4285
 	err = writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", info.StockMaxNumber)).Error
4288 4286
 	return err
4289 4287
 }
@@ -4760,3 +4758,9 @@ func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
4760 4758
 	err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
4761 4759
 	return info, err
4762 4760
 }
4761
+
4762
+func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
4763
+
4764
+	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
4765
+	return err
4766
+}