|
|
@@ -17,54 +17,75 @@ class AndroidInventoryService
|
|
|
//未盘任务列表
|
|
|
public function getUnInventoryTaskList($taskId)
|
|
|
{
|
|
|
- return InventoryAccountMission::query()
|
|
|
+ $stock_status = InventoryAccount::query()->where('id', $taskId)->value('status');
|
|
|
+ $query = InventoryAccountMission::query()
|
|
|
->select('location')->selectRaw("count(*) count")
|
|
|
->where('inventory_account_id', $taskId)
|
|
|
- ->where('checked', '否')->groupBy("location")
|
|
|
- ->get();
|
|
|
+ ->groupBy("location");
|
|
|
+ if ($stock_status=='待盘点'||$stock_status=='盘点中'){ //初盘
|
|
|
+ return $query->where('checked', '否')->get();
|
|
|
+ }elseif ($stock_status=='复盘中'){ //复盘
|
|
|
+ return $query->where('checked', '是')->whereNotNull('difference_amount')->get();
|
|
|
+ }else{
|
|
|
+ return collect();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
//根据员工姓名获取当日盘点行数
|
|
|
public function getStaffSameDayInvCount(): int
|
|
|
{
|
|
|
- return Sign::query()
|
|
|
+ return Sign::query()
|
|
|
->where('signable_type', 'inventory_account_missions')
|
|
|
->where('field', '盘点人')
|
|
|
->where('created_at', 'like', Carbon::now()->toDateString() . '%')
|
|
|
->where('mark', Auth::user()['name'])->count();
|
|
|
}
|
|
|
- public function getLocInvPro($taskId,$location): array
|
|
|
+
|
|
|
+ public function getLocInvPro($taskId, $location)
|
|
|
{
|
|
|
- $ins=InventoryAccountMission::query()
|
|
|
- ->where('inventory_account_id',$taskId)
|
|
|
- ->where('location',$location)->get();
|
|
|
+ $ins = InventoryAccountMission::query()
|
|
|
+ ->where('inventory_account_id', $taskId)
|
|
|
+ ->where('location', $location)->get();
|
|
|
//库位盘点任务总条数
|
|
|
- $total=$ins->count();
|
|
|
+ $total = $ins->count();
|
|
|
//已盘数
|
|
|
- $invCount=$ins->where('checked','<>','否')->count();
|
|
|
- return ['total'=>$total,'invCount'=>$invCount];
|
|
|
+ $invCount = $ins->where('checked', '<>', '否')->count();
|
|
|
+ if ($total == 0 && $invCount == 0) {
|
|
|
+ return 0;//库位不存在
|
|
|
+ } else {
|
|
|
+ return ['total' => $total, 'invCount' => $invCount];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
//根据盘点任务号,库位,条码 查询指定盘点任务
|
|
|
- public function getInventoryDetail($taskId,$location,$barcode)
|
|
|
+ public function getInventoryDetail($taskId, $location, $barcode)
|
|
|
{
|
|
|
- return Cache::remember($taskId.'_'.$location.'_'.$barcode, 300, function ()use($taskId,$location,$barcode) {
|
|
|
- return InventoryAccountMission::with(['commodity.barcodes','stockInventoryPersons'])
|
|
|
- ->whereHas('commodity',function($query)use($barcode){
|
|
|
- $query->whereHas('barcodes',function($sql)use($barcode){
|
|
|
- $sql->where('code','=',$barcode);
|
|
|
- });
|
|
|
- })->where('location',$location)
|
|
|
- ->where('inventory_account_id',$taskId)
|
|
|
- ->where('checked','否')
|
|
|
- ->first();
|
|
|
- });
|
|
|
+ $stock_status = InventoryAccount::query()->where('id', $taskId)->value('status');
|
|
|
+ $query = InventoryAccountMission::with(['commodity.barcodes', 'stockInventoryPersons'])
|
|
|
+ ->whereHas('commodity', function ($query) use ($barcode) {
|
|
|
+ $query->whereHas('barcodes', function ($sql) use ($barcode) {
|
|
|
+ $sql->where('code', '=', $barcode);
|
|
|
+ });
|
|
|
+ })->where('location', $location)
|
|
|
+ ->where('inventory_account_id', $taskId);
|
|
|
+ if ($stock_status == '待盘点' || $stock_status == '盘点中') { //初盘
|
|
|
+ return $query->where('checked', '否')->first();
|
|
|
+ } elseif ($stock_status == '复盘中') { //复盘
|
|
|
+ return $query->where('checked', '是')->whereNotNull('difference_amount')->first();
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
public function skipInventory($inventoryDetailId)
|
|
|
{
|
|
|
- $inventoryAccountMission=InventoryAccountMission::query()->find($inventoryDetailId);
|
|
|
- if (!$inventoryAccountMission)return null;
|
|
|
- $inventoryAccountMission->checked='跳过';
|
|
|
+ $inventoryAccountMission = InventoryAccountMission::query()->find($inventoryDetailId);
|
|
|
+ if (!$inventoryAccountMission) return null;
|
|
|
+ $inventoryAccountMission->checked = '跳过';
|
|
|
$inventoryAccountMission->update();
|
|
|
- if ($inventoryAccountMission->checked=='跳过'){
|
|
|
+ if ($inventoryAccountMission->checked == '跳过') {
|
|
|
/** @var InventoryAccountService $inventoryService */
|
|
|
$inventoryService = app('inventoryAccountService');
|
|
|
$inventoryService->updateInventory($inventoryAccountMission->inventory_account_id);
|