/** * 通过条码获取产品信息 * * @param String $code */ public function getInfoByCode($code) { try { $action = new CodeInfo(); $result = $action->getInfoByCode($code); if (!$result) { return false; } return $result; } catch (Exception $e) { system_out("StocksManager.getInfoByCode Exception:" . $e); throw new Exception($e); } }
/** * 确认表所放的位置 * * @param $billno 单据号 * @param $data 数据 array("station"=>,"code"=>) * @return boolean */ public function confirmInstation($billdata, $data) { $sysno = $billdata['sysno']; $billdate = $billdata['billDate']; //明细表 $stocks = new StocksDao(); $stocks->startTrans(); //当前库存表 $current = new CurrentStocksDao(); $current->startTrans(); //未确认表位 $unconfirm = new UnconfirmstationDao(); $unconfirm->startTrans(); try { $newinsert = false; $station = $data["station"]; $code = $data["code"]; $result = $current->findAll("`code`='{$code}'")->toResultSet(); if (sizeof($result) == 0 && NOBILL_SCAN == false) { $stocks->rollback(); $current->rollback(); $unconfirm->rollback(); $this->setError("库存里找不到该条码[{$code}]对应的表计!"); return false; } else { if (sizeof($result) == 0) { $newinsert = true; $codeinfo = new CodeInfo(); $codedetail = $codeinfo->getInfoByCode($code); $vo = $stocks->createVo('add', '', 'id', 0, $codedetail); $vo->id = 0; $vo->inoutType = 'IN'; $vo->code = $code; $vo->sysno = $billdata['sysno']; $vo->placeno = $billdata['placeno']; $vo->place = $billdata['place']; $vo->billType = $billdata['billType']; $vo->billDate = $billdata['billDate']; $vo->billNo = $billdata['billNo']; $vo->sendMan = $billdata['sendMan']; $vo->saveMan = $billdata['saveMan']; $vo->orderNo = $billdata['orderNo']; $vo->client = $billdata['client']; $vo->inqty = 1; $vo->outqty = 0; $vo->station = $station; //inert new records $stocksmanageraction = new StocksManagerAction(); $savedata["modify"] = array($vo->toArray()); $result = $stocksmanageraction->save($savedata); if (!$result) { system_out("create new recod error:" . $stocksmanageraction->getError()); $this->setError($stocksmanageraction->getError()); return false; } } } $sql = "UPDATE " . (DB_PREFIX ? DB_PREFIX . "_" : "") . "currentstocks\n\t\t\t SET `station`='{$station}'\n\t\t\t\t\t WHERE `code` ='{$code}'"; system_out("update sql:" . $sql); $current->execute($sql); if (!$newinsert) { //返写stocks $result = StocksIndexAction::getTableNameByDate($billdate); if ($result == '') { $stocks->rollback(); $current->rollback(); $unconfirm->rollback(); system_out("get tablename error,billdate:" . $billdate); $this->setError("获取存储表出错!"); return false; } $tablename = $result; $sql = "UPDATE\t`{$tablename}`\n\t\t\t\t\t\t SET `station` = '{$station}'\n\t\t\t\t\t\t WHERE `code` = '{$code}' and\n\t\t\t\t\t\t \t\t`sysno` = '{$sysno}' "; $stocks->execute($sql); } //标记已经确认的开灯记录 $sql = "UPDATE " . (DB_PREFIX ? DB_PREFIX . "_" : "") . "unconfirmstation\n\t\t\t SET `confirm` = 1\n\t\t\t\t\t WHERE `station` = '{$station}' and `state`='U'"; $unconfirm->execute($sql); } catch (Exception $e) { $stocks->rollback(); $current->rollback(); $unconfirm->rollback(); system_out("UnconfirmstationAction.confirmInstation error:{$e},\n\t\t\t\t\t\tsysno:{$sysno},data:" . print_r($data, true)); throw new Exception($e); } //commit $stocks->commit(); $current->commit(); $unconfirm->commit(); return true; }