|
@@ -502,17 +502,20 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
|
502
|
502
|
|
503
|
503
|
likeKey := "%" + keyword + "%"
|
504
|
504
|
|
505
|
|
- if len(keyword) > 0 {
|
506
|
|
- db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ? and t.drug_name like ?", orgid, likeKey)
|
|
505
|
+ if drugcategory > 0 {
|
|
506
|
+ err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_category = ?", drugcategory).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
|
|
507
|
+
|
507
|
508
|
} else {
|
508
|
|
- db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ?", orgid)
|
|
509
|
+ err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ?", orgid).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
|
509
|
510
|
}
|
510
|
|
- if drugcategory > 0 {
|
511
|
|
- db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id and t.status= 1 and t.org_id = ? and t.drug_category = ?", orgid, drugcategory)
|
|
511
|
+
|
|
512
|
+ if len(keyword) > 0 {
|
|
513
|
+ err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ?", likeKey).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
|
|
514
|
+ return
|
|
515
|
+ } else {
|
|
516
|
+ err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ?", orgid).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
|
|
517
|
+ return
|
512
|
518
|
}
|
513
|
|
- //} else {
|
514
|
|
- // db = db.Joins("left join xt_base_drug as t on t.id = x.drug_id")
|
515
|
|
- //}
|
516
|
519
|
|
517
|
520
|
if startime > 0 {
|
518
|
521
|
db = db.Where("x.ctime >=?", startime)
|
|
@@ -525,7 +528,6 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
|
525
|
528
|
db = db.Where("x.org_id = ?", orgid)
|
526
|
529
|
}
|
527
|
530
|
|
528
|
|
- err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehouseing_unit,x.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.price,x.total_price,x.dealer,x.remark,x.org_id,x.is_return,x.warehousing_order,x.type,x.retail_price,x.retail_total_price,x.batch_number,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.manufacturer").Joins("left join xt_base_drug as t on t.id = x.drug_id and t.org_id = ?", orgid).Group("x.drug_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&list).Error
|
529
|
531
|
return list, total, err
|
530
|
532
|
}
|
531
|
533
|
|
|
@@ -585,3 +587,69 @@ func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (dr
|
585
|
587
|
err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ?", drugid, orgid).Offset(offset).Count(&total).Find(&drug).Error
|
586
|
588
|
return drug, total, err
|
587
|
589
|
}
|
|
590
|
+
|
|
591
|
+func GetDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
|
|
592
|
+
|
|
593
|
+ db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
|
|
594
|
+
|
|
595
|
+ if startime > 0 {
|
|
596
|
+ db = db.Where("x.ctime >=?", startime)
|
|
597
|
+ }
|
|
598
|
+ if endtime > 0 {
|
|
599
|
+ db = db.Where("c.time<=?", endtime)
|
|
600
|
+ }
|
|
601
|
+ if orgid > 0 {
|
|
602
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
603
|
+ }
|
|
604
|
+ err = db.Select("sum(x.warehousing_count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
|
|
605
|
+ return info, err
|
|
606
|
+}
|
|
607
|
+
|
|
608
|
+func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
|
|
609
|
+ db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
|
|
610
|
+
|
|
611
|
+ if startime > 0 {
|
|
612
|
+ db = db.Where("x.ctime >=?", startime)
|
|
613
|
+ }
|
|
614
|
+ if endtime > 0 {
|
|
615
|
+ db = db.Where("c.time<=?", endtime)
|
|
616
|
+ }
|
|
617
|
+ if orgid > 0 {
|
|
618
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
619
|
+ }
|
|
620
|
+ err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
|
|
621
|
+ return info, err
|
|
622
|
+}
|
|
623
|
+
|
|
624
|
+func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
|
|
625
|
+ db := XTReadDB().Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
|
|
626
|
+
|
|
627
|
+ if startime > 0 {
|
|
628
|
+ db = db.Where("x.record_time >=?", startime)
|
|
629
|
+ }
|
|
630
|
+ if endtime > 0 {
|
|
631
|
+ db = db.Where("c.record_time<=?", endtime)
|
|
632
|
+ }
|
|
633
|
+ if orgid > 0 {
|
|
634
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
635
|
+ }
|
|
636
|
+ err = db.Select("sum(x.count) as count,x.drug_id").Group("x.drug_id").Scan(&info).Error
|
|
637
|
+ return info, err
|
|
638
|
+
|
|
639
|
+}
|
|
640
|
+
|
|
641
|
+func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
|
|
642
|
+
|
|
643
|
+ db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
|
|
644
|
+ table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
|
|
645
|
+ fmt.Println(table)
|
|
646
|
+ if orgid > 0 {
|
|
647
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
648
|
+ }
|
|
649
|
+ if id > 0 {
|
|
650
|
+ db = db.Where("x.warehouse_out_id = ?", id)
|
|
651
|
+ }
|
|
652
|
+
|
|
653
|
+ err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,t.last_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
|
|
654
|
+ return info, err
|
|
655
|
+}
|