作者 lyh

gx

@@ -23,6 +23,7 @@ use App\Models\Project\ProjectWhiteHatAffix; @@ -23,6 +23,7 @@ use App\Models\Project\ProjectWhiteHatAffix;
23 use App\Models\Template\BTemplateMain; 23 use App\Models\Template\BTemplateMain;
24 use App\Models\Template\TemplateTypeMain; 24 use App\Models\Template\TemplateTypeMain;
25 use App\Models\WebSetting\WebSetting; 25 use App\Models\WebSetting\WebSetting;
  26 +use App\Models\WorkOrder\Tickets;
26 use App\Services\AiBlogService; 27 use App\Services\AiBlogService;
27 use App\Services\CosService; 28 use App\Services\CosService;
28 use App\Services\Geo\GeoService; 29 use App\Services\Geo\GeoService;
@@ -48,13 +49,14 @@ class lyhDemo extends Command @@ -48,13 +49,14 @@ class lyhDemo extends Command
48 protected $description = '更新路由'; 49 protected $description = '更新路由';
49 50
50 public function handle(){ 51 public function handle(){
51 -// $content = "{Introducing the cutting-edge product from Zhejiang Yuexiang Gas Technology Co., Ltd., the Bracket Gas Flowmeter. This innovative gas flowmeter is designed to provide accurate and reliable measurements for a wide range of industrial applications,Equipped with advanced technology and precision components, the Bracket Gas Flowmeter ensures exceptional performance and durability. It offers highly accurate gas flow readings, allowing users to closely monitor and control gas consumption in various processes. The meter's user-friendly interface displays real-time flow rates and totalized flow data, facilitating efficient and convenient data management,With its robust construction and corrosion-resistant materials, the Bracket Gas Flowmeter guarantees long-term reliability, even in harsh operating conditions. It is compatible with various gases such as natural gas, propane, and hydrogen, making it a versatile choice for multiple industries including oil and gas, chemical, and manufacturing,Furthermore, the Bracket Gas Flowmeter is engineered with ease of installation and maintenance in mind. Its compact and space-saving design allows for flexible mounting options, while its modular construction enables quick and hassle-free maintenance. Additionally, it meets international standards for accuracy and safety, ensuring compliance with industry regulations,Choose the Bracket Gas Flowmeter for precise and efficient gas flow measurement, backed by the expertise and commitment of Zhejiang Yuexiang Gas Technology Co., Ltd},{Shop Quality Brackets: Top China Products & Services for Your Needs},4K,高清 --no logo --ar 16:9";  
52 -// $midJourneyService = new MidJourneyService();  
53 -// $result = $midJourneyService->imagine($content);  
54 - $url = 'https://ecdn6-nc.globalso.com/upload/p/1/png/2025-08/688dcebc26a7a59911.png';  
55 - $cosService = new CosService();  
56 - $data = $cosService->cropAndUploadToCOS($url);  
57 - dd($data); 52 + $ticketModel = new Tickets();
  53 + $list = $ticketModel->list(['end_at'=>['!=',null]]);
  54 + foreach ($list as $item){
  55 + echo '执行的任务id:'.$item['id'];
  56 + $end_time = diffInHours($item['created_at'],$item['end_at']);
  57 + $ticketModel->edit(['end_time'=>$end_time],['id'=>$item['id']]);
  58 + }
  59 + return true;
58 } 60 }
59 61
60 /** 62 /**
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:42
  8 + */
  9 +
  10 +namespace App\Console\Commands\Ticket;
  11 +
  12 +use App\Models\Manage\ManageHr;
  13 +use App\Models\Ticket\TicketDailyManageCount;
  14 +use Illuminate\Console\Command;
  15 +
  16 +class TicketCount extends Command
  17 +{
  18 + /**
  19 + * The name and signature of the console command.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $signature = 'ticket_count {action}';
  24 +
  25 + /**
  26 + * The console command description.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $description = '日统计工单';
  31 +
  32 + /**
  33 + * @remark :统计脚本
  34 + * @name :handle
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2025/8/7 17:45
  38 + */
  39 + public function handle(){
  40 +
  41 + }
  42 +
  43 + /**
  44 + * @remark :按管理员统计(只统计技术组)
  45 + * @name :manage_action
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2025/8/7 17:45
  49 + */
  50 + public function manage_action(){
  51 + $manageHrModel = new ManageHr();
  52 + $manageList = $manageHrModel->list(['status'=>1,'dept_id'=>1],'id',['id','name','nickname']);
  53 + $date = date('Y-m-d');
  54 + $ticketManageCountModel = new TicketDailyManageCount();
  55 + foreach ($manageList as $item){
  56 + $data = [
  57 + 'date'=>$date,
  58 + 'manage_id'=>$item['id'],
  59 + 'manage_name'=>$item['name'],
  60 + 'ticket_num'=>'',//工单总数量
  61 + 'average_time'=>'',//平均完成工单时长
  62 + 'fastest_time'=>'',//最快完成工单时间
  63 + 'timeout_num'=>'',//超时工单数量
  64 + 'complete_num'=>'',//完成工单数量
  65 + ];
  66 + //查询当前用户是否当日已有记录
  67 + $ticketManageInfo = $ticketManageCountModel->read(['date'=>$date,'manage_id'=>$item['id']],['id']);
  68 + if($ticketManageInfo === false){
  69 + //TODO::执行新增
  70 +
  71 + }else{
  72 + //TODO::执行编辑
  73 + }
  74 + }
  75 + }
  76 +}
@@ -1421,3 +1421,22 @@ function getTopDomain ($url) { @@ -1421,3 +1421,22 @@ function getTopDomain ($url) {
1421 return $host; 1421 return $host;
1422 } 1422 }
1423 1423
  1424 +/**
  1425 + * @remark :两个时间的差值
  1426 + * @name :diffInHours
  1427 + * @author :lyh
  1428 + * @method :post
  1429 + * @time :2025/8/8 9:10
  1430 + */
  1431 +function diffInHours($startTime, $endTime)
  1432 +{
  1433 + $start = new DateTime($startTime);
  1434 + $end = new DateTime($endTime);
  1435 + // 计算时间差
  1436 + $interval = $start->diff($end);
  1437 + // 总小时数 = 天数 * 24 + 小时数 + 分钟数换算成小数小时
  1438 + $hours = $interval->days * 24 + $interval->h + ($interval->i / 60);
  1439 + // 四舍五入保留1位小数
  1440 + return round($hours, 1);
  1441 +}
  1442 +
@@ -239,6 +239,7 @@ class AsideTicketController extends BaseController @@ -239,6 +239,7 @@ class AsideTicketController extends BaseController
239 { 239 {
240 // 完成工单,把子任务里面未完成的工单改为完成 240 // 完成工单,把子任务里面未完成的工单改为完成
241 $ticket->end_at = now(); 241 $ticket->end_at = now();
  242 + $ticket->end_time = diffInHours($ticket->end_at,$ticket->created_at);
242 $ticket->logs()->where('status', '<', TicketLog::STATUS_COMPLETED)->where('is_engineer', 1) 243 $ticket->logs()->where('status', '<', TicketLog::STATUS_COMPLETED)->where('is_engineer', 1)
243 ->update(['status' => TicketLog::STATUS_COMPLETED, 'end_at' => now()]); 244 ->update(['status' => TicketLog::STATUS_COMPLETED, 'end_at' => now()]);
244 // 推动微信通知 245 // 推动微信通知
@@ -91,6 +91,7 @@ class AsideTicketLogController extends BaseController @@ -91,6 +91,7 @@ class AsideTicketLogController extends BaseController
91 { 91 {
92 $ticket->status = Tickets::STATUS_COMPLETED; 92 $ticket->status = Tickets::STATUS_COMPLETED;
93 $ticket->end_at = now(); 93 $ticket->end_at = now();
  94 + $ticket->end_time = diffInHours($ticket->end_at,$ticket->created_at);
94 $project = $ticket->project; 95 $project = $ticket->project;
95 if ($project->wechat_switch && !$ticket->close_wechat) 96 if ($project->wechat_switch && !$ticket->close_wechat)
96 $project->pushWechatGroupMsg("工单(ID:{$ticket->id})已全部完成,请访问查看详情!"); 97 $project->pushWechatGroupMsg("工单(ID:{$ticket->id})已全部完成,请访问查看详情!");
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketDailyCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:50
  8 + */
  9 +
  10 +namespace App\Models\Ticket;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :工单日统计
  16 + * @name :TicketDailyCount
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/8/7 17:51
  20 + */
  21 +class TicketDailyCount extends Base
  22 +{
  23 + protected $table = 'gl_ticket_daily_count';
  24 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketDailyDeptCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:51
  8 + */
  9 +
  10 +namespace App\Models\Ticket;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :工单日统计:按照技术组统计
  16 + * @name :TicketDailyDeptCount
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/8/7 17:51
  20 + */
  21 +class TicketDailyDeptCount extends Base
  22 +{
  23 + protected $table = 'gl_ticket_daily_dept_count';
  24 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketDailyManageCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/7 17:52
  8 + */
  9 +
  10 +namespace App\Models\Ticket;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :工单日统计:按照人员统计
  16 + * @name :TicketDailyManageCount
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2025/8/7 17:53
  20 + */
  21 +class TicketDailyManageCount extends Base
  22 +{
  23 + protected $table = 'gl_ticket_daily_manage_count';
  24 +}