|
@@ -2424,6 +2424,11 @@ func DeleteCancelStock(ids []string) (err error) {
|
2424
|
2424
|
ut.Rollback()
|
2425
|
2425
|
return
|
2426
|
2426
|
}
|
|
2427
|
+ err = ut.Model(&models.VmStockFlow{}).Where("cancel_stock_id IN (?)", ids).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
|
|
2428
|
+ if err != nil {
|
|
2429
|
+ ut.Rollback()
|
|
2430
|
+ return
|
|
2431
|
+ }
|
2427
|
2432
|
ut.Commit()
|
2428
|
2433
|
return
|
2429
|
2434
|
}
|
|
@@ -5377,6 +5382,13 @@ func GetCurrentWarehosueInfo(id int64) (info []*models.DrugWarehouseInfo, err er
|
5377
|
5382
|
return info, err
|
5378
|
5383
|
}
|
5379
|
5384
|
|
|
5385
|
+func GetCurrentWarehosueInfoOne(id int64) (models.DrugWarehouseInfo, error) {
|
|
5386
|
+
|
|
5387
|
+ info := models.DrugWarehouseInfo{}
|
|
5388
|
+ err := XTReadDB().Model(&info).Where("id=?", id).Find(&info).Error
|
|
5389
|
+ return info, err
|
|
5390
|
+}
|
|
5391
|
+
|
5380
|
5392
|
func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
|
5381
|
5393
|
|
5382
|
5394
|
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
|
|
@@ -5483,6 +5495,12 @@ func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error
|
5483
|
5495
|
return err
|
5484
|
5496
|
}
|
5485
|
5497
|
|
|
5498
|
+func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
|
|
5499
|
+
|
|
5500
|
+ err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
|
|
5501
|
+ return err
|
|
5502
|
+}
|
|
5503
|
+
|
5486
|
5504
|
func UpdatedStockFlowByGoodIdOne(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
|
5487
|
5505
|
|
5488
|
5506
|
err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count, "number": flow.Number, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate, "Price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "license_number": flow.LicenseNumber}).Error
|
|
@@ -5536,6 +5554,12 @@ func IsExsitStockFlow(goodid int64, cancel_order_number string) (*models.VmStock
|
5536
|
5554
|
return &flow, nil
|
5537
|
5555
|
}
|
5538
|
5556
|
|
|
5557
|
+func UpdateStockFlowTwo(id int64, flow models.VmStockFlow) error {
|
|
5558
|
+
|
|
5559
|
+ err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count}).Error
|
|
5560
|
+ return err
|
|
5561
|
+}
|
|
5562
|
+
|
5539
|
5563
|
func UpdateStockFlowThree(id int64, flow models.VmStockFlow) error {
|
5540
|
5564
|
|
5541
|
5565
|
err := XTWriteDB().Model(&flow).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": flow.Count, "manufacturer": flow.Count, "dealer": flow.Dealer, "number": flow.Number, "license_number": flow.LicenseNumber, "price": flow.Price, "product_date": flow.ProductDate, "expire_date": flow.ExpireDate}).Error
|
|
@@ -5569,6 +5593,33 @@ func ModifyDrugWarehouseOutInfoOne(info models.DrugWarehouseOutInfo, drugid int6
|
5569
|
5593
|
return err
|
5570
|
5594
|
}
|
5571
|
5595
|
|
|
5596
|
+func GetDrugWarehouseOutInfoByWarehosueId(drugid int64, patientid int64, recorddate int64, warehosueinfoid int64) (*models.DrugWarehouseOutInfo, error) {
|
|
5597
|
+ info := models.DrugWarehouseOutInfo{}
|
|
5598
|
+ err := XTReadDB().Model(&info).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and warehouse_info_id = ? and status = 1", drugid, patientid, recorddate, warehosueinfoid).Find(&info).Error
|
|
5599
|
+ if err == gorm.ErrRecordNotFound {
|
|
5600
|
+ return nil, err
|
|
5601
|
+ }
|
|
5602
|
+ if err != nil {
|
|
5603
|
+ return nil, err
|
|
5604
|
+ }
|
|
5605
|
+ return &info, nil
|
|
5606
|
+}
|
|
5607
|
+
|
|
5608
|
+func GetDrugFlowRecord(warehouse_out_order_number string, drugid int64, patientid int64) (*models.DrugFlow, error) {
|
|
5609
|
+
|
|
5610
|
+ drugFlow := models.DrugFlow{}
|
|
5611
|
+
|
|
5612
|
+ err := XTReadDB().Where("warehouse_out_order_number = ? and drug_id =? and patient_id = ? and status = 1", warehouse_out_order_number, drugid, patientid).Find(&drugFlow).Error
|
|
5613
|
+
|
|
5614
|
+ if err == gorm.ErrRecordNotFound {
|
|
5615
|
+ return nil, err
|
|
5616
|
+ }
|
|
5617
|
+ if err != nil {
|
|
5618
|
+ return nil, err
|
|
5619
|
+ }
|
|
5620
|
+ return &drugFlow, nil
|
|
5621
|
+}
|
|
5622
|
+
|
5572
|
5623
|
func ModifyDrugFlow(flow models.DrugFlow, warehouse_out_order_number string, drugid int64, patient_id int64) error {
|
5573
|
5624
|
|
5574
|
5625
|
err := XTWriteDB().Model(&flow).Where("warehouse_out_order_number = ? and drug_id = ? and patient_id = ? and status = 1", warehouse_out_order_number, drugid, patient_id).Updates(map[string]interface{}{"count": flow.Count, "max_unit": flow.MaxUnit}).Error
|
|
@@ -5581,6 +5632,28 @@ func ModifyDrugFlowOne(flow models.DrugFlow, warehouse_out_order_number string,
|
5581
|
5632
|
return err
|
5582
|
5633
|
}
|
5583
|
5634
|
|
|
5635
|
+func GetDrugAutoReduceRecordOne(drugid int64, patientid int64, recorddate int64) (detail []*models.DrugAutomaticReduceDetail, err error) {
|
|
5636
|
+
|
|
5637
|
+ err = XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
|
|
5638
|
+
|
|
5639
|
+ return detail, err
|
|
5640
|
+}
|
|
5641
|
+
|
|
5642
|
+func GetDrugAutoReduceRecord(drugid int64, patientid int64, recorddate int64) (*models.DrugAutomaticReduceDetail, error) {
|
|
5643
|
+
|
|
5644
|
+ detail := models.DrugAutomaticReduceDetail{}
|
|
5645
|
+
|
|
5646
|
+ err := XTReadDB().Model(&detail).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1", drugid, patientid, recorddate).Find(&detail).Error
|
|
5647
|
+
|
|
5648
|
+ if err == gorm.ErrRecordNotFound {
|
|
5649
|
+ return nil, err
|
|
5650
|
+ }
|
|
5651
|
+ if err != nil {
|
|
5652
|
+ return nil, err
|
|
5653
|
+ }
|
|
5654
|
+ return &detail, nil
|
|
5655
|
+}
|
|
5656
|
+
|
5584
|
5657
|
func ModifyAutoMaticReduce(auto models.DrugAutomaticReduceDetail, patientid int64, recordate int64, drugid int64) error {
|
5585
|
5658
|
|
5586
|
5659
|
err := XTWriteDB().Model(&auto).Where("patient_id = ? and record_time = ? and drug_id = ? and status = 1", patientid, recordate, drugid).Updates(map[string]interface{}{"count": auto.Count, "count_unit": auto.CountUnit}).Error
|