|
@@ -14,7 +14,7 @@ import (
|
14
|
14
|
//耗材出库
|
15
|
15
|
func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
|
16
|
16
|
|
17
|
|
- fmt.Println("出库数量2333333333333333333333333333333333hhha", goods.Count)
|
|
17
|
+ //fmt.Println("出库数量2333333333333333333333333333333333hhha", goods.Count)
|
18
|
18
|
//开事务
|
19
|
19
|
var deliver_number int64 = 0
|
20
|
20
|
var stock_number int64 = 0
|
|
@@ -47,6 +47,8 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
47
|
47
|
if errThree != nil {
|
48
|
48
|
return errThree
|
49
|
49
|
}
|
|
50
|
+ //更新his_prescripton_project出库状态值
|
|
51
|
+ UpdateHisPrescriptionProjectStatus(goods.GoodId, record_time, orgID, patient_id)
|
50
|
52
|
|
51
|
53
|
//查询剩余库存
|
52
|
54
|
goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID)
|
|
@@ -83,9 +85,12 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
83
|
85
|
OverCount: sum_count,
|
84
|
86
|
}
|
85
|
87
|
warehouseOutInfo.Count = count
|
86
|
|
-
|
|
88
|
+ if orgID == 9671 || orgID == 10265 {
|
|
89
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
90
|
+ warehouseOutInfo.Price = goodsInfo.PackingPrice
|
|
91
|
+ }
|
87
|
92
|
_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
|
88
|
|
- fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
|
|
93
|
+ //fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
|
89
|
94
|
if errcodes == gorm.ErrRecordNotFound {
|
90
|
95
|
errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
|
91
|
96
|
if errOne != nil {
|
|
@@ -94,8 +99,8 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
94
|
99
|
} else if errcodes == nil {
|
95
|
100
|
|
96
|
101
|
outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
|
97
|
|
- fmt.Println("goods.cout23323233223232323w", count)
|
98
|
|
- fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
|
|
102
|
+ //fmt.Println("goods.cout23323233223232323w", count)
|
|
103
|
+ //fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
|
99
|
104
|
if count != outInfoOne.Count {
|
100
|
105
|
UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
|
101
|
106
|
}
|
|
@@ -116,12 +121,13 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
116
|
121
|
for _, item := range flowGoodTwo {
|
117
|
122
|
out_count_one += item.Count
|
118
|
123
|
}
|
119
|
|
- fmt.Println("deliver_number", deliver_number)
|
120
|
|
- fmt.Println("out_count", out_count)
|
121
|
|
- fmt.Println("count", count)
|
122
|
|
- fmt.Println("cancel_out_count2333233", out_count_one)
|
|
124
|
+ //fmt.Println("deliver_number", deliver_number)
|
|
125
|
+ //fmt.Println("out_count", out_count)
|
|
126
|
+ //fmt.Println("count", count)
|
|
127
|
+ //fmt.Println("cancel_out_count2333233", out_count_one)
|
123
|
128
|
//如果本次出库数据大于历史出库数据 新增1条流水
|
124
|
129
|
if count > (out_count - out_count_one) {
|
|
130
|
+
|
125
|
131
|
flow := models.VmStockFlow{
|
126
|
132
|
WarehouseOutId: warehouseOut.ID,
|
127
|
133
|
WarehousingId: warehouse.ID,
|
|
@@ -151,6 +157,11 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
151
|
157
|
OverCount: sum_count,
|
152
|
158
|
BuyPrice: warehouse.Price,
|
153
|
159
|
}
|
|
160
|
+ if orgID == 9671 || orgID == 10265 {
|
|
161
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
162
|
+ flow.Price = goodsInfo.PackingPrice
|
|
163
|
+ flow.BuyPrice = goodsInfo.BuyPrice
|
|
164
|
+ }
|
154
|
165
|
errThre := CreateStockFlowOne(flow)
|
155
|
166
|
if errThre != nil {
|
156
|
167
|
return errThre
|
|
@@ -217,7 +228,10 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
217
|
228
|
StorehouseId: goods.StorehouseId,
|
218
|
229
|
IsCheck: 1,
|
219
|
230
|
}
|
220
|
|
-
|
|
231
|
+ if orgID == 9671 || orgID == 10265 {
|
|
232
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
233
|
+ cancelStockInfo.Price = goodsInfo.PackingPrice
|
|
234
|
+ }
|
221
|
235
|
CreateCancelStockInfoOne(&cancelStockInfo)
|
222
|
236
|
|
223
|
237
|
cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
|
|
@@ -256,6 +270,11 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
256
|
270
|
BuyPrice: warehouse.Price,
|
257
|
271
|
ProjectId: goods.ProjectId,
|
258
|
272
|
}
|
|
273
|
+ if orgID == 9671 || orgID == 10265 {
|
|
274
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
275
|
+ flow.Price = goodsInfo.PackingPrice
|
|
276
|
+ flow.BuyPrice = goodsInfo.BuyPrice
|
|
277
|
+ }
|
259
|
278
|
CreateStockFlowOne(flow)
|
260
|
279
|
}
|
261
|
280
|
|
|
@@ -330,9 +349,12 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
330
|
349
|
OverCount: sum_count,
|
331
|
350
|
}
|
332
|
351
|
warehouseOutInfo.Count = stock_number
|
333
|
|
-
|
|
352
|
+ if orgID == 9671 || orgID == 10265 {
|
|
353
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
354
|
+ warehouseOutInfo.Price = goodsInfo.PackingPrice
|
|
355
|
+ }
|
334
|
356
|
_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
|
335
|
|
- fmt.Println("errcodes23332322332323223", errcodes, goods.ProjectId)
|
|
357
|
+ //fmt.Println("errcodes23332322332323223", errcodes, goods.ProjectId)
|
336
|
358
|
if errcodes == gorm.ErrRecordNotFound {
|
337
|
359
|
errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
|
338
|
360
|
if errOne != nil {
|
|
@@ -391,6 +413,11 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
391
|
413
|
OverCount: sum_count,
|
392
|
414
|
BuyPrice: warehouse.Price,
|
393
|
415
|
}
|
|
416
|
+ if orgID == 9671 || orgID == 10265 {
|
|
417
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
418
|
+ flow.Price = goodsInfo.PackingPrice
|
|
419
|
+ flow.BuyPrice = goodsInfo.BuyPrice
|
|
420
|
+ }
|
394
|
421
|
errThre := CreateStockFlowOne(flow)
|
395
|
422
|
if errThre != nil {
|
396
|
423
|
return errThre
|
|
@@ -453,7 +480,10 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
453
|
480
|
StorehouseId: goods.StorehouseId,
|
454
|
481
|
IsCheck: 1,
|
455
|
482
|
}
|
456
|
|
-
|
|
483
|
+ if orgID == 9671 || orgID == 10265 {
|
|
484
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
485
|
+ cancelStockInfo.Price = goodsInfo.PackingPrice
|
|
486
|
+ }
|
457
|
487
|
CreateCancelStockInfoOne(&cancelStockInfo)
|
458
|
488
|
|
459
|
489
|
cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
|
|
@@ -492,6 +522,11 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
492
|
522
|
BuyPrice: warehouse.Price,
|
493
|
523
|
ProjectId: goods.ProjectId,
|
494
|
524
|
}
|
|
525
|
+ if orgID == 9671 || orgID == 10265 {
|
|
526
|
+ goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
|
|
527
|
+ flow.Price = goodsInfo.PackingPrice
|
|
528
|
+ flow.BuyPrice = goodsInfo.BuyPrice
|
|
529
|
+ }
|
495
|
530
|
CreateStockFlowOne(flow)
|
496
|
531
|
}
|
497
|
532
|
|
|
@@ -2024,3 +2059,17 @@ func UpdateDrugWarehouseOutByPatientId(patient_id int64, advice_date int64, orgi
|
2024
|
2059
|
err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", patient_id, advice_date, orgid).Update(map[string]interface{}{"count": info.Count, "count_unit": info.CountUnit}).Error
|
2025
|
2060
|
return err
|
2026
|
2061
|
}
|
|
2062
|
+
|
|
2063
|
+func FindeGoodInfo(orgid int64, id int64) (models.GoodInformation, error) {
|
|
2064
|
+
|
|
2065
|
+ information := models.GoodInformation{}
|
|
2066
|
+ err := XTReadDB().Where("org_id = ? and id = ? and status = 1", orgid, id).Find(&information).Error
|
|
2067
|
+ return information, err
|
|
2068
|
+}
|
|
2069
|
+
|
|
2070
|
+func UpdateHisPrescriptionProjectStatus(project_id int64, record_time int64, user_org_id int64, patient_id int64) (models.HisPrescriptionProject, error) {
|
|
2071
|
+
|
|
2072
|
+ project := models.HisPrescriptionProject{}
|
|
2073
|
+ err := XTWriteDB().Model(&project).Where("project_id = ? and record_date = ? and user_org_id = ? and patient_id = ? and status = 1", project_id, record_time, user_org_id, patient_id).Update(map[string]interface{}{"is_out": 2}).Error
|
|
2074
|
+ return project, err
|
|
2075
|
+}
|