|
@@ -366,6 +366,82 @@ class ApiService{
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ //全流程巡检记录排名
|
|
|
+ public static function getRecordSort($depart,$start_date,$end_date)
|
|
|
+ {
|
|
|
+ $result['status'] = true;
|
|
|
+ $result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
+ $result['data'] = [];
|
|
|
+
|
|
|
+ $query = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl');
|
|
|
+ if ($depart != 'all') {
|
|
|
+ $query = $query->where('xjdw', $depart);
|
|
|
+ }
|
|
|
+ $query = $query->whereBetween($start_date,$end_date);
|
|
|
+ $query = $query->get();
|
|
|
+
|
|
|
+ $people_list = [];
|
|
|
+ if(count($query) > 0){
|
|
|
+ for($i=0;$i<count($query);$i++){
|
|
|
+ if(!in_array($query[$i]->lrr,$people_list)){
|
|
|
+ $people_list[] = $query[$i]->lrr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+ $pie = [];
|
|
|
+ if(count($people_list) > 0){
|
|
|
+ for($i=0;$i<count($people_list);$i++){
|
|
|
+ $area_list = [];
|
|
|
+ for($j=0;$j<count($query);$j++){
|
|
|
+ if($people_list[$i] == $query[$j]->lrr){
|
|
|
+ $list[$i]['department'] = str_replace("洗选中心", "", $query[$j]->xjdw);
|
|
|
+ $area_list[] = $query[$j]->xjqy;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $unit_zd = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcqyzd')->where('szxmc',$list[$i]['department'])->where('IS_DELETE',0)->pluck('qymc');
|
|
|
+
|
|
|
+ $minCount = PHP_INT_MAX;
|
|
|
+
|
|
|
+ foreach ($unit_zd as $itemB) {
|
|
|
+ // 如果数组A中不包含数组B中的某个项,则直接退出
|
|
|
+ if (!in_array($itemB, $area_list)) {
|
|
|
+ $minCount = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算该项在数组A中出现的次数
|
|
|
+ $count = 0;
|
|
|
+ foreach ($area_list as $itemA) {
|
|
|
+ if ($itemA == $itemB) {
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新最少的数量
|
|
|
+ $minCount = min($minCount, $count);
|
|
|
+ }
|
|
|
+
|
|
|
+ $lrr = explode('|',$people_list[$i]);
|
|
|
+ $list[$i]['lastname'] = $lrr[0];
|
|
|
+ $list[$i]['person_id'] = $lrr[1];
|
|
|
+ $list[$i]['count'] = $minCount;
|
|
|
+
|
|
|
+ $pie[$i]['name'] = $lrr[0];
|
|
|
+ $pie[$i]['value'] = $minCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ usort($list, function($a, $b) {
|
|
|
+ return $b['count'] <=> $a['count']; // 降序
|
|
|
+ });
|
|
|
+
|
|
|
+ $result['data']['list'] = $list;
|
|
|
+ $result['data']['pie'] = $pie;
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
//网格化巡检记录列表
|
|
|
public static function getResultList($person_id, $depart = 'all', $date_type = 'week')
|
|
|
{
|