|
@@ -159,13 +159,17 @@ class ApiService{
|
|
}
|
|
}
|
|
|
|
|
|
//网格化巡检记录查询
|
|
//网格化巡检记录查询
|
|
- public static function getResultList($depart, $date_type = 'week')
|
|
|
|
|
|
+ public static function getResultRecord($depart = 'all', $date_type = 'week')
|
|
{
|
|
{
|
|
$result['status'] = true;
|
|
$result['status'] = true;
|
|
$result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
$result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
$result['data'] = [];
|
|
$result['data'] = [];
|
|
|
|
|
|
- $query = DB::connection('mysql_fwview')->table('uf_wghgl_new')->where('xjdw', $depart);
|
|
|
|
|
|
+ $query = DB::connection('mysql_fwview')->table('uf_wghgl_new');
|
|
|
|
+
|
|
|
|
+ if ($depart != 'all') {
|
|
|
|
+ $query = $query->where('xjdw', $depart);
|
|
|
|
+ }
|
|
|
|
|
|
if ($date_type == 'month') {
|
|
if ($date_type == 'month') {
|
|
$query = $query->where(DB::raw('MONTH(lrsj)'), DB::raw('MONTH(CURDATE())'));
|
|
$query = $query->where(DB::raw('MONTH(lrsj)'), DB::raw('MONTH(CURDATE())'));
|
|
@@ -175,43 +179,75 @@ class ApiService{
|
|
$query = $query->where(DB::raw('WEEK(lrsj)'), DB::raw('WEEK(CURDATE())'));
|
|
$query = $query->where(DB::raw('WEEK(lrsj)'), DB::raw('WEEK(CURDATE())'));
|
|
}
|
|
}
|
|
|
|
|
|
- $query = $query->groupBy('lrdate', 'lrr', 'xjdw', 'dwmc')
|
|
|
|
|
|
+ $query = $query->groupBy('lrdate', 'lrr', 'dwmc')
|
|
->select(
|
|
->select(
|
|
[
|
|
[
|
|
DB::raw('DATE(lrsj) as lrdate'),
|
|
DB::raw('DATE(lrsj) as lrdate'),
|
|
'lrr',
|
|
'lrr',
|
|
- 'xjdw',
|
|
|
|
'dwmc'
|
|
'dwmc'
|
|
]
|
|
]
|
|
)
|
|
)
|
|
->get();
|
|
->get();
|
|
|
|
|
|
- $allcount = DB::connection('mysql_fwview')->table('formtable_main_974')
|
|
|
|
- ->where('szxmc', $depart)->count();
|
|
|
|
-
|
|
|
|
$data = [];
|
|
$data = [];
|
|
foreach ($query as $key => $val) {
|
|
foreach ($query as $key => $val) {
|
|
- $detail = DB::connection('mysql_fwview')->table('uf_wghgl_new')
|
|
|
|
- ->where('xjdw', $depart)
|
|
|
|
- ->where(DB::raw('DATE(lrsj)'), $val->lrdate)
|
|
|
|
- ->where('lrr', $val->lrr)->count();
|
|
|
|
|
|
+ if ($depart == 'all') {
|
|
|
|
+ $wghgl = DB::connection('mysql_fwview')->table('uf_wghgl_new')
|
|
|
|
+ ->where(DB::raw('DATE(lrsj)'), $val->lrdate)
|
|
|
|
+ ->where('lrr', $val->lrr)
|
|
|
|
+ ->groupBy('xjdw')
|
|
|
|
+ ->select('xjdw')
|
|
|
|
+ ->get();
|
|
|
|
|
|
- if ($detail >= $allcount) {
|
|
|
|
$lastname = DB::connection('mysql_fwview')->table('hrmresource')
|
|
$lastname = DB::connection('mysql_fwview')->table('hrmresource')
|
|
- ->where('id', $val->lrr)->value('lastname');
|
|
|
|
-
|
|
|
|
- $data[$val->lrr] = [
|
|
|
|
- 'department' => $val->dwmc,
|
|
|
|
- 'lastname' => $lastname,
|
|
|
|
- 'count' => isset($data[$val->lrr]['count']) ? $data[$val->lrr]['count'] + 1 : 0,
|
|
|
|
- ];
|
|
|
|
|
|
+ ->where('id', $val->lrr)->value('lastname');
|
|
|
|
+
|
|
|
|
+ foreach ($wghgl as $k => $v) {
|
|
|
|
+ $allcount = DB::connection('mysql_fwview')->table('formtable_main_974')
|
|
|
|
+ ->where('szxmc', $v->xjdw)->count();
|
|
|
|
+
|
|
|
|
+ $detail = DB::connection('mysql_fwview')->table('uf_wghgl_new')
|
|
|
|
+ ->where('xjdw', $v->xjdw)
|
|
|
|
+ ->where(DB::raw('DATE(lrsj)'), $val->lrdate)
|
|
|
|
+ ->where('lrr', $val->lrr)->count();
|
|
|
|
+
|
|
|
|
+ if ($detail >= $allcount) {
|
|
|
|
+ $data[$val->lrr] = [
|
|
|
|
+ 'department' => $val->dwmc,
|
|
|
|
+ 'lastname' => $lastname,
|
|
|
|
+ 'count' => isset($data[$val->lrr]['count']) ? $data[$val->lrr]['count'] + 1 : 0,
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- continue;
|
|
|
|
|
|
+ $allcount = DB::connection('mysql_fwview')->table('formtable_main_974')
|
|
|
|
+ ->where('szxmc', $depart)->count();
|
|
|
|
+
|
|
|
|
+ $detail = DB::connection('mysql_fwview')->table('uf_wghgl_new')
|
|
|
|
+ ->where('xjdw', $depart)
|
|
|
|
+ ->where(DB::raw('DATE(lrsj)'), $val->lrdate)
|
|
|
|
+ ->where('lrr', $val->lrr)->count();
|
|
|
|
+
|
|
|
|
+ if ($detail >= $allcount) {
|
|
|
|
+ $lastname = DB::connection('mysql_fwview')->table('hrmresource')
|
|
|
|
+ ->where('id', $val->lrr)->value('lastname');
|
|
|
|
+
|
|
|
|
+ $data[$val->lrr] = [
|
|
|
|
+ 'department' => $val->dwmc,
|
|
|
|
+ 'lastname' => $lastname,
|
|
|
|
+ 'count' => isset($data[$val->lrr]['count']) ? $data[$val->lrr]['count'] + 1 : 0,
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- $result['data'] = array_column($data, 'count');
|
|
|
|
|
|
+ $cmf_arr = array_column($data, 'count');
|
|
|
|
+ array_multisort($cmf_arr, SORT_DESC, $data);
|
|
|
|
+ $result['data'] = $data;
|
|
|
|
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|