public function view_waveinit() { $waveId = WhWaveInfoModel::number_decode($_POST['waveId']); //判断每个区域是否已配货完结 $list = WhWaveReceiveRecordModel::select("waveId='{$waveId}'"); if (!$list) { $result = array('status' => 'A00', 'msg' => '配货单收货记录不存在'); echo json_encode($result); exit; } else { $areas = array(); foreach ($list as $val) { if ($val['scanStatus'] < 2) { $areas[] = $val['area']; } } if ($areas) { $result = array('status' => 'A00', 'msg' => '部分区域未完成收货,暂不能执行分拣<br/>' . implode(', ', $areas)); echo json_encode($result); exit; } } //分配筒号(亮灯) $orderlist = WhWaveShippingRelationModel::select("waveId='{$waveId}' AND is_delete=0 order by shipOrderId asc"); $light = 1; $shipOrderPickData = array(); foreach ($orderlist as $val) { $data = array('pickLight' => $light, 'pickTime' => time(), 'pickUserId' => $_SESSION['userId']); WhWaveShippingRelationModel::update($data, $val['id']); //生成发货单投放记录表 $shipOrderPickData[] = array('waveId' => $waveId, 'shipOrderId' => $val['shipOrderId'], 'pickStatus' => 0, 'pickTime' => 0, 'pickUserId' => 0, 'is_delete' => 0); $light++; } //查看是否有此波次的发货单投放记录 $shipOrderPick = WhWaveShippingPickRecordModel::find(' waveId=' . $waveId); if (!$shipOrderPick) { WhWaveShippingPickRecordModel::insert($shipOrderPickData, true); } //生成分拣记录表 $pick = WhWavePickRecordModel::find("waveId='{$waveId}'"); if (!$pick) { $list = WhShippingOrderdetailModel::getShippingOrderSkuList($waveId); foreach ($list as $val) { $data = array('waveId' => $val['waveId'], 'shipOrderId' => $val['shipOrderId'], 'sku' => $val['sku'], 'skuAmount' => $val['amount'], 'amount' => 0, 'pickStatus' => 0, 'pickUserId' => 0, 'pickTime' => 0, 'deleteUserId' => '0', 'deleteTime' => '0', 'is_delete' => '0'); $picklist[] = $data; } WhWavePickRecordModel::insert($picklist, true); } //扫描配货单的时候,查看配货单是否已经配货完成 $shipOrderPicks = WhWaveShippingPickRecordModel::select(' waveId=' . $waveId . ' AND pickStatus = 0', '*'); $hasShippingPick = false; $message = '配货单筒号分配正常,可以执行分拣(当前流程是SKU分拣)'; if (count($shipOrderPicks) > 0) { $hasShippingPick = true; $message = '配货单筒号分配正常,可以执行分拣(当前流程是发货单投放)'; } $result = array('status' => 'A99', 'hasShippingPick' => $hasShippingPick, 'msg' => $message); echo json_encode($result); }
/** * 发货单投放 * @author czq */ public function act_shipOrderpick() { $waveId = isset($_POST['waveId']) ? intval($_POST['waveId']) : ''; $shipOrderId = isset($_POST['shipOrderId']) ? intval(trim($_POST['shipOrderId'])) : ''; $waveId = WhWaveInfoModel::number_decode($waveId); if (!$waveId || !$shipOrderId) { $msg = array('status' => 'A00', 'waveStatus' => 'A00', 'msg' => '波次配货单不存在,参数错误'); echo json_encode($msg); exit; } $pickRecord = WhWaveShippingPickRecordModel::getRecordInfoByShipOrderId($shipOrderId); if (!$pickRecord) { $msg = array('status' => 'A00', 'waveStatus' => 'A00', 'msg' => '此波次的发货单' . $shipOrderId . '不存在'); echo json_encode($msg); exit; } else { if ($pickRecord[0]['pickStatus'] == 1) { $msg = array('status' => 'A00', 'waveStatus' => 'A00', 'msg' => '此发货单已投放过,桶号为:' . $pickRecord[0]['pickLight']); echo json_encode($msg); exit; } } //更新发货单投放记录表 $data = array('pickStatus' => 1, 'pickUserId' => $_SESSION['userId'], 'pickTime' => time()); WhWaveShippingPickRecordModel::update($data, ' shipOrderId=' . $shipOrderId); //检查当前发货单是否已完结分拣 $ShipOrderpickrecord = WhWaveShippingPickRecordModel::select("waveId='" . $waveId . "' AND pickStatus=0 AND is_delete=0"); if (!$ShipOrderpickrecord) { //最后一个投放 $msg = array('status' => 'A' . ($pickRecord[0]['pickLight'] >= 10 ? $pickRecord[0]['pickLight'] : '0' . $pickRecord[0]['pickLight']), 'pickLight' => $pickRecord[0]['pickLight'] . '号桶', 'shipOrderId' => $pickRecord[0]['shipOrderId'], 'waveStatus' => 'A99', 'msg' => '发货单已投放完毕,请投放料号!'); } else { $msg = array('status' => 'A' . ($pickRecord[0]['pickLight'] >= 10 ? $pickRecord[0]['pickLight'] : '0' . $pickRecord[0]['pickLight']), 'pickLight' => $pickRecord[0]['pickLight'] . '号桶', 'shipOrderId' => $pickRecord[0]['shipOrderId'], 'waveStatus' => 'A00', 'msg' => ''); } echo json_encode($msg); exit; }