Browse Source

Merge branch 'master' into yang

ANG YU 4 years ago
parent
commit
869fe08f2a
100 changed files with 1040 additions and 1741 deletions
  1. 21 9
      .gitlab-ci.yml
  2. 1 1
      app/Demand.php
  3. 2 4
      app/Events/ClockinEvent.php
  4. 2 5
      app/Events/ClockoutEvent.php
  5. 47 0
      app/Events/GitPushedEvent.php
  6. 0 1
      app/Events/SendEmailEvent.php
  7. 3 3
      app/Filters/DischargeTaskFilters.php
  8. 2 2
      app/Filters/LogFilters.php
  9. 10 10
      app/Filters/OrderIssueFilters.php
  10. 3 3
      app/Filters/OrderPackageFilters.php
  11. 4 4
      app/Filters/OrderTrackFilters.php
  12. 10 15
      app/Filters/OwnerMaterialFilters.php
  13. 2 2
      app/Filters/OwnerSundryFeeDetailFilters.php
  14. 0 1
      app/Http/Controllers/DemandController.php
  15. 10 1
      app/Http/Controllers/LaborReportController.php
  16. 1 1
      app/Http/Controllers/OwnerMaterialController.php
  17. 8 1
      app/Http/Controllers/PersonnelController.php
  18. 1 1
      app/Http/Controllers/StationController.php
  19. 68 35
      app/Http/Controllers/StorageController.php
  20. 65 497
      app/Http/Controllers/TestController.php
  21. 6 4
      app/Http/Controllers/UserController.php
  22. 1 1
      app/Http/Controllers/UserLaborController.php
  23. 30 0
      app/Http/Controllers/api/email/SendEmailsController.php
  24. 2 2
      app/Http/Controllers/api/thirdPart/haiq/LightController.php
  25. 1 1
      app/Http/Controllers/api/thirdPart/haiq/StorageController.php
  26. 1 0
      app/Jobs/ProcurementEnquiry.php
  27. 47 0
      app/Listeners/GitPushedSendEmailListener.php
  28. 1 1
      app/Listeners/ModelChangedListener.php
  29. 1 1
      app/Listeners/SendEmailListener.php
  30. 10 5
      app/Notifications/SendEmailNotification.php
  31. 5 0
      app/Providers/EventServiceProvider.php
  32. 5 0
      app/Providers/RouteServiceProvider.php
  33. 1 1
      app/Services/BatchService.php
  34. 47 5
      app/Services/CacheShelfService.php
  35. 11 4
      app/Services/DemandService.php
  36. 1 1
      app/Services/ForeignHaiRoboticsService.php
  37. 1 1
      app/Services/InventoryCompareService.php
  38. 1 1
      app/Services/InventoryDailyLogService.php
  39. 6 0
      app/Services/LaborReportService.php
  40. 10 8
      app/Services/MaterialBoxService.php
  41. 1 0
      app/Services/MenuService.php
  42. 7 1
      app/Services/OrderService.php
  43. 1 1
      app/Services/OwnerBillReportService.php
  44. 1 1
      app/Services/OwnerFeeDetailService.php
  45. 7 7
      app/Services/OwnerReportService.php
  46. 24 15
      app/Services/OwnerService.php
  47. 3 3
      app/Services/PackageService.php
  48. 1 1
      app/Services/ProcessService.php
  49. 3 3
      app/Services/ProcessStatisticService.php
  50. 1 1
      app/Services/RejectedService.php
  51. 3 3
      app/Services/RoleService.php
  52. 3 5
      app/Services/StationService.php
  53. 16 4
      app/Services/StationTaskCommodityService.php
  54. 2 1
      app/Services/StationTaskMaterialBoxService.php
  55. 299 87
      app/Services/StorageService.php
  56. 2 1
      app/Services/StoreCheckingReceiveService.php
  57. 28 0
      app/Services/StoreItemService.php
  58. 2 2
      app/Services/StoreService.php
  59. 12 0
      app/Services/UserService.php
  60. 3 3
      app/StationTaskCommodity.php
  61. 1 2
      app/StationTaskMaterialBox.php
  62. 8 8
      ci/.envCi
  63. 1 1
      ci/executeCommand.sh
  64. 3 0
      ci/installEnv.sh
  65. 9 0
      ci/sendEmail.sh
  66. 1 0
      composer.json
  67. 149 57
      composer.lock
  68. 1 0
      config/stores.php
  69. 0 45
      database/migrations/2019_10_30_184920_create_authorities_table.php
  70. 0 1
      database/migrations/2019_11_22_094145_create_carriers_table.php
  71. 0 3
      database/migrations/2019_11_22_094253_create_cities_table.php
  72. 0 33
      database/migrations/2019_11_28_115444_add_data_authorities.php
  73. 0 2
      database/migrations/2019_11_28_152321_create_waybill_audit_logs_table.php
  74. 0 105
      database/migrations/2019_12_03_174626_add_data_authorities_waybill.php
  75. 0 47
      database/migrations/2019_12_30_114648_add_weigh_authority.php
  76. 0 1
      database/migrations/2020_01_02_172739_change_waybill_price_model_field.php
  77. 0 1
      database/migrations/2020_02_19_145227_create_w_m_s_reflect_package_table.php
  78. 0 44
      database/migrations/2020_03_05_080123_add_weigh_excepted_authority.php
  79. 0 43
      database/migrations/2020_03_09_132100_add_store_transfer_authority.php
  80. 0 49
      database/migrations/2020_03_25_182324_add_process_authority.php
  81. 0 13
      database/migrations/2020_03_30_112202_drop_commodity_barcode_column_to_barcode_table.php
  82. 0 44
      database/migrations/2020_04_09_111337_add_tutorial_authority.php
  83. 0 4
      database/migrations/2020_04_09_111540_change_tutorial_table.php
  84. 0 57
      database/migrations/2020_05_14_091440_add_personnel_authority.php
  85. 0 1
      database/migrations/2020_05_22_172739_create_labor_companies_table.php
  86. 0 49
      database/migrations/2020_05_25_091228_add_labor_company_authority.php
  87. 0 11
      database/migrations/2020_05_25_093853_change_waybills_table.php
  88. 0 37
      database/migrations/2020_05_29_144440_add_inventory_authority.php
  89. 0 38
      database/migrations/2020_06_04_162259_add_order_authority.php
  90. 0 10
      database/migrations/2020_06_12_093011_change_authorities_table.php
  91. 0 3
      database/migrations/2020_06_12_135840_create_custom_fields_table.php
  92. 0 11
      database/migrations/2020_06_16_171741_create_upload_files_table.php
  93. 0 37
      database/migrations/2020_06_16_173559_add_authorrities_waybillmanagement_freigt.php
  94. 0 37
      database/migrations/2020_06_18_145606_add_authorities_order_update_table.php
  95. 0 1
      database/migrations/2020_06_24_145928_add_storage_public_link.php
  96. 0 36
      database/migrations/2020_06_28_162934_add_authorrities_personal_duty_check_type.php
  97. 0 58
      database/migrations/2020_06_30_111337_change_auth_hr_verifies.php
  98. 0 9
      database/migrations/2020_07_02_135957_add_authority_table_process_rollback.php
  99. 0 48
      database/migrations/2020_07_06_111337_change_auth_order_index.php
  100. 0 24
      database/migrations/2020_07_06_160500_create_operator_logs_table_and_add_authority_and_change_processes_column_status.php

+ 21 - 9
.gitlab-ci.yml

@@ -1,18 +1,19 @@
 stages:
   - build
   - test
+  - test_failed
   - deploy
 
 cache:
   paths:
     - vendor/
+    - node_modules/
 
 before_script:
 #配置环境
 #  - sudo cp ci/.envCi .env
 #  - sudo bash ci/installEnv.sh
 
-
 build:
   stage: build
   tags:
@@ -26,9 +27,20 @@ test:
     - testwas
   script:
     - echo "run test....."
-    - path=`pwd`
-    - sudo bash ci/judgePush.sh $path
-#    - vendor/bin/phpunit --testsuite=Unit
+#    - path=`pwd`
+#    - sudo bash ci/judgePush.sh $path
+#    - php vendor/bin/phpunit --testsuite=Services
+#    - sudo bash ci/sendEmail.sh
+
+test_failed:
+  stage: test_failed
+  tags:
+    - testwas
+  script:
+    - echo "run test_failed"
+#    - email=`sudo git log --pretty=format:"%ce" -1`
+#    - sudo bash ci/sendEmail.sh $email
+  when: on_failure
 
 deploy:
   stage: deploy
@@ -36,8 +48,8 @@ deploy:
     - testwas
   script:
     - echo "deploy ...."
-    - cd /var/www/bswas_test && sudo git config --global credential.helper store
-    - sudo git pull
-    - sudo bash ci/executeCommand.sh
-  only:
-    - master
+#    - cd /var/www/bswas_test && sudo git config --global credential.helper store
+#    - sudo git pull
+#    - sudo bash ci/executeCommand.sh
+#  only:
+#    - master

+ 1 - 1
app/Demand.php

@@ -63,7 +63,7 @@ class Demand extends Model
      */
     public function saveFile($fileName,$fileSuffix)
     {
-        return UploadFile::query()->create(['table_name' => $this->getTable(), 'table_id' => $this['id'], 'url' => '/files/issue/'.$fileName, 'type' => $fileSuffix]);
+        return UploadFile::query()->create(['table_name' => $this->getTable(), 'table_id' => $this['id'], 'url' => '/files/'.$fileName, 'type' => $fileSuffix]);
     }
 
     /**

+ 2 - 4
app/Events/ClockinEvent.php

@@ -17,8 +17,7 @@ class ClockinEvent implements ShouldBroadcastNow
 
     /**
      * Create a new event instance.
-     *
-     * @param UserDutyCheck $userDutyCheck
+     * @param LaborReport $laborReport
      */
     public function __construct(LaborReport $laborReport)
     {
@@ -28,9 +27,8 @@ class ClockinEvent implements ShouldBroadcastNow
     /**
      * Get the channels the event should broadcast on.
      *
-     * @return \Illuminate\Broadcasting\Channel|array
      */
-    public function broadcastOn()
+    public function broadcastOn(): Channel
     {
         return new Channel($this->laborReport->userWorkgroup->token);
     }

+ 2 - 5
app/Events/ClockoutEvent.php

@@ -18,8 +18,7 @@ class ClockoutEvent implements ShouldBroadcast
 
     /**
      * Create a new event instance.
-     *
-     * @param UserDutyCheck $userDutyCheck
+     * @param LaborReport $laborReport
      */
     public function __construct(LaborReport $laborReport)
     {
@@ -28,10 +27,8 @@ class ClockoutEvent implements ShouldBroadcast
 
     /**
      * Get the channels the event should broadcast on.
-     *
-     * @return \Illuminate\Broadcasting\Channel|array
      */
-    public function broadcastOn()
+    public function broadcastOn(): Channel
     {
         return new Channel($this->laborReport->userWorkgroup->token);
     }

+ 47 - 0
app/Events/GitPushedEvent.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Events;
+
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class GitPushedEvent
+{
+    use Dispatchable, InteractsWithSockets, SerializesModels;
+
+    public $email;
+    /**
+     * [
+     *  'title'=>''
+     *  'description'='信息'
+     * ]
+     */
+    public $load;
+
+    /**
+     * GitPushedEvent constructor.
+     * @param $email
+     * @param $load
+     */
+    public function __construct($email, $load)
+    {
+        $this->email = $email;
+        $this->load = $load;
+    }
+
+
+    /**
+     * Get the channels the event should broadcast on.
+     *
+     * @return \Illuminate\Broadcasting\Channel|array
+     */
+    public function broadcastOn()
+    {
+        return new PrivateChannel('channel-name');
+    }
+}

+ 0 - 1
app/Events/SendEmailEvent.php

@@ -14,7 +14,6 @@ class SendEmailEvent
 {
     use Dispatchable, InteractsWithSockets, SerializesModels;
 
-
     /**
      * SendEmailEvent constructor.
      */

+ 3 - 3
app/Filters/DischargeTaskFilters.php

@@ -11,7 +11,7 @@ class DischargeTaskFilters
     protected $request;
     protected $queryBuilder;
     protected $filters = [
-        'owner_id', 'created_at_start', 'created_at_end', 'numbers', 'status', 'type', 'income_remark','facilitator_id','created_range'
+        'owners', 'created_at_start', 'created_at_end', 'numbers', 'status', 'type', 'income_remark','facilitators','created_range','owners'
     ];
     protected $array_filter;
     protected $params = [];
@@ -60,7 +60,7 @@ class DischargeTaskFilters
         return $query;
     }
 
-    public function owner_id($owner_id)
+    public function owners($owner_id)
     {
         $this->queryBuilder->where('discharge_tasks.owner_id',$owner_id);
     }
@@ -99,7 +99,7 @@ class DischargeTaskFilters
         $this->queryBuilder->whereIn('discharge_tasks.id',$ids);
     }
 
-    public function facilitator_id($facilitator_id)
+    public function facilitators($facilitator_id)
     {
         $this->searchWay($this->queryBuilder,$facilitator_id,'discharge_tasks.facilitator_id');
     }

+ 2 - 2
app/Filters/LogFilters.php

@@ -12,7 +12,7 @@ class LogFilters
 {
     protected $request;
     protected $queryBuilder;
-    protected $filters = ['username', 'type', 'description',
+    protected $filters = ['name', 'type', 'description',
         'created_at_start', 'created_at_end', 'is_exception', 'class', 'method'];
     protected $array_filter;
 
@@ -111,7 +111,7 @@ class LogFilters
         $this->queryBuilder->whereIn("type", $types);
     }
 
-    private function username($username)
+    private function name($username)
     {
         $this->queryBuilder->whereIn("id_user", function ($query) use ($username) {
             return $query->from("users")->select("id")->where("name", 'like', $username . '%');

+ 10 - 10
app/Filters/OrderIssueFilters.php

@@ -36,7 +36,7 @@ class OrderIssueFilters
         'log_content',
         'is_imported',
         'is_new_rejecting',
-        'logistic_id',
+        'logistic',
         'custom_code',
         'hiddenTag',
         'client_code',
@@ -50,7 +50,7 @@ class OrderIssueFilters
         'id',
         'created_at_start',
         'created_at_end',
-        'order_issue_type_id',
+        'order_issue_type',
         'logistic_indemnity_money',
         'baoshi_indemnity_money',
         'rejectingStatus',
@@ -59,12 +59,12 @@ class OrderIssueFilters
         'settlement_at_end',
         'sendOrderClientCode',
         'sendOrderLogisticNumber',
-        'user_workgroups',
+        'workgroups',
         'shop_name',
         'finance_confirm',
         'logistic_number_return',
         'final_status',
-        'user_owner_group_id',
+        'user_owner_group',
         'archive_at_start',
         'archive_at_end',
     ];
@@ -172,8 +172,8 @@ class OrderIssueFilters
 
         $user = Auth::user();
         $owner_ids = $user ? app('UserService')->getPermittingOwnerIds($user) : [];
-        if (isset($this->params['owner_id'])){
-            $this->searchWay($this->getOrderQuery(),$this->params['owner_id'],'orders.owner_id');
+        if (isset($this->params['owner'])){
+            $this->searchWay($this->getOrderQuery(),$this->params['owner'],'orders.owner_id');
         } else{
             $this->getOrderQuery()->whereIn('owner_id',$owner_ids);
         }
@@ -249,7 +249,7 @@ class OrderIssueFilters
         $this->queryBuilder->where('order_issues.is_new_rejecting',$is_new_rejecting);
     }
 
-    public function logistic_id($logistic_id)
+    public function logistic($logistic_id)
     {
         $this->getOrderQuery()->where('orders.logistic_id',$logistic_id);
     }
@@ -324,7 +324,7 @@ class OrderIssueFilters
         $this->queryBuilder->where('order_issues.created_at', '<=', $created_at_end . " 23:59:59");
     }
 
-    public function order_issue_type_id($order_issue_type_id)
+    public function order_issue_type($order_issue_type_id)
     {
         $this->searchWay($this->queryBuilder,$order_issue_type_id,'order_issues.order_issue_type_id');
     }
@@ -370,7 +370,7 @@ class OrderIssueFilters
         $this->searchWay($this->queryBuilder,$sendOrderClientCode,'order_issues.second_client_no');
     }
 
-    public function user_workgroups($user_work_groups)
+    public function workgroups($user_work_groups)
     {
         if(is_string($user_work_groups)){
             $user_work_groups = explode(',', $user_work_groups);
@@ -431,7 +431,7 @@ class OrderIssueFilters
         $this->queryBuilder->where('order_issues.finance_confirm',$finance_confirm);
     }
 
-    public function user_owner_group_id($user_owner_group_id)
+    public function user_owner_group($user_owner_group_id)
     {
         $this->queryBuilder->where('order_issues.user_owner_group_id',$user_owner_group_id);
     }

+ 3 - 3
app/Filters/OrderPackageFilters.php

@@ -15,7 +15,7 @@ class OrderPackageFilters
     protected $request;
     protected $queryBuilder;
     protected $filters = ['logistic_number', 'status', 'received_at_start',
-        'received_at_end', 'is_weighed', 'logistic_id', 'owner_id', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date','has_transfer_status'];
+        'received_at_end', 'is_weighed', 'logistic', 'owner', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date','has_transfer_status'];
 
     public function __construct(Request $request)
     {
@@ -82,7 +82,7 @@ class OrderPackageFilters
         }
     }
 
-    private function logistic_id($logistic_id)
+    private function logistic($logistic_id)
     {
         $logistic_ids = array_filter(preg_split('/[,, ]+/is', $logistic_id));
         $this->queryBuilder->whereIn('order_id', function ($query) use ($logistic_ids) {
@@ -90,7 +90,7 @@ class OrderPackageFilters
         });
     }
 
-    private function owner_id($owner_id)
+    private function owner($owner_id)
     {
         $owner_ids = array_filter(preg_split('/[,, ]+/is', $owner_id));
         $this->queryBuilder->whereIn('owner_id', $owner_ids);

+ 4 - 4
app/Filters/OrderTrackFilters.php

@@ -24,7 +24,7 @@ class OrderTrackFilters
     protected $queryBuilder;
     protected $params = [];
     protected $filters = ['client_code', 'order_client_code_wms',
-        'logistic_id', 'client', 'web_order_number', 'sku', 'logistic_number','remark','ids',
+        'logistic', 'client', 'web_order_number', 'sku', 'logistic_number','remark','ids',
         'start_at', 'end_at', 'start_planning_sent_at', 'end_planning_sent_at'];
     protected $array_filter;
 
@@ -65,8 +65,8 @@ class OrderTrackFilters
         // 货主
         $user = Auth::user();
         $owner_ids = $user ? app(UserService::class)->getPermittingOwnerIds($user) : [];
-        if (isset($this->params['owner_id'])) {
-            $ownerIds = explode(",", $this->params['owner_id']);
+        if (isset($this->params['owner'])) {
+            $ownerIds = explode(",", $this->params['owner']);
             $owner_ids = array_intersect($owner_ids, $ownerIds);
         }
         $this->ownerId($owner_ids);
@@ -110,7 +110,7 @@ class OrderTrackFilters
         $this->searchWay($this->queryBuilder,$order_client_code_wms,'order_trackings.order_client_code_wms');
     }
 
-    public function logistic_id($logistic_id)
+    public function logistic($logistic_id)
     {
         $this->queryBuilder->where('order_trackings.logistic_id',$logistic_id);
     }

+ 10 - 15
app/Filters/OwnerMaterialFilters.php

@@ -15,10 +15,12 @@ class OwnerMaterialFilters
     protected $queryBuilder;
     protected $materialQuery;
     protected $userQuery;
-    protected $filters = [];
+    protected $filters = [
+        'owner_id','material_code','created_at_start','created_at_end','special','specification'
+    ];
     protected $array_filter;
     protected $params = [
-        'owner_id','material_code','user_name','created_at_start','created_at_end','special'
+        'owner_id','material_code','created_at_start','created_at_end','special','specification'
     ];
 
     public function __construct(Request $request)
@@ -64,13 +66,6 @@ class OwnerMaterialFilters
         return $this->materialQuery;
     }
 
-    private function getUserQuery():Builder
-    {
-        if(!$this->userQuery)
-            $this->userQuery = User::query()->selectRaw('id');
-        return $this->userQuery;
-    }
-
     public function owner_Id($owner_id)
     {
         $this->searchWay($this->queryBuilder,$owner_id,'owner_id');
@@ -78,12 +73,8 @@ class OwnerMaterialFilters
 
     public function material_code($material_code)
     {
-        $this->getMaterialQuery()->where('code','like',"{$material_code}%");
-    }
-
-    public function user_name($user_name)
-    {
-        $this->getUserQuery()->where('name','like',"{$user_name}%");
+//        $this->getMaterialQuery()->where('code','like',"{$material_code}%");
+        $this->queryBuilder->where('material_code','like',"{$material_code}%");
     }
 
     public function created_at_start($created_at)
@@ -100,6 +91,10 @@ class OwnerMaterialFilters
     {
         $this->queryBuilder->where('special','like',"{$special}%");
     }
+    public function specification($specification)
+    {
+        $this->queryBuilder->where('specification','like',"{$specification}%");
+    }
 
     public function afterApply()
     {

+ 2 - 2
app/Filters/OwnerSundryFeeDetailFilters.php

@@ -14,7 +14,7 @@ class OwnerSundryFeeDetailFilters
 {
     protected $request;
     protected $queryBuilder;
-    protected $filters = ['owner_id'];
+    protected $filters = ['owners'];
 
     public function __construct(Request $request)
     {
@@ -34,7 +34,7 @@ class OwnerSundryFeeDetailFilters
     }
 
 
-    private function owner_id($owner_id)
+    private function owners($owner_id)
     {
         if (strpos($owner_id, ',') || strpos($owner_id, ',') || strpos($owner_id, ' ')) {
             $arr = array_filter(preg_split('/[,, ]+/is', $owner_id));

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

@@ -32,7 +32,6 @@ class DemandController extends Controller
         if(!isset($user))return redirect('/');
 
         $demands = Demand::query()->with(['initiator', 'handle', 'uploadFile', 'processes.user'])->filter($filters)->orderByDesc('demands.id')->paginate($request['paginate'] ?? 50);
-
         return view('demand.search.index', compact('demands'));
     }
 

+ 10 - 1
app/Http/Controllers/LaborReportController.php

@@ -273,7 +273,16 @@ class LaborReportController extends Controller
     function recycle(Request $request){
         if(!Gate::allows('人事管理-临时工报表-删除')){ return redirect('/');  }
         $paginateParams=$request->input();
-        $laborReports=LaborReport::query()->with(['user','userDutyCheck','userWorkgroup','laborCompany'])->orderByDesc('id')->onlyTrashed()->paginate($request->paginate??50);
+        $laborReports=app('laborReportService')->recycleQuery($request->input());
+        foreach ($laborReports as $laborReport){
+            if (!$laborReport->user_duty_check_id)continue;
+                $userDutyCheck=UserDutyCheck::query()
+                ->where('user_id',$laborReport->user_id)
+                ->where('id','>',$laborReport->user_duty_check_id)
+                ->orderBy('id')
+                ->limit(1)->first();
+            if ($userDutyCheck && $userDutyCheck->type=='登出')$laborReport->exit_at=$userDutyCheck->checked_at;
+        }
         return view('personnel.laborReport.recycle',compact('laborReports','paginateParams'));
     }
 

+ 1 - 1
app/Http/Controllers/OwnerMaterialController.php

@@ -23,7 +23,7 @@ class OwnerMaterialController extends Controller
     public function index(Request $request,OwnerMaterialFilters $filters)
     {
         $this->gate('项目耗材');
-        $ownerMaterials = OwnerMaterial::query()->with(['owner','material','initiator','file'])->orderByDesc('id')->filter($filters)->paginate($request['paginate'] ?? 50);
+        $ownerMaterials = OwnerMaterial::query()->filter($filters)->with(['owner','material','initiator','file'])->orderByDesc('id')->paginate($request['paginate'] ?? 50);
         $owners = app(OwnerService::class)->getAuthorizedOwners();
         $materials = Material::all();
         return view('/maintenance/ownerMaterial/index',compact('ownerMaterials','owners','materials'));

+ 8 - 1
app/Http/Controllers/PersonnelController.php

@@ -121,7 +121,14 @@ class PersonnelController extends Controller
                 $userDutyCheckBefore=UserDutyCheck::query()->where('user_id',$user_id)->where('checked_at','like',$checkedAtDate.'%')->orderBy('id','desc')->first();
 //                if ($userDutyCheckBefore['type']=='登入'&&$userDutyCheck->type=='登入')return ['result'=>true,'data'=>'已存在进场记录!'];
                 if ($laborReport && $userDutyCheck->type=='登入')return ['result'=>true,'data'=>'已存在进场记录!'];
-                if ($userDutyCheckBefore['type']=='登出'&&$userDutyCheck->type=='登出')return ['result'=>true,'data'=>'已存在出场记录!'];
+                if ($userDutyCheckBefore['type']=='登出'&&$userDutyCheck->type=='登出'){
+                    LaborReportStatus::query()->updateOrCreate([
+                        'labor_report_id'=>$laborReport->id,
+                        'status'=>'已退场',
+                        'created_at'=>$userDutyCheckBefore->checked_at,
+                    ]);
+                    return ['result'=>true,'data'=>'已存在出场记录!'];
+                }
                 $userDutyCheck->save();
                 app('LogService')->log(__METHOD__,"录入补卡".__FUNCTION__,json_encode($userDutyCheck),Auth::user()['id']);
                 $errorMessage=$this->makeOrUpdateLaborReport($userDutyCheck,$remark);

+ 1 - 1
app/Http/Controllers/StationController.php

@@ -57,7 +57,7 @@ class StationController extends Controller
 //        $stationTypeBinMonitor = StationTypeBinMonitor::query()->where("station_id",$station->id)->first();
         $station->loadMissing([
             "stationTasks_today.stationTaskCommodities.commodity.barcodes",
-            "stationTasks_today.stationTaskCommodities.materialBox",
+            "stationTasks_today.stationTaskCommodities.stationTaskMaterialBox",
             "stationTasks_today.stationTaskBatches.batch.owner",
             "stationTasks_today.stationTaskMaterialBoxes.materialBox",
             "stationTypeBinMonitor",

+ 68 - 35
app/Http/Controllers/StorageController.php

@@ -2,9 +2,12 @@
 
 namespace App\Http\Controllers;
 
+use App\Commodity;
 use App\CommodityMaterialBoxModel;
 use App\Components\AsyncResponse;
 use App\MaterialBox;
+use App\MaterialBoxModel;
+use App\Owner;
 use App\Station;
 use App\StationTask;
 use App\StationTaskMaterialBox;
@@ -29,8 +32,8 @@ class StorageController extends Controller
         //check info
         if (!$asn || !$ide || !$barCode || !$amount)$this->error("信息不完整");
         $fromLocation = app("MaterialBoxService")->getBoxLocation($ide);
-        if (!$fromLocation)$this->error("海柔无此库位信息");
-        $box = MaterialBox::query()->select("id")->where("code",$ide)->first();
+        if (!$fromLocation)$this->error("WAS无此库位信息");
+        $box = MaterialBox::query()->where("code",$ide)->first();
         if (!$box)$this->error("WAS无此料箱");
 
         //库存相关信息
@@ -46,17 +49,16 @@ class StorageController extends Controller
             });
         })->first();
         //get flux
-        $asns = app("StorageService")->getFluxTask($asn,$barCode,$amount);
-        if (!$asns)$this->error("ASN不存在或上架数量与入库数量不符");
+        $tasks = app("StorageService")->getFluxTask($asn,$barCode,$amount);
+        if (!$tasks)$this->error("该单无上架任务或不存在");
         //此处嵌套三层事务 以最高层级为准
         DB::beginTransaction(); //总体事务 回滚WAS错误操作
         try{
-            //if (!app("StorageService")->putWareHousing($fromLocation,$box->id))$this->error("错误库位或库位已被下达任务");
             //库存记录
             if (!app("StorageService")->enterWarehouse($station->id, $box->id, $item->commodity_id ?? null, $amount, $box->material_box_model_id))$this->error("库存异常");
 
-            DB::connection("oracle")->transaction(function ()use($asns,$ide){ //单体嵌套事务 回滚FLUX失败任务
-                foreach ($asns as $asn)if (!app("StorageService")->fluxPA($asn,$ide,(int)$asn->fmqty)){
+            DB::connection("oracle")->transaction(function ()use($tasks,$ide){ //单体嵌套事务 回滚FLUX失败任务
+                foreach ($tasks as $task)if (!app("StorageService")->fluxPA($task,$ide)){
                     DB::connection("oracle")->rollBack();
                     $this->error("FLUX上架失败");
                 };
@@ -86,24 +88,16 @@ class StorageController extends Controller
      */
     public function checkMaximum()
     {
-        $item = StoreItem::query()->whereHas("store",function (Builder $query){
-            $query->where("asn_code",request("asn"));
-        })->whereHas("commodity",function (Builder $query){
-            $query->whereHas("barcodes",function (Builder $query){
-                $query->where("code",request("barCode"));
-            });
-        })->first();
-        if (!$item)$this->error("WAS无此单据记录");
+        $item = app("StoreItemService")->getMaxAvailableDetail(request("asn"),request("barCode"));
+        if (!$item)$this->error("无此单据记录");
         $models = CommodityMaterialBoxModel::query()->where("commodity_id",$item->commodity_id)->get();
         if ($models->count()==0)$this->error("商品首入,请使用缓存架空箱入库");
         foreach ($models as $model){
-            $box = Storage::query()->select(DB::raw("MAX({$model->maximum}-amount) need"),"material_box_id")
-                ->whereHas("materialBox",function (Builder $query)use($model){
-                $query->where("material_box_model_id",$model->material_box_model_id);
-            })->where("commodity_id",$model->commodity_id)->where("amount","<",$model->maximum)
-                ->where("status",0)->first();
-            $box->commodity_id = $item->commodity_id;
-            if ($box)$this->success($box);
+            $result = app("StorageService")->getHalfBoxLocation($model,$item,request("asn"));
+            if ($result){
+                $result->maximum = $model->maximum-$result->amount;
+                $this->success($result);
+            }
         }
         $this->success(["need"=>$models[0]->maximum,"material_box_model_id"=>$models[0]->material_box_model_id,"commodity_id"=>$item->commodity_id]);
     }
@@ -142,26 +136,32 @@ class StorageController extends Controller
         //获取目标库位
         $station = app("StationService")->getMirrorMappingLocation(request("station"));
         if (!$station)$this->error("未知库位");
+        $occupyTask = StationTaskMaterialBox::query()->where("station_id",$station->id)->whereNotIn("status",["完成","取消"])->first();
+        if ($occupyTask)$this->error("库位存在任务未处理完成");
+        $amount = app("StorageService")->checkPutAmount(request("asn"),request("barCode"));
+        if ($amount<request("amount"))$this->error("待上架数量不足,最大可上数量为{$amount}");
         //获取料箱
         if ($boxId && !app("MaterialBoxService")->checkUsableBox($boxId)){
+            $blacklist = [$boxId];
             $boxId = null;
             //料箱存在且不可用
             $models = CommodityMaterialBoxModel::query()->where("commodity_id",request("commodity_id"))->get();
+            $item = app("StoreItemService")->getMaxAvailableDetail(request("asn"),request("barCode"));
+            if (!$item)$this->error("无此单据记录");
             foreach ($models as $model){
-                Storage::query()->select("material_box_id")
-                    ->whereHas("materialBox",function (Builder $query)use($model){
-                        $query->where("material_box_model_id",$model->material_box_model_id);
-                    })->where("commodity_id",$model->commodity_id)->where("amount","<",$model->maximum)
-                    ->where("status",0)->where(DB::raw("{$model->maximum}-amount"),">=",request("amount"))->get()->each(function ($box)use(&$boxId){
-                        if (app("MaterialBoxService")->checkUsableBox($box->id)){
-                            $boxId = $box->id;
-                            return false;
-                        }
-                        return true;
-                    });
-                if ($boxId)break;
+                //料箱不可用寻找新料箱
+                $result = app("StorageService")->getHalfBoxLocation($model,$item,request("asn"),$blacklist);
+                while ($result){
+                    //料箱可用并且数量符合本次半箱数量 跳出
+                    if (app("MaterialBoxService")->checkUsableBox($result->material_box_id)
+                        && $model->maximum-$result->amount>=request("amount")){$boxId = $result->material_box_id;break;}
+                    else $blacklist[] = $result->material_box_id;
+                    //否则黑名单此料箱继续查找 直至料箱为空
+                    $result = app("StorageService")->getHalfBoxLocation($model,$item,request("asn"),$blacklist);
+                }
             }
         }
+        //料箱不存在且该商品有过入库记录 拿取空箱
         if (!$boxId){
             if (!$modelId){
                 $box = null;
@@ -174,7 +174,6 @@ class StorageController extends Controller
             if (!$box)$this->error("无可用料箱");
             $boxId = $box->id;
         }
-        if (!$boxId || !app("MaterialBoxService")->checkUsableBox($boxId))$this->error("无可用料箱");
         //发起取箱任务
         DB::beginTransaction();
         $collection = new Collection();
@@ -228,4 +227,38 @@ class StorageController extends Controller
             ->where("commodity_id",$task->commodity_id)->update(["maximum"=>$maximum]);
         $this->success("校正成功");
     }
+
+    public function syncStorage()
+    {
+        ini_set('max_execution_time', 0);
+        $model = MaterialBoxModel::query()->create([
+            "code" => "common"
+        ]);
+        $sql = <<<sql
+    select * from INV_LOT_LOC_ID where traceid = '*' and locationid like 'IDE%'
+sql;
+        DB::beginTransaction();
+        foreach (DB::connection("oracle")->select(DB::raw($sql)) as $inv){
+            $materialBox = MaterialBox::query()->firstOrCreate(["code"=>$inv->locationid],[
+                "code" => $inv->locationid,
+                "material_box_model_id"=>$model
+            ]);
+            $owner = Owner::query()->firstOrCreate([
+                "code" => $inv->customerid
+            ],[
+                "code" => $inv->customerid,
+                "name" => $inv->customerid,
+            ]);
+            $commodity = Commodity::query()->where("owner_id",$owner->id)->where("sku",$inv->sku)->first();
+            $s = \App\Storage::query()->where("material_box_id",$materialBox->id)
+                ->where("commodity_id",$commodity->id)->first();
+            if (!$s)\App\Storage::query()->create([
+                "material_box_id" => $materialBox->id,
+                "commodity_id" => $commodity->id,
+                "amount" => $inv->qty,
+            ]);else $s->update(["amount" => $inv->qty]);
+        }
+        DB::commit();
+        $this->success();
+    }
 }

+ 65 - 497
app/Http/Controllers/TestController.php

@@ -6,6 +6,7 @@ use App\Authority;
 use App\Batch;
 use App\City;
 use App\Commodity;
+use App\CommodityMaterialBoxModel;
 use App\Components\AsyncResponse;
 use App\Console\Commands\CreateOwnerAreaReport;
 use App\Console\Commands\CreateOwnerBillReport;
@@ -25,6 +26,7 @@ use App\Jobs\LogisticAliJiSuSync;
 use App\Jobs\LogisticYTOSync;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
+use App\Jobs\ProcurementCheckConfirmInform;
 use App\Jobs\StoreCreateInstantBill;
 use App\Jobs\ResetInstantBill;
 use App\LaborReport;
@@ -54,6 +56,7 @@ use App\ProcurementDeliverie;
 use App\ProcurementQuotation;
 use App\ProcurementTotalBill;
 use App\RejectedBillItem;
+use App\Services\AuthorityService;
 use App\Services\BatchService;
 use App\Services\CacheService;
 use App\Services\CacheShelfService;
@@ -61,6 +64,7 @@ use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
 use App\Services\common\DataHandlerService;
 use App\Services\common\QueryService;
+use App\Services\ConfigurationService;
 use App\Services\DeliveryAppointmentService;
 use App\Services\DocWaveHeaderService;
 use App\Services\FeatureService;
@@ -68,10 +72,6 @@ use App\Services\InventoryCompareService;
 use App\Services\LogisticService;
 use App\Services\LogisticZopService;
 use App\Services\LogService;
-use App\Services\NewOrderCountingRecordService;
-use App\Services\MaterialBoxService;
-use App\Services\MenuService;
-use App\Services\OracleDocAsnHerderService;
 use App\Services\OracleDOCOrderHeaderService;
 use App\Services\OracleDocWaveDetailService;
 use App\Services\OrderCommodityService;
@@ -92,6 +92,7 @@ use App\Services\StoreService;
 use App\Services\SupplierService;
 use App\Station;
 use App\StationTask;
+use App\StationTaskCommodity;
 use App\StationTaskMaterialBox;
 use App\Store;
 use App\StationTaskBatch;
@@ -128,6 +129,7 @@ use Overtrue\LaravelPinyin\Facades\Pinyin;
 use PhpMyAdmin\Server\Status\Data;
 use PhpParser\Node\Stmt\DeclareDeclare;
 use Ramsey\Collection\Collection;
+use Symfony\Component\ErrorHandler\Error\FatalError;
 use Zttp\Zttp;
 
 class TestController extends Controller
@@ -145,114 +147,21 @@ class TestController extends Controller
     {
         return call_user_func([$this, $method], $request);
     }
+    public function test1(){
+        $aa = [1,2,3];
 
-    public function test1()
-    {
-        $box = app("MaterialBoxService")->getAnEmptyBox([],$modelId);
-        return view("test");
-    }
-
-    public function test2()
-    {
-        ini_set('max_execution_time',-1);
-        $myfile = @fopen(base_path()."/database/data/menus.data", "a+");
-        foreach (Menu::query()->get() as $menu){
-            $txt = "INSERT INTO menus";
-            $columns = "(";
-            $values = "(";
-            foreach ($menu->toArray() as $col=>$val){
-                $columns .= "{$col},";
-                if (!$val) $values .= "null,";
-                else $values .= "'{$val}',";
-            }
-            $columns = mb_substr($columns,0,-1);
-            $values = mb_substr($values,0,-1);
-            $txt .= "{$columns}) VALUES{$values});\r\n";
-            fwrite($myfile, $txt);
-        }
-        fclose($myfile);
-
-        $myfile = @fopen(base_path()."/database/data/authorities.data", "a+");
-        foreach (Authority::query()->get() as $authority){
-            $txt = "INSERT INTO authorities";
-            $columns = "(";
-            $values = "(";
-            foreach ($authority->toArray() as $col=>$val){
-                $columns .= "{$col},";
-                if (!$val) $values .= "null,";
-                else $values .= "'{$val}',";
-            }
-            $columns = mb_substr($columns,0,-1);
-            $values = mb_substr($values,0,-1);
-            $txt .= "{$columns}) VALUES{$values});\r\n";
-            fwrite($myfile, $txt);
-        }
-        fclose($myfile);
-        dd("OK");
+        $this->test1(...$aa);
     }
     public function test()
     {
-        DB::beginTransaction();
-        try{
-            $mapping = [
-                "43"=>[647],"40"=>[648,649,650],
-                "612"=>[651],"210"=>[652],"274" => [653],"314"=>[654],"327"=>[655],
-                "329"=>[656],"344"=>[657],"159"=>[646,658],"164"=>[660],
-                "206"=>[661,662],"205"=>[663,664,665],"272"=>[666,667],
-                "320"=>[668],"220"=>[669],"223"=>[670],"616"=>[671],"310"=>[672],
-                "348"=>[673],"538"=>[674,675],"311"=>[676],"16"=>[677],"133"=>[678,679],
-                "488"=>[688],"557"=>[689,690]
-            ];
-            foreach ($mapping as $key=>$arr){
-                $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$key]);
-                if (!$roles)continue;
-                foreach ($roles as $role){
-                    foreach ($arr as $aId){
-                        DB::insert(DB::raw("INSERT INTO authority_role(id_authority,id_role) values (?,?)"),[$aId,$role->id_role]);
-                    }
-                }
-            }
-            $re = [
-                257=>1,
-                258=>2,
-                259=>3,
-                260=>4,
-                261=>5,
-                262=>6,
-                263=>7,
-                264=>8,
-                265=>9,
-                266=>10,
-                312=>11,
-                313=>12,
-                510=>13,
-            ];
-            foreach ($re as $key=>$val){
-                $usId = $val;
-                $auId = $key;
-                $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
-                if (!$roles)continue;
-                foreach ($roles as $role){
-                    DB::insert(DB::raw("INSERT INTO role_user_work_group(role_id,user_work_group_id) values (?,?)"),[$role->id_role,$usId]);
-                }
-            }
-            $owners = Authority::query()->where("name","like","\_%")->get();
-            foreach ($owners as $owner){
-                $owId = ltrim($owner->name,"_");
-                $auId = $owner->id;
-                $roles = DB::select(DB::raw("SELECT * FROM authority_role WHERE id_authority = ?"),[$auId]);
-                if (!$roles)continue;
-                foreach ($roles as $role){
-                    DB::insert(DB::raw("INSERT INTO owner_role(owner_id,role_id) values (?,?)"),[$owId,$role->id_role]);
-                }
-            }
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            dd($e->getMessage());
-        }
-        app("MenuService")->setMenu();//重建菜单缓存
-        app("AuthorityService")->removeAllAuth();//移除所有用户权限缓存,这将在用户下次访问时重新建立
+        app('StorageService')->clearTask(['HAIB2-02-02','HAIB2-01-01']);
+        dd();
+        ini_set('max_execution_time', 0);
+        $orders = Order::query()->whereBetween("wms_edittime",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
+            ->whereNotIn("id",OwnerFeeDetail::query()->select("outer_id")
+                ->whereBetween("worked_at",["2021-06-01 00:00:00","2021-06-30 23:59:59"])
+                ->where("outer_table_name","orders"))->get();
+        foreach ($orders->chunk(50) as $or)dispatch(new OrderCreateInstantBill($or));
     }
     public function orderCreateBill()
     {
@@ -261,6 +170,23 @@ class TestController extends Controller
         $ser->createInstantBill($order);
         dd("order create bill success");
     }
+    function mp(){
+        $stationTaskCommodities=StationTaskCommodity::query()->where('id',19942)->get();
+        StationTaskCommodity::query()
+            ->whereIn('id',data_get($stationTaskCommodities,'*.id')??[])
+            ->update(['status'=>'完成']);
+        $stationTaskMaterialBoxes=StationTaskMaterialBox::query()
+            ->whereIn('id', data_get($stationTaskCommodities, '*.station_task_material_box_id') ?? [])
+            ->get('material_box_id');
+        $storages= \App\Storage::query()->whereIn('commodity_id',data_get($stationTaskCommodities,'*.commodity_id')??[])
+            ->whereIn('material_box_id',data_get($stationTaskMaterialBoxes,'*.material_box_id')??[])
+            ->get();
+        foreach($storages as $storage){
+            $amountReducing=$stationTaskCommodities->where('material_box_id',$storage['material_box_id'])->first()['amount']??0;
+            $storage['amount']-=$amountReducing;
+            $storage->update();
+        }
+    }
 
     public function supplementMarchOwnerReport()
     {
@@ -305,29 +231,6 @@ class TestController extends Controller
         app('BatchService')->assignTasks($batches);
     }
 
-    public function zzd()
-    {
-        ini_set('max_execution_time', 2500);
-        ini_set('memory_limit', '1526M');
-        $menus = [
-            "A管理" => [
-                "A二级" => [
-                    "A三级"
-                ]
-            ],
-            "B管理" => []
-        ];
-        /*$authorities = [
-            "A管理"=>[
-                "A二级"=>[9
-                    "A三级"=>[
-                        "A四级"
-                    ]
-                ]
-            ]
-        ];*/
-    }
-
     public function updateLaborRemark()
     {
         $laborReports = LaborReport::query()->with(['remarks' => function ($query) {
@@ -506,6 +409,11 @@ class TestController extends Controller
         broadcast(new BroadcastToStation(BroadcastToStation::ALL_STATION, $jsonStationTasks));
     }
 
+    public function ld4()
+    {
+
+    }
+
     public function featureIt()
     {
         LogisticNumberFeatureController::loadRecentRejectedsToFeatures(5, 2500);
@@ -1062,225 +970,6 @@ class TestController extends Controller
             }
         }
     }
-
-    public function addProcurementData()
-    {
-        $this->syncUserDetail();
-        $this->addProcurementDeliver();
-        $this->addProcurement();
-        $this->addProcurementQuotation();
-        $this->addProcurementCheckSheet();
-    }
-
-    public function syncUserDetail()
-    {
-        $sql = DB::raw('SELECT * from user where supplierid is not null');
-        $params = DB::connection('erp')->select($sql);
-        $user_Details = UserDetail::query()->where('created_at', 'like', '2021-04-12%')->get();
-        $dataHandlerService = app(DataHandlerService::class);
-        $user_Details_map = $dataHandlerService->dataHeader(['mobile_phone'], $user_Details);
-        foreach ($params as $param) {
-            $user_detail = $dataHandlerService->getKeyValue(['mobile_phone' => $param->mobile], $user_Details_map);
-            if (!$user_detail) continue;
-            $user_detail->update(['procurement_wechat_open_id' => $param->openid]);
-        }
-    }
-
-    public function addProcurementDeliver()
-    {
-        //送货单
-        $sql = DB::raw('SELECT
-deliver.id id,request.id procurement_id,deliver.delivernum amount,deliver.status status,deliver.accepttime signed_at,
-deliver.createtime created_at,deliver.createtime updated_at,deliver.confirmnum receipt_amount
-from deliver
-LEFT JOIN purch on deliver.purchid=purch.id
-LEFT JOIN ask on purch.askid=ask.id
-LEFT JOIN request on ask.requestid=request.id
-where purch.islower=1');
-        $params = DB::connection('erp')->select($sql);
-        $insert = [];
-        foreach ($params as $param) {
-            $insert[] = [
-                'id' => $param->id,
-                'procurement_id' => $param->procurement_id,
-                'amount' => $param->amount,
-                'status' => $param->status ? $param->status - 1 : $param->status,
-                'signed_at' => Carbon::parse($param->signed_at)->toDateString(),
-                'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
-                'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
-                'receipt_amount' => $param->receipt_amount,
-            ];
-        }
-        ProcurementDeliverie::query()->insert($insert);
-    }
-
-    public function addProcurement()
-    {
-
-        //采购单
-        $sql = DB::raw('select request.id id,
-request.number code,request.type type,request.resourceid owner_material_id,purch.supplierid supplier_id,request.num quantity, request.sellnum amount,
-request.price unit_price,purch.acceptprice cost_price,request.status status,request.createtime created_at,request.createtime updated_at,
-purch.accepttime deadline
-from purch
-LEFT JOIN ask on purch.askid= ask.id
-LEFT JOIN request on ask.requestid=request.id
-where purch.islower=1 and request.type=3 ORDER BY request.id ASC');
-        $params = DB::connection('erp')->select($sql);
-        $insert = [];
-        foreach ($params as $param) {
-            if (!$param->status) continue;
-            if ($param->status == 0) $status = 10;
-            if ($param->status == 1) $status = 0;
-            if ($param->status == 2) $status = 1;
-            if ($param->status == 3) $status = 2;
-            if ($param->status == 4) $status = 11;
-            if ($param->status == 5) $status = 4;
-            if ($param->status == 6) $status = 5;
-            if ($param->status == 7) $status = 6;
-            if ($param->status == 8) $status = 8;
-            if ($param->status == 9) $status = 9;
-            $key = $param->id;
-            $insert[$key] = [
-                'id' => $param->id,
-                'code' => $param->code,
-                'type' => 0,
-                'owner_material_id' => $param->owner_material_id,
-                'supplier_id' => $param->supplier_id,
-                'quantity' => $param->quantity,
-                'amount' => $param->amount,
-                'unit_price' => $param->unit_price,
-                'cost_price' => $param->cost_price,
-                'initiator' => 0,
-                'status' => $status,
-                'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
-                'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
-                'deadline' => Carbon::parse($param->deadline)->toDateTimeString(),
-            ];
-        }
-        Procurement::query()->insert($insert);
-
-        //打样 或者 询价
-        $procurement_ids = Procurement::query()->select('id')->get();
-        $ids = $procurement_ids->map(function ($procurement) {
-            return $procurement['id'];
-        });
-        $idSql = "(''";
-        foreach ($ids as $id) $idSql .= "," . $id;
-        $idSql .= ")";
-        $sql = DB::raw('select * from request where id  not in ' . $idSql);
-        $params = DB::connection('erp')->select($sql);
-        $insert = [];
-        foreach ($params as $param) {
-            if (!$param->status) continue;
-            if (!$param->type) continue;
-            if ($param->status == 0) $status = 10;
-            if ($param->status == 1) $status = 0;
-            if ($param->status == 2) $status = 1;
-            if ($param->status == 3) $status = 2;
-            if ($param->status == 4) $status = 11;
-            if ($param->status == 5) $status = 4;
-            if ($param->status == 6) $status = 5;
-            if ($param->status == 7) $status = 6;
-            if ($param->status == 8) $status = 8;
-            if ($param->status == 9) $status = 9;
-            if ($param->type == 3) {
-                $type = 0;
-            } else {
-                $type = $param->type;
-            }
-            $insert[$param->id] = [
-                'id' => $param->id,
-                'code' => $param->number,
-                'type' => $type,
-                'owner_material_id' => $param->resourceid,
-                'quantity' => $param->num,
-                'amount' => $param->sellnum,
-                'unit_price' => $param->price,
-                'initiator' => 0,
-                'status' => $status,
-                'created_at' => Carbon::parse($param->createtime)->toDateTimeString(),
-                'updated_at' => Carbon::parse($param->createtime)->toDateTimeString(),
-                'deadline' => Carbon::parse($param->createtime)->subHours(-4)->toDateTimeString(),
-            ];
-        }
-        Procurement::query()->insert($insert);
-
-        //删除没有项目耗材的采购记录
-        $OwnerMaterialIds = OwnerMaterial::query()->select('id')->get();
-        $Procurements = Procurement::query()->whereNotIn('owner_material_id', $OwnerMaterialIds)->get();
-        $data = [];
-        foreach ($Procurements as $procurement) {
-            $data[] = $procurement->owner_material_id;
-            $procurement->delete();
-        }
-    }
-
-    public function addProcurementQuotation()
-    {
-        //报价单
-        $procurement_ids = Procurement::query()->select('id')->get();
-        $ids = $procurement_ids->map(function ($procurement) {
-            return $procurement['id'];
-        });
-        $idSql = "(''";
-        foreach ($ids as $id) $idSql .= "," . $id;
-        $idSql .= ")";
-        $sql = DB::raw('SELECT purch.id id,request.id procurement_id,purch.supplierid supplier_id,
-purch.acceptprice offer,purch.accepttime quoted_at,purch.status status,
-purch.accepttime created_at,purch.accepttime updated_at
-FROM purch
-LEFT JOIN ask on purch.askid=ask.id
-LEFT JOIN request on ask.requestid=request.id
-where request.id in' . $idSql);
-        $params = DB::connection('erp')->select($sql);
-        foreach ($params as $param) {
-            $key = $param->id;
-            $insert[$key] = [
-                'id' => $param->id,
-                'procurement_id' => $param->procurement_id,
-                'supplier_id' => $param->supplier_id,
-                'offer' => $param->offer,
-                'status' => $param->status,
-                'quoted_at' => Carbon::parse($param->quoted_at)->toDateTimeString(),
-                'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
-                'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
-            ];
-        }
-        ProcurementQuotation::query()->insert($insert);
-    }
-
-    public function addProcurementCheckSheet()
-    {
-        //对账单
-        $procurement_delivers = ProcurementDeliverie::query()->get();
-        $dataHandlerService = app(DataHandlerService::class);
-        $procurement_delivers_map = $dataHandlerService->dataHeader(['procurement_id'], $procurement_delivers);
-        $sql = DB::raw('select request.id procurement_id,billdetail.billno invoice_number,billdetail.status status,purch.acceptnum amount,purch.acceptprice price,
-purch.accepttime created_at,purch.accepttime updated_at
-FROM billdetail
-LEFT JOIN purch on purch.id=billdetail.purchid
-LEFT JOIN ask on purch.askid=ask.id
-LEFT JOIN request on ask.requestid=request.id
-where purch.islower=1');
-        $params = DB::connection('erp')->select($sql);
-
-        $insert = [];
-        foreach ($params as $param) {
-            $procurement_deliver = $dataHandlerService->getKeyValue(['procurement_id' => $param->procurement_id], $procurement_delivers_map);
-            if (!$procurement_deliver) continue;
-            $insert[$param->procurement_id] = [
-                'procurement_delivery_id' => $procurement_deliver->id,
-                'invoice_number' => $param->invoice_number ?? null,
-                'account_payable' => $param->amount * $param->price,
-                'status' => $param->status,
-                'created_at' => $param->created_at,
-                'updated_at' => $param->updated_at,
-            ];
-        }
-        ProcurementCheckSheet::query()->insert($insert);
-    }
-
     public function order_packages_exception_type_sync()
     {
         $count = OrderPackage::query()->where('status', '派送异常')->update(['exception_type' => '派件异常', 'exception' => '是']);
@@ -1299,142 +988,9 @@ where purch.islower=1');
         dump('更新了: ' . ($count_1 + $count_2));
     }
 
-    public function addProcurementDeliverAndCheckMeet()
-    {
-        $id = ProcurementDeliverie::query()->orderByDesc('id')->value('id');
-        $sql = DB::raw('SELECT
-deliver.id id,request.id procurement_id,deliver.delivernum amount,deliver.status status,deliver.accepttime signed_at,
-deliver.createtime created_at,deliver.createtime updated_at,deliver.confirmnum receipt_amount
-from deliver
-LEFT JOIN purch on deliver.purchid=purch.id
-LEFT JOIN ask on purch.askid=ask.id
-LEFT JOIN request on ask.requestid=request.id
-where purch.islower=1 and deliver.id>' . $id);
-        $params = DB::connection('erp')->select($sql);
-        $insert = [];
-        foreach ($params as $param) {
-            $insert[] = [
-                'id' => $param->id,
-                'procurement_id' => $param->procurement_id,
-                'amount' => $param->amount,
-                'status' => $param->status ? $param->status - 1 : $param->status,
-                'signed_at' => Carbon::parse($param->signed_at)->toDateString(),
-                'created_at' => Carbon::parse($param->created_at)->toDateTimeString(),
-                'updated_at' => Carbon::parse($param->updated_at)->toDateTimeString(),
-                'receipt_amount' => $param->receipt_amount,
-            ];
-        }
-        ProcurementDeliverie::query()->insert($insert);
 
-        $procurement_delivers = ProcurementDeliverie::query()->where('id', '>', $id)->get();
-        $dataHandlerService = app(DataHandlerService::class);
-        $procurement_delivers_map = $dataHandlerService->dataHeader(['procurement_id'], $procurement_delivers);
-        $sql = DB::raw('SELECT deliver.id id,request.id procurement_id,
-deliver.createtime created_at,deliver.createtime updated_at,purch.acceptnum amount,purch.acceptprice price
-from deliver
-LEFT JOIN purch on deliver.purchid=purch.id
-LEFT JOIN ask on purch.askid=ask.id
-LEFT JOIN request on ask.requestid=request.id
-where purch.islower=1 and deliver.id>' . $id);
-        $params = DB::connection('erp')->select($sql);
-        $insert_ = [];
-        foreach ($params as $param) {
-            $procurement_deliver = $dataHandlerService->getKeyValue(['procurement_id' => $param->procurement_id], $procurement_delivers_map);
-            if (!$procurement_deliver) continue;
-            $insert_[$param->procurement_id] = [
-                'procurement_delivery_id' => $procurement_deliver->id,
-                'account_payable' => $param->amount * $param->price,
-                'status' => 0,
-                'created_at' => $param->created_at,
-                'updated_at' => $param->updated_at,
-            ];
-        }
-        ProcurementCheckSheet::query()->insert($insert_);
-    }
 
-    public function updateProcurementCheckSheet()
-    {
-        $pro = ProcurementDeliverie::query()->find(515);
-        $pro->update([
-            'signed_at' => '2021-04-02',
-            'created_at' => '2021-04-02 08:34:51',
-            'updated_at' => '2021-04-02 08:34:51',
-        ]);
-        $pro = $pro->loadMissing('procurement');
-        ProcurementCheckSheet::query()->create([
-            'procurement_delivery_id' => $pro['id'],
-            'account_payable' => $pro['procurement']['cost_price'] * $pro['receipt_amount'],
-            'created_at' => $pro['created_at'],
-            'updated_at' => $pro['updated_at'],
-        ]);
-        $collect = ProcurementDeliverie::query()->with('procurement')->where('id', '>=', 517)
-            ->where('id', '<=', 528)->get();
-        $insert = [];
 
-        foreach ($collect as $item) {
-            if ($item['receipt_amount'] == 0) {
-                $receipt_amount = $item['amount'];
-            } else {
-                $receipt_amount = $item['receipt_amount'];
-            }
-            $insert[] = [
-                'procurement_delivery_id' => $item['id'],
-                'account_payable' => $item['procurement']['cost_price'] * $receipt_amount,
-                'created_at' => $item['created_at'],
-                'updated_at' => $item['updated_at'],
-            ];
-        }
-        ProcurementCheckSheet::query()->insert($insert);
-    }
-
-    public function testPro()
-    {
-        /**@var SupplierService $supplierService */
-        $supplierService = app(SupplierService::class);
-        $supplier_ids = $supplierService->screenSupplierIds();
-//        $status=0;
-//        $procurements=Procurement::query()
-//            ->withCount('procurementQuotations')
-//            ->with('ownerMaterial.material')
-//            ->where('status',$status)
-//            ->whereHas("ownerMaterial",function (Builder $query)use($supplier_ids){
-//                $query->whereHas("material",function (Builder $query)use($supplier_ids){
-//                    $query->whereHas("supplier",function (Builder $query)use($supplier_ids){
-//                        $query->whereIn('id',$supplier_ids);
-//                    });
-//                });
-//            })
-//            ->get();
-//        $keys = [];
-//        foreach ($procurements as $key=>$procurement){
-////            if ($procurement->procurement_quotations_count>0 && $status==0 )$keys[]= $key;
-//            if ($procurement->type==2 && $procurement->supplier_id )$keys[]= $key;
-//            if (Carbon::parse($procurement->deadline)->gt(Carbon::now())) $procurement->deadline=Carbon::parse($procurement->deadline)->diffInMilliseconds();
-//            else $procurement->deadline=0;
-//        }
-//        $procurements = $procurements->diffKeys($keys);
-//        dd($procurements);
-        $status = 0;//0:待报价,2:待接单
-        $procurements = Procurement::query()
-            ->withCount('procurementQuotations')
-            ->with(['ownerMaterial.material', 'procurementQuotations'])
-            ->where('status', $status)
-            ->get();
-        dd($procurements);
-        $keys = [];
-        foreach ($procurements as $key => $procurement) {
-            if ($procurement->procurement_quotations_count > 0) {
-                foreach ($procurement->procurementQuotations as $procurementQuotation) {
-                    if (in_array($procurementQuotation->supplier_id, $supplier_ids)) $keys[] = $key;
-                }
-            }
-            if ($procurement->type == 2 && $procurement->supplier_id) $keys[] = $key;
-            if (Carbon::parse($procurement->deadline)->gt(Carbon::now())) $procurement->deadline = Carbon::parse($procurement->deadline)->diffInMilliseconds();
-            else $procurement->deadline = 0;
-        }
-        $procurements = $procurements->diffKeys($keys);
-        dd($procurements);
-    }
 
     public function pushToWmsWeight()
     {
@@ -1719,20 +1275,32 @@ TEXT;
         dd($result);
     }
 
-    //更新入库近15天详情
-    public function updateStoreItem()
-    {
-        ini_set('max_execution_time', 2 * 60 * 60);
-        ini_set('memory_limit', '1024M');
-        $last_time=Carbon::now()->subDays(7)->toDateTimeString();
-        /** @var OracleDocAsnHerderService $oracleDocAsnHerderService */
-        /** @var StoreItemService $storeItemService */
-        $storeItemService = app(StoreItemService::class);
-        $oracleDocAsnHerderService = app(OracleDocAsnHerderService::class);
-        $asnHerdersCreated = $oracleDocAsnHerderService->getWmsAsnOnStartDateCreate($last_time);
-        $storeItemService->storeItemUpdateByWms($asnHerdersCreated);
-        $asnHerdersUpdated = $oracleDocAsnHerderService->getWmsAsnOnStartDateEdit($last_time);
-        $storeItemService->storeItemUpdateByWms($asnHerdersUpdated);
+    public function createProcurementTotalBill()
+    {
+        $date='2021-05';
+        $procurementCheckSheets=ProcurementCheckSheet::query()
+            ->selectRaw('procurements.supplier_id supplier_id,procurement_check_sheets.created_at created_at,procurement_check_sheets.status status,SUM(procurement_check_sheets.account_payable) account_payable')
+            ->leftJoin('procurement_deliveries','procurement_check_sheets.procurement_delivery_id','procurement_deliveries.id')
+            ->leftJoin('procurements','procurement_deliveries.procurement_id','procurements.id')
+            ->where('procurement_check_sheets.created_at','like',$date."%")
+            ->groupBy('supplier_id')->where('procurements.supplier_id',84)
+            ->get();
+        $totalBill=[];
+        foreach ($procurementCheckSheets as $procurementCheckSheet){
+            if ($procurementCheckSheet->account_payable<1) continue;
+            $totalBill[]=[
+                'counting_month'=>$date.'-01',
+                'supplier_id'=>$procurementCheckSheet->supplier_id,
+                'total_payable'=>$procurementCheckSheet->account_payable,
+                'status'=>$procurementCheckSheet->status,
+                'created_at'=>date('2021-06-01 00:00:00'),
+                'updated_at'=>date('2021-06-01 00:00:00'),
+            ];
+        }
+        if (count($totalBill)>0){
+            DB::table("procurement_total_bills")->insert($totalBill);
+            app('LogService')->log(__METHOD__,"采购管理-生成月账单报表",json_encode($totalBill));
+        }
     }
 
     public function test_ang()

+ 6 - 4
app/Http/Controllers/UserController.php

@@ -33,8 +33,8 @@ class UserController extends Controller
         $owners=app("OwnerService")->getIntersectPermitting();
         $userDetailQuery = UserDetail::query()->select('user_id')->where('type','临时工');
         $query = User::with(['roles','logistics','userWorkgroups','suppliers','userDetail'])->whereNotIn('id',$userDetailQuery);
-        if($request->has('user')){
-            $user=$request->input('user');
+        if($request->has('name')){
+            $user=$request->input('name');
             $query->where('name','like',$user.'%');
         }
         if($request->has('role')){
@@ -49,8 +49,8 @@ class UserController extends Controller
                 }
             });
         }
-        if($request->input('owner_id')){
-            $owner_id= $request->input('owner_id');
+        if($request->input('owners')){
+            $owner_id= $request->input('owners');
             $owner_ids = array_filter(preg_split('/[,, ]+/is',$owner_id));
             $ownerIds=[];
             foreach ($owner_ids as $id)$ownerIds[]='_'.$id;
@@ -166,6 +166,7 @@ class UserController extends Controller
             UserDetail::query()->where('user_id',$user->id) ->update(['mobile_phone'=>$phone]);
         }
         app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']);
+        app("UserService")->clearUserCache($user);
         return redirect('maintenance/user/')->with('successTip',"成功修改用户“{$user['name']}”!");
     }
 
@@ -181,6 +182,7 @@ class UserController extends Controller
         if(!Gate::allows('用户-删除')){ return redirect(url('/'));  }
         app('LogService')->log(__METHOD__,__FUNCTION__,$user->toJson(),Auth::user()['id']);
         $re=$user->delete();
+        app("UserService")->clearUserCache($user);
         return ['success'=>$re];
     }
 

+ 1 - 1
app/Http/Controllers/UserLaborController.php

@@ -26,7 +26,7 @@ class UserLaborController extends Controller
     public function index(Request $request)
     {
         $userLabors=UserLabor::query()->with('userDetail')->orderBy('user_id','desc');
-        $full_name = $request->user_name ?? false;
+        $full_name = $request->name ?? false;
         if ($full_name){
             $userLabors->whereHas('userDetail',function($query)use($full_name){
                 if (strpos($full_name, ',') || strpos($full_name, ',') || strpos($full_name, ' ')) {

+ 30 - 0
app/Http/Controllers/api/email/SendEmailsController.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Controllers\api\email;
+
+use App\Events\GitPushedEvent;
+use App\Http\Controllers\Controller;
+use App\User;
+use Illuminate\Http\Request;
+
+class SendEmailsController extends Controller
+{
+    public function send(Request $request)
+    {
+        $status=$request['status'];
+        if ($status=='failed'){
+            $email=$request['email'];
+            $load=[
+                'title'=>$request['title'],
+                'description'=>$request['description'],
+            ];
+        }else{
+            $email=User::query()->where('name','ldaaww')->pluck('email');
+            $load=[
+                'title'=>'上传代码邮件通知',
+                'description'=>'开发者上传代码成功,如需部署请做后续操作',
+            ];
+        }
+        event(new GitPushedEvent($email,$load));
+    }
+}

+ 2 - 2
app/Http/Controllers/api/thirdPart/haiq/LightController.php

@@ -52,8 +52,8 @@ class LightController
                 /** @var CacheShelfService $cacheShelfService */
                 $cacheShelfService = app(CacheShelfService::class);
                 $result =   $cacheShelfService->lightOffTask($request['locCode'],$request['PTLAction']);
-                $response['location']=$result['success'];
-                $response['errMsg']=$result['errMsg'];
+                $response['location']=$result['success']??'';
+                $response['errMsg']=$result['errMsg']??'';
                 return $response;
             case 'U型线拍灯':
 //                $this->foreignHaiRoboticsService->uLineLightPat($station);

+ 1 - 1
app/Http/Controllers/api/thirdPart/haiq/StorageController.php

@@ -219,7 +219,7 @@ class StorageController
         ];
         $this->lightOff = [
             "PTLAction"=> 0,
-            "locCode"=> "HAIB2-02-03"
+            "locCode"=> "HAIB2-02-02"
         ];
     }
 

+ 1 - 0
app/Jobs/ProcurementEnquiry.php

@@ -50,6 +50,7 @@ class ProcurementEnquiry implements ShouldQueue
             return;
         }
         if(!$this->procurement->unit_price)$this->unit_price=$priceCoefficient*$procurementQuotation['offer'];
+        else $this->unit_price=$this->procurement->unit_price;
         try{
            $this->procurement->update([
                'status'=>2,

+ 47 - 0
app/Listeners/GitPushedSendEmailListener.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Listeners;
+
+use App\Events\GitPushedEvent;
+
+use App\MailEvent;
+use App\Notifications\SendEmailNotification;
+use App\User;
+
+class GitPushedSendEmailListener
+{
+    /**
+     * Create the event listener.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        //
+    }
+
+    /**
+     * Handle the event.
+     *
+     * @param GitPushedEvent $event
+     * @return void
+     */
+    public function handle(GitPushedEvent $event)
+    {
+        $emailEvent = MailEvent::query()
+            ->where('event_name', GitPushedEvent::class)
+            ->where('is_active', true)
+            ->firstOrCreate([
+                'name' => 'gitPushEvent',
+                'event_name' => GitPushedEvent::class,
+            ]);
+        if ($emailEvent) {
+            $email = $event->email;
+            $load = $event->load; //array
+            $user = User::query()->where('email',$email)->first();
+            $template = json_encode($load);
+            $user->notify(new SendEmailNotification($template, 'emails.gitPush'));
+        }
+
+    }
+}

+ 1 - 1
app/Listeners/ModelChangedListener.php

@@ -23,7 +23,7 @@ class ModelChangedListener
         $methodName = $result[1]??'';
         LogService::log(
             get_class($event->model),
-            $methodName,
+                $methodName,
             '对象:'.$event->model->toJson()
             .'调用堆栈h:'.$traces
         );

+ 1 - 1
app/Listeners/SendEmailListener.php

@@ -42,7 +42,7 @@ class SendEmailListener
             /** @var MailEvent $emailEvent */
             $users = $this->getUsers($emailEvent);
             foreach ($users as $user) {//给这些用户发送通知
-                $user->notify(new SendEmailNotification($emailEvent->template));//邮件模板由数据库中定制的模板为准
+                $user->notify(new SendEmailNotification($emailEvent->template,'emails.test'));//邮件模板由数据库中定制的模板为准
             }
         }
     }

+ 10 - 5
app/Notifications/SendEmailNotification.php

@@ -13,20 +13,24 @@ class SendEmailNotification extends Notification implements ShouldQueue
 
     public $objToJson;
 
+    public $view;
+
     /**
      * SendEmailNotification constructor.
      * @param $objToJson
+     * @param $view
      */
-    public function __construct($objToJson)
+    public function __construct($objToJson, $view)
     {
         $this->objToJson = $objToJson;
+        $this->view = $view;
     }
 
 
     /**
      * Get the notification's delivery channels.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
      * @return array
      */
     public function via($notifiable): array
@@ -37,21 +41,22 @@ class SendEmailNotification extends Notification implements ShouldQueue
     /**
      * Get the mail representation of the notification.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
      * @return MailMessage
      */
     public function toMail($notifiable): MailMessage
     {
         $template = json_decode($this->objToJson);
+        $view = $this->view ? $this->view : 'emails.test';
         return (new MailMessage)->view(
-            'emails.test', ['objToJson' => $template]
+            $view, ['objToJson' => $template]
         )->subject($template->title);
     }
 
     /**
      * Get the array representation of the notification.
      *
-     * @param  mixed  $notifiable
+     * @param mixed $notifiable
      * @return array
      */
     public function toArray($notifiable)

+ 5 - 0
app/Providers/EventServiceProvider.php

@@ -35,6 +35,11 @@ class EventServiceProvider extends ServiceProvider
         'App\Events\SendEmailEvent' => [
             'App\Listeners\SendEmailListener'
         ],
+
+        'App\Events\GitPushedEvent' => [
+            'App\Listeners\GitPushedSendEmailListener'
+        ],
+
         'App\Events\AddOrUpdateOrderIssues' => [//问题件新增或更新
             'App\Listeners\AddOrUpdateOrderIssuesListener',//将对应的order_packages的数据的异常装变更
         ],

+ 5 - 0
app/Providers/RouteServiceProvider.php

@@ -76,6 +76,11 @@ class RouteServiceProvider extends ServiceProvider
              ->namespace($this->namespace)
              ->group(base_path('routes/apiLocal.php'));
 
+        Route::prefix('api/email/send')
+            ->middleware('api')
+            ->namespace('App\Http\Controllers\api\email')
+            ->group(base_path('routes/api/email/send.php'));
+
         Route::prefix('api/thirdPart/flux')
             ->middleware('api')
             ->namespace('App\Http\Controllers\api\thirdPart\flux')

+ 1 - 1
app/Services/BatchService.php

@@ -101,7 +101,7 @@ class BatchService
             foreach ($stationTasks as &$stationTask){
                 $stationTask->loadMissing([
                     "stationTaskCommodities.commodity.barcodes",
-                    "stationTaskCommodities.materialBox",
+                    "stationTaskCommodities.stationTaskMaterialBox",
                     "stationTaskBatches.batch.owner",
                     "stationTaskMaterialBoxes.materialBox",
                 ]);

+ 47 - 5
app/Services/CacheShelfService.php

@@ -55,11 +55,17 @@ class   CacheShelfService
      */
     public function lightOffTask($locCode, $PTLAction): array
     {
-        $station = Station::query()->with('pendingStationTask.stationTaskMaterialBoxes.materialBox')->where('code', $locCode)->first();
-        if (!app("StorageService")->checkStorage($station)){
-            $this->stationLightUp($station->code,null,'0','1','上架任务失败');
-            return ['success' => false,'errMsg' => '上架任务失败'];
-        };
+        $station = Station::query()->with(['pendingStationTask.stationTaskMaterialBoxes.materialBox','storage'=>function($query){
+            $query->whereNotNull("material_box_id")->orderByDesc("updated_at");
+        }])->where('code', $locCode)->first();
+        //站存在 站为缓存架2 站为蓝灯状态
+        if ($station && $station->parent_id==7){
+            if (!Storage::query()->where("station_id",$station->id)->whereNotNull("material_box_id")->first())return ['success' => false, 'errMsg' => "任务执行中,不允许灭灯"];
+            if (!app("StorageService")->checkStorage($station)){
+                $this->lightUp($station->code,'0','1',["title"=>"上架失败,联系管理员"]);
+                return ['success' => false,'errMsg' => '上架任务失败'];
+            };
+        }
         try {
             $bool = $this->putBinToStore($station);                         // 推送任务
             if ($bool) {
@@ -210,6 +216,42 @@ class   CacheShelfService
         return json_decode($response->body());
     }
 
+    /**
+     * 站亮灯
+     *
+     * @param string $stationCode
+     * @param string $color             explain: 0-red 1-green 2-blue 3-yellow
+     * @param string $frequency         explain: 0-常亮 1-一次 2-两次 3-三次 4-四次 5-五次 (均为/秒)
+     * @param array $info
+     * @return bool
+     */
+    public function lightUp(string $stationCode, string $color = '1', string $frequency = '0',array $info = []):bool
+    {
+        $default = [
+            "detail01" => '',
+            "detail02" => "",
+            "detail03" => "",
+            "qrCode" => "",
+            "qty00" => "",
+            "qty01" => 0,
+            "qty02" => 0,
+            "title" => '',
+            "uomDesc01" => "",
+            "uomDesc02" => ""
+        ];
+        foreach ($info as $key=>$item)$default[$key] = $item;
+
+        $params = [
+            "areaCode" => "1004",
+            'locCode' => $stationCode,
+            'PTLAction' => 1,
+            'PTLSettings' => ['color' => $color, 'frequency'  => $frequency],
+            "displayInfo" => $default,
+        ];
+        $response = Http::post(config('api.haiq.storage.light'), $params);
+        return $response->status()==200;
+    }
+
     /**
      * 控制格口灭灯
      * @param $locCode

+ 11 - 4
app/Services/DemandService.php

@@ -32,16 +32,23 @@ class DemandService
         if ($file->getSize() > 5 * 1024 * 1024) return ['success' => false, 'message' => '文件不能大于5MB'];
         $fileSuffix = $file->getClientOriginalExtension();
 
-        $dirPath = storage_path('app\public\files\issue');
+        if (!in_array($fileSuffix,[ 'gif','image','jpeg','jpg','png','svg']))
+            return ['success' => false , 'message' => '文件格式应该为gif,image,jpeg,jpg,png,svg格式'];
+
+        $path = ['app','public','files'];
+
+        $path = join(DIRECTORY_SEPARATOR,$path);
+
+        $dirPath = storage_path($path);
         if (!file_exists($dirPath)) {
             mkdir($dirPath);
         }
 
         $fileName = date('ymd') . '-' . Uuid::uuid1();
 
-        $thumbnailName = storage_path('app\public\files\issue\\' . $fileName . '-thumbnail.' . $fileSuffix);
-        $commonName = storage_path('app\public\files\issue\\' . $fileName . '-common.' . $fileSuffix);
-        $bulkyName = storage_path('app\public\files\issue\\' . $fileName . '-bulky.' . $fileSuffix);
+        $thumbnailName = storage_path('app/public/files/' . $fileName . '-thumbnail.' . $fileSuffix);
+        $commonName = storage_path('app/public/files/' . $fileName . '-common.' . $fileSuffix);
+        $bulkyName = storage_path('app/public/files/' . $fileName . '-bulky.' . $fileSuffix);
 
         $result = move_uploaded_file($tmpFile, $bulkyName);
 

+ 1 - 1
app/Services/ForeignHaiRoboticsService.php

@@ -508,7 +508,7 @@ class ForeignHaiRoboticsService
                 'station_id' => $station->id,
                 'material_box_id'=>$box->id,
                 'status'=>"待处理",
-                'type' => '',
+                'type' => '',
                 'station_task_id' => $task->id,
             ]));
             $stationCollection->add($station->code);

+ 1 - 1
app/Services/InventoryCompareService.php

@@ -146,7 +146,7 @@ class InventoryCompareService
         }
         unset($param['differ']);
         $columnQueryRules=[
-            'owner_id' => ['multi' => ','],
+            'owners' => ['alias' => 'owner_id','multi' => ','],
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'date_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
             'mission_code' => ['batch' => '','timeLimit' => 15],

+ 1 - 1
app/Services/InventoryDailyLogService.php

@@ -19,7 +19,7 @@ class InventoryDailyLogService
             $query->with('barcodes');
         }])->orderByDesc('inventory_daily_logs.id');
         $columnQueryRules=[
-            'owner_id' => ['multi' => ','],
+            'owner' => ['alias'=>'owner_id','multi' => ','],
             'created_at_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
             'id' => ['multi' => ','],

+ 6 - 0
app/Services/LaborReportService.php

@@ -65,6 +65,12 @@ class LaborReportService
         $laborReports = app(QueryService::class)->query($params,$laborReports,$columnQueryRules,'labor_reports');
         return $laborReports;
     }
+    public function recycleQuery(array $params){
+        $query=LaborReport::query()->with(['user','userDutyCheck','userWorkgroup','laborCompany'])->orderByDesc('id')->onlyTrashed();
+        $rule=['name' => ['batch' => ''],];
+        $laborReports = app(QueryService::class)->query($params,$query,$rule,'labor_reports')->paginate($params['paginate'] ?? 50);
+        return $laborReports;
+    }
     public function paginate(array $params){
         return $this->conditionQuery($params)->paginate($params['paginate'] ?? 50);
     }

+ 10 - 8
app/Services/MaterialBoxService.php

@@ -7,6 +7,7 @@ namespace App\Services;
 use App\MaterialBox;
 use App\Station;
 use App\StationTaskMaterialBox;
+use App\Storage;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Cache;
@@ -84,11 +85,12 @@ sql;
      *
      * @return string|null
      */
-    public function getBoxLocation(string $ide)
+    public function getBoxLocation(string $ide):?string
     {
-        $bin = DB::connection("mysql_haiRobotics")->table("ks_bin")->select("ks_bin_space_code")
-            ->where("ks_bin_code",$ide)->where("status",1)->first();
-        return $bin->ks_bin_space_code ?? null;
+        $storage = Storage::query()->with("station")->whereHas("materialBox",function (Builder $box)use($ide){
+            $box->where("code",$ide);
+        })->whereNotNull("station_id")->first();
+        return $storage->station->code ?? null;
     }
 
     /**
@@ -98,12 +100,12 @@ sql;
      *
      * @return bool
      */
-    public function checkUsableBox($boxId):bool
+    public function checkUsableBox(int $boxId):bool
     {
         /** @var MaterialBox|\stdClass $box */
-        $box = MaterialBox::query()->find($boxId);
-        if (!$this->getBoxLocation($box->code))return false;
-        if (StationTaskMaterialBox::query()->select(DB::raw(1))->where("status","!=",'完成')->where("material_box_id",$boxId)->first())return false;
+        //$box = MaterialBox::query()->find($boxId);
+        //if (!$this->getBoxLocation($box->code))return false;
+        if (StationTaskMaterialBox::query()->select(DB::raw(1))->whereNotIn("status",['完成','取消'])->where("material_box_id",$boxId)->first())return false;
         return true;
     }
 }

+ 1 - 0
app/Services/MenuService.php

@@ -98,6 +98,7 @@ class MenuService
             foreach ($authorities as $j=>$authority){
                 if ($menu["name"] == $authority["name"]){
                     $mapping[$menu["id"]] = $authority["id"];
+                    $menus[$index]["authId"] = $authority["id"];
                     $mark = true;
                     $authorities[$j]["mark"] = true;
                     if ($authority["child"])$menus[$index]["child"] = array_values($this->formatMenu($menu["child"],$authority["child"],$mapping));

+ 7 - 1
app/Services/OrderService.php

@@ -90,27 +90,32 @@ class OrderService
         if ($ordernos){
             $sql .= " AND orderno IN ".$ordernos;
         }
-//        if ($c_contact) $sql .= " AND c_contact like '".$c_contact."'";
         if ($c_contact)$sql=$this->sqlSearchWay($sql,$c_contact,'c_contact');
         if ($c_tel2){
+            $c_tel2 = str_replace("'",'"',$c_tel2);
             $sql .= " AND (c_tel2 like '".$c_tel2."' OR c_tel1 like '".$c_tel2."')";
         }
         if ($c_province){
+            $c_province = str_replace("'",'"',$c_province);
             if ($c_province=='空')$sql .= " AND c_province is null";
             else$sql .= " AND c_province like '".$c_province."'";
         }
         if ($c_city){
+            $c_city = str_replace("'",'"',$c_city);
             if ($c_city=='空')$sql .= " AND c_city is null";
             else$sql .= " AND c_city like '".$c_city."'";
         }
         if ($c_district){
+            $c_district = str_replace("'",'"',$c_district);
             if ($c_district=='空')$sql .= " AND c_district is null";
             else$sql .= " AND c_district like '".$c_district."'";
         }
         if ($releasestatus){
+            $releasestatus = str_replace("'",'"',$releasestatus);
             $sql .= " AND releasestatus = '".$releasestatus."'";
         }
         if ($alternate_sku1){
+            $alternate_sku1 = str_replace("'",'"',$alternate_sku1);
             if ($checkAllSign) $detailsOrderno = $this->getOrdersNo($alternate_sku1,false);
             else $detailsOrderno = $this->getOrdersNo($alternate_sku1,true, $params['page'] ?? 1, $params['paginate'] ?? 50);
             if (count($detailsOrderno)>0){
@@ -184,6 +189,7 @@ class OrderService
             $sql.=" and notes like '%".$notes."%'";
         }
         if ($soreference5){
+            $soreference5 = str_replace("'",'"',$soreference5);
             $arr=array_values(array_filter(preg_split('/[,, ]+/is', $soreference5)));
             if (count($arr)>0){
                 $sql.=" and (soreference5 in (";

+ 1 - 1
app/Services/OwnerBillReportService.php

@@ -23,7 +23,7 @@ class OwnerBillReportService
         $columnQueryRules = [
             'counting_month_start' => ['alias' => 'counting_month', 'startDate' => '-01'],
             'counting_month_end' => ['alias' => 'counting_month', 'endDate' => '-31'],
-            'owner_id' => ['multi' => ','],
+            'owners' => ['alias' => 'owner_id','multi' => ','],
         ];
         if (($params["customer_id"] ?? false) || ($params["owner_group_id"] ?? false)){
             $builder->whereHas('owner',function ($query)use(&$params){

+ 1 - 1
app/Services/OwnerFeeDetailService.php

@@ -22,7 +22,7 @@ class OwnerFeeDetailService
         $columnQueryRules = [
             'worked_at_start' => ['alias' => 'worked_at', 'startDate' => ''],
             'worked_at_end' => ['alias' => 'worked_at', 'endDate' => ''],
-            'owner_id' => ['multi' => ','],
+            'owners' => ['alias' => 'owner_id','multi' => ','],
             'id' => ['multi' => ','],
             'operation_bill' => ['batch' => ''],
             'logistic_bill' => ['batch' => ''],

+ 7 - 7
app/Services/OwnerReportService.php

@@ -22,21 +22,21 @@ class OwnerReportService
         $columnQueryRules = [
             'counting_month_start' => ['alias' => 'counting_month', 'startDate' => '-01'],
             'counting_month_end' => ['alias' => 'counting_month', 'endDate' => '-31'],
-            'owner_id' => ['multi' => ','],
+            'owners' => ['alias' => 'owner_id','multi' => ','],
         ];
-        if ($params["owner_group_id"] ?? false){
+        if ($params["owner_groups"] ?? false){
             $builder->whereHas('owner',function ($query)use(&$params){
                 /** @var Builder $query */
-                $query->where("user_owner_group_id",$params["owner_group_id"]);
+                $query->where("user_owner_group_id",$params["owner_groups"]);
             });
-            unset($params["owner_group_id"]);
+            unset($params["owner_groups"]);
         }
-        if ($params["customer_id"] ?? false){
+        if ($params["customers"] ?? false){
             $builder->whereHas('owner',function ($query)use(&$params){
                 /** @var Builder $query */
-                $query->where("customer_id",$params["customer_id"]);
+                $query->where("customer_id",$params["customers"]);
             });
-            unset($params["customer_id"]);
+            unset($params["customers"]);
         }
         if ($params["status"] ?? false){
             $builder->whereHas('owner',function ($query)use(&$params){

+ 24 - 15
app/Services/OwnerService.php

@@ -252,6 +252,15 @@ class OwnerService
                 });
                 continue;
             }
+            if ($column == 'customers'){
+                if (is_array($param))$builder->whereIn('customer_id',$param);
+                else $builder->where('customer_id',$param);
+            }
+            if ($column == 'ids'){
+                if (is_array($param))$builder->whereIn('id',$param);
+                else $builder->where('id',$param);
+            }
+
             if (is_array($param))$builder->whereIn($column,$param);
             else $builder->where($column,$param);
         }
@@ -385,37 +394,37 @@ sql
     {
         $relevance = [];
         $sql = <<<sql
-SELECT 1 FROM owner_storage_price_models a 
-LEFT JOIN owner_storage_price_model_owner b ON a.id =  b.owner_storage_price_model_id 
-LEFT JOIN owners c ON b.owner_id = c.id 
+SELECT 1 FROM owner_storage_price_models a
+LEFT JOIN owner_storage_price_model_owner b ON a.id =  b.owner_storage_price_model_id
+LEFT JOIN owners c ON b.owner_id = c.id
 WHERE (a.operation IS NULL OR a.operation = '') AND c.id = ? LIMIT 1
 sql;
         if (DB::selectOne(DB::raw($sql),[$ownerId]))$relevance[] = 0;
         $sql = <<<sql
-SELECT 1 FROM owner_price_operations a 
-LEFT JOIN owner_price_operation_owner b ON a.id =  b.owner_price_operation_id 
-LEFT JOIN owners c ON b.owner_id = c.id 
+SELECT 1 FROM owner_price_operations a
+LEFT JOIN owner_price_operation_owner b ON a.id =  b.owner_price_operation_id
+LEFT JOIN owners c ON b.owner_id = c.id
 WHERE (a.operation IS NULL OR a.operation = '') AND c.id = ? LIMIT 1
 sql;
         if (DB::selectOne(DB::raw($sql),[$ownerId]))$relevance[] = 1;
         $sql = <<<sql
-SELECT 1 FROM owner_price_expresses a 
-LEFT JOIN owner_price_express_owner b ON a.id =  b.owner_price_express_id 
-LEFT JOIN owners c ON b.owner_id = c.id 
+SELECT 1 FROM owner_price_expresses a
+LEFT JOIN owner_price_express_owner b ON a.id =  b.owner_price_express_id
+LEFT JOIN owners c ON b.owner_id = c.id
 WHERE (a.operation IS NULL OR a.operation = '') AND c.id = ? LIMIT 1
 sql;
         if (DB::selectOne(DB::raw($sql),[$ownerId]))$relevance[] = 2;
         $sql = <<<sql
-SELECT 1 FROM owner_price_logistics a 
-LEFT JOIN owner_price_logistic_owner b ON a.id =  b.owner_price_logistic_id 
-LEFT JOIN owners c ON b.owner_id = c.id 
+SELECT 1 FROM owner_price_logistics a
+LEFT JOIN owner_price_logistic_owner b ON a.id =  b.owner_price_logistic_id
+LEFT JOIN owners c ON b.owner_id = c.id
 WHERE (a.operation IS NULL OR a.operation = '') AND c.id = ? LIMIT 1
 sql;
         if (DB::selectOne(DB::raw($sql),[$ownerId]))$relevance[] = 3;
         $sql = <<<sql
-SELECT 1 FROM owner_price_direct_logistics a 
-LEFT JOIN owner_price_direct_logistic_owner b ON a.id =  b.owner_price_direct_logistic_id 
-LEFT JOIN owners c ON b.owner_id = c.id 
+SELECT 1 FROM owner_price_direct_logistics a
+LEFT JOIN owner_price_direct_logistic_owner b ON a.id =  b.owner_price_direct_logistic_id
+LEFT JOIN owners c ON b.owner_id = c.id
 WHERE (a.operation IS NULL OR a.operation = '') AND c.id = ? LIMIT 1
 sql;
         if (DB::selectOne(DB::raw($sql),[$ownerId]))$relevance[] = 4;

+ 3 - 3
app/Services/PackageService.php

@@ -24,10 +24,10 @@ class PackageService
             return  $query->with(['owner','logistic','batch']);
         },'paperBox','measuringMachine'])
         ->whereIn('order_packages.owner_id',$ownerIds)->orderBy(TABLE.'id','DESC');
-        if ($params['owner_id'] ?? false){
-            $owner_id = explode(',',$params['owner_id']);
+        if ($params['owner'] ?? false){
+            $owner_id = explode(',',$params['owner']);
             $packages->whereIn('order_packages.owner_id',$owner_id);
-            unset($params['owner_id']);
+            unset($params['owner']);
         }
         if ($params['logistic_number'] ?? false){
             $packages->whereIn('logistic_number',array_values(array_filter(preg_split('/[,, ]+/is', $params['logistic_number']))));

+ 1 - 1
app/Services/ProcessService.php

@@ -59,7 +59,7 @@ class ProcessService
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'date_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
             'code' => ['batch' => ''],
-            'owner_id' => ['multi' => ','],
+            'owners' => ['alias' => 'owner_id' ,'multi' => ','],
             'id' => ['multi' => ','],
         ];
         $processes = app(QueryService::class)->query($params,$processes,$columnQueryRules,"processes");

+ 3 - 3
app/Services/ProcessStatisticService.php

@@ -15,12 +15,12 @@ class ProcessStatisticService
     private function conditionQuery(array $params){
         $query = ProcessStatistic::with(['process.owner','operatorLog.user'])->orderBy('process_statistics.process_id','DESC')
             ->has('process');
-        if ($params["owner_id"] ?? false){
-            $owner_id=$params["owner_id"];
+        if ($params["owners"] ?? false){
+            $owner_id=$params["owners"];
             $query=$query->whereHas('process',function (Builder $builder)use($owner_id){
                 $builder->where('owner_id',$owner_id);
             });
-            unset($params["owner_id"]);
+            unset($params["owners"]);
         }
         if ($params["code"] ?? false){
             $code=$params["code"];

+ 1 - 1
app/Services/RejectedService.php

@@ -31,7 +31,7 @@ class RejectedService
         $columnQueryRules = [
             'created_at_start' => ['alias' => 'created_at', 'startDate' => ' 00:00:00'],
             'created_at_end' => ['alias' => 'created_at', 'endDate' => ' 23:59:59'],
-            'owner_id' => ['alias' => 'id_owner', 'multi' => ','],
+            'owner' => ['alias' => 'id_owner', 'multi' => ','],
             'order_number' => ['batch' => ''],
             'remark' => ['batch' => '','timeLimit'=>15],
             'logistic_number' => ['batch' => ''],

+ 3 - 3
app/Services/RoleService.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 namespace App\Services;
 
@@ -25,9 +25,9 @@ class RoleService
     {
         $ids = array_column(DB::select(DB::raw("SELECT id_user FROM user_role WHERE id_role = ?"),[$roleId]),"id_user");
         foreach ($ids as $id){
-            if ($isAuthority)Cache::forget("authorities:user_".$id);
+            if ($isAuthority)Cache::tags("authorities:user")->forget("authorities:user_".$id);
             if ($isOwner)Cache::forget("owners:user_".$id);
             if ($isUserWorkGroup)Cache::forget("userWorkGroups:user_".$id);
         }
     }
-}
+}

+ 3 - 5
app/Services/StationService.php

@@ -82,7 +82,7 @@ class StationService
         if($stationTask)
             $stationTask->loadMissing([
                 "stationTaskCommodities.commodity.barcodes",
-                "stationTaskCommodities.materialBox",
+                "stationTaskCommodities.stationTaskMaterialBox",
                 "stationTaskBatches.batch",
                 "stationTaskMaterialBoxes.materialBox",
             ]);
@@ -100,10 +100,8 @@ class StationService
      */
     public function getMirrorMappingLocation($mirrorLocation)
     {
-        $station = Station::query()->select("parent_id")->where("code",$mirrorLocation)->first();
-        if (!$station)return null;
-        return Station::query()->where("station_type_id",5)
-            ->where("id",$station->parent_id)->first();
+        if (!$mirrorLocation)return null;
+        return Station::query()->where("code",substr($mirrorLocation,2))->first();
     }
 
 }

+ 16 - 4
app/Services/StationTaskCommodityService.php

@@ -10,6 +10,7 @@ use App\StationTask;
 use App\StationTaskBatch;
 use App\StationTaskCommodity;
 use App\StationTaskMaterialBox;
+use App\Storage;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Cache;
 use App\Traits\ServiceAppAop;
@@ -108,11 +109,11 @@ class StationTaskCommodityService
             $stationType=$this->stationTypeService->getForCommodity();
             $station=$this->stationService->getStation_byType($stationType['name']);
             $materialBox=$this->materialBoxService->firstOrCreate(['code' => $orderCommodity['location']]);
-            $stationTaskMaterialBoxId=StationTaskMaterialBox::query()->where('station_task_batch_id',$batch['id'])->where('material_box_id',$materialBox['id'])->get('id');
+            $stationTaskMaterialBoxId=StationTaskMaterialBox::query()->where('station_task_batch_id',$stationTaskBatch['id'])->where('material_box_id',$materialBox['id'])->get('id')->first()['id']??null;
             $stationTaskCommodities_toCreate->push(
                 new StationTaskCommodity([
                     'station_id'=>$station['id'],
-                    'material_box_id'=>$materialBox['id'],
+//                    'material_box_id'=>$materialBox['id'],
                     'material_box_position'=>$orderCommodity['material_box_position'],
                     'commodity_id'=>$orderCommodity['commodity_id'],
                     'amount'=>$orderCommodity['amount'],
@@ -156,7 +157,7 @@ class StationTaskCommodityService
                 });
                 if(count($processingIds)==0){
                     foreach($groupByBatch as &$stationTaskCommodity){
-                        if($stationTaskCommodity['material_box_id']==$groupByBatch[0]['material_box_id']){
+                        if($stationTaskCommodity['station_task_material_box_id']==$groupByBatch[0]['station_task_material_box_id']){
                             $stationTaskCommodity['status']='处理中';
                         }
                     }
@@ -189,8 +190,19 @@ class StationTaskCommodityService
 
     function markProcessed(Collection $stationTaskCommodities){
         StationTaskCommodity::query()
-            ->whereIn('id',data_get($stationTaskCommodities,'*.id'))
+            ->whereIn('id',data_get($stationTaskCommodities,'*.id')??[])
             ->update(['status'=>'完成']);
+        $stationTaskMaterialBoxes=StationTaskMaterialBox::query()
+            ->whereIn('id', data_get($stationTaskCommodities, '*.station_task_material_box_id') ?? [])
+            ->get('material_box_id');
+        $storages=Storage::query()->whereIn('commodity_id',data_get($stationTaskCommodities,'*.commodity_id')??[])
+            ->whereIn('material_box_id',data_get($stationTaskMaterialBoxes,'*.material_box_id')??[])
+            ->get();
+        foreach($storages as $storage){
+            $amountReducing=$stationTaskCommodities->where('material_box_id',$storage['material_box_id'])->first()['amount']??0;
+            $storage['amount']-=$amountReducing;
+            $storage->update();
+        }
 //        $station_id=$stationTaskCommodities[0]['station_id'];
 //        $stationTaskCommodities_next=StationTaskCommodity::query()
 //            ->where('station_id',$station_id)

+ 2 - 1
app/Services/StationTaskMaterialBoxService.php

@@ -213,7 +213,8 @@ class StationTaskMaterialBoxService
         $this->instant($this->cacheShelfService,'CacheShelfService');
 
         // 料箱从缓存架上拿走
-        if($stationTaskMaterialBox['station']['stationType']['name']=='缓存架'){
+        if($stationTaskMaterialBox['station']['stationType']['name']=='缓存架'
+            &&$stationTaskMaterialBox['type']=='取'){
 
             $stationTaskMaterialBox['status'] = '完成';
             $result = $this->cacheShelfService->lightOffTask($stationTaskMaterialBox['station']['code'],0);

+ 299 - 87
app/Services/StorageService.php

@@ -3,18 +3,20 @@
 namespace App\Services;
 
 use App\CommodityMaterialBoxModel;
-use App\Log;
 use App\Station;
 use App\StationTask;
 use App\StationTaskMaterialBox;
+use App\StoreItem;
 use App\TaskTransaction;
 use App\Traits\ServiceAppAop;
 use App\Storage;
 use App\ValueStore;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
 
 class StorageService
 {
@@ -69,7 +71,23 @@ class StorageService
             ]);
             $stationTaskMaterialBox->loadMissing("station");
             //清理原有任务
-            app("StorageService")->clearTask([$stationTaskMaterialBox->station->code]);
+            if ($stationTaskMaterialBox->station){
+                switch ($stationTaskMaterialBox->station->parent_id){
+                    case 6:
+                        $this->clearTask([$stationTaskMaterialBox->station->code]);
+                        break;
+                    case 7:
+                        $task = TaskTransaction::query()->with("materialBox")->where("fm_station_id",$stationTaskMaterialBox->station_id)
+                            ->where("status",0)->first();
+                        if ($task)app("CacheShelfService")->lightUp($stationTaskMaterialBox->station->code,'1','0',[
+                            "title"=>$task->materialBox->code ?? '',
+                            "detail01"=>"{$task->doc_code}",
+                            "detail02"=>"商品条码:{$task->bar_code}",
+                            "detail03"=>"上架数量:{$task->amount}",
+                        ]);
+                        break;
+                }
+            }
             DB::commit();
         }catch (\Exception $e){
             DB::rollBack();
@@ -103,7 +121,7 @@ class StorageService
             ->where("status",0)->first();
         if (!$task)return;
         //蓝灯闪烁
-        if ($task->type == '入库' && $task->mark == 1)app("CacheShelfService")->stationLightUp($stationTaskMaterialBox->station->code,null,'2','2');
+        if ($task->type == '入库' && $task->mark == 1)app("CacheShelfService")->lightUp($stationTaskMaterialBox->station->code,'2','2',["title"=>'机器人取箱中,禁止操作',]);
     }
 
     /**
@@ -115,7 +133,7 @@ class StorageService
      *
      * @throws
      */
-    public function checkStorage($station)
+    public function checkStorage(Station $station)
     {
         $task = TaskTransaction::query()->with("materialBox")->where("fm_station_id",$station->id)
             ->where("status",0)->first();
@@ -125,12 +143,12 @@ class StorageService
             DB::beginTransaction();
             try{
                 //get flux
-                $asns = $this->getFluxTask($task->doc_code,$task->bar_code,$task->amount);
-                if (!$asns)return false;
+                $tasks = $this->getFluxTask($task->doc_code,$task->bar_code,$task->amount);
+                if (!$tasks)return false;
                 $ide = $task->materialBox->code;
                 DB::connection("oracle")->beginTransaction();
                 try{
-                    foreach ($asns as $asn)if (!$this->fluxPA($asn,$ide,(int)$asn->fmqty)){
+                    foreach ($tasks as $t)if (!$this->fluxPA($t,$ide)){
                         DB::connection("oracle")->rollBack();
                         return false;
                     };
@@ -143,10 +161,8 @@ class StorageService
                 $task->update([
                     "task_id" => $taskMaterialBox->id,
                     "status" => 1,
-                    "user_id" => Auth::id(),
                 ]);//标记事务完成
-                $collection = new Collection([$taskMaterialBox]);
-                app("ForeignHaiRoboticsService")->fetchGroup($station->code,$collection,'','缓存架入立架'); //呼叫机器人入库
+                app("ForeignHaiRoboticsService")->putBinToStore_fromCacheShelf($taskMaterialBox,$station->code); //呼叫机器人入库
                 DB::commit();
                 DB::connection("oracle")->commit();
                 return true;
@@ -165,7 +181,7 @@ class StorageService
      * @param $stationId
      * @param $boxId
      *
-     * @return Model|\stdClass
+     * @return StationTaskMaterialBox|\stdClass|Model
      */
     public function createWarehousingTask($stationId,$boxId)
     {
@@ -237,24 +253,151 @@ class StorageService
      *
      * @return array|null
      */
-    public function getFluxTask($asn,$barCode,$amount):?array
+    public function getFluxTask(string $asn,string $barCode,int $amount):array
     {
         $sql = <<<sql
-SELECT * FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
+SELECT TSK_TASKLISTS.* FROM DOC_ASN_DETAILS LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID AND DOC_ASN_DETAILS.SKU = BAS_SKU.SKU
 LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
 WHERE ASNNO = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?) AND RECEIVEDQTY >= ?
   AND TASKPROCESS = '00' AND TASKTYPE = 'PA'
 sql;
-        $asns = DB::connection("oracle")->select(DB::raw($sql),[$asn,$barCode,$barCode,$barCode,$amount]);
-        if (!$asns)return null;
+        $tasks = DB::connection("oracle")->select(DB::raw($sql),[$asn,$barCode,$barCode,$barCode,$amount]);
+        if (!$tasks)return [];
         $nums = [];
-        foreach ($asns as $asn){
-            if ((int)$asn->fmqty == $amount)return [$asn];
-            $nums[] = (int)$asn->fmqty;
+        $sum = 0;
+        $maxIndex = null;
+        foreach ($tasks as $i => $task){
+            if ((int)$task->fmqty == $amount)return [$task];
+            $nums[] = (int)$task->fmqty;
+            $sum += (int)$task->fmqty;
+            if ((int)$task->fmqty>$amount)$maxIndex = $i;
         }
-        $result = $this->twoSum($nums,$amount);
-        if ($result)return [$asns[$result[0]],$asns[$result[1]]];
-        return null;
+        if ($sum<$amount)return []; //上架数大于入库数
+        $result = $this->getMatch($nums,$amount);
+        if (!$result)return $this->splitTask($tasks,$maxIndex,$amount);
+        $arr = [];
+        foreach ($result as $index)$arr[] = $tasks[$index];
+        return $arr;
+    }
+
+    /**
+     * 拆分任务
+     * @param array $tasks
+     * @param int|null $maxIndex
+     * @param int $amount
+     *
+     * @return array
+     */
+    private function splitTask($tasks,$maxIndex,$amount):array
+    {
+        $result = [];
+        if ($maxIndex===null){
+            foreach ($tasks as $task){
+                if ($amount>(int)$task->fmqty){
+                    $result[] = $task;
+                    $amount-=(int)$task->fmqty;
+                }else $splitTarget = $task;
+            }
+        }else $splitTarget = $tasks[$maxIndex];
+        $result[] = $this->copyTask($splitTarget,$amount);
+        return $result;
+    }
+
+    /**
+     * 值转换
+     *
+     * @param ?string $val
+     *
+     * @return ?string
+     */
+    private function valFormat($val):?string
+    {
+        if ($val!==null){
+            $ret = date("Y-m-d H:i:s",strtotime($val))==$val;
+            if ($ret)$val = "to_date('".$val."','yyyy-mm-dd hh24:mi:ss')";
+            else $val = "'".$val."'";
+        }else $val = "null";
+        return $val;
+    }
+    /**
+     * @param \stdClass $task
+     * @param int $amount
+     *
+     * @return \stdClass
+     *
+     * @throws
+     */
+    private function copyTask($task,$amount)
+    {
+        DB::connection("oracle")->beginTransaction();
+        try {
+            $columns = '';
+            $values = '';
+            $seq = 0;
+            foreach ($task as $key=>$val){
+                if (Str::upper($key)=='TASKID_SEQUENCE') {
+                    $taskMax = DB::connection("oracle")->selectOne(DB::raw("select MAX(TASKID_SEQUENCE) maxseq from TSK_TASKLISTS where taskid = ?"),[$task->taskid]);
+                    $val = $taskMax->maxseq + 1;
+                    $seq = $val;
+                }
+                if (Str::upper($key)=='FMQTY' || Str::upper($key)=='FMQTY_EACH'
+                    || Str::upper($key)=='PLANTOQTY' || Str::upper($key)=='PLANTOQTY_EACH')$val = $amount;
+                if (Str::upper($key)=='FMID')$val = "WAS".$val;
+                $columns .= $key.",";
+                $values .= $this->valFormat($val) .",";
+            }
+            $columns = mb_substr($columns,0,-1);
+            $values = mb_substr($values,0,-1);
+            $sql = <<<sql
+    INSERT INTO TSK_TASKLISTS({$columns}) VALUES({$values})
+sql;
+            DB::connection("oracle")->insert(DB::raw($sql));
+            DB::connection("oracle")->update(DB::raw("UPDATE TSK_TASKLISTS SET FMQTY = FMQTY-?,FMQTY_EACH = FMQTY_EACH-?,PLANTOQTY=PLANTOQTY-?,PLANTOQTY_EACH=PLANTOQTY_EACH-? WHERE TASKID = ? AND TASKID_SEQUENCE = ?"),[
+                $amount,$amount,$amount,$amount,$task->taskid,$task->taskid_sequence
+            ]);
+            $invs = DB::connection("oracle")->select(DB::raw("SELECT * FROM INV_LOT_LOC_ID WHERE LOTNUM = ? AND LOCATIONID IN (?,?) AND TRACEID = ?"),[
+                $task->fmlotnum,$task->fmlocation,$task->plantolocation,$task->fmid
+            ]);
+            foreach ($invs as $inv){
+                if ($inv->locationid==$task->fmlocation){
+                    $columns = '';
+                    $values = '';
+                    DB::connection("oracle")->update(DB::raw("UPDATE inv_lot_loc_id SET qty = qty-?,qtymvout = qtymvout-? WHERE lotnum = ? AND locationid = ? AND traceid = ?"),[
+                        $amount,$amount,$inv->lotnum,$inv->locationid,$inv->traceid
+                    ]);
+                    foreach ($inv as $key=>$val){
+                        if (Str::upper($key)=='TRACEID') $val = "WAS".$task->fmid;
+                        if (Str::upper($key)=='QTY' || Str::upper($key)=='QTYMVOUT') $val = $amount;
+                        $columns .= $key.",";
+                        $values .= $this->valFormat($val) .",";
+                    }
+                    $columns = mb_substr($columns,0,-1);
+                    $values = mb_substr($values,0,-1);
+                    DB::connection("oracle")->insert(DB::raw("INSERT INTO inv_lot_loc_id({$columns}) VALUES({$values})"));
+                }
+                if ($inv->locationid==$task->plantolocation){
+                    $columns = '';
+                    $values = '';
+                    DB::connection("oracle")->update(DB::raw("UPDATE inv_lot_loc_id SET QTYPA = QTYPA-? WHERE lotnum = ? AND locationid = ? AND traceid = ?"),[
+                        $amount,$inv->lotnum,$inv->locationid,$inv->traceid
+                    ]);
+                    foreach ($inv as $key=>$val){
+                        if (Str::upper($key)=='TRACEID') $val = "WAS".$task->fmid;
+                        if (Str::upper($key)=='QTYPA') $val = $amount;
+                        $columns .= $key.",";
+                        $values .= $this->valFormat($val) .",";
+                    }
+                    $columns = mb_substr($columns,0,-1);
+                    $values = mb_substr($values,0,-1);
+                    DB::connection("oracle")->insert(DB::raw("INSERT INTO inv_lot_loc_id({$columns}) VALUES({$values})"));
+                }
+            }
+            DB::connection("oracle")->commit();
+        }catch(\Exception $e) {
+            DB::connection("oracle")->rollBack();
+            throw new \Exception("拆分任务失败:".$e->getMessage());
+        }
+        return DB::connection("oracle")->selectOne(DB::raw("SELECT * FROM TSK_TASKLISTS WHERE TASKID = ? AND TASKID_SEQUENCE = ?"),[$task->taskid,$seq]);
     }
 
     /**
@@ -264,14 +407,23 @@ sql;
      * @param Integer $target
      * @return Integer[]|null
      */
-    protected function twoSum($nums, $target) {
+    protected function getMatch(array $nums,int $target) :?array
+    {
         $map=[];
-        for($i=0;$i<count($nums);$i++){
-            $complement=$target-$nums[$i];
-            if(array_key_exists($complement,$map)){
-                return [$map[$complement],$i];
+        foreach ($nums as $index=>$val){
+            $complement=$target-$val;
+            if(array_key_exists($complement,$map))return [$map[$complement],$index];
+            if ($val==$target)return [$index];
+            $map[$val]=$index;
+            if ($val<$target){
+                $temp = $nums;
+                unset($temp[$index]);
+                $arr = $this->getMatch($temp,$target-$val);
+                if ($arr) {
+                    $arr[] = $index;
+                    return $arr;
+                }
             }
-            $map[$nums[$i]]=$i;
         }
         return null;
     }
@@ -279,39 +431,22 @@ sql;
     /**
      * 将任务在flux上架
      *
-     * @param $asn
+     * @param \stdClass $task
      * @param $ide
-     * @param $amount
      * @return bool
      * @throws \Throwable
      */
-    public function fluxPA($asn,$ide,$amount)
+    public function fluxPA($task,$ide):bool
     {
-        if (!$asn->taskid)return false;//ASN单无此入库信息,禁止上架
-
+        if (!$task->taskid)return false;//ASN单无此入库信息,禁止上架
+        $amount = (int)$task->fmqty;
         $sql = <<<sql
 SELECT * FROM inv_lot_loc_id  WHERE lotnum = ? AND traceid = ? AND customerid= ?  and sku = ? and qty = {$amount}
 sql;
-        $inv = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn->fmlotnum,$asn->plantoid,$asn->customerid,$asn->sku]);
+        $inv = DB::connection("oracle")->selectOne(DB::raw($sql),[$task->fmlotnum,$task->fmid,$task->customerid,$task->sku]);
         if (!$inv)return false;//余量与入库不符
-        DB::connection("oracle")->transaction(function ()use($inv,$amount,$ide,$asn,&$who){
+        DB::connection("oracle")->transaction(function ()use($inv,$amount,$ide,$task,&$who){
             $db = DB::connection("oracle");
-            /*$qty = $amount;
-            foreach ($inv as $in){
-                if ($qty==0)break;
-                if ($in->qty > $qty){
-                    $db->update(DB::raw("update inv_lot_loc_id set qty = qty-?,qtymvout = qty-? where lotnum = ? and locationid = ? and traceid = ?"),[
-                        $qty,$qty,$in->lotnum,$in->locationid,$in->traceid
-                    ]);
-                    $in->qty = $in->qty-$qty;
-                    $qty = 0;
-                }else{
-                    $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? and locationid = ? and traceid = ?"),[
-                        $in->lotnum,$in->locationid,$in->traceid
-                    ]);
-                    $qty = $qty-$in->qty;
-                }
-            }*/
             $db->delete(DB::raw("DELETE FROM inv_lot_loc_id WHERE lotnum = ? AND traceid = ? AND traceid != '*'  AND qty = 0"),[
                 $inv->lotnum,$inv->traceid
             ]);
@@ -329,54 +464,51 @@ sql;
             $sql = <<<sql
 INSERT INTO ACT_TRANSACTION_LOG VALUES(?,'PA',?,?,?,?,'ASN',?,?,?,?,?,?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,
 TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,0,0,0,0,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),?,?,null,null,null,'*',?,?,?,?,?,?,?,
-?,?,?,?,?,'N',null,?,?,?,?,?,?,?,null,null)
+?,?,?,?,?,'N',null,?,?,?,?,null,null,?,null,null)
 sql;
             list($trid,$max) = $this->getTrNumber();
             $db->insert(DB::raw($sql),[
-                $trid,$asn->customerid,$asn->sku,
-                $asn->asnno,$asn->asnlineno,$inv->lotnum,$asn->fmlocation,$asn->plantoid,$asn->packid,$asn->uom,$amount,$amount,'99',date("Y-m-d H:i:s"),$who,
-                date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),$asn->customerid,$asn->sku,$ide,$who,$asn->packid,$asn->uom,$amount,$amount,$inv->lotnum,
-                '*','0','N','*',$asn->taskid_sequence,$asn->warehouseid,$asn->userdefine1,$asn->userdefine2,
-                $asn->userdefine3,$asn->userdefine4,$asn->userdefine5,'O'
+                $trid,$task->customerid,$task->sku,
+                $task->docno,$task->doclineno,$inv->lotnum,$task->fmlocation,$task->fmid,$task->fmpackid,$task->fmuom,$amount,$amount,'99',date("Y-m-d H:i:s"),$who,
+                date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),$task->customerid,$task->sku,$ide,$who,$task->fmpackid,$task->fmuom,$amount,$amount,$inv->lotnum,
+                '*','0','N','*',$task->taskid_sequence,$task->warehouseid,$task->userdefine1,$task->userdefine2,
+                $task->userdefine3,'O'
             ]);
             $this->setTrNumber($max);
             $sql = <<<sql
-update TSK_TASKLISTS set TASKPROCESS = '99',REASONCODE = 'OK',PLANTOLOCATION = ?,PLANLOGICALTOSEQUENCE = ?,
-CREATE_TRANSACTIONID = ?,OPENWHO = ?,OPENTIME = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),
+update TSK_TASKLISTS set TASKPROCESS = '99',REASONCODE = 'OK',PLANTOLOCATION = ?,PLANLOGICALTOSEQUENCE = ?,FMID = '*',
+COMPLETED_TRANSACTIONID = ?,OPENWHO = ?,OPENTIME = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),
  CLOSEWHO = ?,CLOSETIME = ?,EDITTIME = ?,EDITWHO = ?
  where taskid = ? AND TASKID_SEQUENCE = ?
 sql;
             $db->update(DB::raw($sql),[
-                $ide,$ide,$trid,$who,date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),$who,$asn->taskid,$asn->taskid_sequence
+                $ide,'0',$trid,$who,date("Y-m-d H:i:s"),$who,date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),$who,$task->taskid,$task->taskid_sequence
             ]);
+            $task->who = $who;
+            $this->checkAsn($task);
         });
-        //成功后应去修改ASN状态及数量 暂时不知上架后ASN应为状态
-        /*        $sql = <<<sql
-        UPDATE doc_asn_details SET linestatus = ?,edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ? AND asnlineno = ?
-        sql;*/
-        //if ($asn->expectedqty>$asn->receivedqty && $asn->linestatus!='30')DB::connection("oracle")->update(DB::raw($sql),['30',date("Y-m-d H:i:s"),$who,$asn->asnno,$asn->asnlineno]);
-        if ($asn->expectedqty==$asn->receivedqty && $asn->linestatus=='40'){
-            //DB::connection("oracle")->update(DB::raw($sql),['40',date("Y-m-d H:i:s"),$who,$asn->asnno,$asn->asnlineno]);
-            $check = DB::connection("oracle")->selectOne(DB::raw("SELECT 1 FROM DOC_ASN_DETAILS WHERE ASNNO = ? AND LINESTATUS != '40'"),[$asn->asnno]);
-            if (!$check){
-                $logs = DB::connection("oracle")->select(DB::raw("SELECT SUM(FMQTY) qty,TRANSACTIONTYPE FROM ACT_TRANSACTION_LOG WHERE DOCNO = ? AND TRANSACTIONTYPE IN ('PA','IN') GROUP BY TRANSACTIONTYPE"),[$asn->asnno]);
-                $paQty = 0;
-                $inQty = 0;
-                foreach ($logs as $log){
-                    if ($log->transactiontype == 'IN')$inQty = $log->qty;
-                    else $paQty = $log->qty;
-                }
-                if ($paQty == $inQty){
-                    DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
-                        [date("Y-m-d H:i:s"),$who,$asn->asnno]);
-                    DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_DETAILS SET linestatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
-                        [date("Y-m-d H:i:s"),$who,$asn->asnno]);
-                }
-            }
-        }
         return true;
     }
 
+    private function checkAsn($task)
+    {
+        $sql = <<<SQL
+SELECT 1 FROM DOC_ASN_DETAILS WHERE ASNNO = ? AND LINESTATUS != '40'
+SQL;
+        $asn = DB::connection("oracle")->selectOne(DB::raw($sql),[$task->docno]);
+        if ($asn)return;
+
+        $sql = <<<SQL
+SELECT 1 FROM TSK_TASKLISTS WHERE TASKPROCESS != '99' AND TASKTYPE = 'PA' AND DOCNO = ?
+SQL;
+        $task = DB::connection("oracle")->selectOne(DB::raw($sql),[$task->docno]);
+        if ($task)return;
+
+        DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_HEADER SET asnstatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
+            [date("Y-m-d H:i:s"),$task->who,$task->docno]);
+        DB::connection("oracle")->update(DB::raw("UPDATE DOC_ASN_DETAILS SET linestatus = '99',edittime = TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),editwho = ? WHERE asnno = ?"),
+            [date("Y-m-d H:i:s"),$task->who,$task->docno]);
+    }
     /**
      * put cache rack box to warehousing(将缓存架料箱入库)
      *
@@ -494,6 +626,7 @@ sql;
      * 清除任务
      *
      * @param array $stationCodes
+     *
      */
     public function clearTask(array $stationCodes)
     {
@@ -512,10 +645,89 @@ sql;
         StationTask::query()->where("status","!=",'完成')->whereIn("station_id",$station)->update([
             "status" => "完成"
         ]);
-        Storage::query()->whereIn("station_id",$station)->update([
-            "status" => 1,
-            "station_id" => null,
+    }
+
+    /**
+     * 获取半箱库位库存信息
+     *
+     * @param CommodityMaterialBoxModel|\stdClass $model
+     * @param StoreItem|\stdClass $item
+     * @param string|null $asn
+     *
+     * @return ?Storage
+     */
+    public function getHalfBoxLocation(CommodityMaterialBoxModel $model,StoreItem $item,?string $asn = null,array $blacklist = []):?Storage
+    {
+        if (!$asn){$item->loadMissing("store");$asn = $item->store->asn_code;}
+        $boxCodes = '';//拼接料箱编码
+        $map = [];//库位与库存映射
+        //查询填充
+        $query = Storage::query()->with("materialBox")->whereHas("materialBox",function (Builder $query)use($model){
+            $query->where("material_box_model_id",$model->material_box_model_id);
+        })->where("commodity_id",$model->commodity_id)->where("amount","<",$model->maximum)
+            ->where("status",0)->where(DB::raw("{$model->maximum}-amount"),">",0);
+        if ($blacklist)$query->whereHas("materialBox",function (Builder $query)use($blacklist){
+           $query->whereNotIn("id",$blacklist);
+        });
+        $query->get()->each(function ($storage)use(&$boxCodes,&$map){
+            $boxCodes .= "'".$storage->materialBox->code."',";
+            $map[$storage->materialBox->code] = $storage;
+        });
+        //不存在跳出
+        if (!$boxCodes)return null;
+        $boxCodes = mb_substr($boxCodes,0,-1);
+        //查询对应asn detail
+        $detail = DB::connection("oracle")->selectOne(DB::raw("SELECT * FROM DOC_ASN_DETAILS WHERE ASNNO = ? AND ASNLINENO = ?"),[
+            $asn,$item->asn_line_code
+        ]);
+        if(!$detail)return null;
+        $detail = get_object_vars($detail);
+        //查询对应批次属性
+        $lot = DB::connection("oracle")->selectOne(DB::raw("SELECT * FROM BAS_LOTID WHERE LOTID = (SELECT LOTID FROM BAS_SKU WHERE CUSTOMERID = ? AND SKU = ?)"),[
+            $detail["customerid"],$detail["sku"]
         ]);
-        return true;
+        if(!$lot)return null;
+        //通过符合条件的批次号来查询 库存
+        $lot = get_object_vars($lot);
+        $sql = <<<sql
+SELECT * FROM INV_LOT_LOC_ID WHERE LOTNUM IN
+ (SELECT LOTNUM FROM INV_LOT_ATT WHERE INV_LOT_ATT.CUSTOMERID = ? AND SKU = ?
+sql;
+        //拼接可以合并的批次属性要求
+        for ($i=1;$i<=8;$i++){
+            if ($lot["lotkey0{$i}"]=='Y'){
+                $val = $detail["lotatt0{$i}"] ? "'{$detail["lotatt0{$i}"]}'" : null;
+                $sql .= " AND LOTATT0{$i} = $val";
+            }
+        }
+        $sql .= ") AND LOCATIONID IN ({$boxCodes}) AND TRACEID = '*' AND {$model->maximum}-QTY > 0 ORDER BY {$model->maximum}-QTY";
+        $res = DB::connection("oracle")->selectOne(DB::raw($sql),[
+            $detail["customerid"],$detail["sku"]
+        ]);
+        return $res ? $map[$res->locationid] : null;
+    }
+
+    /**
+     * 检查可上架数量
+     *
+     * @param string $asn
+     * @param string $barCode
+     *
+     * @return int
+     */
+    public function checkPutAmount(string $asn,string $barCode):int
+    {
+        $sql = <<<SQL
+SELECT SUM(FMQTY) qty FROM TSK_TASKLISTS
+LEFT JOIN BAS_SKU ON TSK_TASKLISTS.CUSTOMERID = BAS_SKU.CUSTOMERID AND TSK_TASKLISTS.SKU = BAS_SKU.SKU
+WHERE DOCNO = ? AND (ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? OR ALTERNATE_SKU3 = ?) AND TASKTYPE = 'PA'
+AND TASKPROCESS = '00'
+SQL;
+        $tsk = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn,$barCode,$barCode,$barCode]);
+        if (!$tsk)return  0;
+        $trk = TaskTransaction::query()->select(DB::raw("SUM(amount) amount"))->where("doc_code",$asn)->where("bar_code",$barCode)
+            ->where("type","入库")->where("status",0)->first();
+        if (!$trk)return $tsk->qty;
+        return $tsk->qty - $trk->amount;
     }
 }

+ 2 - 1
app/Services/StoreCheckingReceiveService.php

@@ -18,10 +18,11 @@ class StoreCheckingReceiveService
      * @return Builder
      */
     private function conditionQuery(Builder $query,array $params){
+
         $columnQueryRules=[
             'created_at_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
-            'owner_id' => ['multi' => ','],
+            'owner' => ['alias' => 'owner_id','multi' => ','],
             'id' => ['multi' => ','],
             'asn' => ['batch' => ',']
         ];

+ 28 - 0
app/Services/StoreItemService.php

@@ -9,6 +9,9 @@ use App\Services\common\DataHandlerService;
 use App\Store;
 use App\StoreItem;
 use App\Traits\ServiceAppAop;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\DB;
 
 
 class StoreItemService
@@ -258,4 +261,29 @@ class StoreItemService
             LogService::log(__METHOD__, __FUNCTION__, '删除多余StoreItems error' . count($delete_storeItems) . json_encode($delete_storeItems) . $e->getMessage() . $e->getTraceAsString(), null);
         }
     }
+
+    /**
+     * 获取最大可上架数的详情项
+     *
+     * @param string $asn
+     * @param string $barCode
+     *
+     * @return StoreItem|Model|null
+     */
+    public function getMaxAvailableDetail(string $asn,string $barCode):?StoreItem
+    {
+        $sql = <<<SQL
+SELECT DOC_ASN_DETAILS.ASNLINENO,SUM(TSK_TASKLISTS.FMQTY) QTY FROM DOC_ASN_DETAILS LEFT JOIN TSK_TASKLISTS ON DOC_ASN_DETAILS.ASNNO = TSK_TASKLISTS.DOCNO AND DOC_ASN_DETAILS.ASNLINENO = TSK_TASKLISTS.DOCLINENO
+LEFT JOIN BAS_SKU ON DOC_ASN_DETAILS.SKU = BAS_SKU.SKU AND DOC_ASN_DETAILS.CUSTOMERID = BAS_SKU.CUSTOMERID
+WHERE DOC_ASN_DETAILS.ASNNO = ? AND DOC_ASN_DETAILS.LINESTATUS IN ('30','40')
+  AND (BAS_SKU.ALTERNATE_SKU1 = ? OR ALTERNATE_SKU2 = ? AND ALTERNATE_SKU3 = ?)
+  AND TSK_TASKLISTS.TASKTYPE = 'PA' AND TASKPROCESS = '00'
+GROUP BY (DOC_ASN_DETAILS.ASNLINENO,DOC_ASN_DETAILS.ASNNO) ORDER BY QTY DESC
+SQL;
+        $detail = DB::connection("oracle")->selectOne(DB::raw($sql),[$asn,$barCode,$barCode,$barCode]);
+        if (!$asn)return null;
+        return StoreItem::query()->whereHas("store",function (Builder $query)use($asn){
+            $query->where("asn_code",$asn);
+        })->where("asn_line_code",$detail->asnlineno)->first();
+    }
 }

+ 2 - 2
app/Services/StoreService.php

@@ -32,8 +32,8 @@ class StoreService
             'remark' => ['batch' => '','timeLimit' => 15],
             'created_at_start' => ['alias' => 'created_at', 'startDate' => ' 00:00:00'],
             'created_at_end' => ['alias' => 'created_at', 'endDate' => ' 23:59:59'],
-            'owner_id' => ['multi' => ','],
-            'warehouse_id' => ['multi' => ','],
+            'owner' => ['alias' => 'owner_id','multi' => ','],
+            'warehouse' => ['alias' => 'warehouse_id','multi' => ','],
             'status' => ['multi' => ','],
             'stored_method' => ['multi' => ','],
             'id' => ['multi' => ',']

+ 12 - 0
app/Services/UserService.php

@@ -105,4 +105,16 @@ class UserService
         }
         return Cache::get($key);
     }
+
+    /**
+     * 清除用户缓存
+     *
+     * @param User $user
+     */
+    public function clearUserCache(User $user)
+    {
+        Cache::tags("authorities:user")->forget("authorities:user_".$user->id);
+        Cache::forget("owners:user_".$user->id);
+        Cache::forget("userWorkGroups:user_".$user->id);
+    }
 }

+ 3 - 3
app/StationTaskCommodity.php

@@ -11,15 +11,15 @@ class StationTaskCommodity extends Model
 {
     use ModelLogChanging;
 
-    protected $fillable= ['station_id','material_box_id','commodity_id','amount','order_id','status',"bin_number","station_task_batch_id","material_box_position"];
+    protected $fillable= ['station_id','station_task_material_box_id','commodity_id','amount','order_id','status',"bin_number","station_task_batch_id","material_box_position"];
 
     public function commodity(): BelongsTo
     {   //商品
         return $this->belongsTo(Commodity::class);
     }
-    public function materialBox(): BelongsTo
+    public function StationTaskMaterialBox(): BelongsTo
     {   //料箱
-        return $this->belongsTo(MaterialBox::class);
+        return $this->belongsTo(StationTaskMaterialBox::class);
     }
     function stationTask(): BelongsTo
     {

+ 1 - 2
app/StationTaskMaterialBox.php

@@ -33,7 +33,6 @@ class StationTaskMaterialBox extends Model
     }
     function stationTaskCommodities(): HasMany
     {
-        return $this->hasMany(StationTaskCommodity::class,'station_task_batch_id','station_task_batch_id')
-            ->where('material_box_id',$this['material_box_id']);
+        return $this->hasMany(StationTaskCommodity::class,'station_task_material_box_id','id');
     }
 }

+ 8 - 8
ci/.envCi

@@ -12,11 +12,11 @@ LOG_CHANNEL=stack
 
 
 DB_CONNECTION=mysql
-DB_HOST=47.103.131.176
-DB_PORT=3306
+DB_HOST=101.133.135.193
+DB_PORT=13306
 DB_DATABASE=bswas_test
-DB_USERNAME=developer
-DB_PASSWORD=developer
+DB_USERNAME=bswas_test
+DB_PASSWORD=123456
 
 
 ORACLE_DRIVER=oracle
@@ -30,12 +30,12 @@ ORACLE_CHARSET=utf8
 ORACLE_PREFIX=
 
 
-BROADCAST_DRIVER=pusher
-CACHE_DRIVER=file
-QUEUE_CONNECTION=database
+BROADCAST_DRIVER=redis
+CACHE_DRIVER=redis
+QUEUE_CONNECTION=sync
 SESSION_DRIVER=file
 SESSION_LIFETIME=120
-
+CACHE_PREFIX=testwas
 REDIS_HOST=127.0.0.1
 REDIS_PASSWORD=null
 REDIS_PORT=6379

+ 1 - 1
ci/executeCommand.sh

@@ -11,7 +11,7 @@ update_path=/var/www/update
 # shellcheck disable=SC2006
 for file in `ls $update_path`
      do
-        if [ "composer.json" = "$file" ]; then
+        if [ "composer.json" == "$file" ]; then
             sudo composer install
         elif [ "package.json" == "$file" ]; then
             sudo yarn install

+ 3 - 0
ci/installEnv.sh

@@ -1,6 +1,7 @@
 #!/bin/bash
 
 hasComposer=`command -v composer`
+
 if [[ $hasComposer == '' ]]
     then
 
@@ -45,3 +46,5 @@ if [[ $hasComposer == '' ]]
     composer update
     sudo chown gitlab-runner:docker vendor -R
 fi
+    composer update
+    sudo chown gitlab-runner:docker vendor -R

+ 9 - 0
ci/sendEmail.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+email=$*
+
+if [ "$email" == '' ]; then
+    curl -v "https://testwas.baoshi56.com/api/email/send/gitPushSendEmail?status=success"
+elif [ "$email" != '' ]; then
+    curl -v "https://testwas.baoshi56.com/api/email/send/gitPushSendEmail?status=failed&email=$email&title=上传代码邮件通知&description=开发者上传代码失败,请检查错误!"
+fi

+ 1 - 0
composer.json

@@ -29,6 +29,7 @@
         "oursdreams/export": "^0.0.7",
         "overtrue/laravel-pinyin": "^4.0",
         "overtrue/pinyin": "~4.0",
+        "picqer/php-barcode-generator": "^2.2",
         "predis/predis": "^1.1",
         "pusher/pusher-php-server": "^4.1",
         "te7a-houdini/laravel-trix": "^2.0",

+ 149 - 57
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "9fb48c117bc3478160f1b69ad28ec904",
+    "content-hash": "4c4342ce6a1481f75fbca7b9c6f7fcde",
     "packages": [
         {
             "name": "bacon/bacon-qr-code",
@@ -2306,16 +2306,16 @@
         },
         {
             "name": "league/commonmark",
-            "version": "1.6.4",
+            "version": "1.6.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/thephpleague/commonmark.git",
-                "reference": "c3c8b7217c52572fb42aaf84211abccf75a151b2"
+                "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c3c8b7217c52572fb42aaf84211abccf75a151b2",
-                "reference": "c3c8b7217c52572fb42aaf84211abccf75a151b2",
+                "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
+                "reference": "44ffd8d3c4a9133e4bd0548622b09c55af39db5f",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -2409,7 +2409,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-19T20:08:14+00:00"
+            "time": "2021-06-26T11:57:13+00:00"
         },
         {
             "name": "league/flysystem",
@@ -3019,16 +3019,16 @@
         },
         {
             "name": "myclabs/php-enum",
-            "version": "1.8.0",
+            "version": "1.8.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/myclabs/php-enum.git",
-                "reference": "46cf3d8498b095bd33727b13fd5707263af99421"
+                "reference": "55555d31a622b4bc9662664132a0533ae6ef47b1"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/myclabs/php-enum/zipball/46cf3d8498b095bd33727b13fd5707263af99421",
-                "reference": "46cf3d8498b095bd33727b13fd5707263af99421",
+                "url": "https://api.github.com/repos/myclabs/php-enum/zipball/55555d31a622b4bc9662664132a0533ae6ef47b1",
+                "reference": "55555d31a622b4bc9662664132a0533ae6ef47b1",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -3044,7 +3044,7 @@
             "require-dev": {
                 "phpunit/phpunit": "^9.5",
                 "squizlabs/php_codesniffer": "1.*",
-                "vimeo/psalm": "^4.5.1"
+                "vimeo/psalm": "^4.6.2"
             },
             "type": "library",
             "autoload": {
@@ -3069,7 +3069,7 @@
             ],
             "support": {
                 "issues": "https://github.com/myclabs/php-enum/issues",
-                "source": "https://github.com/myclabs/php-enum/tree/1.8.0"
+                "source": "https://github.com/myclabs/php-enum/tree/1.8.1"
             },
             "funding": [
                 {
@@ -3081,20 +3081,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-02-15T16:11:48+00:00"
+            "time": "2021-06-29T09:20:05+00:00"
         },
         {
             "name": "nesbot/carbon",
-            "version": "2.49.0",
+            "version": "2.50.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/briannesbitt/Carbon.git",
-                "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee"
+                "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/93d9db91c0235c486875d22f1e08b50bdf3e6eee",
-                "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee",
+                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
+                "reference": "f47f17d17602b2243414a44ad53d9f8b9ada5fdb",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -3152,15 +3152,15 @@
                 {
                     "name": "Brian Nesbitt",
                     "email": "brian@nesbot.com",
-                    "homepage": "http://nesbot.com"
+                    "homepage": "https://markido.com"
                 },
                 {
                     "name": "kylekatarnls",
-                    "homepage": "http://github.com/kylekatarnls"
+                    "homepage": "https://github.com/kylekatarnls"
                 }
             ],
             "description": "An API extension for DateTime that supports 281 different languages.",
-            "homepage": "http://carbon.nesbot.com",
+            "homepage": "https://carbon.nesbot.com",
             "keywords": [
                 "date",
                 "datetime",
@@ -3180,7 +3180,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-02T07:31:40+00:00"
+            "time": "2021-06-28T22:38:45+00:00"
         },
         {
             "name": "nikic/php-parser",
@@ -3842,6 +3842,98 @@
             ],
             "time": "2020-07-20T17:29:33+00:00"
         },
+        {
+            "name": "picqer/php-barcode-generator",
+            "version": "v2.2.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/picqer/php-barcode-generator.git",
+                "reference": "7df93b40099e5fefad055543320a36b80dccda05"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/picqer/php-barcode-generator/zipball/7df93b40099e5fefad055543320a36b80dccda05",
+                "reference": "7df93b40099e5fefad055543320a36b80dccda05",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "ext-mbstring": "*",
+                "php": "^7.3|^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^9.5"
+            },
+            "suggest": {
+                "ext-bcmath": "Barcode IMB (Intelligent Mail Barcode) needs bcmath extension",
+                "ext-gd": "For JPG and PNG generators, GD or Imagick is required",
+                "ext-imagick": "For JPG and PNG generators, GD or Imagick is required"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Picqer\\Barcode\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "LGPL-3.0-or-later"
+            ],
+            "authors": [
+                {
+                    "name": "Nicola Asuni",
+                    "email": "info@tecnick.com",
+                    "homepage": "http://nicolaasuni.tecnick.com"
+                },
+                {
+                    "name": "Casper Bakker",
+                    "email": "info@picqer.com",
+                    "homepage": "https://picqer.com"
+                }
+            ],
+            "description": "An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.",
+            "homepage": "https://github.com/picqer/php-barcode-generator",
+            "keywords": [
+                "CODABAR",
+                "Code11",
+                "Code93",
+                "EAN13",
+                "KIX",
+                "KIXCODE",
+                "MSI",
+                "POSTNET",
+                "Pharma",
+                "Standard 2 of 5",
+                "barcode",
+                "barcode generator",
+                "code128",
+                "code39",
+                "ean",
+                "html",
+                "jpeg",
+                "jpg",
+                "php",
+                "png",
+                "svg",
+                "upc"
+            ],
+            "support": {
+                "issues": "https://github.com/picqer/php-barcode-generator/issues",
+                "source": "https://github.com/picqer/php-barcode-generator/tree/v2.2.0"
+            },
+            "funding": [
+                {
+                    "url": "https://github.com/casperbakker",
+                    "type": "github"
+                }
+            ],
+            "time": "2021-03-27T09:06:22+00:00"
+        },
         {
             "name": "predis/predis",
             "version": "v1.1.7",
@@ -5022,16 +5114,16 @@
         },
         {
             "name": "symfony/error-handler",
-            "version": "v5.3.0",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/error-handler.git",
-                "reference": "0e6768b8c0dcef26df087df2bbbaa143867a59b2"
+                "reference": "43323e79c80719e8a4674e33484bca98270d223f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/error-handler/zipball/0e6768b8c0dcef26df087df2bbbaa143867a59b2",
-                "reference": "0e6768b8c0dcef26df087df2bbbaa143867a59b2",
+                "url": "https://api.github.com/repos/symfony/error-handler/zipball/43323e79c80719e8a4674e33484bca98270d223f",
+                "reference": "43323e79c80719e8a4674e33484bca98270d223f",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -5077,7 +5169,7 @@
             "description": "Provides tools to manage errors and ease debugging PHP code",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/error-handler/tree/v5.3.0"
+                "source": "https://github.com/symfony/error-handler/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -5093,7 +5185,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-05-26T17:43:10+00:00"
+            "time": "2021-06-24T08:13:00+00:00"
         },
         {
             "name": "symfony/event-dispatcher",
@@ -5424,16 +5516,16 @@
         },
         {
             "name": "symfony/http-foundation",
-            "version": "v5.3.2",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-foundation.git",
-                "reference": "7b6dd714d95106b831aaa7f3c9c612ab886516bd"
+                "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/7b6dd714d95106b831aaa7f3c9c612ab886516bd",
-                "reference": "7b6dd714d95106b831aaa7f3c9c612ab886516bd",
+                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/0e45ab1574caa0460d9190871a8ce47539e40ccf",
+                "reference": "0e45ab1574caa0460d9190871a8ce47539e40ccf",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -5483,7 +5575,7 @@
             "description": "Defines an object-oriented layer for the HTTP specification",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/http-foundation/tree/v5.3.2"
+                "source": "https://github.com/symfony/http-foundation/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -5499,20 +5591,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-12T10:15:17+00:00"
+            "time": "2021-06-27T09:19:40+00:00"
         },
         {
             "name": "symfony/http-kernel",
-            "version": "v5.3.2",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-kernel.git",
-                "reference": "e7021165d9dbfb4051296b8de827e92c8a7b5c87"
+                "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/e7021165d9dbfb4051296b8de827e92c8a7b5c87",
-                "reference": "e7021165d9dbfb4051296b8de827e92c8a7b5c87",
+                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8",
+                "reference": "90ad9f4b21ddcb8ebe9faadfcca54929ad23f9f8",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -5601,7 +5693,7 @@
             "description": "Provides a structured process for converting a Request into a Response",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/http-kernel/tree/v5.3.2"
+                "source": "https://github.com/symfony/http-kernel/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -5617,7 +5709,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-17T14:18:27+00:00"
+            "time": "2021-06-30T08:27:49+00:00"
         },
         {
             "name": "symfony/mime",
@@ -7000,16 +7092,16 @@
         },
         {
             "name": "symfony/string",
-            "version": "v5.3.2",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/string.git",
-                "reference": "0732e97e41c0a590f77e231afc16a327375d50b0"
+                "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/string/zipball/0732e97e41c0a590f77e231afc16a327375d50b0",
-                "reference": "0732e97e41c0a590f77e231afc16a327375d50b0",
+                "url": "https://api.github.com/repos/symfony/string/zipball/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
+                "reference": "bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -7069,7 +7161,7 @@
                 "utf8"
             ],
             "support": {
-                "source": "https://github.com/symfony/string/tree/v5.3.2"
+                "source": "https://github.com/symfony/string/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -7085,20 +7177,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-06T09:51:56+00:00"
+            "time": "2021-06-27T11:44:38+00:00"
         },
         {
             "name": "symfony/translation",
-            "version": "v5.3.2",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation.git",
-                "reference": "7e2603bcc598e14804c4d2359d8dc4ee3c40391b"
+                "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation/zipball/7e2603bcc598e14804c4d2359d8dc4ee3c40391b",
-                "reference": "7e2603bcc598e14804c4d2359d8dc4ee3c40391b",
+                "url": "https://api.github.com/repos/symfony/translation/zipball/380b8c9e944d0e364b25f28e8e555241eb49c01c",
+                "reference": "380b8c9e944d0e364b25f28e8e555241eb49c01c",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -7170,7 +7262,7 @@
             "description": "Provides tools to internationalize your application",
             "homepage": "https://symfony.com",
             "support": {
-                "source": "https://github.com/symfony/translation/tree/v5.3.2"
+                "source": "https://github.com/symfony/translation/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -7186,7 +7278,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-06T09:51:56+00:00"
+            "time": "2021-06-27T12:22:47+00:00"
         },
         {
             "name": "symfony/translation-contracts",
@@ -7274,16 +7366,16 @@
         },
         {
             "name": "symfony/var-dumper",
-            "version": "v5.3.2",
+            "version": "v5.3.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/var-dumper.git",
-                "reference": "905a22c68b292ffb6f20d7636c36b220d1fba5ae"
+                "reference": "46aa709affb9ad3355bd7a810f9662d71025c384"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/905a22c68b292ffb6f20d7636c36b220d1fba5ae",
-                "reference": "905a22c68b292ffb6f20d7636c36b220d1fba5ae",
+                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/46aa709affb9ad3355bd7a810f9662d71025c384",
+                "reference": "46aa709affb9ad3355bd7a810f9662d71025c384",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -7348,7 +7440,7 @@
                 "dump"
             ],
             "support": {
-                "source": "https://github.com/symfony/var-dumper/tree/v5.3.2"
+                "source": "https://github.com/symfony/var-dumper/tree/v5.3.3"
             },
             "funding": [
                 {
@@ -7364,7 +7456,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2021-06-06T09:51:56+00:00"
+            "time": "2021-06-24T08:13:00+00:00"
         },
         {
             "name": "te7a-houdini/laravel-trix",

+ 1 - 0
config/stores.php

@@ -5,6 +5,7 @@ return [
         "笕尚" => "JIANSHANG",
         "幼岚" => "ALLBLU",
         "淳钲" => "CHUNZHENG",
+        "妍柯" => "YANKE",
         "宝时" => "BAOSHI",
     ],
     "types" => [

+ 0 - 45
database/migrations/2019_10_30_184920_create_authorities_table.php

@@ -1,6 +1,5 @@
 <?php
 
-use App\Authority;
 use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
@@ -22,50 +21,6 @@ class CreateAuthoritiesTable extends Migration
             $table->bigInteger('id_parent')->index()->nullable();
             $table->timestamps();
         });
-        (new Authority(['name'=>'基础设置','alias_name'=>'基础设置']))->save();
-        (new Authority(['name'=>'权限','alias_name'=>'权限']))->save();
-        (new Authority(['name'=>'权限-查询','alias_name'=>'权限-查询']))->save();
-        (new Authority(['name'=>'权限-录入','alias_name'=>'权限-录入']))->save();
-        (new Authority(['name'=>'权限-编辑','alias_name'=>'权限-编辑']))->save();
-        (new Authority(['name'=>'权限-删除','alias_name'=>'权限-删除']))->save();
-        (new Authority(['name'=>'物流公司','alias_name'=>'物流公司']))->save();
-        (new Authority(['name'=>'物流公司-查询','alias_name'=>'物流公司-查询']))->save();
-        (new Authority(['name'=>'物流公司-录入','alias_name'=>'物流公司-录入']))->save();
-        (new Authority(['name'=>'物流公司-编辑','alias_name'=>'物流公司-编辑']))->save();
-        (new Authority(['name'=>'物流公司-删除','alias_name'=>'物流公司-删除']))->save();
-        (new Authority(['name'=>'货主','alias_name'=>'货主']))->save();
-        (new Authority(['name'=>'货主-查询','alias_name'=>'货主-查询']))->save();
-        (new Authority(['name'=>'货主-录入','alias_name'=>'货主-录入']))->save();
-        (new Authority(['name'=>'货主-编辑','alias_name'=>'货主-编辑']))->save();
-        (new Authority(['name'=>'货主-删除','alias_name'=>'货主-删除']))->save();
-        (new Authority(['name'=>'货主-可见全部','alias_name'=>'货主-可见全部']))->save();
-        (new Authority(['name'=>'品质标签','alias_name'=>'品质标签']))->save();
-        (new Authority(['name'=>'品质标签-查询','alias_name'=>'品质标签-查询']))->save();
-        (new Authority(['name'=>'品质标签-录入','alias_name'=>'品质标签-录入']))->save();
-        (new Authority(['name'=>'品质标签-编辑','alias_name'=>'品质标签-编辑']))->save();
-        (new Authority(['name'=>'品质标签-删除','alias_name'=>'品质标签-删除']))->save();
-        (new Authority(['name'=>'角色','alias_name'=>'角色']))->save();
-        (new Authority(['name'=>'角色-查询','alias_name'=>'角色-查询']))->save();
-        (new Authority(['name'=>'角色-录入','alias_name'=>'角色-录入']))->save();
-        (new Authority(['name'=>'角色-编辑','alias_name'=>'角色-编辑']))->save();
-        (new Authority(['name'=>'角色-删除','alias_name'=>'角色-删除']))->save();
-        (new Authority(['name'=>'用户','alias_name'=>'用户']))->save();
-        (new Authority(['name'=>'用户-查询','alias_name'=>'用户-查询']))->save();
-        (new Authority(['name'=>'用户-录入','alias_name'=>'用户-录入']))->save();
-        (new Authority(['name'=>'用户-编辑','alias_name'=>'用户-编辑']))->save();
-        (new Authority(['name'=>'用户-删除','alias_name'=>'用户-删除']))->save();
-        (new Authority(['name'=>'日志','alias_name'=>'日志']))->save();
-        (new Authority(['name'=>'日志-查询','alias_name'=>'日志-查询']))->save();
-        (new Authority(['name'=>'日志-录入','alias_name'=>'日志-录入']))->save();
-        (new Authority(['name'=>'日志-编辑','alias_name'=>'日志-编辑']))->save();
-        (new Authority(['name'=>'日志-删除','alias_name'=>'日志-删除']))->save();
-        (new Authority(['name'=>'退货管理','alias_name'=>'退货管理']))->save();
-        (new Authority(['name'=>'退货管理-相关设置','alias_name'=>'退货管理-相关设置']))->save();
-        (new Authority(['name'=>'退货管理-查询','alias_name'=>'退货管理-查询']))->save();
-        (new Authority(['name'=>'退货管理-录入','alias_name'=>'退货管理-录入']))->save();
-        (new Authority(['name'=>'退货管理-编辑','alias_name'=>'退货管理-编辑']))->save();
-        (new Authority(['name'=>'退货管理-删除','alias_name'=>'退货管理-删除']))->save();
-        (new Authority(['name'=>'退货管理-审核','alias_name'=>'退货管理-审核']))->save();
     }
 
     /**

+ 0 - 1
database/migrations/2019_11_22_094145_create_carriers_table.php

@@ -19,7 +19,6 @@ class CreateCarriersTable extends Migration
             $table->string('name',50)->unique()->comment('名称');
             $table->string('mobile',50)->unique()->comment('手机');
             $table->text('remark')->nullable()->comment('备注');
-
         });
     }
 

+ 0 - 3
database/migrations/2019_11_22_094253_create_cities_table.php

@@ -18,9 +18,6 @@ class CreateCitiesTable extends Migration
             $table->bigInteger('province_id')->index()->comment('省份');
             $table->string('name',50)->unique()->comment('名称');
             $table->timestamps();
-
-            //外键
-//            $table->foreign('province_id')->references('id')->on('provinces');      //省份
         });
         $Shanxi=['西安','宝鸡','咸阳','铜川','渭南','延安','榆林','汉中','安康','商洛'];
         $Gansu=['兰州','嘉峪关','金昌','白银','天水','武威','张掖','平凉','酒泉','庆阳','定西','陇南','临夏','合作'];

+ 0 - 33
database/migrations/2019_11_28_115444_add_data_authorities.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-use App\Authority;
-
-class AddDataAuthorities extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        (new Authority(['name'=>'商品信息','alias_name'=>'商品信息']))->save();
-        (new Authority(['name'=>'商品信息-查询','alias_name'=>'商品信息-查询']))->save();
-        (new Authority(['name'=>'商品信息-录入','alias_name'=>'商品信息-录入']))->save();
-        (new Authority(['name'=>'商品信息-编辑','alias_name'=>'商品信息-编辑']))->save();
-        (new Authority(['name'=>'商品信息-删除','alias_name'=>'商品信息-删除']))->save();
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //
-    }
-}

+ 0 - 2
database/migrations/2019_11_28_152321_create_waybill_audit_logs_table.php

@@ -16,10 +16,8 @@ class CreateWaybillAuditLogsTable extends Migration
         Schema::create('waybill_audit_logs', function (Blueprint $table) {
             $table->bigIncrements('id');
             $table->bigInteger('waybill_id')->comment('外键运单');
-//            $table->foreign('waybill_id')->references('id')->on('waybills');
             $table->string('audit_stage')->comment('审核阶段');
             $table->bigInteger('user_id')->comment('审核人');
-//            $table->foreign('user_id')->references('id')->on('users');
             $table->timestamps();
             $table->softDeletes();
         });

+ 0 - 105
database/migrations/2019_12_03_174626_add_data_authorities_waybill.php

@@ -1,105 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-use App\Authority;
-
-class AddDataAuthoritiesWaybill extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        (new Authority(['name'=>'计费模型','alias_name'=>'计费模型']))->save();
-        (new Authority(['name'=>'计费模型-查询','alias_name'=>'计费模型-查询']))->save();
-        (new Authority(['name'=>'计费模型-录入','alias_name'=>'计费模型-录入']))->save();
-        (new Authority(['name'=>'计费模型-编辑','alias_name'=>'计费模型-编辑']))->save();
-        (new Authority(['name'=>'计费模型-删除','alias_name'=>'计费模型-删除']))->save();
-        (new Authority(['name'=>'承运商','alias_name'=>'承运商']))->save();
-        (new Authority(['name'=>'承运商-查询','alias_name'=>'承运商-查询']))->save();
-        (new Authority(['name'=>'承运商-录入','alias_name'=>'承运商-录入']))->save();
-        (new Authority(['name'=>'承运商-编辑','alias_name'=>'承运商-编辑']))->save();
-        (new Authority(['name'=>'承运商-删除','alias_name'=>'承运商-删除']))->save();
-        (new Authority(['name'=>'车型','alias_name'=>'车型']))->save();
-        (new Authority(['name'=>'车型-查询','alias_name'=>'车型-查询']))->save();
-        (new Authority(['name'=>'车型-录入','alias_name'=>'车型-录入']))->save();
-        (new Authority(['name'=>'车型-编辑','alias_name'=>'车型-编辑']))->save();
-        (new Authority(['name'=>'车型-删除','alias_name'=>'车型-删除']))->save();
-        (new Authority(['name'=>'城市','alias_name'=>'城市']))->save();
-        (new Authority(['name'=>'城市-查询','alias_name'=>'城市-查询']))->save();
-        (new Authority(['name'=>'城市-录入','alias_name'=>'城市-录入']))->save();
-        (new Authority(['name'=>'城市-编辑','alias_name'=>'城市-编辑']))->save();
-        (new Authority(['name'=>'城市-删除','alias_name'=>'城市-删除']))->save();
-        (new Authority(['name'=>'省份','alias_name'=>'省份']))->save();
-        (new Authority(['name'=>'省份-查询','alias_name'=>'省份-查询']))->save();
-        (new Authority(['name'=>'省份-录入','alias_name'=>'省份-录入']))->save();
-        (new Authority(['name'=>'省份-编辑','alias_name'=>'省份-编辑']))->save();
-        (new Authority(['name'=>'省份-删除','alias_name'=>'省份-删除']))->save();
-        (new Authority(['name'=>'财务报表','alias_name'=>'财务报表']))->save();
-        (new Authority(['name'=>'运输管理','alias_name'=>'运输管理']))->save();
-        (new Authority(['name'=>'运输管理-查询','alias_name'=>'运输管理-查询']))->save();
-        (new Authority(['name'=>'运输管理-录入','alias_name'=>'运输管理-录入']))->save();
-        (new Authority(['name'=>'运输管理-编辑','alias_name'=>'运输管理-编辑']))->save();
-        (new Authority(['name'=>'运输管理-调度','alias_name'=>'运输管理-调度']))->save();
-        (new Authority(['name'=>'运输管理-删除','alias_name'=>'运输管理-删除']))->save();
-        (new Authority(['name'=>'运输管理-运单审核','alias_name'=>'运输管理-运单审核']))->save();
-        (new Authority(['name'=>'计量单位','alias_name'=>'计量单位']))->save();
-        (new Authority(['name'=>'计量单位-查询','alias_name'=>'计量单位-查询']))->save();
-        (new Authority(['name'=>'计量单位-录入','alias_name'=>'计量单位-录入']))->save();
-        (new Authority(['name'=>'计量单位-编辑','alias_name'=>'计量单位-编辑']))->save();
-        (new Authority(['name'=>'计量单位-删除','alias_name'=>'计量单位-删除']))->save();
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Authority::where('name','计费模型')->delete();
-        Authority::where('name','计费模型-查询')->delete();
-        Authority::where('name','计费模型-录入')->delete();
-        Authority::where('name','计费模型-编辑')->delete();
-        Authority::where('name','计费模型-删除')->delete();
-        Authority::where('name','承运商')->delete();
-        Authority::where('name','承运商-查询')->delete();
-        Authority::where('name','承运商-录入')->delete();
-        Authority::where('name','承运商-编辑')->delete();
-        Authority::where('name','承运商-删除')->delete();
-        Authority::where('name','车型')->delete();
-        Authority::where('name','车型-查询')->delete();
-        Authority::where('name','车型-录入')->delete();
-        Authority::where('name','车型-编辑')->delete();
-        Authority::where('name','车型-删除')->delete();
-        Authority::where('name','城市')->delete();
-        Authority::where('name','城市-查询')->delete();
-        Authority::where('name','城市-录入')->delete();
-        Authority::where('name','城市-编辑')->delete();
-        Authority::where('name','城市-删除')->delete();
-        Authority::where('name','省份')->delete();
-        Authority::where('name','省份-查询')->delete();
-        Authority::where('name','省份-录入')->delete();
-        Authority::where('name','省份-编辑')->delete();
-        Authority::where('name','省份-删除')->delete();
-        Authority::where('name','财务报表')->delete();
-        Authority::where('name','运输管理')->delete();
-        Authority::where('name','运输管理-查询')->delete();
-        Authority::where('name','运输管理-录入')->delete();
-        Authority::where('name','运输管理-编辑')->delete();
-        Authority::where('name','运输管理-调度')->delete();
-        Authority::where('name','运输管理-删除')->delete();
-        Authority::where('name','运输管理-运单审核')->delete();
-        Authority::where('name','运输管理-调度审核')->delete();
-        Authority::where('name','运输管理-可见费用项')->delete();
-        Authority::where('name','计量单位')->delete();
-        Authority::where('name','计量单位-查询')->delete();
-        Authority::where('name','计量单位-录入')->delete();
-        Authority::where('name','计量单位-编辑')->delete();
-        Authority::where('name','计量单位-删除')->delete();
-    }
-}

+ 0 - 47
database/migrations/2019_12_30_114648_add_weigh_authority.php

@@ -1,47 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddWeighAuthority extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        (new Authority(['name'=>'纸箱','alias_name'=>'纸箱']))->save();
-        (new Authority(['name'=>'纸箱-查询','alias_name'=>'纸箱-查询']))->save();
-        (new Authority(['name'=>'纸箱-录入','alias_name'=>'纸箱-录入']))->save();
-        (new Authority(['name'=>'纸箱-编辑','alias_name'=>'纸箱-编辑']))->save();
-        (new Authority(['name'=>'纸箱-删除','alias_name'=>'纸箱-删除']))->save();
-        (new Authority(['name'=>'测量设备','alias_name'=>'测量设备']))->save();
-        (new Authority(['name'=>'测量设备-查询','alias_name'=>'测量设备-查询']))->save();
-        (new Authority(['name'=>'测量设备-录入','alias_name'=>'测量设备-录入']))->save();
-        (new Authority(['name'=>'测量设备-编辑','alias_name'=>'测量设备-编辑']))->save();
-        (new Authority(['name'=>'测量设备-删除','alias_name'=>'测量设备-删除']))->save();
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Authority::where('name','纸箱')->delete();
-        Authority::where('name','纸箱-查询')->delete();
-        Authority::where('name','纸箱-录入')->delete();
-        Authority::where('name','纸箱-编辑')->delete();
-        Authority::where('name','纸箱-删除')->delete();
-        Authority::where('name','测量设备')->delete();
-        Authority::where('name','测量设备-查询')->delete();
-        Authority::where('name','测量设备-录入')->delete();
-        Authority::where('name','测量设备-编辑')->delete();
-        Authority::where('name','测量设备-删除')->delete();
-    }
-}

+ 0 - 1
database/migrations/2020_01_02_172739_change_waybill_price_model_field.php

@@ -26,7 +26,6 @@ class ChangeWaybillPriceModelField extends Migration
     public function down()
     {
         Schema::table('waybill_price_models', function (Blueprint $table) {
-//            $table->bigInteger('city_id')->index()->comment('外键城市')->change();
         });
     }
 }

+ 0 - 1
database/migrations/2020_02_19_145227_create_w_m_s_reflect_package_table.php

@@ -25,7 +25,6 @@ class CreateWMSReflectPackageTable extends Migration
             $table->string('USERDEFINE1',30)->nullable()->comment('波次号');
             $table->string('USERDEFINE2',30)->nullable()->comment('波次计划规则');
             $table->string('USERDEFINE3',30)->nullable()->comment('预留字段');
-            //$table->string('package_id',30)->nullable()->comment('外链包裹信息');
             $table->timestamps();
         });
     }

+ 0 - 44
database/migrations/2020_03_05_080123_add_weigh_excepted_authority.php

@@ -1,44 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddWeighExceptedAuthority extends Migration
-{
-
-
-
-    protected $authNames=[
-        '称重管理-查看异常',
-        '称重管理-录入',
-        '称重管理-查询',
-        '称重管理',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-
-}

+ 0 - 43
database/migrations/2020_03_09_132100_add_store_transfer_authority.php

@@ -1,43 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddStoreTransferAuthority extends Migration
-{
-
-    protected $authNames=[
-        '入库管理',
-        '入库管理-快速入库',
-        '入库管理-快速入库-查询',
-        '入库管理-快速入库-录入',
-        '入库管理-快速入库-编辑',
-        '入库管理-快速入库-删除',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 49
database/migrations/2020_03_25_182324_add_process_authority.php

@@ -1,49 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddProcessAuthority extends Migration
-{
-
-    protected $authNames=[
-        '二次加工管理',
-        '二次加工管理-查询',
-        '二次加工管理-录入',
-        '二次加工管理-编辑',
-        '二次加工管理-删除',
-        '二次加工管理-打卡审核',
-        '二次加工管理-接单与驳回',
-        '二次加工管理-登记工时',
-        '二次加工管理-登记工时-审核',
-        '二次加工管理-验收完成',
-        '二次加工管理-教程管理',
-        '二次加工管理-临时工资料管理',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 13
database/migrations/2020_03_30_112202_drop_commodity_barcode_column_to_barcode_table.php

@@ -15,22 +15,9 @@ class DropCommodityBarcodeColumnToBarcodeTable extends Migration
      */
     public function up()
     {
-//        \App\Commodity::query()->count();
-//        DB::insert('INSERT commodity_barcodes (code,commodity_id) SELECT barcode, id FROM commodities');
-//        $this->delRepeated();
         Schema::table('commodities', function (Blueprint $table) {
             $table->dropColumn('barcode');
         });
     }
 
-//    private function delRepeated(){
-//        $codes=CommodityBarcode::groupBy('code','commodity_id')->havingRaw('count(*) > ?', [1])->get();
-//        $codes->each(function(CommodityBarcode $code){
-//            $delCodes=CommodityBarcode::where('code',$code['code'])->where('commodity_id',$code['commodity_id'])->where('id','!=',$code['id'])->get();
-//            $delCodes->each(function(CommodityBarcode $delcode){
-//                $delcode->delete();
-//            });
-//        });
-//    }
-
 }

+ 0 - 44
database/migrations/2020_04_09_111337_add_tutorial_authority.php

@@ -1,44 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddTutorialAuthority extends Migration
-{
-    protected $authNames=[
-        '教程-查询',
-        '教程-录入',
-        '教程-编辑',
-        '教程-删除',
-        '临时工',
-        '临时工-查询',
-        '临时工-录入',
-        '临时工-编辑',
-        '临时工-删除',
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 4
database/migrations/2020_04_09_111540_change_tutorial_table.php

@@ -31,9 +31,5 @@ class ChangeTutorialTable extends Migration
         Schema::table('tutorials', function (Blueprint $table) {
             $table->longText('content')->after('name')->nullable()->comment('富文本内容');
         });
-        Schema::table('users', function (Blueprint $table) {
-//            $table->unique('email','users_email_unique');
-//            $table->string('email')->unique()->change();
-        });
     }
 }

+ 0 - 57
database/migrations/2020_05_14_091440_add_personnel_authority.php

@@ -1,57 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddPersonnelAuthority extends Migration
-{
-    protected  $deleteAuthNames=[
-        '二次加工管理-打卡审核',
-        '二次加工管理-登记工时-审核',
-    ];
-
-    protected $authNames=[
-        '人事管理',
-        '人事管理-门卫审核',
-        '人事管理-任务审核',
-        '人事管理-录入补卡',
-        '人事管理-打卡',
-        '工作组',
-        '工作组-查询',
-        '工作组-编辑',
-        '工作组-录入',
-        '工作组-删除',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->deleteAuthNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-        foreach ($this->deleteAuthNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-}

+ 0 - 1
database/migrations/2020_05_22_172739_create_labor_companies_table.php

@@ -18,7 +18,6 @@ class CreateLaborCompaniesTable extends Migration
             $table->string('name')->unique()->nullable()->comment('劳务所名称');
             $table->timestamps();
         });
-        //(new LaborCompany(['name'=>'其他']))->save();
     }
 
     /**

+ 0 - 49
database/migrations/2020_05_25_091228_add_labor_company_authority.php

@@ -1,49 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddLaborCompanyAuthority extends Migration
-{
-
-    protected $authNames=[
-
-        '人事管理-临时工报表',
-        '劳务所',
-        '劳务所-查询',
-        '劳务所-编辑',
-        '劳务所-录入',
-        '劳务所-删除',
-        '仓库',
-        '仓库-查询',
-        '仓库-编辑',
-        '仓库-录入',
-        '仓库-删除',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 11
database/migrations/2020_05_25_093853_change_waybills_table.php

@@ -1,16 +1,11 @@
 <?php
 
-use App\Authority;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
 class ChangeWaybillsTable extends Migration
 {
-
-    protected $authNames=[
-        "运输管理-发运"
-    ];
     /**
      * Run the migrations.
      *
@@ -23,9 +18,6 @@ class ChangeWaybillsTable extends Migration
             $table->bigInteger('amount')->nullable()->comment('件数');
             $table->string('inquire_tel')->nullable()->comment('查件电话');
         });
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
     }
 
     /**
@@ -40,8 +32,5 @@ class ChangeWaybillsTable extends Migration
             $table->dropColumn('amount');
             $table->dropColumn('inquire_tel');
         });
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
     }
 }

+ 0 - 37
database/migrations/2020_05_29_144440_add_inventory_authority.php

@@ -1,37 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddInventoryAuthority extends Migration
-{
-    protected $authNames=[
-        "库存管理",
-        "库存管理-动库报表"
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 38
database/migrations/2020_06_04_162259_add_order_authority.php

@@ -1,38 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddOrderAuthority extends Migration
-{
-    protected $authNames=[
-        "订单管理",
-        "订单管理-查询",
-        "订单管理-批量备注",
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 10
database/migrations/2020_06_12_093011_change_authorities_table.php

@@ -1,6 +1,5 @@
 <?php
 
-use App\Authority;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
@@ -8,9 +7,6 @@ use Illuminate\Support\Facades\Schema;
 class ChangeAuthoritiesTable extends Migration
 {
 
-    protected $authNames=[
-       "退货管理-到付费用"
-    ];
     /**
      * Run the migrations.
      *
@@ -21,9 +17,6 @@ class ChangeAuthoritiesTable extends Migration
         Schema::table('authorities',function (Blueprint $table){
             $table->enum('permission',['允许','禁止'])->after('alias_name')->default('允许')->comment('许可');
         });
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name,'permission'=>'禁止']))->save();
-        }
     }
 
     /**
@@ -36,8 +29,5 @@ class ChangeAuthoritiesTable extends Migration
         Schema::table('authorities',function (Blueprint $table){
             $table->dropColumn('permission');
         });
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
     }
 }

+ 0 - 3
database/migrations/2020_06_12_135840_create_custom_fields_table.php

@@ -1,6 +1,5 @@
 <?php
 
-use App\Authority;
 use App\CustomField;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +24,6 @@ class CreateCustomFieldsTable extends Migration
             $table->string('condition_value')->nullable()->comment('条件字段值,用来作为定义该字段权限和显示名的依据');
             $table->timestamps();
         });
-        if(!Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first())(new Authority(['name'=>'退货管理-查询-客户定义-爱奇艺','alias_name'=>'退货管理-查询-客户定义-爱奇艺']))->save();
-        $authority=Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first();
         CustomField::create(['table'=>'rejected_bills','field'=>'common_01','present_name'=>'寄件方省','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
         CustomField::create(['table'=>'rejected_bills','field'=>'common_02','present_name'=>'退件重量','authority_id'=>$authority['id'],'condition_field'=>'id_owner','condition_value'=>'66']);
     }

+ 0 - 11
database/migrations/2020_06_16_171741_create_upload_files_table.php

@@ -1,16 +1,11 @@
 <?php
 
-use App\Authority;
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
 
 class CreateUploadFilesTable extends Migration
 {
-    protected $authNames=[
-        "运输管理-图片上传",
-        "运输管理-图片删除"
-    ];
     /**
      * Run the migrations.
      *
@@ -25,9 +20,6 @@ class CreateUploadFilesTable extends Migration
             $table->string('type')->nullable()->comment('类型');
             $table->timestamps();
         });
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
     }
 
     /**
@@ -38,8 +30,5 @@ class CreateUploadFilesTable extends Migration
     public function down()
     {
         Schema::dropIfExists('upload_files');
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
     }
 }

+ 0 - 37
database/migrations/2020_06_16_173559_add_authorrities_waybillmanagement_freigt.php

@@ -1,37 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddAuthorritiesWaybillmanagementFreigt extends Migration
-{
-    protected $authNames=[
-        "运输管理-运费",
-        '运输管理-置顶'
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            \App\Authority::create(['name'=>$name,'alias_name'=>$name,'permission'=>'允许']);
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
-        }
-    }
-}

+ 0 - 37
database/migrations/2020_06_18_145606_add_authorities_order_update_table.php

@@ -1,37 +0,0 @@
-<?php
-
-use App\Authority;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddAuthoritiesOrderUpdateTable extends Migration
-{
-
-    protected $authNames=[
-        "订单管理-编辑",
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            if(!Authority::where('name',$name)->first())(new Authority(['name'=>$name,'alias_name'=>$name]))->save();
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-    }
-}

+ 0 - 1
database/migrations/2020_06_24_145928_add_storage_public_link.php

@@ -16,7 +16,6 @@ class AddStoragePublicLink extends Migration
         exec('php artisan storage:link');
         $path_str = substr(app_path(),0,strripos(app_path(), DIRECTORY_SEPARATOR));
         exec('mkdir '.$path_str.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'files');
-//        exec('mkdir ./storage/app/public/files');
     }
 
     /**

+ 0 - 36
database/migrations/2020_06_28_162934_add_authorrities_personal_duty_check_type.php

@@ -1,36 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-class AddAuthorritiesPersonalDutyCheckType extends Migration
-{
-    protected $authNames=[
-       '人事管理-审核类型',
-    ];
-
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        foreach ($this->authNames as $name){
-            \App\Authority::create(['name'=>$name,'alias_name'=>$name,'permission'=>'允许']);
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->authNames as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
-        }
-    }
-}

+ 0 - 58
database/migrations/2020_06_30_111337_change_auth_hr_verifies.php

@@ -1,58 +0,0 @@
-<?php
-
-use App\Authority;
-use App\Unit;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class ChangeAuthHrVerifies extends Migration
-{
-    protected $addNames=[
-        '人事管理-组长审核',
-    ];
-    protected $changeNames=[
-        ['人事管理-审核','人事管理-门卫审核'],
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Authority::where('name','人事管理-门卫审核')->first();
-        foreach ($this->addNames as $namePack){
-            if(!Authority::where('name',$namePack)->first())(new Authority(['name'=>$namePack,'alias_name'=>$namePack]))->save();
-        }
-        //修改或没有则添加
-        foreach ($this->changeNames as $namePack){
-            $authority=Authority::where('name',$namePack[0])->orWhere('name',$namePack[1])->first();
-            if(!$authority){
-                (new Authority(['name'=>$namePack[1],'alias_name'=>$namePack[1]]))->save();
-            }elseif($authority['name']==$namePack[0]){
-                $authority['name']=$namePack[1];
-                $authority['alias_name']=$namePack[1];
-                $authority->save();
-            }
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        foreach ($this->addNames as $name){
-            Authority::where('name',$name)->delete();
-        }
-        //改回旧的
-        foreach ($this->changeNames as $namePack){
-            $authority=Authority::where('name',$namePack[1])->first();
-            $authority['name']=$namePack[0];
-            $authority->save();
-        }
-    }
-}

+ 0 - 9
database/migrations/2020_07_02_135957_add_authority_table_process_rollback.php

@@ -7,9 +7,6 @@ use Illuminate\Support\Facades\Schema;
 class AddAuthorityTableProcessRollback extends Migration
 {
 
-    protected $authNames=[
-        '二次加工管理-回滚',
-    ];
     /**
      * Run the migrations.
      *
@@ -17,9 +14,6 @@ class AddAuthorityTableProcessRollback extends Migration
      */
     public function up()
     {
-        foreach ($this->authNames as $name){
-            \App\Authority::create(['name'=>$name,'alias_name'=>$name,'permission'=>'允许']);
-        }
         Schema::table('processes',function (Blueprint $table){
             $table->softDeletes();
         });
@@ -36,9 +30,6 @@ class AddAuthorityTableProcessRollback extends Migration
      */
     public function down()
     {
-        foreach ($this->authNames as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
-        }
         Schema::table('processes',function (Blueprint $table){
             $table->dropSoftDeletes();
         });

+ 0 - 48
database/migrations/2020_07_06_111337_change_auth_order_index.php

@@ -1,48 +0,0 @@
-<?php
-
-use App\Authority;
-use App\Unit;
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class ChangeAuthOrderIndex extends Migration
-{
-    protected $changeNames=[
-        ['订单管理-发运','订单管理-查询'],
-    ];
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        //修改或没有则添加
-        foreach ($this->changeNames as $namePack){
-            $authority=Authority::where('name',$namePack[0])->orWhere('name',$namePack[1])->first();
-            if(!$authority){
-                (new Authority(['name'=>$namePack[1],'alias_name'=>$namePack[1]]))->save();
-            }elseif($authority['name']==$namePack[0]){
-                $authority['name']=$namePack[1];
-                $authority['alias_name']=$namePack[1];
-                $authority->save();
-            }
-        }
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //改回旧的
-        foreach ($this->changeNames as $namePack){
-            $authority=Authority::where('name',$namePack[1])->first();
-            $authority['name']=$namePack[0];
-            $authority->save();
-        }
-    }
-}

+ 0 - 24
database/migrations/2020_07_06_160500_create_operator_logs_table_and_add_authority_and_change_processes_column_status.php

@@ -6,18 +6,6 @@ use Illuminate\Support\Facades\Schema;
 
 class CreateOperatorLogsTableAndAddAuthorityAndChangeProcessesColumnStatus extends Migration
 {
-    protected $authNames=[
-        '教程',
-        '二次加工管理-审核',
-        '二次加工管理-质量验收',
-        '二次加工管理-交接完成',
-        '二次加工管理-修改价格',
-        '二次加工管理-组长确认',
-        '二次加工管理-财务确认',
-    ];
-    protected $authNamesDel=[
-        '二次加工管理-验收完成'
-    ];
     /**
      * Run the migrations.
      *
@@ -33,12 +21,6 @@ class CreateOperatorLogsTableAndAddAuthorityAndChangeProcessesColumnStatus exten
             $table->string('operation')->nullable()->comment('操作');
             $table->timestamp('created_at');
         });
-        foreach ($this->authNames as $name){
-            \App\Authority::create(['name'=>$name,'alias_name'=>$name]);
-        }
-        foreach ($this->authNamesDel as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
-        }
         Schema::table('processes',function (Blueprint $table){
             $table->dropColumn('status');
         });
@@ -55,12 +37,6 @@ class CreateOperatorLogsTableAndAddAuthorityAndChangeProcessesColumnStatus exten
     public function down()
     {
         Schema::dropIfExists('operator_logs');
-        foreach ($this->authNames as $name){
-            \App\Authority::where(['name'=>$name,'alias_name'=>$name])->delete();
-        }
-        foreach ($this->authNamesDel as $name){
-            \App\Authority::create(['name'=>$name,'alias_name'=>$name]);
-        }
         Schema::table('processes',function (Blueprint $table){
             $table->dropColumn('status');
         });

Some files were not shown because too many files changed in this diff