public function appPublish($appid) { $result = array("s" => true); try { $user = $this->get('security.context')->getToken()->getUser(); $eno = $user->eno; $staff = $user->getUserName(); $da = $this->get("we_data_access"); $caption = ""; if ($appid == "PORTAL") { $caption = "portal_publish"; } else { $caption = "app_publish"; } if ($appid == "PORTAL") { $appid = $eno; $sql = "select * from we_apps_portalconfig where appid=?"; } else { $sql = "select * from we_appcenter_apps where appid=?"; } $dataset = $da->GetData("t", $sql, array((string) $appid)); //判断配置文件是否有编辑或者更改,没有变化时不用发布 $sql = "select publishversion from we_apps_publish where appid=? order by id+0 desc limit 0,1"; $versiondt = $da->GetData("t_v", $sql, array((string) $appid)); $version = count($dataset["t"]["rows"]) == 0 ? 0 : $dataset["t"]["rows"][0]["version"]; $publishversion_max = $versiondt["t_v"]["recordcount"] > 0 ? $versiondt["t_v"]["rows"][0]["publishversion"] : ""; if ($version == $publishversion_max) { $result = array("s" => false, "msg" => "当前版本无更新"); } else { //获取原配置文件生成用于发布的xml文件 //对门户android文件的处理 $doc = $this->get('doctrine.odm.mongodb.document_manager')->getRepository('JustsyMongoDocBundle:WeDocument')->find($dataset["t"]["rows"][0]["configfileid"]); if ($doc == null) { return array("s" => false, "msg" => "配置文件不存在"); } $xmldata = $doc->getFile()->getBytes(); $path = "/tmp/" . $appid . "_publish.xml"; $cont = fopen($path, 'w'); fwrite($cont, $xmldata); fclose($cont); $fileid = $this->saveFile($path); //对门户ios文件的处理 $ios_fileid = null; if ($appid == $eno) { $ios_fileid = $dataset["t"]["rows"][0]["ios_configfileid"]; if (!empty($ios_fileid)) { $doc = $this->get('doctrine.odm.mongodb.document_manager')->getRepository('JustsyMongoDocBundle:WeDocument')->find($ios_fileid); if (empty($doc)) { $ios_fileid = $fileid; } else { $xmldata = $doc->getFile(); if (empty($xmldata)) { $ios_fileid = $fileid; } else { $xmldata = $xmldata->getBytes(); $path = "/tmp/" . $appid . "ios_publish.xml"; $cont = fopen($path, 'w'); fwrite($cont, $xmldata); fclose($cont); $ios_fileid = $this->saveFile($path); } } } } $id = SysSeq::GetSeqNextValue($da, "we_apps_publish", "id"); $sqls = array(); $paras = array(); //更改发布状态 $sql = "update we_apps_publish set publishstate=0 where appid=?"; $parameter = array((string) $appid); array_push($sqls, $sql); array_push($paras, $parameter); //添加发布信息 $sql = "insert into we_apps_publish(id,appid,configfileid,ios_configfileid,publishdate,publishstaff,publishstate,publishversion)value(?,?,?,?,now(),?,1,?)"; $parameter = array((string) $id, (string) $appid, (string) $fileid, $ios_fileid, (string) $staff, (string) $version); array_push($sqls, $sql); array_push($paras, $parameter); //更改应用表最新发布日期及发布人员 $sql = "update we_appcenter_apps set publishdate=now(),publishstaff=? where appid=?"; $parameter = array((string) $user->nick_name, (string) $appid); array_push($sqls, $sql); array_push($paras, $parameter); $da->ExecSQLs($sqls, $paras); $cacheupdate = new \Justsy\BaseBundle\Management\App($this->container); $cacheupdate->refreshPortal(array("eno" => $eno)); //成功后返回的内容 $sql = "select date_format(date_add(publishdate,interval 8 hour),'%Y-%m-%d %H:%i') publishdate from we_apps_publish where appid=? order by id+0 desc limit 1"; $ds = $da->GetData("date", $sql, array((string) $appid)); $date = $ds["date"]["rows"][0]["publishdate"]; //发送出席 $sql = "select fafa_jid from we_staff where state_id!=3 and eno=?"; $ds = $da->GetData("jid", $sql, array((string) $eno)); $tojid = array(); $message = $version; if ($ds && $ds["jid"]["recordcount"] > 0) { for ($i = 0; $i < $ds["jid"]["recordcount"]; $i++) { array_push($tojid, $ds["jid"]["rows"][$i]["fafa_jid"]); if (count($tojid) > 200) { Utils::sendImPresence($this->container->getParameter('im_sender'), implode(",", $tojid), $caption, $message, $this->container, "", "", false, Utils::$systemmessage_code); $tojid = array(); } } } if (count($tojid) > 0) { Utils::sendImPresence($this->container->getParameter('im_sender'), implode(",", $tojid), $caption, $message, $this->container, "", "", false, Utils::$systemmessage_code); } //近回结果//近回结果 $result = array("s" => true, "date" => $date, "staff" => $user->nick_name, "version" => $version, "fileid" => $fileid); } } catch (\Exception $e) { $this->get('logger')->err($e); $result = array("s" => false, "msg" => $e->getMessage()); } return $result; }