Pārlūkot izejas kodu

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

csx 3 gadus atpakaļ
vecāks
revīzija
cea8cbea11

+ 131 - 45
controllers/schedule_api_controller.go Parādīt failu

@@ -68,6 +68,7 @@ func ScheduleApiRegistRouters() {
68 68
 	beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
69 69
 	beego.Router("/api/schedule/getnextweekpanels", &ScheduleApiController{}, "Get:GetNextWeekPanels")
70 70
 	beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
71
+	beego.Router("/api/schedule/getpatientscheduletemplate", &ScheduleApiController{}, "Get:GetPatientScheduleTempalate")
71 72
 }
72 73
 
73 74
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -1959,6 +1960,7 @@ func (c *ScheduleApiController) GetInitExcelInitDate() {
1959 1960
 		theDay := thisTime2.AddDate(0, 0, index)
1960 1961
 		days = append(days, theDay.Format("2006-01-02"))
1961 1962
 	}
1963
+
1962 1964
 	c.ServeSuccessJSON(map[string]interface{}{
1963 1965
 		"days": days,
1964 1966
 	})
@@ -2746,65 +2748,140 @@ func (c *ScheduleApiController) SynchroSchedule() {
2746 2748
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2747 2749
 	//根据模板ID获取模板数据
2748 2750
 	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
2749
-	//清空该时间段的所有排班数据
2750
-	service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
2751 2751
 
2752
+	recordDateStr := time.Now().Format("2006-01-02")
2753
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
2754
+
2755
+	nowtime := recordDate.Unix()
2756
+	fmt.Println("今日时间", nowtime)
2757
+	fmt.Println("后期日期", copy_startime)
2752 2758
 	var tuesday int64
2753 2759
 	var wednesday int64
2754 2760
 	var thursday int64
2755 2761
 	var friday int64
2756 2762
 	var saturday int64
2757 2763
 
2758
-	tuesday = copy_startime + 86400
2759
-	wednesday = copy_startime + 172800
2760
-	thursday = copy_startime + 259200
2761
-	friday = copy_startime + 345600
2762
-	saturday = copy_startime + 432000
2764
+	//如果选择的开始日期大于当前日期
2765
+	if copy_startime > nowtime {
2766
+		//清空该时间段的所有排班数据
2767
+		service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
2763 2768
 
2764
-	for _, item := range list {
2765
-		if item.Weekday == 1 {
2766
-			item.ScheduleDate = copy_startime
2767
-		}
2768
-		if item.Weekday == 2 {
2769
-			item.ScheduleDate = tuesday
2770
-		}
2771
-		if item.Weekday == 3 {
2772
-			item.ScheduleDate = wednesday
2773
-		}
2774
-		if item.Weekday == 4 {
2775
-			item.ScheduleDate = thursday
2776
-		}
2777
-		if item.Weekday == 5 {
2778
-			item.ScheduleDate = friday
2779
-		}
2780
-		if item.Weekday == 6 {
2781
-			item.ScheduleDate = saturday
2782
-		}
2783
-		if item.Weekday == 7 {
2784
-			item.ScheduleDate = copy_endtime
2769
+		tuesday = copy_startime + 86400
2770
+		wednesday = copy_startime + 172800
2771
+		thursday = copy_startime + 259200
2772
+		friday = copy_startime + 345600
2773
+		saturday = copy_startime + 432000
2774
+
2775
+		for _, item := range list {
2776
+			if item.Weekday == 1 {
2777
+				item.ScheduleDate = copy_startime
2778
+			}
2779
+			if item.Weekday == 2 {
2780
+				item.ScheduleDate = tuesday
2781
+			}
2782
+			if item.Weekday == 3 {
2783
+				item.ScheduleDate = wednesday
2784
+			}
2785
+			if item.Weekday == 4 {
2786
+				item.ScheduleDate = thursday
2787
+			}
2788
+			if item.Weekday == 5 {
2789
+				item.ScheduleDate = friday
2790
+			}
2791
+			if item.Weekday == 6 {
2792
+				item.ScheduleDate = saturday
2793
+			}
2794
+			if item.Weekday == 7 {
2795
+				item.ScheduleDate = copy_endtime
2796
+			}
2797
+
2798
+			//根据床位号获取区号
2799
+			number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
2800
+			item.ZoneId = number.ZoneID
2785 2801
 		}
2786 2802
 
2787
-		//根据床位号获取区号
2788
-		number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
2789
-		item.ZoneId = number.ZoneID
2803
+		for _, item := range list {
2804
+			schedule := models.XtSchedule{
2805
+				UserOrgId:    orgId,
2806
+				PartitionId:  item.ZoneId,
2807
+				BedId:        item.DeviceNumberID,
2808
+				PatientId:    item.PatientID,
2809
+				ScheduleDate: item.ScheduleDate,
2810
+				ScheduleType: item.TimeType,
2811
+				ScheduleWeek: item.Weekday,
2812
+				ModeId:       item.TreatMode,
2813
+				Status:       1,
2814
+				CreatedTime:  time.Now().Unix(),
2815
+				UpdatedTime:  0,
2816
+			}
2817
+
2818
+			service.CreatePatientSchedule(&schedule)
2819
+		}
2790 2820
 	}
2821
+	//如果选择的日期小于当前日期,只同步今日以后的数据
2822
+	if copy_startime <= nowtime {
2823
+		//清空今日以后的数据
2824
+		service.DeletePatientScheduleToday(nowtime, copy_endtime, orgId)
2825
+		var tuesday int64
2826
+		var wednesday int64
2827
+		var thursday int64
2828
+		var friday int64
2829
+		var saturday int64
2830
+
2831
+		tuesday = copy_startime + 86400
2832
+		wednesday = copy_startime + 172800
2833
+		thursday = copy_startime + 259200
2834
+		friday = copy_startime + 345600
2835
+		saturday = copy_startime + 432000
2836
+
2837
+		for _, item := range list {
2838
+			if item.Weekday == 1 {
2839
+				item.ScheduleDate = copy_startime
2840
+			}
2841
+			if item.Weekday == 2 {
2842
+				item.ScheduleDate = tuesday
2843
+			}
2844
+			if item.Weekday == 3 {
2845
+				item.ScheduleDate = wednesday
2846
+			}
2847
+			if item.Weekday == 4 {
2848
+				item.ScheduleDate = thursday
2849
+			}
2850
+			if item.Weekday == 5 {
2851
+				item.ScheduleDate = friday
2852
+			}
2853
+			if item.Weekday == 6 {
2854
+				item.ScheduleDate = saturday
2855
+			}
2856
+			if item.Weekday == 7 {
2857
+				item.ScheduleDate = copy_endtime
2858
+			}
2791 2859
 
2792
-	for _, item := range list {
2793
-		schedule := models.XtSchedule{
2794
-			UserOrgId:    orgId,
2795
-			PartitionId:  item.ZoneId,
2796
-			BedId:        item.DeviceNumberID,
2797
-			PatientId:    item.PatientID,
2798
-			ScheduleDate: item.ScheduleDate,
2799
-			ScheduleType: item.TimeType,
2800
-			ScheduleWeek: item.Weekday,
2801
-			ModeId:       item.TreatMode,
2802
-			Status:       1,
2803
-			CreatedTime:  time.Now().Unix(),
2804
-			UpdatedTime:  0,
2860
+			//根据床位号获取区号
2861
+			number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
2862
+			item.ZoneId = number.ZoneID
2863
+		}
2864
+
2865
+		for _, item := range list {
2866
+			// 同步今日以后的数据
2867
+			if item.ScheduleDate > nowtime {
2868
+				schedule := models.XtSchedule{
2869
+					UserOrgId:    orgId,
2870
+					PartitionId:  item.ZoneId,
2871
+					BedId:        item.DeviceNumberID,
2872
+					PatientId:    item.PatientID,
2873
+					ScheduleDate: item.ScheduleDate,
2874
+					ScheduleType: item.TimeType,
2875
+					ScheduleWeek: item.Weekday,
2876
+					ModeId:       item.TreatMode,
2877
+					Status:       1,
2878
+					CreatedTime:  time.Now().Unix(),
2879
+					UpdatedTime:  0,
2880
+				}
2881
+				service.CreatePatientSchedule(&schedule)
2882
+			}
2805 2883
 		}
2806 2884
 
2807
-		service.CreatePatientSchedule(&schedule)
2808 2885
 	}
2809 2886
 
2810 2887
 	returnData := make(map[string]interface{}, 0)
@@ -2812,3 +2889,12 @@ func (c *ScheduleApiController) SynchroSchedule() {
2812 2889
 	c.ServeSuccessJSON(returnData)
2813 2890
 	return
2814 2891
 }
2892
+
2893
+func (c *ScheduleApiController) GetPatientScheduleTempalate() {
2894
+
2895
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2896
+	tempalate, _ := service.GetPatientScheduleTempalate(orgId)
2897
+	c.ServeSuccessJSON(map[string]interface{}{
2898
+		"schedule": tempalate,
2899
+	})
2900
+}

+ 1 - 0
models/self_drug_models.go Parādīt failu

@@ -568,6 +568,7 @@ type BloodDrugWarehouseOutInfo struct {
568 568
 	MinNumber               int64   `json:"min_number"`
569 569
 	Dose                    float64 `json:"dose"`
570 570
 	DoseUnit                string  `json:"dose_unit"`
571
+	LastPrice               float64 `json:"last_price"`
571 572
 }
572 573
 
573 574
 type XtMonitorConfig struct {

+ 1 - 0
models/stock_models.go Parādīt failu

@@ -1084,6 +1084,7 @@ type SgjWarehouseOutInfo struct {
1084 1084
 	PackingUnit             string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1085 1085
 	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1086 1086
 	PackingPrice            float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1087
+	BuyPrice                float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
1087 1088
 }
1088 1089
 
1089 1090
 type SgjCancelStockInfo struct {

+ 2 - 2
service/gobal_config_service.go Parādīt failu

@@ -351,9 +351,9 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
351 351
 	}
352 352
 
353 353
 	if manufacturerId > 0 {
354
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
354
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Where("t.manufacturer = ?", manufacturerId).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
355 355
 	} else {
356
-		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
356
+		err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,b.drug_name,b.drug_spec,b.drug_type,b.min_unit,b.max_unit,b.min_number,b.dose,b.dose_unit,b.last_price,t.creater").Joins("left join xt_base_drug as b on b.id = x.drug_id and b.org_id = ? and b.status =1", orgid).Joins("left join xt_drug_warehouse_out as t on t.id = x.warehouse_out_id and t.org_id = ? and t.status  =1", orgid).Order("x.ctime desc").Count(&total).Offset(offset).Limit(limit).Scan(&outinfo).Error
357 357
 	}
358 358
 
359 359
 	return outinfo, total, err

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Parādīt failu

@@ -285,7 +285,7 @@ func GetWarehouseOutInfoPrintList(orgid int64, startime int64, endtime int64) (o
285 285
 	if endtime > 0 {
286 286
 		db = db.Where("x.ctime<=?", endtime)
287 287
 	}
288
-	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
288
+	err = db.Select("x.patient_id,x.sys_record_time,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price,t.buy_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&out).Error
289 289
 	return out, err
290 290
 }
291 291
 

+ 14 - 0
service/schedule_service.go Parādīt failu

@@ -1022,6 +1022,13 @@ func DeletePatientSchedule(startime int64, endtime int64, org_id int64) (models.
1022 1022
 	return schedule, err
1023 1023
 }
1024 1024
 
1025
+func DeletePatientScheduleToday(startime int64, endtime int64, org_id int64) (models.XtSchedule, error) {
1026
+
1027
+	schedule := models.XtSchedule{}
1028
+	err := XTWriteDB().Model(&schedule).Where("schedule_date>? and schedule_date<=? and user_org_id = ? and status = 1", startime, endtime, org_id).Updates(map[string]interface{}{"status": 0}).Error
1029
+	return schedule, err
1030
+}
1031
+
1025 1032
 func GetBedNumberById(id int64, org_id int64) (models.DeviceNumber, error) {
1026 1033
 
1027 1034
 	number := models.DeviceNumber{}
@@ -1037,3 +1044,10 @@ func CreatePatientSchedule(schedule *models.XtSchedule) error {
1037 1044
 	utx.Commit()
1038 1045
 	return err
1039 1046
 }
1047
+
1048
+func GetPatientScheduleTempalate(orgid int64) (models.PatientScheduleTemplateMode, error) {
1049
+
1050
+	mode := models.PatientScheduleTemplateMode{}
1051
+	err := XTReadDB().Where("org_id = ? and status =1", orgid).Find(&mode).Error
1052
+	return mode, err
1053
+}