$rs=$database->query("select node__field_production_name.field_production_name_value as production_name, ".
"node__field_scene_name.field_scene_name_value as scene_name, node.nid as production_id, node__field_download_url.field_download_url_value as production_download_url, ".
"node__field_belong_computer.computer_code as production_robot_code,node__field_app_name.field_app_name_value as app_name ".
"from {node} as node left join {node__field_production_name} as node__field_production_name on node__field_production_name.entity_id=node.nid ".
"left join {node__field_scene_name} as node__field_scene_name on node__field_scene_name.entity_id=node.nid ".
"left join {node__field_download_url} as node__field_download_url on node__field_download_url.entity_id=node.nid ".
"left join {node__field_app_name} as node__field_app_name on node__field_app_name.entity_id=node.nid ".
// "from {node__field_app_path} as node__field_app_path left join {node__field_user} as node__field_user on node__field_app_path.entity_id=node__field_user.entity_id ".
// "left join {node__field_production} as node__field_production on node__field_app_path.entity_id=node__field_production.entity_id ".
// "where node__field_user.field_user_target_id= :userid and node__field_app_path.bundle='setting_msg') as node__field_app_path on node__field_app_path.field_production_target_id=node.nid ".
"left join ( select node__field_computer_code.field_computer_code_value as computer_code,node__field_user.field_user_target_id,node__field_production.field_production_target_id from {node__field_belong_computer} as node__field_belong_computer ".
"left join {node__field_computer_code} as node__field_computer_code on node__field_belong_computer.field_belong_computer_target_id=node__field_computer_code.entity_id ".
"left join {node__field_user} as node__field_user on node__field_computer_code.entity_id =node__field_user.entity_id ".
"left join {node__field_production} as node__field_production on node__field_production.entity_id=node__field_belong_computer.entity_id ".
"where (node__field_user.field_user_target_id= :userid and node__field_computer_code.field_computer_code_value= :code ) and node__field_belong_computer.bundle='register_robot_code' ) as node__field_belong_computer on node__field_belong_computer.field_production_target_id=node.nid ".
/* "left join (select node__field_robot_code.field_robot_code_value,node__field_production.field_production_target_id,node__field_user.field_user_target_id from {node__field_robot_code} as node__field_robot_code left join {node__field_user} as node__field_user on node__field_robot_code.entity_id=node__field_user.entity_id ".
"left join {node__field_production} as node__field_production on node__field_robot_code.entity_id=node__field_production.entity_id where node__field_user.field_user_target_id= :userid and node__field_robot_code.bundle='register_robot_code' ) as node__field_robot_code on node__field_robot_code.field_production_target_id=node.nid ".
"where node.type='unity_production' and (node__field_belong_computer.field_user_target_id= :userid )and node__field_production_name.field_production_name_value like concat('%', :name ,'%') ",
@@ -60,50 +60,55 @@ public function getProductionList(){
$uid=\Drupal::currentUser()->id();
$database=\Drupal::database();
//先查找订单内容
//查找订单内容
$rs=$database->query("select node__field_production_name.field_production_name_value as production_name, ".
"node__field_scene_name.field_scene_name_value as scene_name, node__field_production.field_production_target_id as production_id, node__field_download_url.field_download_url_value as production_download_url, ".
"node__field_app_name.field_app_name_value as app_name ".
"node__field_production.field_production_target_id as production_id, node__field_download_url.field_download_url_value as production_download_url, ".
"node__field_app_name.field_app_name_value as app_name,node__field_belong_computer.computer_code ".
"from {node} as node left join {node__field_production} as node__field_production on node.nid=node__field_production.entity_id ".
"left join {node__field_production_name} as node__field_production_name on node__field_production_name.entity_id=node__field_production.field_production_target_id ".
"left join {node__field_scene_name} as node__field_scene_name on node__field_scene_name.entity_id=node__field_production.field_production_target_id ".
//"left join {node__field_scene_name} as node__field_scene_name on node__field_scene_name.entity_id=node__field_production.field_production_target_id ".
"left join {node__field_download_url} as node__field_download_url on node__field_download_url.entity_id=node__field_production.field_production_target_id ".
"left join {node__field_app_name} as node__field_app_name on node__field_app_name.entity_id=node__field_production.field_production_target_id ".
"left join {node__field_user} as node__field_user on node__field_user.entity_id=node.nid ".
"left join ( select node__field_computer_code.field_computer_code_value as computer_code,node__field_user.field_user_target_id,node__field_production.field_production_target_id from {node__field_belong_computer} as node__field_belong_computer ".
"left join {node__field_computer_code} as node__field_computer_code on node__field_belong_computer.field_belong_computer_target_id=node__field_computer_code.entity_id ".
"left join {node__field_user} as node__field_user on node__field_computer_code.entity_id =node__field_user.entity_id ".
"left join {node__field_production} as node__field_production on node__field_production.entity_id=node__field_belong_computer.entity_id ".
"where (node__field_user.field_user_target_id= :userid and node__field_computer_code.field_computer_code_value= :code ) and node__field_belong_computer.bundle='register_robot_code' ) as node__field_belong_computer on node__field_belong_computer.field_production_target_id=node__field_production.field_production_target_id ".
"where node.type='production_order' and node__field_user.field_user_target_id= :userid and node__field_production_name.field_production_name_value like concat('%', :name ,'%') ",
[
':userid'=>$uid,
':name'=>$_GET['search_txt'],
':code'=>$_GET['code']
])->fetchAll();
if(count($rs)<=0){
$rs=$database->query("select node__field_production_name.field_production_name_value as production_name, ".
"node__field_scene_name.field_scene_name_value as scene_name, node.nid as production_id, node__field_download_url.field_download_url_value as production_download_url, ".
"node__field_belong_computer.computer_code as production_robot_code,node__field_app_name.field_app_name_value as app_name ".
"from {node} as node left join {node__field_production_name} as node__field_production_name on node__field_production_name.entity_id=node.nid ".
"left join {node__field_scene_name} as node__field_scene_name on node__field_scene_name.entity_id=node.nid ".
"left join {node__field_download_url} as node__field_download_url on node__field_download_url.entity_id=node.nid ".
"left join {node__field_app_name} as node__field_app_name on node__field_app_name.entity_id=node.nid ".
// "from {node__field_app_path} as node__field_app_path left join {node__field_user} as node__field_user on node__field_app_path.entity_id=node__field_user.entity_id ".
// "left join {node__field_production} as node__field_production on node__field_app_path.entity_id=node__field_production.entity_id ".
// "where node__field_user.field_user_target_id= :userid and node__field_app_path.bundle='setting_msg') as node__field_app_path on node__field_app_path.field_production_target_id=node.nid ".
"left join ( select node__field_computer_code.field_computer_code_value as computer_code,node__field_user.field_user_target_id,node__field_production.field_production_target_id from {node__field_belong_computer} as node__field_belong_computer ".
"left join {node__field_computer_code} as node__field_computer_code on node__field_belong_computer.field_belong_computer_target_id=node__field_computer_code.entity_id ".
"left join {node__field_user} as node__field_user on node__field_computer_code.entity_id =node__field_user.entity_id ".
"left join {node__field_production} as node__field_production on node__field_production.entity_id=node__field_belong_computer.entity_id ".
"where (node__field_user.field_user_target_id= :userid and node__field_computer_code.field_computer_code_value= :code ) and node__field_belong_computer.bundle='register_robot_code' ) as node__field_belong_computer on node__field_belong_computer.field_production_target_id=node.nid ".
/* "left join (select node__field_robot_code.field_robot_code_value,node__field_production.field_production_target_id,node__field_user.field_user_target_id from {node__field_robot_code} as node__field_robot_code left join {node__field_user} as node__field_user on node__field_robot_code.entity_id=node__field_user.entity_id ".
"left join {node__field_production} as node__field_production on node__field_robot_code.entity_id=node__field_production.entity_id where node__field_user.field_user_target_id= :userid and node__field_robot_code.bundle='register_robot_code' ) as node__field_robot_code on node__field_robot_code.field_production_target_id=node.nid ".*/
"where node.type='unity_production' and (node__field_belong_computer.field_user_target_id= :userid )and node__field_production_name.field_production_name_value like concat('%', :name ,'%') ",
[
':userid'=>$uid,
':name'=>$_GET['search_txt'],
':code'=>$_GET['code']
])->fetchAll();
}
//用户查找不出,根据code查找
// if(count($rs)<=0){
// $rs=$database->query("select node__field_production_name.field_production_name_value as production_name, ".
// "node__field_scene_name.field_scene_name_value as scene_name, node.nid as production_id, node__field_download_url.field_download_url_value as production_download_url, ".
// "node__field_belong_computer.computer_code as production_robot_code,node__field_app_name.field_app_name_value as app_name ".
// "from {node} as node left join {node__field_production_name} as node__field_production_name on node__field_production_name.entity_id=node.nid ".
// "left join {node__field_scene_name} as node__field_scene_name on node__field_scene_name.entity_id=node.nid ".
// "left join {node__field_download_url} as node__field_download_url on node__field_download_url.entity_id=node.nid ".
// "left join {node__field_app_name} as node__field_app_name on node__field_app_name.entity_id=node.nid ".
//// "from {node__field_app_path} as node__field_app_path left join {node__field_user} as node__field_user on node__field_app_path.entity_id=node__field_user.entity_id ".
//// "left join {node__field_production} as node__field_production on node__field_app_path.entity_id=node__field_production.entity_id ".
//// "where node__field_user.field_user_target_id= :userid and node__field_app_path.bundle='setting_msg') as node__field_app_path on node__field_app_path.field_production_target_id=node.nid ".
// "left join ( select node__field_computer_code.field_computer_code_value as computer_code,node__field_user.field_user_target_id,node__field_production.field_production_target_id from {node__field_belong_computer} as node__field_belong_computer ".
// "left join {node__field_computer_code} as node__field_computer_code on node__field_belong_computer.field_belong_computer_target_id=node__field_computer_code.entity_id ".
// "left join {node__field_user} as node__field_user on node__field_computer_code.entity_id =node__field_user.entity_id ".
// "left join {node__field_production} as node__field_production on node__field_production.entity_id=node__field_belong_computer.entity_id ".
// "where node__field_computer_code.field_computer_code_value= :code and node__field_belong_computer.bundle='register_robot_code' ) as node__field_belong_computer on node__field_belong_computer.field_production_target_id=node.nid ".
//
// /* "left join (select node__field_robot_code.field_robot_code_value,node__field_production.field_production_target_id,node__field_user.field_user_target_id from {node__field_robot_code} as node__field_robot_code left join {node__field_user} as node__field_user on node__field_robot_code.entity_id=node__field_user.entity_id ".
// "left join {node__field_production} as node__field_production on node__field_robot_code.entity_id=node__field_production.entity_id where node__field_user.field_user_target_id= :userid and node__field_robot_code.bundle='register_robot_code' ) as node__field_robot_code on node__field_robot_code.field_production_target_id=node.nid ".*/
// "where node.type='unity_production' and node__field_production_name.field_production_name_value like concat('%', :name ,'%') and node__field_belong_computer.computer_code= :code ",
// [
// ':name'=>$_GET['search_txt'],
// ':code'=>$_GET['code']
// ])->fetchAll();
// }
returnnewJsonResponse(['result'=>$rs]);
}
...
...
@@ -146,44 +151,71 @@ public function saveRobotCode(){
@@ -291,6 +327,111 @@ public function getComputerCode(){
}
}
/*
* 查询该用户产品已绑定和未绑定的计算机
* */
publicfunctiongetComputerCodeListByOrder(){
$uid=\Drupal::currentUser()->id();
$database=\Drupal::database();
$productionid=$_GET['productionid'];
$rs=$database->query("SELECT node__field_computer_name.field_computer_name_value as computer_name,node.nid as computer_id,has_robot_code.production_id ".
"FROM {node} as node LEFT JOIN ".
"(select node__field_belong_computer.field_belong_computer_target_id as computer_id , ".
"node__field_production.field_production_target_id as production_id ".
"from {node} as node ".
"left join {node__field_production} as node__field_production on node.nid=node__field_production.entity_id ".
"left join {node__field_belong_computer} as node__field_belong_computer on node.nid=node__field_belong_computer.entity_id ".
"where node.type='register_robot_code' and node__field_production.field_production_target_id= :productionid ) AS has_robot_code ".
"ON node.nid=has_robot_code.computer_id ".
"left join {node__field_computer_name} as node__field_computer_name on node__field_computer_name.entity_id=node.nid ".
"left join {node__field_user} as node__field_user on node__field_user.entity_id=node.nid ".
"where node.type='compute_bind' and node__field_user.field_user_target_id= :userid ",
"WHERE node.type='production_order' AND node__field_user.field_user_target_id= :userid AND node__field_production.field_production_target_id= :productionid ",