|
@@ -9,6 +9,7 @@ import (
|
9
|
9
|
"fmt"
|
10
|
10
|
"github.com/astaxie/beego"
|
11
|
11
|
"github.com/jinzhu/gorm"
|
|
12
|
+ "strings"
|
12
|
13
|
"time"
|
13
|
14
|
)
|
14
|
15
|
|
|
@@ -34,9 +35,23 @@ func SecondaryOrderApiRegistRouters() {
|
34
|
35
|
beego.Router("/api/secondary/updatedrugout", &SecondaryOrderApiController{}, "get:UpdateDrugOut") //更改药品自动出库仓库
|
35
|
36
|
beego.Router("/api/secondary/getusername", &SecondaryOrderApiController{}, "get:GetuserName") //获取仓库管理员信息
|
36
|
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
|
56
|
func (this *SecondaryOrderApiController) GetStoreCode() {
|
42
|
57
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
@@ -58,7 +73,7 @@ func (this *SecondaryOrderApiController) GetStoreCode() {
|
58
|
73
|
//修改仓库状态
|
59
|
74
|
func (this *SecondaryOrderApiController) UpdateStatus() {
|
60
|
75
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
61
|
|
- orgId = 9675
|
|
76
|
+ //orgId = 9675
|
62
|
77
|
check := map[string][]string{
|
63
|
78
|
"id": {"must", "int", "id"},
|
64
|
79
|
}
|
|
@@ -179,6 +194,7 @@ func (this *SecondaryOrderApiController) IsStorehouseAddress() {
|
179
|
194
|
|
180
|
195
|
//分页
|
181
|
196
|
func (this *SecondaryOrderApiController) StorehouseList() {
|
|
197
|
+ adminUserInfo := this.GetAdminUserInfo()
|
182
|
198
|
page, _ := this.GetInt64("page") //页码
|
183
|
199
|
limit, _ := this.GetInt64("limit") //每一页查出来的条数
|
184
|
200
|
check := map[string][]string{
|
|
@@ -191,10 +207,61 @@ func (this *SecondaryOrderApiController) StorehouseList() {
|
191
|
207
|
if err != nil {
|
192
|
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
|
263
|
this.ServeSuccessJSON(map[string]interface{}{
|
197
|
|
- "list": list,
|
|
264
|
+ "list": tmplist,
|
198
|
265
|
"total": total,
|
199
|
266
|
})
|
200
|
267
|
}
|
|
@@ -210,26 +277,19 @@ func (this *SecondaryOrderApiController) AddStorehouse() {
|
210
|
277
|
return
|
211
|
278
|
}
|
212
|
279
|
var storehouse_status, admin_id int64
|
213
|
|
- var admin_name string
|
214
|
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
|
282
|
if tmpstatus == nil {
|
218
|
283
|
storehouse_status = 1
|
219
|
284
|
} else {
|
220
|
285
|
storehouse_status = int64(dataBody["storehouse_status"].(float64)) //状态
|
221
|
286
|
}
|
222
|
287
|
if tmpid == nil {
|
223
|
|
- admin_id = 0
|
|
288
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "管理员id不能为空")
|
|
289
|
+ return
|
224
|
290
|
} else {
|
225
|
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
|
293
|
switch {
|
234
|
294
|
case dataBody["storehouse_code"] == nil:
|
235
|
295
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "仓库编号不能为空")
|
|
@@ -267,17 +327,15 @@ func (this *SecondaryOrderApiController) AddStorehouse() {
|
267
|
327
|
return
|
268
|
328
|
}
|
269
|
329
|
|
270
|
|
- //storehouse_admin := int64(dataBody["storehouse_admin"].(float64))//仓库管理员,暂时不用管
|
271
|
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
|
340
|
err = service.AddStroehouse(storehouse)
|
283
|
341
|
if err != nil {
|
|
@@ -293,19 +351,27 @@ func (this *SecondaryOrderApiController) AddStorehouse() {
|
293
|
351
|
//修改仓库
|
294
|
352
|
func (this *SecondaryOrderApiController) UpdateStorehouse() {
|
295
|
353
|
dataBody := make(map[string]interface{}, 0)
|
|
354
|
+ //orgId := this.GetAdminUserInfo().CurrentOrgId
|
296
|
355
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
297
|
356
|
if err != nil {
|
298
|
357
|
utils.ErrorLog(err.Error())
|
299
|
358
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
300
|
359
|
return
|
301
|
360
|
}
|
302
|
|
- var storehouse_status int64
|
|
361
|
+ var storehouse_status, admin_id int64
|
303
|
362
|
tmpstatus := dataBody["storehouse_status"]
|
|
363
|
+ tmpid := dataBody["storehouse_admin_id"]
|
304
|
364
|
if tmpstatus == nil {
|
305
|
365
|
storehouse_status = 1
|
306
|
366
|
} else {
|
307
|
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
|
376
|
switch {
|
311
|
377
|
case dataBody["id"] == nil:
|
|
@@ -322,12 +388,12 @@ func (this *SecondaryOrderApiController) UpdateStorehouse() {
|
322
|
388
|
name := dataBody["storehouse_name"].(string) //仓库名称
|
323
|
389
|
address := dataBody["storehouse_address"].(string) //地址
|
324
|
390
|
|
325
|
|
- //storehouse_admin := int64(dataBody["storehouse_admin"].(float64))//仓库管理员,暂时不用管
|
326
|
391
|
storehouse := models.Storehouse{
|
327
|
392
|
ID: id,
|
328
|
393
|
StorehouseName: name,
|
329
|
394
|
StorehouseAddress: address,
|
330
|
395
|
StorehouseStatus: storehouse_status,
|
|
396
|
+ StorehouseAdminId: admin_id,
|
331
|
397
|
Mtime: time.Now().Unix(),
|
332
|
398
|
}
|
333
|
399
|
err = service.UpdateStroehouse(storehouse)
|
|
@@ -555,14 +621,10 @@ func (this *SecondaryOrderApiController) Byliinit() {
|
555
|
621
|
|
556
|
622
|
//查询机构所属管理员
|
557
|
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
|
626
|
this.ServeSuccessJSON(map[string]interface{}{
|
565
|
|
- "list": username,
|
|
627
|
+ "list": viewModels,
|
566
|
628
|
})
|
567
|
629
|
|
568
|
630
|
}
|