|
@@ -2759,7 +2759,7 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
|
2759
|
2759
|
if good_type > 0 {
|
2760
|
2760
|
db = db.Where("t.good_type_id = ?", good_type)
|
2761
|
2761
|
}
|
2762
|
|
- err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.manufacturer").Joins("left join xt_good_information as t on t.id = x.good_id").Offset(offset).Count(&total).Group("x.good_id").Scan(&info).Error
|
|
2762
|
+ err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.warehousing_unit,x.stock_count,x.price,x.total_price,x.dealer,x.remark,x.ctime,x.is_return,x.warehousing_order,x.type,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.min_unit,t.manufacturer").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Scan(&info).Error
|
2763
|
2763
|
return info, total, err
|
2764
|
2764
|
}
|
2765
|
2765
|
|
|
@@ -2807,3 +2807,44 @@ func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, starti
|
2807
|
2807
|
err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id").Offset(offset).Count(&total).Scan(&info).Error
|
2808
|
2808
|
return info, total, err
|
2809
|
2809
|
}
|
|
2810
|
+
|
|
2811
|
+func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
|
|
2812
|
+
|
|
2813
|
+ db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
|
|
2814
|
+ if startime > 0 {
|
|
2815
|
+ db = db.Where("x.ctime >=?", startime)
|
|
2816
|
+ }
|
|
2817
|
+ if endtime > 0 {
|
|
2818
|
+ db = db.Where("x.ctime<=?", endtime)
|
|
2819
|
+ }
|
|
2820
|
+ if orgid > 0 {
|
|
2821
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
2822
|
+ }
|
|
2823
|
+
|
|
2824
|
+ err = db.Select("sum(x.warehousing_count) as count,x.good_id").Group("x.good_id").Scan(&info).Error
|
|
2825
|
+ return info, err
|
|
2826
|
+}
|
|
2827
|
+
|
|
2828
|
+func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
|
|
2829
|
+ db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
|
|
2830
|
+ if startime > 0 {
|
|
2831
|
+ db = db.Where("x.ctime >=?", startime)
|
|
2832
|
+ }
|
|
2833
|
+ if endtime > 0 {
|
|
2834
|
+ db = db.Where("x.ctime<=?", endtime)
|
|
2835
|
+ }
|
|
2836
|
+ if orgid > 0 {
|
|
2837
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
2838
|
+ }
|
|
2839
|
+
|
|
2840
|
+ err = db.Select("sum(x.count) as count,x.good_id").Where("is_sys = 0").Group("x.good_id").Scan(&info).Error
|
|
2841
|
+ return info, err
|
|
2842
|
+}
|
|
2843
|
+
|
|
2844
|
+func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
|
|
2845
|
+
|
|
2846
|
+ err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=? and x.record_time<=? and `status` = 1) as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
|
|
2847
|
+
|
|
2848
|
+ return autoMatic, err
|
|
2849
|
+
|
|
2850
|
+}
|