|
|
@@ -4,6 +4,10 @@ namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
use app\admin\model\Countmidtable;
|
|
|
+use app\admin\model\Users as Usersmodel;
|
|
|
+use app\admin\model\Groups as GroupsModel;
|
|
|
+use app\admin\model\Servicetimelog as ServicetimelogModel;
|
|
|
+use app\admin\model\Kfstatetimes as KfstatetimesModel;
|
|
|
|
|
|
/**
|
|
|
* 报表类
|
|
|
@@ -75,7 +79,7 @@ class Report extends Base
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- $queueData =(new Countmidtable())->getQueryDay($timeInterval['days_list']);
|
|
|
+ $queueData = (new Countmidtable())->getQueryDay($timeInterval['days_list']);
|
|
|
|
|
|
|
|
|
$this->assign([
|
|
|
@@ -97,6 +101,89 @@ class Report extends Base
|
|
|
}//end index()
|
|
|
|
|
|
|
|
|
+ public function attendancereport()
|
|
|
+ {
|
|
|
+
|
|
|
+ $goups = (new GroupsModel)->where(['status' => 1])->select();
|
|
|
+
|
|
|
+ if (request()->isAjax()) {
|
|
|
+
|
|
|
+ $param = input('param.');
|
|
|
+ $limit = $param['pageSize'];
|
|
|
+ $offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
+
|
|
|
+ $param = input('param.searchText');
|
|
|
+ if (empty($param)) {
|
|
|
+ $param = '0|0';
|
|
|
+ }
|
|
|
+ list($zone, $sgroup) = explode('|', $param);
|
|
|
+ if (empty($zone)) {
|
|
|
+ $zoneArray1 = [date("Y-m-d")];
|
|
|
+ } else {
|
|
|
+ $zonesarr = explode(',', $zone);
|
|
|
+ $dd = $this->Date_segmentation($zonesarr['0'], $zonesarr['1']);
|
|
|
+ $zoneArray1 = $dd['days_list'];
|
|
|
+ }
|
|
|
+ $zoneArray = array_map(function ($i) {
|
|
|
+ return "'$i'";
|
|
|
+ }, $zoneArray1);
|
|
|
+ $uidarr = (new Usersmodel())->getUidsBygid(intval($sgroup), 1, 1);
|
|
|
+
|
|
|
+ if (!$uidarr) {
|
|
|
+ return json(['rows' => [], 'total' => 0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $model1 = new ServicetimelogModel();
|
|
|
+ $model2 = new KfstatetimesModel();
|
|
|
+ $ret1 = $model1->getDayData($zoneArray1, $uidarr['uids']);
|
|
|
+ $ret2 = $model2->getDayData($zoneArray1, $uidarr['uids']);
|
|
|
+ $retall = $this->reportDataFormat($ret1, $ret2, $uidarr['objs'], $zoneArray1, $limit, $offset);
|
|
|
+
|
|
|
+ return json($retall);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assign('groups', $goups);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ function reportDataFormat($onoffdata, $timesdata, $uobjarr, $dataArray, $limit, $offset)
|
|
|
+ {
|
|
|
+ $allData = [];
|
|
|
+ $all_last = [];
|
|
|
+ foreach ($dataArray as $day) {
|
|
|
+ foreach ($uobjarr as $uid => $user) {
|
|
|
+ $kfuid = 'KF' . $uid;
|
|
|
+ if (isset($onoffdata[$day][$kfuid])) {
|
|
|
+ $allData[$day][$kfuid] = ['of0' => $onoffdata[$day][$kfuid][0], 'of1' => $onoffdata[$day][$kfuid][1]];
|
|
|
+ } else {
|
|
|
+ $allData[$day][$kfuid] = ['of0' => '', 'of1' => ''];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($timesdata[$day][$kfuid])) {
|
|
|
+ $all_last[] = array_merge($timesdata[$day][$kfuid], $allData[$day][$kfuid], ['uname' => $uobjarr[$uid]->user_name,'account' => $uobjarr[$uid]->user_account,'day'=>$day]);
|
|
|
+ } else {
|
|
|
+ $all_last[] = array_merge(['0' => 0, '1' => 0, '2' => 0, '3' => 0], $allData[$day][$kfuid], ['uname' => $uobjarr[$uid]->user_name, 'account' => $uobjarr[$uid]->user_account,'day'=>$day]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $len = count($all_last);
|
|
|
+ $return = ['rows' => [], 'total' => $len];
|
|
|
+ if ($offset >= $len) {
|
|
|
+ return $return;
|
|
|
+ }
|
|
|
+ $begin = $offset;
|
|
|
+ $end = ($offset + $limit);
|
|
|
+ $end = ($end > $len) ? $len - 1 : $end;
|
|
|
+
|
|
|
+ for ($i = $begin; $i < $end; $i++) {
|
|
|
+ $return['rows'][] = $all_last[$i];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 时间分割
|
|
|
*
|