test_user 1 year ago
parent
commit
2673c68268

+ 16 - 8
controllers/schedule_api_controller.go View File

36
 	beego.Router("/api/schedule/week", &ScheduleApiController{}, "get:GetWeekDaySchedule")
36
 	beego.Router("/api/schedule/week", &ScheduleApiController{}, "get:GetWeekDaySchedule")
37
 	beego.Router("/api/schedule/export", &ScheduleApiController{}, "post:ExportSchedule")
37
 	beego.Router("/api/schedule/export", &ScheduleApiController{}, "post:ExportSchedule")
38
 	beego.Router("/api/schedule_template/export", &ScheduleApiController{}, "post:ExportScheduleTemplate")
38
 	beego.Router("/api/schedule_template/export", &ScheduleApiController{}, "post:ExportScheduleTemplate")
39
-
40
 	beego.Router("/api/schedule_template/search", &ScheduleApiController{}, "get:SearchTemplateSchedulePatients")
39
 	beego.Router("/api/schedule_template/search", &ScheduleApiController{}, "get:SearchTemplateSchedulePatients")
41
-
42
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
40
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
43
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
41
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
44
 	beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
42
 	beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
730
 						}
728
 						}
731
 					}
729
 					}
732
 					schedule.DialysisMachineName = DialysisMachineName
730
 					schedule.DialysisMachineName = DialysisMachineName
733
-
731
+					schedule.IsExport = 3000
734
 					service.SaveSch(schedule)
732
 					service.SaveSch(schedule)
735
 				} else { //新的排班信息
733
 				} else { //新的排班信息
736
 
734
 
865
 						existSchedule.PartitionId = schedule.PartitionId
863
 						existSchedule.PartitionId = schedule.PartitionId
866
 						existSchedule.ScheduleType = schedule.ScheduleType
864
 						existSchedule.ScheduleType = schedule.ScheduleType
867
 						existSchedule.DialysisMachineName = schedule.DialysisMachineName
865
 						existSchedule.DialysisMachineName = schedule.DialysisMachineName
866
+						existSchedule.IsExport = 3001
868
 						service.SaveSmartSch(existSchedule)
867
 						service.SaveSmartSch(existSchedule)
869
 
868
 
870
 					} else {
869
 					} else {
911
 							daySchedule.PartitionId = schedule.PartitionId
910
 							daySchedule.PartitionId = schedule.PartitionId
912
 							daySchedule.BedId = schedule.BedId
911
 							daySchedule.BedId = schedule.BedId
913
 							daySchedule.DialysisMachineName = schedule.DialysisMachineName
912
 							daySchedule.DialysisMachineName = schedule.DialysisMachineName
913
+							existSchedule.IsExport = 3002
914
+
914
 							service.SaveSch(daySchedule)
915
 							service.SaveSch(daySchedule)
915
 						} else {
916
 						} else {
917
+							existSchedule.IsExport = 3003
916
 							service.CreateSchedule(&schedule)
918
 							service.CreateSchedule(&schedule)
917
 						}
919
 						}
918
 					}
920
 					}
1438
 	}
1440
 	}
1439
 
1441
 
1440
 	redis := service.RedisClient()
1442
 	redis := service.RedisClient()
1441
-
1443
+	schedule.IsExport = 1000
1442
 	err = service.CreateSchedule(&schedule)
1444
 	err = service.CreateSchedule(&schedule)
1443
 
1445
 
1444
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1446
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
3050
 			err := service.UpdateScheduleTemplateStatus(this.GetAdminUserInfo().CurrentOrgId)
3052
 			err := service.UpdateScheduleTemplateStatus(this.GetAdminUserInfo().CurrentOrgId)
3051
 			if err == nil {
3053
 			if err == nil {
3052
 				for _, item := range schedules {
3054
 				for _, item := range schedules {
3053
-					service.CreateScheduleTemplate(item)
3055
+					//判斷某個模板下,當天是否有排版,沒有的話就新增
3056
+					total := service.ExportScheduleTemplate(item)
3057
+					if total == 0 {
3058
+						service.CreateScheduleTemplate(item)
3059
+					}
3054
 				}
3060
 				}
3055
 				////查询已经转出或者死亡的患者
3061
 				////查询已经转出或者死亡的患者
3056
 				//patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
3062
 				//patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
3481
 			}
3487
 			}
3482
 		}
3488
 		}
3483
 		schedule.DialysisMachineName = DialysisMachineName
3489
 		schedule.DialysisMachineName = DialysisMachineName
3484
-
3490
+		schedule.IsExport = 4000
3485
 		err = service.AddPatientSchedule(&schedule)
3491
 		err = service.AddPatientSchedule(&schedule)
3486
 
3492
 
3487
 	}
3493
 	}
4166
 	orgId := c.GetAdminUserInfo().CurrentOrgId
4172
 	orgId := c.GetAdminUserInfo().CurrentOrgId
4167
 	//根据模板ID获取模板数据
4173
 	//根据模板ID获取模板数据
4168
 	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
4174
 	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
4175
+	fmt.Println(len(list))
4169
 
4176
 
4170
 	//数据去重操作
4177
 	//数据去重操作
4171
 	list = RemoveRepeatedScheduleTemplate(list)
4178
 	list = RemoveRepeatedScheduleTemplate(list)
4180
 	var thursday int64
4187
 	var thursday int64
4181
 	var friday int64
4188
 	var friday int64
4182
 	var saturday int64
4189
 	var saturday int64
4183
-
4190
+	//
4184
 	//如果选择的开始日期大于当前日期
4191
 	//如果选择的开始日期大于当前日期
4185
 	if copy_startime > nowtime {
4192
 	if copy_startime > nowtime {
4186
 		//清空该时间段的所有排班数据
4193
 		//清空该时间段的所有排班数据
4230
 				Status:       1,
4237
 				Status:       1,
4231
 				CreatedTime:  time.Now().Unix(),
4238
 				CreatedTime:  time.Now().Unix(),
4232
 				UpdatedTime:  0,
4239
 				UpdatedTime:  0,
4240
+				IsExport:     2000,
4233
 			}
4241
 			}
4234
 
4242
 
4235
 			var DialysisMachineName string
4243
 			var DialysisMachineName string
4388
 	for i := 0; i < len(arr); i++ {
4396
 	for i := 0; i < len(arr); i++ {
4389
 		repeat := false
4397
 		repeat := false
4390
 		for j := i + 1; j < len(arr); j++ {
4398
 		for j := i + 1; j < len(arr); j++ {
4391
-			if arr[i].TemplateID == arr[j].TemplateID && arr[i].PatientID == arr[j].PatientID && arr[i].Weekday == arr[j].Weekday && arr[i].DeviceNumberID == arr[j].DeviceNumberID && arr[i].TimeType == arr[j].TimeType {
4399
+			if arr[i].TemplateID == arr[j].TemplateID && arr[i].PatientID == arr[j].PatientID && arr[i].Weekday == arr[j].Weekday {
4392
 				repeat = true
4400
 				repeat = true
4393
 				break
4401
 				break
4394
 			}
4402
 			}

+ 2 - 2
controllers/schedule_template_api_controller.go View File

722
 			src_template.DeviceNumberID = item.DeviceNumberID
722
 			src_template.DeviceNumberID = item.DeviceNumberID
723
 			src_template.TimeType = int8(item.TimeType)
723
 			src_template.TimeType = int8(item.TimeType)
724
 			src_template.TreatMode = item.Mode
724
 			src_template.TreatMode = item.Mode
725
-			//service.SaveSchTemplateItem(src_template)
726
-			fmt.Println("11111")
725
+			service.SaveSchTemplateItem(src_template)
726
+
727
 		} else {
727
 		} else {
728
 			schItemTwo, _ := service.GetScheduleTemplateTwo(this.GetAdminUserInfo().CurrentOrgId, item.TemplateID, item.Weekday, item.PatientID)
728
 			schItemTwo, _ := service.GetScheduleTemplateTwo(this.GetAdminUserInfo().CurrentOrgId, item.TemplateID, item.Weekday, item.PatientID)
729
 			fmt.Println("222222")
729
 			fmt.Println("222222")

+ 5 - 0
service/schedule_service.go View File

876
 	return writeDb.Model(&models.PatientScheduleTemplateItem{}).Create(&m).Error
876
 	return writeDb.Model(&models.PatientScheduleTemplateItem{}).Create(&m).Error
877
 }
877
 }
878
 
878
 
879
+func ExportScheduleTemplate(m *models.PatientScheduleTemplateItem) (total int64) {
880
+	readDb.Model(&models.PatientScheduleTemplateItem{}).Where("template_id = ? AND patient_id = ? AND week_day = ? AND org_id = ?", m.TemplateID, m.PatientID, m.Weekday, m.OrgID).Count(&total)
881
+	return
882
+}
883
+
879
 func FindSchedualTemplateExportLog(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
884
 func FindSchedualTemplateExportLog(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
880
 	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 3", org_id, export_time).Find(&errLogs).Error
885
 	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 3", org_id, export_time).Find(&errLogs).Error
881
 	return
886
 	return