|
@@ -541,19 +541,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
541
|
541
|
|
542
|
542
|
adminUserInfo := c.GetMobileAdminUserInfo()
|
543
|
543
|
|
544
|
|
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
|
545
|
|
- //
|
546
|
|
- //if appRole.UserType == 2 || appRole.UserType == 1 {
|
547
|
|
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
|
548
|
|
- // if getPermissionErr != nil {
|
549
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
550
|
|
- // return
|
551
|
|
- // } else if headNursePermission == nil {
|
552
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
|
553
|
|
- // return
|
554
|
|
- // }
|
555
|
|
- //}
|
556
|
|
-
|
557
|
544
|
var advice models.DoctorAdvice
|
558
|
545
|
|
559
|
546
|
if groupno > 0 {
|
|
@@ -561,7 +548,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
561
|
548
|
for _, item := range advices {
|
562
|
549
|
if item.ExecutionState == 2 {
|
563
|
550
|
advice = item
|
564
|
|
-
|
565
|
551
|
}
|
566
|
552
|
}
|
567
|
553
|
} else {
|
|
@@ -569,7 +555,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
569
|
555
|
for _, item := range advices {
|
570
|
556
|
if item.ExecutionState == 2 {
|
571
|
557
|
advice = item
|
572
|
|
-
|
573
|
558
|
}
|
574
|
559
|
}
|
575
|
560
|
}
|
|
@@ -628,327 +613,34 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
628
|
613
|
if groupno > 0 {
|
629
|
614
|
advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
|
630
|
615
|
isHasWay := false //用来判断是否包含来自药品库的医嘱
|
631
|
|
- record_time := int64(0)
|
632
|
616
|
for _, item := range advices {
|
633
|
617
|
if item.Way == 1 {
|
634
|
618
|
isHasWay = true
|
635
|
|
- record_time = item.RecordDate
|
636
|
619
|
}
|
637
|
620
|
}
|
638
|
621
|
|
639
|
622
|
if isHasWay {
|
640
|
|
- _, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
641
|
|
- if err == gorm.ErrRecordNotFound {
|
642
|
|
- //没有记录,则创建出库单
|
643
|
|
- timeStr := time.Now().Format("2006-01-02")
|
644
|
|
- timeArr := strings.Split(timeStr, "-")
|
645
|
|
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
|
646
|
|
- total = total + 1
|
647
|
|
- warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
648
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
649
|
|
- number = number + total
|
650
|
|
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
651
|
|
- creater := adminUserInfo.AdminUser.Id
|
652
|
|
- warehouseOut := models.DrugWarehouseOut{
|
653
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
654
|
|
- OperationTime: time.Now().Unix(),
|
655
|
|
- OrgId: adminUserInfo.Org.Id,
|
656
|
|
- Creater: creater,
|
657
|
|
- Ctime: time.Now().Unix(),
|
658
|
|
- Status: 1,
|
659
|
|
- WarehouseOutTime: record_time,
|
660
|
|
- Dealer: 0,
|
661
|
|
- Manufacturer: 0,
|
662
|
|
- Type: 1,
|
663
|
|
- IsSys: 1,
|
664
|
|
- }
|
665
|
|
- err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
666
|
|
- if err != nil {
|
667
|
|
- utils.TraceLog("创建出库单失败 err = %v", err)
|
668
|
|
- } else {
|
669
|
|
- for _, item := range advices {
|
670
|
|
- if item.Way == 1 {
|
671
|
|
-
|
672
|
|
- service.DrugsDelivery(item.UserOrgId, &item)
|
673
|
|
-
|
674
|
|
- //if item.PrescribingNumber > 0 {
|
675
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
676
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
677
|
|
- // WarehouseOutId: warehouseOut.ID,
|
678
|
|
- // Status: 1,
|
679
|
|
- // Ctime: time.Now().Unix(),
|
680
|
|
- // Remark: "",
|
681
|
|
- // OrgId: adminUserInfo.Org.Id,
|
682
|
|
- // Type: 1,
|
683
|
|
- // Manufacturer: 0,
|
684
|
|
- // Dealer: 0,
|
685
|
|
- // IsSys: 1,
|
686
|
|
- // SysRecordTime: record_time,
|
687
|
|
- // DrugId: item.DrugId,
|
688
|
|
- // }
|
689
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
690
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
691
|
|
- // warehouseOutInfo.Count = count
|
692
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
693
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
694
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
695
|
|
- // if err == nil {
|
696
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
697
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
698
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
699
|
|
- // PatientId: item.PatientId,
|
700
|
|
- // Ctime: time.Now().Unix(),
|
701
|
|
- // Mtime: time.Now().Unix(),
|
702
|
|
- // Status: 1,
|
703
|
|
- // RecordTime: record_time,
|
704
|
|
- // OrgId: adminUserInfo.Org.Id,
|
705
|
|
- // DrugId: item.DrugId,
|
706
|
|
- // Count: count,
|
707
|
|
- // }
|
708
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
709
|
|
- // }
|
710
|
|
- //}
|
711
|
|
- }
|
712
|
|
-
|
713
|
|
- }
|
714
|
|
- }
|
715
|
|
-
|
716
|
|
- } else if err == nil {
|
717
|
|
- for _, item := range advices {
|
718
|
|
- if item.Way == 1 {
|
719
|
|
- service.DrugsDelivery(item.UserOrgId, &item)
|
720
|
|
- //outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
721
|
|
- //if err == gorm.ErrRecordNotFound {
|
722
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
723
|
|
- // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
724
|
|
- // WarehouseOutId: out.ID,
|
725
|
|
- // Status: 1,
|
726
|
|
- // Ctime: time.Now().Unix(),
|
727
|
|
- // Remark: "",
|
728
|
|
- // OrgId: adminUserInfo.Org.Id,
|
729
|
|
- // Type: 1,
|
730
|
|
- // Manufacturer: 0,
|
731
|
|
- // Dealer: 0,
|
732
|
|
- // IsSys: 1,
|
733
|
|
- // SysRecordTime: record_time,
|
734
|
|
- // }
|
735
|
|
- //
|
736
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
737
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
738
|
|
- // warehouseOutInfo.DrugId = item.DrugId
|
739
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
740
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
741
|
|
- // warehouseOutInfo.Count = count
|
742
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
743
|
|
- // if err == nil {
|
744
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
745
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
746
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
747
|
|
- // PatientId: item.PatientId,
|
748
|
|
- // Ctime: time.Now().Unix(),
|
749
|
|
- // Mtime: time.Now().Unix(),
|
750
|
|
- // Status: 1,
|
751
|
|
- // RecordTime: record_time,
|
752
|
|
- // OrgId: adminUserInfo.Org.Id,
|
753
|
|
- // DrugId: item.DrugId,
|
754
|
|
- // Count: count,
|
755
|
|
- // }
|
756
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
757
|
|
- // }
|
758
|
|
- //
|
759
|
|
- //} else if err == nil { //记录存在,则将增加数量
|
760
|
|
- // if outInfo.ID > 0 {
|
761
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
762
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
763
|
|
- // service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
764
|
|
- // }
|
765
|
|
- //
|
766
|
|
- // //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
767
|
|
- // //if count == 0 {
|
768
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
769
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
770
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
771
|
|
- // WarehouseOutId: outInfo.ID,
|
772
|
|
- // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
773
|
|
- // PatientId: item.PatientId,
|
774
|
|
- // Ctime: time.Now().Unix(),
|
775
|
|
- // Mtime: time.Now().Unix(),
|
776
|
|
- // Status: 1,
|
777
|
|
- // RecordTime: record_time,
|
778
|
|
- // OrgId: adminUserInfo.Org.Id,
|
779
|
|
- // DrugId: item.DrugId,
|
780
|
|
- // Count: count,
|
781
|
|
- // }
|
782
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
783
|
|
- //
|
784
|
|
- //}
|
785
|
|
- }
|
|
623
|
+ for _, item := range advices {
|
|
624
|
+ if item.Way == 1 {
|
|
625
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
786
|
626
|
}
|
787
|
|
-
|
788
|
627
|
}
|
789
|
|
-
|
790
|
628
|
}
|
791
|
629
|
} else {
|
792
|
630
|
advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
|
793
|
631
|
isHasWay := false //用来判断是否包含来自药品库的医嘱
|
794
|
|
- record_time := int64(0)
|
|
632
|
+
|
795
|
633
|
for _, item := range advices {
|
796
|
634
|
if item.Way == 1 {
|
797
|
635
|
isHasWay = true
|
798
|
|
- record_time = item.RecordDate
|
799
|
636
|
}
|
800
|
637
|
}
|
801
|
|
-
|
802
|
638
|
if isHasWay {
|
803
|
|
- _, err := service.FindDrugStockOutByIsSys(adminUserInfo.Org.Id, 1, record_time)
|
804
|
|
- if err == gorm.ErrRecordNotFound {
|
805
|
|
- //没有记录,则创建出库单
|
806
|
|
- timeStr := time.Now().Format("2006-01-02")
|
807
|
|
- timeArr := strings.Split(timeStr, "-")
|
808
|
|
- total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
|
809
|
|
- total = total + 1
|
810
|
|
- warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
811
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
812
|
|
- number = number + total
|
813
|
|
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
814
|
|
- creater := adminUserInfo.AdminUser.Id
|
815
|
|
- warehouseOut := models.DrugWarehouseOut{
|
816
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
817
|
|
- OperationTime: time.Now().Unix(),
|
818
|
|
- OrgId: adminUserInfo.Org.Id,
|
819
|
|
- Creater: creater,
|
820
|
|
- Ctime: time.Now().Unix(),
|
821
|
|
- Status: 1,
|
822
|
|
- WarehouseOutTime: record_time,
|
823
|
|
- Dealer: 0,
|
824
|
|
- Manufacturer: 0,
|
825
|
|
- Type: 1,
|
826
|
|
- IsSys: 1,
|
827
|
|
- }
|
828
|
|
- err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
829
|
|
- if err != nil {
|
830
|
|
- utils.TraceLog("创建出库单失败 err = %v", err)
|
831
|
|
- } else {
|
832
|
|
- for _, item := range advices {
|
833
|
|
- if item.Way == 1 {
|
834
|
|
- service.DrugsDelivery(item.UserOrgId, &item)
|
835
|
|
- //if item.PrescribingNumber > 0 {
|
836
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
837
|
|
- // WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
838
|
|
- // WarehouseOutId: warehouseOut.ID,
|
839
|
|
- // Status: 1,
|
840
|
|
- // Ctime: time.Now().Unix(),
|
841
|
|
- // Remark: "",
|
842
|
|
- // OrgId: adminUserInfo.Org.Id,
|
843
|
|
- // Type: 1,
|
844
|
|
- // Manufacturer: 0,
|
845
|
|
- // Dealer: 0,
|
846
|
|
- // IsSys: 1,
|
847
|
|
- // SysRecordTime: record_time,
|
848
|
|
- // DrugId: item.DrugId,
|
849
|
|
- // }
|
850
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
851
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
852
|
|
- // warehouseOutInfo.Count = count
|
853
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
854
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
855
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
856
|
|
- // if err == nil {
|
857
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
858
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
859
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
860
|
|
- // PatientId: item.PatientId,
|
861
|
|
- // Ctime: time.Now().Unix(),
|
862
|
|
- // Mtime: time.Now().Unix(),
|
863
|
|
- // Status: 1,
|
864
|
|
- // RecordTime: record_time,
|
865
|
|
- // OrgId: adminUserInfo.Org.Id,
|
866
|
|
- // DrugId: item.DrugId,
|
867
|
|
- // Count: count,
|
868
|
|
- // }
|
869
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
870
|
|
- // }
|
871
|
|
- //}
|
872
|
|
- }
|
873
|
|
-
|
874
|
|
- }
|
|
639
|
+ for _, item := range advices {
|
|
640
|
+ if item.Way == 1 {
|
|
641
|
+ service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
|
875
|
642
|
}
|
876
|
|
-
|
877
|
|
- } else if err == nil {
|
878
|
|
- for _, item := range advices {
|
879
|
|
- if item.Way == 1 {
|
880
|
|
- service.DrugsDelivery(item.UserOrgId, &item)
|
881
|
|
- //outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
882
|
|
- //if err == gorm.ErrRecordNotFound {
|
883
|
|
- // warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
884
|
|
- // WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
885
|
|
- // WarehouseOutId: out.ID,
|
886
|
|
- // Status: 1,
|
887
|
|
- // Ctime: time.Now().Unix(),
|
888
|
|
- // Remark: "",
|
889
|
|
- // OrgId: adminUserInfo.Org.Id,
|
890
|
|
- // Type: 1,
|
891
|
|
- // Manufacturer: 0,
|
892
|
|
- // Dealer: 0,
|
893
|
|
- // IsSys: 1,
|
894
|
|
- // SysRecordTime: record_time,
|
895
|
|
- // }
|
896
|
|
- //
|
897
|
|
- // stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.Org.Id)
|
898
|
|
- // warehouseOutInfo.Price = stockInInfo.Price
|
899
|
|
- // warehouseOutInfo.DrugId = item.DrugId
|
900
|
|
- // //warehouseOutInfo.Count = item.
|
901
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
902
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
903
|
|
- // err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
904
|
|
- // if err == nil {
|
905
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
906
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
907
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
908
|
|
- // PatientId: item.PatientId,
|
909
|
|
- // Ctime: time.Now().Unix(),
|
910
|
|
- // Mtime: time.Now().Unix(),
|
911
|
|
- // Status: 1,
|
912
|
|
- // RecordTime: record_time,
|
913
|
|
- // OrgId: adminUserInfo.Org.Id,
|
914
|
|
- // DrugId: item.DrugId,
|
915
|
|
- // Count: count,
|
916
|
|
- // }
|
917
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
918
|
|
- // }
|
919
|
|
- //
|
920
|
|
- //} else if err == nil { //记录存在,则将增加数量
|
921
|
|
- // if outInfo.ID > 0 {
|
922
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
923
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
924
|
|
- // service.UpdateDrugStockOutInfoCount2(adminUserInfo.Org.Id, outInfo.ID, count)
|
925
|
|
- // }
|
926
|
|
- //
|
927
|
|
- // //count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.Org.Id, record_time, item.DrugId, item.PatientId)
|
928
|
|
- // //if count == 0 {
|
929
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
|
930
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
931
|
|
- // details := &models.DrugAutomaticReduceDetail{
|
932
|
|
- // WarehouseOutId: outInfo.ID,
|
933
|
|
- // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
934
|
|
- // PatientId: item.PatientId,
|
935
|
|
- // Ctime: time.Now().Unix(),
|
936
|
|
- // Mtime: time.Now().Unix(),
|
937
|
|
- // Status: 1,
|
938
|
|
- // RecordTime: record_time,
|
939
|
|
- // OrgId: adminUserInfo.Org.Id,
|
940
|
|
- // DrugId: item.DrugId,
|
941
|
|
- // Count: count,
|
942
|
|
- // }
|
943
|
|
- // service.AddSigleDrugAutoReduceRecordInfo(details)
|
944
|
|
- //
|
945
|
|
- //
|
946
|
|
- //}
|
947
|
|
- }
|
948
|
|
- }
|
949
|
|
-
|
950
|
643
|
}
|
951
|
|
-
|
952
|
644
|
}
|
953
|
645
|
}
|
954
|
646
|
}
|
|
@@ -1070,6 +762,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1070
|
762
|
return
|
1071
|
763
|
}
|
1072
|
764
|
adminInfo := c.GetMobileAdminUserInfo()
|
|
765
|
+ creater := c.GetMobileAdminUserInfo().AdminUser.Id
|
1073
|
766
|
advice_id, _ := c.GetInt64("advice_id")
|
1074
|
767
|
advices, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, advice_id)
|
1075
|
768
|
if advices.ExecutionState == 1 {
|
|
@@ -1096,143 +789,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1096
|
789
|
fmt.Println("drugstockconfig000000000000000000000000", drugStockConfig.IsOpen)
|
1097
|
790
|
if drugStockConfig.IsOpen == 1 {
|
1098
|
791
|
advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, advice_id)
|
1099
|
|
- record_time := advice.RecordDate
|
1100
|
|
-
|
1101
|
|
- out, err := service.FindDrugStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
|
1102
|
|
- if err == gorm.ErrRecordNotFound {
|
1103
|
|
- //没有记录,则创建出库单
|
1104
|
|
- timeStr := time.Now().Format("2006-01-02")
|
1105
|
|
- timeArr := strings.Split(timeStr, "-")
|
1106
|
|
- total, _ := service.FindAllDrugWarehouseOut(adminInfo.Org.Id)
|
1107
|
|
- total = total + 1
|
1108
|
|
- warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
|
1109
|
|
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
|
1110
|
|
- number = number + total
|
1111
|
|
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
|
1112
|
|
- creater := adminInfo.AdminUser.Id
|
1113
|
|
- warehouseOut := models.DrugWarehouseOut{
|
1114
|
|
- WarehouseOutOrderNumber: warehousing_out_order,
|
1115
|
|
- OperationTime: time.Now().Unix(),
|
1116
|
|
- OrgId: adminInfo.Org.Id,
|
1117
|
|
- Creater: creater,
|
1118
|
|
- Ctime: time.Now().Unix(),
|
1119
|
|
- Status: 1,
|
1120
|
|
- WarehouseOutTime: record_time,
|
1121
|
|
- Dealer: 0,
|
1122
|
|
- Manufacturer: 0,
|
1123
|
|
- Type: 1,
|
1124
|
|
- IsSys: 1,
|
1125
|
|
- }
|
1126
|
|
- err := service.AddSigleDrugWarehouseOut(&warehouseOut)
|
1127
|
|
- if err != nil {
|
1128
|
|
- utils.TraceLog("创建出库单失败 err = %v", err)
|
1129
|
|
- } else {
|
1130
|
|
- if advice.PrescribingNumber > 0 {
|
1131
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1132
|
|
- WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1133
|
|
- WarehouseOutId: warehouseOut.ID,
|
1134
|
|
- Status: 1,
|
1135
|
|
- Ctime: time.Now().Unix(),
|
1136
|
|
- Remark: "",
|
1137
|
|
- OrgId: adminInfo.Org.Id,
|
1138
|
|
- Type: 1,
|
1139
|
|
- Manufacturer: 0,
|
1140
|
|
- Dealer: 0,
|
1141
|
|
- IsSys: 1,
|
1142
|
|
- SysRecordTime: record_time,
|
1143
|
|
- DrugId: advice.DrugId,
|
1144
|
|
- }
|
1145
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1146
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1147
|
|
- warehouseOutInfo.Count = count
|
1148
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(advice.DrugId, adminInfo.Org.Id)
|
1149
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
1150
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1151
|
|
-
|
1152
|
|
- if err == nil {
|
1153
|
|
- service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
1154
|
|
- //details := &models.DrugAutomaticReduceDetail{
|
1155
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
1156
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1157
|
|
- // PatientId: advice.PatientId,
|
1158
|
|
- // Ctime: time.Now().Unix(),
|
1159
|
|
- // Mtime: time.Now().Unix(),
|
1160
|
|
- // Status: 1,
|
1161
|
|
- // RecordTime: record_time,
|
1162
|
|
- // OrgId: adminInfo.Org.Id,
|
1163
|
|
- // DrugId: advice.DrugId,
|
1164
|
|
- // Count: count,
|
1165
|
|
- //}
|
1166
|
|
- //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1167
|
|
- }
|
1168
|
|
- }
|
1169
|
|
- }
|
1170
|
|
-
|
1171
|
|
- } else if err == nil {
|
1172
|
|
- _, err := service.FindDrugStockOutInfoByTypeId(adminInfo.Org.Id, advice.DrugId, out.ID, out.WarehouseOutOrderNumber)
|
1173
|
|
- if err == gorm.ErrRecordNotFound {
|
1174
|
|
- warehouseOutInfo := &models.DrugWarehouseOutInfo{
|
1175
|
|
- WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
|
1176
|
|
- WarehouseOutId: out.ID,
|
1177
|
|
- Status: 1,
|
1178
|
|
- Ctime: time.Now().Unix(),
|
1179
|
|
- Remark: "",
|
1180
|
|
- OrgId: adminInfo.Org.Id,
|
1181
|
|
- Type: 1,
|
1182
|
|
- Manufacturer: 0,
|
1183
|
|
- Dealer: 0,
|
1184
|
|
- IsSys: 1,
|
1185
|
|
- SysRecordTime: record_time,
|
1186
|
|
- }
|
1187
|
|
-
|
1188
|
|
- stockInInfo, _ := service.FindLastDrugStockInInfoRecord(advice.DrugId, adminInfo.Org.Id)
|
1189
|
|
- warehouseOutInfo.Price = stockInInfo.Price
|
1190
|
|
- warehouseOutInfo.DrugId = advice.DrugId
|
1191
|
|
- prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1192
|
|
- count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1193
|
|
- warehouseOutInfo.Count = count
|
1194
|
|
- err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
|
1195
|
|
- if err == nil {
|
1196
|
|
- service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
1197
|
|
- //details := &models.DrugAutomaticReduceDetail{
|
1198
|
|
- // WarehouseOutId: warehouseOutInfo.ID,
|
1199
|
|
- // WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
|
1200
|
|
- // PatientId: advice.PatientId,
|
1201
|
|
- // Ctime: time.Now().Unix(),
|
1202
|
|
- // Mtime: time.Now().Unix(),
|
1203
|
|
- // Status: 1,
|
1204
|
|
- // RecordTime: record_time,
|
1205
|
|
- // OrgId: adminInfo.Org.Id,
|
1206
|
|
- // DrugId: advice.DrugId,
|
1207
|
|
- // Count: count,
|
1208
|
|
- //}
|
1209
|
|
- //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1210
|
|
- }
|
1211
|
|
-
|
1212
|
|
- } else if err == nil { //记录存在,则将增加数量
|
1213
|
|
- service.HisDrugsDelivery(adminInfo.Org.Id, &advice)
|
1214
|
|
- //if outInfo.ID > 0 {
|
1215
|
|
- // prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1216
|
|
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1217
|
|
- // service.UpdateDrugStockOutInfoCount2(adminInfo.Org.Id, outInfo.ID, count)
|
1218
|
|
- //}
|
1219
|
|
- //prescribingNumber := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
|
1220
|
|
- //count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1221
|
|
- //details := &models.DrugAutomaticReduceDetail{
|
1222
|
|
- // WarehouseOutId: outInfo.ID,
|
1223
|
|
- // WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
|
1224
|
|
- // PatientId: advice.PatientId,
|
1225
|
|
- // Ctime: time.Now().Unix(),
|
1226
|
|
- // Mtime: time.Now().Unix(),
|
1227
|
|
- // Status: 1,
|
1228
|
|
- // RecordTime: record_time,
|
1229
|
|
- // OrgId: adminInfo.Org.Id,
|
1230
|
|
- // DrugId: advice.DrugId,
|
1231
|
|
- // Count: count,
|
1232
|
|
- //}
|
1233
|
|
- //service.AddSigleDrugAutoReduceRecordInfo(details)
|
1234
|
|
- }
|
1235
|
|
- }
|
|
792
|
+ service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1236
|
793
|
}
|
1237
|
794
|
c.ServeSuccessJSON(map[string]interface{}{
|
1238
|
795
|
"msg": "ok",
|