Commit c3a7675c by 孙龙

up

parent 1e853cf6
...@@ -5,6 +5,7 @@ use App\Exceptions\IcException; ...@@ -5,6 +5,7 @@ use App\Exceptions\IcException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use DB; use DB;
use Log;
use App\Model\TemplateListModel; use App\Model\TemplateListModel;
use App\Model\SaleOrderListsModel; use App\Model\SaleOrderListsModel;
use App\Model\TmplRelationsModel; use App\Model\TmplRelationsModel;
...@@ -89,13 +90,14 @@ Class AjaxController extends Controller ...@@ -89,13 +90,14 @@ Class AjaxController extends Controller
$perm = new PermController; $perm = new PermController;
// 用户角色 // 用户角色
$role = $perm->getUserRole($request); $role = $perm->getUserRole($request);
$tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find($id); $tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id));
if($tmpl){ if($tmpl){
$tmpl->status = ($tmpl->status == -1) ? 1 :-1; $tmpl->status = ($tmpl->status == -1) ? 1 :-1;
$tmpl->save(); $tmpl->save();
//此处推送到erp //此处推送到erp
$this->pushTemplateErp(); if(!$this->pushTemplateErp(intval($id))){
return $this->ajaxReturn(-1,"模板信息推送至erp失败");
}
return $this->ajaxReturn(0,"修改成功"); return $this->ajaxReturn(0,"修改成功");
}else{ }else{
return $this->ajaxReturn(-1,"没找到与自己对应的模板"); return $this->ajaxReturn(-1,"没找到与自己对应的模板");
...@@ -113,13 +115,15 @@ Class AjaxController extends Controller ...@@ -113,13 +115,15 @@ Class AjaxController extends Controller
} }
$tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id)); $tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id));
if(!$tmpl){ if(!$tmpl){
return $this->ajaxReturn(-1,"没找到与自己对应的模板"); return $this->ajaxReturn(-1,"您只能修改自己创建的模板哦!");
} }
$tmpl->template_name = $template_name; $tmpl->template_name = $template_name;
$tmpl->save(); $tmpl->save();
//此处推送到erp //此处推送到erp
if(!$this->pushTemplateErp(intval($id))){
return $this->ajaxReturn(-1,"模板信息推送至erp失败");
}
return $this->ajaxReturn(0,"修改成功"); return $this->ajaxReturn(0,"修改成功");
...@@ -136,25 +140,34 @@ Class AjaxController extends Controller ...@@ -136,25 +140,34 @@ Class AjaxController extends Controller
} }
protected function pushTemplateErp(){ /*
* 推送模板消息到erp
*/
protected function pushTemplateErp($t_id=0){
try{ try{
$template = TemplateListModel::find($t_id);
//登录 //登录
$soap = new \SoapClient(env("ERP_DOMAIN").'/ormrpc/services/EASLogin?wsdl'); $soap = new \SoapClient(env("ERP_DOMAIN").'/ormrpc/services/EASLogin?wsdl');
$res = $soap->login( 'TC', 'unicom', 'eas', env('ERP_DB_NAME'), 'L2', 1, 'BaseDB'); $res = $soap->login( 'TC', 'unicom', 'eas', env('ERP_DB_NAME'), 'L2', 1, 'BaseDB');
//接口 //接口
$this->erp = new \SoapClient(ENV("ERP_DOMAIN").'/ormrpc/services/WSIchuntjKFacade?wsdl'); $this->erp = new \SoapClient(ENV("ERP_DOMAIN").'/ormrpc/services/WSIchuntjKFacade?wsdl');
$tmp = $this->erp->createIssueLabel(json_encode([ $res = $this->erp->createIssueLabel(json_encode([
"templateId"=>1, "templateId"=>$template->id,
"templateNmae"=>"aaaa", "templateNmae"=>$template->template_name,
"createUser"=>"bbbb", "createUser"=>$template->create_username,
"status"=>1, "status"=>intval($template->status),
])); ]));
dump($tmp); if($res){
return true; $res = \GuzzleHttp\json_decode($res,true);
if(isset($res["0000"])){
return true;
}
}
return false;
}catch(\Exception $e){ }catch(\Exception $e){
dump($e); Log::info(sprintf("模板更新信息推送到erp失败:%s",$e->getMessage()));
return false; return false;
// dump($e->getMessage());
} }
} }
...@@ -216,6 +229,11 @@ Class AjaxController extends Controller ...@@ -216,6 +229,11 @@ Class AjaxController extends Controller
if($templateExtend === false){ if($templateExtend === false){
throw new \Exception("修改模板属性失败",-1); throw new \Exception("修改模板属性失败",-1);
} }
//此处推送到erp
if(!$this->pushTemplateErp($data['t_id'])){
throw new \Exception("模板信息推送至erp失败",-1);
}
}); });
return $this->ajaxReturn(0,"修改模板成功"); return $this->ajaxReturn(0,"修改模板成功");
}catch(\Exception $e){ }catch(\Exception $e){
...@@ -256,6 +274,10 @@ Class AjaxController extends Controller ...@@ -256,6 +274,10 @@ Class AjaxController extends Controller
if(!$templateExtend){ if(!$templateExtend){
throw new \Exception("添加模板失败",-1); throw new \Exception("添加模板失败",-1);
} }
//此处推送到erp
if(!$this->pushTemplateErp($templateList->id)){
throw new \Exception("模板信息推送至erp失败",-1);
}
}); });
return $this->ajaxReturn(0,"添加模板成功"); return $this->ajaxReturn(0,"添加模板成功");
}catch(\Exception $e){ }catch(\Exception $e){
......
...@@ -88,7 +88,7 @@ class WebController extends Controller ...@@ -88,7 +88,7 @@ class WebController extends Controller
* 设计 * 设计
*/ */
public function design($request,$info){ public function design($request,$info){
throw new \Exception("测试报错");
$info['title'] = '标签设计'; $info['title'] = '标签设计';
return view('web', $info); return view('web', $info);
} }
......
...@@ -7,8 +7,8 @@ return [ ...@@ -7,8 +7,8 @@ return [
// curl证书验证, 线下环境不用开启 // curl证书验证, 线下环境不用开启
'curl_verify' => true, 'curl_verify' => true,
'web_name'=>'定时任务系统错误[请及时修改]', 'web_name'=>'标签库系统告警[请及时修改]',
// webhook的值 // webhook的值
'webhook' => 'https://oapi.dingtalk.com/robot/send?access_token=574c05663dd4bcfae50a3cfde9b2b1c1f1630e00557c3f5b683077772ed960b8', 'webhook' => 'https://oapi.dingtalk.com/robot/send?access_token=ba4ed87924ee03b37d2b96ba0f0cb1a28d476bda3af6b2e75a2458b08b5ae39c',
]; ];
\ No newline at end of file
...@@ -49,27 +49,27 @@ class Monitor ...@@ -49,27 +49,27 @@ class Monitor
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
$enabled = config('monitorDing.enabled'); $enabled = config('monitorDing.enabled');
$sysName = config('monitorDing.web_name');
try { try {
$response = $next($request); $response = $next($request);
} catch (Exception $e) { } catch (Exception $e) {
$response = $this->handleException($request, $e); $response = $this->handleException($request, $e);
$enabled && $this->monitor->sendText(sprintf("文件:%s (%s 行) 内容:%s", $e->getFile(), $e->getLine(), $e->getMessage())); $enabled && $this->monitor->sendText(sprintf("%s,文件:%s (%s 行) 内容:%s",$sysName, $e->getFile(), $e->getLine(), $e->getMessage()));
} catch (Error $error) { } catch (Error $error) {
$e = new FatalThrowableError($error); $e = new FatalThrowableError($error);
$response = $this->handleException($request, $e); $response = $this->handleException($request, $e);
$enabled && $this->monitor->sendText(sprintf("文件:%s (%s 行) 内容:%s", $e->getFile(), $e->getLine(), $e->getMessage())); $enabled && $this->monitor->sendText(sprintf("%s,文件:%s (%s 行) 内容:%s", $sysName,$e->getFile(), $e->getLine(), $e->getMessage()));
}catch(ErrorException $error){ }catch(ErrorException $error){
$e = new FatalThrowableError($error); $e = new FatalThrowableError($error);
$response = $this->handleException($request, $e); $response = $this->handleException($request, $e);
$enabled && $this->monitor->sendText(sprintf("文件:%s (%s 行) 内容:%s", $e->getFile(), $e->getLine(), $e->getMessage())); $enabled && $this->monitor->sendText(sprintf("%s,文件:%s (%s 行) 内容:%s",$sysName, $e->getFile(), $e->getLine(), $e->getMessage()));
}catch(SendErrorException $error){ }catch(SendErrorException $error){
$e = new FatalThrowableError($error); $e = new FatalThrowableError($error);
$response = $this->handleException($request, $e); $response = $this->handleException($request, $e);
$enabled && $this->monitor->sendText(sprintf("文件:%s (%s 行) 内容:%s", $e->getFile(), $e->getLine(), $e->getMessage())); $enabled && $this->monitor->sendText(sprintf("%s,文件:%s (%s 行) 内容:%s",$sysName, $e->getFile(), $e->getLine(), $e->getMessage()));
}finally{ }finally{
if($response->getStatusCode() == '500' && (isset($response->exception) && $response->exception && $response->exception !== null)){ if($response->getStatusCode() == '500' && (isset($response->exception) && $response->exception && $response->exception !== null)){
$sysName = config('monitorDing.web_name');
$this->monitor->sendText(substr($sysName.":".$response->exception,0,500)."---[更多详情请看日志]"); $this->monitor->sendText(substr($sysName.":".$response->exception,0,500)."---[更多详情请看日志]");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment