|
@@ -3162,6 +3162,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3162
|
3162
|
|
3163
|
3163
|
if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
|
3164
|
3164
|
goods, _ := dataBody["goods"].([]interface{})
|
|
3165
|
+
|
3165
|
3166
|
if len(goods) > 0 {
|
3166
|
3167
|
for _, item := range goods {
|
3167
|
3168
|
items := item.(map[string]interface{})
|
|
@@ -3188,7 +3189,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3188
|
3189
|
|
3189
|
3190
|
count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
3190
|
3191
|
commdity_code := items["commdity_code"].(string)
|
3191
|
|
- fmt.Println("新建22222222222222", commdity_code)
|
|
3192
|
+
|
3192
|
3193
|
adminUser := c.GetMobileAdminUserInfo()
|
3193
|
3194
|
prepare := &models.DialysisBeforePrepare{
|
3194
|
3195
|
UserOrgId: adminUser.Org.Id,
|
|
@@ -3203,7 +3204,9 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3203
|
3204
|
Modifier: 0,
|
3204
|
3205
|
CommdityCode: commdity_code,
|
3205
|
3206
|
}
|
|
3207
|
+ //问题点
|
3206
|
3208
|
record_count := service.FindDialysisBeforePrepare(prepare.PatientId, prepare.GoodId, prepare.GoodTypeId, adminUser.Org.Id, record_time)
|
|
3209
|
+
|
3207
|
3210
|
if record_count == 0 {
|
3208
|
3211
|
beforePrepares = append(beforePrepares, prepare)
|
3209
|
3212
|
}
|
|
@@ -3281,7 +3284,7 @@ func (c *DialysisAPIController) CreateConsumables() {
|
3281
|
3284
|
ctime := int64(items["ctime"].(float64))
|
3282
|
3285
|
|
3283
|
3286
|
commdity_code := items["commdity_code"].(string)
|
3284
|
|
- fmt.Println("commdityecode22222222222222222222", commdity_code)
|
|
3287
|
+
|
3285
|
3288
|
prepare := &models.DialysisBeforePrepare{
|
3286
|
3289
|
ID: id,
|
3287
|
3290
|
UserOrgId: adminUser.Org.Id,
|
|
@@ -3525,6 +3528,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3525
|
3528
|
|
3526
|
3529
|
var newBeforePrepares []*models.DialysisBeforePrepare
|
3527
|
3530
|
|
|
3531
|
+ //判断是否开启自动出库
|
3528
|
3532
|
_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
|
3529
|
3533
|
|
3530
|
3534
|
if record.IsOpen == 1 {
|
|
@@ -3585,7 +3589,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3585
|
3589
|
}
|
3586
|
3590
|
|
3587
|
3591
|
count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
3588
|
|
-
|
|
3592
|
+ fmt.Println("count222222222222", count)
|
3589
|
3593
|
if items["ctime"] == nil || reflect.TypeOf(items["ctime"]).String() != "float64" {
|
3590
|
3594
|
utils.ErrorLog("ctime")
|
3591
|
3595
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -3593,7 +3597,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3593
|
3597
|
}
|
3594
|
3598
|
ctime := int64(items["ctime"].(float64))
|
3595
|
3599
|
commdity_code := items["commdity_code"].(string)
|
3596
|
|
- fmt.Println("commdityecode22222222222222222222", commdity_code)
|
|
3600
|
+
|
3597
|
3601
|
adminUser := c.GetMobileAdminUserInfo()
|
3598
|
3602
|
prepare := &models.DialysisBeforePrepare{
|
3599
|
3603
|
ID: id,
|
|
@@ -3616,7 +3620,9 @@ func (c *DialysisAPIController) EditConsumables() {
|
3616
|
3620
|
}
|
3617
|
3621
|
}
|
3618
|
3622
|
|
|
3623
|
+ //查询今日患者出库列表
|
3619
|
3624
|
consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
|
|
3625
|
+ fmt.Println("6666666666666", consumables_source)
|
3620
|
3626
|
|
3621
|
3627
|
if dataBody["new_goods"] != nil && reflect.TypeOf(dataBody["new_goods"]).String() == "[]interface {}" {
|
3622
|
3628
|
goods, _ := dataBody["new_goods"].([]interface{})
|
|
@@ -3645,6 +3651,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3645
|
3651
|
}
|
3646
|
3652
|
|
3647
|
3653
|
count, _ := strconv.ParseInt(items["count"].(string), 10, 64)
|
|
3654
|
+
|
3648
|
3655
|
//commdity_code := items["commdity_code"].(string)
|
3649
|
3656
|
//fmt.Println("commdityecode22222222222222222222",commdity_code)
|
3650
|
3657
|
adminUser := c.GetMobileAdminUserInfo()
|
|
@@ -3666,9 +3673,12 @@ func (c *DialysisAPIController) EditConsumables() {
|
3666
|
3673
|
}
|
3667
|
3674
|
newBeforePrepares = RemoveRepeatedGood(newBeforePrepares)
|
3668
|
3675
|
}
|
|
3676
|
+
|
|
3677
|
+ //创建数据
|
3669
|
3678
|
service.CreateDialysisBeforePrepare(newBeforePrepares)
|
3670
|
3679
|
}
|
3671
|
3680
|
|
|
3681
|
+ //查询是否有出库单
|
3672
|
3682
|
out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
|
3673
|
3683
|
if err == gorm.ErrRecordNotFound {
|
3674
|
3684
|
//没有记录,则创建出库单
|
|
@@ -3694,7 +3704,9 @@ func (c *DialysisAPIController) EditConsumables() {
|
3694
|
3704
|
Type: 1,
|
3695
|
3705
|
IsSys: 1,
|
3696
|
3706
|
}
|
|
3707
|
+ //创建出库单
|
3697
|
3708
|
err := service.AddSigleWarehouseOut(&warehouseOut)
|
|
3709
|
+ fmt.Println("err22222222222222", err)
|
3698
|
3710
|
if err != nil {
|
3699
|
3711
|
utils.TraceLog("创建出库单失败 err = %v", err)
|
3700
|
3712
|
} else {
|
|
@@ -3719,6 +3731,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
3719
|
3731
|
}
|
3720
|
3732
|
stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
|
3721
|
3733
|
warehouseOutInfo.Price = stockInInfo.Price
|
|
3734
|
+ //创建出库详情
|
3722
|
3735
|
err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
3723
|
3736
|
if err == nil {
|
3724
|
3737
|
details := &models.AutomaticReduceDetail{
|
|
@@ -3738,11 +3751,13 @@ func (c *DialysisAPIController) EditConsumables() {
|
3738
|
3751
|
}
|
3739
|
3752
|
}
|
3740
|
3753
|
}
|
|
3754
|
+ //没有出库单创建
|
3741
|
3755
|
} else if err == nil {
|
3742
|
3756
|
|
3743
|
3757
|
if len(newBeforePrepares) > 0 { //新增
|
3744
|
3758
|
|
3745
|
3759
|
for _, item := range newBeforePrepares {
|
|
3760
|
+
|
3746
|
3761
|
outInfo, err := service.FindStockOutInfoByTypeId(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, out.ID, out.WarehouseOutOrderNumber)
|
3747
|
3762
|
|
3748
|
3763
|
if err == gorm.ErrRecordNotFound {
|