Commit afe50bf4 authored by 潘梓豪's avatar 潘梓豪

添加新的脚本

parent 65cfc161
......@@ -10,6 +10,7 @@
use Drupal\zeus_hub\Util\ValCode;
class ApiController extends ControllerBase{
/**
* 保存数据
* @return JsonResponse
......@@ -58,54 +59,51 @@ public function getProductionList(){
//response.header('Access-Control-Allow-Origin: *');
$uid = \Drupal::currentUser()->id();
$database = \Drupal::database();
/* $rs=$database->query("select node__field_robot_code.field_robot_code_value as robot_code, 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_app_path.field_app_path_value ".
"from {node__field_robot_code} as node__field_robot_code left join {node__field_production} as node__field_production on ".
"node__field_robot_code.entity_id=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_user} as node__field_user on ".
"node__field_robot_code.entity_id=node__field_user.entity_id left join {node__field_app_path} as node__field_app_path on node__field_app_path.entity_id=node__field_production.entity_id ".
"where node__field_user.field_user_target_id= :userid",
[
':userid'=>$uid
])->fetchAll();*/
// $us=$database->query("select user__field_parent_user.field_parent_user_target_id as parent_user_id".
// " from user__field_parent_user where user__field_parent_user.entity_id= :userid",
// [
// ':userid'=>$uid,
// ])->fetchAll();
//
// if (count($us)>0){
// $uid=$us[0]->parent_user_id;
// }
//先查找订单内容
$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_app_path.field_app_path_value as production_app_path , 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 ".
"left join (select node__field_app_path.entity_id,node__field_app_path.field_app_path_value,node__field_production.field_production_target_id ".
"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_belong_computer.bundle='register_robot_code' and node__field_computer_code.field_computer_code_value= :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 ,'%') ",
"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 ".
"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_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 ".
"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 ".
// "left join (select node__field_app_path.entity_id,node__field_app_path.field_app_path_value,node__field_production.field_production_target_id ".
// "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();
}
return new JsonResponse(['result'=>$rs]);
}
......@@ -174,7 +172,7 @@ public function saveRobotCode(){
$robotcode = \Drupal::entityTypeManager()
->getStorage('node')
->create([
'title'=>$code.($computer_code->field_computer_name[0]->value),
'title'=>$productionid.'-'.($computer_code->field_computer_name[0]->value),
'field_user'=>[['target_id'=>$uid]],
'field_belong_computer'=>[['target_id'=>$computer_code->id()]],
'field_production'=>[['target_id'=>$productionid]],
......@@ -193,6 +191,7 @@ public function saveRobotCode(){
* */
public function saveComputerCode(){
$uid = \Drupal::currentUser()->id();
$database = \Drupal::database();
$post = json_decode(file_get_contents ( 'php://input' ),TRUE);
$code=$post['code'];
$computer_name=$post['computer_name'];
......@@ -216,6 +215,44 @@ public function saveComputerCode(){
'type'=>'compute_bind'
]);
$robotcode->save();
$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 ".
"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_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 ".
"where node.type='production_order' and node__field_user.field_user_target_id= :userid ",
[
':userid'=>$uid,
])->fetchAll();
return new JsonResponse(['code'=>4,'result'=>count($rs),'type'=>'ComputerCode']);
if(count($rs)>0){
foreach ($rs as $item){
$get_save_robot=\Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties([
'field_user'=>$uid,
'field_production'=>$item->production_id,
'field_belong_computer'=>$robotcode->id(),
'type'=>'register_robot_code'
]);
if(count($get_save_robot)<=0){
$save_robot = \Drupal::entityTypeManager()
->getStorage('node')
->create([
'title'=>$item->production_id.'-'.$computer_name,
'field_user'=>[['target_id'=>$uid]],
'field_belong_computer'=>[['target_id'=>$robotcode->id()]],
'field_production'=>[['target_id'=>$item->production_id]],
'type'=>'register_robot_code'
]);
$save_robot->save();
}
}
}
return new JsonResponse(['code'=>0,'result'=>$computer_name,'type'=>'ComputerCode']);
}else if (count($codepro)>0){
$codepro=array_shift($codepro);
......
#es3cloud保存数据
zeus_es3cloud.easysave:
path: 'zeus/zeushub/easysave'
defaults:
_controller: 'Drupal\zeus_hub\Controller\ApiController::SaveContent'
_title: 'easysave'
requirements:
_access: 'TRUE'
#获取注册机码
zeus_hub.getRobotCode:
......
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 to comment