深圳全飞鸿
标题:
关于beacon的J方案的afterajax
[打印本页]
作者:
syant
时间:
2024-11-26 17:28
标题:
关于beacon的J方案的afterajax
关于beacon的J方案的afterajax
//mqtt data
$mqttdata = array(
"jobid" => 1,
"ma" => $machine,
"data" => $inputdata,
"ec" => 0,
"msg" => "wait...",
"t" => date("Y-m-d H:i:s")
);
$this->app->ajaxAttr("mqtt", $mqttdata);
复制代码
function afterAjax()
{
$this->app->prepare_mqtt();
$data = $this->app->jsdata;
$mqttdata = $data["mqtt"];
$machine = $mqttdata["ma"];
$machineInfo = $this->app->getMachineInfo($machine);
$mqttdata["msg"] = $data["msg"];
$mqttdata["ec"] = $data["ec"];
$mqttdata["wo"] = $machineInfo["WO"];
$mqttdata["empno"] = $machineInfo["emp_no"];
$floor = $machineInfo["FLOOR_CODE"];
if ($data["jobid"]) {
$mqttdata["jobid"] = $data["jobid"];
}
if ($mqttdata["ec"] == 999) {
$mqttdata["msg"] = "准备打印!";
}
if (strlen($machine) > 1) {
$this->app->mqtt->publish("MACHINE/{$floor}/{$machine}", json_encode($mqttdata, JSON_UNESCAPED_UNICODE));
}
}
复制代码
J方案中的变更:
function ajax(){
global $config;
//获取从页面返回的参数;
$params=$this->app->readAjaxParam();
//首先提取Ajax的Debug状态...
if(array_key_exists("debug", $params)){
if($params["debug"]*1>0){
$this->app->setDebug(true);
}
}
//提取Ajax的lan语言...
if(array_key_exists("lan", $params)){
//改为语言
$lan=$params["lan"];
$config->country=$lan;
$this->app->language=$lan;
}
//add by syant 2020-10-01 在没有module类时,这样有机会做一些和S.php不一样的事,又不能放在构造函数中的事情!
if(method_exists($this,'beforeAjax')){ //如果有beforeAjax函数, 就执行
$this->beforeAjax($params);
}else{
if(method_exists($this->app,'beforeAjax')){ //如果父类里有beforeAjax函数, 就执行
$this->app->beforeAjax($params);
}
}
//$this->app->AjaxLog(var_export($params,true));
if (!array_key_exists('action', $params)) {
$this->app->ajax($params); //如果没有找到处理,继续住app去找
//注意,是app自己处理的over();
} else {
$action=$params["action"];
$this->app->AjaxFail("未处理{$action}!");
if(method_exists($this,$action)){
$this->app->AjaxFail("{$action}已找到,但未返回结果!");
$this->$action($params);
}else{
if(method_exists($this->app,$action)){
$this->app->AjaxFail("{$action}已找到,但未返回结果!!");
$this->app->$action($params);
}
}
}
//---
if(method_exists($this,'afterAjax')){ //如果有afterAjax函数, 就执行
$this->afterAjax($params);
}else{
if(method_exists($this->app,'afterAjax')){ //如果父类里有afterAjax函数, 就执行
$this->app->afterAjax($params);
}
}
//---
//$this->app->over(); //返回json数据!
}
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2