public function changeStaffDeptAction($network_domain) { $res = $this->get("request"); $account = trim($res->get("staff")); $deptid = trim($res->get("deptid")); if (empty($account) || empty($deptid)) { $response = new Response(json_encode(array("s" => 0, "msg" => "人员帐号或部门不能为空"))); $response->headers->set('Content-Type', 'text/json'); return $response; } try { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $accountList = explode(",", $account); $user = $this->get('security.context')->getToken()->getUser(); $deptmgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im); $deptInfo = $deptmgr->getinfo($deptid); if ($deptInfo != null) { for ($i = 0; $i < count($accountList); $i++) { $staffmgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $accountList[$i]); $result_jid = $staffmgr->moveToDept($deptid, $deptInfo["fafa_deptid"]); //如果是其他人员更新了自己的部门,则向被移动的人员发条消息 if ($user->getUsername() != $accountList[$i]) { try { //发送即时消息 $message = "你的所属部门已变更为【" . $deptInfo["dept_name"] . "】"; Utils::sendImMessage($user->fafa_jid, $result_jid, "资料变更", $message, $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $this->get('logger')->err($e); } } } $response = new Response(json_encode(array("s" => 1, "msg" => ""))); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $response = new Response(json_encode(array("s" => 0, "msg" => "部门编号无效"))); $response->headers->set('Content-Type', 'text/json'); return $response; } } catch (\Exception $e) { $this->get("logger")->err($e); $response = new Response(json_encode(array("s" => 0, "msg" => "数据操作失败"))); $response->headers->set('Content-Type', 'text/json'); return $response; } }