Explorar o código

库存管理--修改盘点记录中的质量状态

haozi %!s(int64=5) %!d(string=hai) anos
pai
achega
20ea70452f

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

@@ -150,4 +150,17 @@ class InventoryAccountController extends Controller
         if (!$owners)return ['success'=>false,'data'=>'同步货主失败!'];
         return ['success'=>true,'data'=>$owners];
     }
+    public function 修改质量状态(Request $request){
+        if (!Gate::allows('库存管理-盘点')){return redirect(url('/')); }
+        $id=$request->input('id');
+        $location=$request->location;
+        $sku=$request->sku;
+        $quality=$request->quality;
+        $ownerCode=$request->ownerCode;
+        $inventoryAccountMission=app('inventoryAccountService')->修改质量状态($id,$location,$sku,$quality,$ownerCode);
+        $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        if ($inventoryAccountMission==null) return ['success'=>false,'data'=>'WMS中不存在该条记录!'];
+        return ['success'=>true,'data'=>'质量状态修改成功'];
+
+    }
 }

+ 2 - 0
app/OracleInvLotAtt.php

@@ -11,8 +11,10 @@ use Illuminate\Database\Eloquent\Model;
  */
 class OracleInvLotAtt extends Model
 {
+
     protected $connection="oracle";
     protected $table="INV_LOT_ATT";
+    public $timestamps=false;
     /*
      * column: LotAtt05 属性仓
      *         LotAtt08 质量状态

+ 23 - 1
app/Services/InventoryAccountService.php

@@ -9,6 +9,7 @@ use App\InventoryAccount;
 use App\InventoryAccountMission;
 use App\OraccleBasCustomer;
 use App\OracleActTransactionLog;
+use App\OracleInvLotAtt;
 use App\OracleInvLotLocId;
 use App\Owner;
 use App\Services\common\QueryService;
@@ -164,6 +165,12 @@ class InventoryAccountService
             Controller::logS(__METHOD__,"根据wms产品编码和货主查询或创建商品信息__".__FUNCTION__,json_encode($wmsInventory));
             $commodity->newBarcode($wmsInventory->产品条码);
             Controller::logS(__METHOD__,"根据wms产品条码和商品id查询或创建商品条码信息__".__FUNCTION__,json_encode($wmsInventory));
+            if($wmsInventory->质量状态=='ZP') $quality='正品';
+            if ($wmsInventory->质量状态=='CC') $quality='残次';
+            if ($wmsInventory->质量状态=='XS') $quality='箱损';
+            if ($wmsInventory->质量状态=='JS') $quality='机损';
+            if ($wmsInventory->质量状态=='DJ') $quality='冻结';
+            if ($wmsInventory->质量状态=='FKT') $quality='封口贴';
             $inventoryAccountMission=[
             'commodity_id'=>$commodity->id,
             'inventory_account_id'=>$inventoryAccountId,
@@ -173,7 +180,7 @@ class InventoryAccountService
             'stored_at'=>$wmsInventory->入库日期,
             'batch_number'=>$wmsInventory->批号,
             'erp_type_position'=>$wmsInventory->属性仓,
-            'quality'=>$wmsInventory->质量状态,
+            'quality'=>$quality,
             'stored_amount'=>$wmsInventory->在库数量,
             'occupied_amount'=>$wmsInventory->占用数量,
             'valid_amount'=>$wmsInventory->在库数量-$wmsInventory->占用数量,
@@ -236,4 +243,19 @@ class InventoryAccountService
         if (!$inventoryAccountMission) return null;
         return  $inventoryAccountMission;
     }
+    public function 修改质量状态($id,$location,$sku,$quality,$ownerCode){
+        $lotnum=OracleInvLotLocId::query()->where('locationid',$location)->where('customerid',$ownerCode)->where('sku',$sku)->value('lotnum');
+        if (!$lotnum) return null;
+        $oracleInvLotAtt=OracleInvLotAtt::query()->where('lotnum',$lotnum)->where('sku',$sku)->where('customerid',$ownerCode)->first();
+        if(!isset($oracleInvLotAtt))return null;
+        if ($quality=='正品')$status='ZP';
+        if ($quality=='残次')$status='CC';
+        $oracleInvLotAtt=OracleInvLotAtt::query()->where('lotnum',$lotnum)->where('sku',$sku)->where('customerid',$ownerCode)->update([
+            'lotatt08'=>$status,
+        ]);
+        $inventoryAccountMission=InventoryAccountMission::query()->find($id);
+        $inventoryAccountMission->quality=$quality;
+        $inventoryAccountMission=$inventoryAccountMission->update();
+        if ($oracleInvLotAtt>0&&$inventoryAccountMission)return $inventoryAccountMission;
+    }
 }

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

@@ -98,6 +98,7 @@
                 <th>库位</th>
                 <th>产品名</th>
                 <th>产品条码</th>
+                <th>产品编码</th>
                 <th>生产日期</th>
                 <th>失效日期</th>
                 <th>入库日期</th>
@@ -116,6 +117,7 @@
                 <td>@{{ inventoryMission.location }}</td>
                 <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.name }}</td>
                 <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</td>
+                <td v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.sku }}</td>
                 <td >@{{ inventoryMission.produced_at }}</td>
                 <td >@{{ inventoryMission.valid_at }}</td>
                 <td >@{{ inventoryMission.stored_at }}</td>
@@ -123,10 +125,10 @@
                 <td >@{{ inventoryMission.erp_type_position }}</td>
                 <td >
                     <span v-if="listMode">@{{ inventoryMission.quality }}</span>
-                    <select name="quality" id="quality" v-else>
-                        <option :value="inventoryMission.quality">@{{ inventoryMission.quality }}</option>
-                        <option value="ZP">ZP</option>
-                        <option value="CC">CC</option>
+                    <select v-else class="form-control-sm" name="quality" id="quality"  v-model="inventoryMission.quality"
+                            @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
+                        <option value="正品">正品</option>
+                        <option value="残次">残次</option>
                     </select>
                 </td>
                 <td >@{{ inventoryMission.stored_amount }}</td>
@@ -149,11 +151,12 @@
                             <span class="mr-3 text-nowrap">
                                 <span class="font-weight-bold">产品条码:</span>
                                 <span v-if="listMode">@{{ inventoryMission.quality }}</span>
-                    <select name="quality" id="quality" v-else>
-                        <option :value="inventoryMission.quality">@{{ inventoryMission.quality }}</option>
-                        <option value="ZP">ZP</option>
-                        <option value="CC">CC</option>
-                    </select>
+                        <select v-else class="form-control-sm" name="quality" id="quality"
+                                v-model="inventoryMission.quality"
+                                @change="updateQuality(inventoryMission.id,inventoryMission.location,inventoryMission.commodity.sku,inventoryMission.quality,inventory.owner.code)">
+                        <option value="正品">正品</option>
+                        <option value="残次">残次</option>
+                         </select>
                             </span>
                             <span class="mr-3 text-nowrap"><span class="font-weight-bold">产品条码:</span><span style="color:#af7651" v-if="inventoryMission.commodity">@{{ inventoryMission.commodity.barcode }}</span></span>
                             <div v-if="inventory.status=='复盘中'">
@@ -316,6 +319,21 @@
                         tempTip.show('结束初盘失败!'+'网络错误'+err);
                     })
                 },
+                updateQuality(id,location,sku,quality,ownerCode){
+                    let url='{{url('inventory/修改质量状态')}}';
+                    axios.post(url,{id:id,location:location,sku:sku,quality:quality,ownerCode:ownerCode}).then(function (response) {
+                        if (!response.data.success){
+                            tempTip.setDuration(3000);
+                            tempTip.show('修改质量状态失败!'+'   '+response.data.data);
+                        }else {
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess('修改质量状态成功!');
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(2000);
+                        tempTip.show('修改质量状态失败!'+'网络错误'+err);
+                    })
+                },
             }
         });
     </script>

+ 2 - 0
routes/web.php

@@ -302,6 +302,8 @@ Route::group(['prefix'=>'inventory'],function (){
 
     //同步货主
     Route::get('syncOwners','InventoryAccountController@syncOwners');
+
+    Route::post('修改质量状态','InventoryAccountController@修改质量状态');
     //库存盘点
     Route::get('stockInventory/mission','InventoryAccountController@mission');
     //创建盘点任务