瀏覽代碼

仓库管理

mainqaq 3 年之前
父節點
當前提交
8b9d5ba4ce
共有 3 個文件被更改,包括 177 次插入69 次删除
  1. 94 32
      controllers/secondary_order_api_contorller.go
  2. 38 14
      models/secondary_models.go
  3. 45 23
      service/secondary_service.go

+ 94 - 32
controllers/secondary_order_api_contorller.go 查看文件

9
 	"fmt"
9
 	"fmt"
10
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego"
11
 	"github.com/jinzhu/gorm"
11
 	"github.com/jinzhu/gorm"
12
+	"strings"
12
 	"time"
13
 	"time"
13
 )
14
 )
14
 
15
 
34
 	beego.Router("/api/secondary/updatedrugout", &SecondaryOrderApiController{}, "get:UpdateDrugOut")               //更改药品自动出库仓库
35
 	beego.Router("/api/secondary/updatedrugout", &SecondaryOrderApiController{}, "get:UpdateDrugOut")               //更改药品自动出库仓库
35
 	beego.Router("/api/secondary/getusername", &SecondaryOrderApiController{}, "get:GetuserName")                   //获取仓库管理员信息
36
 	beego.Router("/api/secondary/getusername", &SecondaryOrderApiController{}, "get:GetuserName")                   //获取仓库管理员信息
36
 	beego.Router("/api/secondary/byliinit", &SecondaryOrderApiController{}, "get:Byliinit")                         //初始化旧数据
37
 	beego.Router("/api/secondary/byliinit", &SecondaryOrderApiController{}, "get:Byliinit")                         //初始化旧数据
38
+	beego.Router("/api/secondary/ttttt", &SecondaryOrderApiController{}, "get:TTTTT")
37
 
39
 
38
 }
40
 }
39
 
41
 
42
+//ceshi
43
+func (this *SecondaryOrderApiController) TTTTT() {
44
+	orgid := this.GetAdminUserInfo().CurrentOrgId
45
+	err := service.GetDefaultStorehouse(orgid)
46
+	if err != nil {
47
+		utils.ErrorLog("创建默认仓库失败,原因为:", err)
48
+	}
49
+	this.ServeSuccessJSON(map[string]interface{}{
50
+		"list": err,
51
+	})
52
+	return
53
+}
54
+
40
 //获取仓库编码
55
 //获取仓库编码
41
 func (this *SecondaryOrderApiController) GetStoreCode() {
56
 func (this *SecondaryOrderApiController) GetStoreCode() {
42
 	orgId := this.GetAdminUserInfo().CurrentOrgId
57
 	orgId := this.GetAdminUserInfo().CurrentOrgId
58
 //修改仓库状态
73
 //修改仓库状态
59
 func (this *SecondaryOrderApiController) UpdateStatus() {
74
 func (this *SecondaryOrderApiController) UpdateStatus() {
60
 	orgId := this.GetAdminUserInfo().CurrentOrgId
75
 	orgId := this.GetAdminUserInfo().CurrentOrgId
61
-	orgId = 9675
76
+	//orgId = 9675
62
 	check := map[string][]string{
77
 	check := map[string][]string{
63
 		"id": {"must", "int", "id"},
78
 		"id": {"must", "int", "id"},
64
 	}
79
 	}
179
 
194
 
180
 //分页
195
 //分页
181
 func (this *SecondaryOrderApiController) StorehouseList() {
196
 func (this *SecondaryOrderApiController) StorehouseList() {
197
+	adminUserInfo := this.GetAdminUserInfo()
182
 	page, _ := this.GetInt64("page")   //页码
198
 	page, _ := this.GetInt64("page")   //页码
183
 	limit, _ := this.GetInt64("limit") //每一页查出来的条数
199
 	limit, _ := this.GetInt64("limit") //每一页查出来的条数
184
 	check := map[string][]string{
200
 	check := map[string][]string{
191
 	if err != nil {
207
 	if err != nil {
192
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
208
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
193
 	}
209
 	}
210
+	namemap := make(map[int64]string)
211
+	//根据管理员id获取管理员
212
+	viewModels, _, _ := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
213
+	for _, v := range viewModels {
214
+		namemap[int64(v.AdminUserId)] = v.UserName
215
+	}
216
+	slicekey := make([]int64, 0)
217
+	if len(keyword) > 0 {
218
+		for k, v := range namemap {
219
+			res := strings.Contains(v, keyword)
220
+			if res == true {
221
+				slicekey = append(slicekey, k)
222
+			}
223
+		}
224
+	}
194
 	//获取分页的数据
225
 	//获取分页的数据
195
-	list, total, err := service.StorehouseList(page, limit, orgId, keyword)
226
+	list, total, err := service.StorehouseList(page, limit, orgId, keyword, slicekey)
227
+
228
+	//分页
229
+	type Storehouselist struct {
230
+		ID                  int64
231
+		StorehouseCode      string //仓库编号
232
+		StorehouseName      string //仓库名称
233
+		StorehouseAddress   string //仓库地址
234
+		StorehouseStatus    int64  //仓库状态
235
+		Status              int64  //数据状态
236
+		StorehouseAdminId   int64  //仓库管理员id
237
+		StorehouseAdminName string //仓库管理员名字
238
+		UserOrgId           int64
239
+	}
240
+	//初始化该结构体
241
+	tmplist := []*Storehouselist{}
242
+	for i := 0; i < len(list); i++ {
243
+		tlist := &Storehouselist{
244
+			list[i].ID,
245
+			list[i].StorehouseCode,
246
+			list[i].StorehouseName,
247
+			list[i].StorehouseAddress,
248
+			list[i].StorehouseStatus,
249
+			list[i].Status,
250
+			list[i].StorehouseAdminId,
251
+			"",
252
+			list[i].UserOrgId,
253
+		}
254
+		tmplist = append(tmplist, tlist)
255
+	}
256
+	for _, v := range tmplist {
257
+		if k, ok := namemap[v.StorehouseAdminId]; ok {
258
+			v.StorehouseAdminName = k
259
+		} else {
260
+			v.StorehouseAdminName = "超级管理员"
261
+		}
262
+	}
196
 	this.ServeSuccessJSON(map[string]interface{}{
263
 	this.ServeSuccessJSON(map[string]interface{}{
197
-		"list":  list,
264
+		"list":  tmplist,
198
 		"total": total,
265
 		"total": total,
199
 	})
266
 	})
200
 }
267
 }
210
 		return
277
 		return
211
 	}
278
 	}
212
 	var storehouse_status, admin_id int64
279
 	var storehouse_status, admin_id int64
213
-	var admin_name string
214
 	tmpstatus := dataBody["storehouse_status"]
280
 	tmpstatus := dataBody["storehouse_status"]
215
-	tmpid := dataBody["storehouse_admin_id"]
216
-	tmpname := dataBody["storehouse_admin_name"]
281
+	tmpid := dataBody["storehouse_admin_id"] //管理员id
217
 	if tmpstatus == nil {
282
 	if tmpstatus == nil {
218
 		storehouse_status = 1
283
 		storehouse_status = 1
219
 	} else {
284
 	} else {
220
 		storehouse_status = int64(dataBody["storehouse_status"].(float64)) //状态
285
 		storehouse_status = int64(dataBody["storehouse_status"].(float64)) //状态
221
 	}
286
 	}
222
 	if tmpid == nil {
287
 	if tmpid == nil {
223
-		admin_id = 0
288
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "管理员id不能为空")
289
+		return
224
 	} else {
290
 	} else {
225
 		admin_id = int64(dataBody["storehouse_admin_id"].(float64)) //管理员id
291
 		admin_id = int64(dataBody["storehouse_admin_id"].(float64)) //管理员id
226
 	}
292
 	}
227
-	if tmpname == nil {
228
-		admin_name = "admin"
229
-	} else {
230
-		admin_name = dataBody["storehouse_admin_name"].(string) //管理员名称
231
-	}
232
-
233
 	switch {
293
 	switch {
234
 	case dataBody["storehouse_code"] == nil:
294
 	case dataBody["storehouse_code"] == nil:
235
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "仓库编号不能为空")
295
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "仓库编号不能为空")
267
 		return
327
 		return
268
 	}
328
 	}
269
 
329
 
270
-	//storehouse_admin := int64(dataBody["storehouse_admin"].(float64))//仓库管理员,暂时不用管
271
 	storehouse := models.Storehouse{
330
 	storehouse := models.Storehouse{
272
-		StorehouseCode:      code,
273
-		StorehouseName:      name,
274
-		StorehouseAddress:   address,
275
-		StorehouseStatus:    storehouse_status,
276
-		UserOrgId:           orgId,
277
-		Status:              1,
278
-		StorehouseAdminId:   admin_id,
279
-		StorehouseAdminName: admin_name,
280
-		Ctime:               time.Now().Unix(),
331
+		StorehouseCode:    code,
332
+		StorehouseName:    name,
333
+		StorehouseAddress: address,
334
+		StorehouseStatus:  storehouse_status,
335
+		UserOrgId:         orgId,
336
+		Status:            1,
337
+		StorehouseAdminId: admin_id,
338
+		Ctime:             time.Now().Unix(),
281
 	}
339
 	}
282
 	err = service.AddStroehouse(storehouse)
340
 	err = service.AddStroehouse(storehouse)
283
 	if err != nil {
341
 	if err != nil {
293
 //修改仓库
351
 //修改仓库
294
 func (this *SecondaryOrderApiController) UpdateStorehouse() {
352
 func (this *SecondaryOrderApiController) UpdateStorehouse() {
295
 	dataBody := make(map[string]interface{}, 0)
353
 	dataBody := make(map[string]interface{}, 0)
354
+	//orgId := this.GetAdminUserInfo().CurrentOrgId
296
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
355
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
297
 	if err != nil {
356
 	if err != nil {
298
 		utils.ErrorLog(err.Error())
357
 		utils.ErrorLog(err.Error())
299
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
358
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
300
 		return
359
 		return
301
 	}
360
 	}
302
-	var storehouse_status int64
361
+	var storehouse_status, admin_id int64
303
 	tmpstatus := dataBody["storehouse_status"]
362
 	tmpstatus := dataBody["storehouse_status"]
363
+	tmpid := dataBody["storehouse_admin_id"]
304
 	if tmpstatus == nil {
364
 	if tmpstatus == nil {
305
 		storehouse_status = 1
365
 		storehouse_status = 1
306
 	} else {
366
 	} else {
307
 		storehouse_status = int64(dataBody["storehouse_status"].(float64)) //状态
367
 		storehouse_status = int64(dataBody["storehouse_status"].(float64)) //状态
308
 	}
368
 	}
369
+	if tmpid == nil {
370
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "管理员id不能为空")
371
+		return
372
+	} else {
373
+		admin_id = int64(dataBody["storehouse_admin_id"].(float64)) //管理员id
374
+	}
309
 
375
 
310
 	switch {
376
 	switch {
311
 	case dataBody["id"] == nil:
377
 	case dataBody["id"] == nil:
322
 	name := dataBody["storehouse_name"].(string)       //仓库名称
388
 	name := dataBody["storehouse_name"].(string)       //仓库名称
323
 	address := dataBody["storehouse_address"].(string) //地址
389
 	address := dataBody["storehouse_address"].(string) //地址
324
 
390
 
325
-	//storehouse_admin := int64(dataBody["storehouse_admin"].(float64))//仓库管理员,暂时不用管
326
 	storehouse := models.Storehouse{
391
 	storehouse := models.Storehouse{
327
 		ID:                id,
392
 		ID:                id,
328
 		StorehouseName:    name,
393
 		StorehouseName:    name,
329
 		StorehouseAddress: address,
394
 		StorehouseAddress: address,
330
 		StorehouseStatus:  storehouse_status,
395
 		StorehouseStatus:  storehouse_status,
396
+		StorehouseAdminId: admin_id,
331
 		Mtime:             time.Now().Unix(),
397
 		Mtime:             time.Now().Unix(),
332
 	}
398
 	}
333
 	err = service.UpdateStroehouse(storehouse)
399
 	err = service.UpdateStroehouse(storehouse)
555
 
621
 
556
 //查询机构所属管理员
622
 //查询机构所属管理员
557
 func (this *SecondaryOrderApiController) GetuserName() {
623
 func (this *SecondaryOrderApiController) GetuserName() {
558
-	orgId := this.GetAdminUserInfo().CurrentOrgId
559
-	username, err := service.GetuserName(orgId)
560
-	if err != nil {
561
-		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
562
-		return
563
-	}
624
+	adminUserInfo := this.GetAdminUserInfo()
625
+	viewModels, _, _ := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
564
 	this.ServeSuccessJSON(map[string]interface{}{
626
 	this.ServeSuccessJSON(map[string]interface{}{
565
-		"list": username,
627
+		"list": viewModels,
566
 	})
628
 	})
567
 
629
 
568
 }
630
 }

+ 38 - 14
models/secondary_models.go 查看文件

2
 
2
 
3
 //二级仓库
3
 //二级仓库
4
 type Storehouse struct {
4
 type Storehouse struct {
5
-	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
6
-	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`                 //仓库编号
7
-	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`                 //仓库名称
8
-	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`        //仓库地址
9
-	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`           //仓库状态
10
-	Status              int64  `gorm:"column:status" json:"status" form:"status"`                                            //数据状态
11
-	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`     //仓库管理员id
12
-	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_id"` //仓库管理员名字
13
-	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
14
-	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
15
-	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
5
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
6
+	StorehouseCode    string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`             //仓库编号
7
+	StorehouseName    string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`             //仓库名称
8
+	StorehouseAddress string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`    //仓库地址
9
+	StorehouseStatus  int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`       //仓库状态
10
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`                                        //数据状态
11
+	StorehouseAdminId int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"` //仓库管理员id
12
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
13
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
14
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
16
 }
15
 }
17
 
16
 
18
 func (Storehouse) TableName() string {
17
 func (Storehouse) TableName() string {
37
 }
36
 }
38
 
37
 
39
 type App_Role_byli struct {
38
 type App_Role_byli struct {
40
-	Id       int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
41
-	OrgId    int64  `gorm:"column:org_id" json:"org_id"`
42
-	UserName string `gorm:"column:user_name" json:"user_name"` // 用户名称
39
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
40
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
41
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
42
+	UserName    string `gorm:"column:user_name" json:"user_name"` // 用户名称
43
 }
43
 }
44
 
44
 
45
 func (App_Role_byli) TableName() string {
45
 func (App_Role_byli) TableName() string {
46
 	return "sgj_users.sgj_user_admin_role"
46
 	return "sgj_users.sgj_user_admin_role"
47
 }
47
 }
48
+
49
+type UserOrg struct {
50
+	Id      int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
51
+	Creator int64 `gorm:"column:creator" json:"creator"`
52
+}
53
+
54
+func (UserOrg) TableName() string {
55
+	return "sgj_users.sgj_user_org"
56
+}
57
+
58
+//分页
59
+type Storehouselist struct {
60
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
61
+	StorehouseCode      string `gorm:"column:storehouse_code" json:"storehouse_code" form:"storehouse_code"`                 //仓库编号
62
+	StorehouseName      string `gorm:"column:storehouse_name" json:"storehouse_name" form:"storehouse_name"`                 //仓库名称
63
+	StorehouseAddress   string `gorm:"column:storehouse_address" json:"storehouse_address" form:"storehouse_address"`        //仓库地址
64
+	StorehouseStatus    int64  `gorm:"column:storehouse_status" json:"storehouse_status" form:"storehouse_status"`           //仓库状态
65
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`                                            //数据状态
66
+	StorehouseAdminId   int64  `gorm:"column:storehouse_admin_id" json:"storehouse_admin_id" form:"storehouse_admin_id"`     //仓库管理员id
67
+	StorehouseAdminName string `gorm:"column:storehouse_admin_name" json:"storehouse_admin_name" form:"storehouse_admin_id"` //仓库管理员名字
68
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
69
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
70
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
71
+}

+ 45 - 23
service/secondary_service.go 查看文件

6
 	"fmt"
6
 	"fmt"
7
 	"github.com/jinzhu/gorm"
7
 	"github.com/jinzhu/gorm"
8
 	"math/rand"
8
 	"math/rand"
9
+	"strconv"
9
 	"time"
10
 	"time"
10
 )
11
 )
11
 
12
 
118
 func UpdateStroehouse(storehouse models.Storehouse) error {
119
 func UpdateStroehouse(storehouse models.Storehouse) error {
119
 	err := XTWriteDB().Model(&models.Storehouse{}).Where("id = ? and status = 1", storehouse.ID).Updates(
120
 	err := XTWriteDB().Model(&models.Storehouse{}).Where("id = ? and status = 1", storehouse.ID).Updates(
120
 		map[string]interface{}{
121
 		map[string]interface{}{
121
-			"storehouse_name":    storehouse.StorehouseName,
122
-			"storehouse_address": storehouse.StorehouseAddress,
123
-			"storehouse_status":  storehouse.StorehouseStatus,
124
-			"mtime":              storehouse.Mtime,
122
+			"storehouse_name":     storehouse.StorehouseName,
123
+			"storehouse_address":  storehouse.StorehouseAddress,
124
+			"storehouse_status":   storehouse.StorehouseStatus,
125
+			"storehouse_admin_id": storehouse.StorehouseAdminId,
126
+			"mtime":               storehouse.Mtime,
125
 		}).Error
127
 		}).Error
126
 	return err
128
 	return err
127
 }
129
 }
133
 }
135
 }
134
 
136
 
135
 //分页
137
 //分页
136
-func StorehouseList(page, limit, orgid int64, keyword string) (storehouse []models.Storehouse, total int64, err error) {
138
+func StorehouseList(page, limit, orgid int64, keyword string, slicekey []int64) (storehouse []models.Storehouse, total int64, err error) {
137
 	db := XTReadDB().Model(&storehouse).Where("status = 1 and user_org_id = ?", orgid)
139
 	db := XTReadDB().Model(&storehouse).Where("status = 1 and user_org_id = ?", orgid)
138
 	offset := (page - 1) * limit
140
 	offset := (page - 1) * limit
139
 	if len(keyword) > 0 {
141
 	if len(keyword) > 0 {
142
+		var adminid string = "storehouse_code like ? or storehouse_name like ? or storehouse_address like ? "
143
+		if len(slicekey) > 0 {
144
+			for i := 0; i < len(slicekey); i++ {
145
+				adminid = adminid + " or storehouse_admin_id =" + strconv.FormatInt(slicekey[i], 10)
146
+			}
147
+		}
140
 		keyword = "%" + keyword + "%"
148
 		keyword = "%" + keyword + "%"
141
-		db = db.Where("storehouse_code like ? or storehouse_name like ? or storehouse_address like ? or storehouse_admin_name like ?", keyword, keyword, keyword, keyword)
149
+		db = db.Where(adminid, keyword, keyword, keyword)
142
 	}
150
 	}
143
 	err = db.Count(&total).Offset(offset).Order("id").Limit(limit).Find(&storehouse).Error
151
 	err = db.Count(&total).Offset(offset).Order("id").Limit(limit).Find(&storehouse).Error
144
 	return storehouse, total, err
152
 	return storehouse, total, err
161
 			a = false
169
 			a = false
162
 		}
170
 		}
163
 	}
171
 	}
172
+	createid, err := Getcreateid(orgid)
173
+	if err != nil {
174
+		return err
175
+	}
164
 	storehouse := models.Storehouse{
176
 	storehouse := models.Storehouse{
165
-		StorehouseCode:      code,
166
-		StorehouseName:      "默认仓库",
167
-		StorehouseAddress:   "",
168
-		StorehouseStatus:    1,
169
-		UserOrgId:           orgid,
170
-		StorehouseAdminName: "admin",
171
-		Status:              1,
172
-		Ctime:               time.Now().Unix(),
173
-	}
174
-	err := AddStroehouse(storehouse)
177
+		StorehouseCode:    code,
178
+		StorehouseName:    "默认仓库",
179
+		StorehouseAddress: "",
180
+		StorehouseStatus:  1,
181
+		UserOrgId:         orgid,
182
+		StorehouseAdminId: createid.Creator,
183
+		Status:            1,
184
+		Ctime:             time.Now().Unix(),
185
+	}
186
+	err = AddStroehouse(storehouse)
175
 	return err
187
 	return err
176
 }
188
 }
177
 
189
 
293
 			tx.Commit()
305
 			tx.Commit()
294
 		}
306
 		}
295
 	}()
307
 	}()
308
+	err = initsgj_user_admin(tx)
309
+	if err != nil && err.Error() != "record not found" {
310
+		return
311
+	}
296
 	err = StoreReduceOrg(tx)
312
 	err = StoreReduceOrg(tx)
297
 	if err != nil && err.Error() != "record not found" {
313
 	if err != nil && err.Error() != "record not found" {
298
 		return
314
 		return
398
 	return
414
 	return
399
 }
415
 }
400
 
416
 
417
+//初始化管理员名字
418
+func initsgj_user_admin(tx *gorm.DB) (err error) {
419
+	err = tx.Exec("update sgj_users.sgj_user_admin set name = \"超级管理员\" where name is null or name = \"\"").Error
420
+	return
421
+}
422
+
401
 //根据xt_gobal_template 获取的机构id减去仓库表存在的机构id,把结果插入到仓库表
423
 //根据xt_gobal_template 获取的机构id减去仓库表存在的机构id,把结果插入到仓库表
402
 func StoreReduceOrg(tx *gorm.DB) (err error) {
424
 func StoreReduceOrg(tx *gorm.DB) (err error) {
403
 	err = tx.Exec("INSERT INTO sgj_xt.xt_storehouse(storehouse_code,storehouse_name,user_org_id,ctime)" +
425
 	err = tx.Exec("INSERT INTO sgj_xt.xt_storehouse(storehouse_code,storehouse_name,user_org_id,ctime)" +
422
 	return
444
 	return
423
 }
445
 }
424
 
446
 
425
-//初始化 xt_storehouse()把插入管理员的名字
447
+//初始化 xt_storehouse 管理员的名字
426
 func initxt_storehouse(tx *gorm.DB) (err error) {
448
 func initxt_storehouse(tx *gorm.DB) (err error) {
427
 	err = tx.Exec("UPDATE sgj_xt.xt_storehouse as t," +
449
 	err = tx.Exec("UPDATE sgj_xt.xt_storehouse as t," +
428
-		"(SELECT o.id,o.creator,u.name from sgj_users.sgj_user_org as o,sgj_users.sgj_user_admin as u," +
450
+		"(SELECT o.id,o.creator from sgj_users.sgj_user_org as o," +
429
 		"(SELECT DISTINCT org_id from sgj_xt.xt_gobal_template)as t " +
451
 		"(SELECT DISTINCT org_id from sgj_xt.xt_gobal_template)as t " +
430
-		"WHERE o.creator = u.id AND t.org_id = o.id )tmp " +
431
-		"SET t.storehouse_admin_id = tmp.creator,t.storehouse_admin_name = tmp.name,t.mtime = UNIX_TIMESTAMP()" +
452
+		"WHERE t.org_id = o.id )tmp " +
453
+		"SET t.storehouse_admin_id = tmp.creator,t.mtime = UNIX_TIMESTAMP()" +
432
 		"WHERE t.status = 1 and t.user_org_id = tmp.id").Error
454
 		"WHERE t.status = 1 and t.user_org_id = tmp.id").Error
433
 	return
455
 	return
434
 }
456
 }
686
 	return
708
 	return
687
 }
709
 }
688
 
710
 
689
-//查询机构下的所有用户名
690
-func GetuserName(orgid int64) (username []models.App_Role_byli, err error) {
691
-	err = XTReadDB().Select("id,org_id,user_name").Where("org_id = ?", orgid).Find(&username).Error
711
+//查询机构创建者的id
712
+func Getcreateid(orgid int64) (createid models.UserOrg, err error) {
713
+	err = XTReadDB().Select("id,creator").Where("id = ? and status = 1", orgid).Find(&createid).Error
692
 	return
714
 	return
693
 }
715
 }