|
@@ -274,15 +274,27 @@ func (c *StockManagerApiController) CreateWarehouse() {
|
274
|
274
|
ctime := time.Now().Unix()
|
275
|
275
|
adminUserInfo := c.GetAdminUserInfo()
|
276
|
276
|
|
|
277
|
+ // 开始外部循环的事务
|
|
278
|
+ db := service.XTWriteDB()
|
|
279
|
+ tx := db.Begin()
|
|
280
|
+
|
|
281
|
+ // 在函数结束时处理事务回滚
|
|
282
|
+ defer func() {
|
|
283
|
+ if r := recover(); r != nil {
|
|
284
|
+ tx.Rollback()
|
|
285
|
+ }
|
|
286
|
+ }()
|
|
287
|
+
|
277
|
288
|
warehousingDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", warehousing_time)
|
278
|
289
|
if parseDateErr != nil {
|
279
|
290
|
c.ErrorLog("日期(%v)解析错误:%v", warehousingDate, parseDateErr)
|
280
|
291
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
281
|
292
|
return
|
282
|
293
|
}
|
|
294
|
+
|
283
|
295
|
timeStr := time.Now().Format("2006-01-02")
|
284
|
296
|
timeArr := strings.Split(timeStr, "-")
|
285
|
|
- total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
|
|
297
|
+ total, _ := service.FindNewAllWarehouseTotal(adminUserInfo.CurrentOrgId, tx)
|
286
|
298
|
total = total + 1
|
287
|
299
|
warehousing_order := "RKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
|
288
|
300
|
operation_time := time.Now().Unix()
|
|
@@ -300,12 +312,14 @@ func (c *StockManagerApiController) CreateWarehouse() {
|
300
|
312
|
IsCheck: 2,
|
301
|
313
|
}
|
302
|
314
|
if warehousing_info_id == 0 {
|
303
|
|
- service.AddSigleWarehouse(&warehousing)
|
|
315
|
+
|
|
316
|
+ service.AddNewSigleWarehouse(&warehousing, tx)
|
304
|
317
|
}
|
305
|
318
|
if warehousing_info_id > 0 {
|
306
|
|
- service.UpdateWarehouse(warehousing_info_id, storehouse_id)
|
|
319
|
+
|
|
320
|
+ service.UpdateNewWarehouse(warehousing_info_id, storehouse_id, tx)
|
307
|
321
|
}
|
308
|
|
- info, _ := service.FindLastWarehousingSix(adminUserInfo.CurrentOrgId)
|
|
322
|
+ info, _ := service.FindNewLastWarehousingSix(adminUserInfo.CurrentOrgId, tx)
|
309
|
323
|
dataBody := make(map[string]interface{}, 0)
|
310
|
324
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
311
|
325
|
if err != nil {
|
|
@@ -446,16 +460,19 @@ func (c *StockManagerApiController) CreateWarehouse() {
|
446
|
460
|
|
447
|
461
|
for _, item := range warehousingInfo {
|
448
|
462
|
if item.ID == 0 {
|
449
|
|
- service.CreatedWarehouseingDetail(item)
|
|
463
|
+ service.CreatedNewWarehouseingDetail(item, tx)
|
450
|
464
|
}
|
451
|
465
|
if item.ID > 0 {
|
452
|
|
- service.UpdateWarehouseDetail(item, item.ID)
|
|
466
|
+
|
|
467
|
+ service.UpdateNewWarehouseDetail(item, item.ID, tx)
|
453
|
468
|
}
|
454
|
469
|
|
455
|
470
|
}
|
456
|
471
|
|
457
|
472
|
//查询入库数据
|
458
|
|
- list, _ := service.GetGoodWarehouseInfoById(info.ID, info.OrgId)
|
|
473
|
+ list, _ := service.GetNewGoodWarehouseInfoById(info.ID, info.OrgId, tx)
|
|
474
|
+
|
|
475
|
+ tx.Commit()
|
459
|
476
|
dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
|
460
|
477
|
manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
461
|
478
|
|
|
@@ -560,6 +577,18 @@ func (c *StockManagerApiController) GetWarehouseInfoList() {
|
560
|
577
|
}
|
561
|
578
|
}
|
562
|
579
|
func (c *StockManagerApiController) EditWarehouse() {
|
|
580
|
+
|
|
581
|
+ // 开始外部循环的事务
|
|
582
|
+ db := service.XTWriteDB()
|
|
583
|
+ tx := db.Begin()
|
|
584
|
+
|
|
585
|
+ // 在函数结束时处理事务回滚
|
|
586
|
+ defer func() {
|
|
587
|
+ if r := recover(); r != nil {
|
|
588
|
+ tx.Rollback()
|
|
589
|
+ }
|
|
590
|
+ }()
|
|
591
|
+
|
563
|
592
|
warehousing_time := c.GetString("warehousing_time")
|
564
|
593
|
id, _ := c.GetInt64("id", 0)
|
565
|
594
|
types, _ := c.GetInt64("type", 0)
|
|
@@ -580,7 +609,7 @@ func (c *StockManagerApiController) EditWarehouse() {
|
580
|
609
|
return
|
581
|
610
|
}
|
582
|
611
|
|
583
|
|
- warehouse, _ := service.FindWarehousingById(id)
|
|
612
|
+ warehouse, _ := service.FindNewWarehousingById(id, tx)
|
584
|
613
|
|
585
|
614
|
warehousing := models.Warehousing{
|
586
|
615
|
WarehousingOrder: warehouse.WarehousingOrder,
|
|
@@ -593,7 +622,7 @@ func (c *StockManagerApiController) EditWarehouse() {
|
593
|
622
|
StorehouseId: storehouse_id,
|
594
|
623
|
}
|
595
|
624
|
|
596
|
|
- service.EditWarehousing(warehousing)
|
|
625
|
+ service.EditNewWarehousing(warehousing, tx)
|
597
|
626
|
|
598
|
627
|
dataBody := make(map[string]interface{}, 0)
|
599
|
628
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
@@ -605,8 +634,6 @@ func (c *StockManagerApiController) EditWarehouse() {
|
605
|
634
|
|
606
|
635
|
var warehousingInfo []*models.WarehousingInfo
|
607
|
636
|
var upDateWarehousingInfo []*models.WarehousingInfo
|
608
|
|
- var stockFlow []*models.VmStockFlow
|
609
|
|
-
|
610
|
637
|
if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
|
611
|
638
|
thisStockIn, _ := dataBody["stockIn"].([]interface{})
|
612
|
639
|
if len(thisStockIn) > 0 {
|
|
@@ -753,44 +780,22 @@ func (c *StockManagerApiController) EditWarehouse() {
|
753
|
780
|
}
|
754
|
781
|
upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
|
755
|
782
|
|
756
|
|
- flow := &models.VmStockFlow{
|
757
|
|
- WarehousingOrder: warehousing.WarehousingOrder,
|
758
|
|
- WarehousingId: id,
|
759
|
|
- GoodId: good_id,
|
760
|
|
- Number: number,
|
761
|
|
- ProductDate: productDates,
|
762
|
|
- ExpireDate: expiryDates,
|
763
|
|
- Count: warehousing_count,
|
764
|
|
- Price: price,
|
765
|
|
- Status: 1,
|
766
|
|
- Ctime: ctime,
|
767
|
|
- UserOrgId: adminUserInfo.CurrentOrgId,
|
768
|
|
- Manufacturer: manufacturer,
|
769
|
|
- Dealer: dealer,
|
770
|
|
- LicenseNumber: license_number,
|
771
|
|
- IsEdit: 2,
|
772
|
|
- Creator: adminUserInfo.AdminUser.Id,
|
773
|
|
- SystemTime: ctime,
|
774
|
|
- ConsumableType: 1,
|
775
|
|
- WarehousingDetailId: warehouseInfo.ID,
|
776
|
|
- StorehouseId: storehouse_id,
|
777
|
|
- RegisterNumber: register_number,
|
778
|
|
- GoodCode: good_code,
|
779
|
|
- }
|
780
|
|
-
|
781
|
|
- stockFlow = append(stockFlow, flow)
|
782
|
783
|
}
|
783
|
784
|
}
|
784
|
785
|
}
|
785
|
786
|
}
|
786
|
787
|
var errs error
|
787
|
788
|
if len(warehousingInfo) > 0 {
|
788
|
|
- errs = service.CreateWarehousingInfo(warehousingInfo)
|
|
789
|
+
|
|
790
|
+ errs = service.CreateNewWarehousingInfo(warehousingInfo, tx)
|
789
|
791
|
}
|
790
|
792
|
|
791
|
793
|
if len(upDateWarehousingInfo) > 0 {
|
792
|
794
|
for _, item := range upDateWarehousingInfo {
|
793
|
|
- service.UpdateWarehouseInfoByGoodIdOne(item, item.ID)
|
|
795
|
+ if item.ID > 0 {
|
|
796
|
+ service.UpdateNewWarehouseInfoByGoodIdOne(item, item.ID, tx)
|
|
797
|
+ }
|
|
798
|
+
|
794
|
799
|
}
|
795
|
800
|
}
|
796
|
801
|
|
|
@@ -800,7 +805,8 @@ func (c *StockManagerApiController) EditWarehouse() {
|
800
|
805
|
return
|
801
|
806
|
}
|
802
|
807
|
|
803
|
|
- list, _ := service.GetAllStockInList(id, adminUserInfo.CurrentOrgId)
|
|
808
|
+ list, _ := service.GetNewAllStockInList(id, adminUserInfo.CurrentOrgId, tx)
|
|
809
|
+ tx.Commit()
|
804
|
810
|
manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
805
|
811
|
dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
|
806
|
812
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -1258,18 +1264,29 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1258
|
1264
|
return
|
1259
|
1265
|
}
|
1260
|
1266
|
|
|
1267
|
+ // 开始外部循环的事务
|
|
1268
|
+ db := service.XTWriteDB()
|
|
1269
|
+ tx := db.Begin()
|
|
1270
|
+
|
|
1271
|
+ // 在函数结束时处理事务回滚
|
|
1272
|
+ defer func() {
|
|
1273
|
+ if r := recover(); r != nil {
|
|
1274
|
+ tx.Rollback()
|
|
1275
|
+ }
|
|
1276
|
+ }()
|
|
1277
|
+
|
1261
|
1278
|
if warehouseOut_id == 0 {
|
1262
|
1279
|
//查询是否生成出库单
|
1263
|
|
- warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order)
|
|
1280
|
+ warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order, tx)
|
1264
|
1281
|
|
1265
|
1282
|
if warehouseOutObj.ID == 0 {
|
1266
|
|
- service.AddSigleWarehouseOut(&warehouseOut)
|
|
1283
|
+ service.AddSigleWarehouseOut(&warehouseOut, tx)
|
1267
|
1284
|
}
|
1268
|
1285
|
|
1269
|
1286
|
}
|
1270
|
1287
|
|
1271
|
1288
|
if warehouseOut_id > 0 {
|
1272
|
|
- service.UpdateSingleWarehoseOut(warehouseOut_id, storehouse_id)
|
|
1289
|
+ service.UpdateSingleWarehoseOut(warehouseOut_id, storehouse_id, tx)
|
1273
|
1290
|
}
|
1274
|
1291
|
|
1275
|
1292
|
var warehousingOutInfo []*models.WarehouseOutInfo
|
|
@@ -1407,7 +1424,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1407
|
1424
|
}
|
1408
|
1425
|
}
|
1409
|
1426
|
|
1410
|
|
- goodWarehouseOut, _ := service.GetLastGoodWarehouseOutTwenty(adminUserInfo.CurrentOrgId)
|
|
1427
|
+ goodWarehouseOut, _ := service.GetLastGoodWarehouseOutTwentyOne(adminUserInfo.CurrentOrgId, tx)
|
1411
|
1428
|
|
1412
|
1429
|
if len(warehousingOutInfo) > 0 {
|
1413
|
1430
|
for _, it := range warehousingOutInfo {
|
|
@@ -1445,24 +1462,25 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1445
|
1462
|
if it.ID == 0 {
|
1446
|
1463
|
|
1447
|
1464
|
//查询改耗材是否出库
|
1448
|
|
- outInfo, _ := service.GetGoodsIsExsit(it.GoodId, it.SysRecordTime, it.OrgId, goodWarehouseOut.ID)
|
|
1465
|
+ outInfo, _ := service.GetGoodsIsExsit(it.GoodId, it.SysRecordTime, it.OrgId, goodWarehouseOut.ID, tx)
|
1449
|
1466
|
if outInfo.ID == 0 {
|
1450
|
|
- service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
|
1467
|
+ service.AddSigleWarehouseOutInfo(warehouseOutInfo, tx)
|
1451
|
1468
|
}
|
1452
|
1469
|
|
1453
|
1470
|
}
|
1454
|
1471
|
if it.ID > 0 {
|
1455
|
|
- service.ModifyWarehouseOutInfo(it.ID, warehouseOutInfo)
|
|
1472
|
+ service.ModifyWarehouseOutInfo(it.ID, warehouseOutInfo, tx)
|
1456
|
1473
|
}
|
1457
|
1474
|
}
|
1458
|
1475
|
}
|
1459
|
1476
|
|
1460
|
1477
|
appId := adminUserInfo.CurrentAppId
|
1461
|
1478
|
|
1462
|
|
- warehouseOutInfoList, _ := service.GetLastGoodWarehouseOutInfo(adminUserInfo.CurrentOrgId, goodWarehouseOut.ID)
|
|
1479
|
+ warehouseOutInfoList, _ := service.GetLastGoodWarehouseOutInfo(adminUserInfo.CurrentOrgId, goodWarehouseOut.ID, tx)
|
1463
|
1480
|
manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
|
1464
|
1481
|
dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
|
1465
|
1482
|
doctorList, _ := service.GetAllDoctorListSix(adminUserInfo.CurrentOrgId, appId)
|
|
1483
|
+ tx.Commit()
|
1466
|
1484
|
c.ServeSuccessJSON(map[string]interface{}{
|
1467
|
1485
|
"msg": "2",
|
1468
|
1486
|
"good_name": "",
|
|
@@ -1618,7 +1636,7 @@ func (this *StockManagerApiController) DeleteWarehouseOutInfo() {
|
1618
|
1636
|
func (c *StockManagerApiController) GetWarehouseOutInfoList() {
|
1619
|
1637
|
id, _ := c.GetInt64("id", 0)
|
1620
|
1638
|
warehouseOutInfo, _ := service.FindWarehouseOutInfoById(id)
|
1621
|
|
- warehouseOut, _ := service.FindWareHouseOutById(id)
|
|
1639
|
+ warehouseOut, _ := service.FindWareHouseOutByIdOne(id)
|
1622
|
1640
|
adminUserInfo := c.GetAdminUserInfo()
|
1623
|
1641
|
orgId := adminUserInfo.CurrentOrgId
|
1624
|
1642
|
wareoutList, _ := service.GetWareOutInfoById(id, orgId)
|
|
@@ -1630,6 +1648,7 @@ func (c *StockManagerApiController) GetWarehouseOutInfoList() {
|
1630
|
1648
|
|
1631
|
1649
|
}
|
1632
|
1650
|
func (c *StockManagerApiController) EditWarehouseOut() {
|
|
1651
|
+
|
1633
|
1652
|
warehouse_out_time := c.GetString("warehouse_out_time")
|
1634
|
1653
|
id, _ := c.GetInt64("id", 0)
|
1635
|
1654
|
types, _ := c.GetInt64("type", 0)
|
|
@@ -1650,7 +1669,18 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1650
|
1669
|
return
|
1651
|
1670
|
}
|
1652
|
1671
|
|
1653
|
|
- warehouseOut, _ := service.FindWareHouseOutById(id)
|
|
1672
|
+ // 开始外部循环的事务
|
|
1673
|
+ db := service.XTWriteDB()
|
|
1674
|
+ tx := db.Begin()
|
|
1675
|
+
|
|
1676
|
+ // 在函数结束时处理事务回滚
|
|
1677
|
+ defer func() {
|
|
1678
|
+ if r := recover(); r != nil {
|
|
1679
|
+ tx.Rollback()
|
|
1680
|
+ }
|
|
1681
|
+ }()
|
|
1682
|
+
|
|
1683
|
+ warehouseOut, _ := service.FindWareHouseOutById(id, tx)
|
1654
|
1684
|
|
1655
|
1685
|
tempWarehouseOut := models.WarehouseOut{
|
1656
|
1686
|
ID: warehouseOut.ID,
|
|
@@ -1659,7 +1689,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1659
|
1689
|
StorehouseId: storehouse_id,
|
1660
|
1690
|
}
|
1661
|
1691
|
|
1662
|
|
- service.EditWarehouseOut(tempWarehouseOut)
|
|
1692
|
+ service.EditWarehouseOut(tempWarehouseOut, tx)
|
1663
|
1693
|
|
1664
|
1694
|
dataBody := make(map[string]interface{}, 0)
|
1665
|
1695
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
@@ -1871,9 +1901,9 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1871
|
1901
|
|
1872
|
1902
|
for _, item := range warehousingOutInfo {
|
1873
|
1903
|
//查询改耗材是否出库
|
1874
|
|
- outInfo, _ := service.GetGoodsIsExsit(item.GoodId, item.SysRecordTime, item.OrgId, item.WarehouseOutId)
|
|
1904
|
+ outInfo, _ := service.GetGoodsIsExsit(item.GoodId, item.SysRecordTime, item.OrgId, item.WarehouseOutId, tx)
|
1875
|
1905
|
if outInfo.ID == 0 {
|
1876
|
|
- service.AddSigleWarehouseOutInfo(item)
|
|
1906
|
+ service.AddSigleWarehouseOutInfo(item, tx)
|
1877
|
1907
|
}
|
1878
|
1908
|
|
1879
|
1909
|
}
|
|
@@ -1881,10 +1911,14 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1881
|
1911
|
|
1882
|
1912
|
if len(upDateWarehouseOutInfos) > 0 {
|
1883
|
1913
|
for _, item := range upDateWarehouseOutInfos {
|
1884
|
|
- service.UpDateWarehouseOutInfo(item)
|
|
1914
|
+ if item.ID > 0 {
|
|
1915
|
+ service.UpDateWarehouseOutInfo(item, tx)
|
|
1916
|
+ }
|
|
1917
|
+
|
1885
|
1918
|
}
|
1886
|
1919
|
}
|
1887
|
1920
|
|
|
1921
|
+ tx.Commit()
|
1888
|
1922
|
if errs != nil {
|
1889
|
1923
|
utils.ErrorLog(errs.Error())
|
1890
|
1924
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
|
|
@@ -5755,7 +5789,7 @@ func (this *StockManagerApiController) SaveCheckDamage() {
|
5755
|
5789
|
_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
|
5756
|
5790
|
|
5757
|
5791
|
if errcodes == gorm.ErrRecordNotFound {
|
5758
|
|
- service.AddSigleWarehouseOut(&warehouseOut)
|
|
5792
|
+ service.AddSigleWarehouseOutOne(&warehouseOut)
|
5759
|
5793
|
|
5760
|
5794
|
}
|
5761
|
5795
|
out, _ := service.GetLastGoodWarehouseOut(adminUserInfo.CurrentOrgId)
|
|
@@ -5796,8 +5830,8 @@ func (this *StockManagerApiController) SaveCheckDamage() {
|
5796
|
5830
|
LicenseNumber: item.LicenseNumber,
|
5797
|
5831
|
GoodTypeId: goodinfo.GoodTypeId,
|
5798
|
5832
|
}
|
5799
|
|
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
5800
|
|
- fmt.Println("99999999999999", errOne)
|
|
5833
|
+ errOne := service.AddSigleWarehouseOutInfoOne(warehouseOutInfo)
|
|
5834
|
+ fmt.Println("", errOne)
|
5801
|
5835
|
|
5802
|
5836
|
//更改库存
|
5803
|
5837
|
info, _ := service.GetWarehouseInfoById(item.WarehousingInfoId)
|
|
@@ -6309,7 +6343,7 @@ func (this *StockManagerApiController) SaveCheckInventory() {
|
6309
|
6343
|
ProductDate: warehouseInfo.ProductDate,
|
6310
|
6344
|
ExpireDate: warehouseInfo.ExpiryDate,
|
6311
|
6345
|
}
|
6312
|
|
- errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
|
6346
|
+ errOne := service.AddSigleWarehouseOutInfoOne(warehouseOutInfo)
|
6313
|
6347
|
fmt.Println(errOne)
|
6314
|
6348
|
//创建出库明细
|
6315
|
6349
|
service.CreateStockFlowOne(stockFlow)
|
|
@@ -7252,36 +7286,33 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
|
7252
|
7286
|
|
7253
|
7287
|
id, _ := this.GetInt64("id")
|
7254
|
7288
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
7255
|
|
- creater := this.GetAdminUserInfo().AdminUser.Id
|
7256
|
|
- warehouseOut, _ := service.GetWarehouseById(id)
|
|
7289
|
+ // 开始外部循环的事务
|
|
7290
|
+ db := service.XTWriteDB()
|
|
7291
|
+ tx := db.Begin()
|
|
7292
|
+
|
|
7293
|
+ // 在函数结束时处理事务回滚
|
|
7294
|
+ defer func() {
|
|
7295
|
+ if r := recover(); r != nil {
|
|
7296
|
+ tx.Rollback()
|
|
7297
|
+ }
|
|
7298
|
+ }()
|
|
7299
|
+
|
|
7300
|
+ warehouseOut, _ := service.GetNewWarehouseById(id, tx)
|
7257
|
7301
|
|
7258
|
7302
|
//查询已保存的单据
|
7259
|
|
- warehousingOutInfo, _ := service.GetWarehouseOutById(id, orgId)
|
|
7303
|
+ warehousingOutInfo, _ := service.GetNewWarehouseOutById(id, orgId, tx)
|
7260
|
7304
|
|
7261
|
7305
|
////出库逻辑
|
7262
|
7306
|
for _, item := range warehousingOutInfo {
|
7263
|
7307
|
// 查询该耗材是否有库存
|
7264
|
|
- warehouseOne, _ := service.FindWarehousingInfoTen(item.GoodId, item.StorehouseId)
|
7265
|
|
- storehouse, _ := service.FindStoreHouseByStorehouseId(item.StorehouseId, item.OrgId)
|
|
7308
|
+ warehouseOne, _ := service.FindNewWarehousingInfoTen(item.GoodId, item.StorehouseId, tx)
|
|
7309
|
+
|
|
7310
|
+ storehouse, _ := service.FindNewStoreHouseByStorehouseId(item.StorehouseId, item.OrgId, tx)
|
7266
|
7311
|
|
7267
|
7312
|
// 如果出库数量大于该批次剩余库存数量
|
7268
|
7313
|
if item.Count > warehouseOne.StockCount {
|
7269
|
|
-
|
7270
|
|
- goodErrcode := models.XtGoodErrcode{
|
7271
|
|
- UserOrgId: orgId,
|
7272
|
|
- Errcode: "出库数量大于该批次剩余库存",
|
7273
|
|
- GoodId: 0,
|
7274
|
|
- Status: 0,
|
7275
|
|
- Ctime: 0,
|
7276
|
|
- Mtime: 0,
|
7277
|
|
- Count: 0,
|
7278
|
|
- StockCount: 0,
|
7279
|
|
- Creater: creater,
|
7280
|
|
- BatchNumberId: warehouseOne.ID,
|
7281
|
|
- WarehouseOutId: item.ID,
|
7282
|
|
- }
|
7283
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7284
|
|
- goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
|
7314
|
+ goodObj, _ := service.GetNewGoodInformationByGoodId(item.GoodId, tx)
|
|
7315
|
+ tx.Rollback()
|
7285
|
7316
|
this.ServeSuccessJSON(map[string]interface{}{
|
7286
|
7317
|
"msg": "1",
|
7287
|
7318
|
"good_name": goodObj.GoodName,
|
|
@@ -7297,93 +7328,37 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
|
7297
|
7328
|
creater := this.GetAdminUserInfo().AdminUser.Id
|
7298
|
7329
|
|
7299
|
7330
|
//出库
|
7300
|
|
- err := service.ConsumablesDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater)
|
|
7331
|
+ err := service.ConsumablesNewDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater, tx)
|
|
7332
|
+
|
7301
|
7333
|
if err != nil {
|
7302
|
|
- goodErrcode := models.XtGoodErrcode{
|
7303
|
|
- UserOrgId: orgId,
|
7304
|
|
- Errcode: "调用出库接口报错",
|
7305
|
|
- GoodId: item.GoodId,
|
7306
|
|
- Status: 1,
|
7307
|
|
- Ctime: time.Now().Unix(),
|
7308
|
|
- Mtime: 0,
|
7309
|
|
- Count: 0,
|
7310
|
|
- StockCount: 0,
|
7311
|
|
- Creater: creater,
|
7312
|
|
- BatchNumberId: 0,
|
7313
|
|
- WarehouseOutId: 0,
|
7314
|
|
- }
|
7315
|
|
- service.CreateGoodErrcode(goodErrcode)
|
|
7334
|
+ tx.Rollback()
|
|
7335
|
+ return
|
7316
|
7336
|
}
|
7317
|
7337
|
|
7318
|
|
- goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
|
|
7338
|
+ goodList, _ := service.GetNewSumGoodList(orgId, item.StorehouseId, item.GoodId, tx)
|
7319
|
7339
|
var flush_count int64
|
7320
|
7340
|
for _, it := range goodList {
|
7321
|
7341
|
flush_count += it.StockCount
|
7322
|
7342
|
}
|
7323
|
|
- errs := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
|
7324
|
|
- if errs != nil {
|
7325
|
|
- goodErrcode := models.XtGoodErrcode{
|
7326
|
|
- UserOrgId: orgId,
|
7327
|
|
- Errcode: "手动出库更新剩余出库失败",
|
7328
|
|
- GoodId: item.GoodId,
|
7329
|
|
- Status: 1,
|
7330
|
|
- Ctime: time.Now().Unix(),
|
7331
|
|
- Mtime: 0,
|
7332
|
|
- Count: 0,
|
7333
|
|
- StockCount: 0,
|
7334
|
|
- Creater: creater,
|
7335
|
|
- BatchNumberId: 0,
|
7336
|
|
- WarehouseOutId: 0,
|
7337
|
|
- }
|
7338
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7339
|
|
- }
|
|
7343
|
+ service.UpdateNewSumGood(orgId, item.StorehouseId, item.GoodId, flush_count, tx)
|
7340
|
7344
|
|
7341
|
7345
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
7342
|
7346
|
//查询默认仓库
|
7343
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
7344
|
|
- stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
|
|
7347
|
+ storeHouseConfig, _ := service.GetNewAllStoreHouseConfig(orgId, tx)
|
|
7348
|
+ stockList, _ := service.GetNewStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId, tx)
|
7345
|
7349
|
var total_count int64
|
7346
|
7350
|
for _, it := range stockList {
|
7347
|
7351
|
total_count += it.StockCount
|
7348
|
7352
|
}
|
7349
|
7353
|
//基础库扣减库存
|
7350
|
|
- errsum := service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
|
7351
|
|
- if errsum != nil {
|
7352
|
|
- goodErrcode := models.XtGoodErrcode{
|
7353
|
|
- UserOrgId: orgId,
|
7354
|
|
- Errcode: "基础库扣减库存报错",
|
7355
|
|
- GoodId: item.GoodId,
|
7356
|
|
- Status: 1,
|
7357
|
|
- Ctime: time.Now().Unix(),
|
7358
|
|
- Mtime: 0,
|
7359
|
|
- Count: 0,
|
7360
|
|
- StockCount: 0,
|
7361
|
|
- Creater: creater,
|
7362
|
|
- BatchNumberId: 0,
|
7363
|
|
- WarehouseOutId: 0,
|
7364
|
|
- }
|
7365
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7366
|
|
- }
|
|
7354
|
+ service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
|
|
7355
|
+
|
7367
|
7356
|
}
|
7368
|
7357
|
|
7369
|
7358
|
//审核单据
|
7370
|
|
- err := service.UpdatedWarehouseOut(id)
|
7371
|
|
- if err != nil {
|
7372
|
|
- goodErrcode := models.XtGoodErrcode{
|
7373
|
|
- UserOrgId: orgId,
|
7374
|
|
- Errcode: "审核单据报错",
|
7375
|
|
- GoodId: 0,
|
7376
|
|
- Status: 1,
|
7377
|
|
- Ctime: time.Now().Unix(),
|
7378
|
|
- Mtime: 0,
|
7379
|
|
- Count: 0,
|
7380
|
|
- StockCount: 0,
|
7381
|
|
- Creater: creater,
|
7382
|
|
- BatchNumberId: 0,
|
7383
|
|
- WarehouseOutId: 0,
|
7384
|
|
- }
|
7385
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7386
|
|
- }
|
|
7359
|
+ err := service.UpdatedNewWarehouseOut(id, tx)
|
|
7360
|
+
|
|
7361
|
+ tx.Commit()
|
7387
|
7362
|
if err == nil {
|
7388
|
7363
|
this.ServeSuccessJSON(map[string]interface{}{
|
7389
|
7364
|
"msg": "2",
|
|
@@ -7399,162 +7374,50 @@ func (this *StockManagerApiController) ReturnCheckWarehouseOut() {
|
7399
|
7374
|
|
7400
|
7375
|
id, _ := this.GetInt64("id")
|
7401
|
7376
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
7402
|
|
- creater := this.GetAdminUserInfo().AdminUser.Id
|
|
7377
|
+
|
|
7378
|
+ // 开始外部循环的事务
|
|
7379
|
+ db := service.XTWriteDB()
|
|
7380
|
+ tx := db.Begin()
|
|
7381
|
+
|
|
7382
|
+ // 在函数结束时处理事务回滚
|
|
7383
|
+ defer func() {
|
|
7384
|
+ if r := recover(); r != nil {
|
|
7385
|
+ tx.Rollback()
|
|
7386
|
+ }
|
|
7387
|
+ }()
|
7403
|
7388
|
// 查询出库数据
|
7404
|
|
- list, err := service.GetWarehouseOutById(id, orgId)
|
7405
|
|
- if err != nil {
|
7406
|
|
- goodErrcode := models.XtGoodErrcode{
|
7407
|
|
- UserOrgId: orgId,
|
7408
|
|
- Errcode: "反审核查询出库单报错",
|
7409
|
|
- GoodId: 0,
|
7410
|
|
- Status: 1,
|
7411
|
|
- Ctime: time.Now().Unix(),
|
7412
|
|
- Mtime: 0,
|
7413
|
|
- Count: 0,
|
7414
|
|
- StockCount: 0,
|
7415
|
|
- Creater: creater,
|
7416
|
|
- BatchNumberId: 0,
|
7417
|
|
- WarehouseOutId: 0,
|
7418
|
|
- }
|
7419
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7420
|
|
- }
|
|
7389
|
+ list, err := service.GetNewWarehouseOutById(id, orgId, tx)
|
7421
|
7390
|
for _, item := range list {
|
7422
|
7391
|
//回退库存
|
7423
|
|
- err := service.UpdateaGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId)
|
7424
|
|
- if err != nil {
|
7425
|
|
- goodErrcode := models.XtGoodErrcode{
|
7426
|
|
- UserOrgId: orgId,
|
7427
|
|
- Errcode: "反审核回退库存报错",
|
7428
|
|
- GoodId: 0,
|
7429
|
|
- Status: 1,
|
7430
|
|
- Ctime: time.Now().Unix(),
|
7431
|
|
- Mtime: 0,
|
7432
|
|
- Count: 0,
|
7433
|
|
- StockCount: 0,
|
7434
|
|
- Creater: creater,
|
7435
|
|
- BatchNumberId: 0,
|
7436
|
|
- WarehouseOutId: 0,
|
7437
|
|
- }
|
7438
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7439
|
|
- }
|
|
7392
|
+ service.UpdateaNewGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId, tx)
|
|
7393
|
+
|
7440
|
7394
|
//查询默认仓库
|
7441
|
|
- storeHouseConfig, errs := service.GetAllStoreHouseConfig(orgId)
|
7442
|
|
- if errs != nil {
|
7443
|
|
- goodErrcode := models.XtGoodErrcode{
|
7444
|
|
- UserOrgId: orgId,
|
7445
|
|
- Errcode: "反审核查询默认仓库报错",
|
7446
|
|
- GoodId: 0,
|
7447
|
|
- Status: 1,
|
7448
|
|
- Ctime: time.Now().Unix(),
|
7449
|
|
- Mtime: 0,
|
7450
|
|
- Count: 0,
|
7451
|
|
- StockCount: 0,
|
7452
|
|
- Creater: creater,
|
7453
|
|
- BatchNumberId: 0,
|
7454
|
|
- WarehouseOutId: 0,
|
7455
|
|
- }
|
7456
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7457
|
|
- }
|
7458
|
|
- stockList, errcodes := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
|
7459
|
|
- if errcodes != nil {
|
7460
|
|
- goodErrcode := models.XtGoodErrcode{
|
7461
|
|
- UserOrgId: orgId,
|
7462
|
|
- Errcode: "反审核查询默认仓库库存报错",
|
7463
|
|
- GoodId: 0,
|
7464
|
|
- Status: 1,
|
7465
|
|
- Ctime: time.Now().Unix(),
|
7466
|
|
- Mtime: 0,
|
7467
|
|
- Count: 0,
|
7468
|
|
- StockCount: 0,
|
7469
|
|
- Creater: creater,
|
7470
|
|
- BatchNumberId: 0,
|
7471
|
|
- WarehouseOutId: 0,
|
7472
|
|
- }
|
7473
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7474
|
|
- }
|
|
7395
|
+ storeHouseConfig, _ := service.GetNewAllStoreHouseConfig(orgId, tx)
|
|
7396
|
+
|
|
7397
|
+ stockList, _ := service.GetNewStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId, tx)
|
|
7398
|
+
|
7475
|
7399
|
var total_count int64
|
7476
|
7400
|
for _, it := range stockList {
|
7477
|
7401
|
total_count += it.StockCount
|
7478
|
7402
|
}
|
7479
|
7403
|
//基础库扣减库存
|
7480
|
|
- errs = service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, orgId)
|
7481
|
|
- if errs != nil {
|
7482
|
|
- goodErrcode := models.XtGoodErrcode{
|
7483
|
|
- UserOrgId: orgId,
|
7484
|
|
- Errcode: "反审核基础库扣减库存报错",
|
7485
|
|
- GoodId: 0,
|
7486
|
|
- Status: 1,
|
7487
|
|
- Ctime: time.Now().Unix(),
|
7488
|
|
- Mtime: 0,
|
7489
|
|
- Count: 0,
|
7490
|
|
- StockCount: 0,
|
7491
|
|
- Creater: creater,
|
7492
|
|
- BatchNumberId: 0,
|
7493
|
|
- WarehouseOutId: 0,
|
7494
|
|
- }
|
7495
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7496
|
|
- }
|
|
7404
|
+ service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
|
7497
|
7405
|
|
7498
|
|
- goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
|
|
7406
|
+ goodList, _ := service.GetNewSumGoodList(orgId, item.StorehouseId, item.GoodId, tx)
|
7499
|
7407
|
var flush_count int64
|
7500
|
7408
|
for _, it := range goodList {
|
7501
|
7409
|
flush_count += it.StockCount
|
7502
|
7410
|
}
|
7503
|
|
- erros := service.UpdateSumGood(orgId, item.StorehouseId, item.GoodId, flush_count)
|
7504
|
|
- if erros != nil {
|
7505
|
|
- goodErrcode := models.XtGoodErrcode{
|
7506
|
|
- UserOrgId: orgId,
|
7507
|
|
- Errcode: "手动出库更新剩余库存报错",
|
7508
|
|
- GoodId: 0,
|
7509
|
|
- Status: 1,
|
7510
|
|
- Ctime: time.Now().Unix(),
|
7511
|
|
- Mtime: 0,
|
7512
|
|
- Count: 0,
|
7513
|
|
- StockCount: 0,
|
7514
|
|
- Creater: creater,
|
7515
|
|
- BatchNumberId: 0,
|
7516
|
|
- WarehouseOutId: 0,
|
7517
|
|
- }
|
7518
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7519
|
|
- }
|
|
7411
|
+ service.UpdateNewSumGood(orgId, item.StorehouseId, item.GoodId, flush_count, tx)
|
|
7412
|
+
|
7520
|
7413
|
//扣减出库数据
|
7521
|
|
- errcoeds := service.ModifyReduceGoodSumCount(item.StorehouseId, item.Count, orgId, item.GoodId)
|
7522
|
|
- if errcoeds != nil {
|
7523
|
|
- goodErrcode := models.XtGoodErrcode{
|
7524
|
|
- UserOrgId: orgId,
|
7525
|
|
- Errcode: "反审核扣减出库数据报错",
|
7526
|
|
- GoodId: 0,
|
7527
|
|
- Status: 1,
|
7528
|
|
- Ctime: time.Now().Unix(),
|
7529
|
|
- Mtime: 0,
|
7530
|
|
- Count: 0,
|
7531
|
|
- StockCount: 0,
|
7532
|
|
- Creater: creater,
|
7533
|
|
- BatchNumberId: 0,
|
7534
|
|
- WarehouseOutId: 0,
|
7535
|
|
- }
|
7536
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7537
|
|
- }
|
|
7414
|
+ service.ModifyNewReduceGoodSumCount(item.StorehouseId, item.Count, orgId, item.GoodId, tx)
|
7538
|
7415
|
|
7539
|
7416
|
}
|
7540
|
7417
|
//删除流水,改变审核状态
|
7541
|
|
- errcos := service.ModifyGoodWarehouseOut(id)
|
7542
|
|
- if errcos != nil {
|
7543
|
|
- goodErrcode := models.XtGoodErrcode{
|
7544
|
|
- UserOrgId: orgId,
|
7545
|
|
- Errcode: "反审核删除流水,改变审核状态报错",
|
7546
|
|
- GoodId: 0,
|
7547
|
|
- Status: 1,
|
7548
|
|
- Ctime: time.Now().Unix(),
|
7549
|
|
- Mtime: 0,
|
7550
|
|
- Count: 0,
|
7551
|
|
- StockCount: 0,
|
7552
|
|
- Creater: creater,
|
7553
|
|
- BatchNumberId: 0,
|
7554
|
|
- WarehouseOutId: 0,
|
7555
|
|
- }
|
7556
|
|
- service.CreateGoodErrcode(goodErrcode)
|
7557
|
|
- }
|
|
7418
|
+ service.ModifyNewGoodWarehouseOut(id, tx)
|
|
7419
|
+
|
|
7420
|
+ tx.Commit()
|
7558
|
7421
|
|
7559
|
7422
|
if err == nil {
|
7560
|
7423
|
this.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -7568,20 +7431,32 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
|
7568
|
7431
|
warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
|
7569
|
7432
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
7570
|
7433
|
Creator := this.GetAdminUserInfo().AdminUser.Id
|
|
7434
|
+
|
|
7435
|
+ // 开始外部循环的事务
|
|
7436
|
+ db := service.XTWriteDB()
|
|
7437
|
+ tx := db.Begin()
|
|
7438
|
+
|
|
7439
|
+ // 在函数结束时处理事务回滚
|
|
7440
|
+ defer func() {
|
|
7441
|
+ if r := recover(); r != nil {
|
|
7442
|
+ tx.Rollback()
|
|
7443
|
+ }
|
|
7444
|
+ }()
|
|
7445
|
+
|
7571
|
7446
|
//查询默认仓库
|
7572
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
|
7447
|
+ storeHouseConfig, _ := service.GetNewAllStoreHouseConfig(orgId, tx)
|
7573
|
7448
|
|
7574
|
7449
|
checker := this.GetAdminUserInfo().AdminUser.Id
|
7575
|
7450
|
//更改审核状态
|
7576
|
|
- err := service.UpdateCheckWarehouseInfo(warehousing_info_id, checker)
|
|
7451
|
+ err := service.UpdateNewCheckWarehouseInfo(warehousing_info_id, checker, tx)
|
7577
|
7452
|
if err == nil {
|
7578
|
|
- list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
|
|
7453
|
+ list, _ := service.GetNewWarehouseInfoList(warehousing_info_id, orgId, tx)
|
7579
|
7454
|
|
7580
|
7455
|
for _, item := range list {
|
7581
|
|
- service.UpdateWarehouseInfoByIdListThree(item.WarehousingCount, item.ID)
|
|
7456
|
+ service.UpdateNewWarehouseInfoByIdListThree(item.WarehousingCount, item.ID, tx)
|
7582
|
7457
|
|
7583
|
7458
|
//查询该耗材剩余库存库
|
7584
|
|
- stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
|
|
7459
|
+ stockList, _ := service.GetNewStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId, tx)
|
7585
|
7460
|
var total_count int64
|
7586
|
7461
|
var sum_in_count int64
|
7587
|
7462
|
for _, it := range stockList {
|
|
@@ -7589,11 +7464,12 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
|
7589
|
7464
|
sum_in_count += it.WarehousingCount
|
7590
|
7465
|
}
|
7591
|
7466
|
//基础库插入数据
|
7592
|
|
- service.UpdateGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count)
|
|
7467
|
+ service.UpdateNewGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count, tx)
|
7593
|
7468
|
|
7594
|
7469
|
//查询该仓库是否有数据
|
7595
|
|
- _, errcode := service.GetGoodStockCount(orgId, item.StorehouseId, item.GoodId)
|
7596
|
|
- goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
|
|
7470
|
+ _, errcode := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
|
|
7471
|
+
|
|
7472
|
+ goodList, _ := service.GetNewSumGoodList(orgId, item.StorehouseId, item.GoodId, tx)
|
7597
|
7473
|
var flush_count int64
|
7598
|
7474
|
for _, it := range goodList {
|
7599
|
7475
|
flush_count += it.StockCount
|
|
@@ -7640,7 +7516,7 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
|
7640
|
7516
|
GoodCode: item.GoodCode,
|
7641
|
7517
|
}
|
7642
|
7518
|
//创建出库流水
|
7643
|
|
- service.CreateStockFlowOne(stockFlow)
|
|
7519
|
+ service.CreateNewStockFlowOne(stockFlow, tx)
|
7644
|
7520
|
|
7645
|
7521
|
if errcode == gorm.ErrRecordNotFound {
|
7646
|
7522
|
|
|
@@ -7657,14 +7533,16 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
|
7657
|
7533
|
FlushCount: flush_count,
|
7658
|
7534
|
StockActOutCount: 0,
|
7659
|
7535
|
}
|
7660
|
|
- service.CreateGoodCount(goodCount)
|
|
7536
|
+ service.CreateNewGoodCount(goodCount, tx)
|
7661
|
7537
|
}
|
7662
|
7538
|
if errcode == nil {
|
7663
|
|
- service.UpdateGoodStockCount(orgId, item.StorehouseId, item.GoodId, item.WarehousingCount, flush_count)
|
|
7539
|
+ service.UpdateNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, item.WarehousingCount, flush_count, tx)
|
7664
|
7540
|
}
|
7665
|
7541
|
}
|
7666
|
7542
|
}
|
7667
|
7543
|
|
|
7544
|
+ tx.Commit()
|
|
7545
|
+
|
7668
|
7546
|
if err == nil {
|
7669
|
7547
|
this.ServeSuccessJSON(map[string]interface{}{
|
7670
|
7548
|
"list": "list",
|
|
@@ -7676,49 +7554,33 @@ func (this *StockManagerApiController) ReturnCheckWarehouseInfo() {
|
7676
|
7554
|
|
7677
|
7555
|
warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
|
7678
|
7556
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
7557
|
+
|
|
7558
|
+ // 开始外部循环的事务
|
|
7559
|
+ db := service.XTWriteDB()
|
|
7560
|
+ tx := db.Begin()
|
|
7561
|
+
|
|
7562
|
+ // 在函数结束时处理事务回滚
|
|
7563
|
+ defer func() {
|
|
7564
|
+ if r := recover(); r != nil {
|
|
7565
|
+ tx.Rollback()
|
|
7566
|
+ }
|
|
7567
|
+ }()
|
|
7568
|
+
|
7679
|
7569
|
//查询入库数据
|
7680
|
|
- list, _ := service.GetWarehouseInfoList(warehousing_info_id, orgId)
|
|
7570
|
+ list, _ := service.GetNewWarehouseInfoList(warehousing_info_id, orgId, tx)
|
7681
|
7571
|
for _, item := range list {
|
7682
|
7572
|
//查询该耗材 是否有出库数据
|
7683
|
|
- outlist, _ := service.GetWarehouseOutByWarehouseInfoId(item.ID, item.GoodId, item.OrgId)
|
|
7573
|
+ outlist, _ := service.GetNewWarehouseOutByWarehouseInfoId(item.ID, item.GoodId, item.OrgId, tx)
|
7684
|
7574
|
|
7685
|
7575
|
if len(outlist) > 0 {
|
|
7576
|
+ tx.Rollback()
|
7686
|
7577
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCheckGoodParamWrong)
|
7687
|
7578
|
return
|
7688
|
7579
|
}
|
7689
|
7580
|
}
|
7690
|
|
- //for _, item := range list {
|
7691
|
|
- //
|
7692
|
|
- // //扣减数量
|
7693
|
|
- // service.UpdateWarehouseInfoByIdListTwo(item.WarehousingCount, item.ID)
|
7694
|
|
- //
|
7695
|
|
- // //删除流水
|
7696
|
|
- // service.UpdateWarehouseInfoFlow(item.ID)
|
7697
|
|
- //
|
7698
|
|
- // goodList, _ := service.GetSumGoodList(orgId, item.StorehouseId, item.GoodId)
|
7699
|
|
- // var flush_count int64
|
7700
|
|
- // for _, it := range goodList {
|
7701
|
|
- // flush_count += it.StockCount
|
7702
|
|
- // }
|
7703
|
|
- //
|
7704
|
|
- // //扣减数量
|
7705
|
|
- // service.UpdateGoodInCount(item.WarehousingCount, item.OrgId, item.GoodId, item.StorehouseId, flush_count)
|
7706
|
|
- //
|
7707
|
|
- // //查询默认仓库
|
7708
|
|
- // storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
|
7709
|
|
- // //查询该耗材剩余多少库存
|
7710
|
|
- // stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId)
|
7711
|
|
- // var sum_count int64
|
7712
|
|
- // var sum_in_count int64
|
7713
|
|
- // for _, it := range stockList {
|
7714
|
|
- // sum_count += it.StockCount
|
7715
|
|
- // sum_in_count += it.WarehousingCount
|
7716
|
|
- // }
|
7717
|
|
- // service.UpdateGoodInfoAddSumCount(item.GoodId, sum_count, orgId, sum_in_count)
|
7718
|
|
- //}
|
7719
|
|
- //err := service.ReturnCheckWarehouseInfo(warehousing_info_id)
|
7720
|
7581
|
|
7721
|
|
- err := service.UpdateWarehouseInfoMap(list, warehousing_info_id, orgId)
|
|
7582
|
+ err := service.UpdateNewWarehouseInfoMap(list, warehousing_info_id, orgId, tx)
|
|
7583
|
+ tx.Commit()
|
7722
|
7584
|
if err == nil {
|
7723
|
7585
|
this.ServeSuccessJSON(map[string]interface{}{
|
7724
|
7586
|
"msg": "反审核成功!",
|
|
@@ -8223,7 +8085,7 @@ func (this *StockManagerApiController) UpdateBaseDrugListByUserOrgID() {
|
8223
|
8085
|
// service.UpdateDealerManufacturerOne(item.ID, manufacturer.ManufacturerName)
|
8224
|
8086
|
//}
|
8225
|
8087
|
|
8226
|
|
- drugList, _ := service.GetAllBaseDrugListTwentyOne(10598)
|
|
8088
|
+ drugList, _ := service.GetAllBaseDrugListTwentyOne(10215)
|
8227
|
8089
|
|
8228
|
8090
|
for _, item := range drugList {
|
8229
|
8091
|
var drug_spec = item.Dose + item.DoseUnit + "*" + strconv.FormatInt(item.MinNumber, 10) + item.MinUnit + "/" + item.MaxUnit
|