|
@@ -22,6 +22,7 @@ type ScheduleApiController struct {
|
22
|
22
|
|
23
|
23
|
func ScheduleApiRegistRouters() {
|
24
|
24
|
beego.Router("/api/schedule/weekpanel", &ScheduleApiController{}, "Get:GetWeekPanels")
|
|
25
|
+
|
25
|
26
|
beego.Router("/api/schedule/schedules", &ScheduleApiController{}, "Get:GetSchedules")
|
26
|
27
|
beego.Router("/api/excel_date/init", &ScheduleApiController{}, "Get:GetInitExcelInitDate")
|
27
|
28
|
|
|
@@ -56,6 +57,11 @@ func ScheduleApiRegistRouters() {
|
56
|
57
|
beego.Router("/api/schedule/getprintlist", &ScheduleApiController{}, "Get:GetPrintList")
|
57
|
58
|
|
58
|
59
|
beego.Router("/api/schedule/getallzonelist", &ScheduleApiController{}, "Get:GetAllZoneList")
|
|
60
|
+
|
|
61
|
+ beego.Router("/api/schedule/getpatientschedulecount", &ScheduleApiController{}, "Get:GetPatientScheduleCount")
|
|
62
|
+
|
|
63
|
+ beego.Router("/api/schedule/weekpanelone", &ScheduleApiController{}, "Get:GetWeekPanelsOne")
|
|
64
|
+ beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
|
59
|
65
|
}
|
60
|
66
|
|
61
|
67
|
func (c *ScheduleApiController) GetWeekPanels() {
|
|
@@ -2411,3 +2417,171 @@ func (this *ScheduleApiController) GetAllZoneList() {
|
2411
|
2417
|
"zoneList": zoneList,
|
2412
|
2418
|
})
|
2413
|
2419
|
}
|
|
2420
|
+
|
|
2421
|
+func (this *ScheduleApiController) GetPatientScheduleCount() {
|
|
2422
|
+ patitionIdStr := this.GetString("partition_id")
|
|
2423
|
+ week, _ := this.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
|
|
2424
|
+ ids := strings.Split(patitionIdStr, ",")
|
|
2425
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
2426
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
2427
|
+ thisTime := time.Now()
|
|
2428
|
+ weekDay := int(thisTime.Weekday())
|
|
2429
|
+ if week < 1 || week > 4 {
|
|
2430
|
+ week = 2
|
|
2431
|
+ }
|
|
2432
|
+ if week == 1 {
|
|
2433
|
+ thisTime = thisTime.AddDate(0, 0, -7)
|
|
2434
|
+ } else if week == 3 {
|
|
2435
|
+ thisTime = thisTime.AddDate(0, 0, 7)
|
|
2436
|
+ } else if week == 4 {
|
|
2437
|
+ thisTime = thisTime.AddDate(0, 0, 14)
|
|
2438
|
+ }
|
|
2439
|
+ if weekDay == 0 {
|
|
2440
|
+ weekDay = 7
|
|
2441
|
+ }
|
|
2442
|
+ weekEnd := 7 - weekDay
|
|
2443
|
+ weekStart := weekEnd - 6
|
|
2444
|
+ weekTitle := make([]string, 0)
|
|
2445
|
+ days := make([]string, 0)
|
|
2446
|
+ for index := weekStart; index <= weekEnd; index++ {
|
|
2447
|
+ theDay := thisTime.AddDate(0, 0, index)
|
|
2448
|
+ indexYear, indexMonthTime, indexDay := theDay.Date()
|
|
2449
|
+ indexMonth := int(indexMonthTime)
|
|
2450
|
+ indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
|
|
2451
|
+ weekTitle = append(weekTitle, indexWeek)
|
|
2452
|
+ days = append(days, theDay.Format("2006-01-02"))
|
|
2453
|
+ }
|
|
2454
|
+
|
|
2455
|
+ weekStartDay := thisTime.AddDate(0, 0, weekStart)
|
|
2456
|
+ weekEndDay := thisTime.AddDate(0, 0, weekEnd)
|
|
2457
|
+ weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
|
|
2458
|
+ weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
|
|
2459
|
+
|
|
2460
|
+ timeLayout := "2006-01-02 15:04:05"
|
|
2461
|
+ loc, _ := time.LoadLocation("Local")
|
|
2462
|
+ theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
|
|
2463
|
+ theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
|
|
2464
|
+ weekStartPoint := theStarTime.Unix()
|
|
2465
|
+ weekEndPoint := theEndTime.Unix()
|
|
2466
|
+ fmt.Println("startTime222222222222222", weekStartPoint)
|
|
2467
|
+ fmt.Println("endtime33333333333333", weekEndPoint)
|
|
2468
|
+ list, err := service.GetPatientScheduleCount(orgId, weekStartPoint, weekEndPoint, ids)
|
|
2469
|
+ _, total, _ := service.GetTotalBedNumber(orgId, ids)
|
|
2470
|
+ if err != nil {
|
|
2471
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2472
|
+ return
|
|
2473
|
+ }
|
|
2474
|
+
|
|
2475
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
2476
|
+ "list": list,
|
|
2477
|
+ "total": total,
|
|
2478
|
+ })
|
|
2479
|
+}
|
|
2480
|
+
|
|
2481
|
+func (c *ScheduleApiController) GetWeekPanelsOne() {
|
|
2482
|
+
|
|
2483
|
+ data, _ := c.GetInt64("data", 1)
|
|
2484
|
+ patitionIdStr := c.GetString("patitionid")
|
|
2485
|
+
|
|
2486
|
+ ids := strings.Split(patitionIdStr, ",")
|
|
2487
|
+
|
|
2488
|
+ adminInfo := c.GetAdminUserInfo()
|
|
2489
|
+ thisTime := time.Now()
|
|
2490
|
+ year, monthTime, day := thisTime.Date()
|
|
2491
|
+ month := int(monthTime)
|
|
2492
|
+ _, theWeek := thisTime.ISOWeek()
|
|
2493
|
+ weekDay := int(thisTime.Weekday())
|
|
2494
|
+ if weekDay == 0 {
|
|
2495
|
+ weekDay = 7
|
|
2496
|
+ }
|
|
2497
|
+ weekEnd := 7 - weekDay
|
|
2498
|
+ weekStart := weekEnd - 6
|
|
2499
|
+ weekDays := make([]string, 0)
|
|
2500
|
+ for index := weekStart; index <= weekEnd; index++ {
|
|
2501
|
+ theDay := thisTime.AddDate(0, 0, index)
|
|
2502
|
+ indexYear, indexMonthTime, indexDay := theDay.Date()
|
|
2503
|
+ indexMonth := int(indexMonthTime)
|
|
2504
|
+ indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
|
|
2505
|
+ weekDays = append(weekDays, indexWeek)
|
|
2506
|
+ }
|
|
2507
|
+
|
|
2508
|
+ returnData := map[string]interface{}{
|
|
2509
|
+ "year": year,
|
|
2510
|
+ "month": month,
|
|
2511
|
+ "day": day,
|
|
2512
|
+ "theWeek": theWeek,
|
|
2513
|
+ "weekDay": weekDay,
|
|
2514
|
+ "weekDays": weekDays,
|
|
2515
|
+ }
|
|
2516
|
+
|
|
2517
|
+ if data == 1 {
|
|
2518
|
+ partitions, _ := service.GetSchedulePartitionPanelTwo(adminInfo.CurrentOrgId, ids)
|
|
2519
|
+ returnData["partitions"] = partitions
|
|
2520
|
+ }
|
|
2521
|
+
|
|
2522
|
+ c.ServeSuccessJSON(returnData)
|
|
2523
|
+ return
|
|
2524
|
+}
|
|
2525
|
+
|
|
2526
|
+func (c *ScheduleApiController) GetScheduleOne() {
|
|
2527
|
+
|
|
2528
|
+ week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
|
|
2529
|
+ patitionIdStr := c.GetString("patitionid")
|
|
2530
|
+
|
|
2531
|
+ ids := strings.Split(patitionIdStr, ",")
|
|
2532
|
+ fmt.Println("patitonStr", ids)
|
|
2533
|
+ schedule_type, _ := c.GetInt64("schedule_type")
|
|
2534
|
+
|
|
2535
|
+ adminInfo := c.GetAdminUserInfo()
|
|
2536
|
+
|
|
2537
|
+ thisTime := time.Now()
|
|
2538
|
+ today := thisTime.Format("2006-01-02")
|
|
2539
|
+ if week < 1 || week > 4 {
|
|
2540
|
+ week = 2
|
|
2541
|
+ }
|
|
2542
|
+ if week == 1 {
|
|
2543
|
+ thisTime = thisTime.AddDate(0, 0, -7)
|
|
2544
|
+ } else if week == 3 {
|
|
2545
|
+ thisTime = thisTime.AddDate(0, 0, 7)
|
|
2546
|
+ } else if week == 4 {
|
|
2547
|
+ thisTime = thisTime.AddDate(0, 0, 14)
|
|
2548
|
+ }
|
|
2549
|
+
|
|
2550
|
+ weekDay := int(thisTime.Weekday())
|
|
2551
|
+ if weekDay == 0 {
|
|
2552
|
+ weekDay = 7
|
|
2553
|
+ }
|
|
2554
|
+ weekEnd := 7 - weekDay
|
|
2555
|
+ weekStart := weekEnd - 6
|
|
2556
|
+ weekTitle := make([]string, 0)
|
|
2557
|
+ days := make([]string, 0)
|
|
2558
|
+ for index := weekStart; index <= weekEnd; index++ {
|
|
2559
|
+ theDay := thisTime.AddDate(0, 0, index)
|
|
2560
|
+ indexYear, indexMonthTime, indexDay := theDay.Date()
|
|
2561
|
+ indexMonth := int(indexMonthTime)
|
|
2562
|
+ indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
|
|
2563
|
+ weekTitle = append(weekTitle, indexWeek)
|
|
2564
|
+ days = append(days, theDay.Format("2006-01-02"))
|
|
2565
|
+ }
|
|
2566
|
+
|
|
2567
|
+ weekStartDay := thisTime.AddDate(0, 0, weekStart)
|
|
2568
|
+ weekEndDay := thisTime.AddDate(0, 0, weekEnd)
|
|
2569
|
+ weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
|
|
2570
|
+ weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
|
|
2571
|
+
|
|
2572
|
+ timeLayout := "2006-01-02 15:04:05"
|
|
2573
|
+ loc, _ := time.LoadLocation("Local")
|
|
2574
|
+ theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
|
|
2575
|
+ theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
|
|
2576
|
+ weekStartPoint := theStarTime.Unix()
|
|
2577
|
+ weekEndPoint := theEndTime.Unix()
|
|
2578
|
+
|
|
2579
|
+ schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
|
|
2580
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2581
|
+ "days": days,
|
|
2582
|
+ "weekTitle": weekTitle,
|
|
2583
|
+ "schdules": schdules,
|
|
2584
|
+ "today": today,
|
|
2585
|
+ })
|
|
2586
|
+ return
|
|
2587
|
+}
|