コード例 #1
0
 /**
  * WhGoodsAssignAct::export_data()
  * 导出调拨数据 
  * @return void
  */
 public function export_data()
 {
     $ids = trim($_GET['ids']);
     if ($ids) {
         $assignList = WhGoodsAssignModel::getAssignList(" and a.id in ({$ids})", '', '', 'a.id');
         $assign_status = C('assign_status');
         //print_r($assign_status);exit;
         $name = 'assignList' . date('Y-m-d') . ".xls";
         //$name   =   iconv('UTF-8', 'gb2312//ignore', $name);
         $excel = new ExportDataExcel('browser', $name);
         $excel->initialize();
         $tharr = array("调拨单号", "SKU", "产品名称", "转出仓库", "转入仓库", "需求数量", "配货数量", '出库复核数量', '接收数量', '生成人员', '生成时间', '调拨单状态', '状态变更时间');
         $excel->addRow($tharr);
         if (!empty($assignList)) {
             foreach ($assignList as $assign) {
                 $outStore = WarehouseManagementModel::warehouseManagementModelList(" where id = {$assign['outStoreId']}");
                 $outStore = $outStore[0]['whName'];
                 $inStore = WarehouseManagementModel::warehouseManagementModelList(" where id = {$assign['inStoreId']}");
                 $inStore = $inStore[0]['whName'];
                 $maker = getUserNameById($assign['createUid']);
                 $make_date = date('Y-m-d H:i:s', $assign['createTime']);
                 $state_date = date('Y-m-d H:i:s', $assign['statusTime']);
                 $status = $assign_status[$assign['status']];
                 $details = WhGoodsAssignModel::getsAssignListDetail($assign['id']);
                 foreach ($details as $k => $val) {
                     $tdarr = array($k == 0 ? $assign['assignNumber'] : '', $val['sku'], $val['goodsName'], $outStore, $inStore, $val['num'], $val['assignNum'], $val['outCheckNum'], $val['inCheckNum'], $k == 0 ? $maker : '', $k == 0 ? $make_date : '', $k == 0 ? $status : '', $k == 0 ? $state_date : '');
                     //print_r($tdarr);exit;
                     $excel->addRow($tdarr);
                 }
             }
         }
         $excel->finalize();
         exit;
     }
 }
コード例 #2
0
ファイル: whGoodsAssign.view.php プロジェクト: ohjack/newErp
 /**
  * whGoodsAssignView::view_editAssignList()
  * 调拨单修改界面
  * @return void
  */
 public function view_editAssignList()
 {
     self::bulidNav('修改调拨单', '修改调拨单', 51);
     $id = intval(trim($_GET['id'])) ? intval(trim($_GET['id'])) : 0;
     if ($id) {
         $where = 'where status = 1';
         $storeLists = WarehouseManagementModel::warehouseManagementModelList($where);
         //获取可用仓库列表
         $data = WhGoodsAssignModel::getAssignList(" and a.id={$id}", '', '', 'a.id');
         if (!empty($data)) {
             $res = $data[0];
             $detail = WhGoodsAssignModel::getsAssignListDetail($id);
             //调拨单明细
             $this->smarty->assign('detail', $detail);
             $this->smarty->assign('res', $res);
             $createUser = getUserNameById($res['createUid']);
             $this->smarty->assign('createUser', $createUser);
             //$user           =   array('name'=>$userName, 'uid'=>$_SESSION['userId']);
             $this->smarty->assign('storeLists', $storeLists);
             $this->smarty->display('editAssignList.htm');
         }
         //$userName       =   getUserNameById($_SESSION['userId']); //获取用户名
     }
 }
コード例 #3
0
 public function act_whShelf()
 {
     //print_r($_POST);
     $log_file = 'whselfB_log/' . date('Ymd') . '.txt';
     //日志文件路径
     $date = date('Y-m-d H:i:s');
     $userCnName = $_SESSION['userCnName'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $nums = $_POST['nums'];
     $now_position_id = intval(trim($_POST['now_position_id']));
     //现在存放该料号的仓位id
     $goodsAssignId = intval(trim($_POST['now_group_id']));
     $positionId = intval(trim($_POST['position_id']));
     //分配的仓位id
     $assignList = WhGoodsAssignModel::getAssignList("and a.id = {$goodsAssignId}", '', '', '');
     if ($assignList[0]['status'] != 106) {
         self::$errCode = 400;
         self::$errMsg = "该调拨单不在等待上架状态!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($sku)) {
         self::$errCode = 401;
         self::$errMsg = "sku不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($now_position_id) && !$positionId) {
         self::$errCode = 401;
         self::$errMsg = "上架仓位不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if ($nums < 1) {
         self::$errCode = 403;
         self::$errMsg = "上架数量不能小于1";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     $sku_info = WhGoodsAssignModel::getDetail($goodsAssignId, " and a.sku='{$sku}' and a.inCheckNum != 0");
     if (empty($sku_info)) {
         self::$errCode = "404";
         self::$errMsg = "该调拨单无此料号!";
         return FALSE;
     }
     $whselfNums = $nums + $sku_info['whselfNum'];
     if ($whselfNums > $sku_info['assignNum']) {
         self::$errCode = "405";
         self::$errMsg = "总上架数不能大于配货数!";
         return FALSE;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 404;
         self::$errMsg = "无该料号信息";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     } else {
         $skuId = $skuinfo['id'];
         $purchaseId = $skuinfo['purchaseId'];
     }
     $ioTypeId = 35;
     //35 调拨入库上架 出入库类型表id
     $return_num = $nums;
     $in_positionId = 0;
     $userId = $_SESSION['userId'];
     //$where           =  "where pId ={$skuId} and positionId = {$now_position_id} and is_delete=0 and storeId = 2";
     TransactionBaseModel::begin();
     if ($now_position_id) {
         //存在料号仓位关系
         $positioninfo = whShelfModel::selectRelationShip('', '', 2, $now_position_id);
         //检测该料号是否有对应仓位关系
         /***无料号对应仓位的关系时更新关系表***/
         $relationId = $positioninfo[0]['id'];
         $positionId = $positioninfo[0]['positionId'];
         //仓位id
         $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$relationId}'");
         if (!$update_position) {
             self::$errCode = 410;
             self::$errMsg = "更新仓位库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $update_position, $num, $select_now_store);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新仓位库存成功!' . "{$sku}\r\n");
     } else {
         if ($positionId) {
             //没有料号仓位关系则插入一条数据
             $relationId = whShelfModel::insertRelation($skuinfo['id'], $positionId, $nums, 2);
             //插入关系表
             //$update_position = whShelfModel::updateProductPositionRelation($nums,"where id='$relationId'");
             if (!$relationId) {
                 self::$errCode = 410;
                 self::$errMsg = "插入仓位关系失败!";
                 $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $update_position, $num, $select_now_store);
                 write_log($log_file, $log_info);
                 TransactionBaseModel::rollback();
                 return false;
             }
             write_log($log_file, date('Y-m-d H:i:s') . '插入仓位关系成功!' . "{$sku}\r\n");
         }
     }
     /**** 更新总库存 *****/
     $actualStock = whShelfModel::selectSkuNums($sku, 2);
     if (!empty($actualStock)) {
         $where = "where sku='{$sku}' and storeId=2";
         $info = whShelfModel::updateStoreNum($nums, $where);
         if (!$info) {
             self::$errCode = 412;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $nums, $where);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     } else {
         $info = whShelfModel::insertStore($sku, $nums, 2);
         if (!$info) {
             self::$errCode = 413;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $sku, $nums);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     }
     /**** 插入出入库记录 *****/
     $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => $ioTypeId, 'userId' => $userId, 'reason' => '调拨入库上架');
     $record = CommonModel::addIoRecores($paraArr);
     //出库记录
     if (!$record) {
         self::$errCode = 414;
         self::$errMsg = "插入出入库记录失败!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s \r\n", $sku, $date, self::$errMsg, $record, json_encode($paraArr));
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     write_log($log_file, date('Y-m-d H:i:s') . '插入入库记录成功!' . "{$sku}\r\n");
     //更新调拨单料号上架数量
     $where = array('goodsassignId' => $goodsAssignId, 'sku' => $sku);
     $update = array('whselfNum' => $whselfNums);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if ($info === FALSE) {
         self::$errCode = 415;
         self::$errMsg = "更新上架数量失败";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s ,参数:s%\r\n", $sku, $date, self::$errMsg, $nums);
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     //更新料号调拨库存
     $where = array('sku' => $sku, 'storeId' => $assignList[0]['outStoreId']);
     $update = array('assignStock' => "assignStock - {$nums}");
     $info = WhGoodsAssignModel::updateSkuLocation($where, $update);
     if ($info == FALSE) {
         self::$errCode = 416;
         self::$errMsg = "更新调拨库存失败";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s ,参数:s%\r\n", $sku, $date, self::$errMsg, $nums);
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     /** 同步老ERP库存**/
     $pName = whShelfModel::selectPositionInfo('pName', array('id' => $positionId));
     //获取仓位名称
     $pName = $pName['pName'];
     $info = CommonModel::updateIoRecord($sku, $nums, 1, '仓库调拨入库上架', $_SESSION['userCnName'], $pName);
     //var_dump($info);exit;
     if ($info['errCode'] != 200) {
         TransactionBaseModel::rollback();
         self::$errCode = "004";
         self::$errMsg = "同步旧ERP库存失败!";
         $log_info = sprintf("料号:%s, 时间:%s,信息:%s ,参数:%s\r\n", $sku, $date, self::$errMsg, is_array($info) ? json_encode($info) : $info);
         write_log($log_file, $log_info);
         return false;
     }
     TransactionBaseModel::commit();
     self::$errMsg = "料号[{$sku}]上架成功!";
     return true;
 }