|
@@ -1883,11 +1883,16 @@ func (c *DialysisAPIController) PostSolution() {
|
1883
|
1883
|
prescription.PrescriptionDoctor = prescription_doctor
|
1884
|
1884
|
|
1885
|
1885
|
}
|
|
1886
|
+
|
1886
|
1887
|
if dialysisPrescription.ID == 0 { //新增
|
1887
|
1888
|
prescription.Creater = adminUserInfo.AdminUser.Id
|
1888
|
1889
|
|
1889
|
1890
|
} else { //修改
|
1890
|
|
- prescription.Creater = dialysisPrescription.Creater
|
|
1891
|
+ if dialysisPrescription.Creater == 0 {
|
|
1892
|
+ prescription.Creater = adminUserInfo.AdminUser.Id
|
|
1893
|
+ } else {
|
|
1894
|
+ prescription.Creater = dialysisPrescription.Creater
|
|
1895
|
+ }
|
1891
|
1896
|
|
1892
|
1897
|
//if/**/
|
1893
|
1898
|
//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
|
|
@@ -2878,6 +2883,7 @@ func (this *DialysisAPIController) GetLastOrNextDoctorAdvice() {
|
2878
|
2883
|
func (c *DialysisAPIController) CreateConsumables() {
|
2879
|
2884
|
record_date := c.GetString("record_time")
|
2880
|
2885
|
patient_id, _ := c.GetInt64("patient_id", 0)
|
|
2886
|
+ adminUser := c.GetMobileAdminUserInfo()
|
2881
|
2887
|
|
2882
|
2888
|
timeLayout := "2006-01-02"
|
2883
|
2889
|
loc, _ := time.LoadLocation("Local")
|
|
@@ -2935,12 +2941,20 @@ func (c *DialysisAPIController) CreateConsumables() {
|
2935
|
2941
|
Creater: adminUser.AdminUser.Id,
|
2936
|
2942
|
Modifier: 0,
|
2937
|
2943
|
}
|
2938
|
|
- beforePrepares = append(beforePrepares, prepare)
|
|
2944
|
+ record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
|
|
2945
|
+ fmt.Println(record_count)
|
|
2946
|
+ if record_count == 0 {
|
|
2947
|
+ beforePrepares = append(beforePrepares, prepare)
|
|
2948
|
+ }
|
2939
|
2949
|
|
2940
|
2950
|
}
|
2941
|
2951
|
}
|
2942
|
2952
|
}
|
2943
|
|
- errs := service.CreateDialysisBeforePrepare(beforePrepares)
|
|
2953
|
+
|
|
2954
|
+ if len(beforePrepares) > 0 {
|
|
2955
|
+ service.CreateDialysisBeforePrepare(beforePrepares)
|
|
2956
|
+ }
|
|
2957
|
+ var errs error
|
2944
|
2958
|
|
2945
|
2959
|
if dataBody["update_goods"] != nil && reflect.TypeOf(dataBody["update_goods"]).String() == "[]interface {}" {
|
2946
|
2960
|
goods, _ := dataBody["update_goods"].([]interface{})
|
|
@@ -3005,7 +3019,6 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3005
|
3019
|
}
|
3006
|
3020
|
ctime := int64(items["ctime"].(float64))
|
3007
|
3021
|
|
3008
|
|
- adminUser := c.GetMobileAdminUserInfo()
|
3009
|
3022
|
prepare := &models.DialysisBeforePrepare{
|
3010
|
3023
|
ID: id,
|
3011
|
3024
|
UserOrgId: adminUser.Org.Id,
|
|
@@ -3026,22 +3039,19 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3026
|
3039
|
}
|
3027
|
3040
|
if len(updateBeforePrepares) > 0 {
|
3028
|
3041
|
for _, item := range updateBeforePrepares {
|
3029
|
|
- errs = service.UpdateDialysisBeforePrepare(item)
|
|
3042
|
+ errs = service.UpdateDialysisBeforePrepareTwo(item)
|
3030
|
3043
|
}
|
3031
|
3044
|
}
|
3032
|
3045
|
}
|
3033
|
|
-
|
3034
|
3046
|
if errs == nil {
|
3035
|
3047
|
c.ServeSuccessJSON(map[string]interface{}{
|
3036
|
3048
|
"msg": "提交成功",
|
3037
|
3049
|
})
|
3038
|
3050
|
return
|
3039
|
|
-
|
3040
|
3051
|
} else {
|
3041
|
3052
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
3042
|
3053
|
return
|
3043
|
3054
|
}
|
3044
|
|
-
|
3045
|
3055
|
}
|
3046
|
3056
|
|
3047
|
3057
|
func (c *DialysisAPIController) CreateStockOutInfo() {
|
|
@@ -3184,20 +3194,27 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3184
|
3194
|
if outInfo.ID > 0 {
|
3185
|
3195
|
service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
|
3186
|
3196
|
}
|
3187
|
|
- details := &models.AutomaticReduceDetail{
|
3188
|
|
- WarehouseOutId: outInfo.ID,
|
3189
|
|
- WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
3190
|
|
- PatientId: patient_id,
|
3191
|
|
- Ctime: time.Now().Unix(),
|
3192
|
|
- Mtime: time.Now().Unix(),
|
3193
|
|
- Status: 1,
|
3194
|
|
- RecordTime: record_time,
|
3195
|
|
- OrgId: adminInfo.Org.Id,
|
3196
|
|
- GoodId: item.GoodId,
|
3197
|
|
- GoodTypeId: item.GoodTypeId,
|
3198
|
|
- Count: item.Count,
|
|
3197
|
+
|
|
3198
|
+ count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
|
|
3199
|
+ if count == 0 {
|
|
3200
|
+ details := &models.AutomaticReduceDetail{
|
|
3201
|
+ WarehouseOutId: outInfo.ID,
|
|
3202
|
+ WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
3203
|
+ PatientId: patient_id,
|
|
3204
|
+ Ctime: time.Now().Unix(),
|
|
3205
|
+ Mtime: time.Now().Unix(),
|
|
3206
|
+ Status: 1,
|
|
3207
|
+ RecordTime: record_time,
|
|
3208
|
+ OrgId: adminInfo.Org.Id,
|
|
3209
|
+ GoodId: item.GoodId,
|
|
3210
|
+ GoodTypeId: item.GoodTypeId,
|
|
3211
|
+ Count: item.Count,
|
|
3212
|
+ }
|
|
3213
|
+ service.AddSigleAutoReduceRecordInfo(details)
|
|
3214
|
+ } else if count == 1 {
|
|
3215
|
+ service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
|
3199
|
3216
|
}
|
3200
|
|
- service.AddSigleAutoReduceRecordInfo(details)
|
|
3217
|
+
|
3201
|
3218
|
}
|
3202
|
3219
|
}
|
3203
|
3220
|
}
|
|
@@ -3211,7 +3228,6 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
|
3211
|
3228
|
}
|
3212
|
3229
|
|
3213
|
3230
|
}
|
3214
|
|
-
|
3215
|
3231
|
func (c *DialysisAPIController) EditConsumables() {
|
3216
|
3232
|
patient_id, _ := c.GetInt64("patient_id", 0)
|
3217
|
3233
|
record_date := c.GetString("record_time")
|
|
@@ -3373,6 +3389,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3373
|
3389
|
newBeforePrepares = append(newBeforePrepares, prepare)
|
3374
|
3390
|
|
3375
|
3391
|
}
|
|
3392
|
+ newBeforePrepares = RemoveRepeatedGood(newBeforePrepares)
|
3376
|
3393
|
}
|
3377
|
3394
|
service.CreateDialysisBeforePrepare(newBeforePrepares)
|
3378
|
3395
|
}
|
|
@@ -3449,6 +3466,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3449
|
3466
|
} else if err == nil {
|
3450
|
3467
|
|
3451
|
3468
|
if len(newBeforePrepares) > 0 { //新增
|
|
3469
|
+
|
3452
|
3470
|
for _, item := range newBeforePrepares {
|
3453
|
3471
|
outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
|
3454
|
3472
|
|
|
@@ -3474,9 +3492,38 @@ func (c *DialysisAPIController) EditConsumables() {
|
3474
|
3492
|
warehouseOutInfo.Count = item.Count
|
3475
|
3493
|
err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
3476
|
3494
|
if err == nil {
|
|
3495
|
+
|
|
3496
|
+ count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
|
|
3497
|
+ if count == 0 {
|
|
3498
|
+ details := &models.AutomaticReduceDetail{
|
|
3499
|
+ WarehouseOutId: warehouseOutInfo.ID,
|
|
3500
|
+ WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
3501
|
+ PatientId: patient_id,
|
|
3502
|
+ Ctime: time.Now().Unix(),
|
|
3503
|
+ Mtime: time.Now().Unix(),
|
|
3504
|
+ Status: 1,
|
|
3505
|
+ RecordTime: record_time,
|
|
3506
|
+ OrgId: adminInfo.Org.Id,
|
|
3507
|
+ GoodId: item.GoodId,
|
|
3508
|
+ GoodTypeId: item.GoodTypeId,
|
|
3509
|
+ Count: item.Count,
|
|
3510
|
+ }
|
|
3511
|
+ service.AddSigleAutoReduceRecordInfo(details)
|
|
3512
|
+ } else if count == 1 {
|
|
3513
|
+ service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
|
|
3514
|
+ }
|
|
3515
|
+
|
|
3516
|
+ }
|
|
3517
|
+ } else if err == nil { //记录存在,则将加数量
|
|
3518
|
+ if outInfo.ID > 0 {
|
|
3519
|
+ service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
|
|
3520
|
+ }
|
|
3521
|
+
|
|
3522
|
+ count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
|
|
3523
|
+ if count == 0 {
|
3477
|
3524
|
details := &models.AutomaticReduceDetail{
|
3478
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
3479
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
3525
|
+ WarehouseOutId: outInfo.ID,
|
|
3526
|
+ WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
3480
|
3527
|
PatientId: patient_id,
|
3481
|
3528
|
Ctime: time.Now().Unix(),
|
3482
|
3529
|
Mtime: time.Now().Unix(),
|
|
@@ -3488,43 +3535,45 @@ func (c *DialysisAPIController) EditConsumables() {
|
3488
|
3535
|
Count: item.Count,
|
3489
|
3536
|
}
|
3490
|
3537
|
service.AddSigleAutoReduceRecordInfo(details)
|
|
3538
|
+ } else if count == 1 {
|
|
3539
|
+ service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
|
3491
|
3540
|
}
|
3492
|
|
- } else if err == nil { //记录存在,则将加数量
|
3493
|
|
- if outInfo.ID > 0 {
|
3494
|
|
- service.UpdateStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, item.Count)
|
3495
|
|
- }
|
3496
|
|
- details := &models.AutomaticReduceDetail{
|
3497
|
|
- WarehouseOutId: outInfo.ID,
|
3498
|
|
- WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
3499
|
|
- PatientId: patient_id,
|
3500
|
|
- Ctime: time.Now().Unix(),
|
3501
|
|
- Mtime: time.Now().Unix(),
|
3502
|
|
- Status: 1,
|
3503
|
|
- RecordTime: record_time,
|
3504
|
|
- OrgId: adminInfo.Org.Id,
|
3505
|
|
- GoodId: item.GoodId,
|
3506
|
|
- GoodTypeId: item.GoodTypeId,
|
3507
|
|
- Count: item.Count,
|
3508
|
|
- }
|
3509
|
|
- service.AddSigleAutoReduceRecordInfo(details)
|
|
3541
|
+ //details := &models.AutomaticReduceDetail{
|
|
3542
|
+ // WarehouseOutId: outInfo.ID,
|
|
3543
|
+ // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
|
3544
|
+ // PatientId: patient_id,
|
|
3545
|
+ // Ctime: time.Now().Unix(),
|
|
3546
|
+ // Mtime: time.Now().Unix(),
|
|
3547
|
+ // Status: 1,
|
|
3548
|
+ // RecordTime: record_time,
|
|
3549
|
+ // OrgId: adminInfo.Org.Id,
|
|
3550
|
+ // GoodId: item.GoodId,
|
|
3551
|
+ // GoodTypeId: item.GoodTypeId,
|
|
3552
|
+ // Count: item.Count,
|
|
3553
|
+ //}
|
|
3554
|
+ //service.AddSigleAutoReduceRecordInfo(details)
|
3510
|
3555
|
}
|
3511
|
3556
|
}
|
3512
|
3557
|
|
3513
|
3558
|
}
|
3514
|
3559
|
|
3515
|
|
- if len(consumables_source) > 0 { //修改
|
|
3560
|
+ if len(beforePrepares) > 0 { //修改
|
3516
|
3561
|
for _, consumable := range consumables_source {
|
3517
|
3562
|
for _, before := range beforePrepares {
|
3518
|
|
- if consumable.GoodId == before.GoodId && consumable.GoodTypeId == before.GoodTypeId {
|
3519
|
|
- if consumable.Count != before.Count {
|
3520
|
3563
|
|
3521
|
|
- _, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
|
|
3564
|
+ if consumable.GoodId == before.GoodId {
|
|
3565
|
+ fmt.Println(consumable.Count)
|
|
3566
|
+ fmt.Println(before.Count)
|
3522
|
3567
|
|
|
3568
|
+ if consumable.Count != before.Count {
|
|
3569
|
+ fmt.Println("111111111")
|
|
3570
|
+ _, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
|
3523
|
3571
|
//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
|
3524
|
|
-
|
3525
|
3572
|
//判断前端更改后的商品id的出库记录在数据库中是否存在
|
3526
|
3573
|
err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
|
3527
|
3574
|
if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
|
|
3575
|
+ fmt.Println("222222222")
|
|
3576
|
+
|
3528
|
3577
|
warehouseOutInfo := &models.WarehouseOutInfo{
|
3529
|
3578
|
WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
3530
|
3579
|
WarehouseOutId: out.ID,
|
|
@@ -3571,6 +3620,8 @@ func (c *DialysisAPIController) EditConsumables() {
|
3571
|
3620
|
}
|
3572
|
3621
|
}
|
3573
|
3622
|
} else if err == nil { //存在,则更改使用人商品信息
|
|
3623
|
+ fmt.Println("333333333")
|
|
3624
|
+
|
3574
|
3625
|
//处理原来的数据
|
3575
|
3626
|
if newOut.ID > 0 {
|
3576
|
3627
|
if consumable.Count > before.Count { // 减少
|
|
@@ -3609,17 +3660,20 @@ func (c *DialysisAPIController) EditConsumables() {
|
3609
|
3660
|
}
|
3610
|
3661
|
}
|
3611
|
3662
|
|
|
3663
|
+ fmt.Println("444444444")
|
|
3664
|
+
|
3612
|
3665
|
}
|
3613
|
3666
|
}
|
3614
|
3667
|
}
|
3615
|
3668
|
}
|
3616
|
3669
|
}
|
3617
|
3670
|
}
|
|
3671
|
+ fmt.Println("655555555")
|
3618
|
3672
|
|
3619
|
3673
|
var errs error
|
3620
|
3674
|
if len(beforePrepares) > 0 {
|
3621
|
3675
|
for _, item := range beforePrepares {
|
3622
|
|
- errs = service.UpdateDialysisBeforePrepare(item)
|
|
3676
|
+ errs = service.UpdateDialysisBeforePrepareTwo(item)
|
3623
|
3677
|
}
|
3624
|
3678
|
}
|
3625
|
3679
|
if errs == nil {
|
|
@@ -3767,7 +3821,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3767
|
3821
|
var errs error
|
3768
|
3822
|
if len(beforePrepares) > 0 {
|
3769
|
3823
|
for _, item := range beforePrepares {
|
3770
|
|
- errs = service.UpdateDialysisBeforePrepare(item)
|
|
3824
|
+ errs = service.UpdateDialysisBeforePrepareTwo(item)
|
3771
|
3825
|
}
|
3772
|
3826
|
}
|
3773
|
3827
|
if errs == nil {
|
|
@@ -3916,7 +3970,7 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
|
3916
|
3970
|
good_info, _ := service.FindAllGoodInfo(adminUser.Org.Id)
|
3917
|
3971
|
|
3918
|
3972
|
goodUser, _ := service.GetAllStockOutUserDetail(patient_id, adminUser.Org.Id, date.Unix())
|
3919
|
|
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(patient_id, adminUser.Org.Id, date.Unix())
|
|
3973
|
+ lastGoodUserDetial, _ := service.GetLastDialysisGoods(patient_id, adminUser.Org.Id, date.Unix())
|
3920
|
3974
|
c.ServeSuccessJSON(map[string]interface{}{
|
3921
|
3975
|
"good_type": goodTypes,
|
3922
|
3976
|
"good_user": goodUser,
|
|
@@ -3926,7 +3980,6 @@ func (c *DialysisAPIController) GetStockInGoodInfo() {
|
3926
|
3980
|
return
|
3927
|
3981
|
|
3928
|
3982
|
}
|
3929
|
|
-
|
3930
|
3983
|
func (c *DialysisAPIController) CreateOtherStockOutInfo() {
|
3931
|
3984
|
patient_id, _ := c.GetInt64("patient_id", 0)
|
3932
|
3985
|
record_date := c.GetString("record_time")
|
|
@@ -4149,3 +4202,19 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
|
4149
|
4202
|
}
|
4150
|
4203
|
|
4151
|
4204
|
}
|
|
4205
|
+func RemoveRepeatedGood(arr []*models.DialysisBeforePrepare) (newArr []*models.DialysisBeforePrepare) {
|
|
4206
|
+ newArr = make([]*models.DialysisBeforePrepare, 0)
|
|
4207
|
+ for i := 0; i < len(arr); i++ {
|
|
4208
|
+ repeat := false
|
|
4209
|
+ for j := i + 1; j < len(arr); j++ {
|
|
4210
|
+ if arr[i].GoodId == arr[j].GoodId && arr[i].GoodTypeId == arr[j].GoodTypeId {
|
|
4211
|
+ repeat = true
|
|
4212
|
+ break
|
|
4213
|
+ }
|
|
4214
|
+ }
|
|
4215
|
+ if !repeat {
|
|
4216
|
+ newArr = append(newArr, arr[i])
|
|
4217
|
+ }
|
|
4218
|
+ }
|
|
4219
|
+ return
|
|
4220
|
+}
|