Commit c3a7675c by 孙龙

up

parent 1e853cf6
......@@ -5,6 +5,7 @@ use App\Exceptions\IcException;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Log;
use App\Model\TemplateListModel;
use App\Model\SaleOrderListsModel;
use App\Model\TmplRelationsModel;
......@@ -89,13 +90,14 @@ Class AjaxController extends Controller
$perm = new PermController;
// 用户角色
$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){
$tmpl->status = ($tmpl->status == -1) ? 1 :-1;
$tmpl->save();
//此处推送到erp
$this->pushTemplateErp();
if(!$this->pushTemplateErp(intval($id))){
return $this->ajaxReturn(-1,"模板信息推送至erp失败");
}
return $this->ajaxReturn(0,"修改成功");
}else{
return $this->ajaxReturn(-1,"没找到与自己对应的模板");
......@@ -113,13 +115,15 @@ Class AjaxController extends Controller
}
$tmpl = TemplateListModel::where("create_userid",$request->user->userId)->find(intval($id));
if(!$tmpl){
return $this->ajaxReturn(-1,"没找到与自己对应的模板");
return $this->ajaxReturn(-1,"您只能修改自己创建的模板哦!");
}
$tmpl->template_name = $template_name;
$tmpl->save();
//此处推送到erp
if(!$this->pushTemplateErp(intval($id))){
return $this->ajaxReturn(-1,"模板信息推送至erp失败");
}
return $this->ajaxReturn(0,"修改成功");
......@@ -136,25 +140,34 @@ Class AjaxController extends Controller
}
protected function pushTemplateErp(){
/*
* 推送模板消息到erp
*/
protected function pushTemplateErp($t_id=0){
try{
$template = TemplateListModel::find($t_id);
//登录
$soap = new \SoapClient(env("ERP_DOMAIN").'/ormrpc/services/EASLogin?wsdl');
$res = $soap->login( 'TC', 'unicom', 'eas', env('ERP_DB_NAME'), 'L2', 1, 'BaseDB');
//接口
$this->erp = new \SoapClient(ENV("ERP_DOMAIN").'/ormrpc/services/WSIchuntjKFacade?wsdl');
$tmp = $this->erp->createIssueLabel(json_encode([
"templateId"=>1,
"templateNmae"=>"aaaa",
"createUser"=>"bbbb",
"status"=>1,
$res = $this->erp->createIssueLabel(json_encode([
"templateId"=>$template->id,
"templateNmae"=>$template->template_name,
"createUser"=>$template->create_username,
"status"=>intval($template->status),
]));
dump($tmp);
return true;
if($res){
$res = \GuzzleHttp\json_decode($res,true);
if(isset($res["0000"])){
return true;
}
}
return false;
}catch(\Exception $e){
dump($e);
Log::info(sprintf("模板更新信息推送到erp失败:%s",$e->getMessage()));
return false;
// dump($e->getMessage());
}
}
......@@ -216,6 +229,11 @@ Class AjaxController extends Controller
if($templateExtend === false){
throw new \Exception("修改模板属性失败",-1);
}
//此处推送到erp
if(!$this->pushTemplateErp($data['t_id'])){
throw new \Exception("模板信息推送至erp失败",-1);
}
});
return $this->ajaxReturn(0,"修改模板成功");
}catch(\Exception $e){
......@@ -256,6 +274,10 @@ Class AjaxController extends Controller
if(!$templateExtend){
throw new \Exception("添加模板失败",-1);
}
//此处推送到erp
if(!$this->pushTemplateErp($templateList->id)){
throw new \Exception("模板信息推送至erp失败",-1);
}
});
return $this->ajaxReturn(0,"添加模板成功");
}catch(\Exception $e){
......
......@@ -88,7 +88,7 @@ class WebController extends Controller
* 设计
*/
public function design($request,$info){
throw new \Exception("测试报错");
$info['title'] = '标签设计';
return view('web', $info);
}
......
......@@ -7,8 +7,8 @@ return [
// curl证书验证, 线下环境不用开启
'curl_verify' => true,
'web_name'=>'定时任务系统错误[请及时修改]',
'web_name'=>'标签库系统告警[请及时修改]',
// 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
public function handle($request, Closure $next)
{
$enabled = config('monitorDing.enabled');
$sysName = config('monitorDing.web_name');
try {
$response = $next($request);
} catch (Exception $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) {
$e = new FatalThrowableError($error);
$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){
$e = new FatalThrowableError($error);
$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){
$e = new FatalThrowableError($error);
$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{
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)."---[更多详情请看日志]");
}
}
......
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