浏览代码

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

csx 3 年前
父节点
当前提交
e89c585571

+ 5 - 3
controllers/dialysis_api_controller.go 查看文件

@@ -1896,10 +1896,12 @@ func (c *DialysisApiController) GetDialysisWatch() {
1896 1896
 	startTime, _ := c.GetInt64("schedul_time", 0)
1897 1897
 	partitionType, _ := c.GetInt64("partition_type", 0)
1898 1898
 	keywords := c.GetString("keywords")
1899
-
1899
+	start_time, _ := c.GetInt64("start_time")
1900
+	end_time, _ := c.GetInt64("end_time")
1900 1901
 	adminUserInfo := c.GetAdminUserInfo()
1901 1902
 	if len(keywords) > 0 {
1902
-		dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
1903
+
1904
+		dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
1903 1905
 		if err == nil {
1904 1906
 			c.ServeSuccessJSON(map[string]interface{}{
1905 1907
 				"schedule": dialysisSchedule,
@@ -1910,7 +1912,7 @@ func (c *DialysisApiController) GetDialysisWatch() {
1910 1912
 		}
1911 1913
 
1912 1914
 	} else {
1913
-		dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit)
1915
+		dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
1914 1916
 		if err == nil {
1915 1917
 			c.ServeSuccessJSON(map[string]interface{}{
1916 1918
 				"schedule": dialysisSchedule,

+ 274 - 380
controllers/his_api_controller.go 查看文件

@@ -15,7 +15,6 @@ import (
15 15
 	"reflect"
16 16
 	"strconv"
17 17
 	"strings"
18
-	"sync"
19 18
 	"syscall"
20 19
 	"time"
21 20
 	"unsafe"
@@ -620,6 +619,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
620 619
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
621 620
 	//获取所有基础药
622 621
 	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
622
+
623 623
 	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
624 624
 	if config.ID > 0 && config.IsOpen == 1 {
625 625
 		for _, item := range drugs {
@@ -665,8 +665,6 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
665 665
 	})
666 666
 }
667 667
 
668
-var waitGroup sync.WaitGroup
669
-
670 668
 func (c *HisApiController) CreateHisPrescription() {
671 669
 	record_date := c.GetString("record_date")
672 670
 	patient_id, _ := c.GetInt64("patient_id")
@@ -713,19 +711,10 @@ func (c *HisApiController) CreateHisPrescription() {
713 711
 
714 712
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
715 713
 
716
-	redisClient := service.RedisClient()
717
-	redisClient.LPush("111", patient)
718
-	str, _ := redisClient.LPop("111").Result()
719
-	fmt.Println("~~~~~" + str)
720
-	defer redisClient.Close()
721
-
722 714
 	if drugStockConfig.IsOpen == 1 {
723
-
724 715
 		//校验库存总量
725 716
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
726 717
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
727
-
728
-			//GetPrescriptionById(prescriptions)
729 718
 			if len(prescriptions) > 0 {
730 719
 				for _, item := range prescriptions {
731 720
 					items := item.(map[string]interface{})
@@ -736,6 +725,7 @@ func (c *HisApiController) CreateHisPrescription() {
736 725
 								var drug_id int64
737 726
 								var prescribing_number float64
738 727
 								var prescribingNumberUnit string
728
+								var prescribingNumber string
739 729
 
740 730
 								var adviceId int64
741 731
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
@@ -744,7 +734,7 @@ func (c *HisApiController) CreateHisPrescription() {
744 734
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
745 735
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
746 736
 									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
747
-
737
+									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
748 738
 								}
749 739
 
750 740
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
@@ -770,31 +760,51 @@ func (c *HisApiController) CreateHisPrescription() {
770 760
 								//查询该药品是否存在开药记录
771 761
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
772 762
 
763
+								//新增处方
764
+								if advicelist.ID == 0 {
765
+									all_count, _ := strconv.ParseFloat(totals, 64)
766
+									if prescribingNumberUnit == drug.MinUnit {
767
+										if prescribing_number > all_count {
768
+											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
769
+											return
770
+										}
771
+									} else {
772
+										if prescribingNumberUnit == drug.MaxUnit {
773
+											num := prescribing_number * float64(drug.MinNumber)
774
+											if num > all_count {
775
+												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
776
+												return
777
+											}
778
+										}
779
+									}
780
+								}
773 781
 								//修改处方
774 782
 								if advicelist.ID > 0 {
775 783
 									var device_number int64
784
+
776 785
 									if advicelist.PrescribingNumberUnit == drug.MaxUnit {
777
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
778
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
786
+										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
787
+										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
779 788
 										device_number = prescribingNumberInt * drug.MinNumber
780 789
 									}
781 790
 									if advicelist.PrescribingNumberUnit == drug.MinUnit {
782
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
783
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
791
+										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
792
+										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
784 793
 										device_number = prescribingNumberInt
785 794
 									}
786 795
 
787 796
 									var number_count int64
788 797
 									if prescribingNumberUnit == drug.MaxUnit {
789
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
790 798
 										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
791 799
 										number_count = prescribingNumberInt * drug.MinNumber
792 800
 									}
793 801
 									if prescribingNumberUnit == drug.MinUnit {
794
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
795 802
 										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
796 803
 										number_count = prescribingNumberInt
797 804
 									}
805
+
806
+									fmt.Println("以前出库数量23323232322332323223233223232332", device_number)
807
+									fmt.Println("现在出库数量", number_count)
798 808
 									//如果修改的数量大于之前修改的数量
799 809
 									if (number_count - device_number) > 0 {
800 810
 										//如果修改的差数量 大于库存数量
@@ -803,27 +813,42 @@ func (c *HisApiController) CreateHisPrescription() {
803 813
 											return
804 814
 										}
805 815
 									}
806
-								}
807 816
 
808
-								//新增处方
809
-								if advicelist.ID == 0 {
810
-									all_count, _ := strconv.ParseFloat(totals, 64)
811
-									if prescribingNumberUnit == drug.MinUnit {
812
-										if prescribing_number > all_count {
813
-											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
814
-											return
817
+									if device_number != number_count {
818
+
819
+										// 查询该药品最后一次出库记录
820
+										druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
821
+										fmt.Println("以前出库数量23323232322332323223233223232332", device_number)
822
+										fmt.Println("现在出库数量", number_count)
823
+										//回退库存
824
+										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
825
+
826
+											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
815 827
 										}
816
-									} else {
817
-										if prescribingNumberUnit == drug.MaxUnit {
818
-											num := prescribing_number * float64(drug.MinNumber)
819
-											if num > all_count {
820
-												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
821
-												return
828
+										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
829
+											var stock_max_number int64
830
+											var stock_min_number int64
831
+
832
+											if number_count >= drug.MinNumber {
833
+												fmt.Println("尽力啊了吗332323322332233232332233223232323")
834
+												stock_max_number = device_number / drug.MinNumber
835
+												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
836
+												stock_min_number = device_number % drug.MinNumber
837
+												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
838
+
839
+											} else {
840
+												fmt.Println("99999999999999999999")
841
+												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
822 842
 											}
823 843
 										}
844
+
845
+										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
846
+											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
847
+										}
848
+										//删除记录
849
+										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
824 850
 									}
825 851
 								}
826
-
827 852
 							}
828 853
 						}
829 854
 					}
@@ -835,16 +860,27 @@ func (c *HisApiController) CreateHisPrescription() {
835 860
 	if stockConfig.IsOpen == 1 {
836 861
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
837 862
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
863
+
838 864
 			if len(prescriptions) > 0 {
839 865
 				for _, item := range prescriptions {
866
+
840 867
 					items := item.(map[string]interface{})
841 868
 					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
842 869
 						projects := items["project"].([]interface{})
843 870
 						if len(projects) > 0 {
871
+
844 872
 							for _, project := range projects {
873
+
845 874
 								var project_id int64
846 875
 								var project_type int64
847 876
 								var totals float64
877
+								var project_name string
878
+								var parsetotal int64
879
+								var id int64
880
+
881
+								if project.(map[string]interface{})["id"] != nil || reflect.TypeOf(project.(map[string]interface{})["id"]).String() == "float64" {
882
+									id = int64(project.(map[string]interface{})["id"].(float64))
883
+								}
848 884
 								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
849 885
 									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
850 886
 								}
@@ -853,20 +889,23 @@ func (c *HisApiController) CreateHisPrescription() {
853 889
 								}
854 890
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
855 891
 									total, _ := project.(map[string]interface{})["total"].(string)
856
-
857 892
 									totals, _ = strconv.ParseFloat(total, 64)
893
+									parsetotal, _ = strconv.ParseInt(total, 10, 64)
894
+								}
895
+
896
+								if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
897
+									project_name = project.(map[string]interface{})["project_name"].(string)
898
+
858 899
 								}
859 900
 								if project_type == 3 {
860 901
 
861 902
 									//查找该耗材的出库记录
862
-									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSeven(project_id, patient_id, recordDateTime)
863
-
864
-									if goodWarehouseInfo.ID == 0 {
865
-										good, _ := service.FindGoodInfoByIdSeven(project_id)
866
-										if good.ID == 0 {
867
-											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
868
-											return
869
-										}
903
+									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
904
+									//var total_count int64
905
+									//for _, it := range goodWarehouseInfo {
906
+									//	total_count += it.Count
907
+									//}
908
+									if len(goodWarehouseInfo) == 0 {
870 909
 										//查询耗材库存
871 910
 										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
872 911
 										var stock_count int64
@@ -876,199 +915,29 @@ func (c *HisApiController) CreateHisPrescription() {
876 915
 										stock_counts := strconv.FormatInt(stock_count, 10)
877 916
 										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
878 917
 										if totals > stock_total_count {
879
-											c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
918
+											c.ServeDynamicFailJsonSend(project_name + "库存不足")
880 919
 											return
881 920
 										}
882 921
 									}
883
-								}
884
-
885
-							}
886
-						}
887
-					}
888
-				}
889
-			}
890
-		}
891
-	}
892
-
893
-	//ch := make(chan struct{})
894
-	//count := 2 // count 表示活动的协程个数
895
-
896
-	go func() {
897
-		if drugStockConfig.IsOpen == 1 {
898
-			//校验库存总量
899
-			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
900
-				prescriptions, _ := dataBody["prescriptions"].([]interface{})
901
-				if len(prescriptions) > 0 {
902
-
903
-					for _, item := range prescriptions {
904
-						items := item.(map[string]interface{})
905
-						if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
906
-							advices := items["advices"].([]interface{})
907
-							if len(advices) > 0 {
908
-								for _, advice := range advices {
909
-									var drug_id int64
910
-									var prescribingNumberUnit string
911
-									var prescribingNumber string
912
-									var adviceId int64
913
-									if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
914
-										drug_id = int64(advice.(map[string]interface{})["id"].(float64))
915
-									}
916
-									if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
917
-
918
-										prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
919
-
920
-									}
921
-
922
-									if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
923
-										prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
924
-									}
925
-
926
-									if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
927
-										adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
928
-									}
929
-
930
-									drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
931
-									if drug.ID == 0 {
932
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
933
-										return
934
-									}
935
-
936
-									//查询药品的所有库存
937
-									list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
938
-									var total_count int64
939
-									for _, it := range list {
940
-										total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
941
-									}
942
-
943
-									//查询该药品是否存在开药记录
944
-									advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
945
-
946
-									//修改处方
947
-									if advicelist.ID > 0 {
948
-										var device_number int64
949
-										if advicelist.PrescribingNumberUnit == drug.MaxUnit {
950
-											prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
951
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
952
-											device_number = prescribingNumberInt * drug.MinNumber
953
-										}
954
-										if advicelist.PrescribingNumberUnit == drug.MinUnit {
955
-											prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
956
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
957
-											device_number = prescribingNumberInt
958
-										}
959
-
960
-										var sum_count int64
961
-										//判断是否做过修改
962
-										if prescribingNumberUnit == drug.MaxUnit {
963
-
964
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
965
-
966
-											sum_count = prescribingNumberInt * drug.MinNumber
967
-										}
968
-										if prescribingNumberUnit == drug.MinUnit {
969
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
970
-											sum_count = prescribingNumberInt
971
-										}
972
-										fmt.Println("sum_count23322332323232323232323223322323", sum_count)
973
-										fmt.Println("devcie_number23333223333332232332233232323223", device_number)
974
-
975
-										if device_number != sum_count {
976
-
977
-											// 查询该药品最后一次出库记录
978
-											druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
979
-											fmt.Println("单位12332232322332322323233223", druginfo.CountUnit)
980
-											fmt.Println("单位2332233223323223322332332233223", drug.MaxUnit)
981
-											//回退库存
982
-											if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
983
-
984
-												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
985
-											}
986
-											if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
987
-												var stock_max_number int64
988
-												var stock_min_number int64
989
-												if device_number >= drug.MinNumber {
990
-													stock_max_number = device_number / drug.MinNumber
991
-													fmt.Println("大的值2323233232232323", stock_max_number)
992
-													service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
993
-													stock_min_number = device_number % drug.MinNumber
994
-													fmt.Println("小的值322332332323233223", stock_min_number)
995
-													if stock_min_number == drug.MinNumber {
996
-
997
-													}
998
-													service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
999
-
1000
-												} else {
1001
-
1002
-													service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
1003
-												}
1004
-
1005
-											}
1006
-
1007
-											if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1008
-												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
922
+									if len(goodWarehouseInfo) > 0 {
923
+										//查询该患者耗材的历史数据
924
+										ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
925
+										count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
926
+										fmt.Println("parsetotal33223232323232323", parsetotal)
927
+										fmt.Println("count2332322332232332", count)
928
+										//数量发生改变
929
+										if parsetotal != count {
930
+											//查找今日该患者已经出库的所有耗材
931
+											goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
932
+											fmt.Println("goodList3323223232323232323", goodList)
933
+											for _, item := range goodList {
934
+												//回退库存
935
+												service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1009 936
 											}
1010
-
1011 937
 											//删除记录
1012
-											service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
938
+											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1013 939
 										}
1014
-									}
1015
-								}
1016
-							}
1017
-						}
1018
-					}
1019
-				}
1020
-			}
1021
-		}
1022
-		//ch <- struct{}{}
1023
-	}()
1024
-
1025
-	go func() {
1026
-		if stockConfig.IsOpen == 1 {
1027
-			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1028
-				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1029
-				if len(prescriptions) > 0 {
1030
-					for _, item := range prescriptions {
1031
-						items := item.(map[string]interface{})
1032
-						if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
1033
-							projects := items["project"].([]interface{})
1034
-							if len(projects) > 0 {
1035
-								for _, project := range projects {
1036
-									var project_id int64
1037
-									var project_type int64
1038
-									var parsetotal int64
1039
-									if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
1040
-										project_id = int64(project.(map[string]interface{})["project_id"].(float64))
1041
-									}
1042
-									if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
1043
-										project_type = int64(project.(map[string]interface{})["type"].(float64))
1044
-									}
1045
-									if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
1046
-										total, _ := project.(map[string]interface{})["total"].(string)
1047
-										parsetotal, _ = strconv.ParseInt(total, 10, 64)
1048
-									}
1049 940
 
1050
-									if project_type == 3 {
1051
-										//查找该耗材的出库记录
1052
-										goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
1053
-										var total_count int64
1054
-										for _, it := range goodWarehouseInfo {
1055
-											total_count += it.Count
1056
-										}
1057
-										//查询该患者耗材的历史数据
1058
-										ordProject, _ := service.GetHisProjectPrescriptionByPatientId(patient_id, recordDateTime)
1059
-										if total_count > 0 {
1060
-											//数量发生改变
1061
-											if parsetotal != total_count || len(ordProject) != len(projects) {
1062
-												//查找今日该患者已经出库的所有耗材
1063
-												goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
1064
-												for _, item := range goodList {
1065
-													//回退库存
1066
-													service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1067
-													//删除记录
1068
-													service.DeleteAutoWarehouse(item.PatientId, item.SysRecordTime)
1069
-												}
1070
-											}
1071
-										}
1072 941
 									}
1073 942
 								}
1074 943
 							}
@@ -1077,17 +946,7 @@ func (c *HisApiController) CreateHisPrescription() {
1077 946
 				}
1078 947
 			}
1079 948
 		}
1080
-		//ch <- struct{}{}
1081
-	}()
1082
-
1083
-	//for range ch {
1084
-	//	// 每次从ch中接收数据,表明一个活动的协程结束
1085
-	//	count--
1086
-	//	// 当所有活动的协程都结束时,关闭管道
1087
-	//	if count == 0 {
1088
-	//		close(ch)
1089
-	//	}
1090
-	//}
949
+	}
1091 950
 
1092 951
 	info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
1093 952
 	var hpInfo models.HisPrescriptionInfo
@@ -1164,10 +1023,18 @@ func (c *HisApiController) CreateHisPrescription() {
1164 1023
 		defer redis.Close()
1165 1024
 	}
1166 1025
 
1026
+	//定义切片
1027
+
1028
+	var adviceList []models.HisDoctorAdviceInfo
1029
+	var projectList []models.HisPrescriptionProject
1030
+
1031
+	//var hisLis  []models.HisList
1032
+
1167 1033
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1168 1034
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
1169 1035
 
1170 1036
 		var tempPrescription *models.HisPrescription
1037
+
1171 1038
 		if len(prescriptions) > 0 {
1172 1039
 			for _, item := range prescriptions {
1173 1040
 				items := item.(map[string]interface{})
@@ -1308,6 +1175,10 @@ func (c *HisApiController) CreateHisPrescription() {
1308 1175
 
1309 1176
 							s.StartTime = pTime
1310 1177
 							service.CreateHisDoctorAdvice(&s)
1178
+
1179
+							//存储切片中
1180
+							adviceList = append(adviceList, s)
1181
+
1311 1182
 							redis := service.RedisClient()
1312 1183
 							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
1313 1184
 							redis.Set(key, "", time.Second)
@@ -1355,6 +1226,7 @@ func (c *HisApiController) CreateHisPrescription() {
1355 1226
 							}
1356 1227
 
1357 1228
 							service.CreateHisProjectTwo(&p)
1229
+							projectList = append(projectList, p)
1358 1230
 							var randNum int
1359 1231
 							randNum = rand.Intn(10000) + 1000
1360 1232
 							timestamp := time.Now().Unix()
@@ -1414,14 +1286,14 @@ func (c *HisApiController) CreateHisPrescription() {
1414 1286
 
1415 1287
 							service.SaveHisProjectTwo(&p)
1416 1288
 
1417
-							if p.Type == 3 { //处理透前准备耗材数量数据
1418
-								consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
1419
-								if consumables.ID > 0 {
1420
-									cnt, _ := strconv.ParseInt(p.Count, 10, 64)
1421
-									consumables.Count = cnt
1422
-									service.UpdateConsumables(&consumables)
1423
-								}
1424
-							}
1289
+							//if p.Type == 3 { //处理透前准备耗材数量数据
1290
+							//	consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
1291
+							//	if consumables.ID > 0 {
1292
+							//		cnt, _ := strconv.ParseInt(p.Count, 10, 64)
1293
+							//		consumables.Count = cnt
1294
+							//		service.UpdateConsumables(&consumables)
1295
+							//	}
1296
+							//}
1425 1297
 
1426 1298
 						}
1427 1299
 					}
@@ -1464,6 +1336,33 @@ func (c *HisApiController) CreateHisPrescription() {
1464 1336
 		}
1465 1337
 	}
1466 1338
 
1339
+	//redisClient := service.RedisClient()
1340
+	//defer redisClient.Close()
1341
+	//
1342
+	//list := models.HisList{
1343
+	//  Patient_id:  patient_id,
1344
+	//  Advice_id:0,
1345
+	//  Record_date: 0,
1346
+	//  Advice:      adviceList,
1347
+	//  Project:     nil,
1348
+	//}
1349
+	//hisLis = append(hisLis, list)
1350
+	//
1351
+	//advice_json, _ := json.Marshal(&hisLis)
1352
+	//redisClient.RPush("111", advice_json).Result()
1353
+	//result, _ := redisClient.RPop("111").Result()
1354
+	//fmt.Println("resuilt2332323323232323232323232322323233232",redisClient.LLen("111"))
1355
+	//
1356
+	//var dat []map[string]interface{}
1357
+	//json.Unmarshal([]byte(result), &dat)
1358
+	//fmt.Println("hhhh2332323232233223322332322323232323",dat)
1359
+	//
1360
+	//for k,v:=range dat{
1361
+	//  fmt.Println("第",k,"个数的值是:",v,v["Advice"],v["Patient_id"])
1362
+	//}
1363
+	//project_json, _ := json.Marshal(&projectList)
1364
+	//redisClient.LPush("222", project_json).Result()
1365
+
1467 1366
 	if err == nil {
1468 1367
 		c.ServeSuccessJSON(map[string]interface{}{
1469 1368
 			"msg": "保存成功",
@@ -3344,82 +3243,82 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
3344 3243
 		}
3345 3244
 	}
3346 3245
 
3347
-	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(advice.UserOrgId)
3348
-
3349
-	if drugStockConfig.IsOpen == 1 {
3350
-
3351
-		drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
3352
-		if advice.ID == 0 { //医嘱不存在
3353
-			if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
3354
-				drug.Total = drug.Total - advice.PrescribingNumber
3355
-				service.UpdateBaseDrugLib(&drug)
3356
-
3357
-			} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
3358
-				num := advice.PrescribingNumber * float64(drug.MinNumber)
3359
-				drug.Total = drug.Total - num
3360
-				service.UpdateBaseDrugLib(&drug)
3361
-			}
3362
-
3363
-		} else if advice.ID > 0 { //医嘱存在
3364
-			hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
3365
-			var num float64
3366
-
3367
-			if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
3368
-				if hisAdvice.PrescribingNumberUnit == advice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
3369
-					if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
3370
-						num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
3371
-						drug.Total = drug.Total + num
3372
-						service.UpdateBaseDrugLib(&drug)
3373
-					} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
3374
-						num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
3375
-						drug.Total = drug.Total - num
3376
-						service.UpdateBaseDrugLib(&drug)
3377
-					}
3378
-				} else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
3379
-					num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3380
-					if num2 > advice.PrescribingNumber {
3381
-						num = num2 - advice.PrescribingNumber
3382
-						drug.Total = drug.Total + num
3383
-						service.UpdateBaseDrugLib(&drug)
3384
-					} else if num2 < advice.PrescribingNumber {
3385
-						num = advice.PrescribingNumber - num2
3386
-						drug.Total = drug.Total - num
3387
-						service.UpdateBaseDrugLib(&drug)
3388
-					}
3389
-
3390
-				}
3391
-
3392
-			} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
3393
-				if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
3394
-					num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3395
-					num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3396
-					if num1 > num2 {
3397
-						num = num1 - num2
3398
-						drug.Total = drug.Total + num
3399
-						service.UpdateBaseDrugLib(&drug)
3400
-					} else if num1 < num2 {
3401
-						num = num2 - num1
3402
-						drug.Total = drug.Total - num
3403
-						service.UpdateBaseDrugLib(&drug)
3404
-					}
3405
-
3406
-				} else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
3407
-					num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3408
-					//num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
3409
-					if hisAdvice.PrescribingNumber > num2 {
3410
-						num = hisAdvice.PrescribingNumber - num2
3411
-						drug.Total = drug.Total + num
3412
-						service.UpdateBaseDrugLib(&drug)
3413
-					} else if num2 < advice.PrescribingNumber {
3414
-						num = num2 - hisAdvice.PrescribingNumber
3415
-						drug.Total = drug.Total - num
3416
-						service.UpdateBaseDrugLib(&drug)
3417
-					}
3418
-
3419
-				}
3420
-			}
3421
-		}
3422
-	}
3246
+	//_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(advice.UserOrgId)
3247
+	//
3248
+	//if drugStockConfig.IsOpen == 1 {
3249
+	//
3250
+	//	drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
3251
+	//	if advice.ID == 0 { //医嘱不存在
3252
+	//		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
3253
+	//			drug.Total = drug.Total - advice.PrescribingNumber
3254
+	//			service.UpdateBaseDrugLib(&drug)
3255
+	//
3256
+	//		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
3257
+	//			num := advice.PrescribingNumber * float64(drug.MinNumber)
3258
+	//			drug.Total = drug.Total - num
3259
+	//			service.UpdateBaseDrugLib(&drug)
3260
+	//		}
3261
+	//
3262
+	//	} else if advice.ID > 0 { //医嘱存在
3263
+	//		hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
3264
+	//		var num float64
3265
+	//
3266
+	//		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
3267
+	//			if hisAdvice.PrescribingNumberUnit == advice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
3268
+	//				if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
3269
+	//					num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
3270
+	//					drug.Total = drug.Total + num
3271
+	//					service.UpdateBaseDrugLib(&drug)
3272
+	//				} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
3273
+	//					num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
3274
+	//					drug.Total = drug.Total - num
3275
+	//					service.UpdateBaseDrugLib(&drug)
3276
+	//				}
3277
+	//			} else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
3278
+	//				num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3279
+	//				if num2 > advice.PrescribingNumber {
3280
+	//					num = num2 - advice.PrescribingNumber
3281
+	//					drug.Total = drug.Total + num
3282
+	//					service.UpdateBaseDrugLib(&drug)
3283
+	//				} else if num2 < advice.PrescribingNumber {
3284
+	//					num = advice.PrescribingNumber - num2
3285
+	//					drug.Total = drug.Total - num
3286
+	//					service.UpdateBaseDrugLib(&drug)
3287
+	//				}
3288
+	//
3289
+	//			}
3290
+	//
3291
+	//		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
3292
+	//			if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
3293
+	//				num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3294
+	//				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3295
+	//				if num1 > num2 {
3296
+	//					num = num1 - num2
3297
+	//					drug.Total = drug.Total + num
3298
+	//					service.UpdateBaseDrugLib(&drug)
3299
+	//				} else if num1 < num2 {
3300
+	//					num = num2 - num1
3301
+	//					drug.Total = drug.Total - num
3302
+	//					service.UpdateBaseDrugLib(&drug)
3303
+	//				}
3304
+	//
3305
+	//			} else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
3306
+	//				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3307
+	//				//num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
3308
+	//				if hisAdvice.PrescribingNumber > num2 {
3309
+	//					num = hisAdvice.PrescribingNumber - num2
3310
+	//					drug.Total = drug.Total + num
3311
+	//					service.UpdateBaseDrugLib(&drug)
3312
+	//				} else if num2 < advice.PrescribingNumber {
3313
+	//					num = num2 - hisAdvice.PrescribingNumber
3314
+	//					drug.Total = drug.Total - num
3315
+	//					service.UpdateBaseDrugLib(&drug)
3316
+	//				}
3317
+	//
3318
+	//			}
3319
+	//		}
3320
+	//	}
3321
+	//}
3423 3322
 
3424 3323
 	//
3425 3324
 	//if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
@@ -3561,46 +3460,46 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
3561 3460
 	//	project.WeekDay = week_day
3562 3461
 	//}
3563 3462
 
3564
-	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
3565
-
3566
-	if project.ID == 0 {
3567
-		if stockConfig.IsOpen == 1 {
3568
-			if project.Type == 3 {
3569
-				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3570
-				f_count, _ := strconv.ParseFloat(project.Count, 64)
3571
-				good.Total = good.Total - f_count
3572
-				service.UpdateGoodInfo(&good)
3573
-			}
3574
-		}
3575
-
3576
-	} else {
3577
-		temp_project, _ := service.GetHisPrescriptionProjectByID(project.ID)
3578
-
3579
-		if stockConfig.IsOpen == 1 {
3580
-			if project.Type == 3 {
3581
-				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3582
-				if project.Count < temp_project.Count {
3583
-					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3584
-					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3585
-
3586
-					other_count := f_count_two - f_count_one
3587
-					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3588
-					good.Total = good.Total + other_count_two
3589
-					service.UpdateGoodInfo(&good)
3590
-				} else if project.Count > temp_project.Count {
3591
-					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3592
-					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3593
-
3594
-					other_count := f_count_one - f_count_two
3595
-					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3596
-					good.Total = good.Total - other_count_two
3597
-					service.UpdateGoodInfo(&good)
3598
-				}
3599
-
3600
-			}
3601
-		}
3602
-
3603
-	}
3463
+	//_, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
3464
+	//
3465
+	//if project.ID == 0 {
3466
+	//	if stockConfig.IsOpen == 1 {
3467
+	//		if project.Type == 3 {
3468
+	//			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3469
+	//			f_count, _ := strconv.ParseFloat(project.Count, 64)
3470
+	//			good.Total = good.Total - f_count
3471
+	//			service.UpdateGoodInfo(&good)
3472
+	//		}
3473
+	//	}
3474
+	//
3475
+	//} else {
3476
+	//	temp_project, _ := service.GetHisPrescriptionProjectByID(project.ID)
3477
+	//
3478
+	//	if stockConfig.IsOpen == 1 {
3479
+	//		if project.Type == 3 {
3480
+	//			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3481
+	//			if project.Count < temp_project.Count {
3482
+	//				f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3483
+	//				f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3484
+	//
3485
+	//				other_count := f_count_two - f_count_one
3486
+	//				other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3487
+	//				good.Total = good.Total + other_count_two
3488
+	//				service.UpdateGoodInfo(&good)
3489
+	//			} else if project.Count > temp_project.Count {
3490
+	//				f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3491
+	//				f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3492
+	//
3493
+	//				other_count := f_count_one - f_count_two
3494
+	//				other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3495
+	//				good.Total = good.Total - other_count_two
3496
+	//				service.UpdateGoodInfo(&good)
3497
+	//			}
3498
+	//
3499
+	//		}
3500
+	//	}
3501
+	//
3502
+	//}
3604 3503
 
3605 3504
 	return 0
3606 3505
 }
@@ -5435,17 +5334,17 @@ func (c *HisApiController) GetFaPiaoData() {
5435 5334
 	admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
5436 5335
 
5437 5336
 	c.ServeSuccessJSON(map[string]interface{}{
5438
-		"order_number":    order.Number,             //业务流水号
5439
-		"id_card_no":      his.IdCardNo,             //社会保障号
5440
-		"department_name": department.Name,          //科室
5441
-		"number":          his.Number,               //门诊号
5442
-		"date":            order.SettleAccountsDate, //结算日期
5443
-		"name":            order.PsnName,            //姓名
5444
-		"gender":          order.Gend,               //性别
5445
-		"psn_cash_money":  order.PsnCashPay,         //个人支付
5446
-		"pay_way":         "门诊",                     //结算方式
5447
-		"medfee_sumamt":   order.MedfeeSumamt,       //总费用
5448
-		"admin_user_name": admin.UserName,           //收款员
5337
+		"order_number":    order.Number,        //业务流水号
5338
+		"id_card_no":      his.IdCardNo,        //社会保障号
5339
+		"department_name": department.Name,     //科室
5340
+		"number":          his.Number,          //门诊号
5341
+		"date":            order.SettleEndTime, //结算日期
5342
+		"name":            order.PsnName,       //姓名
5343
+		"gender":          order.Gend,          //性别
5344
+		"psn_cash_money":  order.PsnCashPay,    //个人支付
5345
+		"pay_way":         "门诊",                //结算方式
5346
+		"medfee_sumamt":   order.MedfeeSumamt,  //总费用
5347
+		"admin_user_name": admin.UserName,      //收款员
5449 5348
 
5450 5349
 		"bedCostTotal":                                bedCostTotal,
5451 5350
 		"bedCostSelfTotal":                            bedCostSelfTotal,
@@ -6938,8 +6837,3 @@ func (c *HisApiController) GetHisDoctorAdviceInfo() {
6938 6837
 	})
6939 6838
 	return
6940 6839
 }
6941
-
6942
-func GetPrescriptionById(prescription []interface{}) {
6943
-
6944
-	fmt.Println("prescription222222222222225555532323332323233223323323322332323232323232332322323323232", prescription)
6945
-}

+ 39 - 42
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -191,26 +191,23 @@ func (this *DialysisAPIController) Scheduals() {
191 191
 			//获取今日所有的处方开的耗材
192 192
 			project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
193 193
 
194
-			fmt.Println("orgID00000000000000000000000000000000", date.Unix())
195 194
 			//获取今日透析准备的数据
196
-			goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
195
+			//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
197 196
 
198
-			list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
197
+			//list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
199 198
 
200
-			autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
201
-			for _, item := range goodList {
202
-				for _, it := range list {
203
-					if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
204
-						item.Children = append(item.Children, it)
205
-					}
206
-				}
207
-			}
208
-			fmt.Println("goodlist888888888888888888888", goodList, err)
199
+			//autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
200
+			//for _, item := range goodList {
201
+			//	for _, it := range list {
202
+			//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
203
+			//			item.Children = append(item.Children, it)
204
+			//		}
205
+			//	}
206
+			//}
207
+			//fmt.Println("goodlist888888888888888888888", goodList, err)
209 208
 			this.ServeSuccessJSON(map[string]interface{}{
210 209
 				"scheduals": scheduals,
211 210
 				"project":   project,
212
-				"goodList":  goodList,
213
-				"autoList":  autoList,
214 211
 			})
215 212
 		}
216 213
 
@@ -226,26 +223,26 @@ func (this *DialysisAPIController) Scheduals() {
226 223
 		project, _ := service.GetAllHisProjectPrescription(orgID, date.Unix())
227 224
 
228 225
 		//获取今日透析准备的数据
229
-		goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
230
-		fmt.Println("goodlist23323232323233232332233223323233", goodList, err)
231
-
232
-		list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
233
-
234
-		for _, item := range goodList {
235
-			for _, it := range list {
236
-				if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
237
-					item.Children = append(item.Children, it)
238
-				}
239
-			}
240
-		}
241
-		autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
226
+		//goodList, err := service.MobileGetDialysisGoodsSeven(orgID, date.Unix())
227
+		//fmt.Println("goodlist23323232323233232332233223323233", goodList, err)
228
+		//
229
+		//list, err := service.MobileGetDialysisGoodsSix(orgID, date.Unix())
230
+		//
231
+		//for _, item := range goodList {
232
+		//	for _, it := range list {
233
+		//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
234
+		//			item.Children = append(item.Children, it)
235
+		//		}
236
+		//	}
237
+		//}
238
+		//autoList, _ := service.GetMobileAutoReduce(orgID, date.Unix())
242 239
 		this.ServeSuccessJSON(map[string]interface{}{
243 240
 			"scheduals": dat,
244 241
 			"redis":     "true",
245 242
 			"date":      schedualDate,
246 243
 			"project":   project,
247
-			"goodList":  goodList,
248
-			"autoList":  autoList,
244
+			//"goodList":  goodList,
245
+			//"autoList":  autoList,
249 246
 		})
250 247
 
251 248
 	}
@@ -572,17 +569,17 @@ func (this *DialysisAPIController) DialysisRecord() {
572 569
 	}
573 570
 
574 571
 	//获取今日透析准备的数据
575
-	goodList, _ := service.MobileGetDialysisGoodsSeven(adminInfo.Org.Id, date.Unix())
576
-	list, _ := service.MobileGetDialysisGoodsSix(adminInfo.Org.Id, date.Unix())
577
-
578
-	autoList, _ := service.GetMobileAutoReduce(adminInfo.Org.Id, date.Unix())
579
-	for _, item := range goodList {
580
-		for _, it := range list {
581
-			if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
582
-				item.Children = append(item.Children, it)
583
-			}
584
-		}
585
-	}
572
+	//goodList, _ := service.MobileGetDialysisGoodsSeven(adminInfo.Org.Id, date.Unix())
573
+	//list, _ := service.MobileGetDialysisGoodsSix(adminInfo.Org.Id, date.Unix())
574
+	//
575
+	//autoList, _ := service.GetMobileAutoReduce(adminInfo.Org.Id, date.Unix())
576
+	//for _, item := range goodList {
577
+	//	for _, it := range list {
578
+	//		if item.RecordDate == it.RecordDate && item.PatientId == it.PatientId {
579
+	//			item.Children = append(item.Children, it)
580
+	//		}
581
+	//	}
582
+	//}
586 583
 
587 584
 	returnData := map[string]interface{}{
588 585
 		"patient":                        patient,
@@ -614,8 +611,8 @@ func (this *DialysisAPIController) DialysisRecord() {
614 611
 		"is_project_open_config":         is_project_open_config,
615 612
 		"project":                        projects,
616 613
 		"team_projects":                  team_projects,
617
-		"goodList":                       goodList,
618
-		"autoList":                       autoList,
614
+		//"goodList":                       goodList,
615
+		//"autoList":                       autoList,
619 616
 	}
620 617
 	this.ServeSuccessJSON(returnData)
621 618
 }

+ 6 - 0
controllers/print_data_api_controller.go 查看文件

@@ -37,7 +37,13 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
37 37
 	idStrs := strings.Split(schIDStr, ",")
38 38
 	adminUserInfo := this.GetAdminUserInfo()
39 39
 	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
40
+	for _, item := range schedules {
41
+		list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
42
+		if this.GetAdminUserInfo().CurrentOrgId != 10101 {
43
+			item.Count = list.Count
44
+		}
40 45
 
46
+	}
41 47
 	if getScheduleErr != nil {
42 48
 		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
43 49
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 12 - 0
controllers/schedule_api_controller.go 查看文件

@@ -69,6 +69,7 @@ func ScheduleApiRegistRouters() {
69 69
 	beego.Router("/api/schedule/getnextweekpanels", &ScheduleApiController{}, "Get:GetNextWeekPanels")
70 70
 	beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
71 71
 	beego.Router("/api/schedule/getpatientscheduletemplate", &ScheduleApiController{}, "Get:GetPatientScheduleTempalate")
72
+	beego.Router("/api/schedule/getsolutionschedule", &ScheduleApiController{}, "Get:GetSolutionSchedule")
72 73
 }
73 74
 
74 75
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -2940,3 +2941,14 @@ func (c *ScheduleApiController) GetPatientScheduleTempalate() {
2940 2941
 		"schedule": tempalate,
2941 2942
 	})
2942 2943
 }
2944
+
2945
+func (c *ScheduleApiController) GetSolutionSchedule() {
2946
+
2947
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2948
+	solution, _ := service.GetSolutionSchedule(orgId)
2949
+	fmt.Println("solution33232323223233233323232332323232", solution)
2950
+	c.ServeSuccessJSON(map[string]interface{}{
2951
+		"solution": solution,
2952
+	})
2953
+	return
2954
+}

+ 2 - 1
main.go 查看文件

@@ -11,13 +11,14 @@ func init() {
11 11
 }
12 12
 
13 13
 func main() {
14
-	service.BeginAutoCreateWeekSchedulesJob()
14
+	//service.BeginAutoCreateWeekSchedulesJob()
15 15
 	//service.BeginAutoCreateWeekDisinfectionJob()
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()
18 18
 	//service.BeginAutoCreateStaffScheduleJob()
19 19
 	//service.BeginAutoCreateDrugJob()
20 20
 	//service.BeginAutoCreateStockJob()
21
+
21 22
 	//beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 6000
22 23
 	beego.Run()
23 24
 }

+ 13 - 0
models/dialysis.go 查看文件

@@ -774,6 +774,19 @@ type DialysisOrders struct {
774 774
 	Number         string       `gorm:"column:number" json:"number"`
775 775
 }
776 776
 
777
+type VmDialysisOrder struct {
778
+	Count        int64
779
+	DialysisDate int64 `gorm:"column:dialysis_date" json:"dialysis_date"`
780
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
781
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
782
+	Stage        int64 `gorm:"column:stage" json:"stage"`
783
+	Status       int64 `gorm:"column:status" json:"status"`
784
+}
785
+
786
+func (VmDialysisOrder) TableName() string {
787
+	return "xt_dialysis_order"
788
+}
789
+
777 790
 type DialysisOrder struct {
778 791
 	ID                     int64         `gorm:"column:id" json:"id"`
779 792
 	DialysisDate           int64         `gorm:"column:dialysis_date" json:"dialysis_date"`

+ 8 - 1
models/his_models.go 查看文件

@@ -180,6 +180,14 @@ func (HisCaseHistoryTemplate) TableName() string {
180 180
 	return "his_case_history_template"
181 181
 }
182 182
 
183
+type HisList struct {
184
+	Patient_id  int64
185
+	Advice_id   int64
186
+	Record_date int64
187
+	Advice      []HisDoctorAdviceInfo    `gorm:json:"advices"`
188
+	Project     []HisPrescriptionProject `gorm:json:"project"`
189
+}
190
+
183 191
 type HisDoctorAdviceInfo struct {
184 192
 	ID                    int64                  `gorm:"column:id" json:"id" form:"id"`
185 193
 	UserOrgId             int64                  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -1636,7 +1644,6 @@ func (HisStockPriceConfig) TableName() string {
1636 1644
 	return "his_stock_price_config"
1637 1645
 }
1638 1646
 
1639
-
1640 1647
 type SgjAdmin struct {
1641 1648
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1642 1649
 	Account      string `gorm:"column:account" json:"account" form:"account"`

+ 16 - 0
models/stock_models.go 查看文件

@@ -239,6 +239,22 @@ func (WarehouseOutInfo) TableName() string {
239 239
 	return "xt_warehouse_out_info"
240 240
 }
241 241
 
242
+type WarehouseOutInfoNight struct {
243
+	ID               int64 `gorm:"column:id" json:"id"`
244
+	Count            int64 `gorm:"column:count" json:"count"`
245
+	GoodId           int64 `gorm:"column:good_id" json:"good_id"`
246
+	SysRecordTime    int64 `gorm:"column:sys_record_time" json:"sys_record_time"`
247
+	PatientId        int64 `gorm:"column:patient_id" json:"patient_id"`
248
+	ProjectId        int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
249
+	WarehouseInfotId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
250
+	IsSys            int64 `gorm:"column:is_sys" json:"is_sys"`
251
+	Status           int64 `gorm:"column:status" json:"status"`
252
+}
253
+
254
+func (WarehouseOutInfoNight) TableName() string {
255
+	return "xt_warehouse_out_info"
256
+}
257
+
242 258
 type WarehouseOutInfoSeven struct {
243 259
 	ID    int64 `gorm:"column:id" json:"id"`
244 260
 	Count int64 `gorm:"column:count" json:"count"`

+ 14 - 2
service/dialysis_service.go 查看文件

@@ -696,7 +696,7 @@ func GetLastAcceptsAssessment(patient int64, orgId int64) (error, models.Receive
696 696
 	return err, receiveTreatmentAsses
697 697
 }
698 698
 
699
-func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64) (schedule []*models.DialysisSchedule, err error, total int64) {
699
+func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) (schedule []*models.DialysisSchedule, err error, total int64) {
700 700
 	db := readDb.
701 701
 		Model(&models.MonitorDialysisSchedule{}).
702 702
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
@@ -717,6 +717,12 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
717 717
 	if schedulType > 0 {
718 718
 		db = db.Where("schedule_type = ?", schedulType)
719 719
 	}
720
+	if start > 0 {
721
+		db = db.Where("schedule_date >= ?", start)
722
+	}
723
+	if end > 0 {
724
+		db = db.Where("schedule_date <= ?", end)
725
+	}
720 726
 	if partitionType > 0 {
721 727
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ? and xt_device_number.status = 1", partitionType)
722 728
 		// db = db.Where("partition_id = ?", partitionType)
@@ -741,7 +747,7 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
741 747
 //	return schedules, err, total
742 748
 //}
743 749
 
744
-func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) ([]*models.DialysisSchedule, error, int64) {
750
+func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64, start int64, end int64) ([]*models.DialysisSchedule, error, int64) {
745 751
 	var patients []*models.Patients
746 752
 	getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
747 753
 	if getPatientErr != nil {
@@ -767,6 +773,12 @@ func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, p
767 773
 	if schedulType > 0 {
768 774
 		db = db.Where("schedule_type = ?", schedulType)
769 775
 	}
776
+	if start > 0 {
777
+		db = db.Where("schedule_date >= ?", start)
778
+	}
779
+	if end > 0 {
780
+		db = db.Where("schedule_date<=?", end)
781
+	}
770 782
 	if partitionType > 0 {
771 783
 		db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
772 784
 		// db = db.Where("partition_id = ?", partitionType)

+ 1 - 1
service/his_project_service.go 查看文件

@@ -47,7 +47,7 @@ func GetHisProjectList(orgid int64, limit int64, page int64, charge int64, start
47 47
 	if isMark > 0 {
48 48
 		db = db.Where("x.is_mark = ?", isMark)
49 49
 	}
50
-	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark").Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&hisproject).Error
50
+	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark,x.social_security_directory_code").Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&hisproject).Error
51 51
 	return hisproject, total, err
52 52
 }
53 53
 

+ 6 - 17
service/mobile_dialysis_service.go 查看文件

@@ -3592,24 +3592,13 @@ func MobileGetPredialysisEvaluationSeven(orgID int64, patientID int64, recordDat
3592 3592
 	return &record, nil
3593 3593
 }
3594 3594
 
3595
-func MobileGetDialysisGoodsSeven(orgID int64, scheduleDate int64) (prepare []*models.DialysisBeforePrepare, err error) {
3596
-
3597
-	db := readDb.Table("dialysis_before_prepare as p").Where("status = 1")
3598
-	if orgID > 0 {
3599
-		db = db.Where("p.user_org_id = ?", orgID)
3600
-	}
3601
-	if scheduleDate > 0 {
3602
-		db = db.Where("p.record_date<= ?", scheduleDate)
3603
-	}
3604
-	err = db.Select("p.patient_id,p.good_id,Max(p.record_date) as record_date").Group("patient_id").Order("id desc").Find(&prepare).Error
3605
-	return prepare, err
3606
-}
3607
-
3608
-func MobileGetDialysisGoodsSix(orgID int64, scheduleDate int64) (prepare []*models.DialysisBeforePrepare, err error) {
3595
+//
3609 3596
 
3610
-	err = readDb.Where("user_org_id = ? AND status=1 AND record_date <= ? AND count > 0", orgID, scheduleDate).Select("patient_id,good_id,record_date").Find(&prepare).Error
3611
-	return prepare, err
3612
-}
3597
+//func MobileGetDialysisGoodsSix(orgID int64, scheduleDate int64) (prepare []*models.DialysisBeforePrepare, err error) {
3598
+//
3599
+//	err = readDb.Where("user_org_id = ? AND status=1 AND record_date = ? AND count > 0", orgID, scheduleDate).Select("patient_id,good_id,record_date").Find(&prepare).Error
3600
+//	return prepare, err
3601
+//}
3613 3602
 
3614 3603
 func GetMobileAutoReduce(orgID int64, scheduleDate int64) (auto []*models.AutomaticReduceDetail, err error) {
3615 3604
 

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go 查看文件

@@ -575,7 +575,7 @@ type ScheduleVM struct {
575 575
 	LastAfterWeight          XtAssessmentAfterDislysisVM      `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
576 576
 	HisAdvices               []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_advices"`
577 577
 	HisPrescriptionProject   []*models.HisPrescriptionProject `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"his_project"`
578
-	Count                    int
578
+	Count                    int64
579 579
 }
580 580
 
581 581
 func (ScheduleVM) TableName() string {

+ 9 - 10
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go 查看文件

@@ -57,18 +57,16 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
57 57
 		return nil, err
58 58
 	}
59 59
 	for _, item := range schedules {
60
-
61 60
 		if orgID != 10101 {
62
-			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
61
+			dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
62
+
63 63
 			item.Patient.TotalDialysis = dialysis_count
64
+
64 65
 		}
65 66
 		if orgID == 10101 {
66 67
 			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
67 68
 			item.Patient.TotalDialysis = dialysis_count
68 69
 		}
69
-
70
-		fmt.Println(item.Patient.TotalDialysis)
71
-
72 70
 	}
73 71
 	return schedules, nil
74 72
 }
@@ -207,13 +205,14 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
207 205
 	return
208 206
 }
209 207
 
210
-//func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64)(order []*models.DialysisOrder,err error) {
211
-// err = p_service.XTReadDB().Where("dialysis_date <= ? AND status = 1 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Find(&order).Error
212
-// return order,err
213
-//}
208
+func GetDialysisOrderCountSeven(patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
209
+	order := models.VmDialysisOrder{}
210
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ?", recordDate, patient_id).Scan(&order).Error
211
+	return order, err
212
+}
214 213
 
215 214
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
216
-	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
215
+	err = p_service.XTReadDB().Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
217 216
 	return
218 217
 }
219 218
 

+ 6 - 0
service/schedule_service.go 查看文件

@@ -1100,3 +1100,9 @@ func GetPatientScheduleTempalate(orgid int64) (models.PatientScheduleTemplateMod
1100 1100
 	err := XTReadDB().Where("org_id = ? and status =1", orgid).Find(&mode).Error
1101 1101
 	return mode, err
1102 1102
 }
1103
+
1104
+func GetSolutionSchedule(orgid int64) (solution []*models.DialysisSolution, err error) {
1105
+
1106
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time desc").Find(&solution).Error
1107
+	return solution, err
1108
+}

+ 18 - 3
service/stock_service.go 查看文件

@@ -3569,12 +3569,26 @@ func GetHisProjectPrescriptionByPatientId(patientid int64, recorddate int64) (pr
3569 3569
 	return project, err
3570 3570
 }
3571 3571
 
3572
-func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfo, err error) {
3572
+func GetHisProjectPrescriptionByPatientIdOne(id int64) (models.HisPrescriptionProject, error) {
3573
+	project := models.HisPrescriptionProject{}
3574
+	err = XTReadDB().Model(&project).Where("id = ? and status =1", id).Find(&project).Error
3575
+	return project, err
3576
+}
3573 3577
 
3574
-	err = XTReadDB().Model(&auto).Where("patient_id = ? and sys_record_time = ? and status = 1", patientid, recorddate).Find(&auto).Error
3578
+func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfoNight, err error) {
3579
+
3580
+	err = XTReadDB().Select("count,warehouse_info_id").Where(" patient_id = ? and sys_record_time = ?  and status = 1 and is_sys = 1 and count>0", patientid, recorddate).Find(&auto).Error
3575 3581
 	return auto, err
3582
+
3576 3583
 }
3577 3584
 
3585
+//func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.VmStockFlow, err error) {
3586
+//
3587
+//	err = XTReadDB().Select("count,warehousing_id").Where(" patient_id = ? and system_time = ?  and status = 1 and is_sys = 1 and count>0",patientid,recorddate).Find(&auto).Error
3588
+//	return auto, err
3589
+//
3590
+//}
3591
+
3578 3592
 func ModefyWarehouseInfo(count int64, id int64) error {
3579 3593
 
3580 3594
 	err := XTWriteDB().Model(models.WarehousingInfo{}).Where(" id =? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
@@ -3585,8 +3599,9 @@ func DeleteAutoWarehouse(patient_id int64, record_time int64) error {
3585 3599
 
3586 3600
 	err := XTWriteDB().Model(models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3587 3601
 	err = XTWriteDB().Model(models.DialysisBeforePrepare{}).Where("patient_id = ? and record_date = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3588
-	err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("patient_id = ? and sys_record_time =? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3589 3602
 	err = XTWriteDB().Model(models.VmStockFlow{}).Where("patient_id = ? and system_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3603
+	err = XTWriteDB().Model(models.WarehouseOutInfoNight{}).Where("patient_id = ? and sys_record_time = ? and status = 1", patient_id, record_time).Updates(map[string]interface{}{"status": 0}).Error
3604
+	fmt.Println("err2332332322323322323232323232332", err)
3590 3605
 	return err
3591 3606
 }
3592 3607
 

+ 8 - 4
service/warhouse_service.go 查看文件

@@ -579,6 +579,8 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
579 579
 		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
580 580
 		var maxNumber int64 = 0
581 581
 		var minNumber int64 = 0
582
+		var stock_max_number int64 = 0
583
+		stock_max_number = warehouse.StockMaxNumber
582 584
 
583 585
 		maxNumber = deliver_number / drup.MinNumber
584 586
 		minNumber = deliver_number % drup.MinNumber
@@ -592,9 +594,9 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
592 594
 				return errors.New("库存数量不足")
593 595
 			}
594 596
 		}
595
-		if minNumber != 0 {
596
-			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
597
-		}
597
+		fmt.Println("minNumber23323323232323232322332", maxNumber, minNumber)
598
+
599
+		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
598 600
 
599 601
 		if warehouse.StockMaxNumber < 0 {
600 602
 			warehouse.StockMaxNumber = 0
@@ -618,7 +620,9 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
618 620
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
619 621
 			fmt.Println("2223232332322323", warehouse.StockMinNumber)
620 622
 			warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
621
-
623
+			if warehouse.StockMinNumber == 0 {
624
+				warehouse.StockMaxNumber = stock_max_number
625
+			}
622 626
 		}
623 627
 
624 628
 		if drup.MaxUnit != drup.MinUnit {