|
@@ -3552,128 +3552,127 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
|
3552
|
3552
|
|
3553
|
3553
|
checker := c.GetAdminUserInfo().AdminUser.Id
|
3554
|
3554
|
//更改核对状态
|
3555
|
|
- err := service.CheckWarehousingInfo(warehousing_id, orgId, checker)
|
|
3555
|
+ service.CheckWarehousingInfo(warehousing_id, orgId, checker)
|
3556
|
3556
|
|
3557
|
|
- if err == nil {
|
3558
|
|
- list, _ := service.GetWarehousingInfoByList(warehousing_id, orgId)
|
3559
|
|
- for _, item := range list {
|
3560
|
|
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
3561
|
|
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
|
3562
|
|
- //新增库存
|
3563
|
|
- service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
|
|
3557
|
+ list, _ := service.GetWarehousingInfoByList(warehousing_id, orgId)
|
|
3558
|
+ for _, item := range list {
|
|
3559
|
+ medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
3560
|
+ if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
|
|
3561
|
+ //新增库存
|
|
3562
|
+ service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
|
3564
|
3563
|
|
3565
|
|
- }
|
3566
|
|
- if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
|
3567
|
|
- //新增库存
|
3568
|
|
- service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
|
|
3564
|
+ }
|
|
3565
|
+ if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
|
|
3566
|
+ //新增库存
|
|
3567
|
+ service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
|
3569
|
3568
|
|
3570
|
|
- }
|
|
3569
|
+ }
|
3571
|
3570
|
|
3572
|
|
- if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
|
|
3571
|
+ if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
|
3573
|
3572
|
|
3574
|
|
- //新增库存
|
3575
|
|
- service.AddDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID)
|
|
3573
|
+ //新增库存
|
|
3574
|
+ service.AddDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID)
|
3576
|
3575
|
|
3577
|
|
- }
|
|
3576
|
+ }
|
3578
|
3577
|
|
3579
|
|
- Creator := c.GetAdminUserInfo().AdminUser.Id
|
|
3578
|
+ Creator := c.GetAdminUserInfo().AdminUser.Id
|
3580
|
3579
|
|
3581
|
|
- //查询默认仓库
|
|
3580
|
+ //查询默认仓库
|
3582
|
3581
|
|
3583
|
|
- //查询默认仓库剩余多少库存
|
3584
|
|
- list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
|
3585
|
|
- var sum_count int64
|
3586
|
|
- var sum_in_count int64
|
3587
|
|
- for _, it := range list {
|
3588
|
|
- baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
3589
|
|
- if it.MaxUnit == baseDrug.MaxUnit {
|
3590
|
|
- it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
3591
|
|
- it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
3592
|
|
- }
|
3593
|
|
- sum_count += it.StockMaxNumber + it.StockMinNumber
|
3594
|
|
- sum_in_count += it.WarehousingCount
|
3595
|
|
- }
|
3596
|
|
- flow := &models.DrugFlow{
|
3597
|
|
- WarehousingId: 0,
|
3598
|
|
- DrugId: item.DrugId,
|
3599
|
|
- Number: item.Number,
|
3600
|
|
- BatchNumber: item.BatchNumber,
|
3601
|
|
- Count: item.WarehousingCount,
|
3602
|
|
- UserOrgId: item.OrgId,
|
3603
|
|
- PatientId: 0,
|
3604
|
|
- SystemTime: time.Now().Unix(),
|
3605
|
|
- ConsumableType: 1,
|
3606
|
|
- IsSys: 0,
|
3607
|
|
- WarehousingOrder: item.WarehousingOrder,
|
3608
|
|
- WarehouseOutId: 0,
|
3609
|
|
- WarehouseOutOrderNumber: "",
|
3610
|
|
- IsEdit: 0,
|
3611
|
|
- CancelStockId: 0,
|
3612
|
|
- CancelOrderNumber: "",
|
3613
|
|
- Manufacturer: 0,
|
3614
|
|
- Dealer: 0,
|
3615
|
|
- Creator: Creator,
|
3616
|
|
- UpdateCreator: Creator,
|
3617
|
|
- Status: 1,
|
3618
|
|
- Ctime: item.Ctime,
|
3619
|
|
- Mtime: 0,
|
3620
|
|
- Price: item.Price,
|
3621
|
|
- WarehousingDetailId: item.ID,
|
3622
|
|
- WarehouseOutDetailId: 0,
|
3623
|
|
- CancelOutDetailId: 0,
|
3624
|
|
- ExpireDate: item.ExpiryDate,
|
3625
|
|
- ProductDate: item.ProductDate,
|
3626
|
|
- MaxUnit: item.MaxUnit,
|
3627
|
|
- MinUnit: item.MinUnit,
|
3628
|
|
- StorehouseId: item.StorehouseId,
|
3629
|
|
- OverCount: sum_count,
|
3630
|
|
- }
|
3631
|
|
- service.CreateDrugFlowTwo(flow)
|
3632
|
|
- //更新基础库剩余库存
|
3633
|
|
- service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
|
3634
|
|
-
|
3635
|
|
- drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
|
3636
|
|
- var total_count int64 // 入库总数量
|
3637
|
|
- var over_count int64 //剩余库存
|
3638
|
|
- for _, it := range drugInfolist {
|
3639
|
|
- baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
3640
|
|
- if it.MaxUnit == baseDrug.MaxUnit {
|
3641
|
|
- it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
3642
|
|
- it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
3643
|
|
- }
|
3644
|
|
- }
|
3645
|
|
- for _, it := range drugInfolist {
|
3646
|
|
- total_count += it.WarehousingCount
|
3647
|
|
- over_count += it.StockMaxNumber + it.StockMinNumber
|
|
3582
|
+ //查询默认仓库剩余多少库存
|
|
3583
|
+ list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
|
|
3584
|
+ var sum_count int64
|
|
3585
|
+ var sum_in_count int64
|
|
3586
|
+ for _, it := range list {
|
|
3587
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
3588
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
3589
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
3590
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
3648
|
3591
|
}
|
3649
|
|
- //查询该仓库是否有默认数据
|
3650
|
|
- _, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
|
3651
|
|
- if errcode == gorm.ErrRecordNotFound {
|
3652
|
|
- drugStock := models.XtDrugStockCount{
|
3653
|
|
- UserOrgId: item.OrgId,
|
3654
|
|
- StorehouseId: item.StorehouseId,
|
3655
|
|
- SumInCount: total_count,
|
3656
|
|
- SumOutCount: 0,
|
3657
|
|
- SumCancelCount: 0,
|
3658
|
|
- DrugId: item.DrugId,
|
3659
|
|
- Ctime: time.Now().Unix(),
|
3660
|
|
- Mtime: 0,
|
3661
|
|
- Status: 1,
|
3662
|
|
- FlushCount: over_count,
|
3663
|
|
- SumActOutCount: 0,
|
3664
|
|
- }
|
3665
|
|
- service.CreateDrugStockSum(drugStock)
|
|
3592
|
+ sum_count += it.StockMaxNumber + it.StockMinNumber
|
|
3593
|
+ sum_in_count += it.WarehousingCount
|
|
3594
|
+ }
|
|
3595
|
+ flow := &models.DrugFlow{
|
|
3596
|
+ WarehousingId: 0,
|
|
3597
|
+ DrugId: item.DrugId,
|
|
3598
|
+ Number: item.Number,
|
|
3599
|
+ BatchNumber: item.BatchNumber,
|
|
3600
|
+ Count: item.WarehousingCount,
|
|
3601
|
+ UserOrgId: item.OrgId,
|
|
3602
|
+ PatientId: 0,
|
|
3603
|
+ SystemTime: time.Now().Unix(),
|
|
3604
|
+ ConsumableType: 1,
|
|
3605
|
+ IsSys: 0,
|
|
3606
|
+ WarehousingOrder: item.WarehousingOrder,
|
|
3607
|
+ WarehouseOutId: 0,
|
|
3608
|
+ WarehouseOutOrderNumber: "",
|
|
3609
|
+ IsEdit: 0,
|
|
3610
|
+ CancelStockId: 0,
|
|
3611
|
+ CancelOrderNumber: "",
|
|
3612
|
+ Manufacturer: 0,
|
|
3613
|
+ Dealer: 0,
|
|
3614
|
+ Creator: Creator,
|
|
3615
|
+ UpdateCreator: Creator,
|
|
3616
|
+ Status: 1,
|
|
3617
|
+ Ctime: item.Ctime,
|
|
3618
|
+ Mtime: 0,
|
|
3619
|
+ Price: item.Price,
|
|
3620
|
+ WarehousingDetailId: item.ID,
|
|
3621
|
+ WarehouseOutDetailId: 0,
|
|
3622
|
+ CancelOutDetailId: 0,
|
|
3623
|
+ ExpireDate: item.ExpiryDate,
|
|
3624
|
+ ProductDate: item.ProductDate,
|
|
3625
|
+ MaxUnit: item.MaxUnit,
|
|
3626
|
+ MinUnit: item.MinUnit,
|
|
3627
|
+ StorehouseId: item.StorehouseId,
|
|
3628
|
+ OverCount: sum_count,
|
|
3629
|
+ }
|
|
3630
|
+ service.CreateDrugFlowTwo(flow)
|
|
3631
|
+ //更新基础库剩余库存
|
|
3632
|
+ service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
|
3666
|
3633
|
|
3667
|
|
- } else if errcode == nil {
|
3668
|
|
- service.UpdateDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
|
|
3634
|
+ drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
|
|
3635
|
+ var total_count int64 // 入库总数量
|
|
3636
|
+ var over_count int64 //剩余库存
|
|
3637
|
+ for _, it := range drugInfolist {
|
|
3638
|
+ baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
|
|
3639
|
+ if it.MaxUnit == baseDrug.MaxUnit {
|
|
3640
|
+ it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
|
|
3641
|
+ it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
|
|
3642
|
+ }
|
|
3643
|
+ }
|
|
3644
|
+ for _, it := range drugInfolist {
|
|
3645
|
+ total_count += it.WarehousingCount
|
|
3646
|
+ over_count += it.StockMaxNumber + it.StockMinNumber
|
|
3647
|
+ }
|
|
3648
|
+ //查询该仓库是否有默认数据
|
|
3649
|
+ _, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
|
|
3650
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
3651
|
+ drugStock := models.XtDrugStockCount{
|
|
3652
|
+ UserOrgId: item.OrgId,
|
|
3653
|
+ StorehouseId: item.StorehouseId,
|
|
3654
|
+ SumInCount: total_count,
|
|
3655
|
+ SumOutCount: 0,
|
|
3656
|
+ SumCancelCount: 0,
|
|
3657
|
+ DrugId: item.DrugId,
|
|
3658
|
+ Ctime: time.Now().Unix(),
|
|
3659
|
+ Mtime: 0,
|
|
3660
|
+ Status: 1,
|
|
3661
|
+ FlushCount: over_count,
|
|
3662
|
+ SumActOutCount: 0,
|
3669
|
3663
|
}
|
|
3664
|
+ service.CreateDrugStockSum(drugStock)
|
3670
|
3665
|
|
|
3666
|
+ } else if errcode == nil {
|
|
3667
|
+ service.UpdateDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
|
3671
|
3668
|
}
|
3672
|
3669
|
|
3673
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
3674
|
|
- "list": list,
|
3675
|
|
- })
|
3676
|
3670
|
}
|
|
3671
|
+
|
|
3672
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
3673
|
+ "list": list,
|
|
3674
|
+ })
|
|
3675
|
+
|
3677
|
3676
|
}
|
3678
|
3677
|
|
3679
|
3678
|
func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
|