|
@@ -580,18 +580,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
580
|
580
|
var maxNumber int64 = 0
|
581
|
581
|
var minNumber int64 = 0
|
582
|
582
|
|
583
|
|
- //fmt.Println("deliver_number23332323232333232323233232323232",deliver_number)
|
584
|
583
|
maxNumber = deliver_number / drup.MinNumber
|
585
|
|
-
|
586
|
|
- if deliver_number <= drup.MinNumber {
|
587
|
|
- minNumber = deliver_number % drup.MinNumber
|
588
|
|
- } else {
|
589
|
|
- minNumber = deliver_number
|
590
|
|
- }
|
591
|
|
-
|
592
|
|
- if deliver_number <= drup.MinNumber && warehouse.StockMaxNumber == 0 {
|
593
|
|
- minNumber = deliver_number
|
594
|
|
- }
|
|
584
|
+ minNumber = deliver_number % drup.MinNumber
|
595
|
585
|
|
596
|
586
|
if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
|
597
|
587
|
minNumber = maxNumber
|
|
@@ -602,23 +592,33 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
602
|
592
|
return errors.New("库存数量不足")
|
603
|
593
|
}
|
604
|
594
|
}
|
|
595
|
+ if minNumber != 0 {
|
|
596
|
+ warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
|
|
597
|
+ }
|
605
|
598
|
|
606
|
|
- warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
|
607
|
|
- //fmt.Println("最大单位23323232323232332323233232323",warehouse.StockMaxNumber)
|
608
|
599
|
if warehouse.StockMaxNumber < 0 {
|
609
|
600
|
warehouse.StockMaxNumber = 0
|
610
|
601
|
}
|
|
602
|
+ if warehouse.StockMinNumber < 0 {
|
|
603
|
+ warehouse.StockMinNumber = 0
|
|
604
|
+ }
|
611
|
605
|
|
612
|
606
|
warehouse.Mtime = time.Now().Unix()
|
613
|
|
- //fmt.Println("最小单位2323223233232233233232323232323323232",warehouse.StockMinNumber)
|
614
|
|
- //fmt.Println("最小换算量233232332322323322332323232332323223",minNumber)
|
|
607
|
+ fmt.Println("w23332233232232332", warehouse.StockMinNumber, minNumber)
|
|
608
|
+
|
615
|
609
|
if warehouse.StockMinNumber < minNumber {
|
|
610
|
+ fmt.Println("进来的风3232332322323")
|
616
|
611
|
warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
|
617
|
612
|
warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
|
618
|
613
|
} else {
|
619
|
|
- //fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhh",warehouse.StockMinNumber,minNumber)
|
|
614
|
+ fmt.Println("进3232332322323")
|
620
|
615
|
warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
|
621
|
|
- //fmt.Println("我的魏2232332322323323",warehouse.StockMinNumber)
|
|
616
|
+ }
|
|
617
|
+
|
|
618
|
+ if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
|
|
619
|
+ fmt.Println("2223232332322323", warehouse.StockMinNumber)
|
|
620
|
+ warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
|
|
621
|
+
|
622
|
622
|
}
|
623
|
623
|
|
624
|
624
|
if drup.MaxUnit != drup.MinUnit {
|
|
@@ -626,6 +626,9 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
626
|
626
|
return errors.New("库存数量不足")
|
627
|
627
|
}
|
628
|
628
|
}
|
|
629
|
+ if warehouse.StockMinNumber <= 0 {
|
|
630
|
+ warehouse.StockMinNumber = 0
|
|
631
|
+ }
|
629
|
632
|
|
630
|
633
|
//扣减库存232332332332
|
631
|
634
|
errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
|
|
@@ -1054,6 +1057,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
1054
|
1057
|
GoodTypeId: item.GoodTypeId,
|
1055
|
1058
|
GoodId: item.GoodId,
|
1056
|
1059
|
Count: item.Count,
|
|
1060
|
+ ProjectId: item.ProjectId,
|
1057
|
1061
|
}
|
1058
|
1062
|
|
1059
|
1063
|
ConsumablesDelivery(orgID, patient_id, record_time, &prepare, &out, newCount)
|
|
@@ -1074,6 +1078,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
|
1074
|
1078
|
//耗材出库
|
1075
|
1079
|
func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
|
1076
|
1080
|
|
|
1081
|
+ fmt.Println("count23323223233232323232332232323", count, goods.Count)
|
1077
|
1082
|
var deliver_number int64 = 0
|
1078
|
1083
|
var stock_number int64 = 0
|
1079
|
1084
|
var maxNumber int64 = 0
|
|
@@ -1116,6 +1121,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1116
|
1121
|
Price: info.PackingPrice,
|
1117
|
1122
|
ExpiryDate: warehouse.ExpiryDate,
|
1118
|
1123
|
ProductDate: warehouse.ProductDate,
|
|
1124
|
+ ProjectId: goods.ProjectId,
|
1119
|
1125
|
}
|
1120
|
1126
|
warehouseOutInfo.Count = count
|
1121
|
1127
|
|
|
@@ -1141,6 +1147,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1141
|
1147
|
GoodId: goods.GoodId,
|
1142
|
1148
|
GoodTypeId: goods.GoodTypeId,
|
1143
|
1149
|
Count: count,
|
|
1150
|
+ ProjectId: goods.ProjectId,
|
1144
|
1151
|
}
|
1145
|
1152
|
//查询当天耗材是否已经存在数据
|
1146
|
1153
|
_, errcode := GetAutoMaticReduceDetail(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
|
@@ -1174,6 +1181,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1174
|
1181
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1175
|
1182
|
IsSys: 1,
|
1176
|
1183
|
PatientId: patient_id,
|
|
1184
|
+ ProjectId: goods.ProjectId,
|
1177
|
1185
|
}
|
1178
|
1186
|
//查询流水是否存在
|
1179
|
1187
|
exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1209,6 +1217,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1209
|
1217
|
IsSys: 1,
|
1210
|
1218
|
PatientId: patient_id,
|
1211
|
1219
|
ReturnCount: exsit.Count + (exsit.Count + deliver_number),
|
|
1220
|
+ ProjectId: goods.ProjectId,
|
1212
|
1221
|
}
|
1213
|
1222
|
|
1214
|
1223
|
errFour := UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1241,6 +1250,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1241
|
1250
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1242
|
1251
|
IsSys: 1,
|
1243
|
1252
|
PatientId: patient_id,
|
|
1253
|
+ ProjectId: goods.ProjectId,
|
1244
|
1254
|
}
|
1245
|
1255
|
//查询流水是否存在
|
1246
|
1256
|
exsit, errflow := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1275,6 +1285,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1275
|
1285
|
IsSys: 1,
|
1276
|
1286
|
PatientId: patient_id,
|
1277
|
1287
|
ReturnCount: exsit.Count + (exsit.Count + deliver_number),
|
|
1288
|
+ ProjectId: goods.ProjectId,
|
1278
|
1289
|
}
|
1279
|
1290
|
//UpdatedStockFlow(flow)
|
1280
|
1291
|
UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1327,6 +1338,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1327
|
1338
|
Price: info.PackingPrice,
|
1328
|
1339
|
ExpiryDate: warehouse.ExpiryDate,
|
1329
|
1340
|
ProductDate: warehouse.ProductDate,
|
|
1341
|
+ ProjectId: goods.ProjectId,
|
1330
|
1342
|
}
|
1331
|
1343
|
warehouseOutInfo.Count = stock_number
|
1332
|
1344
|
|
|
@@ -1362,6 +1374,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1362
|
1374
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1363
|
1375
|
IsSys: 1,
|
1364
|
1376
|
PatientId: patient_id,
|
|
1377
|
+ ProjectId: goods.ProjectId,
|
1365
|
1378
|
}
|
1366
|
1379
|
//查询流水是否存在
|
1367
|
1380
|
exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1394,6 +1407,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1394
|
1407
|
IsSys: 1,
|
1395
|
1408
|
PatientId: patient_id,
|
1396
|
1409
|
ReturnCount: exsit.Count + (exsit.Count + deliver_number),
|
|
1410
|
+ ProjectId: goods.ProjectId,
|
1397
|
1411
|
}
|
1398
|
1412
|
//UpdatedStockFlow(flow)
|
1399
|
1413
|
UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1429,6 +1443,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1429
|
1443
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1430
|
1444
|
IsSys: 1,
|
1431
|
1445
|
PatientId: patient_id,
|
|
1446
|
+ ProjectId: goods.ProjectId,
|
1432
|
1447
|
}
|
1433
|
1448
|
//查询流水是否存在
|
1434
|
1449
|
exsit, errflows := GetStockFlowIsExsit(warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1460,6 +1475,7 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1460
|
1475
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1461
|
1476
|
IsSys: 1,
|
1462
|
1477
|
PatientId: patient_id,
|
|
1478
|
+ ProjectId: goods.ProjectId,
|
1463
|
1479
|
}
|
1464
|
1480
|
//UpdatedStockFlow(flow)
|
1465
|
1481
|
UpdatedStockFlowOne(flow, warehouse.ID, patient_id, record_time, goods.GoodId)
|
|
@@ -1976,6 +1992,7 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
1976
|
1992
|
PatientId: advice.PatientId,
|
1977
|
1993
|
Count: deliver_number, //出最小单位
|
1978
|
1994
|
WarehouseInfoId: warehouse.ID,
|
|
1995
|
+ AdviceId: advice.ID,
|
1979
|
1996
|
}
|
1980
|
1997
|
|
1981
|
1998
|
drugflow := models.DrugFlow{
|
|
@@ -2000,6 +2017,7 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
2000
|
2017
|
IsSys: 1,
|
2001
|
2018
|
PatientId: advice.PatientId,
|
2002
|
2019
|
WarehousingDetailId: warehouse.ID,
|
|
2020
|
+ AdviceId: advice.ID,
|
2003
|
2021
|
}
|
2004
|
2022
|
|
2005
|
2023
|
CreateDrugFlowOne(drugflow)
|
|
@@ -2099,6 +2117,7 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
2099
|
2117
|
PatientId: advice.PatientId,
|
2100
|
2118
|
Count: deliver_number,
|
2101
|
2119
|
WarehouseInfoId: warehouse.ID,
|
|
2120
|
+ AdviceId: advice.ID,
|
2102
|
2121
|
}
|
2103
|
2122
|
errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
2104
|
2123
|
if errOne != nil {
|
|
@@ -2196,6 +2215,7 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
|
2196
|
2215
|
IsSys: 1,
|
2197
|
2216
|
PatientId: advice.PatientId,
|
2198
|
2217
|
WarehousingDetailId: warehouse.ID,
|
|
2218
|
+ AdviceId: advice.ID,
|
2199
|
2219
|
}
|
2200
|
2220
|
|
2201
|
2221
|
CreateDrugFlowOne(drugflow)
|
|
@@ -2280,6 +2300,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2280
|
2300
|
PatientId: advice.PatientId,
|
2281
|
2301
|
WarehouseInfoId: warehouse.ID,
|
2282
|
2302
|
Count: deliver_number,
|
|
2303
|
+ AdviceId: advice.ID,
|
2283
|
2304
|
}
|
2284
|
2305
|
|
2285
|
2306
|
drugflow := models.DrugFlow{
|
|
@@ -2305,6 +2326,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2305
|
2326
|
PatientId: advice.PatientId,
|
2306
|
2327
|
SystemTime: advice.RecordDate,
|
2307
|
2328
|
WarehousingDetailId: warehouse.ID,
|
|
2329
|
+ AdviceId: advice.ID,
|
2308
|
2330
|
}
|
2309
|
2331
|
|
2310
|
2332
|
CreateDrugFlowOne(drugflow)
|
|
@@ -2326,6 +2348,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2326
|
2348
|
Count: deliver_number,
|
2327
|
2349
|
CountUnit: drup.MinUnit,
|
2328
|
2350
|
WarehouseInfoId: warehouse.ID,
|
|
2351
|
+ AdviceId: advice.ID,
|
2329
|
2352
|
}
|
2330
|
2353
|
errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
2331
|
2354
|
if errTwo != nil {
|
|
@@ -2361,6 +2384,9 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2361
|
2384
|
if warehouse.StockMaxNumber < 0 {
|
2362
|
2385
|
return errors.New("库存数量不足")
|
2363
|
2386
|
}
|
|
2387
|
+ if warehouse.StockMinNumber <= 0 {
|
|
2388
|
+ warehouse.StockMinNumber = 0
|
|
2389
|
+ }
|
2364
|
2390
|
|
2365
|
2391
|
errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
|
2366
|
2392
|
|
|
@@ -2394,6 +2420,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2394
|
2420
|
WarehouseInfoId: warehouse.ID,
|
2395
|
2421
|
Count: deliver_number,
|
2396
|
2422
|
CountUnit: drup.MinUnit,
|
|
2423
|
+ AdviceId: advice.ID,
|
2397
|
2424
|
}
|
2398
|
2425
|
|
2399
|
2426
|
drugflow := models.DrugFlow{
|
|
@@ -2419,6 +2446,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2419
|
2446
|
PatientId: advice.PatientId,
|
2420
|
2447
|
SystemTime: advice.RecordDate,
|
2421
|
2448
|
WarehousingDetailId: warehouse.ID,
|
|
2449
|
+ AdviceId: advice.ID,
|
2422
|
2450
|
}
|
2423
|
2451
|
|
2424
|
2452
|
CreateDrugFlowOne(drugflow)
|
|
@@ -2440,6 +2468,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
|
2440
|
2468
|
Count: deliver_number,
|
2441
|
2469
|
CountUnit: drup.MinUnit,
|
2442
|
2470
|
WarehouseInfoId: warehouse.ID,
|
|
2471
|
+ AdviceId: advice.ID,
|
2443
|
2472
|
}
|
2444
|
2473
|
errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
2445
|
2474
|
if errTwo != nil {
|