|
|
@@ -66,7 +66,7 @@ class InventoryCompareService
|
|
|
$inventoryCompare->quality='正品';
|
|
|
$inventoryCompare->amount_in_sys=0;
|
|
|
$inventoryCompare->amount_in_compare=$amount;
|
|
|
- $inventoryCompare->differ=0-$amount;
|
|
|
+ $inventoryCompare->differ=$amount-0;
|
|
|
$inventoryCompare->mission_code= $creatingMissionCode;
|
|
|
$inventoryCompare->save();
|
|
|
Controller::logS(__METHOD__,"修改库存对比任务号__".__FUNCTION__,json_encode($creatingMissionCode));
|
|
|
@@ -106,10 +106,10 @@ class InventoryCompareService
|
|
|
$wmsInventoryCompareZp=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->where('质量状态','ZP')->first();
|
|
|
$wmsInventoryCompareCc=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->where('质量状态','CC')->first();
|
|
|
$wmsInventoryCompareDj=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->where('质量状态','DJ')->first();
|
|
|
- $unknownQualityStatus=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->whereNotIn('质量状态',['DJ','CC','ZP']);
|
|
|
- if (!$wmsInventoryCompareZp&&!$wmsInventoryCompareCc&&!$wmsInventoryCompareDj&&$unknownQualityStatus->isEmpty()){
|
|
|
- $inventoryCompare=$this->createInventoryCompare_underImport($sku, $custom_location, $amount, $owner_id,$owner_name);
|
|
|
- }
|
|
|
+ //$unknownQualityStatus=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->whereNotIn('质量状态',['DJ','CC','ZP']);
|
|
|
+ //if (!$wmsInventoryCompareZp&&!$wmsInventoryCompareCc&&!$wmsInventoryCompareDj&&$unknownQualityStatus->isEmpty()){
|
|
|
+ //$inventoryCompare=$this->createInventoryCompare_underImport($sku, $custom_location, $amount, $owner_id,$owner_name);
|
|
|
+ //}
|
|
|
$creatingMissionCode = $this->getCreatingMissionCode($owner_name);
|
|
|
$commodityId=Commodity::where('sku',$sku)->where('owner_id',$owner_id)->value('id');
|
|
|
if ($wmsInventoryCompareZp||$wmsInventoryCompareDj) {
|
|
|
@@ -120,9 +120,9 @@ class InventoryCompareService
|
|
|
'custom_location' => $custom_location,
|
|
|
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
|
'quality' => '正品',
|
|
|
- 'amount_in_sys' => ($wmsInventoryCompareZp['在库数量'] ?? 0) + ($wmsInventoryCompareDj['在库数量'] ?? 0),
|
|
|
+ 'amount_in_sys' => ($wmsInventoryCompareZp['在库数量'] ?? 0)+($wmsInventoryCompareDj['在库数量'] ?? 0),
|
|
|
'amount_in_compare' => $amount,
|
|
|
- 'differ' => $amount - ($wmsInventoryCompareZp['在库数量'] ?? 0) - ($wmsInventoryCompareDj['在库数量'] ?? 0),
|
|
|
+ 'differ' => $amount-(($wmsInventoryCompareZp['在库数量'] ?? 0) + ($wmsInventoryCompareDj['在库数量'] ?? 0)),
|
|
|
];
|
|
|
array_push($wasInventoryCompares,$wasInventoryCompareZP);
|
|
|
}
|
|
|
@@ -135,12 +135,12 @@ class InventoryCompareService
|
|
|
'created_at'=>Carbon::now()->format('Y-m-d H:i:s'),
|
|
|
'quality'=>'次品',
|
|
|
'amount_in_sys'=>$wmsInventoryCompareCc['在库数量'],
|
|
|
- 'amount_in_compare' =>'',
|
|
|
- 'differ' =>'',
|
|
|
+ 'amount_in_compare' =>$amount,
|
|
|
+ 'differ' =>$amount-($wmsInventoryCompareCc['在库数量']??0),
|
|
|
];
|
|
|
array_push($wasInventoryCompares,$wasInventoryCompareCC);
|
|
|
}
|
|
|
- if($unknownQualityStatus->isNotEmpty())return null;
|
|
|
+ //if($unknownQualityStatus->isNotEmpty())return null;
|
|
|
}
|
|
|
$inventoryCompares=DB::table('inventory_compares')->insert($wasInventoryCompares);
|
|
|
if (!$inventoryCompares)return null;
|
|
|
@@ -187,70 +187,10 @@ class InventoryCompareService
|
|
|
->selectRaw('commodities.name commodity_name,commodities.sku commodity_sku')
|
|
|
->leftJoin('commodity_barcodes','commodity_barcodes.commodity_id','commodities.id')
|
|
|
->selectRaw('commodity_barcodes.code commodity_barcode_code')
|
|
|
+ ->groupBy('owner_name','commodity_sku','inventory_compares.custom_location','inventory_compares.quality')
|
|
|
->sql();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// public function createInventoryCompare($SKU,$LotAtt05,$amount,$ownerId){
|
|
|
-// $ownerName=Owner::where('id',$ownerId)->value('name');
|
|
|
-// $request=[
|
|
|
-// '产品编码'=>$SKU,
|
|
|
-// '属性仓'=>$LotAtt05,
|
|
|
-// '数量'=>$amount,
|
|
|
-// '货主'=>$ownerId,
|
|
|
-// ];
|
|
|
-// $wmsInventories=$this->conditionQuery($SKU,$LotAtt05,$ownerName);
|
|
|
-// if (count($wmsInventories)==0) return null;
|
|
|
-// $zpAmount=0;
|
|
|
-// $ccAmount=0;
|
|
|
-// $amountTotal=0;
|
|
|
-// foreach ($wmsInventories as $wmsInventory){
|
|
|
-// $commodity=Commodity::query()->firstOrCreate([
|
|
|
-// 'owner_id'=>$ownerId,
|
|
|
-// 'sku'=>$wmsInventory->产品编码,
|
|
|
-// 'name'=>$wmsInventory->商品名称,
|
|
|
-// ]);
|
|
|
-// Controller::logS(__METHOD__,"根据wms产品编码和货主查询或创建商品信息__".__FUNCTION__,json_encode($wmsInventory));
|
|
|
-// $commodity->newBarcode($wmsInventory->产品条码);
|
|
|
-// Controller::logS(__METHOD__,"根据wms产品条码和商品id查询或创建商品条码信息__".__FUNCTION__,json_encode($wmsInventory));
|
|
|
-// $amountTotal=$amountTotal+$wmsInventory->在库数量;
|
|
|
-// if ($wmsInventory->质量状态=='DJ'||$wmsInventory->质量状态=='ZP'){
|
|
|
-// $zpAmount=$zpAmount+$wmsInventory->在库数量;
|
|
|
-// }
|
|
|
-// if ($wmsInventory->质量状态=='CC'){
|
|
|
-// $ccAmount=$ccAmount+$wmsInventory->在库数量;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $unknownStatusAmount=$amountTotal-$ccAmount-$zpAmount;
|
|
|
-// $creatingMissionCode = $this->getCreatingMissionCode($ownerName);
|
|
|
-// $commodityId=Commodity::where('sku',$SKU)->where('owner_id',$ownerId)->value('id');
|
|
|
-// $inventoryCompare=new InventoryCompare();
|
|
|
-// $inventoryCompare->owner_id=$ownerId;
|
|
|
-// $inventoryCompare->commodity_id=$commodityId;
|
|
|
-// $inventoryCompare->mission_code=Uuid::uuid1();
|
|
|
-// $inventoryCompare->custom_location=$LotAtt05;
|
|
|
-// $inventoryCompare->created_at=Carbon::now()->format('Y-m-d H:i:s');
|
|
|
-// $inventoryCompare->mission_code=$creatingMissionCode;
|
|
|
-// if ($zpAmount!=0){
|
|
|
-// $inventoryCompare->quality='正品';
|
|
|
-// $inventoryCompare->amount_in_sys=$zpAmount;
|
|
|
-// $inventoryCompare->amount_in_compare=$amount;
|
|
|
-// $inventoryCompare->differ=$zpAmount-$amount;
|
|
|
-// }
|
|
|
-// if ($ccAmount!=0){
|
|
|
-// $inventoryCompare->quality='次品';
|
|
|
-// $inventoryCompare['amount_in_sys']=$ccAmount;
|
|
|
-// }
|
|
|
-// if ($unknownStatusAmount!=0){
|
|
|
-// $inventoryCompare->quality='未知';
|
|
|
-// $inventoryCompare->amount_in_sys=$unknownStatusAmount;
|
|
|
-// }
|
|
|
-// $inventoryCompare->save();
|
|
|
-// Controller::logS(__METHOD__,"创建库存对比__".__FUNCTION__,json_encode($request));
|
|
|
-// Controller::logS(__METHOD__,"修改库存对比任务号__".__FUNCTION__,json_encode($creatingMissionCode));
|
|
|
-// return $inventoryCompare;
|
|
|
-// }
|
|
|
-//
|
|
|
public function batchUpdateItself($column, array $params)
|
|
|
{
|
|
|
return app(BatchUpdateService::class)->batchUpdateItself('inventory_compares', $column, $params);
|