答案 0 :(得分:0)
如果我的问题正确,您可以检索每天关于员工的数据,但您想知道员工每月在场的天数。也许是这样的:
DatabaseReference employees_ref=FirebaseDatabase.getInstance().getReference().child("EmployeesAttendance").child(Employee_uid).child("2018").child("March");
employees_Ref.addListenerForSingleValueEvent(new Value....{
onDataChanged(DataSnapshot datasnapshot){
//get the number of days that employees where present in march
int number_days_present_march=datasnapshot.getChildrenCount();
}
});
修改强>
我想你现在想要的是知道员工x何时出现以及他/她何时离开(或缺席)。
为此,当他/她在这里以及他们离开时,你必须得到你想要的每一天。
让我说我想知道员工x何时来,他什么时候离开2018年/ 3月/ 18:
//get a reference of employee x during 2018/march/18
Databasereference employee_presence= FirebaseDatabase.getInstance().getReference().child("EmployeesAttendance").child(EmployeeX_uid).child("2018").child("march").child("18");
//use the reference to know when he was in and when he was out
employee_presence.addListenerForSingleValueEvent(new Value.....{
onDatachange(DataSnapshot datasnapshot){
//if you stored your date as number (long)
//get the presence like this:
long time_in=datasnapshot.child("in_time").getValue(long.class);
long time_out=datasnapshot.child("out_time").getValue(long.class);
//show a message
Toast.makeText(getApplicationContext(), "Employee X was in at"+ String.Valueof(time_in) + "and was out at" + String.Valueof(time_out) ).show();
//if you stored your date as a string
//get the presence like this:
String time_in= datasnapshot.child("time_in").getValue().toString();
String time_out= datasnapshot.child("time_out").getValue().toString();
//show a message
Toast.makeText(getApplicationContext(), "Employee x was in at" + time_in + "and was out at" + time_out).show();
}
});