Преглед на файлове

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

 Conflicts:
	app/Http/Controllers/TestController.php
	app/Services/StoreService.php
LD преди 5 години
родител
ревизия
9950c65edd
променени са 6 файла, в които са добавени 95 реда и са изтрити 8 реда
  1. 7 3
      .gitlab-ci.yml
  2. 1 0
      app/Http/Controllers/TestController.php
  3. 7 5
      app/Services/StoreService.php
  4. 25 0
      ci/executeCommand.sh
  5. 21 0
      ci/judgePush.sh
  6. 34 0
      resources/scripts/git-hooks/pre-push

+ 7 - 3
.gitlab-ci.yml

@@ -17,9 +17,7 @@ build:
   tags:
     - testwas
   script:
-#    - echo "build ....."
-    - path=`pwd`
-    - echo "$path"
+    - echo "build ....."
 
 test:
   stage: test
@@ -27,6 +25,8 @@ test:
     - testwas
   script:
     - echo "run test....."
+    - path=`pwd`
+#    - sudo bash ci/judgePush.sh $path
 #    - vendor/bin/phpunit --testsuite=Unit
 
 deploy:
@@ -35,3 +35,7 @@ deploy:
     - testwas
   script:
     - echo "deploy ...."
+#    - cd /var/www/testwas && git pull
+#    - sudo bash ci/executeCommand.sh $path
+#  only:
+#    - master

+ 1 - 0
app/Http/Controllers/TestController.php

@@ -36,6 +36,7 @@ use App\Jobs\BatchTaskJob;
 use App\Jobs\DeleteRepetitionSkuItem;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
+use App\Jobs\StoreCreateInstantBill;
 use App\Jobs\ResetInstantBill;
 use App\Jobs\StoreCreateInstantBill;
 use App\LaborReport;

+ 7 - 5
app/Services/StoreService.php

@@ -87,7 +87,7 @@ class StoreService
         if (count($asnHerders)<1) return;
         $last_time = $asnHerders->first()['edittime'];
         $last_records = $asnHerders->where('edittime', $last_time);
-        $this->createStore($asnHerders);
+        $this->createStore($asnHerders,"update");
         $this->updateStore($asnHerders);
         $this->createStoreRejected($asnHerders);
         $this->deleteCacheKey($update_set, $update_keys);
@@ -95,7 +95,7 @@ class StoreService
         $this->setAsnLastSyncAt($updated_at, $last_time);
     }
 
-    public function createStore($asnHerders)
+    public function createStore($asnHerders,$isUpdate=null)
     {
         if (!$asnHerders) return null;
         /** @var OwnerService $ownerService */
@@ -126,7 +126,7 @@ class StoreService
         /** @var RejectedBillService $rejectedBillService */
         $rejectedBillService = app(RejectedBillService::class);
         $rejectedBillService->syncLoadedStatusByAsnHerder($asnHerders);
-        $this->pushJob($asnHerders);
+        if (!$isUpdate)$this->pushJob($asnHerders);
         unset($asnHerders, $owners_code_map, $warehouses_code_map);
     }
 
@@ -244,8 +244,10 @@ class StoreService
     }
 
     public function pushJob($asnHerders){
-        $stores = Store::query()->with(["storeItems"])->where('status','已入库')->whereIn('asn_code', data_get($asnHerders,'*.asnno'))->get();
-        dispatch(new StoreCreateInstantBill($stores));
+        $stores = Store::query()->with(["storeItems"])->where('status','已入库')->whereIn('asn_code',data_get($asnHerders,'*.asnno'))->get();
+        $stores->each(function($store){
+            dispatch(new StoreCreateInstantBill($store));
+        });
     }
 
     public function insert($params)

+ 25 - 0
ci/executeCommand.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+
+
+update_path=/var/www/update
+#重启队列
+#sudo bash runServes.sh
+
+
+
+# shellcheck disable=SC2045
+# shellcheck disable=SC2006
+for file in `ls $update_path`
+     do
+        if [ "composer.json" = "$file" ]; then
+            sudo composer install
+        elif [ "package.json" == "$file" ]; then
+            sudo yarn install
+        elif [ "resources" == "$file" ]; then
+            sudo yarn run prod
+            else
+                echo "11"
+        fi
+    done
+
+

+ 21 - 0
ci/judgePush.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#push 变动文件
+update_path=/var/www/update
+#git 文件路径
+path=$1
+# shellcheck disable=SC2164
+cd "$path"
+#将项目文件中3分钟之前改动的文件存到update文件
+# shellcheck disable=SC2038
+# shellcheck disable=SC2185
+find -mmin -3 |xargs -I {} cp {} -u -t $update_path
+
+# shellcheck disable=SC2045
+# shellcheck disable=SC2006
+for file in `ls $update_path`
+     do
+        if [ "composer.json" = "$file" ]; then
+            sudo composer install
+        fi
+    done

+ 34 - 0
resources/scripts/git-hooks/pre-push

@@ -0,0 +1,34 @@
+#!/usr/bin/php
+
+<?php
+
+// 获取应用名称
+$projectName = basename(getcwd());
+
+echo PHP_EOL;
+echo '开始执行单元测试...'.PHP_EOL;
+exec('phpunit Unit', $output, $returnCode);
+exec('phpunit Services', $output, $returnCode);
+exec('phpunit Feature', $output, $returnCode);
+exec('phpunit Inventory', $output, $returnCode);
+exec('phpunit OrderIssues', $output, $returnCode);
+exec('phpunit StoreService', $output, $returnCode);
+
+printf("测试结果: ", $projectName);
+echo PHP_EOL;
+
+if ($returnCode !== 0) {
+//    printf(" ( %s ) %s%2\$s", json_encode($output), PHP_EOL);
+    print_r("<pre>");
+    print_r($output);
+    printf(" x 测试不通过,Git Push 已终止!\n");
+
+    // 停止 Git
+    exit(1);
+}
+
+echo ' √ 测试通过!'.PHP_EOL;
+echo PHP_EOL;
+
+// 继续执行 Git
+exit(0);