Browse Source

历史排班

28169 1 year ago
parent
commit
718404a004

+ 6 - 0
controllers/dialysis_api_controller.go View File

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

+ 2 - 2
controllers/doctor_schedule_api_controller.go View File

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

+ 7 - 8
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

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

+ 63 - 18
controllers/patient_api_controller.go View File

@@ -716,6 +716,35 @@ func (c *PatientApiController) EditLapseto() {
716 716
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
717 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 748
 	adminUserInfo := c.GetAdminUserInfo()
720 749
 
721 750
 	patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
@@ -740,15 +769,8 @@ func (c *PatientApiController) EditLapseto() {
740 769
 		return
741 770
 	}
742 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 775
 	if patientBody["lapseto_time"] == nil || reflect.TypeOf(patientBody["lapseto_time"]).String() != "string" {
754 776
 		utils.ErrorLog("lapseto_time")
@@ -756,11 +778,11 @@ func (c *PatientApiController) EditLapseto() {
756 778
 		return
757 779
 	}
758 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 787
 	out_reason, _ := patientBody["out_reason"].(string)
766 788
 
@@ -771,11 +793,11 @@ func (c *PatientApiController) EditLapseto() {
771 793
 	//}
772 794
 
773 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 801
 	lapseto.LapsetoTime = lapsetoTimeUnix.Unix()
780 802
 	lapseto.UpdatedTime = time.Now().Unix()
781 803
 	lapseto.CreatedTime = time.Now().Unix()
@@ -783,6 +805,11 @@ func (c *PatientApiController) EditLapseto() {
783 805
 	patient.Lapseto = lapseto.LapsetoType
784 806
 	patient.OutReason = out_reason
785 807
 	patient.DeathTime = lapsetoTimeUnix.Unix()
808
+
809
+	patient.PatientStartTime = startTime
810
+	patient.PatientEndTime = endTime
811
+	patient.PatientAddress = patient_address
812
+
786 813
 	//if patient.Lapseto == 1 {
787 814
 	//	patientTotal := service.GetLapsetoPatientCount(adminUserInfo.CurrentOrgId, 1)
788 815
 	//	subscibes := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
@@ -806,6 +833,24 @@ func (c *PatientApiController) EditLapseto() {
806 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 854
 	if err != nil {
810 855
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEditLapsetoFail)
811 856
 		return

+ 31 - 26
controllers/self_drug_api_congtroller.go View File

@@ -3001,6 +3001,7 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
3001 3001
 	}
3002 3002
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3003 3003
 	list, total, err := service.GetGoodPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3004
+	storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3004 3005
 	for _, item := range list {
3005 3006
 
3006 3007
 		//获取期初结余数量
@@ -3016,29 +3017,29 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
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 3021
 		for _, it := range goodWarehouseInfoList {
3021 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 3027
 		for _, it := range WarehouseInfoFlowList {
3027 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 3032
 		for _, it := range reduceWarehouseInfoList {
3032 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 3038
 		for _, it := range lowInfo {
3038 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 3043
 		for _, it := range outInfo {
3043 3044
 			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
3044 3045
 		}
@@ -3101,12 +3102,12 @@ func (this *SelfDrugApiController) GetGoodPurchaseStockQuery() {
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 3106
 		for _, it := range profit {
3106 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 3111
 		for _, it := range losses {
3111 3112
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3112 3113
 		}
@@ -3683,55 +3684,57 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3683 3684
 	manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
3684 3685
 
3685 3686
 	if orgId == 10265 {
3687
+		storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3688
+
3686 3689
 		list, total, err := service.GetGoodNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, ids, goodIds)
3687 3690
 
3688 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 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 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 3705
 			for _, it := range goodWarehouseInfoList {
3703 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 3711
 			for _, it := range WarehouseInfoFlowList {
3709 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 3716
 			for _, it := range reduceWarehouseInfoList {
3714 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 3722
 			for _, it := range lowInfo {
3720 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 3727
 			for _, it := range outInfo {
3725 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 3733
 			for _, it := range profit {
3731 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 3738
 			for _, it := range losses {
3736 3739
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3737 3740
 			}
@@ -3751,54 +3754,56 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
3751 3754
 
3752 3755
 	if orgId != 10265 {
3753 3756
 		list, total, err := service.GetGoodNewPurchaseStockQueryOne(good_type, keyword, page, limit, orgId, ids, goodIds)
3754
-
3757
+		storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
3755 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 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 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 3773
 			for _, it := range goodWarehouseInfoList {
3770 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 3780
 			for _, it := range WarehouseInfoFlowList {
3776 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 3785
 			for _, it := range reduceWarehouseInfoList {
3781 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 3791
 			for _, it := range lowInfo {
3787 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 3796
 			for _, it := range outInfo {
3792 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 3802
 			for _, it := range profit {
3798 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 3807
 			for _, it := range losses {
3803 3808
 				item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3804 3809
 			}

+ 1 - 0
models/new_stock_models.go View File

@@ -232,6 +232,7 @@ type VmStockFlowTwenty struct {
232 232
 	IsRead              int64              `gorm:"column:is_read" json:"is_read" form:"is_read"`
233 233
 	OverCount           int64              `gorm:"column:over_count" json:"over_count" form:"over_count"`
234 234
 	Ctime               int64              `gorm:"column:ctime" json:"ctime" form:"ctime"`
235
+	StorehouseId        int64              `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
235 236
 	WarehousingInfo     NewWarehousingInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehousingId" json:"xt_warehouse_info"`
236 237
 }
237 238
 

+ 1 - 0
models/stock_models.go View File

@@ -1553,6 +1553,7 @@ type StartWarehousingInfo struct {
1553 1553
 	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1554 1554
 	WarehousingUnit  string  `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1555 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 1559
 func (StartWarehousingInfo) TableName() string {

+ 2 - 2
service/patient_service.go View File

@@ -768,14 +768,14 @@ func CreatePatientsNew(patientsNew *models.XtPatientsNew) error {
768 768
 
769 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 773
 	return err
774 774
 }
775 775
 
776 776
 func EditPatientLapseto(patient *models.Patients, lapseto *models.PatientLapseto) (err error) {
777 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 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 780
 	if err != nil {
781 781
 		utx.Rollback()

+ 1 - 1
service/schedule_service.go View File

@@ -1728,7 +1728,7 @@ func GetNumberListById(id int64, org_id int64) (number []*models.DeviceNumber, e
1728 1728
 
1729 1729
 func CreateScheduleLog(log models.XtScheduleLog) error {
1730 1730
 
1731
-	err := XTWriteDB().Create(log).Error
1731
+	err := XTWriteDB().Create(&log).Error
1732 1732
 
1733 1733
 	return err
1734 1734
 }

+ 33 - 12
service/self_drug_service.go View File

@@ -2012,7 +2012,7 @@ func GetEndGoodWarehouseInfoList(good_id int64, orgid int64, endtime int64) (inf
2012 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 2016
 	db := XTReadDB().Model(&info).Where("status = 1 and is_check =1")
2017 2017
 	if good_id > 0 {
2018 2018
 		db = db.Where("good_id = ?", good_id)
@@ -2026,12 +2026,15 @@ func GetAddGoodWarehouseInfoList(good_id int64, orgid int64, startime int64, end
2026 2026
 	if endtime > 0 {
2027 2027
 		db = db.Where("ctime <=?", endtime)
2028 2028
 	}
2029
+	if storehouse_id > 0 {
2030
+		db = db.Where("storehouse_id = ?", storehouse_id)
2031
+	}
2029 2032
 	err = db.Find(&info).Error
2030 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 2038
 	if good_id > 0 {
2036 2039
 		db = db.Where("good_id = ?", good_id)
2037 2040
 	}
@@ -2044,11 +2047,14 @@ func GetAddStartFlow(good_id int64, orgid int64, startime int64, endtime int64)
2044 2047
 	if endtime > 0 {
2045 2048
 		db = db.Where("ctime <=?", endtime)
2046 2049
 	}
2050
+	if storehouse_id > 0 {
2051
+		db = db.Where("storehouse_id =?", storehouse_id)
2052
+	}
2047 2053
 	err = db.Find(&info).Error
2048 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 2058
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type= 15)")
2053 2059
 	if good_id > 0 {
2054 2060
 		db = db.Where("good_id = ?", good_id)
@@ -2062,11 +2068,14 @@ func GetReduceWarehouseInfoList(good_id int64, orgid int64, startime int64, endt
2062 2068
 	if endtime > 0 {
2063 2069
 		db = db.Where("ctime <=?", endtime)
2064 2070
 	}
2071
+	if storehouse_id > 0 {
2072
+		db = db.Where("storehouse_id = ?", storehouse_id)
2073
+	}
2065 2074
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2066 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 2079
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 7)")
2071 2080
 	if good_id > 0 {
2072 2081
 		db = db.Where("good_id = ?", good_id)
@@ -2080,6 +2089,9 @@ func GetStartEndCancelFLowInfo(good_id int64, orgid int64, startime int64, endti
2080 2089
 	if endtime > 0 {
2081 2090
 		db = db.Where("ctime <=?", endtime)
2082 2091
 	}
2092
+	if storehouse_id > 0 {
2093
+		db = db.Where("storehouse_id =?", storehouse_id)
2094
+	}
2083 2095
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2084 2096
 	return outinfo, err
2085 2097
 }
@@ -2179,7 +2191,7 @@ func FindEndCancelInfo(good_id int64, orgid int64, endtime int64) (info []*model
2179 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 2196
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 2 or consumable_type = 3 or consumable_type = 15)")
2185 2197
 	if good_id > 0 {
@@ -2191,6 +2203,9 @@ func FindeWarehouseOutInfo(good_id int64, orgid int64, startime int64) (outinfo
2191 2203
 	if startime > 0 {
2192 2204
 		db = db.Where("ctime <?", startime)
2193 2205
 	}
2206
+	if storehouse_id > 0 {
2207
+		db = db.Where("storehouse_id= ?", storehouse_id)
2208
+	}
2194 2209
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2195 2210
 	return outinfo, err
2196 2211
 }
@@ -2211,7 +2226,7 @@ func FindeStartStockInventoryProfit(good_id int64, orgid int64, startime int64)
2211 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 2231
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 10)")
2217 2232
 	if good_id > 0 {
@@ -2226,11 +2241,14 @@ func FindeEndStokInventoryProfit(good_id int64, orgid int64, startime int64, end
2226 2241
 	if endtime < 0 {
2227 2242
 		db = db.Where("ctime <=?", endtime)
2228 2243
 	}
2244
+	if storehouse_id > 0 {
2245
+		db = db.Where("storehouse_id = ?", storehouse_id)
2246
+	}
2229 2247
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2230 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 2252
 	db := XTReadDB().Model(&outinfo).Where("status = 1 and (consumable_type = 11)")
2235 2253
 	if good_id > 0 {
2236 2254
 		db = db.Where("good_id = ?", good_id)
@@ -2244,6 +2262,9 @@ func FindeEndStockInventoryLosses(good_id int64, orgid int64, startime int64, en
2244 2262
 	if endtime < 0 {
2245 2263
 		db = db.Where("ctime <=?", endtime)
2246 2264
 	}
2265
+	if storehouse_id > 0 {
2266
+		db = db.Where("storehouse_id = ?", storehouse_id)
2267
+	}
2247 2268
 	err = db.Preload("WarehousingInfo", "org_id = ? and status = 1", orgid).Find(&outinfo).Error
2248 2269
 	return outinfo, err
2249 2270
 }
@@ -2645,16 +2666,16 @@ func GetGoodNewPurchaseStockQueryOne(good_type int64, keyword string, page int64
2645 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 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 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 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 2679
 	return flwo, err
2659 2680
 }
2660 2681