فهرست منبع

盘点出至U型线调整

haozi 4 سال پیش
والد
کامیت
7acad0e329

+ 15 - 0
app/Http/Controllers/InventoryAccountController.php

@@ -22,6 +22,21 @@ class InventoryAccountController extends Controller
         app()->singleton('inventoryAccountService', InventoryAccountService::class);
     }
 
+    public function outToLineUpdateInventoryMissions(Request $request): array
+    {
+        if (!Gate::allows('库存管理-盘点')) {return ['success' => false, 'data' => '没有权限'];}
+        $inventory=$request->input('inventory');
+        $location=$request->input('location');
+        $location_arr=array_filter(preg_split('/[,, ]+/is', $location));
+        $wmsInventories='';
+        if ($inventory['type']=='全盘'||$inventory['type']=='局部盘点')
+            $wmsInventories=app('inventoryAccountService')->conditionTotalStock($inventory['owner_id'],$location,null);
+        if ($inventory['type']=='动盘')
+            $wmsInventories=app('inventoryAccountService')->conditionPortStock(substr($inventory['start_at'],0,10),substr($inventory['end_at'],0,10),$inventory['owner_id'],$location,null);
+        app('inventoryAccountService')->updateInventoryAccountMissionRecord($inventory['owner_id'],$inventory['id'],$location_arr,$wmsInventories);
+        return ['success' => true, 'data' => '更新成功'];
+
+    }
     //创建盘点任务
     public function createStockInventoryMission(Request $request)
     {

+ 70 - 1
app/Services/InventoryAccountService.php

@@ -12,6 +12,7 @@ use App\OracleInvLotAtt;
 use App\OracleInvLotLocId;
 use App\Owner;
 use App\Services\common\BatchUpdateService;
+use App\Services\common\DataHandlerService;
 use App\Services\common\QueryService;
 use Carbon\Carbon;
 use Illuminate\Support\Facades\Auth;
@@ -127,7 +128,7 @@ class InventoryAccountService
         return DB::connection('oracle')->select($sql);
     }
     //全盘查询
-    private function conditionTotalStock($ownerId,$location,$barcode){
+    public function conditionTotalStock($ownerId,$location,$barcode){
         $code=Owner::where('id',$ownerId)->value('code');
         $sql='select * from (select result.* from (';
         $sql.=' select customer.Descr_C as 货主,storeStatus.CUSTOMERID 客户,storeStatus.LocationID 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码1, sku.ALTERNATE_SKU2 产品条码2, sku.ALTERNATE_SKU3 产品条码3, ';
@@ -243,6 +244,74 @@ class InventoryAccountService
         Controller::logS(__METHOD__,"创建盘点任务__".__FUNCTION__,json_encode($request),Auth::user()['id']);
         return $inventory;
     }
+    //更新盘点记录任务
+    public function updateInventoryAccountMissionRecord($ownerId,$inventoryAccountId,array $locations,$wmsInventories){
+        ini_set('memory_limit','1526M');
+        $ownerCode=Owner::query()->where('id',$ownerId)->value('code');
+        $commodities=Commodity::query()
+            ->select('id','owner_id','name','sku')
+            ->where('owner_id',$ownerId)
+            ->get();
+        $commoditiesArr=[];
+        foreach ($commodities as $commodity){
+            $commoditiesArr[$ownerCode.'|'.$commodity['sku']]=$commodity;
+        }
+        $inventoryAccountMissions = InventoryAccountMission::query()
+            ->where('inventory_account_id', $inventoryAccountId)
+            ->whereIn('location', array_unique($locations))
+            ->get();
+        /** @var DataHandlerService $dataHandlerService */
+        $dataHandlerService = app(DataHandlerService::class);
+        $inventoryAccountMissions_map = $dataHandlerService->dataHeader(['inventory_account_id','commodity_id','location'], $inventoryAccountMissions);
+        $updateParams = [[
+            'id', 'commodity_id', 'inventory_account_id', 'location', 'produced_at', 'valid_at', 'batch_number',
+            'erp_type_position', 'quality', 'stored_amount', 'occupied_amount', 'valid_amount','created_at','updated_at'
+        ]];
+        foreach ($wmsInventories as $wmsInventory){
+            $commodity=$commoditiesArr[$wmsInventory->客户.'|'.$wmsInventory->产品编码]??null;
+            if (!$commodity)continue;
+            $inventoryAccountMission = $dataHandlerService
+                ->getKeyValue(['inventory_account_id'=>$inventoryAccountId,'commodity_id' => $commodity['id'],'location' => $wmsInventory->库位], $inventoryAccountMissions_map);
+            if (!$inventoryAccountMission)continue;
+            if($wmsInventory->质量状态=='ZP') $quality='正品';
+            if ($wmsInventory->质量状态=='CC') $quality='残次';
+            if ($wmsInventory->质量状态=='XS') $quality='箱损';
+            if ($wmsInventory->质量状态=='JS') $quality='机损';
+            if ($wmsInventory->质量状态=='DJ') $quality='冻结';
+            if ($wmsInventory->质量状态=='FKT') $quality='封口贴';
+
+            if (
+                $inventoryAccountMission->produced_at != $wmsInventory->生产日期 ||
+                $inventoryAccountMission->valid_at != $wmsInventory->失效日期 ||
+                $inventoryAccountMission->batch_number != $wmsInventory->批号 ||
+                $inventoryAccountMission->erp_type_position != $wmsInventory->属性仓 ||
+                $inventoryAccountMission->quality != $quality ||
+                $inventoryAccountMission->stored_amount != $wmsInventory->在库数量 ||
+                $inventoryAccountMission->occupied_amount != $wmsInventory->占用数量 ||
+                $inventoryAccountMission->valid_amount != ($wmsInventory->在库数量-$wmsInventory->占用数量)
+            ){
+                $updateParams[] = [
+                    'id' => $inventoryAccountMission->id,
+                    'commodity_id'=>$commodity->id,
+                    'inventory_account_id'=>$inventoryAccountId,
+                    'location'=>$wmsInventory->库位,
+                    'produced_at'=>$wmsInventory->生产日期,
+                    'valid_at'=>$wmsInventory->失效日期,
+                    'batch_number'=>$wmsInventory->批号,
+                    'erp_type_position'=>$wmsInventory->属性仓,
+                    'quality'=>$quality,
+                    'stored_amount'=>$wmsInventory->在库数量,
+                    'occupied_amount'=>$wmsInventory->占用数量,
+                    'valid_amount'=>$wmsInventory->在库数量-$wmsInventory->占用数量,
+                    'created_at'=>Carbon::now()->format('Y-m-d H:i:s'),
+                    'updated_at'=>Carbon::now()->format('Y-m-d H:i:s'),
+                ];
+            }
+        }
+        app(BatchUpdateService::class)->batchUpdate('inventory_account_missions', $updateParams);
+        Controller::logS(__METHOD__,"批量更新盘点记录__".__FUNCTION__,json_encode($updateParams));
+
+    }
     //创建盘点记录任务
     public function createInventoryAccountMissionRecord($ownerId,$inventoryAccountId,$wmsInventories){
         ini_set('memory_limit','1526M');

+ 29 - 0
resources/views/inventory/stockInventory/_outOnlineModal.blade.php

@@ -0,0 +1,29 @@
+<div class="modal " id="change-outOnLineAmount" tabindex="-1" >
+    <div class="modal-dialog modal-lg modal-dialog-centered">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title text-center">选定出库料想数量</h5>
+                <button type="button" class="close" data-dismiss="modal">
+                    <span>&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                    <div class="form-group row">
+                        <label for="outOnLineAmount" class="col-2 col-form-label text-right">指定料想数量</label>
+                        <div class="col-4">
+                            <input type="text" class="form-control "  name="outOnLineAmount" autocomplete="off"
+                                   :class="errors.outOnLineAmount ? 'is-invalid' : ''" v-model="outOnLineAmount">
+                            <span class="invalid-feedback" role="alert" v-if="errors.outOnLineAmount">
+                            <strong>@{{ errors.outOnLineAmount[0] }}</strong>
+                        </span>
+                        </div>
+                        <span v-if="ideLocArr.length>0">/总:@{{ ideLocArr.length }}</span>
+                    </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary"  data-dismiss="modal" >关闭</button>
+                <button type="button" class="btn btn-primary" @click="outToULineEnsure">提交</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 48 - 9
resources/views/inventory/stockInventory/inventoryMission.blade.php

@@ -19,6 +19,7 @@
                     <button class="btn btn-sm" @click="listMode?listMode=false:listMode=true" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="listMode&&inventory.status!=='已完成'&&inventory.status!=='已审核'">切换为盘点</button>
                 @endcan
             </span>
+            @include('inventory.stockInventory._outOnlineModal')
 
             <span class="dropdown">
                 <button class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
@@ -45,7 +46,7 @@
                 <button class="btn btn-sm btn-info" @click="新增盘点记录()" :class="listMode?'btn-dark':'btn-outline-dark'" v-if="!listMode&&!addInventoryMission">新增盘点记录</button>
                  <button class="btn btn-sm" @click="收起新增()" :class="addInventoryMission?'btn-dark':'btn-outline-dark'" v-if="addInventoryMission">收起新增</button>
             </span>
-            <button class="btn btn-sm btn-success" @click="outToULine()" v-if="!listMode&&materialBoxCodes">出库</button>
+            <button class="btn btn-sm btn-success" @click="outToULine()" v-if="!listMode&&ideLocArr.length>0">出库</button>
             <span class="form-group  mb-5">
             <label class="text-muted">货主:</label><span class="font-weight-bold">@{{ inventory.owner.name }}</span>
         </span>
@@ -716,6 +717,9 @@
                 goodses:[],
                 selectTr:'',
                 materialBoxCodes:'',
+                outOnLineAmount:'',
+                ideLocArr:[],
+                errors:{},
             },
             beforeMount: function () {
                 this.重排序并标记全列表类型();
@@ -770,30 +774,65 @@
                     _this.listMode = false;
                 })();
                 _this.建立记录索引();
-                _this.inventoryMissions.forEach(function (inventoryMission){
+                //将库位含有ide的料想存入数组
+                _this.未盘列.forEach(function (inventoryMission){
                     if (inventoryMission.location.indexOf('IDE')>-1){
-                        _this.materialBoxCodes += inventoryMission.location + ','
+                        _this.ideLocArr.push(inventoryMission.location)
                     }
                 });
-                if (_this.materialBoxCodes.length > 0) {
-                    _this.materialBoxCodes = _this.materialBoxCodes.substr(0,_this.materialBoxCodes.length - 1);
-                }
             },
             methods:{
                 outToULine(){
-                    if(!confirm('确定要将当前盘点任务涉及的IDE料箱号出至输送线吗?')){return;}
+                    this.ideLocArr=this.unique(this.ideLocArr);
+                    console.log(this.ideLocArr)
+                    $("#change-outOnLineAmount").modal('show');
+                },
+                //TODO 更具输入数量 截取库位 出库
+                outToULineEnsure(){
                     let _this=this;
-                    let text = _this.materialBoxCodes;
+                    let error = {};
+                    if (_this.outOnLineAmount>_this.ideLocArr.length)error.outOnLineAmount = ["出库料箱数大于当前任务料想总数"];
+                    if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
+                    if(!confirm('确定要将当前盘点任务涉及的IDE料箱号出至输送线吗?')){return;}
+                    console.log(_this.ideLocArr)
+                    let selectedArr = _this.ideLocArr.slice(0,_this.outOnLineAmount);
+                    _this.materialBoxCodes='';
+                    selectedArr.forEach(function (item){
+                        _this.materialBoxCodes += item + ','
+                    });
+                    if (_this.materialBoxCodes.length > 0) {
+                        _this.materialBoxCodes = _this.materialBoxCodes.substr(0,_this.materialBoxCodes.length - 1);
+                    }
+                    let text=_this.materialBoxCodes;
                     if(!text){
                         alert('当前盘点任务未查询到IDE料箱号!')
-                        return
+                        return;
                     }
+                    let url = '{{url('inventory/stockInventory/outToLineUpdateInventoryMissions')}}';
+                    window.axios.post(url,{inventory:_this.inventory,location:text})
+                        .then(res=>{
+                            if (res.data.success){
+                                $("#change-outOnLineAmount").modal('hide');
+                                _this.outOnLineAmount='';
+                                _this.dispatchHaiq(text);
+                            }else {
+                                window.tempTip.setDuration(2000);
+                                window.tempTip.show(res.data.data);
+                            }
+                        }).catch(err=>{
+                        window.tempTip.setDuration(2000);
+                        window.tempTip.show("网络错误:"+err);
+                    })
+                },
+                dispatchHaiq(text){
                     console.log(text)
                     axios.post('{{url('/api/thirdPart/haiq/storage/takeOutToULine')}}',{codes:text})
                         .then(function(response){
                             tempTip.okWindow(response.data.result,'确定')
+                            window.location.reload();
                         }).catch(function(err){
                         tempTip.okWindow(err,'确定')
+                        window.location.reload();
                     })
                 },
                 checkAll(e) {

+ 1 - 1
resources/views/store/handInStorage/receive.blade.php

@@ -169,7 +169,7 @@
                 ensure(){
                     let error = {};
                     if (!this.info.asnno)error.asnno = ["ASN号必填"];
-                    if (this.info.asnno && this.info.asnno.length!==13)error.asnno = ["无效ASN号"];
+                    if (this.info.asnno && this.info.asnno.indexOf('ASN')===-1)error.asnno = ["无效ASN号"];
                     if (JSON.stringify(error)!=='{}'){this.errors = error;return;}
                     if (!this.info.customerid||!this.info.asntype){this.info.customerid='';this.info.asntype='';}
                     this.checkAsnOperation();

+ 1 - 0
routes/web.php

@@ -689,6 +689,7 @@ Route::group(['middleware'=>'auth'],function ($route){
             Route::get('blindReceive/{id}','InventoryAccountController@enterBlindReceive');
             Route::post('baseOnBlindReceive','InventoryAccountController@baseOnBlindReceive');
             Route::post('batchStockByLocation','InventoryAccountController@batchStockByLocation');
+            Route::post('outToLineUpdateInventoryMissions','InventoryAccountController@outToLineUpdateInventoryMissions');
         });
         /** 库存比对 */
         Route::group(['prefix'=>'inventoryCompare'],function(){

+ 3 - 3
syncProject.sh

@@ -16,8 +16,8 @@ expect {
 }
 expect eof"
 done
-npm run dev
-php artisan migrate
-composer update
+sudo npm run dev
+sudo php artisan migrate
+sudo composer update