Commit 03641e6b by 叶明星

合并分支

parents 70d355c1 5d23d9d3
......@@ -12,6 +12,7 @@ use App\Http\Model\Logic\PackCheckLogic;
use App\Http\Model\Logic\PalletLogic;
use App\Http\Model\Logic\PickTaskLogic;
use App\Http\Model\OutStoreDetailModel;
use App\Http\Model\PickTaskDetailModel;
use Illuminate\Http\Request;
class AdminOutstoreController extends Controller
......@@ -44,11 +45,12 @@ class AdminOutstoreController extends Controller
$data = $request->all();
try{
//获取需要修改的货品
if ($data['out_store_detail_id'] == 'all'){
$data['out_store_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('out_store_detail_id');
if ($data['pick_task_detail_id'] == 'all'){
$data['pick_task_detail_id_arr'] = PickTaskDetailModel::where('out_store_id',$data['out_store_id'])->whereIn('pick_status',[1,4])->pluck('pick_task_detail_id');
}else{
$data['out_store_detail_id_arr'] = [$data['out_store_detail_id']];
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
}
$returnData = (new PickTaskLogic())->confirmPick($data);
}catch (\Exception $exception){
......@@ -64,10 +66,10 @@ class AdminOutstoreController extends Controller
$data = $request->all();
try{
//获取需要修改的货品
if ($data['out_store_detail_id'] == 'all'){
$data['out_store_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('out_store_detail_id');
if ($data['pick_task_detail_id'] == 'all'){
$data['pick_task_detail_id_arr'] = PickTaskDetailModel::where('out_store_id',$data['out_store_id'])->where('pick_status',3)->pluck('pick_task_detail_id')->toArray();
}else{
$data['out_store_detail_id_arr'] = [$data['out_store_detail_id']];
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
}
$returnData = (new PickTaskLogic())->cancelPick($data);
}catch (\Exception $exception){
......@@ -82,10 +84,10 @@ class AdminOutstoreController extends Controller
$data = $request->all();
try{
//获取需要修改的货品
if ($data['out_store_detail_id'] == 'all'){
$data['out_store_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('out_store_detail_id');
if ($data['pick_task_detail_id'] == 'all'){
$data['pick_task_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('pick_task_detail_id')->toArray();
}else{
$data['out_store_detail_id_arr'] = [$data['out_store_detail_id']];
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
}
$returnData = (new PalletLogic())->confirmOutStore($data);
......@@ -102,10 +104,10 @@ class AdminOutstoreController extends Controller
$data = $request->all();
try{
//获取需要修改的货品
if ($data['out_store_detail_id'] == 'all'){
$data['out_store_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('out_store_detail_id');
if ($data['pick_task_detail_id'] == 'all'){
$data['pick_task_detail_id_arr'] = OutStoreDetailModel::where('out_store_id',$data['out_store_id'])->pluck('pick_task_detail_id')->toArray();
}else{
$data['out_store_detail_id_arr'] = [$data['out_store_detail_id']];
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
}
$returnData = (new PalletLogic())->cancelOutStore($data);
......@@ -141,7 +143,7 @@ class AdminOutstoreController extends Controller
return $this->apiReturn($returnData);
}
//装箱
//复核
public function right_pack_check($request)
{
$data = $request->all();
......@@ -153,6 +155,19 @@ class AdminOutstoreController extends Controller
return $this->apiReturn($returnData);
}
//取消复核
public function left_pack_check($request)
{
$data = $request->all();
try{
$returnData = (new PackCheckLogic())->left_pack_check($data);
}catch (\Exception $exception){
return $this->apiReturn($exception->getMessage().'|jsondata='.json_encode($data));
}
return $this->apiReturn($returnData);
}
//装卡板
public function palletActive($request)
{
......@@ -162,6 +177,7 @@ class AdminOutstoreController extends Controller
}catch (\Exception $exception){
return $this->apiReturn($exception->getMessage().'|jsondata='.json_encode($data));
}
return $this->apiReturn($returnData);
}
......@@ -192,6 +208,47 @@ class AdminOutstoreController extends Controller
return $this->apiReturn($returnData);
}
//获取卡板标签打印信息
public function print_pallet_label($request)
{
$data = $request->all();
try{
$returnData = (new PalletLogic())->print_pallet_label($data);
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
}
//获取卡板标签打印信息
public function print_box_label($request)
{
$data = $request->all();
try{
$returnData = (new PalletLogic())->print_box_label($data);
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
}
//获取卡板标签打印信息
public function print_pick_task_label($request)
{
$data = $request->all();
try{
$returnData = (new PalletLogic())->print_pick_task_label($data);
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
}
//获取拣货任务打印信息
public function print_pick_task_info($request)
{
......
......@@ -13,7 +13,6 @@ use App\Http\Model\Logic\PickTaskLogic;
use App\Http\Model\PickTaskDetailModel;
use Illuminate\Http\Request;
use App\Http\Model\Logic\OutStoreLogic;
class OutstoreController extends Controller
{
public function Entrance(Request $request, $id)
......@@ -27,11 +26,11 @@ class OutstoreController extends Controller
public function createOutStore($request)
{
$data = $request->all();
try {
try{
$inserData = OutStoreLogic::handleInsertData($data);
$returnData = OutStoreLogic::insertData($inserData);
} catch (\Exception $exception) {
return $this->apiReturn($exception->getMessage() . '|jsondata=' . json_encode($data));
}catch (\Exception $exception){
return $this->apiReturn($exception->getMessage().'|jsondata='.json_encode($data));
}
return $this->apiReturn($returnData);
}
......@@ -40,24 +39,26 @@ class OutstoreController extends Controller
public function palletBoxList($request)
{
$data = $request->all();
try {
try{
$returnData = (new PalletLogic())->palletBoxList($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
}
//扫描出库列表
public function scan_out_store_list($request)
{
$data = $request->all();
try {
try{
$returnData = (new PickTaskLogic())->getPickTaskDetailList($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -68,12 +69,11 @@ class OutstoreController extends Controller
public function confirm_out_store($request)
{
$data = $request->all();
try {
$outStoreDetailIdArr = PickTaskDetailModel::where('pick_task_detail_id', $data['pick_task_detail_id'])->pluck('out_store_detail_id');
$data['out_store_detail_id_arr'] = $outStoreDetailIdArr;
try{
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
$returnData = (new PalletLogic())->confirmOutStore($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -83,13 +83,12 @@ class OutstoreController extends Controller
public function cancel_out_store($request)
{
$data = $request->all();
try {
try{
//获取所有的out_store_detail_id
$outStoreDetailIdArr = PickTaskDetailModel::where('pick_task_detail_id', $data['pick_task_detail_id'])->pluck('out_store_detail_id');
$data['out_store_detail_id_arr'] = $outStoreDetailIdArr;
$data['pick_task_detail_id_arr'] = [$data['pick_task_detail_id']];
$returnData = (new PalletLogic())->cancelOutStore($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -99,11 +98,12 @@ class OutstoreController extends Controller
public function deliver_goods($request)
{
$data = $request->all();
try {
$data['pick_task_detail_id_str'] = implode(',', $data['pick_task_detail_id']);
try{
$data['pick_task_detail_id_str'] = implode(',',$data['pick_task_detail_id']);
$data['is_apply_customs_app'] = '1';
$returnData = (new PalletLogic())->deliverGoods($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -113,10 +113,14 @@ class OutstoreController extends Controller
public function palletActive($request)
{
$data = $request->all();
try {
try{
if (empty($data['box_id_arr'])){
throw new \Exception('装卡板箱子不能为空');
}
$data['box_sn_str'] = implode(',',$data['box_id_arr']);
$returnData = (new PalletLogic())->palletActive($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -126,10 +130,10 @@ class OutstoreController extends Controller
public function get_box_info($request)
{
$data = $request->all();
try {
try{
$returnData = (new PalletLogic())->getBoxInfo($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......@@ -139,10 +143,10 @@ class OutstoreController extends Controller
public function get_pallet_info($request)
{
$data = $request->all();
try {
try{
$returnData = (new PalletLogic())->getPalletInfo($data);
} catch (\Exception $exception) {
if (empty(self::$errCode)) self::$errCode = 101;
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
}
return $this->apiReturn($returnData);
......
......@@ -84,8 +84,8 @@ class PicktaskController extends Controller
if (empty($outStoreDetailIdArr)){
throw new \Exception('该任务下没有这个型号');
}
$data['out_store_detail_id_arr'] = $outStoreDetailIdArr;
$returnData = (new PickTaskLogic())->confirmPick($data);
$pickTaskDetailArr = PickTaskDetailModel::getWhereObj([])->whereIn('out_store_detail_id',$outStoreDetailIdArr)->whereIn('pick_status',[1,4])->pluck('pick_task_detail_id')->toArray();
$returnData = (new PickTaskLogic())->confirmPick(['pick_task_detail_id_arr'=>$pickTaskDetailArr]);
}catch (\Exception $exception){
if (empty(self::$errCode))self::$errCode=101;
return $this->apiReturn($exception->getMessage());
......@@ -101,12 +101,14 @@ class PicktaskController extends Controller
try{
//获取所有的out_store_detail_id
$outStoreDetailIdArr = PickTaskDetailModel::where('pick_task_detail_id',$data['pick_task_detail_id'])->pluck('out_store_detail_id');
$pickTaskDetailIdArr = PickTaskDetailModel::where('pick_task_detail_id',$data['pick_task_detail_id'])->where('pick_status',3)->pluck('pick_task_detail_id');
if (empty($outStoreDetailIdArr)){
throw new \Exception('该任务下没有这个型号');
if (empty($pickTaskDetailIdArr)){
throw new \Exception('该任务下不是已拣货状态');
}
$data['out_store_detail_id_arr'] = $outStoreDetailIdArr;
$pickTaskDetailIdArr = $pickTaskDetailIdArr->toArray();
$data['pick_task_detail_id_arr'] = $pickTaskDetailIdArr;
$returnData = (new PickTaskLogic())->cancelPick($data);
}catch (\Exception $exception){
......
......@@ -21,4 +21,6 @@ class BoxModel extends Model
{
return $obj = self::where('store_id','=',app('request')->store_id);
}
}
\ No newline at end of file
......@@ -59,7 +59,6 @@ class CommonLogic
case 'delivery_id'://发货人员
case 'admin_id'://根据id获取人员姓名
case 'pick_user_id'://拣货人
case 'confirm_user_id'://确认人
$value = '暂未录入';break;
case 'store_id'://根据仓库IDid获取名称
$value = StoreModel::where('store_id',$value)->value("store_name");break;
......@@ -113,9 +112,9 @@ class CommonLogic
{
$outStoreArr = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->pluck('out_store_id')->toArray();
foreach (array_filter($outStoreArr) as $key=>$value){
foreach (array_unique(array_filter($outStoreArr)) as $key=>$value){
$outStoreInfo = OutStoreModel::getWhereObj([])->where('out_store_id',$value)->first()->toArray();
$outStoreInfo = OutStoreModel::getWhereObj([])->where('out_store_id',$value)->first();
$outStoreDetailData = OutStoreDetailModel::getWhereObj([])
->where('out_store_id',$value)
......@@ -126,14 +125,14 @@ class CommonLogic
$json = [
'SyncName'=>'out_store',
'Data'=>[
'erp_store_id'=>$outStoreInfo['erp_out_store_id'],
'box_number'=>count(array_filter(array_column($outStoreDetailData,'box_id'))),
'pallet_number'=>count(array_filter(array_column($outStoreDetailData,'pallet_id'))),
'erp_store_id'=>$outStoreInfo->erp_out_store_id,
'box_number'=>count(array_unique(array_filter(array_column($outStoreDetailData,'box_id')))),
'pallet_number'=>count(array_unique(array_filter(array_column($outStoreDetailData,'pallet_id')))),
'detail'=>$outStoreDetailData,
]
];
return Amqp::publish('store_audit_status', json_encode($json),[ 'queue' => 'store_audit_status', 'exchange' => 'store', 'exchange_type' => 'direct']);
return Amqp::publish('scm_store_audit_status', json_encode($json),[ 'queue' => 'scm_store_audit_status', 'exchange' => 'scm_store', 'exchange_type' => 'direct']);
}
......
......@@ -55,7 +55,7 @@ class OutStoreLogic
//判断该入库单号是否拥有
if (!empty(OutStoreModel::where('warehousing_sn',$data['warehousing_sn'])->value('out_store_id'))){
Controller::$level = 5;Controller::$errCode = 2;
throw new \Exception('该入单号已经存在'.$data['warehousing_sn']);
throw new \Exception('该入单号已经存在'.$data['warehousing_sn']);
}
//判断入库详情是否为空
......@@ -174,13 +174,19 @@ class OutStoreLogic
OutStoreModel::where('out_store_id',$outStoreId)->update(['is_insp'=>1]);
}
$outStoreDetailId = OutStoreDetailModel::insertGetId(array_merge(self::handleOutStoreDetailInsertData($value,$insertData),['pick_task_id'=>$pickTaskId]));
$value = array_merge(self::handleOutStoreDetailInsertData($value,$insertData),['pick_task_id'=>$pickTaskId]);
$outStoreDetailId = OutStoreDetailModel::insertGetId($value);
//is_apply_customs报关任务默认隐藏
PickTaskDetailModel::insertGetId(PickTaskLogic::handleInsertData([
$pickTaskData = PickTaskLogic::handleInsertData([
'out_store_id'=>$outStoreId,'out_store_detail_id'=>$outStoreDetailId,'store_id'=>$insertData['store_id'],
'pick_task_id'=>$pickTaskId,'is_show'=>empty($insertData['is_apply_customs'])?1:0
]));
],$value);
foreach ($pickTaskData as $v){
PickTaskDetailModel::insertGetId($v);
}
}
DB::commit();
......
......@@ -65,9 +65,12 @@ class PackCheckLogic
$outStoreDetailIdArr = BoxModel::where('box_sn',$data['goods_name_box_id'])->value('box_id');
$outStoreDetailIdArr = OutStoreDetailModel::where('pick_task_id',$pickTaskId)->where('box_id',$outStoreDetailIdArr)->pluck('out_store_detail_id');
break;
case 'FH':
$fh = substr($data['goods_name_box_id'],2);
$outStoreDetailIdArr = [$fh];
break;
default:
$outStoreDetailIdArr = GoodsModel::where('goods_name',$data['goods_name_box_id'])->value('goods_id');
$outStoreDetailIdArr = OutStoreDetailModel::where('pick_task_id',$pickTaskId)->where('goods_id',$outStoreDetailIdArr)->pluck('out_store_detail_id');
$outStoreDetailIdArr = OutStoreDetailModel::where('goods_name',$data['goods_name_box_id'])->pluck('out_store_detail_id');
break;
}
......@@ -83,4 +86,41 @@ class PackCheckLogic
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['pack_status'=>2]);
return [];
}
public function left_pack_check($data)
{
//获取所有的out_store_detail_id
$goodsType = substr($data['goods_name_box_id'],0,2);
$pickTaskId = PickTaskModel::where('pick_task_sn',$data['pick_task_sn'])->value('pick_task_id');
switch ($goodsType){
case 'KB':
$outStoreDetailIdArr = PalletModel::getWhereObj([])->where('pallet_sn',$data['goods_name_box_id'])->value('pallet_id');
$outStoreDetailIdArr = OutStoreDetailModel::where('pick_task_id',$pickTaskId)->where('pallet_id',$outStoreDetailIdArr)->pluck('out_store_detail_id');
break;
case 'XB':
$outStoreDetailIdArr = BoxModel::where('box_sn',$data['goods_name_box_id'])->value('box_id');
$outStoreDetailIdArr = OutStoreDetailModel::where('pick_task_id',$pickTaskId)->where('box_id',$outStoreDetailIdArr)->pluck('out_store_detail_id');
break;
case 'FH':
$fh = substr($data['goods_name_box_id'],2);
$outStoreDetailIdArr = [$fh];
break;
default:
$outStoreDetailIdArr = OutStoreDetailModel::where('goods_name',$data['goods_name_box_id'])->pluck('out_store_detail_id');
break;
}
if (empty($outStoreDetailIdArr)){
throw new \Exception('该拣货任务下没找到该型号');
}
//判断是否是未复核状态
$packStatus = PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->value('pack_status');
if ($packStatus !== 2 ){
throw new \Exception('该型号没有在复核状态中');
}
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['pack_status'=>1]);
return [];
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace App\Http\Model\Logic;
use App\Http\Model\BoxModel;
use App\Http\Model\GoodsModel;
use App\Http\Model\OutStoreDetailModel;
use App\Http\Model\OutStoreModel;
use App\Http\Model\PalletModel;
......@@ -44,16 +45,30 @@ class PalletLogic
public function palletActive($data)
{
if (empty($boxSnArr = explode(',',$data['box_sn_str']))){
throw new \Exception('箱子不能为空');
if (empty($boxSnArr = array_filter(explode(',',$data['box_sn_str'])))){
throw new \Exception('装卡板箱子不能为空');
}
$boxSnArr = array_filter($boxSnArr);
$boxSnArr = array_unique($boxSnArr);
if (BoxModel::whereIn('box_sn',$boxSnArr)->where('status',2)->value('box_id')){
//获取所有的箱子ID
$boxIdArr = BoxModel::whereIn('box_sn',$boxSnArr)->pluck('box_id');
if (empty($boxIdArr)){
throw new \Exception('获取不到箱子信息');
}
$boxIdArr = json_decode(json_encode($boxIdArr));
if (in_array(2,$boxIdArr)){
throw new \Exception('有箱子在上架状态请确认');
}
if (DB::table('pallet')->where('pallet_sn',$data['pallet_sn'])->value('status') == 2){
throw new \Exception('卡板为上架状态,不可装卡板');
}
//获取卡板ID
$palletId = DB::table('pallet')->where('pallet_sn',$data['pallet_sn'])->value('pallet_id');
......@@ -62,15 +77,30 @@ class PalletLogic
throw new \Exception('这些箱子不在同一个卡板');
}
DB::table('box')->whereIn('box_sn',$boxSnArr)->where('pallet_id',0)->update(['pallet_id'=>$palletId]);
DB::beginTransaction();
try{
DB::table('box')->whereIn('box_sn',$boxSnArr)->where('pallet_id',0)->update(['pallet_id'=>$palletId]);
OutStoreDetailModel::whereIn('box_id',$boxIdArr)->update(['pallet_id'=>$palletId]);
DB::commit();
}catch (\Exception $exception){
DB::rollBack();
throw new \Exception('装卡板事物异常错误为: '.$exception->getMessage());
}
return [];
}
//确认出库
public function confirmOutStore($data)
{
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>4,'is_confirm'=>1]);
$outStoreDetailIdArr = $data['pick_task_detail_id_arr'];
$adminInfo = CommonLogic::getAdminInfo();
PickTaskDetailModel::whereIn('pick_task_detail_id',$outStoreDetailIdArr)->update([
'is_confirm'=>1,'confirm_time'=>time(),
'confirm_user_name'=>$adminInfo['admin_name'],
'confirm_user_id'=>$adminInfo['admin_id'],
]);
return [];
}
......@@ -78,16 +108,16 @@ class PalletLogic
public function cancelOutStore($data)
{
//获取需要修改的货品
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
$outStoreDetailIdArr = $data['pick_task_detail_id_arr'];
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>4,'is_confirm'=>0]);
PickTaskDetailModel::whereIn('pick_task_detail_id',$outStoreDetailIdArr)->update(['is_confirm'=>0]);
return [];
}
//发货
public function deliverGoods($data)
{
if (empty($pickTaskDetailIdArr = explode(',',$data['pick_task_detail_id_str']))){
if (empty($pickTaskDetailIdArr = array_filter(explode(',',$data['pick_task_detail_id_str'])))){
throw new \Exception('参数不完整');
}
......@@ -97,23 +127,41 @@ class PalletLogic
throw new \Exception('查找不到拣货详情');
}
//查找出所有的卡板和箱子
$palletIdArr = OutStoreDetailModel::getWhereObj([])->whereIn('out_store_detail_id',$outStoreDetailIdArr)->pluck('pallet_id');
$boxIdArr = OutStoreDetailModel::getWhereObj([])->whereIn('out_store_detail_id',$outStoreDetailIdArr)->pluck('box_id');
//是否需要报关
if (OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->value('is_apply_customs') && (empty($data['weigh_val']))){
throw new \Exception('报关单据不可在此发货');
//判断箱子卡板是否可以发货
if (!empty($palletIdArr)){
$palletIdArr = $palletIdArr->toArray();
$palletIdArr = array_unique(array_filter($palletIdArr));
if (count($palletIdArr)>1){
throw new \Exception('发货任务卡板大于两个');
}
if (PalletModel::getWhereObj([])->whereIn('pallet_id',$palletIdArr)->where('status',2)->value('pallet_id')){
throw new \Exception('卡板在上架状态,不能发货');
}
}
if (!empty($boxIdArr)){
$boxIdArr = $boxIdArr->toArray();
if (BoxModel::getWhereObj([])->whereIn('box_id',$boxIdArr)->where('status',2)->value('box_id')){
throw new \Exception('有箱子在上架状态,不能发货');
}
}
//查询状态
$packStatus = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->pluck('pack_status')->toArray();
$packStatus = array_filter($packStatus);
if (count($packStatus) > 1){
throw new \Exception('单据存在未确认的数据,不可重复操作');
if (!isset($data['is_apply_customs_app'])){
//是否需要报关
if (OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->value('is_apply_customs') && (empty($data['weigh_val']))){
throw new \Exception('报关单据不可在此发货');
}
}
$packStatus = array_pop($packStatus);
if($packStatus == 4){
throw new \Exception('单据存已发货,不可重复操作');
if(PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->whereNotIn('pack_status',[2,3])->value('pick_task_detail_id')){
throw new \Exception('单据存在未复核或者已出库数据,不可重复操作');
}
......@@ -121,22 +169,30 @@ class PalletLogic
try{
//查找库存
foreach ($pickTaskDetailIdArr as $value){
$stockFrozen = StockFrozenModel::getWhereObj([])->where('pick_task_detail_id',$value)->get()->toArray();
$stockFrozen = StockFrozenModel::where('pick_task_detail_id',$value)->get()->toArray();
if (!empty($stockFrozen)){
foreach ($stockFrozen as $v){
$stock = StockModel::getWhereObj([])->where('stock_id',$v['stock_id'])->value('stock');
$stock = StockModel::where('stock_id',$v['stock_id'])->value('stock');
if ($stock < $v['number']){
throw new \Exception($v['goods_id'].'可扣减库存不足');
throw new \Exception(json_encode($v).json_encode($stock).'可扣减库存不足');
}
StockModel::getWhereObj([])->where('stock_id',$v['stock_id'])->update(bcsub($stock,$v['number']));
StockModel::where('stock_id',$v['stock_id'])->update(['stock'=>bcsub($stock,$v['number'])]);
//扣减实际库存
StockFrozenModel::getWhereObj([])->where('pick_task_detail_id',$value)->where('stock_id',$v['stock_id'])->update(['number'=>0,'status'=>3]);
StockFrozenModel::where('pick_task_detail_id',$value)->where('stock_id',$v['stock_id'])->update(['number'=>0,'status'=>3]);
}
}else{
throw new \Exception('出库库存为0');
}
}
PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->update(['pack_status'=>4]);
//修改发货状态
$outStoreIdArr = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->pluck('out_store_id')->toArray();
foreach ($outStoreIdArr as $value){
OutStoreModel::where('out_store_id',$value)->update(['out_store_status'=>self::getOutStoreStatusForId($value)]);
}
//有快递公司才记录
if (isset($data['express_company'])){
OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update([
......@@ -160,7 +216,7 @@ class PalletLogic
//装箱
public function packCheck($data)
{
if (empty($pickTaskDetailIdArr = explode(',',$data['pick_task_detail_id_str']))){
if (empty($pickTaskDetailIdArr = array_filter(explode(',',$data['pick_task_detail_id_str'])))){
throw new \Exception('装箱型号不能为空');
}
......@@ -189,7 +245,7 @@ class PalletLogic
$outStoreIdArr = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->pluck('out_store_id');
if (count(array_filter(OutStoreModel::whereIn('out_store_id',array_filter($outStoreIdArr))->pluck('customer_id'))) > 1){
if (count(array_unique(array_filter(OutStoreModel::whereIn('out_store_id',array_unique($outStoreIdArr))->pluck('customer_id')))) > 1){
throw new \Exception('不同委托方不可一起装箱');
}
......@@ -250,16 +306,28 @@ class PalletLogic
//获取后端的卡板打印信息
public function print_pallet_info($data)
{
if ($palletId = PalletModel::getWhereObj([])->where('pallet_sn',$data['pallet_sn']->value('pallet_id'))){
if (empty($palletId = PalletModel::getWhereObj([])->where('pallet_sn',$data['pallet_sn'])->value('pallet_id'))){
throw new \Exception('当前卡板不存在');
}
$boxData = BoxModel::where('pallet_id',$palletId)->get()->toArray();
//获取拣货任务中已经有的箱子信息
$boxIdArr = OutStoreDetailModel::getWhereObj([])->where('pallet_id',$palletId)->pluck('box_id');
if (empty($boxIdArr)){
throw new \Exception('当前卡板并没有箱子');
}
$boxIdArr = $boxIdArr->toArray();
$boxData = BoxModel::whereIn('box_id',$boxIdArr)->get()->toArray();
if (empty($boxData)){
throw new \Exception('当前卡板不存在箱子');
}
foreach ($boxData as $key=>$val){
$boxData[$key]['warehousing_sn'] = OutStoreDetailModel::getWhereObj([])->where('box_id',$val['box_id'])->value('warehousing_sn');
}
return [
'pallet_sn'=>$data['pallet_sn'],
'pallet_box_num'=>count($boxData),
......@@ -284,7 +352,114 @@ class PalletLogic
throw new \Exception('该拣货任务不存在');
}
foreach ($outStoreDetailData as $key=>$value){
$value = array_merge(PickTaskDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray(),$value);
$outStoreDetailData[$key] = CommonLogic::getHaveKeyCn($value);
}
return $outStoreDetailData;
}
//获取打印的拣货任务信息
public function print_pick_task_label($data)
{
//查询当前卡板
if (empty($palletId = PalletModel::where('pallet_sn',$data['pallet_sn'])->value('pallet_id'))){
throw new \Exception('当前卡板不存在');
}
//获取拣货任务中已经有的箱子信息
$boxIdArr = PickTaskDetailModel::where('pallet_id',$palletId)->pluck('box_id');
if (empty($boxIdArr)){
throw new \Exception('当前卡板并没有箱子');
}
$boxIdArr = $boxIdArr->toArray();
$boxData = BoxModel::whereIn('box_id',$boxIdArr)->get()->toArray();
if (empty($boxData)){
throw new \Exception('当前卡板不存在箱子');
}
$data = [
'WEIGHT'=>array_sum(array_column($boxData,'weight')),
'NO'=>$data['pallet_sn'],
'QTY'=>count(array_unique(array_filter($boxIdArr))),
'ID'=>$palletId,
];
return $data;
}
//获取打印的箱子标签信息
public function print_box_label($data)
{
$box = PickTaskDetailModel::getWhereObj([])->where('box_id',$data['box_id'])->get()->toArray();
if (empty($box)){
throw new \Exception('该箱子暂无需要打印的数据');
}
$returnbox = [];
$returnbox['box_sn'] = $data['box_sn'];
foreach ($box as $key=>$val){
$outStoreDetailInfo = OutStoreDetailModel::where('out_store_detail_id',$val['out_store_detail_id'])->first();
$returnbox['box_list'][$key]['goods_name'] = $outStoreDetailInfo->goods_name;
$returnbox['box_list'][$key]['number'] = $val['number'];
}
$returnbox['weight'] = array_sum(BoxModel::whereIn('box_id',array_filter(array_column($box,'box_id')))->pluck('weight')->toArray());
return $returnbox;
}
//获取打印的拣货任务信息
public function print_pallet_label($data)
{
//查找拣货任务ID
$pickTask = PickTaskModel::where('pick_task_sn',$data['pick_task_sn'])->value('pick_task_id');
if (empty($pickTask)){
throw new \Exception('该拣货任务不存在');
}
$outStoreDetailData = OutStoreDetailModel::where('pick_task_id',$pickTask)->get()->toArray();
if (empty($outStoreDetailData)){
throw new \Exception('该拣货任务不存在');
}
return $outStoreDetailData;
}
//根据出库id获取出库状态
static public function getOutStoreStatusForId($outStoreId)
{
$returnOutStoreStatus = 1;
$outStoreStatus = PickTaskDetailModel::getWhereObj([])->where('out_store_id',$outStoreId)->pluck('pack_status');
if (!empty($outStoreStatus)) {
$outStoreStatus = $outStoreStatus->toArray();
$outStoreStatus = array_unique(array_filter($outStoreStatus));
//判断有几种状态
if (count($outStoreStatus) > 1) {
if (in_array(4, $outStoreStatus)) {
$returnOutStoreStatus = 2;
}
} else {
$outStoreStatus = array_pop($outStoreStatus);
if ($outStoreStatus == 4) {
$returnOutStoreStatus = 3;
}
}
}
return $returnOutStoreStatus;
}
}
\ No newline at end of file
......@@ -41,15 +41,71 @@ class PickTaskLogic
}
//拣货任务逻辑层
static public function handleInsertData($data)
//拣货任务生成逻辑层
static public function handleInsertData($data,$outStoreDetail)
{
//判断该拣货任务是否存在
if (!empty(PickTaskDetailModel::where('out_store_detail_id',$data['out_store_detail_id'])->value('pick_task_detail_id'))){
throw new \Exception('该出库商品拣货任务已经存在');
}
$data['add_time'] = time();
return $data;
$pickData = [];
//查询当前商品所绑定的库存
$stockInfo = StockModel::where('goods_id',$outStoreDetail['goods_id'])->where('warehousing_sn',$outStoreDetail['warehousing_sn'])->orderBy('stock','asc')->get()->toArray();
if (empty($stockInfo)){
throw new \Exception('当前入库单的商品库存不存在');
}
//根据货位,卡板
foreach ($stockInfo as $stockValue){
$locationkey = $stockValue['location_id'].'_'.$stockValue['pallet_id'].'_'.$stockValue['box_id'];
if (isset($pickData[$locationkey])){
$pickData[$locationkey] = bcadd($stockValue['stock'],$pickData[$locationkey]);
}else{
$pickData[$locationkey] = $stockValue['stock'];
}
}
//判断是否没有卡板箱子数据
$isAllGoods = 0;
//生成拣货记录
foreach ($pickData as $key=>$value){
$locatiion = explode('_',$key);
$data['number'] = $value;
$data['location_id'] = $locatiion[0];
$data['pallet_id'] = $locatiion[1];
if (!empty($data['pallet_id'])){
if (StockModel::where('pallet_id',$data['pallet_id'])->where('warehousing_sn',$outStoreDetail['warehousing_sn'])->sum('stock') == $value){
$data['pick_remark'] = '整卡板';
}else{
$data['pick_remark'] = '拆零';
}
$isAllGoods++;
}
$data['box_id'] = $locatiion[2];
if (!empty($data['box_id'])){
if (StockModel::where('pallet_id',$data['pallet_id'])->where('warehousing_sn',$outStoreDetail['warehousing_sn'])->sum('stock') == $value){
$data['pick_remark'] = '整箱';
}else{
$data['pick_remark'] = '拆零';
}
}
$returData[] = $data;
}
if (empty($isAllGoods)){
//判断是当前商品是否是整拣
if (StockModel::where('goods_id',$outStoreDetail['goods_id'])->where('warehousing_sn',$outStoreDetail['warehousing_sn'])->sum('stock') == $returData[0]['number']){
$returData[0]['pick_remark'] = '整拣';
}else{
$returData[0]['pick_remark'] = '拆零';
}
}
return $returData;
}
//生成拣货任务
......@@ -98,18 +154,27 @@ class PickTaskLogic
$outStoreDetailIdArr = OutStoreDetailModel::where('pick_task_id',$pickTaskId)->where('location_id',$locationId)->pluck('out_store_detail_id');
}
$returnData = PickTaskDetailModel::where('is_del',0)->where('is_show',1)->orderBy('pick_status','asc')->whereIn('out_store_detail_id',$outStoreDetailIdArr)->orderBy('add_time','desc')->get();
$returnData = PickTaskDetailModel::where('is_del',0)
->where('is_show',1)
->orderBy('pick_status','asc')
->orderBy('add_time','desc')
->where('pick_task_id',$pickTaskId);
if (!empty($outStoreDetailIdArr)){
$returnData = $returnData->whereIn('out_store_detail_id',$outStoreDetailIdArr);
}
$returnData = $returnData->get()->toArray();
if (empty($returnData)){
return [];
}
$returnData = $returnData->toArray();
foreach ($returnData as $key=>$value){
$value = array_merge($value,OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray());
$value = array_merge(OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray(),$value);
$returnData[$key] = CommonLogic::getHaveKeyCn($value);
$returnData[$key]['piece_num'] = 0;
$returnData[$key]['piece_num'] = 1;
}
return $returnData;
}
......@@ -118,6 +183,141 @@ class PickTaskLogic
public function confirmPick($data)
{
$pickTaskDetailIdArr = $data['pick_task_detail_id_arr'];
//获取可以拣货的数据
if (empty($pickTaskDetail = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->where('pick_status','!=',3)->get()->toArray())){
throw new \Exception('当前出库号没有可以拣货任务: ');
}
self::checkIsPackCheck($pickTaskDetailIdArr,'该单据已经复核,不可再拣货');
DB::beginTransaction();
try{
foreach ($pickTaskDetail as $value){
//获取需要配合的拣货详情
if (empty($outStoreDetailInfo = OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first())){
throw new \Exception('当前出库详情没有数据: '.$value['out_store_detail_id']);
}
if (empty($outStoreInfo = OutStoreModel::where('out_store_id',$value['out_store_id'])->first())){
throw new \Exception('当前出库单没有数据: '.$value['out_store_id']);
}
$outStoreInfo = $outStoreInfo->toArray();
$outStoreDetailInfo = $outStoreDetailInfo->toArray();
//增加冻结库存,扣减可用库存,实际库存不变 如果为散件,则生成打包复核任务
if (empty($stockInfo = StockModel::where('warehousing_sn',$outStoreDetailInfo['warehousing_sn'])
->where('location_id',$value['location_id'])
->where('pallet_id',$value['pallet_id'])
->where('box_id',$value['box_id'])
->where('goods_id',$outStoreDetailInfo['goods_id'])
->get()->toArray())){
throw new \Exception('当前库存详情没有数据: '.$value['pick_task_detail_id']);
}
//下架箱子和卡板
if (!empty($value['box_id'])){
BoxModel::getWhereObj([])->where('box_id',$value['box_id'])->update(['status'=>3]);
}
if (!empty($value['pallet_id'])){
PalletModel::getWhereObj([])->where('pallet_id',$value['pallet_id'])->update(['status'=>3]);
}
//如果该任务没有打包复核任务,而且还是散件,就生成一个打包复核任务
if($outStoreInfo['remark'] == '散件'){
$picktaskInfo = PickTaskModel::getWhereObj([])->where('pick_task_id',$value['pick_task_id'])->first();
if (!empty($picktaskInfo)){
//如果没有就添加
if (empty($packInfo = PackCheckModel::getWhereObj([])->where('pick_task_id',$value['pick_task_id'])->first())){
$packCheckId = PackCheckModel::insertGetId([
'pack_check_sn'=>PackCheckLogic::getPackCheckSn(),'pick_task_sn'=>$picktaskInfo['pick_task_sn'],
'in_store_sn'=>$outStoreInfo['warehousing_sn'],
'pick_task_id'=>$picktaskInfo['pick_task_id'],'add_time'=>time(),'store_id'=>CommonLogic::getAdminInfo()['store_id']
]);
}else{
$packCheckId = $packInfo->pack_check_id;
}
PickTaskDetailModel::getWhereObj([])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pack_check_id'=>$packCheckId]);
}
}
//查看数量是否足够 ,所有库存减去冻结库存
$totalNumber = array_sum(array_column($stockInfo,'stock'));
$totalNumber = $totalNumber - StockFrozenModel::where('goods_id',$outStoreDetailInfo['goods_id'])->where('pick_task_detail_id',$value['pick_task_detail_id'])->where('status',1)->sum('number');
if ( $totalNumber < $value['number']){
throw new \Exception('该商品库存不足');
}
$needNumber = $value['number'];
foreach ($stockInfo as $stockKey=>$stockValue){
//所需要库存完整了,就停止
if ($needNumber <= 0){
break;
}
//查看当前可用的库存是否充足,没有了直接跳过
if ($currentStocFrozenkNum = StockFrozenModel::whereIn('stock_id',[$stockValue['stock_id']])->where('pick_task_detail_id',$value['pick_task_detail_id'])->where('status',1)->value('number')){
if ( ($stockValue['stock'] -= $currentStocFrozenkNum) <= 0){
continue;
}
}
//增加相应的冻结库存
if ($stockValue['stock'] < $needNumber){
$needNumber = bcsub($needNumber,$stockValue['stock']);
$stockFrozenNum = $stockValue['stock'];
}else{
$stockFrozenNum = $needNumber;
$needNumber = 0;
}
//增加冻结库存
if ($frozenInfo = StockFrozenModel::where('stock_id',$stockValue['stock_id'])->where('pick_task_detail_id',$value['pick_task_detail_id'])->first()){
$frozenInfo = $frozenInfo->toArray();
StockFrozenModel::where('stock_id',$stockValue['stock_id'])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['number'=>bcadd($frozenInfo['number'],$stockFrozenNum)]);
}else{
StockFrozenModel::insertGetId([
'stock_id'=>$stockValue['stock_id'], 'store_id'=>$outStoreInfo['store_id'],'location_id'=>$value['location_id'],
'goods_id'=>$outStoreDetailInfo['goods_id'],
'status'=>1,'add_time'=>time(),'number'=>$stockFrozenNum,'pick_task_detail_id'=>$value['pick_task_detail_id']
]);
}
}
}
//确认拣货
PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->update(['pick_status'=>3,'pick_time'=>time(),'pick_user_name'=>CommonLogic::getAdminInfo()['admin_name']]);
DB::commit();
}catch (\Exception $exception){
DB::rollBack();
throw new \Exception('拣货事物异常错误为: '.$exception->getMessage());
}
return [];
}
//拣货
public function confirmPick_back($data)
{
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
//获取可以拣货的数据
......@@ -125,11 +325,14 @@ class PickTaskLogic
throw new \Exception('当前出库号没有可以拣货任务: ');
}
self::checkIsPackCheck($outStoreDetailIdArr,'该单据已经复核,不可再拣货');
DB::beginTransaction();
try{
foreach ($pickTaskDetail as $value){
foreach ($pickTaskDetail as $value){
DB::beginTransaction();
try{
//获取需要配合的拣货详情
if (empty($outStoreDetailInfo = OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first())){
throw new \Exception('当前出库详情没有数据: '.$value['out_store_detail_id']);
......@@ -137,18 +340,38 @@ class PickTaskLogic
$outStoreDetailInfo = $outStoreDetailInfo->toArray();
//增加冻结库存,扣减可用库存,实际库存不变 如果为散件,则生成打包复核任务
if (empty($stockInfo = StockModel::where('goods_name',$outStoreDetailInfo['goods_name'])->orderBy('stock','asc')->select('stock','stock_id')->get())){
if (empty($stockInfo = StockModel::where('goods_name',$outStoreDetailInfo['goods_name'])->orderBy('stock','asc')->select('stock','stock_id')->get()->toArray())){
throw new \Exception('当前库存详情没有数据: '.$outStoreDetailInfo['goods_id']);
}
$stockInfo = $stockInfo->toArray();
//下架箱子和卡板
if (!empty($outStoreDetailInfo->box_id)){
BoxModel::getWhereObj([])->where('box_id',$outStoreDetailInfo->box_id)->update(['status'=>3]);
if (!empty($outStoreDetailInfo['box_id'])){
BoxModel::getWhereObj([])->where('box_id',$outStoreDetailInfo['box_id'])->update(['status'=>3]);
}
if (!empty($outStoreDetailInfo->pallet_id)){
PalletModel::getWhereObj([])->where('pallet_id',$outStoreDetailInfo->pallet_id)->update(['status'=>3]);
if (!empty($outStoreDetailInfo['pallet_id'])){
PalletModel::getWhereObj([])->where('pallet_id',$outStoreDetailInfo['pallet_id'])->update(['status'=>3]);
}
//如果该任务没有打包复核任务,而且还是散件,就生成一个打包复核任务
if(empty($outStoreDetailInfo['box_id']) && empty($outStoreDetailInfo['pallet_id'])){
$picktaskInfo = PickTaskModel::getWhereObj([])->where('pick_task_id',$value['pick_task_id'])->first();
if (!empty($picktaskInfo)){
//如果没有就添加
if (empty($packInfo = PackCheckModel::getWhereObj([])->where('pick_task_id',$value['pick_task_id'])->first())){
$packCheckId = PackCheckModel::insertGetId([
'pack_check_sn'=>PackCheckLogic::getPackCheckSn(),'pick_task_sn'=>PickTaskModel::where('out_store_id',$outStoreDetailInfo['out_store_id'])->value('pick_task_sn'),
'in_store_sn'=>OutStoreModel::where('out_store_id',$outStoreDetailInfo['out_store_id'])->value('warehousing_sn'),
'pick_task_id'=>$picktaskInfo['pick_task_id'],'add_time'=>time(),'store_id'=>CommonLogic::getAdminInfo()['store_id']
]);
}else{
$packCheckId = $packInfo->pack_check_id;
}
PickTaskDetailModel::getWhereObj([])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pack_check_id'=>$packCheckId,'pick_remark'=>'散件']);
}
}
//查询出所有商品ID
......@@ -191,7 +414,7 @@ class PickTaskLogic
//增加冻结库存
if ($frozenInfo = StockFrozenModel::where('stock_id',$stockValue['stock_id'])->first()){
if ($frozenInfo = StockFrozenModel::where('stock_id',$stockValue['stock_id'])->where('pick_task_detail_id',$value['pick_task_detail_id'])->first()){
$frozenInfo = $frozenInfo->toArray();
StockFrozenModel::where('stock_id',$stockValue['stock_id'])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['number'=>bcadd($frozenInfo['number'],$stockFrozenNum)]);
}else{
......@@ -202,24 +425,16 @@ class PickTaskLogic
]);
}
}
//如果该任务没有打包复核任务,而且还是散件,就生成一个打包复核任务
if($outStoreDetailInfo['remark'] == '散件'){
PackCheckModel::insertGetId([
'pack_check_sn'=>PackCheckLogic::getPackCheckSn(),'pick_task_sn'=>PickTaskModel::where('out_store_id',$outStoreDetailInfo['out_store_id'])->value('pick_task_sn'),
'in_store_sn'=>OutStoreModel::where('out_store_id',$outStoreDetailInfo['out_store_id'])->value('warehousing_sn'),
'store_id'=>$outStoreDetailInfo['store_id'],'add_time'=>time(),
]);
}
DB::commit();
}catch (\Exception $exception){
DB::rollBack();
throw new \Exception($value['pick_task_detail_id'].'拣货事物异常错误为: '.$exception->getMessage());
}
//确认拣货
PickTaskDetailModel::where('pick_task_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>3,'pick_time'=>time(),'pick_user_name'=>CommonLogic::getAdminInfo()['admin_name']]);
DB::commit();
}catch (\Exception $exception){
DB::rollBack();
throw new \Exception($value['pick_task_detail_id'].'拣货事物异常错误为: '.$exception->getMessage());
}
//确认拣货
PickTaskDetailModel::where('pick_task_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>3,'pick_time'=>time(),'pick_user_name'=>CommonLogic::getAdminInfo()['admin_name']]);
return [];
}
......@@ -230,22 +445,21 @@ class PickTaskLogic
*/
public function cancelPick($data)
{
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
$pickTaskDetailIdArr = $data['pick_task_detail_id_arr'];
self::checkIsPackCheck($pickTaskDetailIdArr,'该单据已经复核,不可再拣货');
//获取可以拣货的数据
if (empty($pickTaskDetail = PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->where('pick_status','=',3)->get()->toArray())){
if (empty($pickTaskDetail = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->where('pick_status','=',3)->get()->toArray())){
throw new \Exception('当前出库号没有可以取消的拣货任务: ');
}
DB::beginTransaction();
try{
foreach ($pickTaskDetail as $value){
//获取需要配合的拣货详情
if (empty($outStoreDetailInfo = OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first())){
throw new \Exception('当前出库详情没有数据: '.$value['out_store_detail_id']);
......@@ -260,7 +474,7 @@ class PickTaskLogic
StockFrozenModel::where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['number'=>0]);
//取消拣货
PickTaskDetailModel::where('pick_task_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>4]);
PickTaskDetailModel::where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pick_status'=>4]);
}
DB::commit();
......@@ -276,15 +490,18 @@ class PickTaskLogic
{
$palletId = PalletModel::getWhereObj([])->where('pallet_sn',$data['pallet_box_sn'])->value('pallet_id');
$returnData = PickTaskDetailModel::getWhereObj(['pallet_id'=>$palletId])->orderBy('add_time','desc')->get();
if (empty($palletId)){
throw new \Exception('卡板ID不存在');
}
$returnData = OutStoreDetailModel::getWhereObj([])->where('pallet_id',$palletId)->orderBy('add_time','desc')->get()->toArray();
if (empty($returnData)){
return [];
}
$returnData = $returnData->toArray();
foreach ($returnData as $key=>$value){
$value = array_merge($value,OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray());
$value = array_merge(PickTaskDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray(),$value);
$returnData[$key] = CommonLogic::getHaveKeyCn($value);
}
return $returnData;
......@@ -356,4 +573,11 @@ class PickTaskLogic
}
static public function checkIsPackCheck($pickTaskDetailIdArr,$msg='请求错误')
{
if (!empty(PickTaskDetailModel::getWhereObj([])->whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->where('pack_status','>',1)->value('pick_task_detail_id'))){
throw new \Exception($msg);
}
}
}
\ No newline at end of file
{"server":{"listen_ip":"0.0.0.0","listen_port":"40003","socket_type":1,"enable_coroutine_runtime":false,"server":"LaravelS","handle_static":false,"laravel_base_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","inotify_reload":{"enable":false,"watch_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","file_types":[".php"],"excluded_dirs":[],"log":true},"event_handlers":[],"websocket":{"enable":false},"sockets":[],"processes":[],"timer":{"enable":false,"jobs":[],"pid_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/laravels-timer.pid","max_wait_time":5},"events":[],"swoole_tables":[],"register_providers":[],"cleaners":[],"swoole":{"daemonize":false,"dispatch_mode":2,"reactor_num":4,"worker_num":"3","task_ipc_mode":1,"task_max_request":8000,"task_tmpdir":"/tmp","max_request":8000,"open_tcp_nodelay":true,"pid_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/laravels.pid","log_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/logs/swoole-2020-05.log","log_level":4,"document_root":"/usr/local/var/www/ichunt/scm_wms_outstore_service/public","buffer_output_size":2097152,"socket_buffer_size":134217728,"package_max_length":4194304,"reload_async":true,"max_wait_time":60,"enable_reuse_port":true,"enable_coroutine":false,"http_compression":false},"enable_gzip":false,"process_prefix":"/usr/local/var/www/ichunt/scm_wms_outstore_service","ignore_check_pid":false},"laravel":{"root_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","static_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service/public","cleaners":[],"register_providers":[],"is_lumen":true,"_SERVER":{"SHELL":"/bin/bash","TERM":"xterm-256color","HOMEBREW_BOTTLE_DOMAIN":"https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles","TMPDIR":"/var/folders/vd/95yw3kdx65n1qw9ggmkkkp7c0000gn/T/","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.wWtj0v7Agw/Render","USER":"gongyang","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.tXmktxiIKD/Listeners","__CF_USER_TEXT_ENCODING":"0x1F5:0x19:0x34","PATH":"/usr/local/opt/mysql@5.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin","_":"/usr/bin/php","PWD":"/usr/local/var/www/ichunt/scm_wms_outstore_service","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"0","HOME":"/Users/gongyang","SHLVL":"2","LOGNAME":"gongyang","LC_CTYPE":"zh_CN.UTF-8","PHP_SELF":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","SCRIPT_NAME":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","SCRIPT_FILENAME":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","PATH_TRANSLATED":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","DOCUMENT_ROOT":"","REQUEST_TIME_FLOAT":1589425564.966995,"REQUEST_TIME":1589425564,"argv":["/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","laravels","config"],"argc":3,"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"","APP_TIMEZONE":"PRC","DB_TIMEZONE":"+08:00","SYSTEM_CODE":"01","SYSTEM_NAME":"服务初始服务(开发环境)","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"40003","worker_num":"3","DB_CONNECTION":"mysql","DB_HOST":"192.168.2.232","DB_USERNAME":"liexin_scm_wms","DB_PASSWORD":"liexin_scm_wms#zsyM","DB_PORT":"3306","DB_DATABASE":"liexin_scm_wms","DB_PREFIX":"lie_","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.237","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","RABBIT_IP":"192.168.1.237","RABBIT_PORT":"5672","RABBIT_USER":"huntadmin","RABBIT_PASS":"jy2y2900","SHELL_VERBOSITY":0},"_ENV":{"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"","APP_TIMEZONE":"PRC","DB_TIMEZONE":"+08:00","SYSTEM_CODE":"01","SYSTEM_NAME":"服务初始服务(开发环境)","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"40003","worker_num":"3","DB_CONNECTION":"mysql","DB_HOST":"192.168.2.232","DB_USERNAME":"liexin_scm_wms","DB_PASSWORD":"liexin_scm_wms#zsyM","DB_PORT":"3306","DB_DATABASE":"liexin_scm_wms","DB_PREFIX":"lie_","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.237","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","RABBIT_IP":"192.168.1.237","RABBIT_PORT":"5672","RABBIT_USER":"huntadmin","RABBIT_PASS":"jy2y2900","SHELL_VERBOSITY":0}}}
\ No newline at end of file
{"server":{"listen_ip":"0.0.0.0","listen_port":"40003","socket_type":1,"enable_coroutine_runtime":false,"server":"LaravelS","handle_static":false,"laravel_base_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","inotify_reload":{"enable":false,"watch_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","file_types":[".php"],"excluded_dirs":[],"log":true},"event_handlers":[],"websocket":{"enable":false},"sockets":[],"processes":[],"timer":{"enable":false,"jobs":[],"pid_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/laravels-timer.pid","max_wait_time":5},"events":[],"swoole_tables":[],"register_providers":[],"cleaners":[],"swoole":{"daemonize":false,"dispatch_mode":2,"reactor_num":4,"worker_num":"3","task_worker_num":3,"task_ipc_mode":1,"task_max_request":8000,"task_tmpdir":"/tmp","max_request":8000,"open_tcp_nodelay":true,"pid_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/laravels.pid","log_file":"/usr/local/var/www/ichunt/scm_wms_outstore_service/storage/logs/swoole-2020-05.log","log_level":4,"document_root":"/usr/local/var/www/ichunt/scm_wms_outstore_service/public","buffer_output_size":2097152,"socket_buffer_size":134217728,"package_max_length":4194304,"reload_async":true,"max_wait_time":60,"enable_reuse_port":true,"enable_coroutine":false,"http_compression":false},"enable_gzip":false,"process_prefix":"/usr/local/var/www/ichunt/scm_wms_outstore_service","ignore_check_pid":false},"laravel":{"root_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service","static_path":"/usr/local/var/www/ichunt/scm_wms_outstore_service/public","cleaners":[],"register_providers":[],"is_lumen":true,"_SERVER":{"SHELL":"/bin/bash","TERM":"xterm-256color","HOMEBREW_BOTTLE_DOMAIN":"https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles","TMPDIR":"/var/folders/vd/95yw3kdx65n1qw9ggmkkkp7c0000gn/T/","Apple_PubSub_Socket_Render":"/private/tmp/com.apple.launchd.qUCXwtFWzp/Render","USER":"gongyang","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.Z1K2tYGKcP/Listeners","__CF_USER_TEXT_ENCODING":"0x1F5:0x19:0x34","PATH":"/usr/local/opt/mysql@5.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin","_":"/usr/bin/php","PWD":"/usr/local/var/www/ichunt/scm_wms_outstore_service","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"0","HOME":"/Users/gongyang","SHLVL":"2","LOGNAME":"gongyang","LC_CTYPE":"zh_CN.UTF-8","PHP_SELF":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","SCRIPT_NAME":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","SCRIPT_FILENAME":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","PATH_TRANSLATED":"/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","DOCUMENT_ROOT":"","REQUEST_TIME_FLOAT":1589768657.672203,"REQUEST_TIME":1589768657,"argv":["/usr/local/var/www/ichunt/scm_wms_outstore_service/artisan","laravels","config"],"argc":3,"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"","APP_TIMEZONE":"PRC","DB_TIMEZONE":"+08:00","SYSTEM_CODE":"01","SYSTEM_NAME":"服务初始服务(开发环境)","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"40003","worker_num":"3","DB_CONNECTION":"mysql","DB_HOST":"192.168.2.232","DB_USERNAME":"liexin_scm_wms","DB_PASSWORD":"liexin_scm_wms#zsyM","DB_PORT":"3306","DB_DATABASE":"liexin_scm_wms","DB_PREFIX":"lie_","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.237","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","RABBIT_IP":"192.168.1.237","RABBIT_PORT":"5672","RABBIT_USER":"huntadmin","RABBIT_PASS":"jy2y2900","RABBITMQ_LOG_HOST":"192.168.1.237","RABBITMQ_LOG_PORT":"5672","RABBITMQ_LOG_VHOST":"/","RABBITMQ_LOG_LOGIN":"huntadmin","RABBITMQ_LOG_PASSWORD":"jy2y2900","RABBITMQ_LOG_QUEUE":"scm_wms_log","SHELL_VERBOSITY":0},"_ENV":{"APP_ENV":"local","APP_DEBUG":"true","APP_KEY":"","APP_TIMEZONE":"PRC","DB_TIMEZONE":"+08:00","SYSTEM_CODE":"01","SYSTEM_NAME":"服务初始服务(开发环境)","LARAVELS_LISTEN_IP":"0.0.0.0","LARAVELS_LISTEN_PORT":"40003","worker_num":"3","DB_CONNECTION":"mysql","DB_HOST":"192.168.2.232","DB_USERNAME":"liexin_scm_wms","DB_PASSWORD":"liexin_scm_wms#zsyM","DB_PORT":"3306","DB_DATABASE":"liexin_scm_wms","DB_PREFIX":"lie_","REDIS_HOST":"192.168.1.235","REDIS_PASSWORD":"icDb29mLy2s","REDIS_PORT":"6379","REDIS_READ_HOST":"192.168.1.237","REDIS_READ_PASSWORD":"icDb29mLy2s","REDIS_READ_PORT":"6379","CACHE_DRIVER":"file","QUEUE_DRIVER":"sync","RABBIT_IP":"192.168.1.237","RABBIT_PORT":"5672","RABBIT_USER":"huntadmin","RABBIT_PASS":"jy2y2900","RABBITMQ_LOG_HOST":"192.168.1.237","RABBITMQ_LOG_PORT":"5672","RABBITMQ_LOG_VHOST":"/","RABBITMQ_LOG_LOGIN":"huntadmin","RABBITMQ_LOG_PASSWORD":"jy2y2900","RABBITMQ_LOG_QUEUE":"scm_wms_log","SHELL_VERBOSITY":0}}}
\ No newline at end of file
74392
\ No newline at end of file
13578
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment