Commit f64e9a4a by Joneq

完善添加

parent 3ce6bf13
......@@ -170,12 +170,11 @@ class AdminOutstoreController extends Controller
public function palletActive($request)
{
$data = $request->all();
// try{
// $returnData = (new PalletLogic())->palletActive($data);
// }catch (\Exception $exception){
// return $this->apiReturn($exception->getMessage().'|jsondata='.json_encode($data));
// }
$returnData = (new PalletLogic())->palletActive($data);
try{
$returnData = (new PalletLogic())->palletActive($data);
}catch (\Exception $exception){
return $this->apiReturn($exception->getMessage().'|jsondata='.json_encode($data));
}
return $this->apiReturn($returnData);
}
......@@ -207,6 +206,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)
{
......
......@@ -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,7 +112,7 @@ 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();
......@@ -127,8 +126,8 @@ class CommonLogic
'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'))),
'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,
]
];
......
......@@ -177,10 +177,10 @@ class OutStoreLogic
$outStoreDetailId = OutStoreDetailModel::insertGetId(array_merge(self::handleOutStoreDetailInsertData($value,$insertData),['pick_task_id'=>$pickTaskId]));
//is_apply_customs报关任务默认隐藏
PickTaskDetailModel::insertGetId(PickTaskLogic::handleInsertData([
PickTaskDetailModel::insertGetId([
'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
]));
]);
}
DB::commit();
......
......@@ -44,12 +44,11 @@ class PalletLogic
public function palletActive($data)
{
return 1;
if (empty($boxSnArr = explode(',',$data['box_sn_str']))){
throw new \Exception('装卡板箱子不能为空');
}
$boxSnArr = array_filter($boxSnArr);
$boxSnArr = array_unique($boxSnArr);
//获取所有的箱子ID
$boxIdArr = BoxModel::whereIn('box_sn',$boxSnArr)->pluck('box_id');
......@@ -65,6 +64,9 @@ class PalletLogic
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');
......@@ -77,7 +79,7 @@ class PalletLogic
DB::beginTransaction();
try{
DB::table('box')->whereIn('box_sn',$boxSnArr)->where('pallet_id',0)->update(['pallet_id'=>$palletId]);
OutStoreDetailModel::getWhereObj([])->whereIn('box_id',$boxIdArr)->update(['pallet_id'=>$palletId]);
OutStoreDetailModel::whereIn('box_id',$boxIdArr)->update(['pallet_id'=>$palletId]);
DB::commit();
}catch (\Exception $exception){
DB::rollBack();
......@@ -94,7 +96,7 @@ class PalletLogic
$adminInfo = CommonLogic::getAdminInfo();
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update([
'pick_status'=>4,'is_confirm'=>1,'confirm_time'=>time(),
'is_confirm'=>1,'confirm_time'=>time(),
'confirm_user_name'=>$adminInfo['admin_name'],
'confirm_user_id'=>$adminInfo['admin_id'],
]);
......@@ -107,7 +109,7 @@ class PalletLogic
//获取需要修改的货品
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['pick_status'=>4,'is_confirm'=>0]);
PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->update(['is_confirm'=>0]);
return [];
}
......@@ -124,6 +126,30 @@ 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 (!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('有箱子在上架状态,不能发货');
}
}
if (!isset($data['is_apply_customs_app'])){
//是否需要报关
......@@ -132,17 +158,9 @@ class PalletLogic
}
}
//查询状态
$packStatus = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->pluck('pack_status')->toArray();
$packStatus = array_filter($packStatus);
if (count($packStatus) > 1){
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('单据存在未复核或者已出库数据,不可重复操作');
}
......@@ -166,6 +184,12 @@ class PalletLogic
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([
......@@ -218,7 +242,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('不同委托方不可一起装箱');
}
......@@ -279,16 +303,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),
......@@ -313,7 +349,112 @@ class PalletLogic
throw new \Exception('该拣货任务不存在');
}
foreach ($outStoreDetailData as $key=>$value){
$value = array_merge($value,PickTaskDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray());
$outStoreDetailData[$key] = CommonLogic::getHaveKeyCn($value);
}
return $outStoreDetailData;
}
//获取打印的拣货任务信息
public function print_pick_task_label($data)
{
//查询当前卡板
if (empty($palletId = PalletModel::getWhereObj([])->where('pallet_sn',$data['pallet_sn'])->value('pallet_id'))){
throw new \Exception('当前卡板不存在');
}
//获取拣货任务中已经有的箱子信息
$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('当前卡板不存在箱子');
}
$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)
{
//查找拣货任务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;
}
//获取打印的拣货任务信息
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,41 @@ 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();
if (empty($stockInfo)){
throw new \Exception('当前入库单的商品库存不存在');
}
$stockInfo = $stockInfo->toArray();
//根据货位,卡板
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'];
}
}
//生成拣货记录
foreach ($pickData as $key=>$value){
$locatiion = explode('_',$key);
$data['number'] = $value;
$data['location_id'] = $locatiion[0];
$data['pallet_id'] = $locatiion[1];
$data['box_id'] = $locatiion[2];
$returData[] = array_merge($value,$data);
}
return $returData;
}
//生成拣货任务
......@@ -98,7 +124,17 @@ 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();
if (empty($returnData)){
return [];
......@@ -109,7 +145,7 @@ class PickTaskLogic
foreach ($returnData as $key=>$value){
$value = array_merge($value,OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->first()->toArray());
$returnData[$key] = CommonLogic::getHaveKeyCn($value);
$returnData[$key]['piece_num'] = 0;
$returnData[$key]['piece_num'] = 1;
}
return $returnData;
}
......@@ -129,6 +165,7 @@ class PickTaskLogic
DB::beginTransaction();
try{
foreach ($pickTaskDetail as $value){
......
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