浏览代码

11月8日库存管理

XMLWAN 3 年前
父节点
当前提交
361573b5d8

+ 1 - 1
conf/app.conf 查看文件

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 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,

+ 241 - 353
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"
@@ -666,8 +665,6 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
666 665
 	})
667 666
 }
668 667
 
669
-var waitGroup sync.WaitGroup
670
-
671 668
 func (c *HisApiController) CreateHisPrescription() {
672 669
 	record_date := c.GetString("record_date")
673 670
 	patient_id, _ := c.GetInt64("patient_id")
@@ -715,12 +712,9 @@ func (c *HisApiController) CreateHisPrescription() {
715 712
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
716 713
 
717 714
 	if drugStockConfig.IsOpen == 1 {
718
-
719 715
 		//校验库存总量
720 716
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
721 717
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
722
-
723
-			//GetPrescriptionById(prescriptions)
724 718
 			if len(prescriptions) > 0 {
725 719
 				for _, item := range prescriptions {
726 720
 					items := item.(map[string]interface{})
@@ -731,6 +725,7 @@ func (c *HisApiController) CreateHisPrescription() {
731 725
 								var drug_id int64
732 726
 								var prescribing_number float64
733 727
 								var prescribingNumberUnit string
728
+								var prescribingNumber string
734 729
 
735 730
 								var adviceId int64
736 731
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
@@ -739,7 +734,7 @@ func (c *HisApiController) CreateHisPrescription() {
739 734
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
740 735
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
741 736
 									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
742
-
737
+									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
743 738
 								}
744 739
 
745 740
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
@@ -765,31 +760,51 @@ func (c *HisApiController) CreateHisPrescription() {
765 760
 								//查询该药品是否存在开药记录
766 761
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
767 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
+								}
768 781
 								//修改处方
769 782
 								if advicelist.ID > 0 {
770 783
 									var device_number int64
784
+
771 785
 									if advicelist.PrescribingNumberUnit == drug.MaxUnit {
772
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
773
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
786
+										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
787
+										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
774 788
 										device_number = prescribingNumberInt * drug.MinNumber
775 789
 									}
776 790
 									if advicelist.PrescribingNumberUnit == drug.MinUnit {
777
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
778
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
791
+										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
792
+										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
779 793
 										device_number = prescribingNumberInt
780 794
 									}
781 795
 
782 796
 									var number_count int64
783 797
 									if prescribingNumberUnit == drug.MaxUnit {
784
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
785 798
 										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
786 799
 										number_count = prescribingNumberInt * drug.MinNumber
787 800
 									}
788 801
 									if prescribingNumberUnit == drug.MinUnit {
789
-										prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
790 802
 										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
791 803
 										number_count = prescribingNumberInt
792 804
 									}
805
+
806
+									fmt.Println("以前出库数量23323232322332323223233223232332", device_number)
807
+									fmt.Println("现在出库数量", number_count)
793 808
 									//如果修改的数量大于之前修改的数量
794 809
 									if (number_count - device_number) > 0 {
795 810
 										//如果修改的差数量 大于库存数量
@@ -798,27 +813,42 @@ func (c *HisApiController) CreateHisPrescription() {
798 813
 											return
799 814
 										}
800 815
 									}
801
-								}
802 816
 
803
-								//新增处方
804
-								if advicelist.ID == 0 {
805
-									all_count, _ := strconv.ParseFloat(totals, 64)
806
-									if prescribingNumberUnit == drug.MinUnit {
807
-										if prescribing_number > all_count {
808
-											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
809
-											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)
810 827
 										}
811
-									} else {
812
-										if prescribingNumberUnit == drug.MaxUnit {
813
-											num := prescribing_number * float64(drug.MinNumber)
814
-											if num > all_count {
815
-												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
816
-												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)
817 842
 											}
818 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)
819 850
 									}
820 851
 								}
821
-
822 852
 							}
823 853
 						}
824 854
 					}
@@ -832,6 +862,7 @@ func (c *HisApiController) CreateHisPrescription() {
832 862
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
833 863
 			if len(prescriptions) > 0 {
834 864
 				for _, item := range prescriptions {
865
+
835 866
 					items := item.(map[string]interface{})
836 867
 					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
837 868
 						projects := items["project"].([]interface{})
@@ -840,6 +871,8 @@ func (c *HisApiController) CreateHisPrescription() {
840 871
 								var project_id int64
841 872
 								var project_type int64
842 873
 								var totals float64
874
+								var project_name string
875
+								var parsetotal int64
843 876
 								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
844 877
 									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
845 878
 								}
@@ -848,20 +881,21 @@ func (c *HisApiController) CreateHisPrescription() {
848 881
 								}
849 882
 								if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
850 883
 									total, _ := project.(map[string]interface{})["total"].(string)
851
-
852 884
 									totals, _ = strconv.ParseFloat(total, 64)
885
+									parsetotal, _ = strconv.ParseInt(total, 10, 64)
853 886
 								}
854
-								if project_type == 3 {
887
+								if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
888
+									project_name = project.(map[string]interface{})["project_name"].(string)
855 889
 
890
+								}
891
+								if project_type == 3 {
856 892
 									//查找该耗材的出库记录
857
-									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSeven(project_id, patient_id, recordDateTime)
858
-
859
-									if goodWarehouseInfo.ID == 0 {
860
-										good, _ := service.FindGoodInfoByIdSeven(project_id)
861
-										if good.ID == 0 {
862
-											c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
863
-											return
864
-										}
893
+									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
894
+									var total_count int64
895
+									for _, it := range goodWarehouseInfo {
896
+										total_count += it.Count
897
+									}
898
+									if len(goodWarehouseInfo) == 0 {
865 899
 										//查询耗材库存
866 900
 										list, _ := service.GetGoodWarehouseInfoSeven(project_id)
867 901
 										var stock_count int64
@@ -871,183 +905,11 @@ func (c *HisApiController) CreateHisPrescription() {
871 905
 										stock_counts := strconv.FormatInt(stock_count, 10)
872 906
 										stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
873 907
 										if totals > stock_total_count {
874
-											c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
908
+											c.ServeDynamicFailJsonSend(project_name + "库存不足")
875 909
 											return
876 910
 										}
877 911
 									}
878
-								}
879
-
880
-							}
881
-						}
882
-					}
883
-				}
884
-			}
885
-		}
886
-	}
887
-
888
-	ch := make(chan struct{})
889
-	count := 2 // count 表示活动的协程个数
890
-
891
-	go func() {
892
-		if drugStockConfig.IsOpen == 1 {
893
-			//校验库存总量
894
-			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
895
-				prescriptions, _ := dataBody["prescriptions"].([]interface{})
896
-				if len(prescriptions) > 0 {
897
-					for _, item := range prescriptions {
898
-						items := item.(map[string]interface{})
899
-						if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
900
-							advices := items["advices"].([]interface{})
901
-							if len(advices) > 0 {
902
-								for _, advice := range advices {
903
-									var drug_id int64
904
-									var prescribingNumberUnit string
905
-									var prescribingNumber string
906
-									var adviceId int64
907
-									if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
908
-										drug_id = int64(advice.(map[string]interface{})["id"].(float64))
909
-									}
910
-									if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
911
-
912
-										prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
913
-
914
-									}
915
-
916
-									if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
917
-										prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
918
-									}
919
-
920
-									if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
921
-										adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
922
-									}
923
-
924
-									drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
925
-									if drug.ID == 0 {
926
-										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
927
-										return
928
-									}
929
-
930
-									//查询药品的所有库存
931
-									list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
932
-									var total_count int64
933
-									for _, it := range list {
934
-										total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
935
-									}
936
-
937
-									//查询该药品是否存在开药记录
938
-									advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
939
-
940
-									//修改处方
941
-									if advicelist.ID > 0 {
942
-										var device_number int64
943
-										if advicelist.PrescribingNumberUnit == drug.MaxUnit {
944
-											prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
945
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
946
-											device_number = prescribingNumberInt * drug.MinNumber
947
-										}
948
-										if advicelist.PrescribingNumberUnit == drug.MinUnit {
949
-											prescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
950
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
951
-											device_number = prescribingNumberInt
952
-										}
953
-
954
-										var sum_count int64
955
-										//判断是否做过修改
956
-										if prescribingNumberUnit == drug.MaxUnit {
957
-
958
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
959
-
960
-											sum_count = prescribingNumberInt * drug.MinNumber
961
-										}
962
-										if prescribingNumberUnit == drug.MinUnit {
963
-											prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
964
-											sum_count = prescribingNumberInt
965
-										}
966
-										fmt.Println("sum_count23322332323232323232323223322323", sum_count)
967
-										fmt.Println("devcie_number23333223333332232332233232323223", device_number)
968
-
969
-										if device_number != sum_count {
970
-
971
-											// 查询该药品最后一次出库记录
972
-											druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
973
-											fmt.Println("单位12332232322332322323233223", druginfo.CountUnit)
974
-											fmt.Println("单位2332233223323223322332332233223", drug.MaxUnit)
975
-											//回退库存
976
-											if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
977
-
978
-												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
979
-											}
980
-											if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
981
-												var stock_max_number int64
982
-												var stock_min_number int64
983
-												if device_number >= drug.MinNumber {
984
-													stock_max_number = device_number / drug.MinNumber
985
-													//fmt.Println("大的值2323233232232323", stock_max_number)
986
-													service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
987
-													stock_min_number = device_number % drug.MinNumber
988
-													//	fmt.Println("小的值322332332323233223", stock_min_number)
989
-													if stock_min_number == drug.MinNumber {
990
-
991
-													}
992
-													service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
993
-
994
-												} else {
995
-
996
-													service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
997
-												}
998
-
999
-											}
1000
-
1001
-											if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1002
-												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
1003
-											}
1004
-
1005
-											//删除记录
1006
-											service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
1007
-										}
1008
-									}
1009
-								}
1010
-							}
1011
-						}
1012
-					}
1013
-				}
1014
-			}
1015
-		}
1016
-		ch <- struct{}{}
1017
-	}()
1018
-
1019
-	go func() {
1020
-		if stockConfig.IsOpen == 1 {
1021
-			if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1022
-				prescriptions, _ := dataBody["prescriptions"].([]interface{})
1023
-				if len(prescriptions) > 0 {
1024
-					for _, item := range prescriptions {
1025
-						items := item.(map[string]interface{})
1026
-						if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
1027
-							projects := items["project"].([]interface{})
1028
-							if len(projects) > 0 {
1029
-								for _, project := range projects {
1030
-									var project_id int64
1031
-									var project_type int64
1032
-									var parsetotal int64
1033
-									if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
1034
-										project_id = int64(project.(map[string]interface{})["project_id"].(float64))
1035
-									}
1036
-									if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
1037
-										project_type = int64(project.(map[string]interface{})["type"].(float64))
1038
-									}
1039
-									if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
1040
-										total, _ := project.(map[string]interface{})["total"].(string)
1041
-										parsetotal, _ = strconv.ParseInt(total, 10, 64)
1042
-									}
1043
-
1044
-									if project_type == 3 {
1045
-										//查找该耗材的出库记录
1046
-										goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
1047
-										var total_count int64
1048
-										for _, it := range goodWarehouseInfo {
1049
-											total_count += it.Count
1050
-										}
912
+									if len(goodWarehouseInfo) > 0 {
1051 913
 										//查询该患者耗材的历史数据
1052 914
 										ordProject, _ := service.GetHisProjectPrescriptionByPatientId(patient_id, recordDateTime)
1053 915
 										if total_count > 0 {
@@ -1055,12 +917,13 @@ func (c *HisApiController) CreateHisPrescription() {
1055 917
 											if parsetotal != total_count || len(ordProject) != len(projects) {
1056 918
 												//查找今日该患者已经出库的所有耗材
1057 919
 												goodList, _ := service.GetAllAutoRecordByPatient(patient_id, recordDateTime)
920
+												fmt.Println("goodList3323223232323232323", goodList)
1058 921
 												for _, item := range goodList {
1059 922
 													//回退库存
1060 923
 													service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
1061
-													//删除记录
1062
-													service.DeleteAutoWarehouse(item.PatientId, item.SysRecordTime)
1063 924
 												}
925
+												//删除记录
926
+												service.DeleteAutoWarehouse(patient_id, recordDateTime)
1064 927
 											}
1065 928
 										}
1066 929
 									}
@@ -1071,16 +934,6 @@ func (c *HisApiController) CreateHisPrescription() {
1071 934
 				}
1072 935
 			}
1073 936
 		}
1074
-		ch <- struct{}{}
1075
-	}()
1076
-
1077
-	for range ch {
1078
-		// 每次从ch中接收数据,表明一个活动的协程结束
1079
-		count--
1080
-		// 当所有活动的协程都结束时,关闭管道
1081
-		if count == 0 {
1082
-			close(ch)
1083
-		}
1084 937
 	}
1085 938
 
1086 939
 	info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
@@ -1158,10 +1011,18 @@ func (c *HisApiController) CreateHisPrescription() {
1158 1011
 		defer redis.Close()
1159 1012
 	}
1160 1013
 
1014
+	//定义切片
1015
+
1016
+	var adviceList []models.HisDoctorAdviceInfo
1017
+	var projectList []models.HisPrescriptionProject
1018
+
1019
+	//var hisLis  []models.HisList
1020
+
1161 1021
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
1162 1022
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
1163 1023
 
1164 1024
 		var tempPrescription *models.HisPrescription
1025
+
1165 1026
 		if len(prescriptions) > 0 {
1166 1027
 			for _, item := range prescriptions {
1167 1028
 				items := item.(map[string]interface{})
@@ -1302,6 +1163,10 @@ func (c *HisApiController) CreateHisPrescription() {
1302 1163
 
1303 1164
 							s.StartTime = pTime
1304 1165
 							service.CreateHisDoctorAdvice(&s)
1166
+
1167
+							//存储切片中
1168
+							adviceList = append(adviceList, s)
1169
+
1305 1170
 							redis := service.RedisClient()
1306 1171
 							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
1307 1172
 							redis.Set(key, "", time.Second)
@@ -1349,6 +1214,7 @@ func (c *HisApiController) CreateHisPrescription() {
1349 1214
 							}
1350 1215
 
1351 1216
 							service.CreateHisProjectTwo(&p)
1217
+							projectList = append(projectList, p)
1352 1218
 							var randNum int
1353 1219
 							randNum = rand.Intn(10000) + 1000
1354 1220
 							timestamp := time.Now().Unix()
@@ -1408,14 +1274,14 @@ func (c *HisApiController) CreateHisPrescription() {
1408 1274
 
1409 1275
 							service.SaveHisProjectTwo(&p)
1410 1276
 
1411
-							if p.Type == 3 { //处理透前准备耗材数量数据
1412
-								consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
1413
-								if consumables.ID > 0 {
1414
-									cnt, _ := strconv.ParseInt(p.Count, 10, 64)
1415
-									consumables.Count = cnt
1416
-									service.UpdateConsumables(&consumables)
1417
-								}
1418
-							}
1277
+							//if p.Type == 3 { //处理透前准备耗材数量数据
1278
+							//	consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
1279
+							//	if consumables.ID > 0 {
1280
+							//		cnt, _ := strconv.ParseInt(p.Count, 10, 64)
1281
+							//		consumables.Count = cnt
1282
+							//		service.UpdateConsumables(&consumables)
1283
+							//	}
1284
+							//}
1419 1285
 
1420 1286
 						}
1421 1287
 					}
@@ -1458,6 +1324,33 @@ func (c *HisApiController) CreateHisPrescription() {
1458 1324
 		}
1459 1325
 	}
1460 1326
 
1327
+	//redisClient := service.RedisClient()
1328
+	//defer redisClient.Close()
1329
+	//
1330
+	//list := models.HisList{
1331
+	//  Patient_id:  patient_id,
1332
+	//  Advice_id:0,
1333
+	//  Record_date: 0,
1334
+	//  Advice:      adviceList,
1335
+	//  Project:     nil,
1336
+	//}
1337
+	//hisLis = append(hisLis, list)
1338
+	//
1339
+	//advice_json, _ := json.Marshal(&hisLis)
1340
+	//redisClient.RPush("111", advice_json).Result()
1341
+	//result, _ := redisClient.RPop("111").Result()
1342
+	//fmt.Println("resuilt2332323323232323232323232322323233232",redisClient.LLen("111"))
1343
+	//
1344
+	//var dat []map[string]interface{}
1345
+	//json.Unmarshal([]byte(result), &dat)
1346
+	//fmt.Println("hhhh2332323232233223322332322323232323",dat)
1347
+	//
1348
+	//for k,v:=range dat{
1349
+	//  fmt.Println("第",k,"个数的值是:",v,v["Advice"],v["Patient_id"])
1350
+	//}
1351
+	//project_json, _ := json.Marshal(&projectList)
1352
+	//redisClient.LPush("222", project_json).Result()
1353
+
1461 1354
 	if err == nil {
1462 1355
 		c.ServeSuccessJSON(map[string]interface{}{
1463 1356
 			"msg": "保存成功",
@@ -3338,82 +3231,82 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
3338 3231
 		}
3339 3232
 	}
3340 3233
 
3341
-	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(advice.UserOrgId)
3342
-
3343
-	if drugStockConfig.IsOpen == 1 {
3344
-
3345
-		drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
3346
-		if advice.ID == 0 { //医嘱不存在
3347
-			if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
3348
-				drug.Total = drug.Total - advice.PrescribingNumber
3349
-				service.UpdateBaseDrugLib(&drug)
3350
-
3351
-			} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
3352
-				num := advice.PrescribingNumber * float64(drug.MinNumber)
3353
-				drug.Total = drug.Total - num
3354
-				service.UpdateBaseDrugLib(&drug)
3355
-			}
3356
-
3357
-		} else if advice.ID > 0 { //医嘱存在
3358
-			hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
3359
-			var num float64
3360
-
3361
-			if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
3362
-				if hisAdvice.PrescribingNumberUnit == advice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
3363
-					if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
3364
-						num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
3365
-						drug.Total = drug.Total + num
3366
-						service.UpdateBaseDrugLib(&drug)
3367
-					} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
3368
-						num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
3369
-						drug.Total = drug.Total - num
3370
-						service.UpdateBaseDrugLib(&drug)
3371
-					}
3372
-				} else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
3373
-					num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3374
-					if num2 > advice.PrescribingNumber {
3375
-						num = num2 - advice.PrescribingNumber
3376
-						drug.Total = drug.Total + num
3377
-						service.UpdateBaseDrugLib(&drug)
3378
-					} else if num2 < advice.PrescribingNumber {
3379
-						num = advice.PrescribingNumber - num2
3380
-						drug.Total = drug.Total - num
3381
-						service.UpdateBaseDrugLib(&drug)
3382
-					}
3383
-
3384
-				}
3385
-
3386
-			} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
3387
-				if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
3388
-					num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3389
-					num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3390
-					if num1 > num2 {
3391
-						num = num1 - num2
3392
-						drug.Total = drug.Total + num
3393
-						service.UpdateBaseDrugLib(&drug)
3394
-					} else if num1 < num2 {
3395
-						num = num2 - num1
3396
-						drug.Total = drug.Total - num
3397
-						service.UpdateBaseDrugLib(&drug)
3398
-					}
3399
-
3400
-				} else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
3401
-					num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3402
-					//num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
3403
-					if hisAdvice.PrescribingNumber > num2 {
3404
-						num = hisAdvice.PrescribingNumber - num2
3405
-						drug.Total = drug.Total + num
3406
-						service.UpdateBaseDrugLib(&drug)
3407
-					} else if num2 < advice.PrescribingNumber {
3408
-						num = num2 - hisAdvice.PrescribingNumber
3409
-						drug.Total = drug.Total - num
3410
-						service.UpdateBaseDrugLib(&drug)
3411
-					}
3412
-
3413
-				}
3414
-			}
3415
-		}
3416
-	}
3234
+	//_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(advice.UserOrgId)
3235
+	//
3236
+	//if drugStockConfig.IsOpen == 1 {
3237
+	//
3238
+	//	drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
3239
+	//	if advice.ID == 0 { //医嘱不存在
3240
+	//		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
3241
+	//			drug.Total = drug.Total - advice.PrescribingNumber
3242
+	//			service.UpdateBaseDrugLib(&drug)
3243
+	//
3244
+	//		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
3245
+	//			num := advice.PrescribingNumber * float64(drug.MinNumber)
3246
+	//			drug.Total = drug.Total - num
3247
+	//			service.UpdateBaseDrugLib(&drug)
3248
+	//		}
3249
+	//
3250
+	//	} else if advice.ID > 0 { //医嘱存在
3251
+	//		hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
3252
+	//		var num float64
3253
+	//
3254
+	//		if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
3255
+	//			if hisAdvice.PrescribingNumberUnit == advice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
3256
+	//				if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
3257
+	//					num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
3258
+	//					drug.Total = drug.Total + num
3259
+	//					service.UpdateBaseDrugLib(&drug)
3260
+	//				} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
3261
+	//					num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
3262
+	//					drug.Total = drug.Total - num
3263
+	//					service.UpdateBaseDrugLib(&drug)
3264
+	//				}
3265
+	//			} else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
3266
+	//				num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3267
+	//				if num2 > advice.PrescribingNumber {
3268
+	//					num = num2 - advice.PrescribingNumber
3269
+	//					drug.Total = drug.Total + num
3270
+	//					service.UpdateBaseDrugLib(&drug)
3271
+	//				} else if num2 < advice.PrescribingNumber {
3272
+	//					num = advice.PrescribingNumber - num2
3273
+	//					drug.Total = drug.Total - num
3274
+	//					service.UpdateBaseDrugLib(&drug)
3275
+	//				}
3276
+	//
3277
+	//			}
3278
+	//
3279
+	//		} else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
3280
+	//			if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
3281
+	//				num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
3282
+	//				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3283
+	//				if num1 > num2 {
3284
+	//					num = num1 - num2
3285
+	//					drug.Total = drug.Total + num
3286
+	//					service.UpdateBaseDrugLib(&drug)
3287
+	//				} else if num1 < num2 {
3288
+	//					num = num2 - num1
3289
+	//					drug.Total = drug.Total - num
3290
+	//					service.UpdateBaseDrugLib(&drug)
3291
+	//				}
3292
+	//
3293
+	//			} else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
3294
+	//				num2 := advice.PrescribingNumber * float64(drug.MinNumber)
3295
+	//				//num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
3296
+	//				if hisAdvice.PrescribingNumber > num2 {
3297
+	//					num = hisAdvice.PrescribingNumber - num2
3298
+	//					drug.Total = drug.Total + num
3299
+	//					service.UpdateBaseDrugLib(&drug)
3300
+	//				} else if num2 < advice.PrescribingNumber {
3301
+	//					num = num2 - hisAdvice.PrescribingNumber
3302
+	//					drug.Total = drug.Total - num
3303
+	//					service.UpdateBaseDrugLib(&drug)
3304
+	//				}
3305
+	//
3306
+	//			}
3307
+	//		}
3308
+	//	}
3309
+	//}
3417 3310
 
3418 3311
 	//
3419 3312
 	//if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
@@ -3555,46 +3448,46 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
3555 3448
 	//	project.WeekDay = week_day
3556 3449
 	//}
3557 3450
 
3558
-	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
3559
-
3560
-	if project.ID == 0 {
3561
-		if stockConfig.IsOpen == 1 {
3562
-			if project.Type == 3 {
3563
-				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3564
-				f_count, _ := strconv.ParseFloat(project.Count, 64)
3565
-				good.Total = good.Total - f_count
3566
-				service.UpdateGoodInfo(&good)
3567
-			}
3568
-		}
3569
-
3570
-	} else {
3571
-		temp_project, _ := service.GetHisPrescriptionProjectByID(project.ID)
3572
-
3573
-		if stockConfig.IsOpen == 1 {
3574
-			if project.Type == 3 {
3575
-				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3576
-				if project.Count < temp_project.Count {
3577
-					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3578
-					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3579
-
3580
-					other_count := f_count_two - f_count_one
3581
-					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3582
-					good.Total = good.Total + other_count_two
3583
-					service.UpdateGoodInfo(&good)
3584
-				} else if project.Count > temp_project.Count {
3585
-					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3586
-					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3587
-
3588
-					other_count := f_count_one - f_count_two
3589
-					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3590
-					good.Total = good.Total - other_count_two
3591
-					service.UpdateGoodInfo(&good)
3592
-				}
3593
-
3594
-			}
3595
-		}
3596
-
3597
-	}
3451
+	//_, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
3452
+	//
3453
+	//if project.ID == 0 {
3454
+	//	if stockConfig.IsOpen == 1 {
3455
+	//		if project.Type == 3 {
3456
+	//			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3457
+	//			f_count, _ := strconv.ParseFloat(project.Count, 64)
3458
+	//			good.Total = good.Total - f_count
3459
+	//			service.UpdateGoodInfo(&good)
3460
+	//		}
3461
+	//	}
3462
+	//
3463
+	//} else {
3464
+	//	temp_project, _ := service.GetHisPrescriptionProjectByID(project.ID)
3465
+	//
3466
+	//	if stockConfig.IsOpen == 1 {
3467
+	//		if project.Type == 3 {
3468
+	//			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
3469
+	//			if project.Count < temp_project.Count {
3470
+	//				f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3471
+	//				f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3472
+	//
3473
+	//				other_count := f_count_two - f_count_one
3474
+	//				other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3475
+	//				good.Total = good.Total + other_count_two
3476
+	//				service.UpdateGoodInfo(&good)
3477
+	//			} else if project.Count > temp_project.Count {
3478
+	//				f_count_one, _ := strconv.ParseFloat(project.Count, 64)
3479
+	//				f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
3480
+	//
3481
+	//				other_count := f_count_one - f_count_two
3482
+	//				other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
3483
+	//				good.Total = good.Total - other_count_two
3484
+	//				service.UpdateGoodInfo(&good)
3485
+	//			}
3486
+	//
3487
+	//		}
3488
+	//	}
3489
+	//
3490
+	//}
3598 3491
 
3599 3492
 	return 0
3600 3493
 }
@@ -6932,8 +6825,3 @@ func (c *HisApiController) GetHisDoctorAdviceInfo() {
6932 6825
 	})
6933 6826
 	return
6934 6827
 }
6935
-
6936
-func GetPrescriptionById(prescription []interface{}) {
6937
-
6938
-	fmt.Println("prescription222222222222225555532323332323233223323323322332323232323232332322323323232", prescription)
6939
-}

+ 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)

+ 11 - 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,13 @@ 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
+	c.ServeSuccessJSON(map[string]interface{}{
2950
+		"solution": solution,
2951
+	})
2952
+	return
2953
+}

+ 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
 

+ 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().Model(&solution).Where("org_id = ? and status = 1", orgid).Group("mode_id").Order("created_time desc").Find(&solution).Error
1107
+	return solution, err
1108
+}

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

@@ -3569,12 +3569,20 @@ 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 GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.WarehouseOutInfoNight, err error) {
3573 3573
 
3574
-	err = XTReadDB().Model(&auto).Where("patient_id = ? and sys_record_time = ? and status = 1", patientid, recorddate).Find(&auto).Error
3574
+	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 3575
 	return auto, err
3576
+
3576 3577
 }
3577 3578
 
3579
+//func GetAllAutoRecordByPatient(patientid int64, recorddate int64) (auto []*models.VmStockFlow, err error) {
3580
+//
3581
+//	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
3582
+//	return auto, err
3583
+//
3584
+//}
3585
+
3578 3586
 func ModefyWarehouseInfo(count int64, id int64) error {
3579 3587
 
3580 3588
 	err := XTWriteDB().Model(models.WarehousingInfo{}).Where(" id =? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
@@ -3585,8 +3593,9 @@ func DeleteAutoWarehouse(patient_id int64, record_time int64) error {
3585 3593
 
3586 3594
 	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 3595
 	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 3596
 	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
3597
+	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
3598
+	fmt.Println("err2332332322323322323232323232332", err)
3590 3599
 	return err
3591 3600
 }
3592 3601
 

+ 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 {