|
@@ -90,7 +90,6 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
90
|
90
|
warehouseOutInfo.Price = goodsInfo.PackingPrice
|
91
|
91
|
}
|
92
|
92
|
_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
|
93
|
|
- //fmt.Println("errcodes2333232233232wode3223", errcodes, goods.ProjectId)
|
94
|
93
|
if errcodes == gorm.ErrRecordNotFound {
|
95
|
94
|
errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
|
96
|
95
|
if errOne != nil {
|
|
@@ -99,8 +98,6 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
99
|
98
|
} else if errcodes == nil {
|
100
|
99
|
|
101
|
100
|
outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
|
102
|
|
- //fmt.Println("goods.cout23323233223232323w", count)
|
103
|
|
- //fmt.Println("outInfoOnewowowwowowowowowo", outInfoOne.Count)
|
104
|
101
|
if count != outInfoOne.Count {
|
105
|
102
|
UpdatedWarehouseOutInfo(warehouseOutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId)
|
106
|
103
|
}
|
|
@@ -121,10 +118,6 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
|
121
|
118
|
for _, item := range flowGoodTwo {
|
122
|
119
|
out_count_one += item.Count
|
123
|
120
|
}
|
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)
|
128
|
121
|
//如果本次出库数据大于历史出库数据 新增1条流水
|
129
|
122
|
if count > (out_count - out_count_one) {
|
130
|
123
|
|
|
@@ -553,6 +546,13 @@ func FindWarehouseOutInfoByPatientId(patient_id int64, record_time int64, good_i
|
553
|
546
|
return outInfo, err
|
554
|
547
|
}
|
555
|
548
|
|
|
549
|
+func FindWarehouseOutInfoByPatientIdTwo(patient_id int64, record_time int64, good_id int64, org_id int64, project_id int64) (models.WarehouseOutInfo, error) {
|
|
550
|
+
|
|
551
|
+ outInfo := models.WarehouseOutInfo{}
|
|
552
|
+ err := XTReadDB().Where("patient_id = ? and sys_record_time = ? and good_id = ? and org_id = ? and status = 1 and project_id = ?", patient_id, record_time, good_id, org_id, project_id).Last(&outInfo).Error
|
|
553
|
+ return outInfo, err
|
|
554
|
+}
|
|
555
|
+
|
556
|
556
|
func UpdateDrugStockCount(drug_id int64, org_id int64, storehouse_id int64, flush_count int64) error {
|
557
|
557
|
|
558
|
558
|
drug := models.XtDrugStockCount{}
|
|
@@ -2120,3 +2120,723 @@ func UpdateHisPrescriptionProjectStatus(project_id int64, record_time int64, use
|
2120
|
2120
|
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": 1}).Error
|
2121
|
2121
|
return project, err
|
2122
|
2122
|
}
|
|
2123
|
+
|
|
2124
|
+// 药品自动出库 递归方式
|
|
2125
|
+func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
|
|
2126
|
+
|
|
2127
|
+ // 判断处方里药品单位是拆零单位还是包装单位, 如果是包装单位,则根据规格,将包装数量转为拆零数量
|
|
2128
|
+ var deliver_number int64 = 0
|
|
2129
|
+ var stock_number int64 = 0
|
|
2130
|
+
|
|
2131
|
+ prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
|
|
2132
|
+ count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
|
|
2133
|
+
|
|
2134
|
+ var drug_price float64
|
|
2135
|
+ if advice.PrescribingNumberUnit == drup.MaxUnit {
|
|
2136
|
+ deliver_number = count * drup.MinNumber
|
|
2137
|
+
|
|
2138
|
+ } else {
|
|
2139
|
+ deliver_number = count
|
|
2140
|
+
|
|
2141
|
+ }
|
|
2142
|
+
|
|
2143
|
+ if advice.PrescribingNumberUnit == drup.MaxUnit {
|
|
2144
|
+ drug_price = drup.RetailPrice
|
|
2145
|
+ }
|
|
2146
|
+ fmt.Println(drug_price)
|
|
2147
|
+
|
|
2148
|
+ if advice.PrescribingNumberUnit == drup.MinUnit {
|
|
2149
|
+ drug_price = drup.MinPrice
|
|
2150
|
+ }
|
|
2151
|
+
|
|
2152
|
+ if advice.PrescribingNumberUnit != drup.MaxUnit || advice.PrescribingNumberUnit != drup.MinUnit {
|
|
2153
|
+ drug_price = drup.RetailPrice
|
|
2154
|
+ }
|
|
2155
|
+
|
|
2156
|
+ // 根据先进先出原则,查询最先入库的批次,进行出库
|
|
2157
|
+ // 如果没有对应的库存,则报错
|
|
2158
|
+ storeConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
|
|
2159
|
+ lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
|
|
2160
|
+ if lastWarehouse.StockMinNumber >= drup.MinNumber {
|
|
2161
|
+ var stockMax int64
|
|
2162
|
+ var stockMin int64
|
|
2163
|
+ stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
|
|
2164
|
+ stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
|
|
2165
|
+
|
|
2166
|
+ ChangeMaxNumber(lastWarehouse.ID, stockMax)
|
|
2167
|
+ UpdateMinNumber(lastWarehouse.ID, stockMin)
|
|
2168
|
+ }
|
|
2169
|
+ warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
|
|
2170
|
+
|
|
2171
|
+ if err != nil {
|
|
2172
|
+
|
|
2173
|
+ return err
|
|
2174
|
+ }
|
|
2175
|
+ // 将该批次的剩余库存数量转换为拆零数量
|
|
2176
|
+ // 将该批次的剩余库存数量转换为拆零数量
|
|
2177
|
+ if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
|
|
2178
|
+
|
|
2179
|
+ stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
|
|
2180
|
+
|
|
2181
|
+ }
|
|
2182
|
+ if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
|
|
2183
|
+
|
|
2184
|
+ stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
|
|
2185
|
+
|
|
2186
|
+ }
|
|
2187
|
+ if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
|
|
2188
|
+
|
|
2189
|
+ stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
|
|
2190
|
+
|
|
2191
|
+ }
|
|
2192
|
+
|
|
2193
|
+ // 当库存数量大于或等于出库数量的话,则正常出库该批次
|
|
2194
|
+ if stock_number >= deliver_number {
|
|
2195
|
+
|
|
2196
|
+ var maxNumber int64 = 0
|
|
2197
|
+ var minNumber int64 = 0
|
|
2198
|
+
|
|
2199
|
+ maxNumber = deliver_number / drup.MinNumber
|
|
2200
|
+ minNumber = deliver_number % drup.MinNumber
|
|
2201
|
+
|
|
2202
|
+ if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
|
|
2203
|
+ minNumber = maxNumber
|
|
2204
|
+ }
|
|
2205
|
+
|
|
2206
|
+ if drup.MaxUnit != drup.MinUnit {
|
|
2207
|
+ if warehouse.StockMaxNumber < maxNumber && warehouse.StockMinNumber < minNumber {
|
|
2208
|
+ return errors.New("库存数量不足")
|
|
2209
|
+ }
|
|
2210
|
+ }
|
|
2211
|
+
|
|
2212
|
+ if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
|
|
2213
|
+ warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
|
|
2214
|
+ }
|
|
2215
|
+ if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
|
|
2216
|
+ warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
|
|
2217
|
+ }
|
|
2218
|
+ if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
|
|
2219
|
+ warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
|
|
2220
|
+ }
|
|
2221
|
+
|
|
2222
|
+ if warehouse.StockMaxNumber < 0 {
|
|
2223
|
+ warehouse.StockMaxNumber = 0
|
|
2224
|
+ }
|
|
2225
|
+ if warehouse.StockMinNumber < 0 {
|
|
2226
|
+ warehouse.StockMinNumber = 0
|
|
2227
|
+ }
|
|
2228
|
+
|
|
2229
|
+ warehouse.Mtime = time.Now().Unix()
|
|
2230
|
+
|
|
2231
|
+ fmt.Println("minnU目标而332322323323233223323223我", minNumber)
|
|
2232
|
+ fmt.Println("max_number232232332232322wo", maxNumber)
|
|
2233
|
+ fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
|
|
2234
|
+
|
|
2235
|
+ if warehouse.StockMinNumber < minNumber {
|
|
2236
|
+
|
|
2237
|
+ warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
|
|
2238
|
+ if warehouse.MaxUnit != warehouse.MinUnit {
|
|
2239
|
+ warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
|
|
2240
|
+ }
|
|
2241
|
+ } else {
|
|
2242
|
+ if minNumber > 0 {
|
|
2243
|
+ if (warehouse.StockMinNumber - minNumber) >= 0 {
|
|
2244
|
+ warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
|
|
2245
|
+ }
|
|
2246
|
+
|
|
2247
|
+ }
|
|
2248
|
+
|
|
2249
|
+ if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
|
|
2250
|
+ if warehouse.StockMinNumber > 0 {
|
|
2251
|
+ if warehouse.StockMinNumber-deliver_number >= 0 {
|
|
2252
|
+ warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
|
|
2253
|
+ }
|
|
2254
|
+
|
|
2255
|
+ }
|
|
2256
|
+
|
|
2257
|
+ }
|
|
2258
|
+
|
|
2259
|
+ }
|
|
2260
|
+
|
|
2261
|
+ if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
|
|
2262
|
+ if (warehouse.StockMinNumber - deliver_number) >= 0 {
|
|
2263
|
+ warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
|
|
2264
|
+ }
|
|
2265
|
+
|
|
2266
|
+ }
|
|
2267
|
+
|
|
2268
|
+ if drup.MaxUnit != drup.MinUnit {
|
|
2269
|
+ if warehouse.StockMaxNumber < 0 && warehouse.StockMinNumber < 0 {
|
|
2270
|
+ return errors.New("库存数量不足")
|
|
2271
|
+ }
|
|
2272
|
+ }
|
|
2273
|
+ if warehouse.StockMinNumber <= 0 {
|
|
2274
|
+ warehouse.StockMinNumber = 0
|
|
2275
|
+ }
|
|
2276
|
+
|
|
2277
|
+ //扣减库存数据
|
|
2278
|
+ errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
|
|
2279
|
+ if errThree != nil {
|
|
2280
|
+ return errThree
|
|
2281
|
+ }
|
|
2282
|
+
|
|
2283
|
+ //查询剩余库存
|
|
2284
|
+ stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
|
|
2285
|
+ var sum_count int64
|
|
2286
|
+ for _, its := range stockInfo {
|
|
2287
|
+ if its.MaxUnit == drup.MaxUnit {
|
|
2288
|
+ its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
|
|
2289
|
+ }
|
|
2290
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
2291
|
+ }
|
|
2292
|
+
|
|
2293
|
+ warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
2294
|
+ WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
2295
|
+ WarehouseOutId: warehouseout.ID,
|
|
2296
|
+ Status: 1,
|
|
2297
|
+ Ctime: time.Now().Unix(),
|
|
2298
|
+ Remark: warehouse.Remark,
|
|
2299
|
+ OrgId: orgID,
|
|
2300
|
+ Type: 5,
|
|
2301
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2302
|
+ Dealer: warehouse.Dealer,
|
|
2303
|
+ IsSys: 1,
|
|
2304
|
+ SysRecordTime: advice.RecordDate,
|
|
2305
|
+ DrugId: advice.DrugId,
|
|
2306
|
+ Number: warehouse.Number,
|
|
2307
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2308
|
+ Price: warehouse.RetailPrice,
|
|
2309
|
+ CountUnit: drup.MinUnit,
|
|
2310
|
+ RetailPrice: warehouse.RetailPrice,
|
|
2311
|
+ ProductDate: warehouse.ProductDate,
|
|
2312
|
+ ExpiryDate: warehouse.ExpiryDate,
|
|
2313
|
+ PatientId: advice.PatientId,
|
|
2314
|
+ Count: deliver_number, //出最小单位
|
|
2315
|
+ WarehouseInfoId: warehouse.ID,
|
|
2316
|
+ SupplyWarehouseId: warehouse.SupplyWarehouseId,
|
|
2317
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2318
|
+ IsCheck: 1,
|
|
2319
|
+ OverCount: sum_count,
|
|
2320
|
+ AdviceId: advice.ID,
|
|
2321
|
+ OrderId: warehouseout.OrderId,
|
|
2322
|
+ }
|
|
2323
|
+
|
|
2324
|
+ //查询今日该药品该患者是否有出库数据
|
|
2325
|
+ lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
|
|
2326
|
+
|
|
2327
|
+ if lastDrugOutInfo.ID == 0 {
|
|
2328
|
+ errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
2329
|
+ if errOne != nil {
|
|
2330
|
+ return errOne
|
|
2331
|
+ }
|
|
2332
|
+ }
|
|
2333
|
+ if lastDrugOutInfo.ID > 0 {
|
|
2334
|
+ var his_count int64
|
|
2335
|
+ if lastDrugOutInfo.CountUnit == drup.MaxUnit {
|
|
2336
|
+ his_count = lastDrugOutInfo.Count * drup.MinNumber
|
|
2337
|
+ }
|
|
2338
|
+ if lastDrugOutInfo.CountUnit == drup.MinUnit {
|
|
2339
|
+ his_count = lastDrugOutInfo.Count
|
|
2340
|
+ }
|
|
2341
|
+ if deliver_number != his_count {
|
|
2342
|
+ errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
|
|
2343
|
+ if errThree != nil {
|
|
2344
|
+ return errThree
|
|
2345
|
+ }
|
|
2346
|
+ }
|
|
2347
|
+ }
|
|
2348
|
+
|
|
2349
|
+ var out_count int64
|
|
2350
|
+ var cancel_count int64
|
|
2351
|
+ //查询出库数据
|
|
2352
|
+ infoCountList, _ := FindDrugWarehouseOutInfoCount(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
|
|
2353
|
+ //查询退库数据
|
|
2354
|
+ cancelInfoList, _ := FindDrugCancelOutInfo(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
|
|
2355
|
+ for _, item := range infoCountList {
|
|
2356
|
+ out_count += item.Count
|
|
2357
|
+ }
|
|
2358
|
+
|
|
2359
|
+ for _, item := range cancelInfoList {
|
|
2360
|
+ cancel_count += item.Count
|
|
2361
|
+ }
|
|
2362
|
+
|
|
2363
|
+ fmt.Println("deliver_number", deliver_number)
|
|
2364
|
+ fmt.Println("out_count", out_count)
|
|
2365
|
+ fmt.Println("cancel_count", cancel_count)
|
|
2366
|
+ //如果本次出库数据大于历史出库数据 新增1条流水
|
|
2367
|
+ if deliver_number > (out_count - cancel_count) {
|
|
2368
|
+ drugflow := models.DrugFlow{
|
|
2369
|
+ WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
2370
|
+ WarehouseOutId: warehouseout.ID,
|
|
2371
|
+ DrugId: advice.DrugId,
|
|
2372
|
+ Number: warehouse.Number,
|
|
2373
|
+ ProductDate: warehouse.ProductDate,
|
|
2374
|
+ ExpireDate: warehouse.ExpiryDate,
|
|
2375
|
+ Count: deliver_number - (out_count - cancel_count), //按最小单位计算,
|
|
2376
|
+ Price: warehouse.RetailPrice,
|
|
2377
|
+ Status: 1,
|
|
2378
|
+ Ctime: time.Now().Unix(),
|
|
2379
|
+ UserOrgId: orgID,
|
|
2380
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2381
|
+ Dealer: warehouse.Dealer,
|
|
2382
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2383
|
+ MaxUnit: drup.MinUnit,
|
|
2384
|
+ ConsumableType: 15,
|
|
2385
|
+ IsEdit: 1,
|
|
2386
|
+ Creator: advice.ExecutionStaff,
|
|
2387
|
+ IsSys: 1,
|
|
2388
|
+ PatientId: advice.PatientId,
|
|
2389
|
+ SystemTime: advice.AdviceDate,
|
|
2390
|
+ WarehousingDetailId: warehouse.ID,
|
|
2391
|
+ SupplyWarehouseId: warehouse.SupplyWarehouseId,
|
|
2392
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2393
|
+ WarehouseOutDetailId: lastDrugOutInfo.ID,
|
|
2394
|
+ OverCount: sum_count,
|
|
2395
|
+ AdviceId: advice.ID,
|
|
2396
|
+ LastPrice: warehouse.Price,
|
|
2397
|
+ OrderId: warehouseout.OrderId,
|
|
2398
|
+ }
|
|
2399
|
+
|
|
2400
|
+ CreateDrugFlowOne(drugflow)
|
|
2401
|
+ //出库数量相加
|
|
2402
|
+ AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
|
|
2403
|
+
|
|
2404
|
+ }
|
|
2405
|
+
|
|
2406
|
+ //如果本次出库数据小于历史出库数据 新增1条退库流水
|
|
2407
|
+ if deliver_number < (out_count - cancel_count) {
|
|
2408
|
+
|
|
2409
|
+ operation_time := time.Now().Unix()
|
|
2410
|
+
|
|
2411
|
+ ctime := time.Now().Unix()
|
|
2412
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
2413
|
+ timeArr := strings.Split(timeStr, "-")
|
|
2414
|
+ total, _ := FindAllDrugCancelStockTotal(advice.UserOrgId)
|
|
2415
|
+ total = total + 1
|
|
2416
|
+ orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
|
|
2417
|
+ cancelStock := models.DrugCancelStock{
|
|
2418
|
+ OrderNumber: orderNumber,
|
|
2419
|
+ OperaTime: operation_time,
|
|
2420
|
+ OrgId: advice.UserOrgId,
|
|
2421
|
+ Creater: advice.ExecutionStaff,
|
|
2422
|
+ Ctime: ctime,
|
|
2423
|
+ Status: 1,
|
|
2424
|
+ ReturnTime: advice.AdviceDate,
|
|
2425
|
+ Dealer: 0,
|
|
2426
|
+ Manufacturer: 0,
|
|
2427
|
+ Type: 5,
|
|
2428
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2429
|
+ IsCheck: 1,
|
|
2430
|
+ OrderId: warehouseout.OrderId,
|
|
2431
|
+ }
|
|
2432
|
+
|
|
2433
|
+ _, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
|
2434
|
+ if errCode == gorm.ErrRecordNotFound {
|
|
2435
|
+ AddSigleDrugCancelStock(&cancelStock)
|
|
2436
|
+ }
|
|
2437
|
+ lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
|
2438
|
+
|
|
2439
|
+ manufactureName, _ := GetManufactureById(warehouse.Manufacturer)
|
|
2440
|
+ dealer, _ := GetDealerById(warehouse.Dealer)
|
|
2441
|
+ cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
|
|
2442
|
+ cancelStockInfo := models.DrugCancelStockInfo{
|
|
2443
|
+ OrderNumber: cancelInfo.OrderNumber,
|
|
2444
|
+ CancelStockId: lastDrugCancelStock.ID,
|
|
2445
|
+ DrugId: advice.DrugId,
|
|
2446
|
+ Count: (out_count - cancel_count) - deliver_number,
|
|
2447
|
+ Status: 1,
|
|
2448
|
+ Ctime: ctime,
|
|
2449
|
+ OrgId: advice.UserOrgId,
|
|
2450
|
+ Type: 5,
|
|
2451
|
+ Manufacturer: manufactureName.ManufacturerName,
|
|
2452
|
+ Dealer: dealer.DealerName,
|
|
2453
|
+ Total: 0,
|
|
2454
|
+ RetailPrice: warehouse.RetailPrice,
|
|
2455
|
+ RetailTotalPrice: warehouse.RetailTotalPrice,
|
|
2456
|
+ Price: warehouse.Price,
|
|
2457
|
+ RegisterAccount: "",
|
|
2458
|
+ Remark: warehouse.Remark,
|
|
2459
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2460
|
+ MaxUnit: drup.MinUnit,
|
|
2461
|
+ ProductDate: warehouse.ProductDate,
|
|
2462
|
+ ExpiryDate: warehouse.ExpiryDate,
|
|
2463
|
+ BatchNumberId: warehouse.ID,
|
|
2464
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2465
|
+ IsCheck: 1,
|
|
2466
|
+ OrderId: warehouseout.OrderId,
|
|
2467
|
+ }
|
|
2468
|
+ CreatedCancelStock(cancelStockInfo)
|
|
2469
|
+ flow := models.DrugFlow{
|
|
2470
|
+ WarehousingId: warehouse.ID,
|
|
2471
|
+ DrugId: warehouse.DrugId,
|
|
2472
|
+ Number: "",
|
|
2473
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2474
|
+ Count: out_count - cancel_count - deliver_number,
|
|
2475
|
+ UserOrgId: advice.UserOrgId,
|
|
2476
|
+ PatientId: advice.PatientId,
|
|
2477
|
+ SystemTime: advice.AdviceDate,
|
|
2478
|
+ ConsumableType: 16,
|
|
2479
|
+ IsSys: 0,
|
|
2480
|
+ WarehousingOrder: "",
|
|
2481
|
+ WarehouseOutId: 0,
|
|
2482
|
+ WarehouseOutOrderNumber: "",
|
|
2483
|
+ IsEdit: 0,
|
|
2484
|
+ CancelStockId: cancelStock.ID,
|
|
2485
|
+ CancelOrderNumber: cancelStock.OrderNumber,
|
|
2486
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2487
|
+ Dealer: warehouse.Dealer,
|
|
2488
|
+ Creator: advice.ExecutionStaff,
|
|
2489
|
+ UpdateCreator: 0,
|
|
2490
|
+ Status: 1,
|
|
2491
|
+ Ctime: time.Now().Unix(),
|
|
2492
|
+ Mtime: 0,
|
|
2493
|
+ Price: warehouse.RetailPrice,
|
|
2494
|
+ WarehousingDetailId: warehouse.ID,
|
|
2495
|
+ WarehouseOutDetailId: 0,
|
|
2496
|
+ CancelOutDetailId: lastDrugCancelStock.ID,
|
|
2497
|
+ ExpireDate: warehouse.ExpiryDate,
|
|
2498
|
+ ProductDate: warehouse.ProductDate,
|
|
2499
|
+ MaxUnit: drup.MinUnit,
|
|
2500
|
+ MinUnit: "",
|
|
2501
|
+ AdviceId: advice.ID,
|
|
2502
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2503
|
+ LastPrice: warehouse.Price,
|
|
2504
|
+ OverCount: sum_count,
|
|
2505
|
+ OrderId: warehouseout.OrderId,
|
|
2506
|
+ }
|
|
2507
|
+ CreateDrugFlowOne(flow)
|
|
2508
|
+ AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
|
2509
|
+ ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
2510
|
+ }
|
|
2511
|
+
|
|
2512
|
+ //查询是否存在数据
|
|
2513
|
+ details := &models.DrugAutomaticReduceDetail{
|
|
2514
|
+ WarehouseOutId: warehouseout.ID,
|
|
2515
|
+ WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
2516
|
+ PatientId: advice.PatientId,
|
|
2517
|
+ Ctime: time.Now().Unix(),
|
|
2518
|
+ Mtime: time.Now().Unix(),
|
|
2519
|
+ Status: 1,
|
|
2520
|
+ RecordTime: advice.RecordDate,
|
|
2521
|
+ OrgId: orgID,
|
|
2522
|
+ DrugId: advice.DrugId,
|
|
2523
|
+ Count: deliver_number,
|
|
2524
|
+ CountUnit: drup.MinUnit,
|
|
2525
|
+ WarehouseInfoId: warehouse.ID,
|
|
2526
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2527
|
+ AdviceId: advice.ID,
|
|
2528
|
+ }
|
|
2529
|
+ errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
|
2530
|
+ if errTwo != nil {
|
|
2531
|
+ return errTwo
|
|
2532
|
+ }
|
|
2533
|
+ return nil
|
|
2534
|
+
|
|
2535
|
+ } else {
|
|
2536
|
+
|
|
2537
|
+ info := models.XtDrugWarehouseInfo{
|
|
2538
|
+ ID: warehouse.ID,
|
|
2539
|
+ WarehousingId: warehouse.WarehousingId,
|
|
2540
|
+ DrugId: warehouse.DrugId,
|
|
2541
|
+ Number: warehouse.Number,
|
|
2542
|
+ ProductDate: warehouse.ProductDate,
|
|
2543
|
+ ExpiryDate: warehouse.ExpiryDate,
|
|
2544
|
+ WarehousingCount: warehouse.WarehousingCount,
|
|
2545
|
+ Price: warehouse.RetailPrice,
|
|
2546
|
+ TotalPrice: warehouse.TotalPrice,
|
|
2547
|
+ Dealer: warehouse.Dealer,
|
|
2548
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2549
|
+ Remark: warehouse.Remark,
|
|
2550
|
+ Ctime: warehouse.Ctime,
|
|
2551
|
+ Mtime: warehouse.Mtime,
|
|
2552
|
+ Status: 1,
|
|
2553
|
+ OrgId: warehouse.OrgId,
|
|
2554
|
+ IsReturn: warehouse.IsReturn,
|
|
2555
|
+ WarehousingOrder: warehouse.WarehousingOrder,
|
|
2556
|
+ Type: warehouse.Type,
|
|
2557
|
+ RetailPrice: warehouse.RetailPrice,
|
|
2558
|
+ RetailTotalPrice: warehouse.RetailPrice,
|
|
2559
|
+ StockMaxNumber: 0,
|
|
2560
|
+ StockMinNumber: 0,
|
|
2561
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2562
|
+ MaxUnit: warehouse.MaxUnit,
|
|
2563
|
+ WarehousingInfoId: warehouse.WarehousingInfoId,
|
|
2564
|
+ SupplyWarehouseId: warehouse.SupplyWarehouseId,
|
|
2565
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2566
|
+ IsCheck: 1,
|
|
2567
|
+ }
|
|
2568
|
+ //扣减库存
|
|
2569
|
+ errThree := UpDateDrugWarehouseInfoByStock(&info)
|
|
2570
|
+
|
|
2571
|
+ if errThree != nil {
|
|
2572
|
+ return errThree
|
|
2573
|
+ }
|
|
2574
|
+ //查询剩余库存
|
|
2575
|
+ stockInfo, _ := GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, orgID, advice.DrugId)
|
|
2576
|
+ var sum_count int64
|
|
2577
|
+ for _, its := range stockInfo {
|
|
2578
|
+ if its.MaxUnit == drup.MaxUnit {
|
|
2579
|
+ its.StockMaxNumber = its.StockMaxNumber * drup.MinNumber
|
|
2580
|
+ }
|
|
2581
|
+ sum_count += its.StockMaxNumber + its.StockMinNumber
|
|
2582
|
+ }
|
|
2583
|
+
|
|
2584
|
+ // 当该批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
|
|
2585
|
+ warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
|
2586
|
+ WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
2587
|
+ WarehouseOutId: warehouseout.ID,
|
|
2588
|
+ Status: 1,
|
|
2589
|
+ Ctime: time.Now().Unix(),
|
|
2590
|
+ Remark: warehouse.Remark,
|
|
2591
|
+ OrgId: orgID,
|
|
2592
|
+ Type: 5,
|
|
2593
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2594
|
+ Dealer: warehouse.Dealer,
|
|
2595
|
+ IsSys: 1,
|
|
2596
|
+ SysRecordTime: advice.RecordDate,
|
|
2597
|
+ DrugId: advice.DrugId,
|
|
2598
|
+ Number: warehouse.Number,
|
|
2599
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2600
|
+ Price: warehouse.RetailPrice,
|
|
2601
|
+ CountUnit: drup.MinUnit,
|
|
2602
|
+ ProductDate: warehouse.ProductDate,
|
|
2603
|
+ ExpiryDate: warehouse.ExpiryDate,
|
|
2604
|
+ PatientId: advice.PatientId,
|
|
2605
|
+ Count: stock_number,
|
|
2606
|
+ WarehouseInfoId: warehouse.ID,
|
|
2607
|
+ SupplyWarehouseId: warehouse.SupplyWarehouseId,
|
|
2608
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2609
|
+ IsCheck: 1,
|
|
2610
|
+ OverCount: sum_count,
|
|
2611
|
+ AdviceId: advice.ID,
|
|
2612
|
+ OrderId: warehouseout.OrderId,
|
|
2613
|
+ }
|
|
2614
|
+ //查询是否存在出库数据
|
|
2615
|
+ _, errCode := GetSigleDrugWarehouseOutInfo(advice.PatientId, advice.AdviceDate, orgID)
|
|
2616
|
+ if errCode == gorm.ErrRecordNotFound {
|
|
2617
|
+
|
|
2618
|
+ errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
|
2619
|
+ if errOne != nil {
|
|
2620
|
+ return errOne
|
|
2621
|
+ }
|
|
2622
|
+ }
|
|
2623
|
+ if errCode == nil {
|
|
2624
|
+
|
|
2625
|
+ lastDrugOutInfo, _ := GetSigleDrugWarehouseOutInfoOne(advice.PatientId, advice.AdviceDate, orgID)
|
|
2626
|
+ var his_count int64
|
|
2627
|
+ if lastDrugOutInfo.CountUnit == drup.MaxUnit {
|
|
2628
|
+ his_count = lastDrugOutInfo.Count * drup.MinNumber
|
|
2629
|
+ }
|
|
2630
|
+ if lastDrugOutInfo.CountUnit == drup.MinUnit {
|
|
2631
|
+ his_count = lastDrugOutInfo.Count
|
|
2632
|
+ }
|
|
2633
|
+ if deliver_number != his_count {
|
|
2634
|
+ errThree := UpdateSingleDrugWarehouseOutInfoSix(advice.PatientId, advice.AdviceDate, orgID, warehouseOutInfo, advice.ID)
|
|
2635
|
+ if errThree != nil {
|
|
2636
|
+ return errThree
|
|
2637
|
+ }
|
|
2638
|
+ }
|
|
2639
|
+ }
|
|
2640
|
+
|
|
2641
|
+ lastDrugOutInfo, _ := FindLastDrugWarehouseOutInfo(orgID)
|
|
2642
|
+ details := &models.DrugAutomaticReduceDetail{
|
|
2643
|
+ WarehouseOutId: warehouseout.ID,
|
|
2644
|
+ WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
2645
|
+ PatientId: advice.PatientId,
|
|
2646
|
+ Ctime: time.Now().Unix(),
|
|
2647
|
+ Mtime: time.Now().Unix(),
|
|
2648
|
+ Status: 1,
|
|
2649
|
+ RecordTime: advice.RecordDate,
|
|
2650
|
+ OrgId: orgID,
|
|
2651
|
+ DrugId: advice.DrugId,
|
|
2652
|
+ Count: stock_number,
|
|
2653
|
+ CountUnit: drup.MinUnit,
|
|
2654
|
+ WarehouseInfoId: warehouse.ID,
|
|
2655
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2656
|
+ AdviceId: advice.ID,
|
|
2657
|
+ }
|
|
2658
|
+
|
|
2659
|
+ _, errcodeThree := FindDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId)
|
|
2660
|
+ if errcodeThree == gorm.ErrRecordNotFound {
|
|
2661
|
+ errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
|
2662
|
+ if errTwo != nil {
|
|
2663
|
+ return errTwo
|
|
2664
|
+ }
|
|
2665
|
+ }
|
|
2666
|
+ if errcodeThree == nil {
|
|
2667
|
+ UpdateDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId, details)
|
|
2668
|
+ }
|
|
2669
|
+
|
|
2670
|
+ var out_count int64
|
|
2671
|
+ var cancel_count int64
|
|
2672
|
+ //查询出库数据
|
|
2673
|
+ infoCountList, _ := FindDrugWarehouseOutInfoCount(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
|
|
2674
|
+ //查询退库数据
|
|
2675
|
+ cancelInfoList, _ := FindDrugCancelOutInfo(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID)
|
|
2676
|
+ for _, item := range infoCountList {
|
|
2677
|
+ out_count += item.Count
|
|
2678
|
+ }
|
|
2679
|
+
|
|
2680
|
+ for _, item := range cancelInfoList {
|
|
2681
|
+ cancel_count += item.Count
|
|
2682
|
+ }
|
|
2683
|
+
|
|
2684
|
+ //如果本次出库数据大于历史出库数据 新增1条流水
|
|
2685
|
+ if deliver_number > (out_count - cancel_count) {
|
|
2686
|
+
|
|
2687
|
+ drugflow := models.DrugFlow{
|
|
2688
|
+ WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
|
|
2689
|
+ WarehouseOutId: warehouseout.ID,
|
|
2690
|
+ DrugId: advice.DrugId,
|
|
2691
|
+ Number: warehouse.Number,
|
|
2692
|
+ ProductDate: warehouse.ProductDate,
|
|
2693
|
+ ExpireDate: warehouse.ExpiryDate,
|
|
2694
|
+ Count: stock_number,
|
|
2695
|
+ Price: warehouse.RetailPrice,
|
|
2696
|
+ Status: 1,
|
|
2697
|
+ Ctime: time.Now().Unix(),
|
|
2698
|
+ UserOrgId: orgID,
|
|
2699
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2700
|
+ Dealer: warehouse.Dealer,
|
|
2701
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2702
|
+ MaxUnit: drup.MinUnit,
|
|
2703
|
+ ConsumableType: 15,
|
|
2704
|
+ IsEdit: 1,
|
|
2705
|
+ Creator: advice.ExecutionStaff,
|
|
2706
|
+ IsSys: 1,
|
|
2707
|
+ PatientId: advice.PatientId,
|
|
2708
|
+ WarehousingDetailId: warehouse.ID,
|
|
2709
|
+ SupplyWarehouseId: warehouse.SupplyWarehouseId,
|
|
2710
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2711
|
+ WarehouseOutDetailId: lastDrugOutInfo.ID,
|
|
2712
|
+ OverCount: sum_count,
|
|
2713
|
+ AdviceId: advice.ID,
|
|
2714
|
+ LastPrice: warehouse.Price,
|
|
2715
|
+ SystemTime: advice.AdviceDate,
|
|
2716
|
+ OrderId: warehouseout.OrderId,
|
|
2717
|
+ }
|
|
2718
|
+
|
|
2719
|
+ CreateDrugFlowOne(drugflow)
|
|
2720
|
+ //出库数量相加
|
|
2721
|
+ AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
|
|
2722
|
+ }
|
|
2723
|
+
|
|
2724
|
+ if deliver_number < (out_count - cancel_count) {
|
|
2725
|
+ operation_time := time.Now().Unix()
|
|
2726
|
+
|
|
2727
|
+ ctime := time.Now().Unix()
|
|
2728
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
2729
|
+ timeArr := strings.Split(timeStr, "-")
|
|
2730
|
+ total, _ := FindAllDrugCancelStockTotal(advice.UserOrgId)
|
|
2731
|
+ total = total + 1
|
|
2732
|
+ orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
|
|
2733
|
+ cancelStock := models.DrugCancelStock{
|
|
2734
|
+ OrderNumber: orderNumber,
|
|
2735
|
+ OperaTime: operation_time,
|
|
2736
|
+ OrgId: advice.UserOrgId,
|
|
2737
|
+ Creater: advice.ExecutionStaff,
|
|
2738
|
+ Ctime: ctime,
|
|
2739
|
+ Status: 1,
|
|
2740
|
+ ReturnTime: advice.AdviceDate,
|
|
2741
|
+ Dealer: 0,
|
|
2742
|
+ Manufacturer: 0,
|
|
2743
|
+ Type: 5,
|
|
2744
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2745
|
+ IsCheck: 1,
|
|
2746
|
+ OrderId: warehouseout.OrderId,
|
|
2747
|
+ }
|
|
2748
|
+
|
|
2749
|
+ _, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
|
2750
|
+ if errCode == gorm.ErrRecordNotFound {
|
|
2751
|
+ AddSigleDrugCancelStock(&cancelStock)
|
|
2752
|
+ }
|
|
2753
|
+ lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
|
2754
|
+
|
|
2755
|
+ manufactureName, _ := GetManufactureById(warehouse.Manufacturer)
|
|
2756
|
+ dealer, _ := GetDealerById(warehouse.Dealer)
|
|
2757
|
+ cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
|
|
2758
|
+ cancelStockInfo := models.DrugCancelStockInfo{
|
|
2759
|
+ OrderNumber: cancelInfo.OrderNumber,
|
|
2760
|
+ CancelStockId: lastDrugCancelStock.ID,
|
|
2761
|
+ DrugId: advice.DrugId,
|
|
2762
|
+ Count: (out_count - cancel_count) - deliver_number,
|
|
2763
|
+ Status: 1,
|
|
2764
|
+ Ctime: ctime,
|
|
2765
|
+ OrgId: advice.UserOrgId,
|
|
2766
|
+ Type: 5,
|
|
2767
|
+ Manufacturer: manufactureName.ManufacturerName,
|
|
2768
|
+ Dealer: dealer.DealerName,
|
|
2769
|
+ Total: 0,
|
|
2770
|
+ RetailPrice: warehouse.RetailPrice,
|
|
2771
|
+ RetailTotalPrice: warehouse.RetailTotalPrice,
|
|
2772
|
+ Price: warehouse.Price,
|
|
2773
|
+ RegisterAccount: "",
|
|
2774
|
+ Remark: warehouse.Remark,
|
|
2775
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2776
|
+ MaxUnit: drup.MinUnit,
|
|
2777
|
+ ProductDate: warehouse.ProductDate,
|
|
2778
|
+ ExpiryDate: warehouse.ExpiryDate,
|
|
2779
|
+ BatchNumberId: warehouse.ID,
|
|
2780
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2781
|
+ IsCheck: 1,
|
|
2782
|
+ OrderId: warehouseout.OrderId,
|
|
2783
|
+ }
|
|
2784
|
+ CreatedCancelStock(cancelStockInfo)
|
|
2785
|
+ flow := models.DrugFlow{
|
|
2786
|
+ WarehousingId: warehouse.ID,
|
|
2787
|
+ DrugId: warehouse.DrugId,
|
|
2788
|
+ Number: "",
|
|
2789
|
+ BatchNumber: warehouse.BatchNumber,
|
|
2790
|
+ Count: out_count - cancel_count - deliver_number,
|
|
2791
|
+ UserOrgId: advice.UserOrgId,
|
|
2792
|
+ PatientId: advice.PatientId,
|
|
2793
|
+ SystemTime: advice.AdviceDate,
|
|
2794
|
+ ConsumableType: 16,
|
|
2795
|
+ IsSys: 0,
|
|
2796
|
+ WarehousingOrder: "",
|
|
2797
|
+ WarehouseOutId: 0,
|
|
2798
|
+ WarehouseOutOrderNumber: "",
|
|
2799
|
+ IsEdit: 0,
|
|
2800
|
+ CancelStockId: cancelStock.ID,
|
|
2801
|
+ CancelOrderNumber: cancelStock.OrderNumber,
|
|
2802
|
+ Manufacturer: warehouse.Manufacturer,
|
|
2803
|
+ Dealer: warehouse.Dealer,
|
|
2804
|
+ Creator: advice.ExecutionStaff,
|
|
2805
|
+ UpdateCreator: 0,
|
|
2806
|
+ Status: 1,
|
|
2807
|
+ Ctime: time.Now().Unix(),
|
|
2808
|
+ Mtime: 0,
|
|
2809
|
+ Price: warehouse.RetailPrice,
|
|
2810
|
+ WarehousingDetailId: warehouse.ID,
|
|
2811
|
+ WarehouseOutDetailId: 0,
|
|
2812
|
+ CancelOutDetailId: lastDrugCancelStock.ID,
|
|
2813
|
+ ExpireDate: warehouse.ExpiryDate,
|
|
2814
|
+ ProductDate: warehouse.ProductDate,
|
|
2815
|
+ MaxUnit: drup.MinUnit,
|
|
2816
|
+ MinUnit: "",
|
|
2817
|
+ AdviceId: advice.ID,
|
|
2818
|
+ StorehouseId: storeConfig.DrugStorehouseOut,
|
|
2819
|
+ LastPrice: warehouse.Price,
|
|
2820
|
+ OverCount: sum_count,
|
|
2821
|
+ OrderId: warehouseout.OrderId,
|
|
2822
|
+ }
|
|
2823
|
+ CreateDrugFlowOne(flow)
|
|
2824
|
+
|
|
2825
|
+ //退库数量增加
|
|
2826
|
+ AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
|
2827
|
+ ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
2828
|
+ }
|
|
2829
|
+
|
|
2830
|
+ // 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
|
|
2831
|
+ prescribingNumber_two_temp := deliver_number - stock_number
|
|
2832
|
+
|
|
2833
|
+ overPlusNumber := float64(prescribingNumber_two_temp)
|
|
2834
|
+
|
|
2835
|
+ advice.PrescribingNumber = float64(prescribingNumber_two_temp)
|
|
2836
|
+ advice.PrescribingNumberUnit = drup.MinUnit
|
|
2837
|
+
|
|
2838
|
+ HisSettleDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice)
|
|
2839
|
+ }
|
|
2840
|
+
|
|
2841
|
+ return
|
|
2842
|
+}
|