|
@@ -203,24 +203,27 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
|
203
|
203
|
// 判断处方里药品单位是拆零单位还是包装单位, 如果是拆零单位,则根据规格,将拆零数量转为包装数量
|
204
|
204
|
var maxNumber int64 = 0
|
205
|
205
|
var minNumber int64 = 0
|
206
|
|
- if advice.PrescribingNumberUnit == drup.MinUnit {
|
|
206
|
+ fmt.Println("单位1111111111", advice.PrescribingNumberUnit)
|
|
207
|
+ fmt.Println("单位222222222222222", drup.MaxUnit)
|
|
208
|
+ if advice.PrescribingNumberUnit == drup.MaxUnit {
|
207
|
209
|
maxNumber = count / drup.MinNumber
|
208
|
210
|
minNumber = count % drup.MinNumber
|
209
|
211
|
} else {
|
210
|
|
- maxNumber = count
|
|
212
|
+ minNumber = count
|
211
|
213
|
}
|
212
|
|
-
|
|
214
|
+ fmt.Println("maxNumber0000000000000", maxNumber)
|
|
215
|
+ fmt.Println("minNumber999999999999999", minNumber)
|
213
|
216
|
if warehouse.StockMaxNumber < maxNumber {
|
214
|
|
- fmt.Println("尽量323223232")
|
|
217
|
+
|
215
|
218
|
return errors.New("库存数量不足")
|
216
|
219
|
}
|
217
|
220
|
|
218
|
221
|
warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
|
219
|
222
|
warehouse.Mtime = time.Now().Unix()
|
220
|
|
-
|
221
|
223
|
if warehouse.StockMinNumber < minNumber {
|
222
|
224
|
warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
|
223
|
225
|
warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
|
|
226
|
+
|
224
|
227
|
} else {
|
225
|
228
|
warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
|
226
|
229
|
}
|
|
@@ -228,6 +231,7 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
|
228
|
231
|
if warehouse.StockMaxNumber < 0 {
|
229
|
232
|
return errors.New("库存数量不足")
|
230
|
233
|
}
|
|
234
|
+
|
231
|
235
|
errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
|
232
|
236
|
if errThree != nil {
|
233
|
237
|
return errThree
|
|
@@ -933,7 +937,6 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
933
|
937
|
info, _ := GetGoodInformationByGoodId(goods.GoodId)
|
934
|
938
|
// 当库存数量大于或等于出库数量的话,则正常出库该批次
|
935
|
939
|
if stock_number >= deliver_number {
|
936
|
|
- fmt.Println("进来22323232323232323232233223323223322323")
|
937
|
940
|
warehouseOutInfo := &models.WarehouseOutInfo{
|
938
|
941
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
939
|
942
|
WarehouseOutId: warehouseOut.ID,
|
|
@@ -986,6 +989,9 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
986
|
989
|
|
987
|
990
|
if errcode == gorm.ErrRecordNotFound {
|
988
|
991
|
errTwo := CreateAutoReduceRecord(&details)
|
|
992
|
+ if errTwo != nil {
|
|
993
|
+ return errTwo
|
|
994
|
+ }
|
989
|
995
|
//插入库存流水表
|
990
|
996
|
flow := models.VmStockFlow{
|
991
|
997
|
WarehouseOutId: warehouseOut.ID,
|
|
@@ -1013,10 +1019,13 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1013
|
1019
|
}
|
1014
|
1020
|
//查询流水是否存在
|
1015
|
1021
|
exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
|
1016
|
|
- fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
|
1017
|
1022
|
|
|
1023
|
+ fmt.Println("什么数据233232323", errflow)
|
1018
|
1024
|
if errflow == gorm.ErrRecordNotFound {
|
1019
|
|
- CreateStockFlowOne(flow)
|
|
1025
|
+ errThre := CreateStockFlowOne(flow)
|
|
1026
|
+ if errThre != nil {
|
|
1027
|
+ return errThre
|
|
1028
|
+ }
|
1020
|
1029
|
} else if errflow == nil {
|
1021
|
1030
|
flow := models.VmStockFlow{
|
1022
|
1031
|
ID: exsit.ID,
|
|
@@ -1044,14 +1053,13 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1044
|
1053
|
PatientId: patient_id,
|
1045
|
1054
|
ReturnCount: exsit.Count + (exsit.Count + deliver_number),
|
1046
|
1055
|
}
|
1047
|
|
- UpdatedStockFlow(flow)
|
1048
|
|
- }
|
1049
|
|
- if errTwo != nil {
|
1050
|
|
- return errTwo
|
|
1056
|
+ errFour := UpdatedStockFlow(flow)
|
|
1057
|
+ if errFour != nil {
|
|
1058
|
+ return errFour
|
|
1059
|
+ }
|
1051
|
1060
|
}
|
1052
|
|
- } else if errcode == nil {
|
1053
|
1061
|
|
1054
|
|
- fmt.Println("wodeeeeeeeeeeewewewewewewewewweewewewewewweewewew")
|
|
1062
|
+ } else if errcode == nil {
|
1055
|
1063
|
flow := models.VmStockFlow{
|
1056
|
1064
|
WarehouseOutId: warehouseOut.ID,
|
1057
|
1065
|
WarehousingId: warehouse.ID,
|
|
@@ -1078,10 +1086,11 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1078
|
1086
|
}
|
1079
|
1087
|
//查询流水是否存在
|
1080
|
1088
|
exsit, errflow := GetStockFlowIsExsit(warehouseOut.ID, patient_id, record_time, goods.GoodId)
|
1081
|
|
- fmt.Println("8888232322332323222332323223322332233232323232322323233223232332", exsit.Count+goods.Count)
|
1082
|
1089
|
|
1083
|
1090
|
if errflow == gorm.ErrRecordNotFound {
|
1084
|
1091
|
CreateStockFlowOne(flow)
|
|
1092
|
+ DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
|
1093
|
+ CreateAutoReduceRecord(&details)
|
1085
|
1094
|
} else if errflow == nil {
|
1086
|
1095
|
flow := models.VmStockFlow{
|
1087
|
1096
|
ID: exsit.ID,
|
|
@@ -1110,9 +1119,9 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
|
1110
|
1119
|
ReturnCount: exsit.Count + (exsit.Count + deliver_number),
|
1111
|
1120
|
}
|
1112
|
1121
|
UpdatedStockFlow(flow)
|
|
1122
|
+ DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
|
1123
|
+ CreateAutoReduceRecord(&details)
|
1113
|
1124
|
}
|
1114
|
|
- DeleteAutoRedeceDetailTwo(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
|
1115
|
|
- CreateAutoReduceRecord(&details)
|
1116
|
1125
|
|
1117
|
1126
|
}
|
1118
|
1127
|
|