XMLWAN 3 lat temu
rodzic
commit
b5ccd22293

+ 1 - 1
conf/app.conf Wyświetl plik

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 27 - 27
controllers/base_api_controller.go Wyświetl plik

@@ -69,33 +69,33 @@ type BaseAuthAPIController struct {
69 69
 func (this *BaseAuthAPIController) Prepare() {
70 70
 	this.BaseAPIController.Prepare()
71 71
 	if this.GetAdminUserInfo() == nil {
72
-		var userAdmin models.AdminUser
73
-		userAdmin.Id = 1448
74
-		userAdmin.Mobile = "13318599895"
75
-
76
-		//userAdmin.Id = 597
77
-		//userAdmin.Mobile = "19874122664"
78
-		userAdmin.IsSuperAdmin = false
79
-		userAdmin.Status = 1
80
-		userAdmin.CreateTime = 1530786071
81
-		userAdmin.ModifyTime = 1530786071
82
-		var subscibe models.ServeSubscibe
83
-		subscibe.ID = 1
84
-		subscibe.OrgId = 4
85
-		subscibe.PeriodStart = 1538035409
86
-		subscibe.PeriodEnd = 1569571409
87
-		subscibe.State = 1
88
-		subscibe.Status = 1
89
-		subscibe.CreatedTime = 1538035409
90
-		subscibe.UpdatedTime = 1538035409
91
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
-		subscibes[4] = &subscibe
93
-		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 4
95
-		adminUserInfo.CurrentAppId = 4
96
-		adminUserInfo.AdminUser = &userAdmin
97
-		adminUserInfo.Subscibes = subscibes
98
-		this.SetSession("admin_user_info", &adminUserInfo)
72
+		//var userAdmin models.AdminUser
73
+		//userAdmin.Id = 1448
74
+		//userAdmin.Mobile = "13318599895"
75
+		//
76
+		////userAdmin.Id = 597
77
+		////userAdmin.Mobile = "19874122664"
78
+		//userAdmin.IsSuperAdmin = false
79
+		//userAdmin.Status = 1
80
+		//userAdmin.CreateTime = 1530786071
81
+		//userAdmin.ModifyTime = 1530786071
82
+		//var subscibe models.ServeSubscibe
83
+		//subscibe.ID = 1
84
+		//subscibe.OrgId = 4
85
+		//subscibe.PeriodStart = 1538035409
86
+		//subscibe.PeriodEnd = 1569571409
87
+		//subscibe.State = 1
88
+		//subscibe.Status = 1
89
+		//subscibe.CreatedTime = 1538035409
90
+		//subscibe.UpdatedTime = 1538035409
91
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		//subscibes[4] = &subscibe
93
+		//var adminUserInfo service.AdminUserInfo
94
+		//adminUserInfo.CurrentOrgId = 4
95
+		//adminUserInfo.CurrentAppId = 4
96
+		//adminUserInfo.AdminUser = &userAdmin
97
+		//adminUserInfo.Subscibes = subscibes
98
+		//this.SetSession("admin_user_info", &adminUserInfo)
99 99
 
100 100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101 101
 		this.StopRun()

+ 0 - 2
controllers/drug_stock_api_contorller.go Wyświetl plik

@@ -1227,8 +1227,6 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1227 1227
 				remark := items["remark"].(string)
1228 1228
 				max_unit := items["max_unit"].(string)
1229 1229
 
1230
-				fmt.Println("包装单位999999999999", max_unit)
1231
-
1232 1230
 				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1233 1231
 					WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1234 1232
 					WarehouseOutId:          warehouseOut.ID,

+ 60 - 0
controllers/gobal_config_api_controller.go Wyświetl plik

@@ -95,6 +95,9 @@ func GobalConfigRegistRouters() {
95 95
 
96 96
 	beego.Router("/api/drugoutstock/getoutdrugstockflow", &GobalConfigApiController{}, "Get:GetDrugOutStockFlow")
97 97
 	beego.Router("/api/drug/getbatchorderdetail", &GobalConfigApiController{}, "Get:GetBatchOrderDetail")
98
+
99
+	beego.Router("/api/drug/getdrugcountlist", &GobalConfigApiController{}, "Get:GetDrugCountList")
100
+	beego.Router("/api/drug/getsingleorderdetail", &GobalConfigApiController{}, "Get:GetSingleOrderDetail")
98 101
 }
99 102
 
100 103
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1962,3 +1965,60 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
1962 1965
 		"total":  total,
1963 1966
 	})
1964 1967
 }
1968
+
1969
+func (c *GobalConfigApiController) GetDrugCountList() {
1970
+
1971
+	start_time := c.GetString("start_time")
1972
+
1973
+	end_time := c.GetString("end_time")
1974
+
1975
+	timeLayout := "2006-01-02"
1976
+	loc, _ := time.LoadLocation("Local")
1977
+	var startTime int64
1978
+	if len(start_time) > 0 {
1979
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1980
+		if err != nil {
1981
+			fmt.Println(err)
1982
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1983
+			return
1984
+		}
1985
+		startTime = theTime.Unix()
1986
+	}
1987
+	var endTime int64
1988
+	if len(end_time) > 0 {
1989
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1990
+		if err != nil {
1991
+			utils.ErrorLog(err.Error())
1992
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1993
+			return
1994
+		}
1995
+		endTime = theTime.Unix()
1996
+	}
1997
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1998
+	list, err := service.GetDrugCountList(startTime, endTime, orgId)
1999
+	outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2000
+	auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2001
+	if err != nil {
2002
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2003
+		return
2004
+	}
2005
+	c.ServeSuccessJSON(map[string]interface{}{
2006
+		"countList":    list,
2007
+		"outCountList": outCountList,
2008
+		"auCountList":  auCountList,
2009
+	})
2010
+}
2011
+
2012
+func (c *GobalConfigApiController) GetSingleOrderDetail() {
2013
+
2014
+	id, _ := c.GetInt64("id")
2015
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2016
+	list, err := service.GetSingleOrderDetail(id, orgId)
2017
+	if err != nil {
2018
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2019
+		return
2020
+	}
2021
+	c.ServeSuccessJSON(map[string]interface{}{
2022
+		"list": list,
2023
+	})
2024
+}

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Wyświetl plik

@@ -335,7 +335,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
335 335
 
336 336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
337 337
 
338
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 {
338
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 {
339 339
 		dewater_amount = dewater_amount * 1000
340 340
 	}
341 341
 

+ 1 - 0
controllers/patient_api_controller.go Wyświetl plik

@@ -1234,6 +1234,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1234 1234
 		}
1235 1235
 
1236 1236
 		if adviceNameM["template_id"] != nil && reflect.TypeOf(adviceNameM["template_id"]).String() == "string" {
1237
+
1237 1238
 			template_id, _ := adviceNameM["template_id"].(string)
1238 1239
 			advice.TemplateId = template_id
1239 1240
 		}

+ 19 - 0
controllers/stock_in_api_controller.go Wyświetl plik

@@ -87,6 +87,7 @@ func StockManagerApiRegistRouters() {
87 87
 	beego.Router("/api/good/getstockdrugcount", &StockManagerApiController{}, "Get:GetStockDrugCount")
88 88
 
89 89
 	beego.Router("/api/good/getorderdetialbyorderid", &StockManagerApiController{}, "Get:GetOrderDetialByOrderId")
90
+	beego.Router("/api/good/getorderdetaibyid", &StockManagerApiController{}, "Get:GetOrderDetailById")
90 91
 }
91 92
 
92 93
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -3786,3 +3787,21 @@ func (this *StockManagerApiController) GetOrderDetialByOrderId() {
3786 3787
 		"list": list,
3787 3788
 	})
3788 3789
 }
3790
+
3791
+func (this *StockManagerApiController) GetOrderDetailById() {
3792
+
3793
+	good_id, _ := this.GetInt64("good_id")
3794
+	record_time, _ := this.GetInt64("record_time")
3795
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3796
+
3797
+	userDetails, err, total := service.FindUserDetailByIdOne(good_id, record_time, orgId)
3798
+	if err == nil {
3799
+		this.ServeSuccessJSON(map[string]interface{}{
3800
+			"list":  userDetails,
3801
+			"total": total,
3802
+		})
3803
+	} else {
3804
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3805
+		return
3806
+	}
3807
+}

+ 5 - 0
models/drug_stock.go Wyświetl plik

@@ -232,3 +232,8 @@ type VmDrugAutomaticReduceDetail struct {
232 232
 	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
233 233
 	Total                   int64
234 234
 }
235
+
236
+type VmDrugWarehouseInfo struct {
237
+	DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
238
+	Count  int64 `gorm:"column:count" json:"count" form:"count"`
239
+}

+ 34 - 0
models/self_drug_models.go Wyświetl plik

@@ -599,3 +599,37 @@ type StDrugWarehouseInfo struct {
599 599
 	PackingUnit      string  `json:"packing_unit"`
600 600
 	Dosage           int64   `json:"dosage"`
601 601
 }
602
+
603
+type VmDrugWarehouseOutInfo struct {
604
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
605
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
606
+	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
607
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
608
+	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
609
+	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
610
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
611
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
612
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
613
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
614
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
615
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
616
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
617
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
618
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
619
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
620
+	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
621
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
622
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
623
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
624
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
625
+	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
626
+	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
627
+	DrugType                int64   `json:"drug_type"`
628
+	MaxUnit                 string  `json:"max_unit"`
629
+	MinUnit                 string  `json:"min_unit"`
630
+	MinNumber               int64   `json:"min_number"`
631
+	Dose                    float64 `json:"dose"`
632
+	DoseUnit                string  `json:"dose_unit"`
633
+	LastPrice               string  `json:"last_price"`
634
+	DrugName                string  `json:"drug_name"`
635
+}

+ 77 - 9
service/gobal_config_service.go Wyświetl plik

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

+ 12 - 1
service/stock_service.go Wyświetl plik

@@ -2782,7 +2782,7 @@ func GetStockListById(good_id int64, orgid int64, limit int64, page int64, start
2782 2782
 	if good_id > 0 {
2783 2783
 		db = db.Where("x.good_id = ?", good_id)
2784 2784
 	}
2785
-	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.manufacturer,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").Joins("left join xt_good_information as t on t.id = x.good_id").Offset(offset).Count(&total).Scan(&info).Error
2785
+	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.manufacturer,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").Joins("left join xt_good_information as t on t.id = x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&info).Error
2786 2786
 	return info, total, err
2787 2787
 
2788 2788
 }
@@ -2863,3 +2863,14 @@ func GetOrderDetialByOrderId(id int64, orgid int64) (out []*models.WarehouseOutI
2863 2863
 	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
2864 2864
 	return out, err
2865 2865
 }
2866
+
2867
+func FindUserDetailByIdOne(good_id int64, record_time int64, org_id int64) (user []*models.AutomaticReduceDetail, err error, total int64) {
2868
+	db := readDb.Model(&models.AutomaticReduceDetail{})
2869
+	db = db.Preload("GoodInfo", "org_id = ? AND status = 1", org_id)
2870
+	db = db.Preload("GoodsType", "status = 1")
2871
+	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
2872
+	db = db.Where("status = 1 AND org_id = ? AND good_id = ? AND record_time = ? ", org_id, good_id, record_time)
2873
+	db = db.Count(&total)
2874
+	err = db.Find(&user).Error
2875
+	return
2876
+}