Commit a59f541c by CnChunfeng

Merge branch 'develop' into 'master'

Develop

See merge request !1
parents 68c44461 301a4d7a
/.idea
Homestead.json
Homestead.yaml
/storage
\ No newline at end of file
......@@ -12,7 +12,6 @@ use App\Http\Model\Logic\OutStoreLogic;
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;
......
......@@ -16,6 +16,7 @@ class Controller extends BaseController
//获取错误描述
$ErrMsg = config('errmsg.cn.'.self::$errCode);
if (empty($ErrMsg))$ErrMsg=$dataArr;
//上报错误
$data=['errcode'=>self::$errCode, 'errmsg'=>$ErrMsg];
......
......@@ -201,12 +201,38 @@ class OutStoreLogic
DB::rollBack();
Controller::$level = 5;
Controller::$errCode = 5;
throw new \Exception('插入出库事物错误数据为 '.$exception->getMessage());
throw new \Exception('插入出库事物错误数据为::: '.$exception->getMessage());
}
return [];
}
/*
* 删除出库通知单
* param1 warehousing_sn
* 1 根据参数1查找出出库单ID
* 2 根据出库单ID删除对应的出库单明细
* where
* 如果生成了拣货任务就不删除
*/
public function deleteOutStore($data)
{
$outStoreInfo = OutStoreModel::where('warehousing_sn',$data['warehousing_sn'])->where('is_del',0)->select('out_store_id')->first();
if (empty($outStoreInfo)){
throw new \Exception('该入仓号号不存在');
}
if (PickTaskDetailModel::where('is_del',0)->where('is_show',1)->where('out_store_id',$outStoreInfo->out_store_id)->value('pick_task_detail_id')){
throw new \Exception('发货通知单已经生成拣货任务');
}
OutStoreModel::where('out_store_id',$outStoreInfo->out_store_id)->where('is_del',0)->update(['is_del'=>1]);
OutStoreDetailModel::where('out_store_id',$outStoreInfo->out_store_id)->where('is_del',0)->update(['is_del'=>1]);
PickTaskDetailModel::where('out_store_id',$outStoreInfo->out_store_id)->where('is_del',0)->update(['is_del'=>1]);
return [];
}
//获取出库仓号
......
......@@ -19,6 +19,7 @@ use App\Http\Model\PickTaskModel;
use App\Http\Model\StockFrozenModel;
use App\Http\Model\StockModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class PalletLogic
{
......@@ -176,10 +177,10 @@ class PalletLogic
}
}
$isApplyCustoms = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->value('is_apply_customs');
if (!isset($data['is_apply_customs_app'])){
//是否需要报关
if ($isApplyCustoms = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->value('is_apply_customs') ){
if ($isApplyCustoms){
throw new \Exception('报关单据不可在此发货');
}
//复核
......@@ -258,21 +259,30 @@ class PalletLogic
throw new \Exception('装箱型号不能为空');
}
//查找出所有的拣货详情
$outStoreDetailIdArr = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->pluck('out_store_detail_id')->toArray();
if (empty($outStoreDetailIdArr)){
throw new \Exception('查找不到拣货详情');
}
//如果是新箱子就生成一个下架箱子
if ($data['pack_type'] != 2){
$data['pack_val'] = $boxSn = BoxModel::getBoxSn();
Log::info(json_encode($outStoreDetailIdArr));
$isInsp = OutStoreDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->where('is_insp',1)->value('out_store_detail_id');
if (empty($isInsp)){
$isInsp = 2;
}else{
$isInsp = 1;
}
BoxModel::insertGetId([
'box_sn'=>$boxSn,'weight'=>$data['weigh_val'],'status'=>3,
'add_time'=>time(),'admin_id'=>CommonLogic::getAdminInfo()['admin_id'],'admin_name'=>CommonLogic::getAdminInfo()['admin_name'],
'box_sn'=>$boxSn,'weight'=>$data['weigh_val'],'status'=>3,'is_insp'=>$isInsp,
'add_time'=>time(),'last_update_time'=>time(),'admin_id'=>CommonLogic::getAdminInfo()['admin_id'],'admin_name'=>CommonLogic::getAdminInfo()['admin_name'],
'store_id'=>CommonLogic::getAdminInfo()['store_id'],'customer_id'=>OutStoreModel::where('out_store_id',PickTaskDetailModel::where('pick_task_detail_id',$pickTaskDetailIdArr[0])->value('out_store_id'))->value('customer_id')
]);
}
//查找出所有的拣货详情
$outStoreDetailIdArr = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->pluck('out_store_detail_id')->toArray();
if (empty($outStoreDetailIdArr)){
throw new \Exception('查找不到拣货详情');
}
//查找出当前箱子信息
if (empty($boxId = BoxModel::where('box_sn',$data['pack_val'])->value('box_id'))){
......
......@@ -66,13 +66,13 @@ class PickTaskLogic
}
}
//生成拣货记录
//生成拣货记录,增加拣货任务不变的卡板定位箱子数据。
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];
$data['pick_location_id'] = $data['location_id'] = $locatiion[0];
$data['pick_pallet_id'] = $data['pallet_id'] = $locatiion[1];
$data['pick_box_id'] = $data['box_id'] = $locatiion[2];
$returData[] = $data;
}
......@@ -206,7 +206,9 @@ class PickTaskLogic
}else{
$packCheckId = $packInfo->pack_check_id;
}
PickTaskDetailModel::getWhereObj([])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pack_check_id'=>$packCheckId]);
//当时拆零的时候就重新设置卡板和箱子ID
PickTaskDetailModel::getWhereObj([])->where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pack_check_id'=>$packCheckId,'pallet_id'=>0,'box_id'=>0]);
}
}
......@@ -268,137 +270,11 @@ class PickTaskLogic
throw new \Exception('拣货事物异常错误为: '.$exception->getMessage());
}
return [];
}
//拣货
public function confirmPick_back($data)
{
$outStoreDetailIdArr = $data['out_store_detail_id_arr'];
//获取可以拣货的数据
if (empty($pickTaskDetail = PickTaskDetailModel::whereIn('out_store_detail_id',$outStoreDetailIdArr)->where('pick_status','!=',3)->get()->toArray())){
throw new \Exception('当前出库号没有可以拣货任务: ');
}
self::checkIsPackCheck($outStoreDetailIdArr,'该单据已经复核,不可再拣货');
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']);
}
$outStoreDetailInfo = $outStoreDetailInfo->toArray();
//增加冻结库存,扣减可用库存,实际库存不变 如果为散件,则生成打包复核任务
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']);
}
//下架箱子和卡板
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['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'=>$picktaskInfo->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
$goodsIdArr = GoodsModel::where('goods_name',$outStoreDetailInfo['goods_name'])->where('status',1)->pluck('goods_id')->toArray();
if (empty($goodsIdArr)){
throw new \Exception('该型号暂无商品');
}
//查看数量是否足够 ,所有库存减去冻结库存
$totalNumber = array_sum(array_column($stockInfo,'stock'));
$totalNumber = $totalNumber - StockFrozenModel::whereIn('goods_id',$goodsIdArr)->where('status',1)->sum('number');
if ( $totalNumber < $outStoreDetailInfo['number']){
throw new \Exception('该商品库存不足');
}
$needNumber = $outStoreDetailInfo['number'];
foreach ($stockInfo as $stockValue){
//所需要库存完整了,就停止
if ($needNumber <= 0){
break;
}
//查看当前可用的库存是否充足,没有了直接跳过
if ($currentStocFrozenkNum = StockFrozenModel::whereIn('stock_id',[$stockValue['stock_id']])->where('status',1)->value('number')){
if ( ($stockValue['stock'] -= $currentStocFrozenkNum) <= 0){
continue;
}
}
//增加相应的冻结库存
if ($stockValue['stock'] < $needNumber){
$needNumber = $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'=>$outStoreDetailInfo['store_id'],'location_id'=>$outStoreDetailInfo['location_id'],
'goods_id'=>$outStoreDetailInfo['goods_id'],
'status'=>1,'add_time'=>time(),'number'=>$stockFrozenNum,'pick_task_detail_id'=>$value['pick_task_detail_id']
]);
}
}
}
//确认拣货
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());
}
return [];
}
/**
* 取消拣货
......@@ -433,8 +309,9 @@ class PickTaskLogic
}
StockFrozenModel::where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['number'=>0]);
//取消拣货
PickTaskDetailModel::where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pick_status'=>4]);
//取消拣货,修改打包复核ID未0,返回原始的箱子和卡板ID
PickTaskDetailModel::where('pick_task_detail_id',$value['pick_task_detail_id'])->update(['pick_status'=>4,'pack_check_id'=>0,'pallet_id'=>$value['pick_pallet_id'],'box_id'=>$value['pick_box_id']]);
}
DB::commit();
......@@ -557,6 +434,10 @@ class PickTaskLogic
$palletBoxGoodsData = PickTaskDetailModel::whereIn('pick_task_detail_id',$pickTaskDetailIdArr)->select('pallet_id','box_id','out_store_detail_id','pick_task_detail_id','number')->get()->toArray();
$pickTaskRemarkData = [];
//卡板和箱子的数量
$palletNum = [];
$boxNum = [];
foreach ($palletBoxGoodsData as $value){
$value['goods_id'] = OutStoreDetailModel::where('out_store_detail_id',$value['out_store_detail_id'])->value('goods_id');
$key = $value['pallet_id'].'_'.$value['box_id'].'_'.$value['goods_id'];
......@@ -566,6 +447,18 @@ class PickTaskLogic
$pickTaskRemarkData[$key]['number'] = $value['number'];
}
if(isset($palletNum[$value['pallet_id']])){
$palletNum[$value['pallet_id']] = bcadd($palletNum[$value['pallet_id']],$value['number']);
}else{
$palletNum[$value['pallet_id']] = $value['number'];
}
if(isset($boxNum[$value['box_id']])){
$boxNum[$value['box_id']] = bcadd($boxNum[$value['box_id']],$value['number']);
}else{
$boxNum[$value['box_id']] = $value['number'];
}
$pickTaskRemarkData[$key]['pick_task_detail_id_arr'][] = $value['pick_task_detail_id'];
}
......@@ -575,7 +468,7 @@ class PickTaskLogic
//卡板不为空卡板数量比较
if (!empty($locationArr[0])){
if ($value['number'] == StockModel::where('pallet_id',$locationArr[0])->sum('stock')){
if ($palletNum[$locationArr[0]] == StockModel::where('pallet_id',$locationArr[0])->sum('stock')){
$pickRemark = '整卡板';
}else{
$pickRemark = '拆零';
......@@ -583,7 +476,7 @@ class PickTaskLogic
}else{
//箱不为空,箱数量比较
if (!empty($locationArr[1])){
if ($value['number'] == StockModel::where('box_id',$locationArr[1])->sum('stock')){
if ($boxNum[$locationArr[1]] == StockModel::where('box_id',$locationArr[1])->sum('stock')){
$pickRemark = '整箱';
}else{
$pickRemark = '拆零';
......
......@@ -20,7 +20,7 @@ class OutStoreDetailModel extends Model
static public function getWhereObj($data)
{
$obj = self::where('store_id',app('request')->store_id);
$obj = self::where('store_id',app('request')->store_id)->where('is_del',0);
foreach ($data as $key=>$value){
if (empty($value))continue;
......
......@@ -19,6 +19,6 @@ class OutStoreModel extends Model
static public function getWhereObj($data)
{
return $obj = self::where('store_id','=',app('request')->store_id);
return $obj = self::where('store_id','=',app('request')->store_id)->where('is_del',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.Cbm9nTKoj1/Render","USER":"gongyang","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.F27n9HY3bm/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":1590049958.276179,"REQUEST_TIME":1590049958,"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
81424
\ No newline at end of file
......@@ -279,7 +279,7 @@ class ClassLoader
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**
......@@ -377,7 +377,7 @@ class ClassLoader
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
$search = $subPath.'\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
......
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