Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
ab276a96c7

+ 1 - 1
conf/app.conf View File

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

+ 3 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -3371,6 +3371,7 @@ func (c *DialysisAPIController) CreateConsumables() {
3371 3371
 			list, _ := service.GetAutoReduceRecordInfoByPatientId(adminUser.Org.Id, patient_id, record_time)
3372 3372
 			fmt.Println("1111111111111111111111111111111111111111111", list)
3373 3373
 			if len(list) == 0 {
3374
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3374 3375
 				return
3375 3376
 			}
3376 3377
 
@@ -3629,6 +3630,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
3629 3630
 
3630 3631
 				list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
3631 3632
 				if len(list) == 0 {
3633
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3632 3634
 					return
3633 3635
 				}
3634 3636
 				for _, item := range list {
@@ -3651,13 +3653,12 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
3651 3653
 			//
3652 3654
 		} else if err == nil {
3653 3655
 			for _, item := range consumables {
3654
-
3655
-				fmt.Println("hhhhhhhhhh7777777777777", item.GoodId)
3656 3656
 				//出库
3657 3657
 				service.ConsumablesDelivery(item.UserOrgId, patient_id, record_time, item, &out, item.Count)
3658 3658
 
3659 3659
 				list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
3660 3660
 				if len(list) == 0 {
3661
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3661 3662
 					return
3662 3663
 				}
3663 3664
 				for _, item := range list {

+ 79 - 0
controllers/stock_in_api_controller.go View File

@@ -80,6 +80,9 @@ func StockManagerApiRegistRouters() {
80 80
 	beego.Router("/api/good/postsearchgoodlist", &StockManagerApiController{}, "Get:PostSearchGoodList")
81 81
 
82 82
 	beego.Router("/api/good/getallstocklist", &StockManagerApiController{}, "Get:GetAllStockList")
83
+
84
+	beego.Router("/api/stock/getstocklistbyid", &StockManagerApiController{}, "Get:GetStockListById")
85
+	beego.Router("/api/stock/getstockoutlist", &StockManagerApiController{}, "Get:GetStockOutList")
83 86
 }
84 87
 
85 88
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -3652,3 +3655,79 @@ func (this *StockManagerApiController) GetAllStockList() {
3652 3655
 		"manufacturerList": manufacturerList,
3653 3656
 	})
3654 3657
 }
3658
+
3659
+func (this *StockManagerApiController) GetStockListById() {
3660
+
3661
+	id, _ := this.GetInt64("id")
3662
+	adminUserInfo := this.GetAdminUserInfo()
3663
+	orgId := adminUserInfo.CurrentOrgId
3664
+	limit, _ := this.GetInt64("limit")
3665
+	page, _ := this.GetInt64("page")
3666
+	timeLayout := "2006-01-02"
3667
+	loc, _ := time.LoadLocation("Local")
3668
+	start_time := this.GetString("start_time")
3669
+	end_time := this.GetString("end_time")
3670
+	var startTime int64
3671
+	if len(start_time) > 0 {
3672
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3673
+		if err != nil {
3674
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3675
+			return
3676
+		}
3677
+		startTime = theTime.Unix()
3678
+	}
3679
+	var endTime int64
3680
+	if len(end_time) > 0 {
3681
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3682
+		if err != nil {
3683
+			utils.ErrorLog(err.Error())
3684
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3685
+			return
3686
+		}
3687
+		endTime = theTime.Unix()
3688
+	}
3689
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3690
+	list, total, _ := service.GetStockListById(id, orgId, limit, page, startTime, endTime)
3691
+	this.ServeSuccessJSON(map[string]interface{}{
3692
+		"list":             list,
3693
+		"total":            total,
3694
+		"manufacturerList": manufacturerList,
3695
+	})
3696
+}
3697
+
3698
+func (this *StockManagerApiController) GetStockOutList() {
3699
+
3700
+	id, _ := this.GetInt64("id")
3701
+	adminUserInfo := this.GetAdminUserInfo()
3702
+	orgId := adminUserInfo.CurrentOrgId
3703
+	limit, _ := this.GetInt64("limit")
3704
+	page, _ := this.GetInt64("page")
3705
+	timeLayout := "2006-01-02"
3706
+	loc, _ := time.LoadLocation("Local")
3707
+	start_time := this.GetString("start_time")
3708
+	end_time := this.GetString("end_time")
3709
+	var startTime int64
3710
+	if len(start_time) > 0 {
3711
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3712
+		if err != nil {
3713
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3714
+			return
3715
+		}
3716
+		startTime = theTime.Unix()
3717
+	}
3718
+	var endTime int64
3719
+	if len(end_time) > 0 {
3720
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
3721
+		if err != nil {
3722
+			utils.ErrorLog(err.Error())
3723
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3724
+			return
3725
+		}
3726
+		endTime = theTime.Unix()
3727
+	}
3728
+	outList, total, _ := service.GetStockOutList(id, orgId, limit, page, startTime, endTime)
3729
+	this.ServeSuccessJSON(map[string]interface{}{
3730
+		"outList": outList,
3731
+		"total":   total,
3732
+	})
3733
+}

+ 45 - 0
service/stock_service.go View File

@@ -2761,3 +2761,48 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
2761 2761
 	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).Group("x.good_id").Scan(&info).Error
2762 2762
 	return info, total, err
2763 2763
 }
2764
+
2765
+func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
2766
+
2767
+	offset := (page - 1) * limit
2768
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1")
2769
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
2770
+	fmt.Println(table)
2771
+	if startime > 0 {
2772
+		db = db.Where("x.ctime>=?", startime)
2773
+	}
2774
+	if endtime > 0 {
2775
+		db = db.Where("x.ctime<=?", endtime)
2776
+	}
2777
+
2778
+	if orgid > 0 {
2779
+		db = db.Where("x.org_id = ?", orgid)
2780
+	}
2781
+	if good_id > 0 {
2782
+		db = db.Where("x.good_id = ?", good_id)
2783
+	}
2784
+	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
+	return info, total, err
2786
+
2787
+}
2788
+
2789
+func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.WarehouseOutInfo, total int64, err error) {
2790
+	offset := (page - 1) * limit
2791
+
2792
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status= 1")
2793
+	if startime > 0 {
2794
+		db = db.Where("x.ctime>=?", startime)
2795
+	}
2796
+	if endtime > 0 {
2797
+		db = db.Where("x.ctime<=?", endtime)
2798
+	}
2799
+
2800
+	if orgid > 0 {
2801
+		db = db.Where("x.org_id = ?", orgid)
2802
+	}
2803
+	if good_id > 0 {
2804
+		db = db.Where("x.good_id = ?", good_id)
2805
+	}
2806
+	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
2807
+	return info, total, err
2808
+}