作者 lyh

未续费项目增加搜索

@@ -94,7 +94,19 @@ class TicketCount extends Command @@ -94,7 +94,19 @@ class TicketCount extends Command
94 $fastest_time = null; 94 $fastest_time = null;
95 } 95 }
96 //超时工单数量 96 //超时工单数量
97 - $timeout_num = $ticketLogModel->counts(['engineer_id'=>$item['manage_id'],'is_engineer'=>1,'plan_end_at'=>['>',date('Y-m-d H:i:s')]]); 97 + $timeout_num = $ticketLogModel
  98 + ->where('engineer_id', $item['manage_id'])
  99 + ->where('is_engineer', 1)
  100 + ->where(function ($query) {
  101 + $query->where(function ($q) {
  102 + $q->whereNotNull('end_at')
  103 + ->whereColumn('plan_end_at', '>', 'end_at');
  104 + })->orWhere(function ($q) {
  105 + $q->whereNull('end_at')
  106 + ->where('plan_end_at', '>', now());
  107 + });
  108 + })
  109 + ->count();
98 if(!empty($timeout_num)){ 110 if(!empty($timeout_num)){
99 $timeout_ratio = round($timeout_num / $ticket_num, 3); 111 $timeout_ratio = round($timeout_num / $ticket_num, 3);
100 } 112 }
@@ -148,7 +160,19 @@ class TicketCount extends Command @@ -148,7 +160,19 @@ class TicketCount extends Command
148 $average_time = round($timeCount / $ticket_num, 3); 160 $average_time = round($timeCount / $ticket_num, 3);
149 } 161 }
150 //超期工单数量 162 //超期工单数量
151 - $timeout_num = $ticketLogModel->counts(['engineer_id'=>['in',$manageIdArr],'is_engineer'=>1,'plan_end_at'=>['>',date('Y-m-d H:i:s')]]); 163 + $timeout_num = $ticketLogModel
  164 + ->where('engineer_id', $item['manage_id'])
  165 + ->where('is_engineer', 1)
  166 + ->where(function ($query) {
  167 + $query->where(function ($q) {
  168 + $q->whereNotNull('end_at')
  169 + ->whereColumn('plan_end_at', '>', 'end_at');
  170 + })->orWhere(function ($q) {
  171 + $q->whereNull('end_at')
  172 + ->where('plan_end_at', '>', now());
  173 + });
  174 + })
  175 + ->count();
152 if(!empty($timeout_num)){ 176 if(!empty($timeout_num)){
153 $timeout_ratio = round($timeout_num / $ticket_num, 3); 177 $timeout_ratio = round($timeout_num / $ticket_num, 3);
154 } 178 }
@@ -199,7 +223,17 @@ class TicketCount extends Command @@ -199,7 +223,17 @@ class TicketCount extends Command
199 ) 223 )
200 ->groupBy('p.project_cate') 224 ->groupBy('p.project_cate')
201 ->pluck('ticket_count', 'project_cate'); 225 ->pluck('ticket_count', 'project_cate');
202 - $timeout_num = $ticketModel->counts(['plan_end_at'=>['>',date('Y-m-d H:i:s')]]); 226 + $timeout_num = $ticketModel
  227 + ->where(function ($query) {
  228 + $query->where(function ($q) {
  229 + $q->whereNotNull('end_at')
  230 + ->whereColumn('plan_end_at', '>', 'end_at');
  231 + })->orWhere(function ($q) {
  232 + $q->whereNull('end_at')
  233 + ->where('plan_end_at', '>', now());
  234 + });
  235 + })
  236 + ->count();
203 $timeout_ratio = null; 237 $timeout_ratio = null;
204 if(!empty($timeout_num)){ 238 if(!empty($timeout_num)){
205 $timeout_ratio = round($timeout_num / $ticket_num, 3); 239 $timeout_ratio = round($timeout_num / $ticket_num, 3);