Просмотр исходного кода

Merge branch 'Haozi' of ssh://was.baoshi56.com:10022/var/git/bswas

LD 5 лет назад
Родитель
Сommit
b958bf523e
2 измененных файлов с 18 добавлено и 29 удалено
  1. 0 5
      app/Imports/InventoryCompareImport.php
  2. 18 24
      app/Services/InventoryCompareService.php

+ 0 - 5
app/Imports/InventoryCompareImport.php

@@ -75,7 +75,6 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
                 'custom_location'=>$customLocation,
             ];
             $this->ownerArr = array_merge($this->ownerArr,[$owners['custom_location']=>$owners]);
-
         }
         $skuAndWarehouseArr=[];
         $inventoryCompares=[];
@@ -96,7 +95,6 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
                     $sum++;
                     continue;
                 }
-
                 if ($this->ownerArr["$row[$customLocationName]"]['owner_id']){
                     $this->owner_id=$this->ownerArr["$row[$customLocationName]"]['owner_id'];
                     $this->ownerCode=$this->ownerArr["$row[$customLocationName]"]['owner_code'];
@@ -157,13 +155,10 @@ class InventoryCompareImport implements ToCollection, WithHeadingRow, WithMultip
                 array_push($inventoryCompares,$inventoryCompare);
                 $sum++;
             }
-//            if(empty($exception)){
                 /** @var InventoryCompareService $service */
                 $service = app('InventoryCompareService');
                 $inventoryCompare= $service->createInventoryCompares($inventoryCompares);
                 if (!$inventoryCompare) array_push($exception, ['创建库存对比失败!']);
-//            }
-
         }
         Cache::put('exception', $exception, 86400);
     }

+ 18 - 24
app/Services/InventoryCompareService.php

@@ -19,28 +19,6 @@ use Ramsey\Uuid\Uuid;
 class InventoryCompareService
 {
     static private $missionCode;
-//    private function conditionQuery($SKU,$LotAtt05,$descr_c){
-//        $sql='select * from (select result.*,rownum rn from (';
-//        $sql.=' select customer.Descr_C as 货主,storeStatus.CUSTOMERID 客户,storeStatus.LocationID 库位, sku.SKU 产品编码, sku.ALTERNATE_SKU1 产品条码, ';
-//        $sql.=' sku.Descr_C 商品名称, lot.LotAtt05 属性仓, lot.LotAtt08 质量状态, lot.LotAtt02 失效日期, storeStatus.ADDTIME 创建时间, ';
-//        $sql.=' lot.LotAtt04 批号 ';
-//        $sql.=' , storeStatus.QTY 在库数量, storeStatus.QtyAllocated 占用数量,count(1) over () as sum from ';
-//        $sql.=' INV_LOT_LOC_ID storeStatus';
-//        $sql.=' left join BAS_Customer customer on customer.CustomerID=storeStatus.CUSTOMERID ';
-//        $sql.=' left join BAS_SKU sku on sku.SKU=storeStatus.SKU and sku.CUSTOMERID=storeStatus.CUSTOMERID ';
-//        $sql.=' left join INV_LOT_ATT lot on lot.LOTNUM = storeStatus.LOTNUM AND lot.CUSTOMERID = storeStatus.CUSTOMERID ';
-//        $sql.=' group by storeStatus.LocationID,customer.Descr_C,sku.SKU,sku.ALTERNATE_SKU1 ';
-//        $sql.=' ,sku.Descr_C,lot.LotAtt05,lot.LotAtt08,lot.LotAtt02,lot.LotAtt04 ';
-//        $sql.=' , storeStatus.QTY, storeStatus.QtyAllocated,storeStatus.CUSTOMERID,storeStatus.ADDTIME  ';
-//        $sql.=' )result where 1=1 ';
-//        if ($SKU)$sql.=" and 产品编码 like '".$SKU."' ";
-//        if ($LotAtt05)$sql .=" and 属性仓 like '".$LotAtt05."' ";
-//        if ($descr_c)$sql.=" and 货主 = '".$descr_c."' ";
-//        $sql.=' )  ';
-//        return DB::connection('oracle')->select($sql);
-//    }
-
-
     public function getCreatingMissionCode($ownerName=''){
         if(self::$missionCode)return self::$missionCode;
         $sequence=Cache::get('InventoryCompareMissionSequence');
@@ -106,9 +84,11 @@ 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']);
+            $wmsInventoryCompareYjz=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->where('质量状态','YJZ')->first();
+            $unknownQualityStatus=$query->where('属性仓',$custom_location)->where('产品编码',$sku)->whereNotIn('质量状态',['DJ','CC','ZP','YJZ']);
             if (!$wmsInventoryCompareZp&&!$wmsInventoryCompareCc&&!$wmsInventoryCompareDj&&$unknownQualityStatus->isEmpty()){
                 $this->createInventoryCompare_underImport($sku, $custom_location, $amount, $owner_id,$owner_name);
+                continue;
             }
             $creatingMissionCode = $this->getCreatingMissionCode($owner_name);
             $commodityId=Commodity::where('sku',$sku)->where('owner_id',$owner_id)->value('id');
@@ -140,7 +120,21 @@ class InventoryCompareService
                 ];
                 array_push($wasInventoryCompares,$wasInventoryCompareCC);
             }
-            if($unknownQualityStatus->isNotEmpty())return null;
+            if ($wmsInventoryCompareYjz){
+                $wasInventoryCompareYjz=[
+                    'owner_id'=>$owner_id,
+                    'commodity_id'=>$commodityId,
+                    'mission_code'=>$creatingMissionCode,
+                    'custom_location'=>$custom_location,
+                    'created_at'=>Carbon::now()->format('Y-m-d H:i:s'),
+                    'quality'=>'有价值',
+                    'amount_in_sys'=>$wmsInventoryCompareYjz['在库数量'],
+                    'amount_in_compare' =>$amount,
+                    'differ' =>$amount-($wmsInventoryCompareYjz['在库数量']??0),
+                ];
+                array_push($wasInventoryCompares,$wasInventoryCompareYjz);
+            }
+            if($unknownQualityStatus->isNotEmpty())continue;
         }
         $inventoryCompares=DB::table('inventory_compares')->insert($wasInventoryCompares);
         if (!$inventoryCompares)return null;