parent_key = $parentFlow->getFormKey(); } $this->seq = $this->_getSeq(); } public function __toString() { return json_encode($this); } public static function getDetail($parentKey, $seq = 0) { $detail = DB::result("select * from workflow_subflow where seq='" . $seq . "' and parent_key ='" . $parentKey . "'"); return $detail; } /** * @desc workflow_sublow 新增一条记录 * @param Subflow $subflow * @param $sender * @param int $seq */ public function append(Subflow $subflow, $sender, $seq = null) { DB::query("insert into workflow_subflow (FORM_KEY, SEQ, PARENT_KEY, LEADER_NO, CREATE_DATE, SENDER) values ('" . $subflow->getFormKey() . "', '" . $this->seq . "', '" . $this->parent_key . "', '" . $subflow->current_assigner . "', now(), '" . $sender . "' ) "); } static function getChildNode($childFormKey) { $node = DB::result("select * from workflow_subflow where form_key ='" . $childFormKey . "'"); return $node[0]; } /** * 未回复统计 * @return integer|null */ public function getUnReplyCount($seq = null) { if ($seq == null) { return null; } list($cnt) = DB::fields("select count(*) from workflow_subflow where reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'"); return $cnt; } /** * 未回复明细 * @return array|void */ public function getUnReplyDetail($seq = null) { if ($seq == null) { return null; } list($detail) = DB::fields("select * from workflow_subflow where reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'"); return $detail; } /** * 已回复统计 * @param null $seq * @return integer */ public function getReplyCount($seq = null) { if ($seq == null) { return null; } list($cnt) = DB::fields("select count(*) from workflow_subflow where reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'"); return $cnt; } /** * 已回复明细 * @param null $seq 会签的序号 * @return integer */ public function getReplyDetail($seq = null) { if ($seq == null) { return null; } $detail = DB::result("select * from workflow_subflow where reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'"); return $detail; } /** * 获取$parentKey 已经会签或拆分的次数 * @return integer */ private function _getSeq() { list($cnt) = DB::fields("select nvl(max(seq),-1)+1 from workflow_subflow where parent_key ='" . $this->parent_key . "'"); return $cnt; } /** * 获取$parentKey已经会签或拆分的次数 * @return integer */ public static function getSeqByFormKey($formKey) { list($seq) = DB::fields("select seq from workflow_subflow where form_key ='" . $formKey . "'"); return $seq; } /** * 获取该节点 * @param $formKey * @return integer */ public static function getCurrentParentFlowCode($formKey) { $flow = new Flow($formKey); list($flow_code) = DB::fields("select flow_code from flow where form_key ='" . $flow->getParentKey() . "'"); return $flow_code; } /** * @param $formKey * @param $flag REPLY_FLAG */ public static function updateReplyFlag($formKey, $flag) { $where = "form_key = '" . $formKey . "'"; DB::update_table("workflow_subflow", array( "REPLY_FLAG" => "'" . $flag . "'" ), $where); } /** * * 获取会签中不同意的数量 * @param $seq * @return null */ public function getRejectOpinionCount($seq) { if ($seq == null) { return null; } $details = $this->getReplyDetail($seq); $cnt = 0; foreach ($details as $row) { if ($row['reply_flag'] == 'N') { $cnt++; } } return $cnt; } /** * * 获取会签中不同意的数量 */ public function getAcceptOpinionCount($seq) { if ($seq == null) { return null; } $details = $this->getReplyDetail($seq); $cnt = 0; foreach ($details as $row) { if ($row['reply_flag'] == 'Y') { $cnt++; } } return $cnt; } public static function updateReplyComment($formKey, $comment) { $where = "form_key = '" . $formKey . "'"; DB::update_table("workflow_subflow", array( "REPLY_COMMENT" => "'" . $comment . "'" ), $where); self::updateChangeDate($formKey); } public static function getReplyComment($formKey) { $detail = DB::result("select reply_comment from workflow_subflow where form_key='" . $formKey . "'"); return $detail; } public static function getCounterSignComments($parentKey) { $sql = "select rownum seq ,seq CS_SEQ ,LEADER_NO ASSIGNER,reply_comment ASSIGN_OPINION ,change_date ASSIGN_DATE , LEAD_CODE, f_return_content('lead_code',LEAD_CODE) POSITION_NAME,case Reply_flag when 'Y' then 'F1' when 'N' then 'Y1' else 'A4' end ASSIGN_STATUS,'' FLOW_CODE from workflow_subflow a,employee b where parent_key='" . $parentKey . "' and a.leader_no=b.employee_no"; return DB::result($sql); } public static function updateChangeDate($formKey) { $sql = "update workflow_subflow set change_date=sysdate where form_key='" . $formKey . "'"; DB::query($sql); } }