正在显示
3 个修改的文件
包含
47 行增加
和
8 行删除
| @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Api; | @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Api; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Http\Controllers\Controller; | 11 | use App\Http\Controllers\Controller; |
| 12 | +use App\Models\WorkOrder\TicketProject; | ||
| 12 | use Illuminate\Http\Exceptions\HttpResponseException; | 13 | use Illuminate\Http\Exceptions\HttpResponseException; |
| 13 | use Illuminate\Http\JsonResponse; | 14 | use Illuminate\Http\JsonResponse; |
| 14 | use Illuminate\Http\Request; | 15 | use Illuminate\Http\Request; |
| @@ -139,4 +140,6 @@ class BaseController extends Controller | @@ -139,4 +140,6 @@ class BaseController extends Controller | ||
| 139 | $response = response($result,$result_code,$header); | 140 | $response = response($result,$result_code,$header); |
| 140 | throw new HttpResponseException($response); | 141 | throw new HttpResponseException($response); |
| 141 | } | 142 | } |
| 143 | + | ||
| 144 | + | ||
| 142 | } | 145 | } |
| @@ -136,11 +136,11 @@ class Ticket5UploadDataController extends BaseController | @@ -136,11 +136,11 @@ class Ticket5UploadDataController extends BaseController | ||
| 136 | public function save() | 136 | public function save() |
| 137 | { | 137 | { |
| 138 | $this->request->validate([ | 138 | $this->request->validate([ |
| 139 | - 'project_id' => 'required', | 139 | + 'post_id' => 'required', |
| 140 | 'type' => 'required', | 140 | 'type' => 'required', |
| 141 | 'text' => 'required' | 141 | 'text' => 'required' |
| 142 | ], [ | 142 | ], [ |
| 143 | - 'project_id.required' => 'project_id不能为空', | 143 | + 'post_od.required' => 'project_id不能为空', |
| 144 | 'type.required' => '上传类型不能为空', | 144 | 'type.required' => '上传类型不能为空', |
| 145 | 'text' => '数据详情不为空' | 145 | 'text' => '数据详情不为空' |
| 146 | ]); | 146 | ]); |
| @@ -152,5 +152,41 @@ class Ticket5UploadDataController extends BaseController | @@ -152,5 +152,41 @@ class Ticket5UploadDataController extends BaseController | ||
| 152 | } | 152 | } |
| 153 | //验证当前数据是否已提交 | 153 | //验证当前数据是否已提交 |
| 154 | $this->param['text'] = json_encode($this->param['text'], true); | 154 | $this->param['text'] = json_encode($this->param['text'], true); |
| 155 | + $this->pushTicketByBots($this->param['post_id'],$this->param['type']); | ||
| 156 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 157 | + //执行编辑 | ||
| 158 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 159 | + if($info['status'] == 0){ | ||
| 160 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 161 | + }else{ | ||
| 162 | + $this->response('当前状态不允许编辑', Code::SYSTEM_ERROR); | ||
| 163 | + } | ||
| 164 | + $this->response('success'); | ||
| 165 | + }else{ | ||
| 166 | + $info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]); | ||
| 167 | + if ($info === false) { | ||
| 168 | + $id = $this->model->addReturnId($this->param); | ||
| 169 | + } else { | ||
| 170 | + $id = $info['id']; | ||
| 171 | + } | ||
| 172 | + $data = ['id' => $id]; | ||
| 173 | + $this->response('success', Code::SUCCESS, $data); | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * @remark :钉钉通知 | ||
| 179 | + * @name :pushTicketByBots | ||
| 180 | + * @author :lyh | ||
| 181 | + * @method :post | ||
| 182 | + * @time :2025/11/10 11:10 | ||
| 183 | + */ | ||
| 184 | + public function pushTicketByBots($post_id,$type = 1) | ||
| 185 | + { | ||
| 186 | + $project = TicketProject::where('post_id', $post_id)->where('project_cate',$type)->where('is_del', 0)->first(); | ||
| 187 | + if (!$project){ | ||
| 188 | + return response()->json(['message' => '未找到对应的工单项目'], 404); | ||
| 189 | + } | ||
| 190 | + return $project->pushWechatGroupMsg("您好,用户已上传数据,请审核!"); | ||
| 155 | } | 191 | } |
| 156 | } | 192 | } |
| @@ -179,7 +179,7 @@ class TicketUploadDataController extends BaseController | @@ -179,7 +179,7 @@ class TicketUploadDataController extends BaseController | ||
| 179 | } | 179 | } |
| 180 | //验证当前数据是否已提交 | 180 | //验证当前数据是否已提交 |
| 181 | $this->param['text'] = json_encode($this->param['text'], true); | 181 | $this->param['text'] = json_encode($this->param['text'], true); |
| 182 | - $this->pushTicketByBot($this->param['project_id']); | 182 | + $this->pushTicketByBots($this->param['project_id']); |
| 183 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 183 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 184 | //执行编辑 | 184 | //执行编辑 |
| 185 | $info = $this->model->read(['id'=>$this->param['id']]); | 185 | $info = $this->model->read(['id'=>$this->param['id']]); |
| @@ -202,15 +202,15 @@ class TicketUploadDataController extends BaseController | @@ -202,15 +202,15 @@ class TicketUploadDataController extends BaseController | ||
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | /** | 204 | /** |
| 205 | - * @remark :6.0数据推送微信 | ||
| 206 | - * @name :pushTicketByBot | 205 | + * @remark :钉钉通知 |
| 206 | + * @name :pushTicketByBots | ||
| 207 | * @author :lyh | 207 | * @author :lyh |
| 208 | * @method :post | 208 | * @method :post |
| 209 | - * @time :2025/11/10 10:34 | 209 | + * @time :2025/11/10 11:07 |
| 210 | */ | 210 | */ |
| 211 | - public function pushTicketByBot($project_id) | 211 | + public function pushTicketByBots($project_id,$type = 2) |
| 212 | { | 212 | { |
| 213 | - $project = TicketProject::where('table_id', $project_id)->where('project_cate',2)->where('is_del', 0)->first(); | 213 | + $project = TicketProject::where('table_id', $project_id)->where('project_cate',$type)->where('is_del', 0)->first(); |
| 214 | if (!$project){ | 214 | if (!$project){ |
| 215 | return response()->json(['message' => '未找到对应的工单项目'], 404); | 215 | return response()->json(['message' => '未找到对应的工单项目'], 404); |
| 216 | } | 216 | } |
-
请 注册 或 登录 后发表评论