Browse Source

耗材参数

XMLWAN 4 years ago
parent
commit
d9a21f417b
2 changed files with 30 additions and 1 deletions
  1. 16 0
      controllers/stock_in_api_controller.go
  2. 14 1
      service/stock_service.go

+ 16 - 0
controllers/stock_in_api_controller.go View File

@@ -64,6 +64,7 @@ func StockManagerApiRegistRouters() {
64 64
 
65 65
 	beego.Router("/api/warehouseout/user", &StockManagerApiController{}, "get:GetUserDetailInfo")
66 66
 
67
+	beego.Router("/api/warehouseout/postsearchstock", &StockManagerApiController{}, "Get:PostSearchStock")
67 68
 }
68 69
 
69 70
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -1960,3 +1961,18 @@ func (this *StockManagerApiController) GetUserDetailInfo() {
1960 1961
 	}
1961 1962
 
1962 1963
 }
1964
+
1965
+func (this *StockManagerApiController) PostSearchStock() {
1966
+
1967
+	keyword := this.GetString("keyword")
1968
+	fmt.Println("keyword2222222222222", keyword)
1969
+	adminUserInfo := this.GetAdminUserInfo()
1970
+	orgId := adminUserInfo.CurrentOrgId
1971
+	stock, err := service.PostSearchStock(keyword, orgId)
1972
+	if err != nil {
1973
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteFail)
1974
+	}
1975
+	this.ServeSuccessJSON(map[string]interface{}{
1976
+		"stock": stock,
1977
+	})
1978
+}

+ 14 - 1
service/stock_service.go View File

@@ -1163,6 +1163,7 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, star
1163 1163
 			return db.Where("org_id = ? AND status = 1 and sys_record_time>=? and  sys_record_time<=?", orgId, startime, endtime)
1164 1164
 		})
1165 1165
 	}
1166
+
1166 1167
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
1167 1168
 	db = db.Group("xt_good_information.id")
1168 1169
 	db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
@@ -1182,7 +1183,8 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, star
1182 1183
 	if len(keyword) > 0 {
1183 1184
 		likeKey := "%" + keyword + "%"
1184 1185
 		db = db.Joins("join xt_goods_type on xt_goods_type.id = xt_good_information.good_type_id  AND xt_goods_type.org_id = ? AND xt_goods_type.status = 1", orgId)
1185
-		db = db.Where("xt_good_information.good_code LIKE ? OR xt_good_information.specification_name LIKE ? OR xt_goods_type.type_name LIKE ?", likeKey, likeKey, likeKey).Group("xt_good_information.id")
1186
+		db = db.Where("xt_good_information.good_code LIKE ? OR xt_good_information.specification_name LIKE ? OR xt_good_information.good_name LIKE ? OR xt_goods_type.type_name LIKE ?", likeKey, likeKey, likeKey, likeKey).Group("xt_good_information.id")
1187
+
1186 1188
 	}
1187 1189
 
1188 1190
 	if type_name > 0 {
@@ -2077,3 +2079,14 @@ func GetAllStockOutUserDetail(patient_id int64, orgId int64, record_time int64)
2077 2079
 	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND record_date = ? AND status = 1", patient_id, orgId, record_time).Find(&goodUser).Error
2078 2080
 	return
2079 2081
 }
2082
+
2083
+func PostSearchStock(keyword string, orgid int64) (goods []*models.GoodsType, err error) {
2084
+
2085
+	likeKey := "%" + keyword + "%"
2086
+	db := XTReadDB().Model(&goods)
2087
+	if len(keyword) > 0 {
2088
+		db = db.Where("type_name like ?", likeKey)
2089
+	}
2090
+	err = db.Where("org_id = ? and status =1", orgid).Find(&goods).Error
2091
+	return goods, err
2092
+}