test_user 1 год назад
Родитель
Сommit
2673c68268

+ 16 - 8
controllers/schedule_api_controller.go Просмотреть файл

@@ -36,9 +36,7 @@ func ScheduleApiRegistRouters() {
36 36
 	beego.Router("/api/schedule/week", &ScheduleApiController{}, "get:GetWeekDaySchedule")
37 37
 	beego.Router("/api/schedule/export", &ScheduleApiController{}, "post:ExportSchedule")
38 38
 	beego.Router("/api/schedule_template/export", &ScheduleApiController{}, "post:ExportScheduleTemplate")
39
-
40 39
 	beego.Router("/api/schedule_template/search", &ScheduleApiController{}, "get:SearchTemplateSchedulePatients")
41
-
42 40
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
43 41
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
44 42
 	beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
@@ -730,7 +728,7 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
730 728
 						}
731 729
 					}
732 730
 					schedule.DialysisMachineName = DialysisMachineName
733
-
731
+					schedule.IsExport = 3000
734 732
 					service.SaveSch(schedule)
735 733
 				} else { //新的排班信息
736 734
 
@@ -865,6 +863,7 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
865 863
 						existSchedule.PartitionId = schedule.PartitionId
866 864
 						existSchedule.ScheduleType = schedule.ScheduleType
867 865
 						existSchedule.DialysisMachineName = schedule.DialysisMachineName
866
+						existSchedule.IsExport = 3001
868 867
 						service.SaveSmartSch(existSchedule)
869 868
 
870 869
 					} else {
@@ -911,8 +910,11 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
911 910
 							daySchedule.PartitionId = schedule.PartitionId
912 911
 							daySchedule.BedId = schedule.BedId
913 912
 							daySchedule.DialysisMachineName = schedule.DialysisMachineName
913
+							existSchedule.IsExport = 3002
914
+
914 915
 							service.SaveSch(daySchedule)
915 916
 						} else {
917
+							existSchedule.IsExport = 3003
916 918
 							service.CreateSchedule(&schedule)
917 919
 						}
918 920
 					}
@@ -1438,7 +1440,7 @@ func (c *ScheduleApiController) CreateSchedule() {
1438 1440
 	}
1439 1441
 
1440 1442
 	redis := service.RedisClient()
1441
-
1443
+	schedule.IsExport = 1000
1442 1444
 	err = service.CreateSchedule(&schedule)
1443 1445
 
1444 1446
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
@@ -3050,7 +3052,11 @@ func (this *ScheduleApiController) ExportScheduleTemplate() {
3050 3052
 			err := service.UpdateScheduleTemplateStatus(this.GetAdminUserInfo().CurrentOrgId)
3051 3053
 			if err == nil {
3052 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 3062
 				//patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
@@ -3481,7 +3487,7 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
3481 3487
 			}
3482 3488
 		}
3483 3489
 		schedule.DialysisMachineName = DialysisMachineName
3484
-
3490
+		schedule.IsExport = 4000
3485 3491
 		err = service.AddPatientSchedule(&schedule)
3486 3492
 
3487 3493
 	}
@@ -4166,6 +4172,7 @@ func (c *ScheduleApiController) SynchroSchedule() {
4166 4172
 	orgId := c.GetAdminUserInfo().CurrentOrgId
4167 4173
 	//根据模板ID获取模板数据
4168 4174
 	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
4175
+	fmt.Println(len(list))
4169 4176
 
4170 4177
 	//数据去重操作
4171 4178
 	list = RemoveRepeatedScheduleTemplate(list)
@@ -4180,7 +4187,7 @@ func (c *ScheduleApiController) SynchroSchedule() {
4180 4187
 	var thursday int64
4181 4188
 	var friday int64
4182 4189
 	var saturday int64
4183
-
4190
+	//
4184 4191
 	//如果选择的开始日期大于当前日期
4185 4192
 	if copy_startime > nowtime {
4186 4193
 		//清空该时间段的所有排班数据
@@ -4230,6 +4237,7 @@ func (c *ScheduleApiController) SynchroSchedule() {
4230 4237
 				Status:       1,
4231 4238
 				CreatedTime:  time.Now().Unix(),
4232 4239
 				UpdatedTime:  0,
4240
+				IsExport:     2000,
4233 4241
 			}
4234 4242
 
4235 4243
 			var DialysisMachineName string
@@ -4388,7 +4396,7 @@ func RemoveRepeatedScheduleTemplate(arr []*models.VmPatientScheduleTemplateItem)
4388 4396
 	for i := 0; i < len(arr); i++ {
4389 4397
 		repeat := false
4390 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 4400
 				repeat = true
4393 4401
 				break
4394 4402
 			}

+ 2 - 2
controllers/schedule_template_api_controller.go Просмотреть файл

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

+ 5 - 0
service/schedule_service.go Просмотреть файл

@@ -876,6 +876,11 @@ func CreateScheduleTemplate(m *models.PatientScheduleTemplateItem) error {
876 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 884
 func FindSchedualTemplateExportLog(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
880 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 886
 	return