@@ -1442,3 +1442,93 @@ def get_latest_job() -> Optional[JobInfo]:
1442
1442
else :
1443
1443
logger .debug ("job_id = %s のジョブに %d 回アクセスしましたが、完了しませんでした。" , job ["job_id" ], job_access_count )
1444
1444
return False
1445
+
1446
+ #########################################
1447
+ # Public Method : Labor Control
1448
+ #########################################
1449
+ @staticmethod
1450
+ def _get_actual_worktime_hour_from_labor (labor : Dict [str , Any ]) -> Optional [float ]:
1451
+ working_time_by_user = labor ["values" ]["working_time_by_user" ]
1452
+ if working_time_by_user is None :
1453
+ return None
1454
+
1455
+ actual_worktime = working_time_by_user .get ("results" )
1456
+ if actual_worktime is None :
1457
+ return None
1458
+ else :
1459
+ return actual_worktime / 3600 / 1000
1460
+
1461
+ @staticmethod
1462
+ def _get_plan_worktime_hour_from_labor (labor : Dict [str , Any ]) -> Optional [float ]:
1463
+ working_time_by_user = labor ["values" ]["working_time_by_user" ]
1464
+ if working_time_by_user is None :
1465
+ return None
1466
+
1467
+ actual_worktime = working_time_by_user .get ("plans" )
1468
+ if actual_worktime is None :
1469
+ return None
1470
+ else :
1471
+ return actual_worktime / 3600 / 1000
1472
+
1473
+ def get_labor_control_worktime (
1474
+ self ,
1475
+ organization_id : Optional [str ] = None ,
1476
+ project_id : Optional [str ] = None ,
1477
+ account_id : Optional [str ] = None ,
1478
+ from_date : Optional [str ] = None ,
1479
+ to_date : Optional [str ] = None ,
1480
+ ) -> List [Dict [str , Any ]]:
1481
+ """
1482
+ 実績作業時間(actual_worktime)と予定作業時間(plan_worktime)を取得する。
1483
+
1484
+ Args:
1485
+ query_params:
1486
+
1487
+ Returns:
1488
+
1489
+ """
1490
+
1491
+ def _to_new_data (labor : Dict [str , Any ]) -> Dict [str , Any ]:
1492
+ labor ["actual_worktime" ] = self ._get_actual_worktime_hour_from_labor (labor )
1493
+ labor ["plan_worktime" ] = self ._get_plan_worktime_hour_from_labor (labor )
1494
+ labor .pop ("values" , None )
1495
+ return labor
1496
+
1497
+ query_params = {
1498
+ "organization_id" : organization_id ,
1499
+ "project_id" : project_id ,
1500
+ "account_id" : account_id ,
1501
+ "from_date" : from_date ,
1502
+ "to_date" : to_date ,
1503
+ }
1504
+ labor_list , _ = self .api .get_labor_control (query_params )
1505
+ return [_to_new_data (e ) for e in labor_list ]
1506
+
1507
+ def get_labor_control_availability (
1508
+ self , account_id : str = None , from_date : Optional [str ] = None , to_date : Optional [str ] = None
1509
+ ) -> List [Dict [str , Any ]]:
1510
+ """
1511
+ 労務管理の予定稼働時間を取得する。
1512
+
1513
+ Args:
1514
+ account_id:
1515
+ from_date:
1516
+ to_date:
1517
+
1518
+ Returns:
1519
+ 予定稼働時間情報
1520
+ """
1521
+
1522
+ def _to_new_data (labor : Dict [str , Any ]) -> Dict [str , Any ]:
1523
+ labor ["availability" ] = self ._get_plan_worktime_hour_from_labor (labor )
1524
+ labor .pop ("values" , None )
1525
+ return labor
1526
+
1527
+ query_params = {
1528
+ "organization_id" : "___plannedWorktime___" ,
1529
+ "account_id" : account_id ,
1530
+ "from_date" : from_date ,
1531
+ "to_date" : to_date ,
1532
+ }
1533
+ labor_list , _ = self .api .get_labor_control (query_params )
1534
+ return [_to_new_data (e ) for e in labor_list ]
0 commit comments