|
@@ -1261,6 +1261,20 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
|
1261
|
1261
|
// 药品自动出库 递归方式
|
1262
|
1262
|
func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
|
1263
|
1263
|
|
|
1264
|
+ drugError := models.XtDrugError{
|
|
1265
|
+ UserOrgId: orgID,
|
|
1266
|
+ DrugId: advice.DrugId,
|
|
1267
|
+ RecordDate: advice.AdviceDate,
|
|
1268
|
+ PatientId: advice.PatientId,
|
|
1269
|
+ Remark: "进入出库页面",
|
|
1270
|
+ Status: 1,
|
|
1271
|
+ Ctime: time.Now().Unix(),
|
|
1272
|
+ Mtime: 0,
|
|
1273
|
+ SumCount: 0,
|
|
1274
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1275
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1276
|
+ }
|
|
1277
|
+ CreateDrugError(drugError)
|
1264
|
1278
|
// 判断处方里药品单位是拆零单位还是包装单位, 如果是包装单位,则根据规格,将包装数量转为拆零数量
|
1265
|
1279
|
var deliver_number int64 = 0
|
1266
|
1280
|
var stock_number int64 = 0
|
|
@@ -1306,28 +1320,39 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1306
|
1320
|
warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, storeConfig.DrugStorehouseOut)
|
1307
|
1321
|
|
1308
|
1322
|
if err != nil {
|
1309
|
|
-
|
|
1323
|
+ drugError := models.XtDrugError{
|
|
1324
|
+ UserOrgId: orgID,
|
|
1325
|
+ DrugId: advice.DrugId,
|
|
1326
|
+ RecordDate: advice.AdviceDate,
|
|
1327
|
+ PatientId: advice.PatientId,
|
|
1328
|
+ Remark: "查询库存报错",
|
|
1329
|
+ Status: 1,
|
|
1330
|
+ Ctime: time.Now().Unix(),
|
|
1331
|
+ Mtime: 0,
|
|
1332
|
+ SumCount: 0,
|
|
1333
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1334
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1335
|
+ }
|
|
1336
|
+ CreateDrugError(drugError)
|
1310
|
1337
|
return err
|
1311
|
1338
|
}
|
1312
|
|
- // 将该批次的剩余库存数量转换为拆零数量
|
|
1339
|
+
|
1313
|
1340
|
// 将该批次的剩余库存数量转换为拆零数量
|
1314
|
1341
|
if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
|
1315
|
|
- //fmt.Println("进来1")
|
|
1342
|
+
|
1316
|
1343
|
stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
|
1317
|
|
- //fmt.Println("剩余库存1", stock_number)
|
|
1344
|
+
|
1318
|
1345
|
}
|
1319
|
1346
|
if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
|
1320
|
|
- //fmt.Println("进来2")
|
|
1347
|
+
|
1321
|
1348
|
stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
|
1322
|
|
- //fmt.Println("剩余库存2", stock_number)
|
|
1349
|
+
|
1323
|
1350
|
}
|
1324
|
1351
|
if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
|
1325
|
|
- //fmt.Println("进来3")
|
|
1352
|
+
|
1326
|
1353
|
stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
|
1327
|
|
- //fmt.Println("剩余库存3", stock_number)
|
|
1354
|
+
|
1328
|
1355
|
}
|
1329
|
|
- //fmt.Println("剩余库存23333333333333333333333333333wo", stock_number)
|
1330
|
|
- //fmt.Println("出库数量2333333333333333333333333333333333333wo", deliver_number)
|
1331
|
1356
|
|
1332
|
1357
|
// 当库存数量大于或等于出库数量的话,则正常出库该批次
|
1333
|
1358
|
if stock_number >= deliver_number {
|
|
@@ -1367,10 +1392,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1367
|
1392
|
|
1368
|
1393
|
warehouse.Mtime = time.Now().Unix()
|
1369
|
1394
|
|
1370
|
|
- fmt.Println("minnU目标而332322323323233223323223我", minNumber)
|
1371
|
|
- fmt.Println("max_number232232332232322wo", maxNumber)
|
1372
|
|
- fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
|
1373
|
|
-
|
1374
|
1395
|
if warehouse.StockMinNumber < minNumber {
|
1375
|
1396
|
|
1376
|
1397
|
warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
|
|
@@ -1416,6 +1437,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1416
|
1437
|
//扣减库存数据
|
1417
|
1438
|
errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
|
1418
|
1439
|
if errThree != nil {
|
|
1440
|
+ drugError := models.XtDrugError{
|
|
1441
|
+ UserOrgId: orgID,
|
|
1442
|
+ DrugId: advice.DrugId,
|
|
1443
|
+ RecordDate: advice.AdviceDate,
|
|
1444
|
+ PatientId: advice.PatientId,
|
|
1445
|
+ Remark: "扣减库存失败",
|
|
1446
|
+ Status: 1,
|
|
1447
|
+ Ctime: time.Now().Unix(),
|
|
1448
|
+ Mtime: 0,
|
|
1449
|
+ SumCount: 0,
|
|
1450
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1451
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1452
|
+ }
|
|
1453
|
+ CreateDrugError(drugError)
|
1419
|
1454
|
return errThree
|
1420
|
1455
|
}
|
1421
|
1456
|
|
|
@@ -1464,6 +1499,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1464
|
1499
|
if lastDrugOutInfo.ID == 0 {
|
1465
|
1500
|
errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1466
|
1501
|
if errOne != nil {
|
|
1502
|
+ drugError := models.XtDrugError{
|
|
1503
|
+ UserOrgId: orgID,
|
|
1504
|
+ DrugId: advice.DrugId,
|
|
1505
|
+ RecordDate: advice.AdviceDate,
|
|
1506
|
+ PatientId: advice.PatientId,
|
|
1507
|
+ Remark: "创建出库单失败",
|
|
1508
|
+ Status: 1,
|
|
1509
|
+ Ctime: time.Now().Unix(),
|
|
1510
|
+ Mtime: 0,
|
|
1511
|
+ SumCount: 0,
|
|
1512
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1513
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1514
|
+ }
|
|
1515
|
+ CreateDrugError(drugError)
|
1467
|
1516
|
return errOne
|
1468
|
1517
|
}
|
1469
|
1518
|
}
|
|
@@ -1478,6 +1527,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1478
|
1527
|
if deliver_number != his_count {
|
1479
|
1528
|
errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
|
1480
|
1529
|
if errThree != nil {
|
|
1530
|
+ drugError := models.XtDrugError{
|
|
1531
|
+ UserOrgId: orgID,
|
|
1532
|
+ DrugId: advice.DrugId,
|
|
1533
|
+ RecordDate: advice.AdviceDate,
|
|
1534
|
+ PatientId: advice.PatientId,
|
|
1535
|
+ Remark: "更新出库单失败",
|
|
1536
|
+ Status: 1,
|
|
1537
|
+ Ctime: time.Now().Unix(),
|
|
1538
|
+ Mtime: 0,
|
|
1539
|
+ SumCount: 0,
|
|
1540
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1541
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1542
|
+ }
|
|
1543
|
+ CreateDrugError(drugError)
|
1481
|
1544
|
return errThree
|
1482
|
1545
|
}
|
1483
|
1546
|
}
|
|
@@ -1497,12 +1560,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1497
|
1560
|
cancel_count += item.Count
|
1498
|
1561
|
}
|
1499
|
1562
|
|
1500
|
|
- //fmt.Println("deliver_number", deliver_number)
|
1501
|
|
- //fmt.Println("out_count", out_count)
|
1502
|
|
- //fmt.Println("cancel_count", cancel_count)
|
1503
|
|
- //
|
1504
|
|
- //fmt.Println("出库数据", deliver_number)
|
1505
|
|
- //fmt.Println("出库流水---------------------", out_count, cancel_count)
|
1506
|
1563
|
//如果本次出库数据大于历史出库数据 新增1条流水
|
1507
|
1564
|
if deliver_number >= (out_count - cancel_count) {
|
1508
|
1565
|
drugflow := models.DrugFlow{
|
|
@@ -1536,9 +1593,43 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1536
|
1593
|
LastPrice: warehouse.Price,
|
1537
|
1594
|
}
|
1538
|
1595
|
|
1539
|
|
- CreateDrugFlowOne(drugflow)
|
|
1596
|
+ errThreeTy := CreateDrugFlowOne(drugflow)
|
|
1597
|
+
|
|
1598
|
+ if errThreeTy != nil {
|
|
1599
|
+ drugError := models.XtDrugError{
|
|
1600
|
+ UserOrgId: orgID,
|
|
1601
|
+ DrugId: advice.DrugId,
|
|
1602
|
+ RecordDate: advice.AdviceDate,
|
|
1603
|
+ PatientId: advice.PatientId,
|
|
1604
|
+ Remark: "创建流水失败",
|
|
1605
|
+ Status: 1,
|
|
1606
|
+ Ctime: time.Now().Unix(),
|
|
1607
|
+ Mtime: 0,
|
|
1608
|
+ SumCount: 0,
|
|
1609
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1610
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1611
|
+ }
|
|
1612
|
+ CreateDrugError(drugError)
|
|
1613
|
+ }
|
1540
|
1614
|
//出库数量相加
|
1541
|
|
- AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
|
|
1615
|
+ errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
|
|
1616
|
+
|
|
1617
|
+ if errThreeTys != nil {
|
|
1618
|
+ drugError := models.XtDrugError{
|
|
1619
|
+ UserOrgId: orgID,
|
|
1620
|
+ DrugId: advice.DrugId,
|
|
1621
|
+ RecordDate: advice.AdviceDate,
|
|
1622
|
+ PatientId: advice.PatientId,
|
|
1623
|
+ Remark: "出库数量相加失败",
|
|
1624
|
+ Status: 1,
|
|
1625
|
+ Ctime: time.Now().Unix(),
|
|
1626
|
+ Mtime: 0,
|
|
1627
|
+ SumCount: 0,
|
|
1628
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1629
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1630
|
+ }
|
|
1631
|
+ CreateDrugError(drugError)
|
|
1632
|
+ }
|
1542
|
1633
|
|
1543
|
1634
|
}
|
1544
|
1635
|
|
|
@@ -1570,7 +1661,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1570
|
1661
|
|
1571
|
1662
|
_, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
1572
|
1663
|
if errCode == gorm.ErrRecordNotFound {
|
1573
|
|
- AddSigleDrugCancelStock(&cancelStock)
|
|
1664
|
+ errCode := AddSigleDrugCancelStock(&cancelStock)
|
|
1665
|
+ if errCode != nil {
|
|
1666
|
+ drugError := models.XtDrugError{
|
|
1667
|
+ UserOrgId: orgID,
|
|
1668
|
+ DrugId: advice.DrugId,
|
|
1669
|
+ RecordDate: advice.AdviceDate,
|
|
1670
|
+ PatientId: advice.PatientId,
|
|
1671
|
+ Remark: "创建退库单失败",
|
|
1672
|
+ Status: 1,
|
|
1673
|
+ Ctime: time.Now().Unix(),
|
|
1674
|
+ Mtime: 0,
|
|
1675
|
+ SumCount: 0,
|
|
1676
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1677
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1678
|
+ }
|
|
1679
|
+ CreateDrugError(drugError)
|
|
1680
|
+ }
|
1574
|
1681
|
}
|
1575
|
1682
|
lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
1576
|
1683
|
|
|
@@ -1602,7 +1709,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1602
|
1709
|
StorehouseId: storeConfig.DrugStorehouseOut,
|
1603
|
1710
|
IsCheck: 1,
|
1604
|
1711
|
}
|
1605
|
|
- CreatedCancelStock(cancelStockInfo)
|
|
1712
|
+ errCodes := CreatedCancelStock(cancelStockInfo)
|
|
1713
|
+ if errCodes != nil {
|
|
1714
|
+ drugError := models.XtDrugError{
|
|
1715
|
+ UserOrgId: orgID,
|
|
1716
|
+ DrugId: advice.DrugId,
|
|
1717
|
+ RecordDate: advice.AdviceDate,
|
|
1718
|
+ PatientId: advice.PatientId,
|
|
1719
|
+ Remark: "创建退库单失败",
|
|
1720
|
+ Status: 1,
|
|
1721
|
+ Ctime: time.Now().Unix(),
|
|
1722
|
+ Mtime: 0,
|
|
1723
|
+ SumCount: 0,
|
|
1724
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1725
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1726
|
+ }
|
|
1727
|
+ CreateDrugError(drugError)
|
|
1728
|
+ }
|
1606
|
1729
|
flow := models.DrugFlow{
|
1607
|
1730
|
WarehousingId: warehouse.ID,
|
1608
|
1731
|
DrugId: warehouse.DrugId,
|
|
@@ -1640,9 +1763,57 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1640
|
1763
|
LastPrice: warehouse.Price,
|
1641
|
1764
|
OverCount: sum_count,
|
1642
|
1765
|
}
|
1643
|
|
- CreateDrugFlowOne(flow)
|
1644
|
|
- AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
1645
|
|
- ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
1766
|
+ errCodeflow := CreateDrugFlowOne(flow)
|
|
1767
|
+ if errCodeflow != nil {
|
|
1768
|
+ drugError := models.XtDrugError{
|
|
1769
|
+ UserOrgId: orgID,
|
|
1770
|
+ DrugId: advice.DrugId,
|
|
1771
|
+ RecordDate: advice.AdviceDate,
|
|
1772
|
+ PatientId: advice.PatientId,
|
|
1773
|
+ Remark: "退库流水创建失败",
|
|
1774
|
+ Status: 1,
|
|
1775
|
+ Ctime: time.Now().Unix(),
|
|
1776
|
+ Mtime: 0,
|
|
1777
|
+ SumCount: 0,
|
|
1778
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1779
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1780
|
+ }
|
|
1781
|
+ CreateDrugError(drugError)
|
|
1782
|
+ }
|
|
1783
|
+ errCodesum := AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
|
1784
|
+ if errCodesum != nil {
|
|
1785
|
+ drugError := models.XtDrugError{
|
|
1786
|
+ UserOrgId: orgID,
|
|
1787
|
+ DrugId: advice.DrugId,
|
|
1788
|
+ RecordDate: advice.AdviceDate,
|
|
1789
|
+ PatientId: advice.PatientId,
|
|
1790
|
+ Remark: "增加退库数量失败",
|
|
1791
|
+ Status: 1,
|
|
1792
|
+ Ctime: time.Now().Unix(),
|
|
1793
|
+ Mtime: 0,
|
|
1794
|
+ SumCount: 0,
|
|
1795
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1796
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1797
|
+ }
|
|
1798
|
+ CreateDrugError(drugError)
|
|
1799
|
+ }
|
|
1800
|
+ errCodereduce := ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
1801
|
+ if errCodereduce != nil {
|
|
1802
|
+ drugError := models.XtDrugError{
|
|
1803
|
+ UserOrgId: orgID,
|
|
1804
|
+ DrugId: advice.DrugId,
|
|
1805
|
+ RecordDate: advice.AdviceDate,
|
|
1806
|
+ PatientId: advice.PatientId,
|
|
1807
|
+ Remark: "减少出库数量失败",
|
|
1808
|
+ Status: 1,
|
|
1809
|
+ Ctime: time.Now().Unix(),
|
|
1810
|
+ Mtime: 0,
|
|
1811
|
+ SumCount: 0,
|
|
1812
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1813
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1814
|
+ }
|
|
1815
|
+ CreateDrugError(drugError)
|
|
1816
|
+ }
|
1646
|
1817
|
}
|
1647
|
1818
|
|
1648
|
1819
|
//查询是否存在数据
|
|
@@ -1664,6 +1835,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1664
|
1835
|
}
|
1665
|
1836
|
errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
1666
|
1837
|
if errTwo != nil {
|
|
1838
|
+ drugError := models.XtDrugError{
|
|
1839
|
+ UserOrgId: orgID,
|
|
1840
|
+ DrugId: advice.DrugId,
|
|
1841
|
+ RecordDate: advice.AdviceDate,
|
|
1842
|
+ PatientId: advice.PatientId,
|
|
1843
|
+ Remark: "新增自动出库表失败",
|
|
1844
|
+ Status: 1,
|
|
1845
|
+ Ctime: time.Now().Unix(),
|
|
1846
|
+ Mtime: 0,
|
|
1847
|
+ SumCount: 0,
|
|
1848
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1849
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1850
|
+ }
|
|
1851
|
+ CreateDrugError(drugError)
|
1667
|
1852
|
return errTwo
|
1668
|
1853
|
}
|
1669
|
1854
|
return nil
|
|
@@ -1705,6 +1890,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1705
|
1890
|
errThree := UpDateDrugWarehouseInfoByStock(&info)
|
1706
|
1891
|
|
1707
|
1892
|
if errThree != nil {
|
|
1893
|
+ drugError := models.XtDrugError{
|
|
1894
|
+ UserOrgId: orgID,
|
|
1895
|
+ DrugId: advice.DrugId,
|
|
1896
|
+ RecordDate: advice.AdviceDate,
|
|
1897
|
+ PatientId: advice.PatientId,
|
|
1898
|
+ Remark: "第二批次扣减库存失败",
|
|
1899
|
+ Status: 1,
|
|
1900
|
+ Ctime: time.Now().Unix(),
|
|
1901
|
+ Mtime: 0,
|
|
1902
|
+ SumCount: 0,
|
|
1903
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1904
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1905
|
+ }
|
|
1906
|
+ CreateDrugError(drugError)
|
1708
|
1907
|
return errThree
|
1709
|
1908
|
}
|
1710
|
1909
|
//查询剩余库存
|
|
@@ -1749,9 +1948,22 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1749
|
1948
|
//查询是否存在出库数据
|
1750
|
1949
|
_, errCode := GetSigleDrugWarehouseOutInfo(advice.PatientId, advice.AdviceDate, orgID)
|
1751
|
1950
|
if errCode == gorm.ErrRecordNotFound {
|
1752
|
|
- fmt.Println("j你俩3233223323232323233wo")
|
1753
|
1951
|
errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1754
|
1952
|
if errOne != nil {
|
|
1953
|
+ drugError := models.XtDrugError{
|
|
1954
|
+ UserOrgId: orgID,
|
|
1955
|
+ DrugId: advice.DrugId,
|
|
1956
|
+ RecordDate: advice.AdviceDate,
|
|
1957
|
+ PatientId: advice.PatientId,
|
|
1958
|
+ Remark: "创建出库表失败",
|
|
1959
|
+ Status: 1,
|
|
1960
|
+ Ctime: time.Now().Unix(),
|
|
1961
|
+ Mtime: 0,
|
|
1962
|
+ SumCount: 0,
|
|
1963
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1964
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1965
|
+ }
|
|
1966
|
+ CreateDrugError(drugError)
|
1755
|
1967
|
return errOne
|
1756
|
1968
|
}
|
1757
|
1969
|
}
|
|
@@ -1768,6 +1980,20 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1768
|
1980
|
if deliver_number != his_count {
|
1769
|
1981
|
errThree := UpdateSingleDrugWarehouseOutInfoSix(advice.PatientId, advice.AdviceDate, orgID, warehouseOutInfo, advice.ID)
|
1770
|
1982
|
if errThree != nil {
|
|
1983
|
+ drugError := models.XtDrugError{
|
|
1984
|
+ UserOrgId: orgID,
|
|
1985
|
+ DrugId: advice.DrugId,
|
|
1986
|
+ RecordDate: advice.AdviceDate,
|
|
1987
|
+ PatientId: advice.PatientId,
|
|
1988
|
+ Remark: "更新出库表失败",
|
|
1989
|
+ Status: 1,
|
|
1990
|
+ Ctime: time.Now().Unix(),
|
|
1991
|
+ Mtime: 0,
|
|
1992
|
+ SumCount: 0,
|
|
1993
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1994
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1995
|
+ }
|
|
1996
|
+ CreateDrugError(drugError)
|
1771
|
1997
|
return errThree
|
1772
|
1998
|
}
|
1773
|
1999
|
}
|
|
@@ -1795,11 +2021,42 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1795
|
2021
|
if errcodeThree == gorm.ErrRecordNotFound {
|
1796
|
2022
|
errTwo := AddSigleDrugAutoReduceRecordInfo(details)
|
1797
|
2023
|
if errTwo != nil {
|
|
2024
|
+ drugError := models.XtDrugError{
|
|
2025
|
+ UserOrgId: orgID,
|
|
2026
|
+ DrugId: advice.DrugId,
|
|
2027
|
+ RecordDate: advice.AdviceDate,
|
|
2028
|
+ PatientId: advice.PatientId,
|
|
2029
|
+ Remark: "第二批次新增自动出库表失败",
|
|
2030
|
+ Status: 1,
|
|
2031
|
+ Ctime: time.Now().Unix(),
|
|
2032
|
+ Mtime: 0,
|
|
2033
|
+ SumCount: 0,
|
|
2034
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2035
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2036
|
+ }
|
|
2037
|
+ CreateDrugError(drugError)
|
1798
|
2038
|
return errTwo
|
1799
|
2039
|
}
|
1800
|
2040
|
}
|
1801
|
2041
|
if errcodeThree == nil {
|
1802
|
|
- UpdateDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId, details)
|
|
2042
|
+ errThreeauto := UpdateDrugAutoReduceRecordInfo(advice.PatientId, advice.RecordDate, advice.DrugId, details)
|
|
2043
|
+ if errThreeauto != nil {
|
|
2044
|
+ drugError := models.XtDrugError{
|
|
2045
|
+ UserOrgId: orgID,
|
|
2046
|
+ DrugId: advice.DrugId,
|
|
2047
|
+ RecordDate: advice.AdviceDate,
|
|
2048
|
+ PatientId: advice.PatientId,
|
|
2049
|
+ Remark: "第二批次更新自动出库表失败",
|
|
2050
|
+ Status: 1,
|
|
2051
|
+ Ctime: time.Now().Unix(),
|
|
2052
|
+ Mtime: 0,
|
|
2053
|
+ SumCount: 0,
|
|
2054
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2055
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2056
|
+ }
|
|
2057
|
+ CreateDrugError(drugError)
|
|
2058
|
+ }
|
|
2059
|
+
|
1803
|
2060
|
}
|
1804
|
2061
|
|
1805
|
2062
|
var out_count int64
|
|
@@ -1855,9 +2112,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1855
|
2112
|
AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
|
1856
|
2113
|
}
|
1857
|
2114
|
|
1858
|
|
- fmt.Println("libai", out_count)
|
1859
|
|
- fmt.Println("cancel", cancel_count)
|
1860
|
|
- fmt.Println("deliver_number", deliver_number)
|
1861
|
2115
|
if deliver_number < (out_count - cancel_count) {
|
1862
|
2116
|
operation_time := time.Now().Unix()
|
1863
|
2117
|
|
|
@@ -1884,7 +2138,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1884
|
2138
|
|
1885
|
2139
|
_, errCode := FindDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
1886
|
2140
|
if errCode == gorm.ErrRecordNotFound {
|
1887
|
|
- AddSigleDrugCancelStock(&cancelStock)
|
|
2141
|
+ errCodeCancel := AddSigleDrugCancelStock(&cancelStock)
|
|
2142
|
+ if errCodeCancel != nil {
|
|
2143
|
+ drugError := models.XtDrugError{
|
|
2144
|
+ UserOrgId: orgID,
|
|
2145
|
+ DrugId: advice.DrugId,
|
|
2146
|
+ RecordDate: advice.AdviceDate,
|
|
2147
|
+ PatientId: advice.PatientId,
|
|
2148
|
+ Remark: "第二批次新增流水表失败",
|
|
2149
|
+ Status: 1,
|
|
2150
|
+ Ctime: time.Now().Unix(),
|
|
2151
|
+ Mtime: 0,
|
|
2152
|
+ SumCount: 0,
|
|
2153
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2154
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2155
|
+ }
|
|
2156
|
+ CreateDrugError(drugError)
|
|
2157
|
+ }
|
1888
|
2158
|
}
|
1889
|
2159
|
lastDrugCancelStock, _ := FindLastDrugCancelStock(advice.AdviceDate, advice.UserOrgId)
|
1890
|
2160
|
|
|
@@ -1916,7 +2186,23 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1916
|
2186
|
StorehouseId: storeConfig.DrugStorehouseOut,
|
1917
|
2187
|
IsCheck: 1,
|
1918
|
2188
|
}
|
1919
|
|
- CreatedCancelStock(cancelStockInfo)
|
|
2189
|
+ errCodeCancel := CreatedCancelStock(cancelStockInfo)
|
|
2190
|
+ if errCodeCancel != nil {
|
|
2191
|
+ drugError := models.XtDrugError{
|
|
2192
|
+ UserOrgId: orgID,
|
|
2193
|
+ DrugId: advice.DrugId,
|
|
2194
|
+ RecordDate: advice.AdviceDate,
|
|
2195
|
+ PatientId: advice.PatientId,
|
|
2196
|
+ Remark: "第二批次创建自动退库表失败",
|
|
2197
|
+ Status: 1,
|
|
2198
|
+ Ctime: time.Now().Unix(),
|
|
2199
|
+ Mtime: 0,
|
|
2200
|
+ SumCount: 0,
|
|
2201
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2202
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2203
|
+ }
|
|
2204
|
+ CreateDrugError(drugError)
|
|
2205
|
+ }
|
1920
|
2206
|
flow := models.DrugFlow{
|
1921
|
2207
|
WarehousingId: warehouse.ID,
|
1922
|
2208
|
DrugId: warehouse.DrugId,
|
|
@@ -1954,11 +2240,59 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
|
1954
|
2240
|
LastPrice: warehouse.Price,
|
1955
|
2241
|
OverCount: sum_count,
|
1956
|
2242
|
}
|
1957
|
|
- CreateDrugFlowOne(flow)
|
|
2243
|
+ errCodeFlows := CreateDrugFlowOne(flow)
|
|
2244
|
+ if errCodeFlows != nil {
|
|
2245
|
+ drugError := models.XtDrugError{
|
|
2246
|
+ UserOrgId: orgID,
|
|
2247
|
+ DrugId: advice.DrugId,
|
|
2248
|
+ RecordDate: advice.AdviceDate,
|
|
2249
|
+ PatientId: advice.PatientId,
|
|
2250
|
+ Remark: "第二批次创建自动退库流水表失败",
|
|
2251
|
+ Status: 1,
|
|
2252
|
+ Ctime: time.Now().Unix(),
|
|
2253
|
+ Mtime: 0,
|
|
2254
|
+ SumCount: 0,
|
|
2255
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2256
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2257
|
+ }
|
|
2258
|
+ CreateDrugError(drugError)
|
|
2259
|
+ }
|
1958
|
2260
|
|
1959
|
2261
|
//退库数量增加
|
1960
|
|
- AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
1961
|
|
- ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
2262
|
+ errCodeFlows = AddCancelSumCountOne(storeConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, flow.Count)
|
|
2263
|
+ if errCodeFlows != nil {
|
|
2264
|
+ drugError := models.XtDrugError{
|
|
2265
|
+ UserOrgId: orgID,
|
|
2266
|
+ DrugId: advice.DrugId,
|
|
2267
|
+ RecordDate: advice.AdviceDate,
|
|
2268
|
+ PatientId: advice.PatientId,
|
|
2269
|
+ Remark: "第二批次创建自动退库流水表失败",
|
|
2270
|
+ Status: 1,
|
|
2271
|
+ Ctime: time.Now().Unix(),
|
|
2272
|
+ Mtime: 0,
|
|
2273
|
+ SumCount: 0,
|
|
2274
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2275
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2276
|
+ }
|
|
2277
|
+ CreateDrugError(drugError)
|
|
2278
|
+ }
|
|
2279
|
+ errCodereduce := ReduceDrugCountTwo(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, flow.Count)
|
|
2280
|
+ if errCodereduce != nil {
|
|
2281
|
+ drugError := models.XtDrugError{
|
|
2282
|
+ UserOrgId: orgID,
|
|
2283
|
+ DrugId: advice.DrugId,
|
|
2284
|
+ RecordDate: advice.AdviceDate,
|
|
2285
|
+ PatientId: advice.PatientId,
|
|
2286
|
+ Remark: "第二批次减少库存表失败",
|
|
2287
|
+ Status: 1,
|
|
2288
|
+ Ctime: time.Now().Unix(),
|
|
2289
|
+ Mtime: 0,
|
|
2290
|
+ SumCount: 0,
|
|
2291
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
2292
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
2293
|
+ }
|
|
2294
|
+ CreateDrugError(drugError)
|
|
2295
|
+ }
|
1962
|
2296
|
}
|
1963
|
2297
|
|
1964
|
2298
|
// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
|