|
@@ -3244,6 +3244,7 @@ func (this *DialysisAPIController) GetLastOrNextDoctorAdvice() {
|
3244
|
3244
|
func (c *DialysisAPIController) CreateConsumables() {
|
3245
|
3245
|
record_date := c.GetString("record_time")
|
3246
|
3246
|
patient_id, _ := c.GetInt64("patient_id", 0)
|
|
3247
|
+ active, _ := c.GetInt64("active")
|
3247
|
3248
|
adminUser := c.GetMobileAdminUserInfo()
|
3248
|
3249
|
|
3249
|
3250
|
timeLayout := "2006-01-02"
|
|
@@ -3261,7 +3262,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3261
|
3262
|
|
3262
|
3263
|
var beforePrepares []*models.DialysisBeforePrepareGoods
|
3263
|
3264
|
var newBeforePrepares []*models.NewDialysisBeforePrepareGoods
|
3264
|
|
-
|
|
3265
|
+ var dialysisBefor []*models.DialysisBeforePrepare
|
3265
|
3266
|
if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
|
3266
|
3267
|
goods, _ := dataBody["goods"].([]interface{})
|
3267
|
3268
|
|
|
@@ -3308,48 +3309,98 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3308
|
3309
|
}
|
3309
|
3310
|
|
3310
|
3311
|
newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
|
3311
|
|
- }
|
3312
|
3312
|
|
|
3313
|
+ prepare := &models.DialysisBeforePrepare{
|
|
3314
|
+ GoodTypeId: good_type_id,
|
|
3315
|
+ GoodId: good_id,
|
|
3316
|
+ Count: count,
|
|
3317
|
+ PatientId: patient_id,
|
|
3318
|
+ RecordDate: record_time,
|
|
3319
|
+ UserOrgId: adminUser.Org.Id,
|
|
3320
|
+ Status: 1,
|
|
3321
|
+ Ctime: time.Now().Unix(),
|
|
3322
|
+ Creater: adminUser.AdminUser.Id,
|
|
3323
|
+ CommdityCode: commdity_code,
|
|
3324
|
+ }
|
|
3325
|
+
|
|
3326
|
+ dialysisBefor = append(dialysisBefor, prepare)
|
|
3327
|
+
|
|
3328
|
+ }
|
3313
|
3329
|
}
|
3314
|
|
- }
|
3315
|
|
- fmt.Println("8888888888888888888888", beforePrepares)
|
3316
|
|
- if len(beforePrepares) > 0 {
|
3317
|
3330
|
|
3318
|
|
- //出库
|
3319
|
|
- err = service.ConsumablesDeliveryTotal(adminUser.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares)
|
3320
|
|
- fmt.Println("err", err)
|
|
3331
|
+ fmt.Println("dialysisBefor9999999999999999999", dialysisBefor)
|
|
3332
|
+ //新增
|
|
3333
|
+ if active == 1 && len(goods) > 0 {
|
|
3334
|
+ for _, item := range dialysisBefor {
|
|
3335
|
+ dialyPrepareOne := models.DialysisBeforePrepare{
|
|
3336
|
+ GoodTypeId: item.GoodTypeId,
|
|
3337
|
+ GoodId: item.GoodId,
|
|
3338
|
+ PatientId: item.PatientId,
|
|
3339
|
+ RecordDate: item.RecordDate,
|
|
3340
|
+ UserOrgId: item.UserOrgId,
|
|
3341
|
+ Count: item.Count,
|
|
3342
|
+ Ctime: time.Now().Unix(),
|
|
3343
|
+ Creater: item.Creater,
|
|
3344
|
+ CommdityCode: item.CommdityCode,
|
|
3345
|
+ Status: 1,
|
|
3346
|
+ }
|
|
3347
|
+ //先清除再插入
|
|
3348
|
+ service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
|
3349
|
+ err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
|
3321
|
3350
|
|
3322
|
|
- //查询今日出库数据
|
3323
|
|
- list, _ := service.GetAutoReduceRecordInfoByPatientId(adminUser.Org.Id, patient_id, record_time)
|
3324
|
|
- fmt.Println("1111111111111111111111111111111111111111111", list)
|
3325
|
|
- if len(list) == 0 {
|
3326
|
|
- return
|
|
3351
|
+ }
|
|
3352
|
+ if err == nil {
|
|
3353
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3354
|
+ "msg": "保存成功",
|
|
3355
|
+ })
|
|
3356
|
+ return
|
|
3357
|
+
|
|
3358
|
+ } else {
|
|
3359
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
3360
|
+ return
|
|
3361
|
+ }
|
3327
|
3362
|
}
|
3328
|
3363
|
|
3329
|
|
- //for _, item := range list {
|
3330
|
|
- // prepare := models.DialysisBeforePrepare{
|
3331
|
|
- // UserOrgId: item.OrgId,
|
3332
|
|
- // PatientId: patient_id,
|
3333
|
|
- // RecordDate: item.RecordTime,
|
3334
|
|
- // GoodId: item.GoodId,
|
3335
|
|
- // GoodTypeId: item.GoodTypeId,
|
3336
|
|
- // Count: item.Count,
|
3337
|
|
- // Ctime: time.Now().Unix(),
|
3338
|
|
- // Creater: adminUser.AdminUser.Id,
|
3339
|
|
- // Status: 1,
|
3340
|
|
- // }
|
3341
|
|
- // //删除准备表数据
|
3342
|
|
- // service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time,item.GoodId,item.GoodTypeId)
|
3343
|
|
- // service.CreateDialysisBeforePrepareOne(&prepare)
|
3344
|
|
- //}
|
|
3364
|
+ if len(beforePrepares) > 0 && active == 2 {
|
|
3365
|
+
|
|
3366
|
+ //出库
|
|
3367
|
+ err = service.ConsumablesDeliveryTotal(adminUser.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares)
|
|
3368
|
+ fmt.Println("err", err)
|
|
3369
|
+
|
|
3370
|
+ //查询今日出库数据
|
|
3371
|
+ list, _ := service.GetAutoReduceRecordInfoByPatientId(adminUser.Org.Id, patient_id, record_time)
|
|
3372
|
+ fmt.Println("1111111111111111111111111111111111111111111", list)
|
|
3373
|
+ if len(list) == 0 {
|
|
3374
|
+ return
|
|
3375
|
+ }
|
|
3376
|
+
|
|
3377
|
+ for _, item := range list {
|
|
3378
|
+ prepare := models.DialysisBeforePrepare{
|
|
3379
|
+ UserOrgId: item.OrgId,
|
|
3380
|
+ PatientId: patient_id,
|
|
3381
|
+ RecordDate: item.RecordTime,
|
|
3382
|
+ GoodId: item.GoodId,
|
|
3383
|
+ GoodTypeId: item.GoodTypeId,
|
|
3384
|
+ Count: item.Count,
|
|
3385
|
+ Ctime: time.Now().Unix(),
|
|
3386
|
+ Creater: adminUser.AdminUser.Id,
|
|
3387
|
+ Status: 1,
|
|
3388
|
+ }
|
|
3389
|
+ //删除准备表数据
|
|
3390
|
+ service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
|
3391
|
+ service.CreateDialysisBeforePrepareOne(&prepare)
|
|
3392
|
+ }
|
3345
|
3393
|
|
|
3394
|
+ }
|
3346
|
3395
|
}
|
|
3396
|
+
|
3347
|
3397
|
var errs error
|
3348
|
3398
|
|
3349
|
3399
|
if dataBody["update_goods"] != nil && reflect.TypeOf(dataBody["update_goods"]).String() == "[]interface {}" {
|
3350
|
|
- goods, _ := dataBody["update_goods"].([]interface{})
|
3351
|
|
- if len(goods) > 0 {
|
3352
|
|
- for _, item := range goods {
|
|
3400
|
+ update_goods, _ := dataBody["update_goods"].([]interface{})
|
|
3401
|
+
|
|
3402
|
+ if len(update_goods) > 0 {
|
|
3403
|
+ for _, item := range update_goods {
|
3353
|
3404
|
items := item.(map[string]interface{})
|
3354
|
3405
|
|
3355
|
3406
|
if items["record_time"] == nil || reflect.TypeOf(items["record_time"]).String() != "float64" {
|
|
@@ -3401,7 +3452,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3401
|
3452
|
}
|
3402
|
3453
|
|
3403
|
3454
|
count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
3404
|
|
-
|
|
3455
|
+ fmt.Println("count9999999999999923924343434343434343434", count)
|
3405
|
3456
|
if items["ctime"] == nil || reflect.TypeOf(items["ctime"]).String() != "float64" {
|
3406
|
3457
|
utils.ErrorLog("ctime")
|
3407
|
3458
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -3428,10 +3479,57 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3428
|
3479
|
|
3429
|
3480
|
newBeforePrepares = append(newBeforePrepares, newPrepareGoods)
|
3430
|
3481
|
|
|
3482
|
+ prepare := &models.DialysisBeforePrepare{
|
|
3483
|
+ GoodTypeId: good_type_id,
|
|
3484
|
+ GoodId: good_id,
|
|
3485
|
+ Count: count,
|
|
3486
|
+ PatientId: patient_id,
|
|
3487
|
+ RecordDate: record_time,
|
|
3488
|
+ UserOrgId: adminUser.Org.Id,
|
|
3489
|
+ Status: 1,
|
|
3490
|
+ Ctime: time.Now().Unix(),
|
|
3491
|
+ Creater: adminUser.AdminUser.Id,
|
|
3492
|
+ CommdityCode: commdity_code,
|
|
3493
|
+ }
|
|
3494
|
+ dialysisBefor = append(dialysisBefor, prepare)
|
|
3495
|
+
|
3431
|
3496
|
}
|
3432
|
3497
|
}
|
3433
|
3498
|
|
3434
|
|
- if len(beforePrepares) > 0 {
|
|
3499
|
+ //新增
|
|
3500
|
+ if active == 1 && len(update_goods) > 0 {
|
|
3501
|
+ for _, item := range dialysisBefor {
|
|
3502
|
+
|
|
3503
|
+ dialyPrepareOne := models.DialysisBeforePrepare{
|
|
3504
|
+ GoodTypeId: item.GoodTypeId,
|
|
3505
|
+ GoodId: item.GoodId,
|
|
3506
|
+ PatientId: item.PatientId,
|
|
3507
|
+ RecordDate: item.RecordDate,
|
|
3508
|
+ UserOrgId: item.UserOrgId,
|
|
3509
|
+ Count: item.Count,
|
|
3510
|
+ Ctime: time.Now().Unix(),
|
|
3511
|
+ Creater: item.Creater,
|
|
3512
|
+ CommdityCode: item.CommdityCode,
|
|
3513
|
+ Status: 1,
|
|
3514
|
+ }
|
|
3515
|
+ //先清除再插入
|
|
3516
|
+ service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
|
3517
|
+ err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
|
|
3518
|
+
|
|
3519
|
+ }
|
|
3520
|
+ if err == nil {
|
|
3521
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3522
|
+ "msg": "保存成功",
|
|
3523
|
+ })
|
|
3524
|
+ return
|
|
3525
|
+
|
|
3526
|
+ } else {
|
|
3527
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
3528
|
+ return
|
|
3529
|
+ }
|
|
3530
|
+ }
|
|
3531
|
+
|
|
3532
|
+ if len(beforePrepares) > 0 && active == 2 {
|
3435
|
3533
|
//出库
|
3436
|
3534
|
err = service.ConsumablesDeliveryTotal(adminUser.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares)
|
3437
|
3535
|
fmt.Println("err", err)
|
|
@@ -3457,14 +3555,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3457
|
3555
|
service.CreateDialysisBeforePrepareOne(&prepare)
|
3458
|
3556
|
}
|
3459
|
3557
|
}
|
3460
|
|
- //去重
|
3461
|
|
- //updateBeforePrepares = RemoveRepeatedGood(updateBeforePrepares)
|
3462
|
3558
|
|
3463
|
|
- //if len(updateBeforePrepares) > 0 {
|
3464
|
|
- // for _, item := range updateBeforePrepares {
|
3465
|
|
- // errs = service.UpdateDialysisBeforePrepareTwo(item)
|
3466
|
|
- // }
|
3467
|
|
- //}
|
3468
|
3559
|
}
|
3469
|
3560
|
if errs == nil {
|
3470
|
3561
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -3494,7 +3585,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3494
|
3585
|
record_time := theRecordTime.Unix()
|
3495
|
3586
|
|
3496
|
3587
|
consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
|
3497
|
|
-
|
|
3588
|
+ fmt.Println("000000000000000000000000000", consumables)
|
3498
|
3589
|
_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
|
3499
|
3590
|
|
3500
|
3591
|
consumables = RemoveRepeatedGood(consumables)
|
|
@@ -3537,6 +3628,9 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3537
|
3628
|
}
|
3538
|
3629
|
|
3539
|
3630
|
list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
|
|
3631
|
+ if len(list) == 0 {
|
|
3632
|
+ return
|
|
3633
|
+ }
|
3540
|
3634
|
for _, item := range list {
|
3541
|
3635
|
prepare := models.DialysisBeforePrepare{
|
3542
|
3636
|
UserOrgId: adminInfo.Org.Id,
|
|
@@ -3558,10 +3652,14 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3558
|
3652
|
} else if err == nil {
|
3559
|
3653
|
for _, item := range consumables {
|
3560
|
3654
|
|
|
3655
|
+ fmt.Println("hhhhhhhhhh7777777777777", item.GoodId)
|
3561
|
3656
|
//出库
|
3562
|
3657
|
service.ConsumablesDelivery(item.UserOrgId, patient_id, record_time, item, &out, item.Count)
|
3563
|
3658
|
|
3564
|
3659
|
list, _ := service.GetAutoReduceRecordInfoByPatientId(adminInfo.Org.Id, patient_id, record_time)
|
|
3660
|
+ if len(list) == 0 {
|
|
3661
|
+ return
|
|
3662
|
+ }
|
3565
|
3663
|
for _, item := range list {
|
3566
|
3664
|
prepare := models.DialysisBeforePrepare{
|
3567
|
3665
|
UserOrgId: adminInfo.Org.Id,
|
|
@@ -3574,7 +3672,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3574
|
3672
|
Status: 1,
|
3575
|
3673
|
Ctime: time.Now().Unix(),
|
3576
|
3674
|
}
|
3577
|
|
- fmt.Println("hhhhhhhhhhhhh666666666666666666666666666666")
|
|
3675
|
+
|
3578
|
3676
|
//清空准备表数据
|
3579
|
3677
|
err = service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
3580
|
3678
|
service.CreateDialysisBeforePrepareOne(&prepare)
|
|
@@ -3593,182 +3691,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3593
|
3691
|
|
3594
|
3692
|
}
|
3595
|
3693
|
|
3596
|
|
-//func (c *DialysisAPIController) CreateStockOutInfo() {
|
3597
|
|
-// patient_id, _ := c.GetInt64("patient_id", 0)
|
3598
|
|
-// record_date := c.GetString("record_time")
|
3599
|
|
-//
|
3600
|
|
-// if patient_id <= 0 {
|
3601
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
3602
|
|
-// return
|
3603
|
|
-// }
|
3604
|
|
-//
|
3605
|
|
-// adminInfo := c.GetMobileAdminUserInfo()
|
3606
|
|
-//
|
3607
|
|
-// timeLayout := "2006-01-02"
|
3608
|
|
-// loc, _ := time.LoadLocation("Local")
|
3609
|
|
-// theRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
|
3610
|
|
-// record_time := theRecordTime.Unix()
|
3611
|
|
-//
|
3612
|
|
-// consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
|
3613
|
|
-//
|
3614
|
|
-// _, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
|
3615
|
|
-//
|
3616
|
|
-// consumables = RemoveRepeatedGood(consumables)
|
3617
|
|
-//
|
3618
|
|
-// if record.IsOpen == 1 {
|
3619
|
|
-// out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
|
3620
|
|
-// if err == gorm.ErrRecordNotFound {
|
3621
|
|
-// //没有记录,则创建出库单
|
3622
|
|
-// timeStr := time.Now().Format("2006-01-02")
|
3623
|
|
-// timeArr := strings.Split(timeStr, "-")
|
3624
|
|
-// total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
|
3625
|
|
-// total = total + 1
|
3626
|
|
-// warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
3627
|
|
-// number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
3628
|
|
-// number = number + total
|
3629
|
|
-// warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
3630
|
|
-// creater := adminInfo.AdminUser.Id
|
3631
|
|
-// warehouseOut := models.WarehouseOut{
|
3632
|
|
-// WarehouseOutOrderNumber: warehousing_out_order,
|
3633
|
|
-// OperationTime: time.Now().Unix(),
|
3634
|
|
-// OrgId: adminInfo.Org.Id,
|
3635
|
|
-// Creater: creater,
|
3636
|
|
-// Ctime: time.Now().Unix(),
|
3637
|
|
-// Status: 1,
|
3638
|
|
-// WarehouseOutTime: record_time,
|
3639
|
|
-// Dealer: 0,
|
3640
|
|
-// Manufacturer: 0,
|
3641
|
|
-// Type: 1,
|
3642
|
|
-// IsSys: 1,
|
3643
|
|
-// }
|
3644
|
|
-// err := service.AddSigleWarehouseOut(&warehouseOut)
|
3645
|
|
-// if err != nil {
|
3646
|
|
-// utils.TraceLog("创建出库单失败 err = %v", err)
|
3647
|
|
-// } else {
|
3648
|
|
-//
|
3649
|
|
-// for _, item := range consumables {
|
3650
|
|
-//
|
3651
|
|
-// if item.Count > 0 {
|
3652
|
|
-// warehouseOutInfo := &models.WarehouseOutInfo{
|
3653
|
|
-// WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
3654
|
|
-// WarehouseOutId: warehouseOut.ID,
|
3655
|
|
-// Status: 1,
|
3656
|
|
-// Ctime: time.Now().Unix(),
|
3657
|
|
-// Remark: "",
|
3658
|
|
-// OrgId: adminInfo.Org.Id,
|
3659
|
|
-// Type: 1,
|
3660
|
|
-// Manufacturer: 0,
|
3661
|
|
-// Dealer: 0,
|
3662
|
|
-// IsSys: 1,
|
3663
|
|
-// SysRecordTime: record_time,
|
3664
|
|
-// GoodTypeId: item.GoodTypeId,
|
3665
|
|
-// GoodId: item.GoodId,
|
3666
|
|
-// }
|
3667
|
|
-// warehouseOutInfo.Count = item.Count
|
3668
|
|
-// stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
|
3669
|
|
-// warehouseOutInfo.Price = stockInInfo.Price
|
3670
|
|
-// err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
3671
|
|
-// if err == nil {
|
3672
|
|
-// details := &models.AutomaticReduceDetail{
|
3673
|
|
-// WarehouseOutId: warehouseOutInfo.ID,
|
3674
|
|
-// WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
3675
|
|
-// PatientId: patient_id,
|
3676
|
|
-// Ctime: time.Now().Unix(),
|
3677
|
|
-// Mtime: time.Now().Unix(),
|
3678
|
|
-// Status: 1,
|
3679
|
|
-// RecordTime: record_time,
|
3680
|
|
-// OrgId: adminInfo.Org.Id,
|
3681
|
|
-// GoodId: item.GoodId,
|
3682
|
|
-// GoodTypeId: item.GoodTypeId,
|
3683
|
|
-// Count: item.Count,
|
3684
|
|
-// }
|
3685
|
|
-// service.AddSigleAutoReduceRecordInfo(details)
|
3686
|
|
-// }
|
3687
|
|
-//
|
3688
|
|
-// }
|
3689
|
|
-//
|
3690
|
|
-// }
|
3691
|
|
-//
|
3692
|
|
-// }
|
3693
|
|
-// } else if err == nil {
|
3694
|
|
-// for _, item := range consumables {
|
3695
|
|
-// outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
|
3696
|
|
-// if err == gorm.ErrRecordNotFound {
|
3697
|
|
-// warehouseOutInfo := &models.WarehouseOutInfo{
|
3698
|
|
-// WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
3699
|
|
-// WarehouseOutId: out.ID,
|
3700
|
|
-// Status: 1,
|
3701
|
|
-// Ctime: time.Now().Unix(),
|
3702
|
|
-// Remark: "",
|
3703
|
|
-// OrgId: adminInfo.Org.Id,
|
3704
|
|
-// Type: 1,
|
3705
|
|
-// Manufacturer: 0,
|
3706
|
|
-// Dealer: 0,
|
3707
|
|
-// IsSys: 1,
|
3708
|
|
-// SysRecordTime: record_time,
|
3709
|
|
-// }
|
3710
|
|
-//
|
3711
|
|
-// stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
|
3712
|
|
-// warehouseOutInfo.Price = stockInInfo.Price
|
3713
|
|
-// warehouseOutInfo.GoodId = item.GoodId
|
3714
|
|
-// warehouseOutInfo.GoodTypeId = item.GoodTypeId
|
3715
|
|
-// warehouseOutInfo.Count = item.Count
|
3716
|
|
-// err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
3717
|
|
-// if err == nil {
|
3718
|
|
-// details := &models.AutomaticReduceDetail{
|
3719
|
|
-// WarehouseOutId: warehouseOutInfo.ID,
|
3720
|
|
-// WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
3721
|
|
-// PatientId: patient_id,
|
3722
|
|
-// Ctime: time.Now().Unix(),
|
3723
|
|
-// Mtime: time.Now().Unix(),
|
3724
|
|
-// Status: 1,
|
3725
|
|
-// RecordTime: record_time,
|
3726
|
|
-// OrgId: adminInfo.Org.Id,
|
3727
|
|
-// GoodId: item.GoodId,
|
3728
|
|
-// GoodTypeId: item.GoodTypeId,
|
3729
|
|
-// Count: item.Count,
|
3730
|
|
-// }
|
3731
|
|
-// service.AddSigleAutoReduceRecordInfo(details)
|
3732
|
|
-// }
|
3733
|
|
-//
|
3734
|
|
-// } else if err == nil { //记录存在,则将增加数量
|
3735
|
|
-// if outInfo.ID > 0 {
|
3736
|
|
-// service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
|
3737
|
|
-// }
|
3738
|
|
-//
|
3739
|
|
-// count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
|
3740
|
|
-// if count == 0 {
|
3741
|
|
-// details := &models.AutomaticReduceDetail{
|
3742
|
|
-// WarehouseOutId: outInfo.ID,
|
3743
|
|
-// WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
3744
|
|
-// PatientId: patient_id,
|
3745
|
|
-// Ctime: time.Now().Unix(),
|
3746
|
|
-// Mtime: time.Now().Unix(),
|
3747
|
|
-// Status: 1,
|
3748
|
|
-// RecordTime: record_time,
|
3749
|
|
-// OrgId: adminInfo.Org.Id,
|
3750
|
|
-// GoodId: item.GoodId,
|
3751
|
|
-// GoodTypeId: item.GoodTypeId,
|
3752
|
|
-// Count: item.Count,
|
3753
|
|
-// }
|
3754
|
|
-// service.AddSigleAutoReduceRecordInfo(details)
|
3755
|
|
-// } else if count == 1 {
|
3756
|
|
-// service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
|
3757
|
|
-// }
|
3758
|
|
-//
|
3759
|
|
-// }
|
3760
|
|
-// }
|
3761
|
|
-// }
|
3762
|
|
-// c.ServeSuccessJSON(map[string]interface{}{
|
3763
|
|
-// "msg": "提交成功",
|
3764
|
|
-// })
|
3765
|
|
-// return
|
3766
|
|
-// } else {
|
3767
|
|
-// c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOpenStocktWrong)
|
3768
|
|
-// return
|
3769
|
|
-// }
|
3770
|
|
-//
|
3771
|
|
-//}
|
3772
|
3694
|
func (c *DialysisAPIController) EditConsumables() {
|
3773
|
3695
|
patient_id, _ := c.GetInt64("patient_id", 0)
|
3774
|
3696
|
record_date := c.GetString("record_time")
|
|
@@ -4009,166 +3931,6 @@ func (c *DialysisAPIController) EditConsumables() {
|
4009
|
3931
|
return
|
4010
|
3932
|
}
|
4011
|
3933
|
}
|
4012
|
|
- //手动出库
|
4013
|
|
-
|
4014
|
|
- //} else {
|
4015
|
|
- // if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
|
4016
|
|
- // goods, _ := dataBody["goods"].([]interface{})
|
4017
|
|
- // if len(goods) > 0 {
|
4018
|
|
- // for _, item := range goods {
|
4019
|
|
- // items := item.(map[string]interface{})
|
4020
|
|
- //
|
4021
|
|
- // if items["record_time"] == nil || reflect.TypeOf(items["record_time"]).String() != "float64" {
|
4022
|
|
- // utils.ErrorLog("record_time")
|
4023
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4024
|
|
- // return
|
4025
|
|
- // }
|
4026
|
|
- // record_time := int64(items["record_time"].(float64))
|
4027
|
|
- //
|
4028
|
|
- // if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
4029
|
|
- // utils.ErrorLog("id")
|
4030
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4031
|
|
- // return
|
4032
|
|
- // }
|
4033
|
|
- // id := int64(items["id"].(float64))
|
4034
|
|
- //
|
4035
|
|
- // if items["patient_id"] == nil || reflect.TypeOf(items["patient_id"]).String() != "float64" {
|
4036
|
|
- // utils.ErrorLog("patient_id")
|
4037
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4038
|
|
- // return
|
4039
|
|
- // }
|
4040
|
|
- // patient_id := int64(items["patient_id"].(float64))
|
4041
|
|
- //
|
4042
|
|
- // if items["creater"] == nil || reflect.TypeOf(items["creater"]).String() != "float64" {
|
4043
|
|
- // utils.ErrorLog("creater")
|
4044
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4045
|
|
- // return
|
4046
|
|
- // }
|
4047
|
|
- // creater := int64(items["creater"].(float64))
|
4048
|
|
- //
|
4049
|
|
- // if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
|
4050
|
|
- // utils.ErrorLog("good_id")
|
4051
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4052
|
|
- // return
|
4053
|
|
- // }
|
4054
|
|
- // good_id := int64(items["good_id"].(float64))
|
4055
|
|
- //
|
4056
|
|
- // if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
|
4057
|
|
- // utils.ErrorLog("good_type_id")
|
4058
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4059
|
|
- // return
|
4060
|
|
- // }
|
4061
|
|
- // good_type_id := int64(items["good_type_id"].(float64))
|
4062
|
|
- //
|
4063
|
|
- // if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
|
4064
|
|
- // utils.ErrorLog("count")
|
4065
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4066
|
|
- // return
|
4067
|
|
- // }
|
4068
|
|
- //
|
4069
|
|
- // count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
4070
|
|
- // fmt.Println(count)
|
4071
|
|
- // if items["ctime"] == nil || reflect.TypeOf(items["ctime"]).String() != "float64" {
|
4072
|
|
- // utils.ErrorLog("ctime")
|
4073
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4074
|
|
- // return
|
4075
|
|
- // }
|
4076
|
|
- // ctime := int64(items["ctime"].(float64))
|
4077
|
|
- // fmt.Println(ctime)
|
4078
|
|
- // adminUser := c.GetMobileAdminUserInfo()
|
4079
|
|
- // fmt.Println(adminUser)
|
4080
|
|
- //
|
4081
|
|
- // prepareGoods := &models.DialysisBeforePrepareGoods{
|
4082
|
|
- // GoodTypeId: good_type_id,
|
4083
|
|
- // GoodId: good_id,
|
4084
|
|
- // Count: count,
|
4085
|
|
- // }
|
4086
|
|
- //
|
4087
|
|
- // beforePrepares = append(beforePrepares, prepareGoods)
|
4088
|
|
- // //prepare := &models.DialysisBeforePrepare{
|
4089
|
|
- // // ID: id,
|
4090
|
|
- // // UserOrgId: adminUser.Org.Id,
|
4091
|
|
- // // PatientId: patient_id,
|
4092
|
|
- // // RecordDate: record_time,
|
4093
|
|
- // // GoodId: good_id,
|
4094
|
|
- // // GoodTypeId: good_type_id,
|
4095
|
|
- // // Count: count,
|
4096
|
|
- // // Ctime: ctime,
|
4097
|
|
- // // Mtime: time.Now().Unix(),
|
4098
|
|
- // // Creater: creater,
|
4099
|
|
- // // Modifier: adminUser.AdminUser.Id,
|
4100
|
|
- // // Status: 1,
|
4101
|
|
- // //}
|
4102
|
|
- // //beforePrepares = append(beforePrepares, prepare)
|
4103
|
|
- //
|
4104
|
|
- // }
|
4105
|
|
- // }
|
4106
|
|
- // }
|
4107
|
|
- // if dataBody["new_goods"] != nil && reflect.TypeOf(dataBody["new_goods"]).String() == "[]interface {}" {
|
4108
|
|
- // goods, _ := dataBody["new_goods"].([]interface{})
|
4109
|
|
- // if len(goods) > 0 {
|
4110
|
|
- // for _, item := range goods {
|
4111
|
|
- // items := item.(map[string]interface{})
|
4112
|
|
- //
|
4113
|
|
- // if items["good_id"] == nil || reflect.TypeOf(items["good_id"]).String() != "float64" {
|
4114
|
|
- // utils.ErrorLog("good_id")
|
4115
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4116
|
|
- // return
|
4117
|
|
- // }
|
4118
|
|
- // good_id := int64(items["good_id"].(float64))
|
4119
|
|
- //
|
4120
|
|
- // if items["good_type_id"] == nil || reflect.TypeOf(items["good_type_id"]).String() != "float64" {
|
4121
|
|
- // utils.ErrorLog("good_type_id")
|
4122
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4123
|
|
- // return
|
4124
|
|
- // }
|
4125
|
|
- // good_type_id := int64(items["good_type_id"].(float64))
|
4126
|
|
- //
|
4127
|
|
- // if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "string" {
|
4128
|
|
- // utils.ErrorLog("count")
|
4129
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
4130
|
|
- // return
|
4131
|
|
- // }
|
4132
|
|
- //
|
4133
|
|
- // count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
4134
|
|
- //
|
4135
|
|
- // adminUser := c.GetMobileAdminUserInfo()
|
4136
|
|
- // prepare := &models.DialysisBeforePrepare{
|
4137
|
|
- // UserOrgId: adminUser.Org.Id,
|
4138
|
|
- // PatientId: patient_id,
|
4139
|
|
- // RecordDate: record_time,
|
4140
|
|
- // GoodId: good_id,
|
4141
|
|
- // GoodTypeId: good_type_id,
|
4142
|
|
- // Count: count,
|
4143
|
|
- // Ctime: time.Now().Unix(),
|
4144
|
|
- // Mtime: time.Now().Unix(),
|
4145
|
|
- // Creater: adminUser.AdminUser.Id,
|
4146
|
|
- // Modifier: 0,
|
4147
|
|
- // }
|
4148
|
|
- // newBeforePrepares = append(newBeforePrepares, prepare)
|
4149
|
|
- //
|
4150
|
|
- // }
|
4151
|
|
- // }
|
4152
|
|
- // service.CreateDialysisBeforePrepare(newBeforePrepares)
|
4153
|
|
- // }
|
4154
|
|
- // var errs error
|
4155
|
|
- // if len(beforePrepares) > 0 {
|
4156
|
|
- // for _, item := range beforePrepares {
|
4157
|
|
- // errs = service.UpdateDialysisBeforePrepareTwo(item)
|
4158
|
|
- // }
|
4159
|
|
- // }
|
4160
|
|
- // if errs == nil {
|
4161
|
|
- // c.ServeSuccessJSON(map[string]interface{}{
|
4162
|
|
- // "msg": "修改成功",
|
4163
|
|
- // })
|
4164
|
|
- // return
|
4165
|
|
- //
|
4166
|
|
- // } else {
|
4167
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
4168
|
|
- // return
|
4169
|
|
- // }
|
4170
|
|
- //
|
4171
|
|
- //}
|
4172
|
3934
|
|
4173
|
3935
|
}
|
4174
|
3936
|
|