浏览代码

耗材参数

XMLWAN 4 年前
父节点
当前提交
d9a21f417b
共有 2 个文件被更改,包括 30 次插入1 次删除
  1. 16 0
      controllers/stock_in_api_controller.go
  2. 14 1
      service/stock_service.go

+ 16 - 0
controllers/stock_in_api_controller.go 查看文件

64
 
64
 
65
 	beego.Router("/api/warehouseout/user", &StockManagerApiController{}, "get:GetUserDetailInfo")
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
 func (c *StockManagerApiController) CreateWarehouse() {
70
 func (c *StockManagerApiController) CreateWarehouse() {
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 查看文件

1163
 			return db.Where("org_id = ? AND status = 1 and sys_record_time>=? and  sys_record_time<=?", orgId, startime, endtime)
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
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
1167
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
1167
 	db = db.Group("xt_good_information.id")
1168
 	db = db.Group("xt_good_information.id")
1168
 	db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
1169
 	db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
1182
 	if len(keyword) > 0 {
1183
 	if len(keyword) > 0 {
1183
 		likeKey := "%" + keyword + "%"
1184
 		likeKey := "%" + keyword + "%"
1184
 		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.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
 	if type_name > 0 {
1190
 	if type_name > 0 {
2077
 	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
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
 	return
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
+}