|
@@ -1866,7 +1866,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1866
|
1866
|
|
1867
|
1867
|
patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
|
1868
|
1868
|
|
1869
|
|
- //保存处方出库
|
|
1869
|
+ //自动出库的开关开启
|
1870
|
1870
|
_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
1871
|
1871
|
|
1872
|
1872
|
//自动出库
|
|
@@ -1927,6 +1927,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1927
|
1927
|
}
|
1928
|
1928
|
}
|
1929
|
1929
|
if isMidicine == true {
|
|
1930
|
+
|
1930
|
1931
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
|
1931
|
1932
|
return
|
1932
|
1933
|
}
|
|
@@ -1982,6 +1983,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
1982
|
1983
|
|
1983
|
1984
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
1984
|
1985
|
if drug.ID == 0 {
|
|
1986
|
+
|
|
1987
|
+ tx.Rollback()
|
1985
|
1988
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1986
|
1989
|
return
|
1987
|
1990
|
}
|
|
@@ -1997,18 +2000,20 @@ func (c *HisApiController) CreateHisPrescription() {
|
1997
|
2000
|
//查询该药品是否存在开药记录
|
1998
|
2001
|
advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
|
1999
|
2002
|
|
2000
|
|
- //新增处方
|
|
2003
|
+ //新增处方盘点库存是否充足
|
2001
|
2004
|
if advicelist.ID == 0 {
|
2002
|
2005
|
all_count, _ := strconv.ParseFloat(totals, 64)
|
2003
|
2006
|
if prescribingNumberUnit == drug.MinUnit {
|
2004
|
2007
|
if drug.IsUse != 1 {
|
2005
|
2008
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2006
|
2009
|
if all_count == 0 {
|
|
2010
|
+ tx.Rollback()
|
2007
|
2011
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2008
|
2012
|
return
|
2009
|
2013
|
}
|
2010
|
2014
|
|
2011
|
2015
|
if prescribing_number > all_count {
|
|
2016
|
+ tx.Rollback()
|
2012
|
2017
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2013
|
2018
|
return
|
2014
|
2019
|
}
|
|
@@ -2022,10 +2027,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2022
|
2027
|
if drug.IsUse != 1 {
|
2023
|
2028
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2024
|
2029
|
if all_count == 0 {
|
|
2030
|
+ tx.Rollback()
|
2025
|
2031
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2026
|
2032
|
return
|
2027
|
2033
|
}
|
2028
|
2034
|
if num > all_count {
|
|
2035
|
+ tx.Rollback()
|
2029
|
2036
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2030
|
2037
|
return
|
2031
|
2038
|
}
|
|
@@ -2036,6 +2043,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2036
|
2043
|
}
|
2037
|
2044
|
|
2038
|
2045
|
drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
|
2046
|
+ //不使用保存处方出库
|
2039
|
2047
|
if drugOutConfig.IsOpen != 1 {
|
2040
|
2048
|
//修改处方
|
2041
|
2049
|
for _, advice := range advices {
|
|
@@ -2064,6 +2072,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2064
|
2072
|
|
2065
|
2073
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
2066
|
2074
|
if drug.ID == 0 {
|
|
2075
|
+ tx.Rollback()
|
2067
|
2076
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2068
|
2077
|
return
|
2069
|
2078
|
}
|
|
@@ -2085,10 +2094,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2085
|
2094
|
if drug.IsUse != 1 {
|
2086
|
2095
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2087
|
2096
|
if all_count == 0 {
|
|
2097
|
+ tx.Rollback()
|
2088
|
2098
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2089
|
2099
|
return
|
2090
|
2100
|
}
|
2091
|
2101
|
if prescribing_number > all_count {
|
|
2102
|
+ tx.Rollback()
|
2092
|
2103
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2093
|
2104
|
return
|
2094
|
2105
|
}
|
|
@@ -2101,10 +2112,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2101
|
2112
|
if drug.IsUse != 1 {
|
2102
|
2113
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2103
|
2114
|
if all_count == 0 {
|
|
2115
|
+ tx.Rollback()
|
2104
|
2116
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2105
|
2117
|
return
|
2106
|
2118
|
}
|
2107
|
2119
|
if num > all_count {
|
|
2120
|
+ tx.Rollback()
|
2108
|
2121
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2109
|
2122
|
return
|
2110
|
2123
|
}
|
|
@@ -2146,6 +2159,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2146
|
2159
|
//如果修改的差数量 大于库存数量
|
2147
|
2160
|
if drug.IsUse != 1 {
|
2148
|
2161
|
if (number_count - device_number) > total_count {
|
|
2162
|
+ tx.Rollback()
|
2149
|
2163
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2150
|
2164
|
return
|
2151
|
2165
|
}
|
|
@@ -2197,6 +2211,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2197
|
2211
|
|
2198
|
2212
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
2199
|
2213
|
if drug.ID == 0 {
|
|
2214
|
+ tx.Rollback()
|
2200
|
2215
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2201
|
2216
|
return
|
2202
|
2217
|
}
|
|
@@ -2221,6 +2236,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2221
|
2236
|
//新增处方
|
2222
|
2237
|
if advicelist.ID == 0 {
|
2223
|
2238
|
all_count, _ := strconv.ParseFloat(totals, 64)
|
|
2239
|
+
|
2224
|
2240
|
batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
2225
|
2241
|
|
2226
|
2242
|
if prescribingNumberUnit == drug.MinUnit {
|
|
@@ -2229,10 +2245,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2229
|
2245
|
|
2230
|
2246
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2231
|
2247
|
if all_count == 0 {
|
|
2248
|
+ tx.Rollback()
|
2232
|
2249
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2233
|
2250
|
return
|
2234
|
2251
|
}
|
2235
|
2252
|
if prescribing_number > all_count {
|
|
2253
|
+ tx.Rollback()
|
2236
|
2254
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2237
|
2255
|
return
|
2238
|
2256
|
}
|
|
@@ -2240,6 +2258,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2240
|
2258
|
|
2241
|
2259
|
if adminInfo.CurrentOrgId == 10215 {
|
2242
|
2260
|
if prescribing_number > batch_number_all_count {
|
|
2261
|
+ tx.Rollback()
|
2243
|
2262
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2244
|
2263
|
return
|
2245
|
2264
|
}
|
|
@@ -2253,10 +2272,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2253
|
2272
|
if drug.IsUse != 1 {
|
2254
|
2273
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2255
|
2274
|
if all_count == 0 {
|
|
2275
|
+ tx.Rollback()
|
2256
|
2276
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2257
|
2277
|
return
|
2258
|
2278
|
}
|
2259
|
2279
|
if num > all_count {
|
|
2280
|
+ tx.Rollback()
|
2260
|
2281
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2261
|
2282
|
return
|
2262
|
2283
|
}
|
|
@@ -2264,6 +2285,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2264
|
2285
|
|
2265
|
2286
|
if adminInfo.CurrentOrgId == 10215 {
|
2266
|
2287
|
if num > batch_number_all_count {
|
|
2288
|
+ tx.Rollback()
|
2267
|
2289
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2268
|
2290
|
return
|
2269
|
2291
|
}
|
|
@@ -2302,6 +2324,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2302
|
2324
|
|
2303
|
2325
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
2304
|
2326
|
if drug.ID == 0 {
|
|
2327
|
+ tx.Rollback()
|
2305
|
2328
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
2306
|
2329
|
return
|
2307
|
2330
|
}
|
|
@@ -2329,10 +2352,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2329
|
2352
|
if drug.IsUse != 1 {
|
2330
|
2353
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2331
|
2354
|
if all_count == 0 {
|
|
2355
|
+ tx.Rollback()
|
2332
|
2356
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2333
|
2357
|
return
|
2334
|
2358
|
}
|
2335
|
2359
|
if prescribing_number > all_count {
|
|
2360
|
+ tx.Rollback()
|
2336
|
2361
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2337
|
2362
|
return
|
2338
|
2363
|
}
|
|
@@ -2340,6 +2365,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2340
|
2365
|
|
2341
|
2366
|
if adminInfo.CurrentOrgId == 10215 {
|
2342
|
2367
|
if prescribing_number > batch_number_all_count {
|
|
2368
|
+ tx.Rollback()
|
2343
|
2369
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2344
|
2370
|
return
|
2345
|
2371
|
}
|
|
@@ -2354,10 +2380,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2354
|
2380
|
if drug.IsUse != 1 {
|
2355
|
2381
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2356
|
2382
|
if all_count == 0 {
|
|
2383
|
+ tx.Rollback()
|
2357
|
2384
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2358
|
2385
|
return
|
2359
|
2386
|
}
|
2360
|
2387
|
if num > all_count {
|
|
2388
|
+ tx.Rollback()
|
2361
|
2389
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2362
|
2390
|
return
|
2363
|
2391
|
}
|
|
@@ -2365,6 +2393,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2365
|
2393
|
|
2366
|
2394
|
if adminInfo.CurrentOrgId == 10215 {
|
2367
|
2395
|
if prescribing_number > batch_number_all_count {
|
|
2396
|
+ tx.Rollback()
|
2368
|
2397
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2369
|
2398
|
return
|
2370
|
2399
|
}
|
|
@@ -2412,15 +2441,18 @@ func (c *HisApiController) CreateHisPrescription() {
|
2412
|
2441
|
if drug.IsUse != 1 {
|
2413
|
2442
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2414
|
2443
|
if total_count == 0 {
|
|
2444
|
+ tx.Rollback()
|
2415
|
2445
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2416
|
2446
|
return
|
2417
|
2447
|
}
|
2418
|
2448
|
if (number_count - device_number) > total_count {
|
|
2449
|
+ tx.Rollback()
|
2419
|
2450
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2420
|
2451
|
return
|
2421
|
2452
|
}
|
2422
|
2453
|
|
2423
|
2454
|
if (number_count - device_number) > batch_number_count {
|
|
2455
|
+ tx.Rollback()
|
2424
|
2456
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2425
|
2457
|
return
|
2426
|
2458
|
}
|
|
@@ -2449,6 +2481,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2449
|
2481
|
|
2450
|
2482
|
if out_count > 0 {
|
2451
|
2483
|
if (number_count - device_number) > in_count {
|
|
2484
|
+ tx.Rollback()
|
2452
|
2485
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
|
2453
|
2486
|
return
|
2454
|
2487
|
}
|
|
@@ -2461,6 +2494,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2461
|
2494
|
fmt.Println("sum_in_count", sum_in_count)
|
2462
|
2495
|
//如果修改的数量大于有库存的第一个批次
|
2463
|
2496
|
if number_count > sum_in_count {
|
|
2497
|
+ tx.Rollback()
|
2464
|
2498
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
|
2465
|
2499
|
return
|
2466
|
2500
|
}
|
|
@@ -2584,10 +2618,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2584
|
2618
|
if drug.IsUse != 1 {
|
2585
|
2619
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2586
|
2620
|
if all_count == 0 {
|
|
2621
|
+ tx.Rollback()
|
2587
|
2622
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2588
|
2623
|
return
|
2589
|
2624
|
}
|
2590
|
2625
|
if prescribing_number > all_count {
|
|
2626
|
+ tx.Rollback()
|
2591
|
2627
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2592
|
2628
|
return
|
2593
|
2629
|
}
|
|
@@ -2595,6 +2631,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2595
|
2631
|
|
2596
|
2632
|
if adminInfo.CurrentOrgId == 10215 {
|
2597
|
2633
|
if prescribing_number > batch_number_all_count {
|
|
2634
|
+ tx.Rollback()
|
2598
|
2635
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2599
|
2636
|
return
|
2600
|
2637
|
}
|
|
@@ -2609,10 +2646,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2609
|
2646
|
if drug.IsUse != 1 {
|
2610
|
2647
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2611
|
2648
|
if all_count == 0 {
|
|
2649
|
+ tx.Rollback()
|
2612
|
2650
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2613
|
2651
|
return
|
2614
|
2652
|
}
|
2615
|
2653
|
if num > all_count {
|
|
2654
|
+ tx.Rollback()
|
2616
|
2655
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2617
|
2656
|
return
|
2618
|
2657
|
}
|
|
@@ -2620,6 +2659,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2620
|
2659
|
|
2621
|
2660
|
if adminInfo.CurrentOrgId == 10215 {
|
2622
|
2661
|
if prescribing_number > batch_number_all_count {
|
|
2662
|
+ tx.Rollback()
|
2623
|
2663
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2624
|
2664
|
return
|
2625
|
2665
|
}
|
|
@@ -2659,16 +2699,21 @@ func (c *HisApiController) CreateHisPrescription() {
|
2659
|
2699
|
prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
2660
|
2700
|
number_count = prescribingNumberInt
|
2661
|
2701
|
}
|
|
2702
|
+ fmt.Println("number_count--------------", number_count)
|
|
2703
|
+ fmt.Println("device_number--------------", device_number)
|
|
2704
|
+ fmt.Println("batch_number_count", batch_number_count)
|
2662
|
2705
|
//如果修改的数量大于之前修改的数量
|
2663
|
2706
|
if (number_count - device_number) > 0 {
|
2664
|
2707
|
//如果修改的差数量 大于库存数量
|
2665
|
2708
|
if drug.IsUse != 1 {
|
2666
|
2709
|
if drug.IsProject == 0 || drug.IsProject == 2 {
|
2667
|
2710
|
if total_count == 0 {
|
|
2711
|
+ tx.Rollback()
|
2668
|
2712
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2669
|
2713
|
return
|
2670
|
2714
|
}
|
2671
|
2715
|
if (number_count - device_number) > total_count {
|
|
2716
|
+ tx.Rollback()
|
2672
|
2717
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
2673
|
2718
|
return
|
2674
|
2719
|
}
|
|
@@ -2676,6 +2721,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2676
|
2721
|
|
2677
|
2722
|
if adminInfo.CurrentOrgId == 10215 {
|
2678
|
2723
|
if (number_count - device_number) > batch_number_count {
|
|
2724
|
+ tx.Rollback()
|
2679
|
2725
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
2680
|
2726
|
return
|
2681
|
2727
|
}
|
|
@@ -2703,6 +2749,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
2703
|
2749
|
|
2704
|
2750
|
if out_count > 0 {
|
2705
|
2751
|
if (number_count - device_number) > in_count {
|
|
2752
|
+ tx.Rollback()
|
2706
|
2753
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
|
2707
|
2754
|
return
|
2708
|
2755
|
}
|
|
@@ -2714,11 +2761,13 @@ func (c *HisApiController) CreateHisPrescription() {
|
2714
|
2761
|
warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
2715
|
2762
|
sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
|
2716
|
2763
|
if sum_in_count == 0 {
|
|
2764
|
+ tx.Rollback()
|
2717
|
2765
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
|
2718
|
2766
|
return
|
2719
|
2767
|
}
|
2720
|
2768
|
//如果修改的数量大于有库存的第一个批次
|
2721
|
2769
|
if number_count > sum_in_count {
|
|
2770
|
+ tx.Rollback()
|
2722
|
2771
|
c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
|
2723
|
2772
|
return
|
2724
|
2773
|
}
|
|
@@ -2790,10 +2839,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2790
|
2839
|
stock_counts := strconv.FormatInt(stock_count, 10)
|
2791
|
2840
|
stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
|
2792
|
2841
|
if stock_total_count == 0 {
|
|
2842
|
+ tx.Rollback()
|
2793
|
2843
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2794
|
2844
|
return
|
2795
|
2845
|
}
|
2796
|
2846
|
if totals > stock_total_count {
|
|
2847
|
+ tx.Rollback()
|
2797
|
2848
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2798
|
2849
|
return
|
2799
|
2850
|
}
|
|
@@ -2817,10 +2868,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2817
|
2868
|
|
2818
|
2869
|
//库存不足
|
2819
|
2870
|
if stock_count == 0 {
|
|
2871
|
+ tx.Rollback()
|
2820
|
2872
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2821
|
2873
|
return
|
2822
|
2874
|
}
|
2823
|
2875
|
if (parsetotal - count) > stock_count {
|
|
2876
|
+ tx.Rollback()
|
2824
|
2877
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2825
|
2878
|
return
|
2826
|
2879
|
}
|
|
@@ -2896,10 +2949,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
2896
|
2949
|
stock_counts := strconv.FormatInt(stock_count, 10)
|
2897
|
2950
|
stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
|
2898
|
2951
|
if stock_total_count == 0 {
|
|
2952
|
+ tx.Rollback()
|
2899
|
2953
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2900
|
2954
|
return
|
2901
|
2955
|
}
|
2902
|
2956
|
if totals > stock_total_count {
|
|
2957
|
+ tx.Rollback()
|
2903
|
2958
|
c.ServeDynamicFailJsonSend(project_name + "库存不足")
|
2904
|
2959
|
return
|
2905
|
2960
|
}
|
|
@@ -3117,7 +3172,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
3117
|
3172
|
var adviceList []models.HisDoctorAdviceInfo
|
3118
|
3173
|
var projectList []models.HisPrescriptionProject
|
3119
|
3174
|
|
3120
|
|
- if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 {
|
|
3175
|
+ if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 {
|
3121
|
3176
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
3122
|
3177
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
3123
|
3178
|
|
|
@@ -3308,16 +3363,23 @@ func (c *HisApiController) CreateHisPrescription() {
|
3308
|
3363
|
s.Price = lastWarehouse.RetailPrice
|
3309
|
3364
|
}
|
3310
|
3365
|
if s.Price == 0 {
|
3311
|
|
- s.Price = lastWarehouse.RetailPrice
|
|
3366
|
+ if lastWarehouse.ID == 0 {
|
|
3367
|
+ lastWarehouseTwo, _ := service.FindLastDrugWarehousingInfoByIDTwo(s.DrugId, storeConfig.DrugStorehouseOut)
|
|
3368
|
+ s.Price = lastWarehouseTwo.RetailPrice
|
|
3369
|
+ }
|
|
3370
|
+
|
3312
|
3371
|
}
|
3313
|
3372
|
}
|
3314
|
3373
|
|
3315
|
3374
|
//查询保存处方出库开关是否打开
|
3316
|
3375
|
drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
|
3376
|
+
|
3317
|
3377
|
if drugOutConfig.IsOpen == 1 {
|
|
3378
|
+
|
3318
|
3379
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
|
3319
|
3380
|
// 查询该药品最后一次出库记录
|
3320
|
3381
|
druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
|
|
3382
|
+
|
3321
|
3383
|
if len(druginfo) > 0 {
|
3322
|
3384
|
//回退库存
|
3323
|
3385
|
for _, it := range druginfo {
|
|
@@ -3337,8 +3399,10 @@ func (c *HisApiController) CreateHisPrescription() {
|
3337
|
3399
|
|
3338
|
3400
|
}
|
3339
|
3401
|
}
|
|
3402
|
+
|
3340
|
3403
|
//删除记录
|
3341
|
|
- service.DeleteDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
|
|
3404
|
+ service.DeleteNewDrugAutoWarehouseSeven(s.DrugId, patient_id, recordDateTime, s.ID)
|
|
3405
|
+
|
3342
|
3406
|
}
|
3343
|
3407
|
|
3344
|
3408
|
service.CreateHisDoctorAdviceOne(&s, tx)
|
|
@@ -3472,8 +3536,55 @@ func (c *HisApiController) CreateHisPrescription() {
|
3472
|
3536
|
timeFormat := tempTime.Format("20060102150405")
|
3473
|
3537
|
s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
|
3474
|
3538
|
service.CreateHisDoctorAdviceOne(&s, tx)
|
3475
|
|
-
|
|
3539
|
+ //list, _ := service.GetHisToday(s.PatientId, s.AdviceDate, s.UserOrgId, s.DrugId, tx)
|
|
3540
|
+ //var count_total int64
|
|
3541
|
+ //var count_one int64
|
|
3542
|
+ //for _, its := range list {
|
|
3543
|
+ // baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
|
|
3544
|
+ // if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
|
|
3545
|
+ // prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
|
|
3546
|
+ // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3547
|
+ // count_total += prescribingNumberSevenTy * baseDrug.MinNumber
|
|
3548
|
+ // }
|
|
3549
|
+ //
|
|
3550
|
+ // if its.PrescribingNumberUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
|
|
3551
|
+ // prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
|
|
3552
|
+ // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3553
|
+ // count_total += prescribingNumberSevenTy
|
|
3554
|
+ // }
|
|
3555
|
+ //
|
|
3556
|
+ // if its.PrescribingNumberUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
|
|
3557
|
+ // prescribingNumberTenty := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
|
|
3558
|
+ // prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
|
|
3559
|
+ // count_total += prescribingNumberSevenTy
|
|
3560
|
+ // }
|
|
3561
|
+ //
|
|
3562
|
+ // drugAuto, _ := service.GetLastDrugAuto(its.ID, its.DrugId, its.AdviceDate, its.PatientId,its.UserOrgId, tx)
|
|
3563
|
+ //
|
|
3564
|
+ // if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
|
|
3565
|
+ //
|
|
3566
|
+ // count_one = drugAuto.Count * baseDrug.MinNumber
|
|
3567
|
+ // }
|
|
3568
|
+ //
|
|
3569
|
+ // if drugAuto.CountUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
|
|
3570
|
+ //
|
|
3571
|
+ // count_one = drugAuto.Count
|
|
3572
|
+ // }
|
|
3573
|
+ //
|
|
3574
|
+ // if drugAuto.CountUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
|
|
3575
|
+ //
|
|
3576
|
+ // count_one = drugAuto.Count
|
|
3577
|
+ // }
|
|
3578
|
+ // fmt.Println("count_one==================", count_one)
|
|
3579
|
+ // fmt.Println("count_total==================", count_total)
|
|
3580
|
+ // if count_total != count_one {
|
|
3581
|
+ //
|
|
3582
|
+ // service.UpdateTodayHis(its.DrugId, its.AdviceDate, its.PatientId, its.UserOrgId, baseDrug.MinUnit, count_total, its.ID, tx)
|
|
3583
|
+ // }
|
|
3584
|
+ //
|
|
3585
|
+ //}
|
3476
|
3586
|
tx.Commit()
|
|
3587
|
+
|
3477
|
3588
|
keySix := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
|
3478
|
3589
|
redis.Set(keySix, "", time.Second)
|
3479
|
3590
|
keyFive := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
|
|
@@ -3859,265 +3970,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
3859
|
3970
|
}
|
3860
|
3971
|
|
3861
|
3972
|
}
|
3862
|
|
-
|
3863
|
|
- //查询今日该患者开的药品处方
|
3864
|
|
- //hisdoctorlist, _ := service.GetNewHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId, tx)
|
3865
|
|
- //drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
3866
|
|
-
|
3867
|
|
- //药品出库
|
3868
|
|
- //if drugOutConfig.IsOpen == 1 {
|
3869
|
|
- // for _, item := range hisdoctorlist {
|
3870
|
|
- // drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
|
3871
|
|
- //
|
3872
|
|
- // // 查询该药品最后一次出库记录
|
3873
|
|
- // druginfo, _ := service.GetLastNewDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID, tx)
|
3874
|
|
- //
|
3875
|
|
- // if len(druginfo) > 0 {
|
3876
|
|
- // //回退库存
|
3877
|
|
- // for _, it := range druginfo {
|
3878
|
|
- //
|
3879
|
|
- // if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
3880
|
|
- //
|
3881
|
|
- // service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
|
3882
|
|
- //
|
3883
|
|
- // }
|
3884
|
|
- // if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
3885
|
|
- //
|
3886
|
|
- // service.ModifyNewDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
|
3887
|
|
- //
|
3888
|
|
- // }
|
3889
|
|
- // if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
|
3890
|
|
- //
|
3891
|
|
- // service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
|
3892
|
|
- //
|
3893
|
|
- // }
|
3894
|
|
- // }
|
3895
|
|
- // }
|
3896
|
|
- //
|
3897
|
|
- // //删除记录
|
3898
|
|
- // service.DeleteNewDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID, tx)
|
3899
|
|
- // //查询最后一次数据
|
3900
|
|
- // if drugOutConfig.IsOpen == 1 {
|
3901
|
|
- // //出库
|
3902
|
|
- // if drug.IsUse == 2 {
|
3903
|
|
- // creater := adminInfo.AdminUser.Id
|
3904
|
|
- //
|
3905
|
|
- // service.NewHisDrugsDelivery(item.UserOrgId, creater, item, tx)
|
3906
|
|
- //
|
3907
|
|
- // }
|
3908
|
|
- //
|
3909
|
|
- // //更新字典里面的库存
|
3910
|
|
- // stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
|
3911
|
|
- // var sum_count int64
|
3912
|
|
- // for _, its := range stockInfo {
|
3913
|
|
- // baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
|
3914
|
|
- // if its.MaxUnit == baseDrug.MaxUnit {
|
3915
|
|
- // its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
|
3916
|
|
- // }
|
3917
|
|
- // sum_count += its.StockMaxNumber + its.StockMinNumber
|
3918
|
|
- // }
|
3919
|
|
- // //更新基础库存
|
3920
|
|
- // service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
|
3921
|
|
- // //剩余库存
|
3922
|
|
- // service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
|
3923
|
|
- //
|
3924
|
|
- // over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
|
3925
|
|
- // service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
|
3926
|
|
- //
|
3927
|
|
- // }
|
3928
|
|
- // }
|
3929
|
|
- //}
|
3930
|
|
-
|
3931
|
|
- //耗材保存处方出库
|
3932
|
|
- //if goodOutConfig.IsOpen == 1 {
|
3933
|
|
- //
|
3934
|
|
- // //查询今日耗材出库数量
|
3935
|
|
- // hisgoodlist, _ := service.GetHisGoodList(patient_id, recordDateTime, adminInfo.CurrentOrgId)
|
3936
|
|
- //
|
3937
|
|
- // for _, item := range hisgoodlist {
|
3938
|
|
- //
|
3939
|
|
- // //查询历史出库数据
|
3940
|
|
- // flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
|
3941
|
|
- // var out_count_five int64
|
3942
|
|
- // for _, item := range flowGood {
|
3943
|
|
- // out_count_five += item.Count
|
3944
|
|
- // }
|
3945
|
|
- //
|
3946
|
|
- // parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
|
3947
|
|
- //
|
3948
|
|
- // if out_count_five != parseIntCount {
|
3949
|
|
- //
|
3950
|
|
- // //查询耗材最后一次出库记录
|
3951
|
|
- // wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(item.ProjectId, patient_id, recordDateTime, item.ID)
|
3952
|
|
- // //查询默认出库仓库库存
|
3953
|
|
- // storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
3954
|
|
- // if len(wareOut) > 0 {
|
3955
|
|
- //
|
3956
|
|
- // for _, it := range wareOut {
|
3957
|
|
- // //回退库存
|
3958
|
|
- // service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
|
3959
|
|
- //
|
3960
|
|
- // //删除出库记录
|
3961
|
|
- // service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
|
3962
|
|
- //
|
3963
|
|
- // }
|
3964
|
|
- // }
|
3965
|
|
- //
|
3966
|
|
- // timeStr := time.Now().Format("2006-01-02")
|
3967
|
|
- // timeArr := strings.Split(timeStr, "-")
|
3968
|
|
- // total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
|
3969
|
|
- //
|
3970
|
|
- // total = total + 1
|
3971
|
|
- // warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
3972
|
|
- // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
3973
|
|
- // number = number + total
|
3974
|
|
- // warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
|
3975
|
|
- //
|
3976
|
|
- // operation_time := time.Now().Unix()
|
3977
|
|
- // creater := c.GetAdminUserInfo().AdminUser.Id
|
3978
|
|
- //
|
3979
|
|
- // recordDateStr := time.Now().Format("2006-01-02")
|
3980
|
|
- // recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
|
3981
|
|
- // nowtime := recordDate.Unix()
|
3982
|
|
- // warehouseOut := models.WarehouseOut{
|
3983
|
|
- // WarehouseOutOrderNumber: warehousing_out_order,
|
3984
|
|
- // OperationTime: operation_time,
|
3985
|
|
- // OrgId: adminInfo.CurrentOrgId,
|
3986
|
|
- // Creater: creater,
|
3987
|
|
- // Ctime: time.Now().Unix(),
|
3988
|
|
- // Status: 1,
|
3989
|
|
- // WarehouseOutTime: nowtime,
|
3990
|
|
- // Type: 1,
|
3991
|
|
- // StorehouseId: storeConfig.StorehouseOutInfo,
|
3992
|
|
- // IsCheck: 1,
|
3993
|
|
- // IsSys: 1,
|
3994
|
|
- // }
|
3995
|
|
- // //查询是否生成出库单
|
3996
|
|
- // out, _ := service.FindPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
|
3997
|
|
- //
|
3998
|
|
- // if out.ID == 0 {
|
3999
|
|
- // service.AddSigleWarehouseOut(&warehouseOut)
|
4000
|
|
- // }
|
4001
|
|
- //
|
4002
|
|
- // lastOut, _ := service.FindLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime)
|
4003
|
|
- //
|
4004
|
|
- // goodObj, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
|
4005
|
|
- // houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
|
4006
|
|
- //
|
4007
|
|
- // dialyPrepareOne := models.DialysisBeforePrepare{
|
4008
|
|
- // GoodTypeId: goodObj.GoodTypeId,
|
4009
|
|
- // GoodId: item.ProjectId,
|
4010
|
|
- // PatientId: item.PatientId,
|
4011
|
|
- // RecordDate: item.RecordDate,
|
4012
|
|
- // UserOrgId: adminInfo.CurrentOrgId,
|
4013
|
|
- // Count: parseIntCount,
|
4014
|
|
- // Ctime: time.Now().Unix(),
|
4015
|
|
- // Creater: creater,
|
4016
|
|
- // Status: 1,
|
4017
|
|
- // StorehouseId: houseConfig.StorehouseOutInfo,
|
4018
|
|
- // ProjectId: item.ID,
|
4019
|
|
- // }
|
4020
|
|
- // goodinfo, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
|
4021
|
|
- // if goodinfo.IsUser == 2 || goodinfo.IsUser == 0 {
|
4022
|
|
- //
|
4023
|
|
- // //查询历史出库数据
|
4024
|
|
- // flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
|
4025
|
|
- // var out_count int64
|
4026
|
|
- // for _, item := range flowGood {
|
4027
|
|
- // out_count += item.Count
|
4028
|
|
- // }
|
4029
|
|
- //
|
4030
|
|
- // //如果历史数和当前数据不想等才进行退库出库
|
4031
|
|
- // if out_count != parseIntCount {
|
4032
|
|
- // service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
|
4033
|
|
- //
|
4034
|
|
- // service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
|
4035
|
|
- // detail := models.AutomaticReduceDetail{
|
4036
|
|
- // WarehouseOutId: 0,
|
4037
|
|
- // WarehouseOutOrderNumber: "",
|
4038
|
|
- // PatientId: item.PatientId,
|
4039
|
|
- // Ctime: time.Now().Unix(),
|
4040
|
|
- // Mtime: 0,
|
4041
|
|
- // Status: 1,
|
4042
|
|
- // RecordTime: item.RecordDate,
|
4043
|
|
- // OrgId: item.UserOrgId,
|
4044
|
|
- // GoodId: item.ProjectId,
|
4045
|
|
- // GoodTypeId: 0,
|
4046
|
|
- // Count: parseIntCount,
|
4047
|
|
- // Type: 0,
|
4048
|
|
- // ProjectId: item.ID,
|
4049
|
|
- // StorehouseId: 0,
|
4050
|
|
- // }
|
4051
|
|
- //
|
4052
|
|
- // service.CreateAutoDetail(detail)
|
4053
|
|
- //
|
4054
|
|
- // //查询剩余库存
|
4055
|
|
- // goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
|
4056
|
|
- // var sum_count int64
|
4057
|
|
- // for _, item := range goodList {
|
4058
|
|
- // sum_count += item.StockCount
|
4059
|
|
- // }
|
4060
|
|
- //
|
4061
|
|
- // //更新剩余库存
|
4062
|
|
- // service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
|
4063
|
|
- //
|
4064
|
|
- // //耗材
|
4065
|
|
- // service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
|
4066
|
|
- // }
|
4067
|
|
- //
|
4068
|
|
- // }
|
4069
|
|
- //
|
4070
|
|
- // if goodinfo.IsUser == 1 && goodinfo.IsWarehouse == 1 {
|
4071
|
|
- // //查询历史出库数据
|
4072
|
|
- // flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
|
4073
|
|
- // var out_count int64
|
4074
|
|
- // for _, item := range flowGood {
|
4075
|
|
- // out_count += item.Count
|
4076
|
|
- // }
|
4077
|
|
- // //如果历史数和当前数据不想等才进行退库出库
|
4078
|
|
- // if out_count != parseIntCount {
|
4079
|
|
- // service.ConsumablePrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount)
|
4080
|
|
- //
|
4081
|
|
- // service.UpdateAutomaticReduce(item.PatientId, item.RecordDate, item.ProjectId, item.ID)
|
4082
|
|
- // detail := models.AutomaticReduceDetail{
|
4083
|
|
- // WarehouseOutId: 0,
|
4084
|
|
- // WarehouseOutOrderNumber: "",
|
4085
|
|
- // PatientId: item.PatientId,
|
4086
|
|
- // Ctime: time.Now().Unix(),
|
4087
|
|
- // Mtime: 0,
|
4088
|
|
- // Status: 1,
|
4089
|
|
- // RecordTime: item.RecordDate,
|
4090
|
|
- // OrgId: item.UserOrgId,
|
4091
|
|
- // GoodId: item.ProjectId,
|
4092
|
|
- // GoodTypeId: 0,
|
4093
|
|
- // Count: parseIntCount,
|
4094
|
|
- // Type: 0,
|
4095
|
|
- // ProjectId: item.ID,
|
4096
|
|
- // StorehouseId: 0,
|
4097
|
|
- // }
|
4098
|
|
- //
|
4099
|
|
- // service.CreateAutoDetail(detail)
|
4100
|
|
- //
|
4101
|
|
- // //查询剩余库存
|
4102
|
|
- // goodList, _ := service.GetAllGoodSumCount(item.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo)
|
4103
|
|
- // var sum_count int64
|
4104
|
|
- // for _, item := range goodList {
|
4105
|
|
- // sum_count += item.StockCount
|
4106
|
|
- // }
|
4107
|
|
- //
|
4108
|
|
- // //更新剩余库存
|
4109
|
|
- // service.UpdateGoodFlushCount(houseConfig.StorehouseOutInfo, item.ProjectId, adminInfo.CurrentOrgId, sum_count)
|
4110
|
|
- //
|
4111
|
|
- // //耗材
|
4112
|
|
- // service.UpdateGoodSumCountSeven(sum_count, item.ProjectId, adminInfo.CurrentOrgId)
|
4113
|
|
- // }
|
4114
|
|
- //
|
4115
|
|
- // }
|
4116
|
|
- //
|
4117
|
|
- // }
|
4118
|
|
- // }
|
4119
|
|
- //}
|
4120
|
3973
|
}
|
|
3974
|
+
|
4121
|
3975
|
tx.Commit()
|
4122
|
3976
|
if err == nil {
|
4123
|
3977
|
c.ServeSuccessJSON(map[string]interface{}{
|