作者 lyh

变更数据

... ... @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Http\Controllers\Controller;
use App\Models\WorkOrder\TicketProject;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
... ... @@ -139,4 +140,6 @@ class BaseController extends Controller
$response = response($result,$result_code,$header);
throw new HttpResponseException($response);
}
}
... ...
... ... @@ -136,11 +136,11 @@ class Ticket5UploadDataController extends BaseController
public function save()
{
$this->request->validate([
'project_id' => 'required',
'post_id' => 'required',
'type' => 'required',
'text' => 'required'
], [
'project_id.required' => 'project_id不能为空',
'post_od.required' => 'project_id不能为空',
'type.required' => '上传类型不能为空',
'text' => '数据详情不为空'
]);
... ... @@ -152,5 +152,41 @@ class Ticket5UploadDataController extends BaseController
}
//验证当前数据是否已提交
$this->param['text'] = json_encode($this->param['text'], true);
$this->pushTicketByBots($this->param['post_id'],$this->param['type']);
if(isset($this->param['id']) && !empty($this->param['id'])){
//执行编辑
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['status'] == 0){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->response('当前状态不允许编辑', Code::SYSTEM_ERROR);
}
$this->response('success');
}else{
$info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
if ($info === false) {
$id = $this->model->addReturnId($this->param);
} else {
$id = $info['id'];
}
$data = ['id' => $id];
$this->response('success', Code::SUCCESS, $data);
}
}
/**
* @remark :钉钉通知
* @name :pushTicketByBots
* @author :lyh
* @method :post
* @time :2025/11/10 11:10
*/
public function pushTicketByBots($post_id,$type = 1)
{
$project = TicketProject::where('post_id', $post_id)->where('project_cate',$type)->where('is_del', 0)->first();
if (!$project){
return response()->json(['message' => '未找到对应的工单项目'], 404);
}
return $project->pushWechatGroupMsg("您好,用户已上传数据,请审核!");
}
}
... ...
... ... @@ -179,7 +179,7 @@ class TicketUploadDataController extends BaseController
}
//验证当前数据是否已提交
$this->param['text'] = json_encode($this->param['text'], true);
$this->pushTicketByBot($this->param['project_id']);
$this->pushTicketByBots($this->param['project_id']);
if(isset($this->param['id']) && !empty($this->param['id'])){
//执行编辑
$info = $this->model->read(['id'=>$this->param['id']]);
... ... @@ -202,15 +202,15 @@ class TicketUploadDataController extends BaseController
}
/**
* @remark :6.0数据推送微信
* @name :pushTicketByBot
* @remark :钉钉通知
* @name :pushTicketByBots
* @author :lyh
* @method :post
* @time :2025/11/10 10:34
* @time :2025/11/10 11:07
*/
public function pushTicketByBot($project_id)
public function pushTicketByBots($project_id,$type = 2)
{
$project = TicketProject::where('table_id', $project_id)->where('project_cate',2)->where('is_del', 0)->first();
$project = TicketProject::where('table_id', $project_id)->where('project_cate',$type)->where('is_del', 0)->first();
if (!$project){
return response()->json(['message' => '未找到对应的工单项目'], 404);
}
... ...