|
@@ -159,26 +159,61 @@ class ApiService{
|
|
|
}
|
|
|
|
|
|
//网格化巡检记录查询
|
|
|
- public static function getResultList($depart, $date_type)
|
|
|
+ public static function getResultList($depart, $date_type = 'week')
|
|
|
{
|
|
|
$result['status'] = true;
|
|
|
$result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
$result['data'] = [];
|
|
|
|
|
|
- $query = DB::connection('mysql_fwview')->table('uf_wghgl_new')
|
|
|
- ->where('xjdw', $depart)
|
|
|
- ->where('WEEK(lrsj)', 'WEEK(CURDATE())')
|
|
|
- ->groupBy('lrdate, lrr, xjdw')
|
|
|
+ $query = DB::connection('mysql_fwview')->table('uf_wghgl_new')->where('xjdw', $depart);
|
|
|
+
|
|
|
+ if ($date_type == 'month') {
|
|
|
+ $query = $query->where(DB::raw('MONTH(lrsj)'), DB::raw('MONTH(CURDATE())'));
|
|
|
+ } else if ($date_type = 'quarter') {
|
|
|
+ $query = $query->where(DB::raw('QUARTER(lrsj)'), DB::raw('QUARTER(CURDATE())'));
|
|
|
+ } else {
|
|
|
+ $query = $query->where(DB::raw('WEEK(lrsj)'), DB::raw('WEEK(CURDATE())'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = $query->groupBy('lrdate', 'lrr', 'xjdw')
|
|
|
->select(
|
|
|
[
|
|
|
DB::raw('DATE(lrsj) as lrdate'),
|
|
|
'lrr',
|
|
|
- 'xjdw'
|
|
|
+ 'xjdw',
|
|
|
+ 'dwmc'
|
|
|
]
|
|
|
)
|
|
|
->get();
|
|
|
|
|
|
- dd($query);
|
|
|
+ $allcount = DB::connection('mysql_fwview')->table('formtable_main_974')
|
|
|
+ ->whereNotIn('szxmc', $depart)->count();
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $count = 0;
|
|
|
+ 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 ($detail >= $allcount) {
|
|
|
+ $lastname = DB::connection('mysql_fwview')->table('hrmresource')
|
|
|
+ ->where('id', $val->lrr)->value('lastname');
|
|
|
+
|
|
|
+ $count = $count + 1;
|
|
|
+
|
|
|
+ $data[$val->lrr] = [
|
|
|
+ 'department' => $val->dwmc,
|
|
|
+ 'lastname' => $lastname,
|
|
|
+ 'count' => $count,
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dd($data);
|
|
|
|
|
|
return $result;
|
|
|
}
|