|
@@ -633,12 +633,16 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
633
|
633
|
|
634
|
634
|
//查询该患者当天已经出库的耗材信息
|
635
|
635
|
goods_yc, _ := FindConsumablesByDateTwo(orgID, patient_id, record_time)
|
636
|
|
- for _, item := range goods_yc {
|
637
|
|
- fmt.Println("item0000000000000", item.Count)
|
638
|
|
- }
|
639
|
|
- for _, item := range goods {
|
640
|
|
- fmt.Println("item1111111111111", item.Count)
|
641
|
|
- }
|
|
636
|
+ //for _, item := range goods_yc {
|
|
637
|
+ // fmt.Println("已经出库的耗材新消息 -----------------------------------------", item.Count)
|
|
638
|
+ //}
|
|
639
|
+ //for _, item := range goods {
|
|
640
|
+ // fmt.Println("新传进来来的耗材新消息0000000000000000000000000000000000000000000000000", item.Count)
|
|
641
|
+ //}
|
|
642
|
+ //
|
|
643
|
+ //for _,item :=range goodOne{
|
|
644
|
+ // fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",item.Count)
|
|
645
|
+ //}
|
642
|
646
|
// 和新请求的出库数据进行对比,分出那些是继续出库的,那些是需要删除出库的
|
643
|
647
|
for i := len(goods_yc) - 1; i >= 0; i-- {
|
644
|
648
|
goods_yc_temp := goods_yc[i]
|
|
@@ -652,25 +656,25 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
652
|
656
|
goods = append(goods[:j], goods[j+1:]...)
|
653
|
657
|
break
|
654
|
658
|
}
|
655
|
|
- fmt.Println("998888888888888", goods_yc_temp.Count)
|
656
|
|
- fmt.Println("7777777777777777", goods_temp.Count)
|
|
659
|
+ //fmt.Println("998888888888888", goods_yc_temp.Count)
|
|
660
|
+ //fmt.Println("7777777777777777", goods_temp.Count)
|
657
|
661
|
// 如果已经出库的数量 大于 新请求出库的数量,则代表需要删除出库
|
658
|
662
|
if goods_yc_temp.Count > goods_temp.Count {
|
659
|
|
- fmt.Println("进来了是吗")
|
|
663
|
+
|
660
|
664
|
temp_count := goods_yc_temp.Count - goods_temp.Count
|
661
|
665
|
goods_yc[i].Count = temp_count
|
662
|
666
|
goods = append(goods[:j], goods[j+1:]...)
|
663
|
667
|
break
|
664
|
668
|
}
|
665
|
|
- fmt.Println("555555555555", goods_yc_temp.Count)
|
666
|
|
- fmt.Println("444444444444", goods_temp.Count)
|
|
669
|
+ //fmt.Println("555555555555", goods_yc_temp.Count)
|
|
670
|
+ //fmt.Println("444444444444", goods_temp.Count)
|
667
|
671
|
// 如果已经出库的数量 小于 新请求出库的梳理,则代表需要增加出库
|
668
|
672
|
if goods_yc_temp.Count < goods_temp.Count {
|
669
|
673
|
temp_count := goods_temp.Count - goods_yc_temp.Count
|
670
|
|
- fmt.Println("988888888888888", temp_count)
|
|
674
|
+ //fmt.Println("988888888888888", temp_count)
|
671
|
675
|
goods[j].Count = temp_count
|
672
|
676
|
goods_yc = append(goods_yc[:i], goods_yc[i+1:]...)
|
673
|
|
- fmt.Println("888888888", goods_yc)
|
|
677
|
+ //fmt.Println("888888888", goods_yc)
|
674
|
678
|
break
|
675
|
679
|
}
|
676
|
680
|
}
|
|
@@ -678,7 +682,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
678
|
682
|
}
|
679
|
683
|
|
680
|
684
|
// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
|
681
|
|
- // goods 这个数据就是需要出库的耗材的数据
|
|
685
|
+ // goods 这个数据就是需要出库的耗材的数据(新增的数据)
|
682
|
686
|
fmt.Println("goods222222222222", goods)
|
683
|
687
|
fmt.Println("goodsy999999999999", goods_yc)
|
684
|
688
|
if len(goods) > 0 {
|
|
@@ -718,7 +722,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
718
|
722
|
for _, item := range goods {
|
719
|
723
|
var newCount int64 = 0
|
720
|
724
|
for _, it := range goodOne {
|
721
|
|
- if item.GoodTypeId == it.GoodTypeId && it.GoodId == it.GoodId {
|
|
725
|
+ if item.GoodTypeId == it.GoodTypeId && item.GoodId == it.GoodId {
|
722
|
726
|
newCount = it.Count
|
723
|
727
|
}
|
724
|
728
|
}
|
|
@@ -727,20 +731,10 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
727
|
731
|
GoodId: item.GoodId,
|
728
|
732
|
Count: item.Count,
|
729
|
733
|
}
|
730
|
|
-
|
|
734
|
+ fmt.Println("count0000000000000000000000000000000", newCount)
|
731
|
735
|
ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
|
732
|
736
|
}
|
733
|
737
|
|
734
|
|
- // for _, item := range goodOne {
|
735
|
|
- // prepare := models.DialysisBeforePrepare{
|
736
|
|
- // GoodTypeId: item.GoodTypeId,
|
737
|
|
- // GoodId: item.GoodId,
|
738
|
|
- // Count: item.Count,
|
739
|
|
- // NewCount: item.NewCount,
|
740
|
|
- // }
|
741
|
|
- // fmt.Println("数量99999999999999999", item.Count)
|
742
|
|
- // ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, item.Count)
|
743
|
|
- // }
|
744
|
738
|
}
|
745
|
739
|
|
746
|
740
|
if len(goods_yc) > 0 {
|
|
@@ -821,12 +815,16 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
821
|
815
|
}
|
822
|
816
|
//查询当天耗材是否已经存在数据
|
823
|
817
|
_, errcode := GetAutoMaticReduceDetail(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
|
818
|
+
|
|
819
|
+ fmt.Println("errcode00000000000000000000000000000000000000", errcode)
|
824
|
820
|
if errcode == gorm.ErrRecordNotFound {
|
825
|
821
|
errTwo := CreateAutoReduceRecord(&details)
|
826
|
822
|
if errTwo != nil {
|
827
|
823
|
return errTwo
|
828
|
824
|
}
|
829
|
825
|
} else if errcode == nil {
|
|
826
|
+ fmt.Println("sql999999999999999999999999999999999999999")
|
|
827
|
+
|
830
|
828
|
DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
831
|
829
|
CreateAutoReduceRecord(&details)
|
832
|
830
|
}
|
|
@@ -849,6 +847,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
849
|
847
|
GoodId: goods.GoodId,
|
850
|
848
|
PatientId: patient_id,
|
851
|
849
|
}
|
|
850
|
+ fmt.Println("count9999999999999999999999999999999999999", count)
|
852
|
851
|
warehouseOutInfo.Count = count
|
853
|
852
|
//更新入库详情表
|
854
|
853
|
UpdateAutoMaticReduceDetail(goods.GoodId, goods.GoodTypeId, record_time, patient_id, orgID, warehouseOutInfo)
|
|
@@ -874,7 +873,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
874
|
873
|
}
|
875
|
874
|
} else if errcode == nil {
|
876
|
875
|
DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
877
|
|
-
|
878
|
876
|
CreateAutoReduceRecord(&details)
|
879
|
877
|
}
|
880
|
878
|
}
|
|
@@ -1116,7 +1114,7 @@ func ConsumablesDeliveryDelete(orgID int64, patient_id int64, record_time int64,
|
1116
|
1114
|
|
1117
|
1115
|
func GetAutoReduceRecordInfoByPatientId(orgid int64, patient_id int64, recordTime int64) (autoReduce []*models.AutomaticReduceDetail, err error) {
|
1118
|
1116
|
|
1119
|
|
- err = XTReadDB().Model(&autoReduce).Where("org_id = ? and patient_id = ? and record_time = ? and status = 1 and count<>0", orgid, patient_id, recordTime).Find(&autoReduce).Error
|
|
1117
|
+ err = XTReadDB().Model(&autoReduce).Where("org_id = ? and patient_id = ? and record_time = ? and status = 1", orgid, patient_id, recordTime).Find(&autoReduce).Error
|
1120
|
1118
|
return autoReduce, err
|
1121
|
1119
|
}
|
1122
|
1120
|
|
|
@@ -1126,6 +1124,12 @@ func DeleteDialysisBefor(orgid int64, patient_id int64, record_date int64, goodi
|
1126
|
1124
|
return err
|
1127
|
1125
|
}
|
1128
|
1126
|
|
|
1127
|
+func DeleteDialysisBeforThree(orgid int64, patient_id int64, record_date int64) error {
|
|
1128
|
+ prepare := models.DialysisBeforePrepare{}
|
|
1129
|
+ err := XTWriteDB().Model(&prepare).Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patient_id, record_date).Updates(map[string]interface{}{"status": 0, "count": 0, "mtime": time.Now().Unix()}).Error
|
|
1130
|
+ return err
|
|
1131
|
+}
|
|
1132
|
+
|
1129
|
1133
|
func ConsumablesDeliveryTotalOne(orgID int64, patient_id int64, record_time int64, goods []*models.DialysisBeforePrepareGoods, goodOne []*models.NewDialysisBeforePrepareGoods) (err error) {
|
1130
|
1134
|
|
1131
|
1135
|
//查询该患者当天已经出库的耗材信息
|
|
@@ -1279,7 +1283,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
|
1279
|
1283
|
Type: 1,
|
1280
|
1284
|
Manufacturer: 0,
|
1281
|
1285
|
Dealer: 0,
|
1282
|
|
- IsSys: 1,
|
|
1286
|
+ IsSys: 0,
|
1283
|
1287
|
SysRecordTime: record_time,
|
1284
|
1288
|
GoodTypeId: goods.GoodTypeId,
|
1285
|
1289
|
GoodId: goods.GoodId,
|
|
@@ -1307,7 +1311,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
|
1307
|
1311
|
Type: 1,
|
1308
|
1312
|
Manufacturer: 0,
|
1309
|
1313
|
Dealer: 0,
|
1310
|
|
- IsSys: 1,
|
|
1314
|
+ IsSys: 0,
|
1311
|
1315
|
SysRecordTime: record_time,
|
1312
|
1316
|
GoodTypeId: goods.GoodTypeId,
|
1313
|
1317
|
GoodId: goods.GoodId,
|
|
@@ -1347,7 +1351,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
|
1347
|
1351
|
Type: 1,
|
1348
|
1352
|
Manufacturer: 0,
|
1349
|
1353
|
Dealer: 0,
|
1350
|
|
- IsSys: 1,
|
|
1354
|
+ IsSys: 0,
|
1351
|
1355
|
SysRecordTime: record_time,
|
1352
|
1356
|
GoodTypeId: goods.GoodTypeId,
|
1353
|
1357
|
GoodId: goods.GoodId,
|
|
@@ -1387,7 +1391,7 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
|
1387
|
1391
|
Type: 1,
|
1388
|
1392
|
Manufacturer: 0,
|
1389
|
1393
|
Dealer: 0,
|
1390
|
|
- IsSys: 1,
|
|
1394
|
+ IsSys: 0,
|
1391
|
1395
|
SysRecordTime: record_time,
|
1392
|
1396
|
GoodTypeId: goods.GoodTypeId,
|
1393
|
1397
|
GoodId: goods.GoodId,
|
|
@@ -1430,7 +1434,7 @@ func ConsumablesDeliveryDeleteOne(orgID int64, record_time int64, good_yc *model
|
1430
|
1434
|
Type: 1,
|
1431
|
1435
|
Manufacturer: 0,
|
1432
|
1436
|
Dealer: 0,
|
1433
|
|
- IsSys: 1,
|
|
1437
|
+ IsSys: 0,
|
1434
|
1438
|
SysRecordTime: record_time,
|
1435
|
1439
|
GoodTypeId: good_yc.GoodTypeId,
|
1436
|
1440
|
GoodId: good_yc.GoodId,
|