where('name', 'like', 'cur_batch_no')->find(); $package = db('runtime_info')->where('name', 'like', 'cur_package_no')->find(); dump($batch['value']); dump(intval($package['value'])); $fresh['value'] = intval($package['value']+1).""; $fresh['id'] = $package['id']; $package = db('runtime_info')->update($fresh); } public function test() { // 查找空巷道 $emptyChannels = db('storage_area')->alias('sa') ->leftJoin('storage_bin sp', 'sa.id=sp.area_id') ->whereNull('sp.id') // 找到没有关联的 storage_bin 的 storage_area ->select(); dump($emptyChannels); // if (!empty($emptyChannels)) { // dump('找到了空巷道'); // foreach ($emptyChannels as $emptyChannel) { // $name = $emptyChannel['name']; // db('runtime_info')->where('name', 'in_store_tunnel')->update(['value' => $name]); // break; // } // } else { // dump('没有找到空巷道'); // } } public function Move() { $this->BackStore(22940, 2); } public function CreateProduct() { $this->CreateProductInfo("1ewq23", "fsdf", 34682, 72544, 3); } public function CreateProductInfo($batch, $number, $x, $y, $layer) { $bin = db('storage_bin')->where('pos_x', $x)->where('pos_z', $y)->find(); if ($bin == null)return; $insert = []; $insert['batch'] = $batch; $insert['identifier'] = $number; $insert['channel'] = $bin['area_id']; $insert['bin'] = $bin['id']; $insert['layer'] = $layer; $insert['inTime'] = date('Y-m-d H:i:s', time()); db('storage_package')->insert($insert); } //移库 public function BeginMove($x, $y) { //查找出待出库的产品信息 $product_info = db('storage_package')->alias('p') ->join("storage_bin b",'p.bin=b.id') ->where('b.pos_x', $x)->where('b.pos_z', $y) ->where('p.inTime', '>', 0) //入库时间 ->where('p.channel', '>', 0) //入库巷道 ->where('p.outTime', NULL) //出库时间 ->field('p.id, p.outTime, p.batch, p.identifier, p.layer') ->select(); //更新出储位时间 $curtime = date('Y-m-d H:i:s', time()); for ($i=0; $isaveAll($product_info); $ids = []; //生成新的存储信息, 去掉入库出库时间,存储巷道和库位,等入储位时更新 for ($i=0; $iinsertGetId($product_info[$i]); $ids[] = $id; } return implode(',' , $ids); } public function EndMove($x, $y, $idArray) { $bin = db('storage_bin')->where('pos_x', $x)->where('pos_z', $y)->find(); if ($bin == NULL)return; $idarr = explode(',',$idArray); $curtime = date('Y-m-d H:i:s', time()); $update['inTime'] = $curtime; $update['channel'] = $bin['area_id']; $update['bin'] = $bin['id']; dump($update); for ($i=0; $iupdate($update); } } //移库 public function BackStore($binno, $count) { //设置库位剩余个数 $update['state'] = $count; $update['id'] = $binno; db('storage_bin')->update($update); //更新产品出库信息 $product_info = db('storage_package') ->where('bin', $binno) ->where('inTime', '>', 0) //入库时间 ->where('channel', '>', 0) //入库巷道 ->where('outTime', NULL) //出库时间 ->field('id, outTime, batch, identifier, layer') ->select(); for ($i=0; $i($count-1)) { $product_info[$i]['outTime'] = date('Y-m-d H:i:s', time()); db('storage_package')->where('id', $product_info[$i]['id'])->update($product_info[$i]); } } return ; } public function getOutStoreTaskInfoTest() { $postData = request()->post(); $batch = $postData['batch']; $package_count = 6; // 3.1 获取巷道号 $channel_arr = db('storage_package') //->field('channel') ->where('batch',$batch) ->where('outTime',null) ->group('channel') ->column('channel'); // 3.2 获取巷道号内的所有拖 $bin_arr = db('storage_package')->alias('sp') ->field('ANY_VALUE(sp.batch) AS batch,sp.bin,count(sp.id) AS count,sb.area_id,sb.area_idx,sb.state') ->join("sh_storage_bin sb", 'sp.bin = sb.id','LEFT') ->where('sp.channel','IN',$channel_arr) ->where('outTime',null) ->group('sp.bin') ->order('sb.area_id,sb.area_idx') ->select(); // halt($package_arr); // 5. 批量生成任务 $batchtaskModel = new BatchtaskModel(); $sale_no = "12345"; $total_count = 0; $tmp_data = []; $tmp_cnt = 0; foreach ($bin_arr as $key=>$vo){ echo "
===$key===
"; if(0 == $key)$tmp_data = $vo; // 遇到下一个巷道、者批次号不同或者最后一条数据时,写入批次任务 if($tmp_data['area_id'] != $vo['area_id'] || $tmp_data['batch'] != $vo['batch']){ echo "
***$key***
"; if($batch == $tmp_data['batch'])$task_type = 'OUT_STORE'; else $task_type = 'CHANGE_STORE'; $batchtaskModel->CreateBatchTaskRecord($task_type, $sale_no, $tmp_data['area_id'], '', $tmp_cnt); $tmp_cnt = 0; } $tmp_data = $vo; $tmp_cnt ++; if($total_count >= $package_count)break; if($batch == $vo['batch']) { //非出库批次需要倒库,创建倒库任务 $total_count += $vo['count']; } } return $this->sendSuccess(); } public function batchTaskTest() { $sale_no = db('runtime_info')->where('name', 'cur_idlsid')->find(); $batch_task = db('forklift_task') ->where('sale_no', $sale_no['value']) ->order('id DESC')->limit(1)->find(); // halt($batch_task); if(!$batch_task || ($batch_task && 'FORKLIFT_LEAVE' == $batch_task['taskState'])){ $batchtaskModel = new BatchtaskModel(); $state = "12002000000"; $batchtaskModel->CheckBatchTask($state); } return $this->sendSuccess(); } public function test1() { // $batchtaskModel = new BatchtaskModel(); // $endPos = $batchtaskModel->get_in_channel_no(5); // halt($endPos); $packageInfoModel = new PackageInfo(); $packageInfoModel->updateBinLockStatus(31, "070146AA058753", 1); // $ret = $packageInfoModel->getBinLockStatus("071701AA055827"); // halt($ret); return $this->sendSuccess(); } }