Browse Source

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

csx 3 years ago
parent
commit
0543c8b739

+ 0 - 1
controllers/dialysis_api_controller.go View File

2717
 			"project_config":            project_config,
2717
 			"project_config":            project_config,
2718
 			"projects":                  projects,
2718
 			"projects":                  projects,
2719
 		})
2719
 		})
2720
-
2721
 	}
2720
 	}
2722
 
2721
 
2723
 }
2722
 }

+ 163 - 69
controllers/doctors_api_controller.go View File

5
 	"XT_New/models"
5
 	"XT_New/models"
6
 	"XT_New/service"
6
 	"XT_New/service"
7
 	"XT_New/utils"
7
 	"XT_New/utils"
8
+	"encoding/json"
8
 	"fmt"
9
 	"fmt"
9
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego"
10
 	"github.com/jinzhu/gorm"
11
 	"github.com/jinzhu/gorm"
46
 	beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
47
 	beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
47
 	beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
48
 	beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
48
 	beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
49
 	beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
49
-	beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Get:SaveCreationInspection")
50
+	beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
50
 	beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
51
 	beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
51
 	beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
52
 	beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
52
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
53
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
53
-	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Get:UpdateTempalteSummary")
54
+	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
54
 	beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
55
 	beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
55
 }
56
 }
56
 
57
 
763
 
764
 
764
 func (this *DoctorsApiController) SaveCreationInspection() {
765
 func (this *DoctorsApiController) SaveCreationInspection() {
765
 
766
 
766
-	title := this.GetString("title")
767
-
768
-	dryWeight := this.GetString("dry_weight")
767
+	dataBody := make(map[string]interface{}, 0)
768
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
769
+	if err != nil {
770
+		utils.ErrorLog(err.Error())
771
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
772
+		return
773
+	}
774
+	title := dataBody["title"].(string)
775
+	dryWeight := dataBody["dry_weight"].(string)
769
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
776
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
770
-	dialysis_count, _ := this.GetInt64("dialysis_count")
771
-	hd_count, _ := this.GetInt64("hd_count")
772
-	hdf_count, _ := this.GetInt64("hdf_count")
773
-	hp_count, _ := this.GetInt64("hp_count")
774
-	other_count, _ := this.GetInt64("other_count")
775
-	dialzer_apparatus := this.GetString("dialzer_apparatus")
776
-	perfusion_apparatus := this.GetString("perfusion_apparatus")
777
-	anticoagulant, _ := this.GetInt64("anticoagulant")
778
-	kaliumstr := this.GetString("kalium")
777
+	dialysis_count := int64(dataBody["dialysis_count"].(float64))
778
+	hd_count := int64(dataBody["hd_count"].(float64))
779
+	hdf_count := int64(dataBody["hdf_count"].(float64))
780
+	hp_count := int64(dataBody["hp_count"].(float64))
781
+	other_count := int64(dataBody["other_count"].(float64))
782
+	dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
783
+	perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
784
+	anticoagulant := int64(dataBody["anticoagulant"].(float64))
785
+	kaliumstr := dataBody["kalium"].(string)
779
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
786
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
780
-
781
-	autunitestr := this.GetString("autunite")
787
+	autunitestr := dataBody["autunite"].(string)
782
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
788
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
783
-	natriumstr := this.GetString("natrium")
789
+	natriumstr := dataBody["natrium"].(string)
784
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
790
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
785
-	hour, _ := this.GetInt64("hour")
786
-	minute, _ := this.GetInt64("minute")
787
-	beforWeight := this.GetString("befor_weight")
791
+	hour := int64(dataBody["hour"].(float64))
792
+	minute := int64(dataBody["minute"].(float64))
793
+	beforWeight := dataBody["befor_weight"].(string)
788
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
794
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
789
-	afterWeight := this.GetString("after_weight")
795
+	afterWeight := dataBody["after_weight"].(string)
790
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
796
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
791
-	befor_pressure := this.GetString("befor_pressure")
792
-	template_summary_content := this.GetString("template_summary_content")
793
-	template_plan_content := this.GetString("template_plan_content")
794
-	admin_user_id, _ := this.GetInt64("admin_user_id")
795
-	record_time := this.GetString("record_time")
797
+	befor_pressure := dataBody["befor_pressure"].(string)
798
+	template_summary_content := dataBody["template_summary_content"].(string)
799
+	template_plan_content := dataBody["template_plan_content"].(string)
800
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
801
+	record_time := dataBody["record_time"].(string)
796
 	timeLayout := "2006-01-02"
802
 	timeLayout := "2006-01-02"
797
 	loc, _ := time.LoadLocation("Local")
803
 	loc, _ := time.LoadLocation("Local")
798
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
804
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
799
-	after_pressure := this.GetString("after_pressure")
800
-	template_summary_id, _ := this.GetInt64("template_summary_id")
801
-	template_plan_id, _ := this.GetInt64("template_plan_id")
802
-	template_inspection_id, _ := this.GetInt64("template_inspection_id")
803
-	patient_id, _ := this.GetInt64("patient_id")
804
-	fmt.Println("patient_id", patient_id)
805
+	after_pressure := dataBody["after_pressure"].(string)
806
+	template_summary_id := int64(dataBody["template_summary_id"].(float64))
807
+	template_plan_id := int64(dataBody["template_plan_id"].(float64))
808
+	patient_id := int64(dataBody["patient_id"].(float64))
805
 	orgId := this.GetAdminUserInfo().CurrentOrgId
809
 	orgId := this.GetAdminUserInfo().CurrentOrgId
806
-	inspect_date := this.GetString("inspect_date")
807
-	project_id := this.GetString("project_id")
810
+	inspect_date := dataBody["inspect_date"].(string)
811
+	project_id := dataBody["project_id"].(string)
812
+	template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
813
+	//title := this.GetString("title")
814
+	//dryWeight := this.GetString("dry_weight")
815
+	//dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
816
+	//dialysis_count, _ := this.GetInt64("dialysis_count")
817
+	//hd_count, _ := this.GetInt64("hd_count")
818
+	//hdf_count, _ := this.GetInt64("hdf_count")
819
+	//hp_count, _ := this.GetInt64("hp_count")
820
+	//other_count, _ := this.GetInt64("other_count")
821
+	//dialzer_apparatus := this.GetString("dialzer_apparatus")
822
+	//perfusion_apparatus := this.GetString("perfusion_apparatus")
823
+	//anticoagulant, _ := this.GetInt64("anticoagulant")
824
+	//kaliumstr := this.GetString("kalium")
825
+	//kalium, _ := strconv.ParseFloat(kaliumstr, 64)
826
+	//
827
+	//autunitestr := this.GetString("autunite")
828
+	//autunite, _ := strconv.ParseFloat(autunitestr, 64)
829
+	//natriumstr := this.GetString("natrium")
830
+	//natrium, _ := strconv.ParseFloat(natriumstr, 64)
831
+	//hour, _ := this.GetInt64("hour")
832
+	//minute, _ := this.GetInt64("minute")
833
+	//beforWeight := this.GetString("befor_weight")
834
+	//befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
835
+	//afterWeight := this.GetString("after_weight")
836
+	//after_weight, _ := strconv.ParseFloat(afterWeight, 64)
837
+	//befor_pressure := this.GetString("befor_pressure")
838
+	//template_summary_content := this.GetString("template_summary_content")
839
+	//template_plan_content := this.GetString("template_plan_content")
840
+	//admin_user_id, _ := this.GetInt64("admin_user_id")
841
+	//record_time := this.GetString("record_time")
842
+	//timeLayout := "2006-01-02"
843
+	//loc, _ := time.LoadLocation("Local")
844
+	//recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
845
+	//after_pressure := this.GetString("after_pressure")
846
+	//template_summary_id, _ := this.GetInt64("template_summary_id")
847
+	//template_plan_id, _ := this.GetInt64("template_plan_id")
848
+	//template_inspection_id, _ := this.GetInt64("template_inspection_id")
849
+	//patient_id, _ := this.GetInt64("patient_id")
850
+	//fmt.Println("patient_id", patient_id)
851
+	//orgId := this.GetAdminUserInfo().CurrentOrgId
852
+	//inspect_date := this.GetString("inspect_date")
853
+	//project_id := this.GetString("project_id")
808
 	summary := models.XtTemplateSummary{
854
 	summary := models.XtTemplateSummary{
809
 		StartYear:              0,
855
 		StartYear:              0,
810
 		StartMonth:             0,
856
 		StartMonth:             0,
845
 		ProjectId:              project_id,
891
 		ProjectId:              project_id,
846
 	}
892
 	}
847
 
893
 
848
-	err := service.CreateSummary(&summary)
894
+	err = service.CreateSummary(&summary)
849
 	if err == nil {
895
 	if err == nil {
850
 		this.ServeSuccessJSON(map[string]interface{}{
896
 		this.ServeSuccessJSON(map[string]interface{}{
851
 			"summary": summary,
897
 			"summary": summary,
912
 
958
 
913
 func (this *DoctorsApiController) UpdateTempalteSummary() {
959
 func (this *DoctorsApiController) UpdateTempalteSummary() {
914
 
960
 
915
-	id, _ := this.GetInt64("id")
916
-	title := this.GetString("title")
917
-
918
-	dryWeight := this.GetString("dry_weight")
961
+	dataBody := make(map[string]interface{}, 0)
962
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
963
+	if err != nil {
964
+		utils.ErrorLog(err.Error())
965
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
966
+		return
967
+	}
968
+	id := int64(dataBody["id"].(float64))
969
+	title := dataBody["title"].(string)
970
+	dryWeight := dataBody["dry_weight"].(string)
919
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
971
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
920
-	dialysis_count, _ := this.GetInt64("dialysis_count")
921
-	hd_count, _ := this.GetInt64("hd_count")
922
-	hdf_count, _ := this.GetInt64("hdf_count")
923
-	hp_count, _ := this.GetInt64("hp_count")
924
-	other_count, _ := this.GetInt64("other_count")
925
-	dialzer_apparatus := this.GetString("dialzer_apparatus")
926
-	perfusion_apparatus := this.GetString("perfusion_apparatus")
927
-	anticoagulant, _ := this.GetInt64("anticoagulant")
928
-	kaliumstr := this.GetString("kalium")
972
+	dialysis_count := int64(dataBody["dialysis_count"].(float64))
973
+	hd_count := int64(dataBody["hd_count"].(float64))
974
+	hdf_count := int64(dataBody["hdf_count"].(float64))
975
+	hp_count := int64(dataBody["hp_count"].(float64))
976
+	other_count := int64(dataBody["other_count"].(float64))
977
+	dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
978
+	perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
979
+	anticoagulant := int64(dataBody["anticoagulant"].(float64))
980
+	kaliumstr := dataBody["kalium"].(string)
929
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
981
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
930
-
931
-	autunitestr := this.GetString("autunite")
982
+	autunitestr := dataBody["autunite"].(string)
932
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
983
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
933
-	natriumstr := this.GetString("natrium")
984
+	natriumstr := dataBody["natrium"].(string)
934
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
985
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
935
-	hour, _ := this.GetInt64("hour")
936
-	minute, _ := this.GetInt64("minute")
937
-	beforWeight := this.GetString("befor_weight")
986
+	hour := int64(dataBody["hour"].(float64))
987
+	minute := int64(dataBody["minute"].(float64))
988
+	beforWeight := dataBody["befor_weight"].(string)
938
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
989
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
939
-	afterWeight := this.GetString("after_weight")
990
+	afterWeight := dataBody["after_weight"].(string)
940
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
991
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
941
-	befor_pressure := this.GetString("befor_pressure")
942
-	template_summary_content := this.GetString("template_summary_content")
943
-	template_plan_content := this.GetString("template_plan_content")
944
-	admin_user_id, _ := this.GetInt64("admin_user_id")
945
-	record_time := this.GetString("record_time")
992
+	befor_pressure := dataBody["befor_pressure"].(string)
993
+	template_summary_content := dataBody["template_summary_content"].(string)
994
+	template_plan_content := dataBody["template_plan_content"].(string)
995
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
996
+	record_time := dataBody["record_time"].(string)
946
 	timeLayout := "2006-01-02"
997
 	timeLayout := "2006-01-02"
947
 	loc, _ := time.LoadLocation("Local")
998
 	loc, _ := time.LoadLocation("Local")
948
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
999
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
949
-	after_pressure := this.GetString("after_pressure")
950
-	template_summary_id, _ := this.GetInt64("template_summary_id")
951
-	template_plan_id, _ := this.GetInt64("template_plan_id")
952
-	template_inspection_id, _ := this.GetInt64("template_inspection_id")
953
-	patient_id, _ := this.GetInt64("patient_id")
954
-	fmt.Println("patient_id", patient_id)
1000
+	after_pressure := dataBody["after_pressure"].(string)
1001
+	template_summary_id := int64(dataBody["template_summary_id"].(float64))
1002
+	template_plan_id := int64(dataBody["template_plan_id"].(float64))
1003
+	patient_id := int64(dataBody["patient_id"].(float64))
955
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1004
 	orgId := this.GetAdminUserInfo().CurrentOrgId
956
-	inspect_date := this.GetString("inspect_date")
957
-	project_id := this.GetString("project_id")
1005
+	inspect_date := dataBody["inspect_date"].(string)
1006
+	project_id := dataBody["project_id"].(string)
1007
+	template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
1008
+
1009
+	//id, _ := this.GetInt64("id")
1010
+	//title := this.GetString("title")
1011
+	//
1012
+	//dryWeight := this.GetString("dry_weight")
1013
+	//dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
1014
+	//dialysis_count, _ := this.GetInt64("dialysis_count")
1015
+	//hd_count, _ := this.GetInt64("hd_count")
1016
+	//hdf_count, _ := this.GetInt64("hdf_count")
1017
+	//hp_count, _ := this.GetInt64("hp_count")
1018
+	//other_count, _ := this.GetInt64("other_count")
1019
+	//dialzer_apparatus := this.GetString("dialzer_apparatus")
1020
+	//perfusion_apparatus := this.GetString("perfusion_apparatus")
1021
+	//anticoagulant, _ := this.GetInt64("anticoagulant")
1022
+	//kaliumstr := this.GetString("kalium")
1023
+	//kalium, _ := strconv.ParseFloat(kaliumstr, 64)
1024
+	//
1025
+	//autunitestr := this.GetString("autunite")
1026
+	//autunite, _ := strconv.ParseFloat(autunitestr, 64)
1027
+	//natriumstr := this.GetString("natrium")
1028
+	//natrium, _ := strconv.ParseFloat(natriumstr, 64)
1029
+	//hour, _ := this.GetInt64("hour")
1030
+	//minute, _ := this.GetInt64("minute")
1031
+	//beforWeight := this.GetString("befor_weight")
1032
+	//befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
1033
+	//afterWeight := this.GetString("after_weight")
1034
+	//after_weight, _ := strconv.ParseFloat(afterWeight, 64)
1035
+	//befor_pressure := this.GetString("befor_pressure")
1036
+	//template_summary_content := this.GetString("template_summary_content")
1037
+	//template_plan_content := this.GetString("template_plan_content")
1038
+	//admin_user_id, _ := this.GetInt64("admin_user_id")
1039
+	//record_time := this.GetString("record_time")
1040
+	//timeLayout := "2006-01-02"
1041
+	//loc, _ := time.LoadLocation("Local")
1042
+	//recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
1043
+	//after_pressure := this.GetString("after_pressure")
1044
+	//template_summary_id, _ := this.GetInt64("template_summary_id")
1045
+	//template_plan_id, _ := this.GetInt64("template_plan_id")
1046
+	//template_inspection_id, _ := this.GetInt64("template_inspection_id")
1047
+	//patient_id, _ := this.GetInt64("patient_id")
1048
+	//fmt.Println("patient_id", patient_id)
1049
+	//orgId := this.GetAdminUserInfo().CurrentOrgId
1050
+	//inspect_date := this.GetString("inspect_date")
1051
+	//project_id := this.GetString("project_id")
958
 	summary := models.XtTemplateSummary{
1052
 	summary := models.XtTemplateSummary{
959
 		ID:                     id,
1053
 		ID:                     id,
960
 		StartYear:              0,
1054
 		StartYear:              0,
995
 		ProjectId:              project_id,
1089
 		ProjectId:              project_id,
996
 		InspectDate:            inspect_date,
1090
 		InspectDate:            inspect_date,
997
 	}
1091
 	}
998
-	err := service.UpdateTempalteSummary(&summary)
1092
+	err = service.UpdateTempalteSummary(&summary)
999
 	if err == nil {
1093
 	if err == nil {
1000
 		this.ServeSuccessJSON(map[string]interface{}{
1094
 		this.ServeSuccessJSON(map[string]interface{}{
1001
 			"list": summary,
1095
 			"list": summary,

+ 5 - 6
controllers/gobal_config_api_controller.go View File

2010
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2010
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2011
 	list, err := service.GetDrugCountList(startTime, endTime, orgId)
2011
 	list, err := service.GetDrugCountList(startTime, endTime, orgId)
2012
 	countList, err := service.GetMinCountList(startTime, endTime, orgId)
2012
 	countList, err := service.GetMinCountList(startTime, endTime, orgId)
2013
-	//outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2014
-	//auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2013
+	outCountList, _ := service.GetOutDrugCountList(startTime, endTime, orgId)
2014
+	auCountList, err := service.GetAutoDrugCountList(startTime, endTime, orgId)
2015
 	info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
2015
 	info, _ := service.GetDrugWarehouOrderInfo(startTime, endTime, orgId)
2016
 	cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
2016
 	cancelCountList, _ := service.GetCancelDrugCountList(startTime, endTime, orgId)
2017
-	//service.GetAllCountList(startTime,endTime,orgId)
2018
 	if err != nil {
2017
 	if err != nil {
2019
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2018
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2020
 		return
2019
 		return
2021
 	}
2020
 	}
2022
 	c.ServeSuccessJSON(map[string]interface{}{
2021
 	c.ServeSuccessJSON(map[string]interface{}{
2023
-		"countList": list,
2024
-		//"outCountList":    outCountList,
2025
-		//"auCountList":     auCountList,
2022
+		"countList":       list,
2023
+		"outCountList":    outCountList,
2024
+		"auCountList":     auCountList,
2026
 		"minCount":        countList,
2025
 		"minCount":        countList,
2027
 		"info":            info,
2026
 		"info":            info,
2028
 		"cancelCountList": cancelCountList,
2027
 		"cancelCountList": cancelCountList,

+ 12 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

4987
 		return errors.New("退库和出库数据不匹配")
4987
 		return errors.New("退库和出库数据不匹配")
4988
 	}
4988
 	}
4989
 }
4989
 }
4990
+
4991
+func (this *DialysisAPIController) GetMobileScheduleList() {
4992
+
4993
+	limit, _ := this.GetInt64("limit")
4994
+
4995
+	page, _ := this.GetInt64("page")
4996
+
4997
+	type_options_visible, _ := this.GetInt64("type_options_visible")
4998
+	sch_type_options_visible, _ := this.GetInt64("sch_type_options_visible")
4999
+	zone_options_visible, _ := this.GetInt64("zone_options_visible")
5000
+	fmt.Println(limit, page, type_options_visible, sch_type_options_visible, zone_options_visible)
5001
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

163
 
163
 
164
 	beego.Router("/m/api/updatestockgoods", &DialysisAPIController{}, "Get:UpdateStockGoods")
164
 	beego.Router("/m/api/updatestockgoods", &DialysisAPIController{}, "Get:UpdateStockGoods")
165
 
165
 
166
+	beego.Router("/m/api/getmobileschedulelist", &DialysisAPIController{}, "Get:GetMobileScheduleList")
167
+
166
 }
168
 }

+ 6 - 2
controllers/mobile_api_controllers/patient_api_controller.go View File

2692
 	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2692
 	projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
2693
 	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2693
 	if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
2694
 		for _, item := range projects {
2694
 		for _, item := range projects {
2695
-			var advice *models.HisDoctorAdviceInfo
2695
+			var advice models.HisDoctorAdviceInfo
2696
 			advice.ID = item.ID
2696
 			advice.ID = item.ID
2697
 			advice.Checker = item.Checker
2697
 			advice.Checker = item.Checker
2698
 			advice.CheckTime = item.CheckTime
2698
 			advice.CheckTime = item.CheckTime
2708
 				advice.AdviceName = item.HisProject.ProjectName
2708
 				advice.AdviceName = item.HisProject.ProjectName
2709
 			}
2709
 			}
2710
 			advice.StartTime = item.StartTime
2710
 			advice.StartTime = item.StartTime
2711
-			hisAdvice = append(hisAdvice, advice)
2711
+			hisAdvice = append(hisAdvice, &advice)
2712
 		}
2712
 		}
2713
 
2713
 
2714
 	}
2714
 	}
2762
 			"check":                   check,
2762
 			"check":                   check,
2763
 			"dialysiscount":           dialysiscount,
2763
 			"dialysiscount":           dialysiscount,
2764
 			"last_order":              last_order,
2764
 			"last_order":              last_order,
2765
+			"projects":                projects,
2766
+			"project_config":          project_config,
2765
 		})
2767
 		})
2766
 	}
2768
 	}
2767
 
2769
 
2782
 			"check":                   check,
2784
 			"check":                   check,
2783
 			"dialysiscount":           dialysiscount,
2785
 			"dialysiscount":           dialysiscount,
2784
 			"last_order":              last_order,
2786
 			"last_order":              last_order,
2787
+			"projects":                projects,
2788
+			"project_config":          project_config,
2785
 		})
2789
 		})
2786
 	}
2790
 	}
2787
 
2791
 

+ 7 - 3
controllers/schedule_api_controller.go View File

1980
 	week_time, _ := this.GetInt64("week_time")
1980
 	week_time, _ := this.GetInt64("week_time")
1981
 	start_time, _ := this.GetInt64("start_time")
1981
 	start_time, _ := this.GetInt64("start_time")
1982
 	end_time, _ := this.GetInt64("end_time")
1982
 	end_time, _ := this.GetInt64("end_time")
1983
-	zone, _ := this.GetInt64("zone")
1983
+	//zone, _ := this.GetInt64("zone")
1984
+	zons := this.GetString("zone")
1985
+	zone := strings.Split(zons, ",")
1984
 	adminUserInfo := this.GetAdminUserInfo()
1986
 	adminUserInfo := this.GetAdminUserInfo()
1985
 
1987
 
1986
 	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone)
1988
 	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone)
2299
 
2301
 
2300
 	week_type, _ := this.GetInt64("week_type", -1)
2302
 	week_type, _ := this.GetInt64("week_type", -1)
2301
 	week_time, _ := this.GetInt64("week_time")
2303
 	week_time, _ := this.GetInt64("week_time")
2302
-	zone, _ := this.GetInt64("zone")
2304
+	//zone, _ := this.GetInt64("zone")
2305
+	zones := this.GetString("zone")
2306
+	zone := strings.Split(zones, ",")
2303
 	thisTime := time.Now()
2307
 	thisTime := time.Now()
2304
 	weekDay := int(thisTime.Weekday())
2308
 	weekDay := int(thisTime.Weekday())
2305
 	if weekDay == 0 {
2309
 	if weekDay == 0 {
2363
 
2367
 
2364
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2368
 	orgId := this.GetAdminUserInfo().CurrentOrgId
2365
 	if week_type > 0 {
2369
 	if week_type > 0 {
2366
-		list, err := service.GetWeekDayScheduleById(orgId, targetDay.Unix(), week_time, zone)
2370
+		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
2367
 		if err != nil {
2371
 		if err != nil {
2368
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2372
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2369
 			return
2373
 			return

+ 294 - 56
controllers/self_drug_api_congtroller.go View File

78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
81
+	beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
81
 }
82
 }
82
 
83
 
83
 func (this *SelfDrugApiController) GetCurrentPatient() {
84
 func (this *SelfDrugApiController) GetCurrentPatient() {
959
 }
960
 }
960
 
961
 
961
 func (this *SelfDrugApiController) SaveDrugPrice() {
962
 func (this *SelfDrugApiController) SaveDrugPrice() {
962
-	fmt.Println("999999999999999999999")
963
+
963
 	timeLayout := "2006-01-02"
964
 	timeLayout := "2006-01-02"
964
 	loc, _ := time.LoadLocation("Local")
965
 	loc, _ := time.LoadLocation("Local")
965
 	dataBody := make(map[string]interface{}, 0)
966
 	dataBody := make(map[string]interface{}, 0)
1020
 			}
1021
 			}
1021
 			manufacturer := items["manufacturer"].(string)
1022
 			manufacturer := items["manufacturer"].(string)
1022
 
1023
 
1023
-			//if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
1024
-			//  utils.ErrorLog("specification_name")
1025
-			//  this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1026
-			//  return
1027
-			//}
1028
-			//specification_name := items["specification_name"].(string)
1024
+			if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
1025
+				utils.ErrorLog("specification_name")
1026
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1027
+				return
1028
+			}
1029
+			specification_name := items["specification_name"].(string)
1029
 
1030
 
1030
 			if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
1031
 			if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
1031
 				utils.ErrorLog("remark")
1032
 				utils.ErrorLog("remark")
1048
 			}
1049
 			}
1049
 			last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1050
 			last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
1050
 
1051
 
1051
-			if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
1052
-				utils.ErrorLog("count")
1053
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1054
-				return
1055
-			}
1056
-			count := int64(items["count"].(float64))
1057
-
1058
 			if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
1052
 			if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
1059
 				utils.ErrorLog("new_price")
1053
 				utils.ErrorLog("new_price")
1060
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1054
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1090
 
1084
 
1091
 			drugAdjust := models.XtDrugAdjustPrice{
1085
 			drugAdjust := models.XtDrugAdjustPrice{
1092
 				DrugName:          drug_name,
1086
 				DrugName:          drug_name,
1093
-				SpecificationName: "",
1087
+				SpecificationName: specification_name,
1094
 				WarehousingUnit:   warehousing_unit,
1088
 				WarehousingUnit:   warehousing_unit,
1095
-				Count:             count,
1096
 				LastPrice:         last_price,
1089
 				LastPrice:         last_price,
1097
 				RetailPrice:       retail_price,
1090
 				RetailPrice:       retail_price,
1098
 				NewPrice:          new_price,
1091
 				NewPrice:          new_price,
1200
 	list, _ := service.GetDrugAdjuestPrice(ids)
1193
 	list, _ := service.GetDrugAdjuestPrice(ids)
1201
 	for _, item := range list {
1194
 	for _, item := range list {
1202
 		drug := models.BaseDrugLib{
1195
 		drug := models.BaseDrugLib{
1203
-			RetailPrice: item.RetailPrice,
1196
+			RetailPrice: item.NewPrice,
1197
+			LastPrice:   item.NewPrice,
1204
 		}
1198
 		}
1205
 		service.UpdateBaseDrugOne(drug, item.DrugId)
1199
 		service.UpdateBaseDrugOne(drug, item.DrugId)
1206
 	}
1200
 	}
1222
 		for _, item := range tableData {
1216
 		for _, item := range tableData {
1223
 			items := item.(map[string]interface{})
1217
 			items := item.(map[string]interface{})
1224
 			drug_name := items["drug_name"].(string)
1218
 			drug_name := items["drug_name"].(string)
1225
-			fmt.Println("durg_nae232333223332232323323223232323", drug_name)
1226
 			if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
1219
 			if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
1227
 				utils.ErrorLog("drug_name")
1220
 				utils.ErrorLog("drug_name")
1228
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1221
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1361
 			orgId := this.GetAdminUserInfo().CurrentOrgId
1354
 			orgId := this.GetAdminUserInfo().CurrentOrgId
1362
 			Creater := this.GetAdminUserInfo().AdminUser.Id
1355
 			Creater := this.GetAdminUserInfo().AdminUser.Id
1363
 
1356
 
1357
+			if items["stock_max_number"] == nil || reflect.TypeOf(items["stock_max_number"]).String() != "float64" {
1358
+				utils.ErrorLog("stock_max_number")
1359
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1360
+				return
1361
+			}
1362
+			stock_max_number := int64(items["stock_max_number"].(float64))
1363
+
1364
+			if items["stock_min_number"] == nil || reflect.TypeOf(items["stock_min_number"]).String() != "float64" {
1365
+				utils.ErrorLog("stock_min_number")
1366
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1367
+				return
1368
+			}
1369
+			stock_min_number := int64(items["stock_min_number"].(float64))
1370
+
1371
+			if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
1372
+				utils.ErrorLog("total")
1373
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1374
+				return
1375
+			}
1376
+			total := items["total"].(string)
1364
 			drugDamage := models.XtDrugDamage{
1377
 			drugDamage := models.XtDrugDamage{
1365
 				DrugName:          drug_name,
1378
 				DrugName:          drug_name,
1366
 				SpecificationName: specification_name,
1379
 				SpecificationName: specification_name,
1388
 				ProductDate:       product_date,
1401
 				ProductDate:       product_date,
1389
 				WarehousingInfoId: warehousing_info_id,
1402
 				WarehousingInfoId: warehousing_info_id,
1390
 				DrugOriginPlace:   drug_origin_place,
1403
 				DrugOriginPlace:   drug_origin_place,
1404
+				StockMaxNumber:    stock_max_number,
1405
+				StockMinNumber:    stock_min_number,
1406
+				Total:             total,
1391
 			}
1407
 			}
1392
 
1408
 
1393
 			err := service.CreateDrugDamage(drugDamage)
1409
 			err := service.CreateDrugDamage(drugDamage)
1408
 	fmt.Println(err)
1424
 	fmt.Println(err)
1409
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1425
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1410
 	keyword := this.GetString("keyword")
1426
 	keyword := this.GetString("keyword")
1411
-	fmt.Println("keywoer2r2r32rwrwr", keyword)
1427
+
1412
 	start_time := this.GetString("start_time")
1428
 	start_time := this.GetString("start_time")
1413
 	end_time := this.GetString("end_time")
1429
 	end_time := this.GetString("end_time")
1414
 	var startTime int64
1430
 	var startTime int64
1482
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
1498
 	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
1483
 	var manufacturer_id int64
1499
 	var manufacturer_id int64
1484
 	var dealer_id int64
1500
 	var dealer_id int64
1501
+	timeStr := time.Now().Format("2006-01-02")
1502
+	timeArr := strings.Split(timeStr, "-")
1503
+	total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1504
+
1505
+	total = total + 1
1506
+	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1507
+	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1508
+	number = number + total
1509
+	warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1510
+	operation_time := time.Now().Unix()
1511
+	creater := adminUserInfo.AdminUser.Id
1512
+
1513
+	warehouseOut := models.DrugWarehouseOut{
1514
+		WarehouseOutOrderNumber: warehousing_out_order,
1515
+		OperationTime:           operation_time,
1516
+		OrgId:                   adminUserInfo.CurrentOrgId,
1517
+		Creater:                 creater,
1518
+		Ctime:                   ctime,
1519
+		Status:                  1,
1520
+		WarehouseOutTime:        time.Now().Unix(),
1521
+		Type:                    1,
1522
+	}
1523
+	service.AddSigleDrugWarehouseOut(&warehouseOut)
1485
 	for _, item := range list {
1524
 	for _, item := range list {
1486
 		for _, it := range manufacturerList {
1525
 		for _, it := range manufacturerList {
1487
 			if item.Manufacturer == it.ManufacturerName {
1526
 			if item.Manufacturer == it.ManufacturerName {
1495
 			}
1534
 			}
1496
 		}
1535
 		}
1497
 
1536
 
1498
-		timeStr := time.Now().Format("2006-01-02")
1499
-		timeArr := strings.Split(timeStr, "-")
1500
-		total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1501
-
1502
-		total = total + 1
1503
-		warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1504
-		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1505
-		number = number + total
1506
-		warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1507
-		operation_time := time.Now().Unix()
1508
-		creater := adminUserInfo.AdminUser.Id
1509
-
1510
-		warehouseOut := models.DrugWarehouseOut{
1511
-			WarehouseOutOrderNumber: warehousing_out_order,
1512
-			OperationTime:           operation_time,
1513
-			OrgId:                   adminUserInfo.CurrentOrgId,
1514
-			Creater:                 creater,
1515
-			Ctime:                   ctime,
1516
-			Status:                  1,
1517
-			WarehouseOutTime:        time.Now().Unix(),
1518
-			Type:                    1,
1519
-		}
1520
-
1521
 		warehouseOutInfo := models.XtDrugWarehouseOutInfo{
1537
 		warehouseOutInfo := models.XtDrugWarehouseOutInfo{
1522
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1538
 			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1523
 			WarehouseOutId:          warehouseOut.ID,
1539
 			WarehouseOutId:          warehouseOut.ID,
1563
 			IsSys:                   0,
1579
 			IsSys:                   0,
1564
 		}
1580
 		}
1565
 		service.CreateWareHouseOutInfo(&warehouseOutInfo)
1581
 		service.CreateWareHouseOutInfo(&warehouseOutInfo)
1566
-		service.AddSigleDrugWarehouseOut(&warehouseOut)
1567
 		service.CreateDrugFlowOne(drugflow)
1582
 		service.CreateDrugFlowOne(drugflow)
1568
 
1583
 
1584
+		info, _ := service.GetDrugByWarehouseInfo(item.WarehousingInfoId)
1585
+		//扣减库存
1586
+		warehouseInfo := models.XtDrugWarehouseInfo{
1587
+			StockMaxNumber: info.StockMaxNumber - info.StockMaxNumber,
1588
+		}
1589
+		service.UpdateDrugWarehouseingInfo(item.WarehousingInfoId, warehouseInfo)
1569
 	}
1590
 	}
1570
 	this.ServeSuccessJSON(map[string]interface{}{
1591
 	this.ServeSuccessJSON(map[string]interface{}{
1571
 		"damage": damage,
1592
 		"damage": damage,
1585
 func (this *SelfDrugApiController) ModifyDrugPrice() {
1606
 func (this *SelfDrugApiController) ModifyDrugPrice() {
1586
 
1607
 
1587
 	drug_name := this.GetString("drug_name")
1608
 	drug_name := this.GetString("drug_name")
1609
+	specification_name := this.GetString("specification_name")
1610
+	warehousing_unit := this.GetString("warehousing_unit")
1611
+	manufacturer := this.GetString("manufacturer")
1612
+	number := this.GetString("number")
1588
 	retailPrice := this.GetString("retail_price")
1613
 	retailPrice := this.GetString("retail_price")
1589
 	retail_price, _ := strconv.ParseFloat(retailPrice, 64)
1614
 	retail_price, _ := strconv.ParseFloat(retailPrice, 64)
1590
 	newPrice := this.GetString("new_price")
1615
 	newPrice := this.GetString("new_price")
1592
 	count, _ := this.GetInt64("count")
1617
 	count, _ := this.GetInt64("count")
1593
 	remark := this.GetString("remark")
1618
 	remark := this.GetString("remark")
1594
 	id, _ := this.GetInt64("id")
1619
 	id, _ := this.GetInt64("id")
1620
+	drug_id, _ := this.GetInt64("drug_id")
1595
 	adjustPrice := models.XtDrugAdjustPrice{
1621
 	adjustPrice := models.XtDrugAdjustPrice{
1596
-		DrugName:    drug_name,
1597
-		Count:       count,
1598
-		RetailPrice: retail_price,
1599
-		NewPrice:    new_price,
1600
-		Remark:      remark,
1622
+		DrugName:          drug_name,
1623
+		Count:             count,
1624
+		RetailPrice:       retail_price,
1625
+		NewPrice:          new_price,
1626
+		Remark:            remark,
1627
+		SpecificationName: specification_name,
1628
+		WarehousingUnit:   warehousing_unit,
1629
+		Manufacturer:      manufacturer,
1630
+		Number:            number,
1631
+		DrugId:            drug_id,
1601
 	}
1632
 	}
1602
 	err := service.ModifyDrugPrice(id, adjustPrice)
1633
 	err := service.ModifyDrugPrice(id, adjustPrice)
1603
 	fmt.Println(err)
1634
 	fmt.Println(err)
1631
 	id, _ := this.GetInt64("id")
1662
 	id, _ := this.GetInt64("id")
1632
 	drug_id, _ := this.GetInt64("drug_id")
1663
 	drug_id, _ := this.GetInt64("drug_id")
1633
 	drug_name := this.GetString("drug_name")
1664
 	drug_name := this.GetString("drug_name")
1634
-	//drug_origin_place := this.GetString("drug_origin_place")
1665
+	drug_origin_place := this.GetString("drug_origin_place")
1635
 	lastPrice := this.GetString("last_price")
1666
 	lastPrice := this.GetString("last_price")
1636
 	last_price, _ := strconv.ParseFloat(lastPrice, 64)
1667
 	last_price, _ := strconv.ParseFloat(lastPrice, 64)
1637
 	newPrice := this.GetString("new_price")
1668
 	newPrice := this.GetString("new_price")
1643
 	remark := this.GetString("remark")
1674
 	remark := this.GetString("remark")
1644
 	count, _ := this.GetInt64("count")
1675
 	count, _ := this.GetInt64("count")
1645
 	warehousing_unit := this.GetString("warehousing_unit")
1676
 	warehousing_unit := this.GetString("warehousing_unit")
1646
-
1677
+	stock_max_number, _ := this.GetInt64("stock_max_number")
1678
+	stock_min_number, _ := this.GetInt64("stock_min_number")
1679
+	warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
1647
 	damage := models.XtDrugDamage{
1680
 	damage := models.XtDrugDamage{
1648
 		DrugName:          drug_name,
1681
 		DrugName:          drug_name,
1649
 		SpecificationName: "",
1682
 		SpecificationName: "",
1657
 		Remark:            remark,
1690
 		Remark:            remark,
1658
 		DrugId:            drug_id,
1691
 		DrugId:            drug_id,
1659
 		Number:            number,
1692
 		Number:            number,
1693
+		StockMaxNumber:    stock_max_number,
1694
+		StockMinNumber:    stock_min_number,
1695
+		WarehousingInfoId: warehousing_info_id,
1696
+		DrugOriginPlace:   drug_origin_place,
1660
 	}
1697
 	}
1661
 	err := service.ModifyDrugDamage(id, damage)
1698
 	err := service.ModifyDrugDamage(id, damage)
1662
 	fmt.Println(err)
1699
 	fmt.Println(err)
1969
 	}
2006
 	}
1970
 	err = service.UpdateDrugInventory(ids, inventory)
2007
 	err = service.UpdateDrugInventory(ids, inventory)
1971
 	fmt.Println(err)
2008
 	fmt.Println(err)
2009
+
2010
+	list, _ := service.GetDrugInventoryListByIds(ids)
2011
+
2012
+	adminUserInfo := this.GetAdminUserInfo()
2013
+	var stock_total int64
2014
+	var proof_count int64
2015
+	var maxNumber int64
2016
+	var minNumber int64
2017
+	for _, item := range list {
2018
+
2019
+		//查询库存信息
2020
+		drug, _ := service.GetDrugDetailByDrugId(item.DrugId)
2021
+
2022
+		//查询库存
2023
+		info, _ := service.GetDrugWareInfoById(item.WarehouseInfoId)
2024
+
2025
+		//获取最晚的库存数量
2026
+		lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
2027
+		firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
2028
+		stock_total = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
2029
+		proof_count = item.StockMaxNumber*drug.MinNumber + item.StockMinNumber
2030
+
2031
+		//判断 如果库存数量 大于盘点库存,则出库
2032
+		if stock_total > proof_count {
2033
+			minNumber = (stock_total - proof_count) % drug.MinNumber
2034
+			maxNumber = (stock_total - proof_count) / drug.MinNumber
2035
+
2036
+			ctime := time.Now().Unix()
2037
+
2038
+			timeStr := time.Now().Format("2006-01-02")
2039
+			timeArr := strings.Split(timeStr, "-")
2040
+			total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
2041
+
2042
+			total = total + 1
2043
+			warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2044
+			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2045
+			number = number + total
2046
+			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
2047
+			operation_time := time.Now().Unix()
2048
+			creater := adminUserInfo.AdminUser.Id
2049
+
2050
+			warehouseOut := models.DrugWarehouseOut{
2051
+				WarehouseOutOrderNumber: warehousing_out_order,
2052
+				OperationTime:           operation_time,
2053
+				OrgId:                   adminUserInfo.CurrentOrgId,
2054
+				Creater:                 creater,
2055
+				Ctime:                   ctime,
2056
+				Status:                  1,
2057
+				WarehouseOutTime:        ctime,
2058
+				Type:                    1,
2059
+			}
2060
+
2061
+			warehouseOutInfo := models.DrugWarehouseOutInfo{
2062
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
2063
+				WarehouseOutId:          warehouseOut.ID,
2064
+				DrugId:                  firstInfo.DrugId,
2065
+				Count:                   maxNumber,
2066
+				Price:                   firstInfo.Price,
2067
+				TotalPrice:              firstInfo.TotalPrice,
2068
+				Status:                  1,
2069
+				Ctime:                   ctime,
2070
+				Remark:                  item.Remark,
2071
+				OrgId:                   adminUserInfo.CurrentOrgId,
2072
+				Type:                    1,
2073
+				Manufacturer:            firstInfo.Manufacturer,
2074
+				Dealer:                  firstInfo.Dealer,
2075
+				RetailPrice:             firstInfo.RetailPrice,
2076
+				RetailTotalPrice:        firstInfo.RetailTotalPrice,
2077
+				CountUnit:               drug.MaxUnit,
2078
+				ExpiryDate:              firstInfo.ExpiryDate,
2079
+				ProductDate:             firstInfo.ProductDate,
2080
+				Number:                  firstInfo.Number,
2081
+				BatchNumber:             firstInfo.BatchNumber,
2082
+				IsSys:                   0,
2083
+				WarehouseInfoId:         firstInfo.ID,
2084
+			}
2085
+
2086
+			drugflow := models.DrugFlow{
2087
+				WarehouseOutId:          warehouseOut.ID,
2088
+				WarehouseOutOrderNumber: warehousing_out_order,
2089
+				DrugId:                  firstInfo.DrugId,
2090
+				Number:                  firstInfo.Number,
2091
+				ProductDate:             firstInfo.ProductDate,
2092
+				ExpireDate:              firstInfo.ExpiryDate,
2093
+				Count:                   maxNumber,
2094
+				Price:                   firstInfo.Price,
2095
+				Status:                  1,
2096
+				Ctime:                   ctime,
2097
+				UserOrgId:               adminUserInfo.CurrentOrgId,
2098
+				Manufacturer:            firstInfo.Manufacturer,
2099
+				Dealer:                  firstInfo.Dealer,
2100
+				BatchNumber:             firstInfo.BatchNumber,
2101
+				MaxUnit:                 drug.MaxUnit,
2102
+				ConsumableType:          2,
2103
+				IsEdit:                  1,
2104
+				Creator:                 adminUserInfo.AdminUser.Id,
2105
+				IsSys:                   0,
2106
+			}
2107
+
2108
+			service.AddSigleDrugWarehouseOut(&warehouseOut)
2109
+			service.CreateDrugWarehouseOutInfo(warehouseOutInfo)
2110
+			service.CreateDrugFlowOne(drugflow)
2111
+
2112
+		}
2113
+
2114
+		//判断 如果库存数量 小于于盘点库存,则入库
2115
+		if stock_total < proof_count {
2116
+
2117
+			maxNumber = (proof_count - stock_total) / drug.MinNumber
2118
+			minNumber = (proof_count - stock_total) % drug.MinNumber
2119
+			ctime := time.Now().Unix()
2120
+
2121
+			timeStr := time.Now().Format("2006-01-02")
2122
+			timeArr := strings.Split(timeStr, "-")
2123
+			total, _ := service.FindAllWarehouseTotalOne(adminUserInfo.CurrentOrgId)
2124
+			total = total + 1
2125
+			fmt.Println("total2323232323232", total)
2126
+			warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2127
+
2128
+			operation_time := time.Now().Unix()
2129
+			creater := adminUserInfo.AdminUser.Id
2130
+			warehousing := models.DrugWarehouse{
2131
+				WarehousingOrder: warehousing_order,
2132
+				OperationTime:    operation_time,
2133
+				OrgId:            adminUserInfo.CurrentOrgId,
2134
+				Creater:          creater,
2135
+				Ctime:            ctime,
2136
+				Status:           1,
2137
+				WarehousingTime:  ctime,
2138
+				Type:             1,
2139
+			}
2140
+
2141
+			warehouseInfo := models.DrugWarehouseInfo{
2142
+				WarehousingOrder: warehousing.WarehousingOrder,
2143
+				WarehousingId:    warehousing.ID,
2144
+				DrugId:           lastInfo.DrugId,
2145
+				Number:           lastInfo.Number,
2146
+				ProductDate:      lastInfo.ProductDate,
2147
+				ExpiryDate:       lastInfo.ExpiryDate,
2148
+				WarehousingCount: lastInfo.WarehousingCount,
2149
+				Price:            lastInfo.Price,
2150
+				TotalPrice:       lastInfo.TotalPrice,
2151
+				Status:           1,
2152
+				Ctime:            ctime,
2153
+				Remark:           item.Remark,
2154
+				OrgId:            adminUserInfo.CurrentOrgId,
2155
+				Type:             1,
2156
+				Manufacturer:     lastInfo.Manufacturer,
2157
+				Dealer:           lastInfo.Dealer,
2158
+				StockMaxNumber:   maxNumber,
2159
+				StockMinNumber:   minNumber,
2160
+				RetailTotalPrice: lastInfo.RetailTotalPrice,
2161
+				BatchNumber:      lastInfo.BatchNumber,
2162
+				MaxUnit:          drug.MaxUnit,
2163
+				MinUnit:          drug.MinUnit,
2164
+			}
2165
+
2166
+			drugflow := models.DrugFlow{
2167
+				WarehousingOrder: warehousing.WarehousingOrder,
2168
+				WarehousingId:    warehousing.ID,
2169
+				DrugId:           lastInfo.DrugId,
2170
+				Number:           lastInfo.Number,
2171
+				ProductDate:      lastInfo.ProductDate,
2172
+				ExpireDate:       lastInfo.ExpiryDate,
2173
+				Count:            maxNumber,
2174
+				Price:            lastInfo.Price,
2175
+				Status:           1,
2176
+				Ctime:            ctime,
2177
+				UserOrgId:        adminUserInfo.CurrentOrgId,
2178
+				Manufacturer:     lastInfo.Manufacturer,
2179
+				Dealer:           lastInfo.Dealer,
2180
+				BatchNumber:      lastInfo.BatchNumber,
2181
+				MaxUnit:          drug.MaxUnit,
2182
+				MinUnit:          drug.MinUnit,
2183
+				ConsumableType:   1,
2184
+				IsEdit:           1,
2185
+				Creator:          adminUserInfo.AdminUser.Id,
2186
+				IsSys:            0,
2187
+			}
2188
+			service.AddSigleDrugWarehouse(&warehousing)
2189
+			service.CreateDrugWarehouseInfo(warehouseInfo)
2190
+			service.CreateDrugFlowOne(drugflow)
2191
+		}
2192
+	}
1972
 	returnData := make(map[string]interface{}, 0)
2193
 	returnData := make(map[string]interface{}, 0)
1973
 	returnData["msg"] = "ok"
2194
 	returnData["msg"] = "ok"
1974
 	this.ServeSuccessJSON(returnData)
2195
 	this.ServeSuccessJSON(returnData)
2006
 	last_price, _ := strconv.ParseFloat(lastPrice, 64)
2227
 	last_price, _ := strconv.ParseFloat(lastPrice, 64)
2007
 	count, _ := this.GetInt64("count")
2228
 	count, _ := this.GetInt64("count")
2008
 	drug_origin_place := this.GetString("drug_origin_place")
2229
 	drug_origin_place := this.GetString("drug_origin_place")
2230
+
2231
+	stock_max_number, _ := this.GetInt64("stock_max_number")
2232
+	stock_min_number, _ := this.GetInt64("stock_min_number")
2233
+	warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
2009
 	inventory := models.XtDrugInventory{
2234
 	inventory := models.XtDrugInventory{
2010
 		DrugName:          drug_name,
2235
 		DrugName:          drug_name,
2011
 		SpecificationName: specification_name,
2236
 		SpecificationName: specification_name,
2020
 		Number:            number,
2245
 		Number:            number,
2021
 		Total:             total,
2246
 		Total:             total,
2022
 		DrugOriginPlace:   drug_origin_place,
2247
 		DrugOriginPlace:   drug_origin_place,
2248
+		StockMaxNumber:    stock_max_number,
2249
+		StockMinNumber:    stock_min_number,
2250
+		WarehouseInfoId:   warehouse_info_id,
2023
 	}
2251
 	}
2024
 	err := service.ModifyDrugInventory(id, inventory)
2252
 	err := service.ModifyDrugInventory(id, inventory)
2025
 	if err != nil {
2253
 	if err != nil {
2086
 	warehousing_unit := this.GetString("warehousing_unit")
2314
 	warehousing_unit := this.GetString("warehousing_unit")
2087
 	remark := this.GetString("remark")
2315
 	remark := this.GetString("remark")
2088
 	//total := this.GetString("total")
2316
 	//total := this.GetString("total")
2089
-	prof_count, _ := this.GetInt64("prof_count")
2090
-
2317
+	proof_count, _ := this.GetInt64("proof_count")
2318
+	fmt.Println("pof_count2222222", proof_count)
2091
 	inventory := models.XtDrugInventory{
2319
 	inventory := models.XtDrugInventory{
2092
 		WarehouseInfoId: warehouse_info_id,
2320
 		WarehouseInfoId: warehouse_info_id,
2093
-		ProofCount:      prof_count,
2321
+		ProofCount:      proof_count,
2094
 		WarehousingUnit: warehousing_unit,
2322
 		WarehousingUnit: warehousing_unit,
2095
 		Remark:          remark,
2323
 		Remark:          remark,
2096
 	}
2324
 	}
2097
-	err := service.UpdateDrugProofInventory(warehouse_info_id, &inventory)
2325
+	err := service.UpdateDrugProofInventory(id, &inventory)
2098
 	info := models.XtDrugWarehouseInfo{
2326
 	info := models.XtDrugWarehouseInfo{
2099
-		StockMaxNumber: prof_count,
2327
+		StockMaxNumber: proof_count,
2100
 	}
2328
 	}
2101
-	service.UpdateDrugWarehouseInfoById(id, &info)
2329
+	service.UpdateDrugWarehouseInfoById(warehouse_info_id, &info)
2102
 	if err != nil {
2330
 	if err != nil {
2103
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2331
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2104
 		return
2332
 		return
2108
 		"inventory": inventory,
2336
 		"inventory": inventory,
2109
 	})
2337
 	})
2110
 }
2338
 }
2339
+
2340
+func (this *StockManagerApiController) GetDrugWarehouseInfoTotal() {
2341
+
2342
+	id, _ := this.GetInt64("id")
2343
+	list, _ := service.GetDrugWarehouseInfoTotal(id)
2344
+
2345
+	this.ServeSuccessJSON(map[string]interface{}{
2346
+		"list": list,
2347
+	})
2348
+}

+ 289 - 5
controllers/stock_in_api_controller.go View File

127
 	beego.Router("/api/drug/deletedrugprice", &StockManagerApiController{}, "Get:DeleteDrugPrice")
127
 	beego.Router("/api/drug/deletedrugprice", &StockManagerApiController{}, "Get:DeleteDrugPrice")
128
 	beego.Router("/api/stock/getgoodwarehouselist", &StockManagerApiController{}, "Get:GetGoodWarehouseList")
128
 	beego.Router("/api/stock/getgoodwarehouselist", &StockManagerApiController{}, "Get:GetGoodWarehouseList")
129
 	beego.Router("/api/stock/proofinventory", &StockManagerApiController{}, "Get:ProofInventory")
129
 	beego.Router("/api/stock/proofinventory", &StockManagerApiController{}, "Get:ProofInventory")
130
+	beego.Router("/api/stock/getwarehousetotal", &StockManagerApiController{}, "Get:GetWarehouseTotal")
130
 
131
 
131
 }
132
 }
132
 
133
 
1993
 		}
1994
 		}
1994
 
1995
 
1995
 		//查询该批次入库的值
1996
 		//查询该批次入库的值
1996
-		infolist, _ := service.GetWarehouseInfoById(item.WarehouseInfoId)
1997
+		infolist, _ := service.GetWarehouseInfoByIdSeven(item.WarehouseInfoId)
1997
 
1998
 
1998
 		if item.Count > infolist.WarehousingCount {
1999
 		if item.Count > infolist.WarehousingCount {
1999
 			c.ServeSuccessJSON(map[string]interface{}{
2000
 			c.ServeSuccessJSON(map[string]interface{}{
4972
 	fmt.Println(err)
4973
 	fmt.Println(err)
4973
 
4974
 
4974
 	list, _ := service.GetAdjustCheckPriceList(ids)
4975
 	list, _ := service.GetAdjustCheckPriceList(ids)
4976
+	fmt.Println("list2333223323232323232323", list)
4975
 	for _, item := range list {
4977
 	for _, item := range list {
4976
 		info := models.GoodInfo{
4978
 		info := models.GoodInfo{
4977
 			PackingPrice: item.NewPrice,
4979
 			PackingPrice: item.NewPrice,
4980
+			BuyPrice:     item.NewPrice,
4978
 		}
4981
 		}
4979
 		err = service.UpdateAdjustCheckPrice(&info, item.GoodId)
4982
 		err = service.UpdateAdjustCheckPrice(&info, item.GoodId)
4980
 		fmt.Println(err)
4983
 		fmt.Println(err)
5147
 			product_date := int64(items["product_date"].(float64))
5150
 			product_date := int64(items["product_date"].(float64))
5148
 			orgId := this.GetAdminUserInfo().CurrentOrgId
5151
 			orgId := this.GetAdminUserInfo().CurrentOrgId
5149
 			Creater := this.GetAdminUserInfo().AdminUser.Id
5152
 			Creater := this.GetAdminUserInfo().AdminUser.Id
5153
+
5154
+			if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "float64" {
5155
+				utils.ErrorLog("total")
5156
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5157
+				return
5158
+			}
5159
+			total := int64(items["total"].(float64))
5160
+
5161
+			if items["good_origin_place"] == nil || reflect.TypeOf(items["good_origin_place"]).String() != "string" {
5162
+				utils.ErrorLog("good_origin_place")
5163
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5164
+				return
5165
+			}
5166
+			good_origin_place := items["good_origin_place"].(string)
5150
 			reportPrice := models.XtStockReportPrice{
5167
 			reportPrice := models.XtStockReportPrice{
5151
 				GoodName:          good_name,
5168
 				GoodName:          good_name,
5152
 				SpecificationName: specification_name,
5169
 				SpecificationName: specification_name,
5173
 				WarehousingInfoId: warehousing_info_id,
5190
 				WarehousingInfoId: warehousing_info_id,
5174
 				ExpiryDate:        expiry_date,
5191
 				ExpiryDate:        expiry_date,
5175
 				ProductDate:       product_date,
5192
 				ProductDate:       product_date,
5193
+				Total:             total,
5194
+				GoodOriginPlace:   good_origin_place,
5176
 			}
5195
 			}
5177
 			err := service.CreateReportPrice(&reportPrice)
5196
 			err := service.CreateReportPrice(&reportPrice)
5178
 			fmt.Println(err)
5197
 			fmt.Println(err)
5277
 		Ctime:                   ctime,
5296
 		Ctime:                   ctime,
5278
 		Status:                  1,
5297
 		Status:                  1,
5279
 		WarehouseOutTime:        ctime,
5298
 		WarehouseOutTime:        ctime,
5280
-		Type:                    2,
5299
+		Type:                    1,
5281
 	}
5300
 	}
5282
 
5301
 
5283
 	_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
5302
 	_, errcodes := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
5526
 				return
5545
 				return
5527
 			}
5546
 			}
5528
 			warehousing_info_id := int64(items["warehousing_info_id"].(float64))
5547
 			warehousing_info_id := int64(items["warehousing_info_id"].(float64))
5548
+
5549
+			if items["good_origin_place"] == nil || reflect.TypeOf(items["good_origin_place"]).String() != "string" {
5550
+				utils.ErrorLog("good_origin_place")
5551
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5552
+				return
5553
+			}
5554
+			good_origin_place := items["good_origin_place"].(string)
5529
 			orgId := this.GetAdminUserInfo().CurrentOrgId
5555
 			orgId := this.GetAdminUserInfo().CurrentOrgId
5530
 			Creater := this.GetAdminUserInfo().AdminUser.Id
5556
 			Creater := this.GetAdminUserInfo().AdminUser.Id
5531
 
5557
 
5557
 				ProductDate:       product_date,
5583
 				ProductDate:       product_date,
5558
 				Number:            number,
5584
 				Number:            number,
5559
 				WarehousingInfoId: warehousing_info_id,
5585
 				WarehousingInfoId: warehousing_info_id,
5586
+				GoodOriginPlace:   good_origin_place,
5560
 			}
5587
 			}
5561
 			err = service.CreateInentory(inventory)
5588
 			err = service.CreateInentory(inventory)
5562
 			fmt.Println(err)
5589
 			fmt.Println(err)
5635
 		CheckerStatus: 1,
5662
 		CheckerStatus: 1,
5636
 		CheckerTime:   checkTime,
5663
 		CheckerTime:   checkTime,
5637
 	}
5664
 	}
5665
+	adminUserInfo := this.GetAdminUserInfo()
5638
 	err = service.UpdateCheckInventory(ids, inventory)
5666
 	err = service.UpdateCheckInventory(ids, inventory)
5667
+	manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
5668
+	dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
5669
+	var manufactuer_id int64
5670
+	var dealer_id int64
5671
+	//查询耗材信息
5672
+	list, _ := service.GetInventoryDetailById(ids)
5673
+	for _, item := range list {
5674
+		for _, it := range manufacturerList {
5675
+			if item.Manufacturer == it.ManufacturerName {
5676
+				manufactuer_id = it.ID
5677
+			}
5678
+		}
5679
+
5680
+		for _, its := range dealerList {
5681
+			if item.Dealer == its.DealerName {
5682
+				dealer_id = its.ID
5683
+			}
5684
+		}
5685
+		//查寻该批次的库存量
5686
+		list, _ := service.GetWarehouseInfoById(item.WarehousingInfoId)
5687
+
5688
+		//查询该耗材最后1条批次
5689
+		info, _ := service.GetLastWarehouseInfo(item.GoodId)
5690
+		fmt.Println("总共", item.Count)
5691
+		fmt.Println("数据", list.StockCount)
5692
+		//盘点盘点库存和et实际库存的大小
5693
+		// 如果盘点库存大于实际库存,怎需要入库
5694
+		if item.Count > list.StockCount {
5695
+
5696
+			ctime := time.Now().Unix()
5697
+
5698
+			timeStr := time.Now().Format("2006-01-02")
5699
+			timeArr := strings.Split(timeStr, "-")
5700
+			total, _ := service.FindAllWarehouseTotal(adminUserInfo.CurrentOrgId)
5701
+			total = total + 1
5702
+			warehousing_order := "RKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
5703
+			operation_time := time.Now().Unix()
5704
+			creater := adminUserInfo.AdminUser.Id
5705
+			warehousing := models.Warehousing{
5706
+				WarehousingOrder: warehousing_order,
5707
+				OperationTime:    operation_time,
5708
+				OrgId:            adminUserInfo.CurrentOrgId,
5709
+				Creater:          creater,
5710
+				Ctime:            ctime,
5711
+				Status:           1,
5712
+				WarehousingTime:  ctime,
5713
+				Type:             1,
5714
+			}
5715
+			service.AddSigleWarehouse(&warehousing)
5716
+
5717
+			//获取最
5718
+			//入库单表格
5719
+			warehouseInfo := models.WarehousingInfo{
5720
+				WarehousingOrder: warehousing.WarehousingOrder,
5721
+				WarehousingId:    warehousing.ID,
5722
+				GoodId:           item.GoodId,
5723
+				Number:           info.Number,
5724
+				ProductDate:      info.ProductDate,
5725
+				ExpiryDate:       info.ExpiryDate,
5726
+				WarehousingCount: item.Count - list.StockCount,
5727
+				Price:            info.Price,
5728
+				Status:           1,
5729
+				Ctime:            ctime,
5730
+				Remark:           item.Remark,
5731
+				OrgId:            adminUserInfo.CurrentOrgId,
5732
+				Type:             1,
5733
+				Manufacturer:     manufactuer_id,
5734
+				StockCount:       item.Count - list.StockCount,
5735
+				Dealer:           dealer_id,
5736
+				LicenseNumber:    info.LicenseNumber,
5737
+			}
5738
+
5739
+			flow := models.VmStockFlow{
5740
+				WarehousingOrder:    warehousing.WarehousingOrder,
5741
+				WarehousingId:       warehousing.ID,
5742
+				GoodId:              item.GoodId,
5743
+				Number:              info.Number,
5744
+				ProductDate:         info.ProductDate,
5745
+				ExpireDate:          info.ExpiryDate,
5746
+				Count:               item.Count - list.StockCount,
5747
+				Price:               item.BuyPrice,
5748
+				Status:              1,
5749
+				Ctime:               ctime,
5750
+				UserOrgId:           adminUserInfo.CurrentOrgId,
5751
+				Manufacturer:        info.Manufacturer,
5752
+				Dealer:              info.Dealer,
5753
+				LicenseNumber:       info.LicenseNumber,
5754
+				IsEdit:              1,
5755
+				Creator:             adminUserInfo.AdminUser.Id,
5756
+				SystemTime:          operation_time,
5757
+				ConsumableType:      1,
5758
+				WarehousingDetailId: warehouseInfo.ID,
5759
+			}
5760
+
5761
+			service.CreateWarehouseInfo(warehouseInfo)
5762
+			service.CreateStockFlowOne(flow)
5763
+		}
5764
+
5765
+		//如果盘点库存小于实际库存,需要出库
5766
+		if item.Count < list.StockCount {
5767
+			timeStr := time.Now().Format("2006-01-02")
5768
+			timeArr := strings.Split(timeStr, "-")
5769
+			total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
5770
+
5771
+			total = total + 1
5772
+			warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
5773
+			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
5774
+			number = number + total
5775
+			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
5776
+			operation_time := time.Now().Unix()
5777
+			creater := adminUserInfo.AdminUser.Id
5778
+
5779
+			//查询最早的1条批次
5780
+			warehouseInfo, _ := service.GetFirstWarehouseInfo(item.GoodId)
5781
+			warehouseOut := models.WarehouseOut{
5782
+				WarehouseOutOrderNumber: warehousing_out_order,
5783
+				OperationTime:           operation_time,
5784
+				OrgId:                   adminUserInfo.CurrentOrgId,
5785
+				Creater:                 creater,
5786
+				Ctime:                   time.Now().Unix(),
5787
+				Status:                  1,
5788
+				WarehouseOutTime:        time.Now().Unix(),
5789
+				Type:                    1,
5790
+			}
5791
+			err = service.CreateWarehouseOut(warehouseOut)
5792
+			fmt.Println(err)
5793
+			warehouseOutInfo := &models.WarehouseOutInfo{
5794
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5795
+				WarehouseOutId:          warehouseOut.ID,
5796
+				GoodId:                  warehouseInfo.GoodId,
5797
+				Count:                   list.StockCount - item.Count,
5798
+				Price:                   warehouseInfo.Price,
5799
+				Status:                  1,
5800
+				Ctime:                   time.Now().Unix(),
5801
+				Remark:                  item.Remark,
5802
+				OrgId:                   adminUserInfo.CurrentOrgId,
5803
+				Type:                    1,
5804
+				Manufacturer:            manufactuer_id,
5805
+				Number:                  warehouseInfo.Number,
5806
+				ExpiryDate:              warehouseInfo.ExpiryDate,
5807
+				ProductDate:             warehouseInfo.ProductDate,
5808
+				Dealer:                  dealer_id,
5809
+				LicenseNumber:           warehouseInfo.LicenseNumber,
5810
+			}
5811
+
5812
+			stockFlow := models.VmStockFlow{
5813
+				WarehousingId:           item.WarehousingInfoId,
5814
+				GoodId:                  warehouseInfo.GoodId,
5815
+				Number:                  warehouseInfo.Number,
5816
+				LicenseNumber:           warehouseInfo.LicenseNumber,
5817
+				Count:                   list.StockCount - item.Count,
5818
+				UserOrgId:               warehouseInfo.OrgId,
5819
+				PatientId:               0,
5820
+				SystemTime:              0,
5821
+				ConsumableType:          2,
5822
+				IsSys:                   2,
5823
+				WarehousingOrder:        "",
5824
+				WarehouseOutId:          warehouseOut.ID,
5825
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
5826
+				IsEdit:                  1,
5827
+				CancelStockId:           0,
5828
+				CancelOrderNumber:       "",
5829
+				Manufacturer:            manufactuer_id,
5830
+				Dealer:                  dealer_id,
5831
+				Creator:                 adminUserInfo.AdminUser.Id,
5832
+				UpdateCreator:           0,
5833
+				Status:                  1,
5834
+				Ctime:                   time.Now().Unix(),
5835
+				Mtime:                   0,
5836
+				Price:                   warehouseInfo.Price,
5837
+				WarehousingDetailId:     0,
5838
+				WarehouseOutDetailId:    warehouseOutInfo.ID,
5839
+				CancelOutDetailId:       0,
5840
+				ProductDate:             warehouseInfo.ProductDate,
5841
+				ExpireDate:              warehouseInfo.ExpiryDate,
5842
+			}
5843
+			errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
5844
+			fmt.Println(errOne)
5845
+			//创建出库明细
5846
+			service.CreateStockFlowOne(stockFlow)
5847
+
5848
+			//更改库存
5849
+			warehousingInfos := models.WarehousingInfo{
5850
+				StockCount: item.Count,
5851
+			}
5852
+			service.UpdateStockOut(item.WarehousingInfoId, warehousingInfos)
5853
+		}
5854
+	}
5639
 	fmt.Println(err)
5855
 	fmt.Println(err)
5640
 	this.ServeSuccessJSON(map[string]interface{}{
5856
 	this.ServeSuccessJSON(map[string]interface{}{
5641
 		"inventory": inventory,
5857
 		"inventory": inventory,
5645
 func (this *StockManagerApiController) GetModifyPriceDetail() {
5861
 func (this *StockManagerApiController) GetModifyPriceDetail() {
5646
 
5862
 
5647
 	id, _ := this.GetInt64("id")
5863
 	id, _ := this.GetInt64("id")
5864
+
5648
 	detail, _ := service.GetModifyPriceDetail(id)
5865
 	detail, _ := service.GetModifyPriceDetail(id)
5649
 	this.ServeSuccessJSON(map[string]interface{}{
5866
 	this.ServeSuccessJSON(map[string]interface{}{
5650
 		"detail": detail,
5867
 		"detail": detail,
5661
 	packing_price, _ := strconv.ParseFloat(packingPrice, 64)
5878
 	packing_price, _ := strconv.ParseFloat(packingPrice, 64)
5662
 	remark := this.GetString("remark")
5879
 	remark := this.GetString("remark")
5663
 	good_id, _ := this.GetInt64("good_id")
5880
 	good_id, _ := this.GetInt64("good_id")
5881
+	manufacturer := this.GetString("manufacturer")
5882
+	dealer := this.GetString("dealer")
5664
 	adjust := models.XtStockAdjustPrice{
5883
 	adjust := models.XtStockAdjustPrice{
5665
 		NewPrice:     new_price,
5884
 		NewPrice:     new_price,
5666
 		GoodName:     good_name,
5885
 		GoodName:     good_name,
5667
 		PackingPrice: packing_price,
5886
 		PackingPrice: packing_price,
5668
 		Remark:       remark,
5887
 		Remark:       remark,
5669
 		GoodId:       good_id,
5888
 		GoodId:       good_id,
5889
+		Manufacturer: manufacturer,
5890
+		Dealer:       dealer,
5670
 	}
5891
 	}
5671
 	err := service.UpdateStockPrice(adjust, id)
5892
 	err := service.UpdateStockPrice(adjust, id)
5672
 	fmt.Println(err)
5893
 	fmt.Println(err)
5700
 
5921
 
5701
 	count, _ := this.GetInt64("count")
5922
 	count, _ := this.GetInt64("count")
5702
 	id, _ := this.GetInt64("id")
5923
 	id, _ := this.GetInt64("id")
5924
+	good_name := this.GetString("good_name")
5925
+	specification_name := this.GetString("specification_name")
5926
+	number := this.GetString("number")
5927
+	warehousing_unit := this.GetString("warehousing_unit")
5928
+	buyPrice := this.GetString("buy_price")
5929
+	buy_price, _ := strconv.ParseFloat(buyPrice, 64)
5930
+	packingPrice := this.GetString("packing_price")
5931
+	packing_price, _ := strconv.ParseFloat(packingPrice, 64)
5932
+	good_origin_place := this.GetString("good_origin_place")
5933
+	manufacturer := this.GetString("manufacturer")
5934
+	dealer := this.GetString("dealer")
5935
+	total, _ := this.GetInt64("total")
5936
+	remark := this.GetString("remark")
5937
+	warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
5938
+	good_id, _ := this.GetInt64("good_id")
5703
 	adjust := models.XtStockReportPrice{
5939
 	adjust := models.XtStockReportPrice{
5704
-		Count: count,
5940
+		Count:             count,
5941
+		SpecificationName: specification_name,
5942
+		Number:            number,
5943
+		GoodName:          good_name,
5944
+		WarehousingUnit:   warehousing_unit,
5945
+		BuyPrice:          buy_price,
5946
+		PackingPrice:      packing_price,
5947
+		GoodOriginPlace:   good_origin_place,
5948
+		Manufacturer:      manufacturer,
5949
+		Dealer:            dealer,
5950
+		Total:             total,
5951
+		Remark:            remark,
5952
+		WarehousingInfoId: warehousing_info_id,
5953
+		GoodId:            good_id,
5705
 	}
5954
 	}
5706
 	err := service.ModifyPrice(id, adjust)
5955
 	err := service.ModifyPrice(id, adjust)
5707
 	fmt.Println(err)
5956
 	fmt.Println(err)
5742
 
5991
 
5743
 func (this *StockManagerApiController) ModifyInventory() {
5992
 func (this *StockManagerApiController) ModifyInventory() {
5744
 	id, _ := this.GetInt64("id")
5993
 	id, _ := this.GetInt64("id")
5994
+	good_id, _ := this.GetInt64("good_id")
5995
+	good_name := this.GetString("good_name")
5996
+	specification_name := this.GetString("specification_name")
5997
+	number := this.GetString("number")
5998
+	warehousing_unit := this.GetString("warehousing_unit")
5999
+	buyPrice := this.GetString("buy_price")
6000
+	buy_price, _ := strconv.ParseFloat(buyPrice, 64)
6001
+	packingPrice := this.GetString("packing_price")
6002
+	packing_price, _ := strconv.ParseFloat(packingPrice, 64)
6003
+	total, _ := this.GetInt64("total")
6004
+	good_origin_place := this.GetString("good_origin_place")
6005
+	license_number := this.GetString("license_number")
6006
+	dealer := this.GetString("dealer")
6007
+	manufacturer := this.GetString("manufacturer")
5745
 	count, _ := this.GetInt64("count")
6008
 	count, _ := this.GetInt64("count")
5746
 	remark := this.GetString("remark")
6009
 	remark := this.GetString("remark")
5747
 	inventory := models.XtStockInventory{
6010
 	inventory := models.XtStockInventory{
5748
-		Count:  count,
5749
-		Remark: remark,
6011
+		GoodId:            good_id,
6012
+		GoodName:          good_name,
6013
+		SpecificationName: specification_name,
6014
+		Number:            number,
6015
+		WarehousingUnit:   warehousing_unit,
6016
+		BuyPrice:          buy_price,
6017
+		PackingPrice:      packing_price,
6018
+		Total:             total,
6019
+		GoodOriginPlace:   good_origin_place,
6020
+		LicenseNumber:     license_number,
6021
+		Dealer:            dealer,
6022
+		Manufacturer:      manufacturer,
6023
+		Count:             count,
6024
+		Remark:            remark,
5750
 	}
6025
 	}
5751
 	err := service.ModifyInventory(id, inventory)
6026
 	err := service.ModifyInventory(id, inventory)
5752
 	fmt.Println(err)
6027
 	fmt.Println(err)
5852
 		"list": info,
6127
 		"list": info,
5853
 	})
6128
 	})
5854
 }
6129
 }
6130
+
6131
+func (this *StockManagerApiController) GetWarehouseTotal() {
6132
+
6133
+	id, _ := this.GetInt64("id")
6134
+	list, _ := service.GetWarehouseTotal(id)
6135
+	this.ServeSuccessJSON(map[string]interface{}{
6136
+		"list": list,
6137
+	})
6138
+}

+ 6 - 1
models/self_drug_models.go View File

756
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
756
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
757
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
757
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
758
 	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
758
 	BatchNumber       string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
759
+	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
760
+	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
761
+	Total             string  `gorm:"column:total" json:"total" form:"total"`
759
 }
762
 }
760
 
763
 
761
 func (XtDrugDamage) TableName() string {
764
 func (XtDrugDamage) TableName() string {
794
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
797
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
795
 	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
798
 	WarehouseInfoId   int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
796
 	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
799
 	ProofCount        int64   `gorm:"column:proof_count" json:"proof_count" form:"proof_count"`
800
+	StockMaxNumber    int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
801
+	StockMinNumber    int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
797
 }
802
 }
798
 
803
 
799
 func (XtDrugInventory) TableName() string {
804
 func (XtDrugInventory) TableName() string {
829
 	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
834
 	DoseUnit          string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
830
 	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
835
 	MaxUnit           string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
831
 	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
836
 	MinUnit           string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
832
-	Total             int64   `gorm:"column:total" json:"total" form:"total"`
837
+	Total             string  `gorm:"column:total" json:"total" form:"total"`
833
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
838
 	DrugOriginPlace   string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
834
 }
839
 }

+ 3 - 0
models/stock_models.go View File

947
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
947
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
948
 	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
948
 	ExpiryDate        int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
949
 	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
949
 	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
950
+	Total             int64   `gorm:"column:total" json:"total" form:"total"`
951
+	GoodOriginPlace   string  `gorm:"column:good_origin_place" json:"good_origin_place" form:"good_origin_place"`
950
 }
952
 }
951
 
953
 
952
 func (XtStockReportPrice) TableName() string {
954
 func (XtStockReportPrice) TableName() string {
982
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
984
 	WarehousingInfoId int64   `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
983
 	ExpireDate        int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
985
 	ExpireDate        int64   `gorm:"column:expire_date" json:"expire_date" form:"expire_date"`
984
 	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
986
 	ProductDate       int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
987
+	GoodOriginPlace   string  `gorm:"column:good_origin_place" json:"good_origin_place" form:"good_origin_place"`
985
 }
988
 }
986
 
989
 
987
 func (XtStockInventory) TableName() string {
990
 func (XtStockInventory) TableName() string {

+ 1 - 1
service/dialysis_service.go View File

1230
 }
1230
 }
1231
 
1231
 
1232
 func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (advice []*models.HisPrescriptionProject, err error) {
1232
 func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (advice []*models.HisPrescriptionProject, err error) {
1233
-	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1233
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1234
 	return
1234
 	return
1235
 }
1235
 }

+ 26 - 1
service/gobal_config_service.go View File

552
 		db = db.Where("drug_name like ?", likeKey)
552
 		db = db.Where("drug_name like ?", likeKey)
553
 	}
553
 	}
554
 
554
 
555
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugCancelStockInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Preload("DrugWarehouseOutInfo", "status=1 and org_id = ? and ctime >=? and ctime<=?", orgid, startime, endtime).Find(&drug).Error
555
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
556
+		if startime > 0 {
557
+			db = db.Where("ctime>=?", startime)
558
+		}
559
+		if endtime > 0 {
560
+			db = db.Where("ctime<=?", endtime)
561
+		}
562
+		return db.Where("status = 1")
563
+	}).Preload("DrugCancelStockInfo", func(db *gorm.DB) *gorm.DB {
564
+		if startime > 0 {
565
+			db = db.Where("ctime>=?", startime)
566
+		}
567
+		if endtime > 0 {
568
+			db = db.Where("ctime<=?", endtime)
569
+		}
570
+		return db.Where("status = 1")
571
+	}).Preload("DrugWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
572
+		if startime > 0 {
573
+			db = db.Where("ctime>=?", startime)
574
+		}
575
+		if endtime > 0 {
576
+			db = db.Where("ctime<=?", endtime)
577
+		}
578
+		return db.Where("status = 1")
579
+	}).Find(&drug).Error
580
+
556
 	return drug, total, err
581
 	return drug, total, err
557
 }
582
 }
558
 
583
 

+ 1 - 1
service/patientmanage_service.go View File

1668
 	table := XTReadDB().Table("xt_inspection_reference as s").Where("s.status = 1")
1668
 	table := XTReadDB().Table("xt_inspection_reference as s").Where("s.status = 1")
1669
 	fmt.Println(table)
1669
 	fmt.Println(table)
1670
 	if patientid > 0 {
1670
 	if patientid > 0 {
1671
-		db = db.Where("x.patient_id = ?", patientid)
1671
+		db = db.Where("x.patient_id = ? and x.inspect_value <> ''", patientid)
1672
 	}
1672
 	}
1673
 	if len(inspect_date) > 0 {
1673
 	if len(inspect_date) > 0 {
1674
 		db = db.Where("x.inspect_date in(?)", inspect_date)
1674
 		db = db.Where("x.inspect_date in(?)", inspect_date)

+ 7 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

210
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
210
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
211
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
211
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
212
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
212
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
213
+	MaxUltrafiltrationRate     float64 `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
213
 }
214
 }
214
 
215
 
215
 func (PrescriptionVM) TableName() string {
216
 func (PrescriptionVM) TableName() string {
354
 	BloodFlow                       int64   `gorm:"column:blood_flow" json:"blood_flow" form:"blood_flow"`
355
 	BloodFlow                       int64   `gorm:"column:blood_flow" json:"blood_flow" form:"blood_flow"`
355
 	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
356
 	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
356
 	SealingFluidSpecial             string  `gorm:"column:sealing_fluid_special" json:"sealing_fluid_special" form:"sealing_fluid_special"`
357
 	SealingFluidSpecial             string  `gorm:"column:sealing_fluid_special" json:"sealing_fluid_special" form:"sealing_fluid_special"`
358
+	MachineRun                      string  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
357
 }
359
 }
358
 
360
 
359
 func (AssessmentAfterDislysisVM) TableName() string {
361
 func (AssessmentAfterDislysisVM) TableName() string {
525
 	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
527
 	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
526
 	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
528
 	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
527
 	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
529
 	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
530
+	AccumulatedBloodVolume    float64 `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
531
+	BloodTemperature          float64 `gorm:"column:blood_temperature" json:"blood_temperature" form:"blood_temperature"`
532
+	UreaMonitoring            float64 `gorm:"column:urea_monitoring" json:"urea_monitoring" form:"urea_monitoring"`
533
+	BloodThickness            float64 `gorm:"column:blood_thickness" json:"blood_thickness" form:"blood_thickness"`
534
+	BloodMonitor              float64 `gorm:"column:blood_monitor" json:"blood_monitor" form:"blood_monitor"`
528
 }
535
 }
529
 
536
 
530
 func (MonitoringRecordVM) TableName() string {
537
 func (MonitoringRecordVM) TableName() string {

+ 31 - 6
service/schedule_service.go View File

589
 	return list, err
589
 	return list, err
590
 }
590
 }
591
 
591
 
592
-func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone int64) (list []*models.VmSchedulesRemind, err error) {
592
+func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
593
+
594
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
595
+	if orgid > 0 {
596
+		db = db.Where("x.user_org_id = ?", orgid)
597
+	}
598
+	if scheduleDate > 0 {
599
+		db = db.Where("x.schedule_date = ?", scheduleDate)
600
+	}
601
+	if scheduleType > 0 {
602
+		db = db.Where("x.schedule_type = ?", scheduleType)
603
+	}
604
+	if len(zone) > 0 {
605
+		db = db.Where("x.partition_id in (?)", zone)
606
+	}
607
+
608
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
609
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
610
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
611
+		return db.Where("status =1").Order("id asc")
612
+	}).Find(&list).Error
613
+
614
+	return list, err
615
+}
616
+
617
+func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
593
 
618
 
594
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
619
 	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
595
 	if orgid > 0 {
620
 	if orgid > 0 {
601
 	if scheduleType > 0 {
626
 	if scheduleType > 0 {
602
 		db = db.Where("x.schedule_type = ?", scheduleType)
627
 		db = db.Where("x.schedule_type = ?", scheduleType)
603
 	}
628
 	}
604
-	if zone > 0 {
605
-		db = db.Where("x.partition_id = ?", zone)
629
+	if len(zone) > 0 {
630
+		db = db.Where("x.partition_id in (?)", zone)
606
 	}
631
 	}
607
 
632
 
608
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
633
 	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
758
 	return
783
 	return
759
 }
784
 }
760
 
785
 
761
-func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone int64) (schedules []*models.WeekSchedule, err error) {
786
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string) (schedules []*models.WeekSchedule, err error) {
762
 
787
 
763
 	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
788
 	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
764
 	if orgID > 0 {
789
 	if orgID > 0 {
776
 	if weektype > 0 {
801
 	if weektype > 0 {
777
 		db = db.Where("s.schedule_week = ?", weektype)
802
 		db = db.Where("s.schedule_week = ?", weektype)
778
 	}
803
 	}
779
-	if zone > 0 {
780
-		db = db.Where("s.partition_id = ?", zone)
804
+	if len(zone) > 0 {
805
+		db = db.Where("s.partition_id in (?)", zone)
781
 	}
806
 	}
782
 	err = db.
807
 	err = db.
783
 		Preload("DeviceZone", "status = 1 ").
808
 		Preload("DeviceZone", "status = 1 ").

+ 69 - 14
service/self_drug_service.go View File

817
 	if orgid > 0 {
817
 	if orgid > 0 {
818
 		db = db.Where("x.org_id = ?", orgid)
818
 		db = db.Where("x.org_id = ?", orgid)
819
 	}
819
 	}
820
-	err = db.Select("x.id,x.warehousing_id,x.drug_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_origin_place").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
820
+	err = db.Group("x.drug_id").Select("x.id,x.warehousing_id,x.drug_id,t.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehouseing_unit,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_origin_place,t.drug_name,t.min_unit,x.manufacturer,t.retail_price,t.max_unit,t.min_number,t.dose,t.dose_unit,t.last_price,t.drug_origin_place").Joins("left join xt_base_drug as t on t.id = x.drug_id").Where("t.drug_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
821
 	return info, err
821
 	return info, err
822
 
822
 
823
 }
823
 }
889
 func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.XtDrugDamage, total int64, err error) {
889
 func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.XtDrugDamage, total int64, err error) {
890
 	likeKey := "%" + keyword + "%"
890
 	likeKey := "%" + keyword + "%"
891
 	offset := (page - 1) * limit
891
 	offset := (page - 1) * limit
892
-	db := XTReadDB().Model(&adjust).Where("status = 1")
893
-	if startime > 0 {
894
-		db = db.Where("ctime >=?", startime)
895
-	}
896
-	if endtime > 0 {
897
-		db = db.Where("ctime<=?", endtime)
892
+	db := XTReadDB().Table("xt_drug_damage as x").Where("x.status = 1")
893
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
894
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
895
+	fmt.Println(table, tab)
896
+	if len(keyword) > 0 {
897
+		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
898
 	}
898
 	}
899
 	if orgId > 0 {
899
 	if orgId > 0 {
900
-		db = db.Where("user_org_id = ?", orgId)
900
+		db = db.Where("x.user_org_id = ?", orgId)
901
 	}
901
 	}
902
-	if len(keyword) > 0 {
903
-		db = db.Where("warehousing_order like ?", likeKey)
902
+	if startime > 0 {
903
+		db = db.Where("x.ctime >=?", startime)
904
 	}
904
 	}
905
-	err = db.Count(&total).Offset(offset).Limit(limit).Find(&adjust).Error
905
+	if endtime > 0 {
906
+		db = db.Where("x.ctime <=?", endtime)
907
+	}
908
+	err = db.Group("x.id").Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.number,x.drug_origin_place,x.warehousing_info_id,x.batch_number,x.stock_max_number,x.stock_min_number").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
906
 	return adjust, total, err
909
 	return adjust, total, err
907
 }
910
 }
908
 
911
 
920
 
923
 
921
 func ModifyDrugPrice(id int64, adjust models.XtDrugAdjustPrice) error {
924
 func ModifyDrugPrice(id int64, adjust models.XtDrugAdjustPrice) error {
922
 
925
 
923
-	err := XTWriteDB().Model(&adjust).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": adjust.DrugName, "retail_price": adjust.RetailPrice, "new_price": adjust.NewPrice, "count": adjust.Count, "remark": adjust.Remark}).Error
926
+	err := XTWriteDB().Model(&adjust).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": adjust.DrugName, "retail_price": adjust.RetailPrice, "new_price": adjust.NewPrice, "count": adjust.Count, "remark": adjust.Remark, "specification_name": adjust.SpecificationName, "warehousing_unit": adjust.WarehousingUnit, "manufacturer": adjust.Manufacturer, "number": adjust.Number, "drug_id": adjust.DrugId}).Error
924
 	return err
927
 	return err
925
 }
928
 }
926
 
929
 
939
 
942
 
940
 func ModifyDrugDamage(id int64, damage models.XtDrugDamage) error {
943
 func ModifyDrugDamage(id int64, damage models.XtDrugDamage) error {
941
 
944
 
942
-	err := XTWriteDB().Model(&damage).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": damage.DrugName, "warehousing_unit": damage.WarehousingUnit, "count": damage.Count, "last_price": damage.LastPrice, "retail_price": damage.RetailPrice, "new_price": damage.NewPrice, "manufacturer": damage.Manufacturer, "remark": damage.Remark, "number": damage.Number, "drug_id": damage.DrugId}).Error
945
+	err := XTWriteDB().Model(&damage).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": damage.DrugName, "warehousing_unit": damage.WarehousingUnit, "count": damage.Count, "last_price": damage.LastPrice, "retail_price": damage.RetailPrice, "new_price": damage.NewPrice, "manufacturer": damage.Manufacturer, "remark": damage.Remark, "number": damage.Number, "drug_id": damage.DrugId, "stock_max_number": damage.StockMaxNumber, "stock_min_number": damage.StockMinNumber, "warehousing_info_id": damage.WarehousingInfoId, "drug_origin_place": damage.DrugOriginPlace}).Error
943
 	return err
946
 	return err
944
 }
947
 }
945
 
948
 
997
 	return err
1000
 	return err
998
 }
1001
 }
999
 
1002
 
1003
+func GetDrugInventoryListByIds(ids []string) (inventory []*models.XtDrugInventory, err error) {
1004
+
1005
+	err = XTReadDB().Model(&inventory).Where("id in(?) and status = 1", ids).Find(&inventory).Error
1006
+	return inventory, err
1007
+}
1008
+
1009
+func GetDrugDetailByDrugId(drug_id int64) (models.XtBaseDrug, error) {
1010
+
1011
+	drug := models.XtBaseDrug{}
1012
+	err := XTReadDB().Model(&drug).Where("id = ? and status = 1", drug_id).Find(&drug).Error
1013
+	return drug, err
1014
+}
1015
+
1016
+func GetDrugWareInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
1017
+	info := models.XtDrugWarehouseInfo{}
1018
+	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
1019
+	return info, err
1020
+}
1021
+
1022
+func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1023
+
1024
+	info := models.XtDrugWarehouseInfo{}
1025
+	err := XTReadDB().Model(&info).Where("id=? and status = 1", drugid).Last(&info).Error
1026
+	return info, err
1027
+}
1028
+
1029
+func GetFirstDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1030
+
1031
+	info := models.XtDrugWarehouseInfo{}
1032
+	err := XTReadDB().Model(&info).Where("id=? and status = 1", drugid).First(&info).Error
1033
+	return info, err
1034
+}
1035
+
1000
 func GetDrugInventoryDetail(id int64) (models.XtDrugInventory, error) {
1036
 func GetDrugInventoryDetail(id int64) (models.XtDrugInventory, error) {
1001
 
1037
 
1002
 	inventory := models.XtDrugInventory{}
1038
 	inventory := models.XtDrugInventory{}
1006
 
1042
 
1007
 func ModifyDrugInventory(id int64, info models.XtDrugInventory) error {
1043
 func ModifyDrugInventory(id int64, info models.XtDrugInventory) error {
1008
 
1044
 
1009
-	err := XTWriteDB().Model(&info).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": info.DrugName, "specification_name": info.SpecificationName, "warehousing_unit": info.WarehousingUnit, "count": info.Count, "last_price": info.LastPrice, "manufacturer": info.Manufacturer, "remark": info.Remark, "drug_id": info.DrugId, "warehousing_order": info.WarehousingOrder, "number": info.Number, "total": info.Number, "drug_origin_place": info.DrugOriginPlace}).Error
1045
+	err := XTWriteDB().Model(&info).Where("id=? and status = 1", id).Updates(map[string]interface{}{"drug_name": info.DrugName, "specification_name": info.SpecificationName, "warehousing_unit": info.WarehousingUnit, "count": info.Count, "last_price": info.LastPrice, "manufacturer": info.Manufacturer, "remark": info.Remark, "drug_id": info.DrugId, "warehousing_order": info.WarehousingOrder, "number": info.Number, "total": info.Number, "drug_origin_place": info.DrugOriginPlace, "stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber, "warehouse_info_id": info.WarehouseInfoId}).Error
1010
 	return err
1046
 	return err
1011
 }
1047
 }
1012
 
1048
 
1051
 	err := XTWriteDB().Model(&inventory).Where("id = ?", id).Updates(map[string]interface{}{"stock_max_number": inventory.StockMaxNumber}).Error
1087
 	err := XTWriteDB().Model(&inventory).Where("id = ?", id).Updates(map[string]interface{}{"stock_max_number": inventory.StockMaxNumber}).Error
1052
 	return err
1088
 	return err
1053
 }
1089
 }
1090
+
1091
+func GetDrugWarehouseInfoTotal(id int64) (models.XtDrugWarehouseInfo, error) {
1092
+
1093
+	info := models.XtDrugWarehouseInfo{}
1094
+	err := XTReadDB().Where("id = ? and status = 1", id).Preload("XtBaseDrug", "status = 1").Find(&info).Error
1095
+	return info, err
1096
+}
1097
+
1098
+func CreateDrugWarehouseInfo(info models.DrugWarehouseInfo) error {
1099
+
1100
+	err := XTWriteDB().Create(&info).Error
1101
+	return err
1102
+}
1103
+
1104
+func CreateDrugWarehouseOutInfo(info models.DrugWarehouseOutInfo) error {
1105
+
1106
+	err := XTWriteDB().Create(&info).Error
1107
+	return err
1108
+}

+ 102 - 22
service/stock_service.go View File

508
 
508
 
509
 func UpdateBaseDrugOne(lib models.BaseDrugLib, id int64) error {
509
 func UpdateBaseDrugOne(lib models.BaseDrugLib, id int64) error {
510
 
510
 
511
-	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"retail_price": lib.RetailPrice}).Error
511
+	err := XTWriteDB().Model(&lib).Where("id = ?", id).Updates(map[string]interface{}{"retail_price": lib.RetailPrice, "last_price": lib.LastPrice}).Error
512
 	return err
512
 	return err
513
 }
513
 }
514
 func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
514
 func FindeLastWarehouseInfo(id int64) (models.DrugWarehouseInfo, error) {
571
 	return
571
 	return
572
 }
572
 }
573
 
573
 
574
+func GetDrugByWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
575
+
576
+	info := models.XtDrugWarehouseInfo{}
577
+	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
578
+	return info, err
579
+}
580
+
581
+func UpdateDrugWarehouseingInfo(id int64, info models.XtDrugWarehouseInfo) error {
582
+
583
+	warehouseInfo := models.XtDrugWarehouseInfo{}
584
+	err := XTReadDB().Model(&warehouseInfo).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber}).Error
585
+	return err
586
+}
587
+
574
 func CreateDrugFlowOne(flow models.DrugFlow) error {
588
 func CreateDrugFlowOne(flow models.DrugFlow) error {
575
 
589
 
576
 	err := XTWriteDB().Create(&flow).Error
590
 	err := XTWriteDB().Create(&flow).Error
2542
 
2556
 
2543
 }
2557
 }
2544
 
2558
 
2559
+func UpdateStockOut(warehouseinfoid int64, info models.WarehousingInfo) error {
2560
+
2561
+	err := XTWriteDB().Model(&info).Where("id=? and status = 1", warehouseinfoid).Updates(map[string]interface{}{"stock_count": info.StockCount}).Error
2562
+	return err
2563
+}
2564
+
2545
 func AddSigleDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) error {
2565
 func AddSigleDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) error {
2546
 	ut := writeDb.Begin()
2566
 	ut := writeDb.Begin()
2547
 	err := ut.Create(&info).Error
2567
 	err := ut.Create(&info).Error
3208
 		db = db.Where("x.good_type_id = ?", good_type)
3228
 		db = db.Where("x.good_type_id = ?", good_type)
3209
 	}
3229
 	}
3210
 
3230
 
3211
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Preload("CancelStockInfo", "status= 1 and org_id =? and ctime>=? and ctime<=?", orgid, startime, endtime).Find(&info).Error
3231
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Preload("StWarehousingInfo", func(db *gorm.DB) *gorm.DB {
3232
+		if startime > 0 {
3233
+			db = db.Where("ctime>=?", startime)
3234
+		}
3235
+		if endtime > 0 {
3236
+			db = db.Where("ctime<=?", endtime)
3237
+		}
3238
+		return db.Where("status = 1")
3239
+	}).Preload("CancelStockInfo", func(db *gorm.DB) *gorm.DB {
3240
+		if startime > 0 {
3241
+			db = db.Where("ctime>=?", startime)
3242
+		}
3243
+		if endtime > 0 {
3244
+			db = db.Where("ctime<=?", endtime)
3245
+		}
3246
+		return db.Where("status = 1")
3247
+	}).Find(&info).Error
3212
 	return info, total, err
3248
 	return info, total, err
3213
 }
3249
 }
3214
 
3250
 
3299
 
3335
 
3300
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3336
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3301
 
3337
 
3302
-	if startime > 0 {
3303
-		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=?  and `status` = 1)  as b GROUP BY good_id", orgid, startime).Scan(&autoMatic).Error
3304
-	} else {
3305
-		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
3306
-	}
3338
+	//if startime > 0 {
3339
+	//	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >=?  and `status` = 1)  as b GROUP BY good_id", orgid, startime).Scan(&autoMatic).Error
3340
+	//} else {
3341
+	//	err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
3342
+	//}
3307
 
3343
 
3308
-	if endtime > 0 {
3309
-		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time <=?  and `status` = 1)  as b GROUP BY good_id", orgid, endtime).Scan(&autoMatic).Error
3344
+	if startime > 0 || endtime > 0 {
3345
+		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time <=?  and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
3310
 	} else {
3346
 	} else {
3311
 		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
3347
 		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
3312
 	}
3348
 	}
3313
 
3349
 
3350
+	//err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error
3351
+
3314
 	return autoMatic, err
3352
 	return autoMatic, err
3315
 
3353
 
3316
 }
3354
 }
4223
 	return err
4261
 	return err
4224
 }
4262
 }
4225
 
4263
 
4226
-func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4264
+func GetWarehouseInfoByIdSeven(id int64) (models.WarehousingInfo, error) {
4227
 
4265
 
4228
 	info := models.WarehousingInfo{}
4266
 	info := models.WarehousingInfo{}
4229
 	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
4267
 	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
4230
 	return info, err
4268
 	return info, err
4231
 }
4269
 }
4232
 
4270
 
4271
+func GetLastWarehouseInfo(goodid int64) (models.WarehousingInfo, error) {
4272
+
4273
+	info := models.WarehousingInfo{}
4274
+	err := XTReadDB().Model(&info).Where("good_id = ? and status = 1", goodid).Last(&info).Error
4275
+	return info, err
4276
+}
4277
+
4278
+func GetFirstWarehouseInfo(goodid int64) (models.WarehousingInfo, error) {
4279
+	info := models.WarehousingInfo{}
4280
+	err := XTReadDB().Model(&info).Where("good_id = ? and status = 1", goodid).First(&info).Error
4281
+	return info, err
4282
+}
4283
+
4284
+func CreateWarehouseOut(out models.WarehouseOut) error {
4285
+
4286
+	err := XTWriteDB().Create(&out).Error
4287
+	return err
4288
+}
4289
+
4290
+func CreateWarehouseInfo(info models.WarehousingInfo) error {
4291
+
4292
+	err := XTReadDB().Create(&info).Error
4293
+	return err
4294
+}
4295
+
4233
 func UpdateGoodWarehouseInfo(id int64, info models.WarehousingInfo) error {
4296
 func UpdateGoodWarehouseInfo(id int64, info models.WarehousingInfo) error {
4234
 
4297
 
4235
 	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_count": info.StockCount}).Error
4298
 	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_count": info.StockCount}).Error
4311
 	if orgid > 0 {
4374
 	if orgid > 0 {
4312
 		db = db.Where("x.org_id = ?", orgid)
4375
 		db = db.Where("x.org_id = ?", orgid)
4313
 	}
4376
 	}
4314
-	err = db.Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,x.dealer,x.remark,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.warehousing_unit,t.good_name,t.specification_name,x.manufacturer,t.packing_price,t.id as good_id,t.packing_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Where("t.good_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
4377
+	err = db.Group("x.good_id").Select("x.id,x.warehousing_id,x.good_id,x.good_type_id,x.number,x.product_date,x.expiry_date,x.warehousing_count,x.price,x.total_price,t.dealer,x.remark,x.warehousing_order,x.warehousing_unit,x.stock_count,x.license_number,x.warehousing_unit,t.good_name,t.specification_name,t.manufacturer,t.packing_price,t.id as good_id,t.packing_unit,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Where("t.good_name like ? and t.org_id = ?", likeKey, orgid).Order("x.ctime desc").Scan(&info).Error
4315
 	return info, err
4378
 	return info, err
4316
 }
4379
 }
4317
 
4380
 
4332
 		db = db.Where("x.start_time>=?", startime)
4395
 		db = db.Where("x.start_time>=?", startime)
4333
 	}
4396
 	}
4334
 	if endtime > 0 {
4397
 	if endtime > 0 {
4335
-		db = db.Where("x.end_time<=?", endtime)
4398
+		db = db.Where("x.start_time<=?", endtime)
4336
 	}
4399
 	}
4337
 	if len(keyword) > 0 {
4400
 	if len(keyword) > 0 {
4338
 		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
4401
 		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
4352
 
4415
 
4353
 func UpdateAdjustCheckPrice(info *models.GoodInfo, id int64) error {
4416
 func UpdateAdjustCheckPrice(info *models.GoodInfo, id int64) error {
4354
 
4417
 
4355
-	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"packing_price": info.PackingPrice}).Error
4418
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"packing_price": info.PackingPrice, "buy_price": info.BuyPrice}).Error
4356
 	return err
4419
 	return err
4357
 }
4420
 }
4358
 
4421
 
4382
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4445
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4383
 	fmt.Println(table, tab)
4446
 	fmt.Println(table, tab)
4384
 	if startime > 0 {
4447
 	if startime > 0 {
4385
-		db = db.Where("x.start_time>=?", startime)
4448
+		db = db.Where("x.ctime>=?", startime)
4386
 	}
4449
 	}
4387
 	if endtime > 0 {
4450
 	if endtime > 0 {
4388
-		db = db.Where("x.end_time<=?", endtime)
4451
+		db = db.Where("x.ctime<=?", endtime)
4389
 	}
4452
 	}
4390
 	if len(keyword) > 0 {
4453
 	if len(keyword) > 0 {
4391
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4454
 		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4430
 		db = db.Where("x.end_time<=?", endtime)
4493
 		db = db.Where("x.end_time<=?", endtime)
4431
 	}
4494
 	}
4432
 	if len(keyword) > 0 {
4495
 	if len(keyword) > 0 {
4433
-		db = db.Where("x.warehousing_order like ?", likeKey)
4434
-	}
4435
-	if len(keyword) > 0 {
4436
-		db = db.Where("r.user_name like ?", likeKey)
4496
+		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4437
 	}
4497
 	}
4498
+
4438
 	if orgid > 0 {
4499
 	if orgid > 0 {
4439
 		db = db.Where("x.user_org_id = ?", orgid)
4500
 		db = db.Where("x.user_org_id = ?", orgid)
4440
 	}
4501
 	}
4457
 	return info, err
4518
 	return info, err
4458
 }
4519
 }
4459
 
4520
 
4521
+func GetInventoryDetailById(id []string) (list []*models.XtStockInventory, err error) {
4522
+
4523
+	err = XTReadDB().Model(&list).Where("id in(?) and status = 1", id).Find(&list).Error
4524
+	return list, err
4525
+}
4526
+
4527
+func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4528
+
4529
+	info := models.WarehousingInfo{}
4530
+	err := XTReadDB().Model(&info).Where("id = ? and status = 1", id).Find(&info).Error
4531
+	return info, err
4532
+}
4533
+
4460
 func UpdateStockPrice(info models.XtStockAdjustPrice, id int64) error {
4534
 func UpdateStockPrice(info models.XtStockAdjustPrice, id int64) error {
4461
 
4535
 
4462
-	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"new_price": info.NewPrice, "good_name": info.GoodName, "packing_price": info.PackingPrice, "good_id": info.GoodId, "remark": info.Remark}).Error
4536
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"new_price": info.NewPrice, "good_name": info.GoodName, "packing_price": info.PackingPrice, "good_id": info.GoodId, "remark": info.Remark, "manufacturer": info.Manufacturer, "dealer": info.Dealer}).Error
4463
 	return err
4537
 	return err
4464
 }
4538
 }
4465
 
4539
 
4477
 
4551
 
4478
 func ModifyPrice(id int64, info models.XtStockReportPrice) error {
4552
 func ModifyPrice(id int64, info models.XtStockReportPrice) error {
4479
 
4553
 
4480
-	err := XTWriteDB().Model(&info).Where("id = ?", id).Updates(map[string]interface{}{"count": info.Count}).Error
4554
+	err := XTWriteDB().Model(&info).Where("id = ?", id).Updates(map[string]interface{}{"count": info.Count, "specification_name": info.SpecificationName, "good_name": info.GoodName, "number": info.Number, "warehousing_unit": info.WarehousingUnit, "buy_price": info.BuyPrice, "packing_price": info.PackingPrice, "good_origin_place": info.GoodOriginPlace, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "total": info.Total, "remark": info.Remark, "warehousing_info_id": info.WarehousingInfoId, "good_id": info.GoodId}).Error
4481
 	return err
4555
 	return err
4482
 }
4556
 }
4483
 
4557
 
4502
 
4576
 
4503
 func ModifyInventory(id int64, inventory models.XtStockInventory) error {
4577
 func ModifyInventory(id int64, inventory models.XtStockInventory) error {
4504
 
4578
 
4505
-	err := XTWriteDB().Model(&inventory).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"count": inventory.Count, "remark": inventory.Remark}).Error
4579
+	err := XTWriteDB().Model(&inventory).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"good_id": inventory.GoodId, "good_name": inventory.GoodName, "specification_name": inventory.SpecificationName, "number": inventory.Number, "warehousing_unit": inventory.WarehousingUnit, "buy_price": inventory.BuyPrice, "packing_price": inventory.PackingPrice, "total": inventory.Total, "good_origin_place": inventory.GoodOriginPlace, "license_number": inventory.LicenseNumber, "dealer": inventory.Dealer, "manufacturer": inventory.Dealer, "count": inventory.Count, "remark": inventory.Remark}).Error
4506
 	return err
4580
 	return err
4507
 }
4581
 }
4508
 
4582
 
4578
 	err := XTWriteDB().Create(&record).Error
4652
 	err := XTWriteDB().Create(&record).Error
4579
 	return err
4653
 	return err
4580
 }
4654
 }
4655
+
4656
+func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4657
+	info := models.WarehousingInfo{}
4658
+	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4659
+	return info, err
4660
+}