Bläddra i källkod

11月9日库存管理

XMLWAN 1 år sedan
förälder
incheckning
a041560f55

+ 1 - 1
conf/app.conf Visa fil

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

+ 1 - 1
controllers/dialysis_api_controller.go Visa fil

@@ -2968,7 +2968,7 @@ func (c *DialysisApiController) GetDialysisOrder() {
2968 2968
 	}
2969 2969
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
2970 2970
 
2971
-		if xttime <= 1640966400 {
2971
+		if xttime <= 1672416000 {
2972 2972
 			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2973 2973
 			patientInfo.TotalDialysis = dialysis_count
2974 2974
 		}

+ 20 - 1
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Visa fil

@@ -2873,6 +2873,25 @@ func (this *NewDialysisApiController) GetTreateSummary() {
2873 2873
 func (this *NewDialysisApiController) CommitDialysisOrder() {
2874 2874
 
2875 2875
 	org_id := this.GetMobileAdminUserInfo().Org.Id
2876
-	fmt.Println("org_id ===23232323232332", org_id)
2876
+
2877
+	//查询所有患者
2878
+
2879
+	list, err := service.GetAllPatientScheduleList(org_id)
2880
+
2881
+	for _, item := range list {
2882
+		//查询所有患者的2022年12月31日以前的上机记录
2883
+		orderList, _ := service.GetAllDialysiOrderList(item.ID, org_id)
2884
+		for _, it := range orderList {
2885
+			dialysOrder, _ := service.GetDialysisTotalCountThree(it.UserOrgId, it.PatientId, it.DialysisDate)
2886
+			service.UpdateDialysisOrderSix(it.PatientId, it.DialysisDate, it.UserOrgId, dialysOrder.Count)
2887
+		}
2888
+	}
2889
+
2890
+	if err == nil {
2891
+		this.ServeSuccessJSON(map[string]interface{}{
2892
+			"list": list,
2893
+		})
2894
+		return
2895
+	}
2877 2896
 
2878 2897
 }

+ 67 - 1
controllers/schedule_api_controller.go Visa fil

@@ -63,6 +63,7 @@ func ScheduleApiRegistRouters() {
63 63
 
64 64
 	beego.Router("/api/schedule/weekpanelone", &ScheduleApiController{}, "Get:GetWeekPanelsOne")
65 65
 	beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
66
+	beego.Router("/api/schedule/scheduletwo", &ScheduleApiController{}, "Get:GetScheduleTwo")
66 67
 	beego.Router("/api/schedule/postscheduletemplate", &ScheduleApiController{}, "Get:SaveScheduleTemplate")
67 68
 	beego.Router("/api/schedule/getscheduletemplate", &ScheduleApiController{}, "Get:GetScheduleTemplate")
68 69
 	beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
@@ -3994,6 +3995,72 @@ func (c *ScheduleApiController) GetScheduleOne() {
3994 3995
 	return
3995 3996
 }
3996 3997
 
3998
+func (c *ScheduleApiController) GetScheduleTwo() {
3999
+
4000
+	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
4001
+	patitionIdStr := c.GetString("patitionid")
4002
+
4003
+	ids := strings.Split(patitionIdStr, ",")
4004
+
4005
+	schedule_type, _ := c.GetInt64("schedule_type")
4006
+
4007
+	adminInfo := c.GetAdminUserInfo()
4008
+	weekDateStr := c.GetString("week_date")
4009
+	WeekDayIds := strings.Split(weekDateStr, ",")
4010
+
4011
+	thisTime := time.Now()
4012
+	today := thisTime.Format("2006-01-02")
4013
+	if week < 1 || week > 4 {
4014
+		week = 2
4015
+	}
4016
+	if week == 1 {
4017
+		thisTime = thisTime.AddDate(0, 0, -7)
4018
+	} else if week == 3 {
4019
+		thisTime = thisTime.AddDate(0, 0, 7)
4020
+	} else if week == 4 {
4021
+		thisTime = thisTime.AddDate(0, 0, 14)
4022
+	}
4023
+
4024
+	weekDay := int(thisTime.Weekday())
4025
+	if weekDay == 0 {
4026
+		weekDay = 7
4027
+	}
4028
+	weekEnd := 7 - weekDay
4029
+	weekStart := weekEnd - 6
4030
+	weekTitle := make([]string, 0)
4031
+	days := make([]string, 0)
4032
+	for index := weekStart; index <= weekEnd; index++ {
4033
+		theDay := thisTime.AddDate(0, 0, index)
4034
+		indexYear, indexMonthTime, indexDay := theDay.Date()
4035
+		indexMonth := int(indexMonthTime)
4036
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
4037
+		weekTitle = append(weekTitle, indexWeek)
4038
+		days = append(days, theDay.Format("2006-01-02"))
4039
+	}
4040
+
4041
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
4042
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
4043
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
4044
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
4045
+
4046
+	timeLayout := "2006-01-02 15:04:05"
4047
+	loc, _ := time.LoadLocation("Local")
4048
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
4049
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
4050
+	weekStartPoint := theStarTime.Unix()
4051
+	weekEndPoint := theEndTime.Unix()
4052
+
4053
+	schdules, _ := service.GetWeekScheduleThree(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type, WeekDayIds)
4054
+
4055
+	c.ServeSuccessJSON(map[string]interface{}{
4056
+		"days":      days,
4057
+		"weekTitle": weekTitle,
4058
+		"schdules":  schdules,
4059
+		"today":     today,
4060
+	})
4061
+	return
4062
+}
4063
+
3997 4064
 func (c *ScheduleApiController) SaveScheduleTemplate() {
3998 4065
 
3999 4066
 	template_id, _ := c.GetInt64("template_id")
@@ -4043,7 +4110,6 @@ func (c *ScheduleApiController) ChangeFuncPrint() {
4043 4110
 	}
4044 4111
 
4045 4112
 	_, errcode := service.GetDataPrintByOrgId(orgId)
4046
-	fmt.Println("errcode222234444555556t66", errcode)
4047 4113
 	if errcode == gorm.ErrRecordNotFound {
4048 4114
 		service.CreateDataPrint(&dataPrint)
4049 4115
 		c.ServeSuccessJSON(map[string]interface{}{

+ 33 - 0
service/patientmanage_service.go Visa fil

@@ -1879,3 +1879,36 @@ func DeleteHospitalSummary(id []string) error {
1879 1879
 	err := XTWriteDB().Model(models.XtHospitalSummary{}).Where("id in (?) and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1880 1880
 	return err
1881 1881
 }
1882
+
1883
+func GetAllPatientScheduleList(org_id int64) (patient []*models.PatientsThirty, err error) {
1884
+
1885
+	err = XTReadDB().Where("user_org_id = ? and status = 1", org_id).Find(&patient).Error
1886
+
1887
+	return patient, err
1888
+}
1889
+
1890
+func GetAllDialysiOrderList(patient_id int64, org_id int64) (order []*models.DialysisOrder, err error) {
1891
+
1892
+	err = XTReadDB().Where("patient_id = ? and user_org_id = ? and status= 1 and dialysis_date<=1672416000", patient_id, org_id).Find(&order).Error
1893
+
1894
+	return order, err
1895
+}
1896
+
1897
+func GetDialysisTotalCountThree(org_id int64, patient_id int64, dialysis_date int64) (models.BloodDialysisOrderCount, error) {
1898
+
1899
+	order := models.BloodDialysisOrderCount{}
1900
+	db := XTReadDB().Table("xt_dialysis_order as o")
1901
+
1902
+	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule as x on x.patient_id = o.patient_id where o.status =1 and o.user_org_id = ? and o.patient_id = ? and o.dialysis_date<=? and  x.schedule_date = o.dialysis_date and x.status = 1 ", org_id, patient_id, dialysis_date).Scan(&order).Error
1903
+
1904
+	return order, err
1905
+}
1906
+
1907
+func UpdateDialysisOrderSix(patient_id int64, dialysis_date int64, user_org_id int64, dialysis_total int64) (models.DialysisOrder, error) {
1908
+
1909
+	order := models.DialysisOrder{}
1910
+
1911
+	err := XTWriteDB().Model(&order).Where("patient_id = ? and dialysis_date = ? and user_org_id = ? and status = 1", patient_id, dialysis_date, user_org_id).Updates(map[string]interface{}{"dialysis_total": dialysis_total}).Error
1912
+
1913
+	return order, err
1914
+}

+ 22 - 1
service/schedule_service.go Visa fil

@@ -114,7 +114,6 @@ func GetWeekScheduleOne(orgID int64, start, end int64, partionid int64, schedule
114 114
 func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, scheduletype int64) (schedules []*models.Schedule, err error) {
115 115
 
116 116
 	db := readDb.Table("xt_schedule as s")
117
-	fmt.Println("schIds2222222")
118 117
 	if len(schIds) > 0 {
119 118
 		db = db.Where("s.partition_id in (?)", schIds)
120 119
 	}
@@ -130,6 +129,28 @@ func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, schedule
130 129
 	return
131 130
 }
132 131
 
132
+func GetWeekScheduleThree(orgID int64, start, end int64, schIds []string, scheduletype int64, WeekDayIds []string) (schedules []*models.Schedule, err error) {
133
+
134
+	db := readDb.Table("xt_schedule as s")
135
+
136
+	if len(schIds) > 0 {
137
+		db = db.Where("s.partition_id in (?)", schIds)
138
+	}
139
+	if scheduletype > 0 {
140
+		db = db.Where("s.schedule_type = ?", scheduletype)
141
+	}
142
+	if len(WeekDayIds) > 0 {
143
+		db = db.Where("s.schedule_week in(?)", WeekDayIds)
144
+	}
145
+	err = db.Preload("PatientInfectiousDiseases", "status = 1 ").
146
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
147
+		Where("s.user_org_id=? and s.schedule_date>=? and s.schedule_date<=? and s.status=1", orgID, start, end).
148
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time,s.dialysis_machine_name, p.name as patient").
149
+		Order("updated_time asc").
150
+		Find(&schedules).Error
151
+	return
152
+}
153
+
133 154
 func GetDaySchedule(orgID, start, end, patientID int64) (schedule models.Schedule, err error) {
134 155
 	err = readDb.Model(&models.Schedule{}).Where("user_org_id=? and patient_id=? and schedule_date>=? and schedule_date<=? and status=1", orgID, patientID, start, end).First(&schedule).Error
135 156
 	return