浏览代码

历史排班

28169 1年前
父节点
当前提交
718404a004

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

1173
 		Chaptalization:             chaptalization,
1173
 		Chaptalization:             chaptalization,
1174
 	}
1174
 	}
1175
 
1175
 
1176
+	if prescription.Anticoagulant == 0 {
1177
+		prescription.Anticoagulant = 3
1178
+	}
1176
 	//查询最近透析准备表里是否存在 透析器 灌流器
1179
 	//查询最近透析准备表里是否存在 透析器 灌流器
1177
 
1180
 
1178
 	//splitStr := strings.Split(dialysis_dialyszers, ",")
1181
 	//splitStr := strings.Split(dialysis_dialyszers, ",")
1376
 		Chaptalization:             chaptalization,
1379
 		Chaptalization:             chaptalization,
1377
 	}
1380
 	}
1378
 
1381
 
1382
+	if solution.Anticoagulant == 0 {
1383
+		solution.Anticoagulant = 3
1384
+	}
1379
 	//针对河间咸得
1385
 	//针对河间咸得
1380
 	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
1386
 	if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
1381
 
1387
 

+ 2 - 2
controllers/doctor_schedule_api_controller.go 查看文件

552
 func (this *DoctorScheduleApiController) GetScheduleListTotal() {
552
 func (this *DoctorScheduleApiController) GetScheduleListTotal() {
553
 
553
 
554
 	start_time, _ := this.GetInt64("start_time")
554
 	start_time, _ := this.GetInt64("start_time")
555
-	fmt.Println(start_time)
555
+
556
 	end_time, _ := this.GetInt64("end_time")
556
 	end_time, _ := this.GetInt64("end_time")
557
-	fmt.Println("end_time", end_time)
557
+
558
 	adminUserInfo := this.GetAdminUserInfo()
558
 	adminUserInfo := this.GetAdminUserInfo()
559
 	orgId := adminUserInfo.CurrentOrgId
559
 	orgId := adminUserInfo.CurrentOrgId
560
 	//统计班次
560
 	//统计班次

+ 7 - 8
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go 查看文件

56
 	//fmt.Println("end_time",end_time)
56
 	//fmt.Println("end_time",end_time)
57
 	start_time_one := this.GetString("start_time_one")
57
 	start_time_one := this.GetString("start_time_one")
58
 	end_time_one := this.GetString("end_time_one")
58
 	end_time_one := this.GetString("end_time_one")
59
-	fmt.Println("start_time_one--------", len(start_time_one))
60
-	fmt.Println("end_time_one-------", end_time_one)
59
+
61
 	timeLayout := "2006-01-02"
60
 	timeLayout := "2006-01-02"
62
 	loc, _ := time.LoadLocation("Local")
61
 	loc, _ := time.LoadLocation("Local")
63
 	var startTime int64
62
 	var startTime int64
64
 	if len(start_time_one) > 0 {
63
 	if len(start_time_one) > 0 {
65
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
64
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
66
-		fmt.Println("err-----------", err)
65
+
67
 		if err != nil {
66
 		if err != nil {
68
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
67
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
69
 			return
68
 			return
80
 		}
79
 		}
81
 		endTime = theTime.Unix()
80
 		endTime = theTime.Unix()
82
 	}
81
 	}
83
-	fmt.Println("starti_time233232323232", startTime)
84
-	fmt.Println("end_time2323223232323", endTime)
82
+
85
 	staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
83
 	staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
86
 	if err != nil {
84
 	if err != nil {
87
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
85
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
507
 			ErrLog:      string(byterequest),
505
 			ErrLog:      string(byterequest),
508
 			Source:      "手机端删除排班",
506
 			Source:      "手机端删除排班",
509
 			Module:      5,
507
 			Module:      5,
510
-			AdminUserId: this.GetAdminUserInfo().AdminUser.Id,
508
+			AdminUserId: this.GetMobileAdminUserInfo().AdminUser.Id,
511
 		}
509
 		}
512
 		service.CreateScheduleLog(xtScheduleLog)
510
 		service.CreateScheduleLog(xtScheduleLog)
513
 		redis := service.RedisClient()
511
 		redis := service.RedisClient()
651
 }
649
 }
652
 
650
 
653
 func (this *StaffScheduleApiController) UpdateBloodScheduleMode() {
651
 func (this *StaffScheduleApiController) UpdateBloodScheduleMode() {
652
+
654
 	id, _ := this.GetInt64("id")
653
 	id, _ := this.GetInt64("id")
655
 	mode_id, _ := this.GetInt64("mode_id")
654
 	mode_id, _ := this.GetInt64("mode_id")
656
 	schedule := models.XtSchedule{
655
 	schedule := models.XtSchedule{
658
 	}
657
 	}
659
 	service.UpdatedScheduleMode(schedule, id)
658
 	service.UpdatedScheduleMode(schedule, id)
660
 
659
 
661
-	orgId := this.GetAdminUserInfo().CurrentOrgId
660
+	orgId := this.GetMobileAdminUserInfo().Org.Id
662
 	//记录日志
661
 	//记录日志
663
 	byterequest, _ := json.Marshal(schedule)
662
 	byterequest, _ := json.Marshal(schedule)
664
 	scheduleLog := models.XtScheduleLog{
663
 	scheduleLog := models.XtScheduleLog{
671
 		ErrLog:      string(byterequest),
670
 		ErrLog:      string(byterequest),
672
 		Source:      "手机端修改排班模式",
671
 		Source:      "手机端修改排班模式",
673
 		Module:      5,
672
 		Module:      5,
674
-		AdminUserId: this.GetAdminUserInfo().AdminUser.Id,
673
+		AdminUserId: this.GetMobileAdminUserInfo().AdminUser.Id,
675
 	}
674
 	}
676
 
675
 
677
 	service.CreateScheduleLog(scheduleLog)
676
 	service.CreateScheduleLog(scheduleLog)

+ 63 - 18
controllers/patient_api_controller.go 查看文件

716
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
716
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
717
 		return
717
 		return
718
 	}
718
 	}
719
+
720
+	start_time := c.GetString("start_time")
721
+
722
+	end_time := c.GetString("end_time")
723
+	timeLayout := "2006-01-02"
724
+	loc, _ := time.LoadLocation("Local")
725
+	var startTime int64
726
+	if len(start_time) > 0 {
727
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
728
+
729
+		if err != nil {
730
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
731
+			return
732
+		}
733
+		startTime = theTime.Unix()
734
+	}
735
+	var endTime int64
736
+	if len(end_time) > 0 {
737
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
738
+		if err != nil {
739
+			utils.ErrorLog(err.Error())
740
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
741
+			return
742
+		}
743
+		endTime = theTime.Unix()
744
+	}
745
+
746
+	patient_address := c.GetString("patient_address")
747
+
719
 	adminUserInfo := c.GetAdminUserInfo()
748
 	adminUserInfo := c.GetAdminUserInfo()
720
 
749
 
721
 	patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
750
 	patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
740
 		return
769
 		return
741
 	}
770
 	}
742
 	lapsetoType := int64(patientBody["lapseto_type"].(float64))
771
 	lapsetoType := int64(patientBody["lapseto_type"].(float64))
743
-	if lapsetoType <= 0 || lapsetoType > 3 {
744
-		utils.ErrorLog("lapsetoType <= 0 || lapsetoType > 3")
745
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
746
-		return
747
-	}
748
-	lapseto.LapsetoType = lapsetoType
749
 
772
 
750
-	timeLayout := "2006-01-02 15:04:05"
751
-	loc, _ := time.LoadLocation("Local")
773
+	lapseto.LapsetoType = lapsetoType
752
 
774
 
753
 	if patientBody["lapseto_time"] == nil || reflect.TypeOf(patientBody["lapseto_time"]).String() != "string" {
775
 	if patientBody["lapseto_time"] == nil || reflect.TypeOf(patientBody["lapseto_time"]).String() != "string" {
754
 		utils.ErrorLog("lapseto_time")
776
 		utils.ErrorLog("lapseto_time")
756
 		return
778
 		return
757
 	}
779
 	}
758
 	lapsetoTime, _ := patientBody["lapseto_time"].(string)
780
 	lapsetoTime, _ := patientBody["lapseto_time"].(string)
759
-	if len(lapsetoTime) == 0 {
760
-		utils.ErrorLog("len(lapsetoTime) == 0")
761
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSelectLapsetoTime)
762
-		return
763
-	}
781
+	//if len(lapsetoTime) == 0 {
782
+	//	utils.ErrorLog("len(lapsetoTime) == 0")
783
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSelectLapsetoTime)
784
+	//	return
785
+	//}
764
 
786
 
765
 	out_reason, _ := patientBody["out_reason"].(string)
787
 	out_reason, _ := patientBody["out_reason"].(string)
766
 
788
 
771
 	//}
793
 	//}
772
 
794
 
773
 	lapsetoTimeUnix, err := time.ParseInLocation(timeLayout, lapsetoTime, loc)
795
 	lapsetoTimeUnix, err := time.ParseInLocation(timeLayout, lapsetoTime, loc)
774
-	if err != nil {
775
-		utils.ErrorLog("lapsetoTimeUnix")
776
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSelectLapsetoTime)
777
-		return
778
-	}
796
+	//if err != nil {
797
+	//	utils.ErrorLog("lapsetoTimeUnix")
798
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSelectLapsetoTime)
799
+	//	return
800
+	//}
779
 	lapseto.LapsetoTime = lapsetoTimeUnix.Unix()
801
 	lapseto.LapsetoTime = lapsetoTimeUnix.Unix()
780
 	lapseto.UpdatedTime = time.Now().Unix()
802
 	lapseto.UpdatedTime = time.Now().Unix()
781
 	lapseto.CreatedTime = time.Now().Unix()
803
 	lapseto.CreatedTime = time.Now().Unix()
783
 	patient.Lapseto = lapseto.LapsetoType
805
 	patient.Lapseto = lapseto.LapsetoType
784
 	patient.OutReason = out_reason
806
 	patient.OutReason = out_reason
785
 	patient.DeathTime = lapsetoTimeUnix.Unix()
807
 	patient.DeathTime = lapsetoTimeUnix.Unix()
808
+
809
+	patient.PatientStartTime = startTime
810
+	patient.PatientEndTime = endTime
811
+	patient.PatientAddress = patient_address
812
+
786
 	//if patient.Lapseto == 1 {
813
 	//if patient.Lapseto == 1 {
787
 	//	patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
814
 	//	patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
788
 	//	subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
815
 	//	subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
806
 		service.UpdateScheduleItemByPatientId(id)
833
 		service.UpdateScheduleItemByPatientId(id)
807
 	}
834
 	}
808
 
835
 
836
+	allergic := models.XtPatientAllergic{
837
+		UserOrgId:      adminUserInfo.CurrentOrgId,
838
+		PatientId:      patient.ID,
839
+		StartTime:      patient.PatientStartTime,
840
+		EndTime:        patient.PatientEndTime,
841
+		PatientSource:  patient.Lapseto,
842
+		PatientAddress: patient.PatientAddress,
843
+		Remake:         patient.Remark,
844
+		Status:         1,
845
+		Ctime:          time.Now().Unix(),
846
+	}
847
+	if lapseto.LapsetoType == 2 || lapseto.LapsetoType == 3 {
848
+		allergic.StartTime = lapseto.LapsetoTime
849
+		allergic.EndTime = lapseto.LapsetoTime
850
+	}
851
+
852
+	service.CreateAllergic(allergic)
853
+
809
 	if err != nil {
854
 	if err != nil {
810
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEditLapsetoFail)
855
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEditLapsetoFail)
811
 		return
856
 		return

+ 31 - 26
controllers/self_drug_api_congtroller.go 查看文件

3001
 	}
3001
 	}
3002
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3002
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3003
 	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3003
 	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3004
+	storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3004
 	for _, item := range list {
3005
 	for _, item := range list {
3005
 
3006
 
3006
 		//获取期初结余数量
3007
 		//获取期初结余数量
3016
 		}
3017
 		}
3017
 
3018
 
3018
 		//获取期间增加
3019
 		//获取期间增加
3019
-		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3020
+		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3020
 		for _, it := range goodWarehouseInfoList {
3021
 		for _, it := range goodWarehouseInfoList {
3021
 			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3022
 			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3022
 		}
3023
 		}
3023
 
3024
 
3024
 		//获取本期增加
3025
 		//获取本期增加
3025
-		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3026
+		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3026
 		for _, it := range WarehouseInfoFlowList {
3027
 		for _, it := range WarehouseInfoFlowList {
3027
 			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3028
 			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3028
 		}
3029
 		}
3029
 		//获取本期减少
3030
 		//获取本期减少
3030
-		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3031
+		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3031
 		for _, it := range reduceWarehouseInfoList {
3032
 		for _, it := range reduceWarehouseInfoList {
3032
 			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3033
 			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3033
 		}
3034
 		}
3034
 
3035
 
3035
 		//获取期中减少退库
3036
 		//获取期中减少退库
3036
-		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3037
+		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3037
 		for _, it := range lowInfo {
3038
 		for _, it := range lowInfo {
3038
 			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3039
 			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3039
 		}
3040
 		}
3040
 		//
3041
 		//
3041
-		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3042
+		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
3042
 		for _, it := range outInfo {
3043
 		for _, it := range outInfo {
3043
 			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3044
 			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3044
 		}
3045
 		}
3101
 		}
3102
 		}
3102
 
3103
 
3103
 		//期中盘盈
3104
 		//期中盘盈
3104
-		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3105
+		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3105
 		for _, it := range profit {
3106
 		for _, it := range profit {
3106
 			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3107
 			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3107
 		}
3108
 		}
3108
 		//期中盘亏
3109
 		//期中盘亏
3109
-		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3110
+		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3110
 		for _, it := range losses {
3111
 		for _, it := range losses {
3111
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3112
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3112
 		}
3113
 		}
3683
 	manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
3684
 	manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
3684
 
3685
 
3685
 	if orgId == 10265 {
3686
 	if orgId == 10265 {
3687
+		storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3688
+
3686
 		list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3689
 		list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3687
 
3690
 
3688
 		for _, item := range list {
3691
 		for _, item := range list {
3689
 
3692
 
3690
 			//获取期初结余
3693
 			//获取期初结余
3691
-			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3694
+			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
3692
 
3695
 
3693
 			item.GoodStartFlowInfo = low
3696
 			item.GoodStartFlowInfo = low
3694
 
3697
 
3695
 			//获取期末结余
3698
 			//获取期末结余
3696
-			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3699
+			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime, storeConfig.StorehouseOutInfo)
3697
 
3700
 
3698
 			item.GoodEndFlowInfo = flow
3701
 			item.GoodEndFlowInfo = flow
3699
 
3702
 
3700
 			//获取期间增加
3703
 			//获取期间增加
3701
-			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3704
+			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3702
 			for _, it := range goodWarehouseInfoList {
3705
 			for _, it := range goodWarehouseInfoList {
3703
 				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3706
 				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3704
 			}
3707
 			}
3705
 
3708
 
3706
 			//获取本期增加
3709
 			//获取本期增加
3707
-			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3710
+			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3708
 			for _, it := range WarehouseInfoFlowList {
3711
 			for _, it := range WarehouseInfoFlowList {
3709
 				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3712
 				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3710
 			}
3713
 			}
3711
 			//获取本期减少
3714
 			//获取本期减少
3712
-			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3715
+			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3713
 			for _, it := range reduceWarehouseInfoList {
3716
 			for _, it := range reduceWarehouseInfoList {
3714
 				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3717
 				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3715
 			}
3718
 			}
3716
 
3719
 
3717
 			//获取期中减少退库
3720
 			//获取期中减少退库
3718
-			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3721
+			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3719
 			for _, it := range lowInfo {
3722
 			for _, it := range lowInfo {
3720
 				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3723
 				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3721
 			}
3724
 			}
3722
 			//
3725
 			//
3723
-			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3726
+			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
3724
 			for _, it := range outInfo {
3727
 			for _, it := range outInfo {
3725
 				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3728
 				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3726
 			}
3729
 			}
3727
 
3730
 
3728
 			//期中盘盈
3731
 			//期中盘盈
3729
-			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3732
+			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3730
 			for _, it := range profit {
3733
 			for _, it := range profit {
3731
 				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3734
 				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3732
 			}
3735
 			}
3733
 			//期中盘亏
3736
 			//期中盘亏
3734
-			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3737
+			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3735
 			for _, it := range losses {
3738
 			for _, it := range losses {
3736
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3739
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3737
 			}
3740
 			}
3751
 
3754
 
3752
 	if orgId != 10265 {
3755
 	if orgId != 10265 {
3753
 		list, total, err := service.GetGoodNewPurchaseStockQueryOne(good_type, keyword, page, limit, orgId, ids, goodIds)
3756
 		list, total, err := service.GetGoodNewPurchaseStockQueryOne(good_type, keyword, page, limit, orgId, ids, goodIds)
3754
-
3757
+		storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3755
 		for _, item := range list {
3758
 		for _, item := range list {
3756
 
3759
 
3757
 			//获取期初结余
3760
 			//获取期初结余
3758
-			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime)
3761
+			low, _ := service.GetStartLastFLow(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
3759
 
3762
 
3760
 			item.GoodStartFlowInfo = low
3763
 			item.GoodStartFlowInfo = low
3761
 
3764
 
3762
 			//获取期末结余
3765
 			//获取期末结余
3763
-			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime)
3766
+			flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime, storeConfig.StorehouseOutInfo)
3764
 
3767
 
3765
 			item.GoodEndFlowInfo = flow
3768
 			item.GoodEndFlowInfo = flow
3766
 
3769
 
3767
 			//获取期间增加
3770
 			//获取期间增加
3768
-			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime)
3771
+			goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3772
+
3769
 			for _, it := range goodWarehouseInfoList {
3773
 			for _, it := range goodWarehouseInfoList {
3770
 				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3774
 				item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
3771
 			}
3775
 			}
3772
 
3776
 
3773
 			//获取本期增加
3777
 			//获取本期增加
3774
-			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime)
3778
+			WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3779
+
3775
 			for _, it := range WarehouseInfoFlowList {
3780
 			for _, it := range WarehouseInfoFlowList {
3776
 				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3781
 				item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
3777
 			}
3782
 			}
3778
 			//获取本期减少
3783
 			//获取本期减少
3779
-			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime)
3784
+			reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3780
 			for _, it := range reduceWarehouseInfoList {
3785
 			for _, it := range reduceWarehouseInfoList {
3781
 				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3786
 				item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
3782
 			}
3787
 			}
3783
 
3788
 
3784
 			//获取期中减少退库
3789
 			//获取期中减少退库
3785
-			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime)
3790
+			lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3786
 			for _, it := range lowInfo {
3791
 			for _, it := range lowInfo {
3787
 				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3792
 				item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
3788
 			}
3793
 			}
3789
 			//
3794
 			//
3790
-			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime)
3795
+			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
3791
 			for _, it := range outInfo {
3796
 			for _, it := range outInfo {
3792
 				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3797
 				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3793
 			}
3798
 			}
3794
 
3799
 
3795
 			//期中盘盈
3800
 			//期中盘盈
3796
-			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime)
3801
+			profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3797
 			for _, it := range profit {
3802
 			for _, it := range profit {
3798
 				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3803
 				item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
3799
 			}
3804
 			}
3800
 			//期中盘亏
3805
 			//期中盘亏
3801
-			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime)
3806
+			losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
3802
 			for _, it := range losses {
3807
 			for _, it := range losses {
3803
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3808
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3804
 			}
3809
 			}

+ 1 - 0
models/new_stock_models.go 查看文件

232
 	IsRead              int64              `gorm:"column:is_read" json:"is_read" form:"is_read"`
232
 	IsRead              int64              `gorm:"column:is_read" json:"is_read" form:"is_read"`
233
 	OverCount           int64              `gorm:"column:over_count" json:"over_count" form:"over_count"`
233
 	OverCount           int64              `gorm:"column:over_count" json:"over_count" form:"over_count"`
234
 	Ctime               int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
234
 	Ctime               int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
235
+	StorehouseId        int64              `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
235
 	WarehousingInfo     NewWarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
236
 	WarehousingInfo     NewWarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
236
 }
237
 }
237
 
238
 

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

1553
 	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1553
 	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1554
 	WarehousingUnit  string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1554
 	WarehousingUnit  string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1555
 	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1555
 	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1556
+	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1556
 }
1557
 }
1557
 
1558
 
1558
 func (StartWarehousingInfo) TableName() string {
1559
 func (StartWarehousingInfo) TableName() string {

+ 2 - 2
service/patient_service.go 查看文件

768
 
768
 
769
 func CreateAllergic(allergic models.XtPatientAllergic) error {
769
 func CreateAllergic(allergic models.XtPatientAllergic) error {
770
 
770
 
771
-	err := XTWriteDB().Model(&allergic).Create(&allergic).Error
771
+	err := XTWriteDB().Create(&allergic).Error
772
 
772
 
773
 	return err
773
 	return err
774
 }
774
 }
775
 
775
 
776
 func EditPatientLapseto(patient *models.Patients, lapseto *models.PatientLapseto) (err error) {
776
 func EditPatientLapseto(patient *models.Patients, lapseto *models.PatientLapseto) (err error) {
777
 	utx := writeDb.Begin()
777
 	utx := writeDb.Begin()
778
-	err = utx.Model(&models.Patients{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto": patient.Lapseto, "out_reason": patient.OutReason, "death_time": patient.DeathTime}).Error
778
+	err = utx.Model(&models.Patients{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto": patient.Lapseto, "out_reason": patient.OutReason, "death_time": patient.DeathTime, "patient_start_time": patient.PatientStartTime, "patient_end_time": patient.PatientEndTime, "patient_address": patient.PatientAddress}).Error
779
 	//err = utx.Model(&models.PatientLapseto{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto_type": patient.Lapseto, "lapseto_time": time.Now().Unix(), "updated_time": time.Now().Unix()}).Error
779
 	//err = utx.Model(&models.PatientLapseto{}).Where("id=?", patient.ID).Update(map[string]interface{}{"lapseto_type": patient.Lapseto, "lapseto_time": time.Now().Unix(), "updated_time": time.Now().Unix()}).Error
780
 	if err != nil {
780
 	if err != nil {
781
 		utx.Rollback()
781
 		utx.Rollback()

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

1728
 
1728
 
1729
 func CreateScheduleLog(log models.XtScheduleLog) error {
1729
 func CreateScheduleLog(log models.XtScheduleLog) error {
1730
 
1730
 
1731
-	err := XTWriteDB().Create(log).Error
1731
+	err := XTWriteDB().Create(&log).Error
1732
 
1732
 
1733
 	return err
1733
 	return err
1734
 }
1734
 }

+ 33 - 12
service/self_drug_service.go 查看文件

2012
 	return info, err
2012
 	return info, err
2013
 }
2013
 }
2014
 
2014
 
2015
-func GetAddGoodWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.StartWarehousingInfo, err error) {
2015
+func GetAddGoodWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (info []*models.StartWarehousingInfo, err error) {
2016
 	db := XTReadDB().Model(&info).Where("status = 1 and is_check =1")
2016
 	db := XTReadDB().Model(&info).Where("status = 1 and is_check =1")
2017
 	if good_id > 0 {
2017
 	if good_id > 0 {
2018
 		db = db.Where("good_id = ?", good_id)
2018
 		db = db.Where("good_id = ?", good_id)
2026
 	if endtime > 0 {
2026
 	if endtime > 0 {
2027
 		db = db.Where("ctime <=?", endtime)
2027
 		db = db.Where("ctime <=?", endtime)
2028
 	}
2028
 	}
2029
+	if storehouse_id > 0 {
2030
+		db = db.Where("storehouse_id = ?", storehouse_id)
2031
+	}
2029
 	err = db.Find(&info).Error
2032
 	err = db.Find(&info).Error
2030
 	return info, err
2033
 	return info, err
2031
 }
2034
 }
2032
 
2035
 
2033
-func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64) (info []*models.VmStockFlowTwenty, err error) {
2034
-	db := XTReadDB().Model(&info).Where("status = 1 and consumable_type =1")
2036
+func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (info []*models.VmStockFlowTwenty, err error) {
2037
+	db := XTReadDB().Model(&info).Where("status = 1 and (consumable_type =1 or consumable_type = 13)")
2035
 	if good_id > 0 {
2038
 	if good_id > 0 {
2036
 		db = db.Where("good_id = ?", good_id)
2039
 		db = db.Where("good_id = ?", good_id)
2037
 	}
2040
 	}
2044
 	if endtime > 0 {
2047
 	if endtime > 0 {
2045
 		db = db.Where("ctime <=?", endtime)
2048
 		db = db.Where("ctime <=?", endtime)
2046
 	}
2049
 	}
2050
+	if storehouse_id > 0 {
2051
+		db = db.Where("storehouse_id =?", storehouse_id)
2052
+	}
2047
 	err = db.Find(&info).Error
2053
 	err = db.Find(&info).Error
2048
 	return info, err
2054
 	return info, err
2049
 }
2055
 }
2050
 
2056
 
2051
-func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2057
+func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2052
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type= 15)")
2058
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type= 15)")
2053
 	if good_id > 0 {
2059
 	if good_id > 0 {
2054
 		db = db.Where("good_id = ?", good_id)
2060
 		db = db.Where("good_id = ?", good_id)
2062
 	if endtime > 0 {
2068
 	if endtime > 0 {
2063
 		db = db.Where("ctime <=?", endtime)
2069
 		db = db.Where("ctime <=?", endtime)
2064
 	}
2070
 	}
2071
+	if storehouse_id > 0 {
2072
+		db = db.Where("storehouse_id = ?", storehouse_id)
2073
+	}
2065
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2074
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2066
 	return outinfo, err
2075
 	return outinfo, err
2067
 }
2076
 }
2068
 
2077
 
2069
-func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2078
+func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2070
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2079
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2071
 	if good_id > 0 {
2080
 	if good_id > 0 {
2072
 		db = db.Where("good_id = ?", good_id)
2081
 		db = db.Where("good_id = ?", good_id)
2080
 	if endtime > 0 {
2089
 	if endtime > 0 {
2081
 		db = db.Where("ctime <=?", endtime)
2090
 		db = db.Where("ctime <=?", endtime)
2082
 	}
2091
 	}
2092
+	if storehouse_id > 0 {
2093
+		db = db.Where("storehouse_id =?", storehouse_id)
2094
+	}
2083
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2095
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2084
 	return outinfo, err
2096
 	return outinfo, err
2085
 }
2097
 }
2179
 	return info, err
2191
 	return info, err
2180
 }
2192
 }
2181
 
2193
 
2182
-func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2194
+func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64, storehouse_id int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2183
 
2195
 
2184
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type = 15)")
2196
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type = 15)")
2185
 	if good_id > 0 {
2197
 	if good_id > 0 {
2191
 	if startime > 0 {
2203
 	if startime > 0 {
2192
 		db = db.Where("ctime <?", startime)
2204
 		db = db.Where("ctime <?", startime)
2193
 	}
2205
 	}
2206
+	if storehouse_id > 0 {
2207
+		db = db.Where("storehouse_id= ?", storehouse_id)
2208
+	}
2194
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2209
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2195
 	return outinfo, err
2210
 	return outinfo, err
2196
 }
2211
 }
2211
 	return outinfo, err
2226
 	return outinfo, err
2212
 }
2227
 }
2213
 
2228
 
2214
-func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2229
+func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2215
 
2230
 
2216
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2231
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2217
 	if good_id > 0 {
2232
 	if good_id > 0 {
2226
 	if endtime < 0 {
2241
 	if endtime < 0 {
2227
 		db = db.Where("ctime <=?", endtime)
2242
 		db = db.Where("ctime <=?", endtime)
2228
 	}
2243
 	}
2244
+	if storehouse_id > 0 {
2245
+		db = db.Where("storehouse_id = ?", storehouse_id)
2246
+	}
2229
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2247
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2230
 	return outinfo, err
2248
 	return outinfo, err
2231
 }
2249
 }
2232
 
2250
 
2233
-func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2251
+func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, endtime int64, storehouse_id int64) (outinfo []*models.VmStockFlowTwenty, err error) {
2234
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2252
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2235
 	if good_id > 0 {
2253
 	if good_id > 0 {
2236
 		db = db.Where("good_id = ?", good_id)
2254
 		db = db.Where("good_id = ?", good_id)
2244
 	if endtime < 0 {
2262
 	if endtime < 0 {
2245
 		db = db.Where("ctime <=?", endtime)
2263
 		db = db.Where("ctime <=?", endtime)
2246
 	}
2264
 	}
2265
+	if storehouse_id > 0 {
2266
+		db = db.Where("storehouse_id = ?", storehouse_id)
2267
+	}
2247
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2268
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2248
 	return outinfo, err
2269
 	return outinfo, err
2249
 }
2270
 }
2645
 	return goodinfo, total, err
2666
 	return goodinfo, total, err
2646
 }
2667
 }
2647
 
2668
 
2648
-func GetStartLastFLow(goodid int64, orgid int64, startime int64) (models.VmStockFlowTwenty, error) {
2669
+func GetStartLastFLow(goodid int64, orgid int64, startime int64, storehouse_id int64) (models.VmStockFlowTwenty, error) {
2649
 
2670
 
2650
 	flwo := models.VmStockFlowTwenty{}
2671
 	flwo := models.VmStockFlowTwenty{}
2651
-	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime < ?", goodid, orgid, startime).Last(&flwo).Error
2672
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime < ? and storehouse_id = ?", goodid, orgid, startime, storehouse_id).Last(&flwo).Error
2652
 	return flwo, err
2673
 	return flwo, err
2653
 }
2674
 }
2654
 
2675
 
2655
-func GetEndLastFlow(goodid int64, orgid int64, endtime int64) (models.VmStockFlowTwenty, error) {
2676
+func GetEndLastFlow(goodid int64, orgid int64, endtime int64, storehouse_id int64) (models.VmStockFlowTwenty, error) {
2656
 	flwo := models.VmStockFlowTwenty{}
2677
 	flwo := models.VmStockFlowTwenty{}
2657
-	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime <= ?", goodid, orgid, endtime).Last(&flwo).Error
2678
+	err := XTReadDB().Where("good_id = ? and user_org_id = ? and status = 1 and ctime <= ? and storehouse_id= ?", goodid, orgid, endtime, storehouse_id).Last(&flwo).Error
2658
 	return flwo, err
2679
 	return flwo, err
2659
 }
2680
 }
2660
 
2681