Ver código fonte

Merge branch 'master' of http://git.shengws.com/csx/gdyb

test_user 4 meses atrás
pai
commit
0b72c60cd2
3 arquivos alterados com 282 adições e 116 exclusões
  1. 219 61
      controllers/sg/his_api_controller.go
  2. 57 54
      models/new_stock_models.go
  3. 6 1
      service/his_service.go

+ 219 - 61
controllers/sg/his_api_controller.go Ver arquivo

@@ -323,7 +323,7 @@ func (c *HisApiController) FJ3501AND3502() {
323 323
 			struct3502.FixmedinsCode = miConfig.Code
324 324
 			struct3502.Opter = roles.UserName
325 325
 			struct3502.RxFlag = "0"
326
-			struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
326
+			struct3502.InvChgTime = time.Now().Format("2006-01-02")
327 327
 			struct3502.OrgName = miConfig.OrgName
328 328
 			struct3502.AccessKey = miConfig.AccessKey
329 329
 			struct3502.RequestUrl = miConfig.Url
@@ -548,7 +548,7 @@ func (c *HisApiController) DeleteXSandBG() {
548 548
 	for _, item := range drugs {
549 549
 		if item.IsPc == 1 && item.IsBg == 1 {
550 550
 			var struct3507 models.Struct3507
551
-			struct3507.FixmedinsBchno = ""
551
+			struct3507.FixmedinsBchno =
552 552
 			struct3507.InvDataType = "1"
553 553
 			struct3507.Opter = roles.UserName
554 554
 			struct3507.OrgName = miConfig.OrgName
@@ -615,28 +615,115 @@ func (c *HisApiController) ChangeDrug() {
615 615
 
616 616
 	miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
617 617
 
618
+	var err []string
618 619
 	for _, item := range flows {
620
+		var res3 ResultSix
619 621
 		if item.ConsumableType == 3 { //3为自动出库 7为自动退库
620 622
 			prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
621
-			if prescription.OrderStatus == 2 { //已经结算
623
+			if prescription.OrderStatus == 2 {
624
+				//已经结算
622 625
 				//判断是否已经销售
623 626
 				if item.IsSale == 1 { //是否已经销售,1是   0否
624 627
 					//是否已经变更 1是  0否
625 628
 					if item.IsChange == 0 { //没变更,进行变更操作
626
-						ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
629
+						result, result2  := ChangeStock(item.Count, item, miConfig, "107", roles)
630
+						saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
631
+						var respJSON3 map[string]interface{}
632
+						if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
633
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
634
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
635
+							return
636
+						}
637
+						userJSONBytes3, _ := json.Marshal(respJSON3)
638
+						if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
639
+							utils.ErrorLog("解析失败:%v", err)
640
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
641
+							return
642
+						}
643
+						if res3.Infcode != -1{
644
+							item.IsChange = 1
645
+							item.Bchno = item.NewDrugWarehouseInfo.Bchno
646
+							service.SaveDF(item)
647
+						}else{
648
+							err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
649
+						}
627 650
 					}
628 651
 				} else { //没销售,
629
-					//进行商品销售接口
630
-					SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
652
+					var res FJ3507Result
631 653
 
632
-					if item.IsChange == 0 { //没变更,进行变更操作
633
-						ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
654
+					//进行商品销售接口
655
+					result3, result4  := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
656
+					saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
657
+					var respJSON3 map[string]interface{}
658
+					if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
659
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
660
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
661
+						return
662
+					}
663
+					userJSONBytes3, _ := json.Marshal(respJSON3)
664
+					if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
665
+						utils.ErrorLog("解析失败:%v", err)
666
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
667
+						return
668
+					}
669
+					if res.Infcode != -1 {
670
+						item.IsSale = 1
671
+						item.SaleDate = time.Now().Format("2006-01-02")
672
+						err5 := service.SaveDF(item)
673
+						if err5 == nil {
674
+							if item.IsChange == 0 { //没变更,进行变更操作
675
+								result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
676
+								saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
677
+
678
+								var respJSON3 map[string]interface{}
679
+								if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
680
+									utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
681
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
682
+									return
683
+								}
684
+								userJSONBytes3, _ := json.Marshal(respJSON3)
685
+								if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
686
+									utils.ErrorLog("解析失败:%v", err)
687
+									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
688
+									return
689
+								}
690
+								if res3.Infcode != -1 {
691
+									item.IsChange = 1
692
+									item.Bchno = item.NewDrugWarehouseInfo.Bchno
693
+									service.SaveDF(item)
694
+								} else {
695
+									err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
696
+								}
697
+							}
698
+						}
699
+					}else{
700
+						err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
634 701
 					}
635 702
 				}
636 703
 			} else { //还没结算
637 704
 				if item.IsChange == 0 { //没变更,进行变更操作
638
-					ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
705
+					result, result2  :=ChangeStock(item.Count, item, miConfig, "107", roles)
706
+					saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
639 707
 
708
+					var respJSON3 map[string]interface{}
709
+					if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
710
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
711
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
712
+						return
713
+					}
714
+					userJSONBytes3, _ := json.Marshal(respJSON3)
715
+					if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
716
+						utils.ErrorLog("解析失败:%v", err)
717
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
718
+						return
719
+					}
720
+					if res3.Infcode != -1{
721
+						item.IsChange = 1
722
+						item.Bchno = item.NewDrugWarehouseInfo.Bchno
723
+						service.SaveDF(item)
724
+					}else{
725
+						err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
726
+					}
640 727
 				}
641 728
 			}
642 729
 		} else if item.ConsumableType == 7 {
@@ -648,97 +735,174 @@ func (c *HisApiController) ChangeDrug() {
648 735
 				if item.IsSale == 1 { //是否已经销售,1是   0否
649 736
 					//是否已经变更 1是  0否
650 737
 					if item.IsChange == 0 { //没变更,进行变更操作
651
-						ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
738
+						result, result2  :=ChangeStock(item.Count, item, miConfig, "107", roles)
739
+						saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
740
+
741
+						var respJSON3 map[string]interface{}
742
+						if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
743
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
744
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
745
+							return
746
+						}
747
+						userJSONBytes3, _ := json.Marshal(respJSON3)
748
+						if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
749
+							utils.ErrorLog("解析失败:%v", err)
750
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
751
+							return
752
+						}
753
+						if res3.Infcode != -1{
754
+							item.IsChange = 1
755
+							item.Bchno = item.NewDrugWarehouseInfo.Bchno
756
+							service.SaveDF(item)
757
+						}else{
758
+							err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
759
+						}
652 760
 					}
653 761
 				} else { //没销售,
654 762
 					//进行商品销售退货接口
655
-					CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
763
+					result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "",roles)
764
+					saveLog(result111,result222,"3506","销售退货")
656 765
 					if item.IsChange == 0 { //没变更,进行变更操作
657
-						ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
766
+						result, result2  :=ChangeStock(item.Count, item, miConfig, "107", roles)
767
+						saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
768
+
769
+						var respJSON3 map[string]interface{}
770
+						if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
771
+							utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
772
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
773
+							return
774
+						}
775
+						userJSONBytes3, _ := json.Marshal(respJSON3)
776
+						if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
777
+							utils.ErrorLog("解析失败:%v", err)
778
+							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
779
+							return
780
+						}
781
+						if res3.Infcode != -1{
782
+							item.IsChange = 1
783
+							item.Bchno = item.NewDrugWarehouseInfo.Bchno
784
+							service.SaveDF(item)
785
+						}else{
786
+							err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
787
+						}
658 788
 					}
659 789
 				}
660 790
 			} else { //还没结算
661 791
 				if item.IsChange == 0 { //没变更,进行变更操作
662
-					ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
792
+					result, result2  := ChangeStock(item.Count, item, miConfig, "107", roles)
793
+					saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
794
+
795
+					var respJSON3 map[string]interface{}
796
+					if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
797
+						utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
798
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
799
+						return
800
+					}
801
+					userJSONBytes3, _ := json.Marshal(respJSON3)
802
+					if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
803
+						utils.ErrorLog("解析失败:%v", err)
804
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
805
+						return
806
+					}
807
+					if res3.Infcode != -1{
808
+						item.IsChange = 1
809
+						item.Bchno = item.NewDrugWarehouseInfo.Bchno
810
+						service.SaveDF(item)
811
+					}else{
812
+						err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
813
+					}
663 814
 
664 815
 				}
665 816
 			}
666 817
 
667 818
 		} else { //其他方式
668 819
 			if item.IsChange == 0 { //没变更,进行变更操作
669
-				ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
820
+				result, result2  := ChangeStock(item.Count, item, miConfig, "107", roles)
821
+				saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
822
+
823
+				var respJSON3 map[string]interface{}
824
+				if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
825
+					utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
826
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
827
+					return
828
+				}
829
+				userJSONBytes3, _ := json.Marshal(respJSON3)
830
+				if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
831
+					utils.ErrorLog("解析失败:%v", err)
832
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
833
+					return
834
+				}
835
+				if res3.Infcode != -1{
836
+					item.IsChange = 1
837
+					item.Bchno = item.NewDrugWarehouseInfo.Bchno
838
+					service.SaveDF(item)
839
+				}else{
840
+					err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
841
+				}
670 842
 			}
671 843
 		}
672 844
 	}
673 845
 }
674 846
 
675
-func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
847
+func ChangeStock(count int64, drug  *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string,string){
676 848
 	var struct3502 models.Struct3502
677
-	struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
849
+	struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
678 850
 	struct3502.FixmedinsHilistId = miConfig.Code
679 851
 	struct3502.FixmedinsHilistName = miConfig.OrgName
680 852
 	struct3502.FixmedinsCode = miConfig.Code
681 853
 	struct3502.Opter = role.UserName
682 854
 	struct3502.RxFlag = "0"
683
-	struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
855
+	struct3502.InvChgTime =  time.Now().Format("2006-01-02")
684 856
 	struct3502.OrgName = miConfig.OrgName
685 857
 	struct3502.AccessKey = miConfig.AccessKey
686 858
 	struct3502.RequestUrl = miConfig.Url
687 859
 	struct3502.SecretKey = miConfig.SecretKey
688 860
 	struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
689 861
 	struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
690
-
691 862
 	struct3502.Url = miConfig.Url
692 863
 	struct3502.AppId = miConfig.Cainfo
693 864
 	struct3502.AppSecret = miConfig.AppSecret
694 865
 	struct3502.Enckey = miConfig.EncKey
695 866
 	struct3502.SignKey = miConfig.SignKey
696 867
 	struct3502.SecretKey = miConfig.SecretKey
697
-
698 868
 	struct3502.InvChgType = chgType
699
-	struct3502.FixmedinsBchno = ""
869
+	struct3502.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
700 870
 	struct3502.Cnt = strconv.FormatInt(count, 10)
701 871
 	struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
702
-	result1, result2, result3 := service.FJyb3502(struct3502)
703
-	fmt.Println(result1)
704
-	fmt.Println(result2)
705
-	fmt.Println(result3)
706
-
872
+	result1, result2, _ := service.FJyb3502(struct3502)
873
+	return result1,result2
707 874
 }
708
-func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
875
+func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string){
709 876
 	var struct3505 models.Struct3505
710
-	struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
877
+	struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
711 878
 	struct3505.FixmedinsHilistId = miConfig.Code
712 879
 	struct3505.FixmedinsHilistName = miConfig.OrgName
880
+	struct3505.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
881
+
713 882
 	struct3505.FixmedinsCode = miConfig.Code
714
-	struct3505.FixmedinsBchno = ""
715 883
 	roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
716
-	struct3505.PrscDrName = roles.UserName
717
-	struct3505.PharName = ""
718
-	struct3505.PharPracCertNo = ""
884
+	struct3505.PrscDrName =roles.UserName
885
+	struct3505.PharName = "刘水山"
886
+	struct3505.PharPracCertNo = "2015026350260000002611351127"
719 887
 	order := service.GetHisOrderByNumber(pre.BatchNumber)
720 888
 	struct3505.SetlId = order.SetlId
721 889
 	struct3505.MdtrtSn = order.MdtrtId
722
-	struct3505.ManuLotnum = ""
723
-	struct3505.ManuDate = ""
890
+	struct3505.ManuLotnum = drug.Number
891
+	struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02 15:04:05")
724 892
 	struct3505.ExpyEnd = ""
725 893
 	struct3505.RxFlag = "0"
726 894
 	struct3505.TrdnFlag = "1"
727
-
895
+	struct3505.RtalDocno = order.Number
728 896
 	struct3505.Url = miConfig.Url
729 897
 	struct3505.AppId = miConfig.Cainfo
730 898
 	struct3505.AppSecret = miConfig.AppSecret
731 899
 	struct3505.Enckey = miConfig.EncKey
732 900
 	struct3505.SignKey = miConfig.SignKey
733 901
 	struct3505.SecretKey = miConfig.SecretKey
734
-
735
-	struct3505.RtalDocno = order.Number
736
-	strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
902
+	strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
737 903
 	struct3505.SelRetnCnt = strValue
738
-	struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
739
-	roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
740
-
741
-	struct3505.SelRetnOpterName = roles_two.UserName
904
+	struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
905
+	struct3505.SelRetnOpterName = role.UserName
742 906
 	if order.IsMedicineInsurance == 1 {
743 907
 		struct3505.MdtrtSetlType = "1"
744 908
 	} else {
@@ -750,32 +914,30 @@ func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAd
750 914
 	struct3505.SecretKey = miConfig.SecretKey
751 915
 	struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
752 916
 	struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
753
-	result1, result2, result3 := service.FJyb3505(struct3505)
754
-	fmt.Println(result1)
755
-	fmt.Println(result2)
756
-	fmt.Println(result3)
917
+	result1, result2, _ := service.FJyb3505(struct3505)
918
+	return result1,result2
757 919
 
758 920
 }
759
-func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
921
+func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string,role models.UserAdminRole)  (string,string){
760 922
 	var struct3506 models.Struct3506
761
-	struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
923
+	struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
762 924
 	struct3506.FixmedinsHilistId = miConfig.Code
763 925
 	struct3506.FixmedinsHilistName = miConfig.OrgName
764 926
 	struct3506.FixmedinsCode = miConfig.Code
765
-	struct3506.FixmedinsBchno = ""
927
+	struct3506.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
928
+	struct3506.Opter = role.UserName
766 929
 	order := service.GetHisOrderByNumber(pre.BatchNumber)
767
-	//roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
768
-	struct3506.ManuLotnum = ""
769
-	struct3506.ManuDate = ""
930
+	struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
931
+	struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
770 932
 	struct3506.MdtrtSn = order.MdtrtId
771 933
 	struct3506.ExpyEnd = ""
772 934
 	struct3506.RxFlag = "0"
773 935
 	struct3506.TrdnFlag = "1"
774
-	strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
936
+	strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
775 937
 	struct3506.SelRetnCnt = strValue
776
-	struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
777
-	roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
778
-	struct3506.SelRetnOpterName = roles_two.UserName
938
+	struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
939
+	//roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
940
+	struct3506.SelRetnOpterName = role.UserName
779 941
 	struct3506.OrgName = miConfig.OrgName
780 942
 	struct3506.AccessKey = miConfig.AccessKey
781 943
 	struct3506.RequestUrl = miConfig.Url
@@ -789,12 +951,8 @@ func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDo
789 951
 	struct3506.Enckey = miConfig.EncKey
790 952
 	struct3506.SignKey = miConfig.SignKey
791 953
 	struct3506.SecretKey = miConfig.SecretKey
792
-
793
-	result1, result2, result3 := service.FJyb3506(struct3506)
794
-	fmt.Println(result1)
795
-	fmt.Println(result2)
796
-	fmt.Println(result3)
797
-
954
+	result1, result2, _ := service.FJyb3506(struct3506)
955
+	return result1,result2
798 956
 }
799 957
 
800 958
 func (c *HisApiController) Get1318() {

+ 57 - 54
models/new_stock_models.go Ver arquivo

@@ -384,60 +384,63 @@ func (NewDrugCancelStockInfo) TableName() string {
384 384
 }
385 385
 
386 386
 type DrugFlow struct {
387
-	ID                        int64               `gorm:"column:id" json:"id" form:"id"`
388
-	WarehousingId             int64               `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
389
-	DrugId                    int64               `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
390
-	Number                    string              `gorm:"column:number" json:"number" form:"number"`
391
-	BatchNumber               string              `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
392
-	Count                     int64               `gorm:"column:count" json:"count" form:"count"`
393
-	UserOrgId                 int64               `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
394
-	PatientId                 int64               `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
395
-	SystemTime                int64               `gorm:"column:system_time" json:"system_time" form:"system_time"`
396
-	ConsumableType            int64               `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
397
-	IsSys                     int64               `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
398
-	WarehousingOrder          string              `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
399
-	WarehouseOutId            int64               `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
400
-	WarehouseOutOrderNumber   string              `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
401
-	IsEdit                    int64               `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
402
-	CancelStockId             int64               `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
403
-	CancelOrderNumber         string              `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
404
-	Manufacturer              int64               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
405
-	Dealer                    int64               `gorm:"column:dealer" json:"dealer" form:"dealer"`
406
-	Creator                   int64               `gorm:"column:creator" json:"creator" form:"creator"`
407
-	UpdateCreator             int64               `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
408
-	Status                    int64               `gorm:"column:status" json:"status" form:"status"`
409
-	Ctime                     int64               `gorm:"column:ctime" json:"ctime" form:"ctime"`
410
-	Mtime                     int64               `gorm:"column:mtime" json:"mtime" form:"mtime"`
411
-	Price                     float64             `gorm:"column:price" json:"price" form:"price"`
412
-	WarehousingDetailId       int64               `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
413
-	WarehouseOutDetailId      int64               `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
414
-	CancelOutDetailId         int64               `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
415
-	ExpireDate                int64               `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
416
-	ProductDate               int64               `gorm:"column:product_date" json:"product_date" form:"product_date"`
417
-	MaxUnit                   string              `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
418
-	MinUnit                   string              `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
419
-	StockMaxNumber            int64               `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
420
-	StockMinNumber            int64               `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
421
-	LastStockMaxNumber        int64               `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
422
-	LastStockMinNumber        int64               `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
423
-	AdviceId                  int64               `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
424
-	HisDoctorAdviceInfo       HisDoctorAdviceInfo `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
425
-	SupplyWarehouseId         int64               `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
426
-	SupplyCancelOutId         int64               `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
427
-	SupplyWarehouseDetailInfo int64               `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
428
-	StorehouseId              int64               `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
429
-	SecondWarehouseInfoId     int64               `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
430
-	AdminUserId               int64               `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
431
-	LastPrice                 float64             `gorm:"column:last_price" json:"last_price" form:"last_price"`
432
-	StockCount                string              `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
433
-	PharmacyId                int64               `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
434
-	IsRead                    int64               `gorm:"column:is_read" json:"is_read" form:"is_read"`
435
-	IsCheck                   int64               `gorm:"column:is_check" json:"is_check" form:"is_check"`
436
-	OverCount                 int64               `gorm:"column:over_count" json:"over_count" form:"over_count"`
437
-	RetailPrice               float64             `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
438
-	OrderId                   int64               `gorm:"column:order_id" json:"order_id" form:"order_id"`
439
-	IsSale                    int64               `gorm:"column:is_sale" json:"is_sale" form:"is_sale"`
440
-	IsChange                  int64               `gorm:"column:is_change" json:"is_change" form:"is_change"`
387
+	ID                        int64                `gorm:"column:id" json:"id" form:"id"`
388
+	WarehousingId             int64                `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
389
+	DrugId                    int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
390
+	Number                    string               `gorm:"column:number" json:"number" form:"number"`
391
+	BatchNumber               string               `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
392
+	Count                     int64                `gorm:"column:count" json:"count" form:"count"`
393
+	UserOrgId                 int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
394
+	PatientId                 int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
395
+	SystemTime                int64                `gorm:"column:system_time" json:"system_time" form:"system_time"`
396
+	ConsumableType            int64                `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
397
+	IsSys                     int64                `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
398
+	WarehousingOrder          string               `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
399
+	WarehouseOutId            int64                `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
400
+	WarehouseOutOrderNumber   string               `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
401
+	IsEdit                    int64                `gorm:"column:is_edit" json:"is_edit" form:"is_edit"`
402
+	CancelStockId             int64                `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
403
+	CancelOrderNumber         string               `gorm:"column:cancel_order_number" json:"cancel_order_number" form:"cancel_order_number"`
404
+	Manufacturer              int64                `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
405
+	Dealer                    int64                `gorm:"column:dealer" json:"dealer" form:"dealer"`
406
+	Creator                   int64                `gorm:"column:creator" json:"creator" form:"creator"`
407
+	UpdateCreator             int64                `gorm:"column:update_creator" json:"update_creator" form:"update_creator"`
408
+	Status                    int64                `gorm:"column:status" json:"status" form:"status"`
409
+	Ctime                     int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
410
+	Mtime                     int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
411
+	Price                     float64              `gorm:"column:price" json:"price" form:"price"`
412
+	WarehousingDetailId       int64                `gorm:"column:warehousing_detail_id" json:"warehousing_detail_id" form:"warehousing_detail_id"`
413
+	WarehouseOutDetailId      int64                `gorm:"column:warehouse_out_detail_id" json:"warehouse_out_detail_id" form:"warehouse_out_detail_id"`
414
+	CancelOutDetailId         int64                `gorm:"column:cancel_out_detail_id" json:"cancel_out_detail_id" form:"cancel_out_detail_id"`
415
+	ExpireDate                int64                `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
416
+	ProductDate               int64                `gorm:"column:product_date" json:"product_date" form:"product_date"`
417
+	MaxUnit                   string               `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
418
+	MinUnit                   string               `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
419
+	StockMaxNumber            int64                `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
420
+	StockMinNumber            int64                `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
421
+	LastStockMaxNumber        int64                `gorm:"column:last_stock_max_number" json:"last_stock_max_number" form:"last_stock_max_number"`
422
+	LastStockMinNumber        int64                `gorm:"column:last_stock_min_number" json:"last_stock_min_number" form:"last_stock_min_number"`
423
+	AdviceId                  int64                `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
424
+	HisDoctorAdviceInfo       HisDoctorAdviceInfo  `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
425
+	SupplyWarehouseId         int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
426
+	SupplyCancelOutId         int64                `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
427
+	SupplyWarehouseDetailInfo int64                `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
428
+	StorehouseId              int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
429
+	SecondWarehouseInfoId     int64                `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
430
+	AdminUserId               int64                `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
431
+	LastPrice                 float64              `gorm:"column:last_price" json:"last_price" form:"last_price"`
432
+	StockCount                string               `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
433
+	PharmacyId                int64                `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
434
+	IsRead                    int64                `gorm:"column:is_read" json:"is_read" form:"is_read"`
435
+	IsCheck                   int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
436
+	OverCount                 int64                `gorm:"column:over_count" json:"over_count" form:"over_count"`
437
+	RetailPrice               float64              `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
438
+	OrderId                   int64                `gorm:"column:order_id" json:"order_id" form:"order_id"`
439
+	IsSale                    int64                `gorm:"column:is_sale" json:"is_sale" form:"is_sale"`
440
+	IsChange                  int64                `gorm:"column:is_change" json:"is_change" form:"is_change"`
441
+	NewDrugWarehouseInfo      NewDrugWarehouseInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"dw"`
442
+	Bchno                     string               `gorm:"column:bchno" json:"bchno" form:"bchno"`
443
+	SaleDate                  string               `gorm:"column:sale_date" json:"sale_date" form:"sale_date"`
441 444
 }
442 445
 
443 446
 func (DrugFlow) TableName() string {

+ 6 - 1
service/his_service.go Ver arquivo

@@ -1710,7 +1710,7 @@ func GetNewDrugWarehouseInfo(id_arr []string) (newDrugWarehouse []*models.NewDru
1710 1710
 
1711 1711
 func GetNewDrugFlowInfo(id_arr []string) (flows []*models.DrugFlow, err error) {
1712 1712
 	err = readDb.Model(&models.DrugFlow{}).Where("org_id = ? and status = 1 and id in (?)", 10191, id_arr).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1713
-		return db.Where("status = 1").Preload("BaseDrugLib", "status=1")
1713
+		return db.Where("status = 1").Preload("BaseDrugLib", "status=1").Preload("NewDrugWarehouseInfo", "status = 1")
1714 1714
 	}).Find(&flows).Error
1715 1715
 	return
1716 1716
 }
@@ -1724,3 +1724,8 @@ func GetHisOrderByNumber(number string) (order models.HisOrder) {
1724 1724
 	err = readDb.Model(&models.HisOrder{}).Where("number = ? and status = 1", number).First(&order).Error
1725 1725
 	return
1726 1726
 }
1727
+
1728
+func SaveDF(df *models.DrugFlow) (err error) {
1729
+	err = writeDb.Save(&df).Error
1730
+	return
1731
+}