|
@@ -4917,8 +4917,6 @@ func (c *DialysisAPIController) CreateConsumables() {
|
4917
|
4917
|
}
|
4918
|
4918
|
}
|
4919
|
4919
|
|
4920
|
|
- fmt.Println("active------------------------------------", active)
|
4921
|
|
- fmt.Println("len------------------------------", len(goods))
|
4922
|
4920
|
|
4923
|
4921
|
if active == 1 && len(goods) > 0 {
|
4924
|
4922
|
for _, item := range dialysisBefor {
|
|
@@ -5690,124 +5688,89 @@ func (c *DialysisAPIController) EditConsumables() {
|
5690
|
5688
|
|
5691
|
5689
|
}
|
5692
|
5690
|
|
5693
|
|
-
|
5694
|
|
- for _, item := range cancelbefor {
|
5695
|
|
- warehouseOut, _ := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
|
5696
|
|
- creater := adminInfo.AdminUser.Id
|
|
5691
|
+ if len(cancelbefor) > 0 {
|
5697
|
5692
|
|
5698
|
|
-
|
5699
|
|
-
|
|
5693
|
+ for _, item := range cancelbefor {
|
|
5694
|
+ warehouseOut, _ := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
|
|
5695
|
+ creater := adminInfo.AdminUser.Id
|
5700
|
5696
|
|
5701
|
|
- warehouseOutInfos, _ := service.FindStockOutInfoByStockTwo(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, record_time, patient_id)
|
|
5697
|
+
|
|
5698
|
+ warehouseOutInfos, _ := service.FindStockOutInfoByStockTwo(adminInfo.Org.Id, item.GoodTypeId, item.GoodId, record_time, patient_id)
|
5702
|
5699
|
|
5703
|
|
- var delete_count int64 = 0
|
|
5700
|
+ var delete_count int64 = 0
|
5704
|
5701
|
|
5705
|
|
- delete_count = warehouseOutInfos.Count - item.Count
|
|
5702
|
+ delete_count = warehouseOutInfos.Count - item.Count
|
5706
|
5703
|
|
5707
|
|
-
|
5708
|
|
- service.ModifyGoodAddInformation(item.GoodId, delete_count, adminInfo.Org.Id)
|
|
5704
|
+
|
|
5705
|
+ service.ModifyGoodAddInformation(item.GoodId, delete_count, adminInfo.Org.Id)
|
5709
|
5706
|
|
5710
|
|
-
|
5711
|
|
- service.ModifyReduceGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, adminInfo.Org.Id, item.GoodId)
|
|
5707
|
+
|
|
5708
|
+ service.ModifyReduceGoodSumCountTwenty(houseConfig.StorehouseOutInfo, delete_count, adminInfo.Org.Id, item.GoodId)
|
5712
|
5709
|
|
5713
|
|
-
|
|
5710
|
+
|
5714
|
5711
|
|
5715
|
|
- service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count, patient_id, record_time, item.GoodId)
|
|
5712
|
+ service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count, patient_id, record_time, item.GoodId)
|
5716
|
5713
|
|
5717
|
|
- houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
|
5714
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
5718
|
5715
|
|
5719
|
|
-
|
5720
|
|
- goodListOne, _ := service.GetSumGoodList(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId)
|
5721
|
|
- var flush_count int64
|
5722
|
|
- for _, it := range goodListOne {
|
5723
|
|
- flush_count += it.StockCount
|
5724
|
|
- }
|
5725
|
|
- service.UpdateSumGood(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
|
|
5716
|
+
|
|
5717
|
+ goodListOne, _ := service.GetSumGoodList(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId)
|
|
5718
|
+ var flush_count int64
|
|
5719
|
+ for _, it := range goodListOne {
|
|
5720
|
+ flush_count += it.StockCount
|
|
5721
|
+ }
|
|
5722
|
+ service.UpdateSumGood(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
|
5726
|
5723
|
|
5727
|
|
-
|
5728
|
|
- goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
|
5729
|
|
- var sum_count int64
|
5730
|
|
- for _, item := range goodList {
|
5731
|
|
- sum_count += item.StockCount
|
5732
|
|
- }
|
|
5724
|
+
|
|
5725
|
+ goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
|
|
5726
|
+ var sum_count int64
|
|
5727
|
+ for _, item := range goodList {
|
|
5728
|
+ sum_count += item.StockCount
|
|
5729
|
+ }
|
5733
|
5730
|
|
5734
|
|
-
|
5735
|
|
- warehouseOutInfo := &models.WarehouseOutInfo{
|
5736
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
5737
|
|
- WarehouseOutId: warehouseOut.ID,
|
5738
|
|
- Status: 1,
|
5739
|
|
- Ctime: time.Now().Unix(),
|
5740
|
|
- OrgId: adminInfo.Org.Id,
|
5741
|
|
- Type: 1,
|
5742
|
|
- IsSys: 1,
|
5743
|
|
- SysRecordTime: record_time,
|
5744
|
|
- GoodTypeId: item.GoodTypeId,
|
5745
|
|
- GoodId: item.GoodId,
|
5746
|
|
- PatientId: patient_id,
|
5747
|
|
- ConsumableType: 2,
|
5748
|
|
- StorehouseId: houseConfig.StorehouseOutInfo,
|
5749
|
|
- IsCheck: 1,
|
5750
|
|
- OverCount: sum_count,
|
5751
|
|
- }
|
5752
|
|
- warehouseOutInfo.Count = item.Count
|
5753
|
|
-
|
5754
|
|
- stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
|
5755
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
5756
|
|
- warehouseOutInfo.Dealer = stockInInfo.Dealer
|
5757
|
|
- warehouseOutInfo.Manufacturer = stockInInfo.Manufacturer
|
5758
|
|
- warehouseOutInfo.ExpiryDate = stockInInfo.ExpiryDate
|
5759
|
|
- warehouseOutInfo.ProductDate = stockInInfo.ProductDate
|
5760
|
|
- warehouseOutInfo.Number = warehouseOutInfos.Number
|
5761
|
|
- warehouseOutInfo.LicenseNumber = stockInInfo.LicenseNumber
|
5762
|
|
- warehouseOutInfo.WarehouseInfotId = stockInInfo.ID
|
5763
|
|
-
|
5764
|
|
- _, errcod := service.GetWarehouseOutInfoIsExistOne(item.GoodId, patient_id, record_time, 0)
|
5765
|
|
-
|
5766
|
|
- if errcod == gorm.ErrRecordNotFound {
|
5767
|
|
- service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
5768
|
|
-
|
5769
|
|
- stockFlow := models.VmStockFlow{
|
|
5731
|
+
|
|
5732
|
+ warehouseOutInfo := &models.WarehouseOutInfo{
|
5770
|
5733
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
5771
|
5734
|
WarehouseOutId: warehouseOut.ID,
|
5772
|
|
- GoodId: item.GoodId,
|
5773
|
|
- Number: warehouseOutInfos.Number,
|
5774
|
|
- ProductDate: stockInInfo.ProductDate,
|
5775
|
|
- ExpireDate: stockInInfo.ExpiryDate,
|
5776
|
|
- Count: item.Count,
|
5777
|
|
- Price: stockInInfo.Price,
|
5778
|
5735
|
Status: 1,
|
5779
|
5736
|
Ctime: time.Now().Unix(),
|
5780
|
|
- UserOrgId: adminInfo.Org.Id,
|
5781
|
|
- Manufacturer: stockInInfo.Manufacturer,
|
5782
|
|
- Dealer: stockInInfo.Dealer,
|
5783
|
|
- LicenseNumber: stockInInfo.LicenseNumber,
|
5784
|
|
- IsEdit: 2,
|
5785
|
|
- Creator: creater,
|
5786
|
|
- SystemTime: record_time,
|
5787
|
|
- ConsumableType: 3,
|
5788
|
|
- WarehousingDetailId: 0,
|
|
5737
|
+ OrgId: adminInfo.Org.Id,
|
|
5738
|
+ Type: 1,
|
5789
|
5739
|
IsSys: 1,
|
5790
|
|
- UpdateCreator: creater,
|
|
5740
|
+ SysRecordTime: record_time,
|
|
5741
|
+ GoodTypeId: item.GoodTypeId,
|
|
5742
|
+ GoodId: item.GoodId,
|
5791
|
5743
|
PatientId: patient_id,
|
|
5744
|
+ ConsumableType: 2,
|
5792
|
5745
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
|
5746
|
+ IsCheck: 1,
|
|
5747
|
+ OverCount: sum_count,
|
5793
|
5748
|
}
|
5794
|
|
- exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
|
5795
|
|
- if errflow == gorm.ErrRecordNotFound {
|
5796
|
|
-
|
5797
|
|
- err := service.CreateStockFlowOne(stockFlow)
|
5798
|
|
- fmt.Println("err", err)
|
5799
|
|
- } else if errflow == nil {
|
|
5749
|
+ warehouseOutInfo.Count = item.Count
|
|
5750
|
+
|
|
5751
|
+ stockInInfo, _ := service.FindLastStockInInfoRecord(item.GoodId, adminInfo.Org.Id)
|
|
5752
|
+ warehouseOutInfo.Price = stockInInfo.Price
|
|
5753
|
+ warehouseOutInfo.Dealer = stockInInfo.Dealer
|
|
5754
|
+ warehouseOutInfo.Manufacturer = stockInInfo.Manufacturer
|
|
5755
|
+ warehouseOutInfo.ExpiryDate = stockInInfo.ExpiryDate
|
|
5756
|
+ warehouseOutInfo.ProductDate = stockInInfo.ProductDate
|
|
5757
|
+ warehouseOutInfo.Number = warehouseOutInfos.Number
|
|
5758
|
+ warehouseOutInfo.LicenseNumber = stockInInfo.LicenseNumber
|
|
5759
|
+ warehouseOutInfo.WarehouseInfotId = stockInInfo.ID
|
|
5760
|
+
|
|
5761
|
+ _, errcod := service.GetWarehouseOutInfoIsExistOne(item.GoodId, patient_id, record_time, 0)
|
|
5762
|
+
|
|
5763
|
+ if errcod == gorm.ErrRecordNotFound {
|
|
5764
|
+ service.AddSigleWarehouseOutInfo(warehouseOutInfo)
|
5800
|
5765
|
|
5801
|
5766
|
stockFlow := models.VmStockFlow{
|
5802
|
|
- ID: exsit.ID,
|
5803
|
|
- WarehousingId: warehouseOutInfos.WarehouseInfotId,
|
5804
|
5767
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
5805
|
5768
|
WarehouseOutId: warehouseOut.ID,
|
5806
|
5769
|
GoodId: item.GoodId,
|
5807
|
5770
|
Number: warehouseOutInfos.Number,
|
5808
|
5771
|
ProductDate: stockInInfo.ProductDate,
|
5809
|
5772
|
ExpireDate: stockInInfo.ExpiryDate,
|
5810
|
|
- Count: exsit.Count - delete_count,
|
|
5773
|
+ Count: item.Count,
|
5811
|
5774
|
Price: stockInInfo.Price,
|
5812
|
5775
|
Status: 1,
|
5813
|
5776
|
Ctime: time.Now().Unix(),
|
|
@@ -5825,131 +5788,207 @@ func (c *DialysisAPIController) EditConsumables() {
|
5825
|
5788
|
PatientId: patient_id,
|
5826
|
5789
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
5827
|
5790
|
}
|
|
5791
|
+ exsit, errflow := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
|
|
5792
|
+ if errflow == gorm.ErrRecordNotFound {
|
|
5793
|
+
|
|
5794
|
+ err := service.CreateStockFlowOne(stockFlow)
|
|
5795
|
+ fmt.Println("err", err)
|
|
5796
|
+ } else if errflow == nil {
|
|
5797
|
+
|
|
5798
|
+ stockFlow := models.VmStockFlow{
|
|
5799
|
+ ID: exsit.ID,
|
|
5800
|
+ WarehousingId: warehouseOutInfos.WarehouseInfotId,
|
|
5801
|
+ WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
5802
|
+ WarehouseOutId: warehouseOut.ID,
|
|
5803
|
+ GoodId: item.GoodId,
|
|
5804
|
+ Number: warehouseOutInfos.Number,
|
|
5805
|
+ ProductDate: stockInInfo.ProductDate,
|
|
5806
|
+ ExpireDate: stockInInfo.ExpiryDate,
|
|
5807
|
+ Count: exsit.Count - delete_count,
|
|
5808
|
+ Price: stockInInfo.Price,
|
|
5809
|
+ Status: 1,
|
|
5810
|
+ Ctime: time.Now().Unix(),
|
|
5811
|
+ UserOrgId: adminInfo.Org.Id,
|
|
5812
|
+ Manufacturer: stockInInfo.Manufacturer,
|
|
5813
|
+ Dealer: stockInInfo.Dealer,
|
|
5814
|
+ LicenseNumber: stockInInfo.LicenseNumber,
|
|
5815
|
+ IsEdit: 2,
|
|
5816
|
+ Creator: creater,
|
|
5817
|
+ SystemTime: record_time,
|
|
5818
|
+ ConsumableType: 3,
|
|
5819
|
+ WarehousingDetailId: 0,
|
|
5820
|
+ IsSys: 1,
|
|
5821
|
+ UpdateCreator: creater,
|
|
5822
|
+ PatientId: patient_id,
|
|
5823
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
5824
|
+ }
|
5828
|
5825
|
|
5829
|
|
- service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
|
5830
|
|
- }
|
|
5826
|
+ service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
|
|
5827
|
+ }
|
5831
|
5828
|
|
5832
|
|
- } else if errcod == nil {
|
5833
|
|
- service.UpdatedWarehouseOutInfo(warehouseOutInfo, item.GoodId, patient_id, record_time, 0)
|
|
5829
|
+ } else if errcod == nil {
|
|
5830
|
+ service.UpdatedWarehouseOutInfo(warehouseOutInfo, item.GoodId, patient_id, record_time, 0)
|
5834
|
5831
|
|
5835
|
|
- fmt.Println("进来-------------------------------------------------")
|
|
5832
|
+
|
|
5833
|
+ goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
|
|
5834
|
+ var sum_count int64
|
|
5835
|
+ for _, item := range goodList {
|
|
5836
|
+ sum_count += item.StockCount
|
|
5837
|
+ }
|
5836
|
5838
|
|
5837
|
|
-
|
5838
|
|
- goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
|
5839
|
|
- var sum_count int64
|
5840
|
|
- for _, item := range goodList {
|
5841
|
|
- sum_count += item.StockCount
|
|
5839
|
+
|
|
5840
|
+ houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
|
5841
|
+ good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
|
|
5842
|
+
|
|
5843
|
+ operation_time := time.Now().Unix()
|
|
5844
|
+ creater := adminInfo.AdminUser.Id
|
|
5845
|
+
|
|
5846
|
+ timeStr := time.Now().Format("2006-01-02")
|
|
5847
|
+ timeArr := strings.Split(timeStr, "-")
|
|
5848
|
+ total, _ := service.FindAllCancelStockTotal(adminInfo.Org.Id)
|
|
5849
|
+ total = total + 1
|
|
5850
|
+ orderNumber := "CKTKD" + strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
|
|
5851
|
+
|
|
5852
|
+ cancelStock := models.CancelStock{
|
|
5853
|
+ OrderNumber: orderNumber,
|
|
5854
|
+ OperaTime: operation_time,
|
|
5855
|
+ OrgId: adminInfo.Org.Id,
|
|
5856
|
+ Creater: creater,
|
|
5857
|
+ Ctime: time.Now().Unix(),
|
|
5858
|
+ Status: 1,
|
|
5859
|
+ ReturnTime: record_time,
|
|
5860
|
+ Type: 1,
|
|
5861
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
5862
|
+ IsCheck: 1,
|
|
5863
|
+ }
|
|
5864
|
+ _, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(record_time, adminInfo.Org.Id)
|
|
5865
|
+ if msgerrkonde == gorm.ErrRecordNotFound {
|
|
5866
|
+ service.AddSigleCancelStock(&cancelStock)
|
|
5867
|
+ }
|
|
5868
|
+ cancel, _ := service.GetLastCancelStockById(adminInfo.Org.Id)
|
|
5869
|
+
|
|
5870
|
+
|
|
5871
|
+ info, _ := service.GetLastWarehoseByGoodId(item.GoodId, patient_id, record_time)
|
|
5872
|
+
|
|
5873
|
+ manufacturer, _ := service.GetManufactureById(info.Manufacturer)
|
|
5874
|
+ deaerler, _ := service.GetDealerById(info.Dealer)
|
|
5875
|
+
|
|
5876
|
+ if info.ID > 0 {
|
|
5877
|
+ cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
|
|
5878
|
+ cancelStockInfo := models.CancelStockInfo{
|
|
5879
|
+ GoodId: item.GoodId,
|
|
5880
|
+ CancelStockId: cancel.ID,
|
|
5881
|
+ GoodTypeId: good.GoodTypeId,
|
|
5882
|
+ Count: delete_count,
|
|
5883
|
+ Price: info.Price,
|
|
5884
|
+ Total: 0,
|
|
5885
|
+ ProductDate: info.ProductDate,
|
|
5886
|
+ ExpiryDate: info.ExpiryDate,
|
|
5887
|
+ Ctime: time.Now().Unix(),
|
|
5888
|
+ Status: 1,
|
|
5889
|
+ OrgId: adminInfo.Org.Id,
|
|
5890
|
+ OrderNumber: cancel.OrderNumber,
|
|
5891
|
+ Type: 0,
|
|
5892
|
+ Dealer: deaerler.DealerName,
|
|
5893
|
+ Manufacturer: manufacturer.ManufacturerName,
|
|
5894
|
+ Number: info.Number,
|
|
5895
|
+ RegisterAccount: "",
|
|
5896
|
+ Remark: "",
|
|
5897
|
+ WarehouseInfoId: info.WarehouseInfotId,
|
|
5898
|
+ PatientId: info.PatientId,
|
|
5899
|
+ RecordDate: info.SysRecordTime,
|
|
5900
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
5901
|
+ IsCheck: 1,
|
|
5902
|
+ }
|
|
5903
|
+
|
|
5904
|
+ service.CreateCancelStockInfoOne(&cancelStockInfo)
|
|
5905
|
+
|
|
5906
|
+
|
|
5907
|
+ service.UpdateSumAddCancelCount(adminInfo.Org.Id, item.GoodId, houseConfig.StorehouseOutInfo, delete_count)
|
|
5908
|
+
|
|
5909
|
+
|
|
5910
|
+ goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId)
|
|
5911
|
+ var over_count int64
|
|
5912
|
+ for _, it := range goodList {
|
|
5913
|
+ over_count += it.StockCount
|
|
5914
|
+ }
|
|
5915
|
+
|
|
5916
|
+ flow := models.VmStockFlow{
|
|
5917
|
+ WarehousingId: info.WarehouseInfotId,
|
|
5918
|
+ GoodId: item.GoodId,
|
|
5919
|
+ Number: info.Number,
|
|
5920
|
+ LicenseNumber: info.LicenseNumber,
|
|
5921
|
+ Count: delete_count,
|
|
5922
|
+ UserOrgId: adminInfo.Org.Id,
|
|
5923
|
+ PatientId: patient_id,
|
|
5924
|
+ SystemTime: info.SysRecordTime,
|
|
5925
|
+ ConsumableType: 7,
|
|
5926
|
+ IsSys: 0,
|
|
5927
|
+ WarehousingOrder: "",
|
|
5928
|
+ WarehouseOutId: info.WarehouseOutId,
|
|
5929
|
+ WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
|
|
5930
|
+ IsEdit: 0,
|
|
5931
|
+ CancelStockId: cancel.ID,
|
|
5932
|
+ CancelOrderNumber: cancel.OrderNumber,
|
|
5933
|
+ Manufacturer: manufacturer.ID,
|
|
5934
|
+ Dealer: 0,
|
|
5935
|
+ Creator: adminInfo.AdminUser.Id,
|
|
5936
|
+ UpdateCreator: 0,
|
|
5937
|
+ Status: 1,
|
|
5938
|
+ Ctime: time.Now().Unix(),
|
|
5939
|
+ Mtime: 0,
|
|
5940
|
+ Price: info.Price,
|
|
5941
|
+ WarehousingDetailId: info.WarehouseInfotId,
|
|
5942
|
+ WarehouseOutDetailId: info.ID,
|
|
5943
|
+ CancelOutDetailId: cancelInfo.ID,
|
|
5944
|
+ ProductDate: info.ProductDate,
|
|
5945
|
+ ExpireDate: info.ExpiryDate,
|
|
5946
|
+ StorehouseId: houseConfig.StorehouseOutInfo,
|
|
5947
|
+ OverCount: over_count,
|
|
5948
|
+ }
|
|
5949
|
+ service.CreateStockFlowOne(flow)
|
|
5950
|
+
|
|
5951
|
+ }
|
5842
|
5952
|
}
|
5843
|
|
-
|
5844
|
|
- stockFlow := models.VmStockFlow{
|
5845
|
|
- WarehousingId: warehouseOutInfos.WarehouseInfotId,
|
5846
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
5847
|
|
- WarehouseOutId: warehouseOut.ID,
|
|
5953
|
+
|
|
5954
|
+
|
|
5955
|
+ details := models.BloodAutomaticReduceDetail{
|
|
5956
|
+ WarehouseOutId: warehouseOutInfo.ID,
|
|
5957
|
+ WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
|
5958
|
+ PatientId: patient_id,
|
|
5959
|
+ Ctime: time.Now().Unix(),
|
|
5960
|
+ Mtime: time.Now().Unix(),
|
|
5961
|
+ Status: 1,
|
|
5962
|
+ RecordTime: record_time,
|
|
5963
|
+ OrgId: adminInfo.Org.Id,
|
5848
|
5964
|
GoodId: item.GoodId,
|
5849
|
|
- Number: warehouseOutInfos.Number,
|
5850
|
|
- ProductDate: stockInInfo.ProductDate,
|
5851
|
|
- ExpireDate: stockInInfo.ExpiryDate,
|
|
5965
|
+ GoodTypeId: item.GoodTypeId,
|
5852
|
5966
|
Count: item.Count,
|
5853
|
|
- Price: stockInInfo.Price,
|
5854
|
|
- Status: 1,
|
5855
|
|
- Ctime: time.Now().Unix(),
|
5856
|
|
- UserOrgId: adminInfo.Org.Id,
|
5857
|
|
- Manufacturer: stockInInfo.Manufacturer,
|
5858
|
|
- Dealer: stockInInfo.Dealer,
|
5859
|
|
- LicenseNumber: stockInInfo.LicenseNumber,
|
5860
|
|
- IsEdit: 2,
|
5861
|
|
- Creator: creater,
|
5862
|
|
- SystemTime: record_time,
|
5863
|
|
- ConsumableType: 3,
|
5864
|
|
- WarehousingDetailId: 0,
|
5865
|
|
- IsSys: 1,
|
5866
|
|
- UpdateCreator: creater,
|
5867
|
|
- PatientId: patient_id,
|
5868
|
|
- ReturnCount: delete_count,
|
5869
|
5967
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
5870
|
|
- OverCount: sum_count,
|
5871
|
|
- }
|
5872
|
|
- exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
|
5873
|
|
-
|
5874
|
|
- if errflows == gorm.ErrRecordNotFound {
|
5875
|
|
-
|
5876
|
|
- service.CreateStockFlowOne(stockFlow)
|
5877
|
|
- } else if errflows == nil {
|
5878
|
|
- stockFlow := models.VmStockFlow{
|
5879
|
|
- WarehousingId: warehouseOutInfos.WarehouseInfotId,
|
5880
|
|
- ID: exsit.ID,
|
5881
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
5882
|
|
- WarehouseOutId: warehouseOut.ID,
|
5883
|
|
- GoodId: item.GoodId,
|
5884
|
|
- Number: warehouseOutInfos.Number,
|
5885
|
|
- ProductDate: stockInInfo.ProductDate,
|
5886
|
|
- ExpireDate: stockInInfo.ExpiryDate,
|
5887
|
|
- Count: exsit.Count - delete_count,
|
5888
|
|
- Price: stockInInfo.Price,
|
5889
|
|
- Status: 1,
|
5890
|
|
- Ctime: time.Now().Unix(),
|
5891
|
|
- UserOrgId: adminInfo.Org.Id,
|
5892
|
|
- Manufacturer: stockInInfo.Manufacturer,
|
5893
|
|
- Dealer: stockInInfo.Dealer,
|
5894
|
|
- LicenseNumber: stockInInfo.LicenseNumber,
|
5895
|
|
- IsEdit: 2,
|
5896
|
|
- Creator: creater,
|
5897
|
|
- SystemTime: record_time,
|
5898
|
|
- ConsumableType: 3,
|
5899
|
|
- WarehousingDetailId: 0,
|
5900
|
|
- IsSys: 1,
|
5901
|
|
- UpdateCreator: creater,
|
5902
|
|
- PatientId: patient_id,
|
5903
|
|
- ReturnCount: delete_count,
|
5904
|
|
- StorehouseId: houseConfig.StorehouseOutInfo,
|
5905
|
|
- OverCount: exsit.OverCount + delete_count,
|
5906
|
|
- }
|
5907
|
|
- fmt.Println("stockFlow--------------------", stockFlow.OverCount)
|
5908
|
|
- service.UpdatedStockFlowFive(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
|
5909
|
5968
|
}
|
|
5969
|
+
|
|
5970
|
+ _, errcode := service.GetAutoMaticReduceDetail(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
5910
|
5971
|
|
5911
|
|
- }
|
5912
|
|
-
|
5913
|
|
-
|
5914
|
|
- details := models.BloodAutomaticReduceDetail{
|
5915
|
|
- WarehouseOutId: warehouseOutInfo.ID,
|
5916
|
|
- WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
5917
|
|
- PatientId: patient_id,
|
5918
|
|
- Ctime: time.Now().Unix(),
|
5919
|
|
- Mtime: time.Now().Unix(),
|
5920
|
|
- Status: 1,
|
5921
|
|
- RecordTime: record_time,
|
5922
|
|
- OrgId: adminInfo.Org.Id,
|
5923
|
|
- GoodId: item.GoodId,
|
5924
|
|
- GoodTypeId: item.GoodTypeId,
|
5925
|
|
- Count: item.Count,
|
5926
|
|
- StorehouseId: houseConfig.StorehouseOutInfo,
|
5927
|
|
- }
|
5928
|
|
-
|
5929
|
|
- _, errcode := service.GetAutoMaticReduceDetail(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
5930
|
|
-
|
5931
|
|
- if errcode == gorm.ErrRecordNotFound {
|
5932
|
|
- service.CreateAutoReduceRecord(&details)
|
|
5972
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
5973
|
+ service.CreateAutoReduceRecord(&details)
|
5933
|
5974
|
|
5934
|
|
- } else if errcode == nil {
|
5935
|
|
- service.DeleteAutoRedeceDetailTwo(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
5936
|
|
- service.CreateAutoReduceRecord(&details)
|
|
5975
|
+ } else if errcode == nil {
|
|
5976
|
+ service.DeleteAutoRedeceDetailTwo(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
|
|
5977
|
+ service.CreateAutoReduceRecord(&details)
|
5937
|
5978
|
|
5938
|
|
- }
|
|
5979
|
+ }
|
5939
|
5980
|
|
5940
|
|
-
|
5941
|
|
-
|
|
5981
|
+
|
|
5982
|
+ storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
|
5983
|
+ stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
|
|
5984
|
+ var total_count int64
|
|
5985
|
+ for _, it := range stockList {
|
|
5986
|
+ total_count += it.StockCount
|
|
5987
|
+ }
|
|
5988
|
+
|
|
5989
|
+ service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
|
5942
|
5990
|
|
5943
|
|
-
|
5944
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
5945
|
|
- stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
|
5946
|
|
- var total_count int64
|
5947
|
|
- for _, it := range stockList {
|
5948
|
|
- total_count += it.StockCount
|
5949
|
5991
|
}
|
5950
|
|
-
|
5951
|
|
- service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
|
5952
|
|
-
|
5953
|
5992
|
}
|
5954
|
5993
|
|
5955
|
5994
|
fmt.Println("lnet---------------------------", len(outbefor))
|
|
@@ -5963,26 +6002,9 @@ func (c *DialysisAPIController) EditConsumables() {
|
5963
|
6002
|
|
5964
|
6003
|
last_total = item.Count - goodInfoOne.Count
|
5965
|
6004
|
|
5966
|
|
-
|
5967
|
|
- lastInfo, _ := service.GetLastStockOut(goodInfoOne.WarehouseInfotId)
|
5968
|
|
-
|
5969
|
|
- if lastInfo.StockCount == 0 {
|
5970
|
|
-
|
5971
|
|
- wareinfo, _ := service.GetStockGoodCount(item.GoodId)
|
5972
|
|
- if wareinfo.StockCount == 0 {
|
5973
|
|
- goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
5974
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
5975
|
|
- "message": "1",
|
5976
|
|
- "good_name": goodObj.GoodName,
|
5977
|
|
- "specification_name": goodObj.SpecificationName,
|
5978
|
|
- })
|
5979
|
|
- return
|
5980
|
|
- }
|
5981
|
|
-
|
5982
|
|
- }
|
5983
|
|
-
|
5984
|
6005
|
|
5985
|
6006
|
wareinfo, _ := service.GetStockGoodCount(item.GoodId)
|
|
6007
|
+
|
5986
|
6008
|
|
5987
|
6009
|
if last_total > wareinfo.StockCount {
|
5988
|
6010
|
goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
|
@@ -6048,8 +6070,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
6048
|
6070
|
ProjectId: 0,
|
6049
|
6071
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
6050
|
6072
|
}
|
6051
|
|
-
|
6052
|
|
-
|
|
6073
|
+
|
6053
|
6074
|
service.ConsumablesGoodDelivery(adminInfo.Org.Id, patient_id, record_time, &prepare, &out, item.Count)
|
6054
|
6075
|
|
6055
|
6076
|
service.ModifyGoodSumCount(houseConfig.StorehouseOutInfo, prepare.Count, adminInfo.Org.Id, item.GoodId)
|
|
@@ -6109,6 +6130,7 @@ func (c *DialysisAPIController) EditConsumables() {
|
6109
|
6130
|
for _, it := range goodList {
|
6110
|
6131
|
flush_count += it.StockCount
|
6111
|
6132
|
}
|
|
6133
|
+
|
6112
|
6134
|
service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, it.GoodId, flush_count)
|
6113
|
6135
|
|
6114
|
6136
|
}
|
|
@@ -6373,13 +6395,19 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
|
6373
|
6395
|
}
|
6374
|
6396
|
project_id := int64(items["project_id"].(float64))
|
6375
|
6397
|
|
|
6398
|
+ new_count := int64(items["new_count"].(float64))
|
|
6399
|
+ old_count := int64(items["old_count"].(float64))
|
|
6400
|
+
|
6376
|
6401
|
prepare := &models.DialysisBeforePrepareGoods{
|
6377
|
6402
|
GoodId: good_id,
|
6378
|
6403
|
GoodTypeId: good_type_id,
|
6379
|
6404
|
Count: count,
|
6380
|
6405
|
ProjectId: project_id,
|
6381
|
6406
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
|
6407
|
+ NewCount: new_count,
|
|
6408
|
+ OldCount: old_count,
|
6382
|
6409
|
}
|
|
6410
|
+
|
6383
|
6411
|
beforePrepares = append(beforePrepares, prepare)
|
6384
|
6412
|
|
6385
|
6413
|
newPrepare := &models.NewDialysisBeforePrepareGoods{
|
|
@@ -6388,25 +6416,35 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
|
6388
|
6416
|
Count: count,
|
6389
|
6417
|
ProjectId: project_id,
|
6390
|
6418
|
StorehouseId: houseConfig.StorehouseOutInfo,
|
|
6419
|
+ NewCount: new_count,
|
|
6420
|
+ OldCount: old_count,
|
6391
|
6421
|
}
|
|
6422
|
+
|
6392
|
6423
|
newBeforePrepares = append(newBeforePrepares, newPrepare)
|
|
6424
|
+
|
6393
|
6425
|
}
|
6394
|
6426
|
}
|
6395
|
6427
|
}
|
6396
|
6428
|
|
6397
|
6429
|
|
|
6430
|
+
|
6398
|
6431
|
for _, item := range beforePrepares {
|
6399
|
|
- storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
6400
|
|
- warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, storeConfig.StorehouseOutInfo)
|
6401
|
|
- if item.Count > warehouse.Count {
|
6402
|
|
- goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
6403
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
6404
|
|
- "message": "1",
|
6405
|
|
- "good_name": goodObj.GoodName,
|
6406
|
|
- "specification_name": goodObj.SpecificationName,
|
6407
|
|
- })
|
6408
|
|
- return
|
|
6432
|
+
|
|
6433
|
+ if item.NewCount > 0 {
|
|
6434
|
+ storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
|
|
6435
|
+ warehouse, _ := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId, storeConfig.StorehouseOutInfo)
|
|
6436
|
+
|
|
6437
|
+ if item.Count > warehouse.Count {
|
|
6438
|
+ goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
|
6439
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
6440
|
+ "message": "1",
|
|
6441
|
+ "good_name": goodObj.GoodName,
|
|
6442
|
+ "specification_name": goodObj.SpecificationName,
|
|
6443
|
+ })
|
|
6444
|
+ return
|
|
6445
|
+ }
|
6409
|
6446
|
}
|
|
6447
|
+
|
6410
|
6448
|
}
|
6411
|
6449
|
|
6412
|
6450
|
|