|
|
@@ -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');
|