Procházet zdrojové kódy

需求修复的大量提交
二次加工部分

Zhouzhendong před 3 roky
rodič
revize
8c8666ffd8

+ 2 - 0
app/Http/Controllers/InventoryController.php

@@ -64,6 +64,8 @@ class InventoryController extends Controller
         }else return "暂时关闭,如需开启请联系管理员";
     }
     public function exportAllInventory(Request $request){
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
         if(!Gate::allows("库存管理-库存")){ return view("denied");  }
         if ($request->checkAllSign){
             $params = $request->input();

+ 23 - 16
app/Http/Controllers/ProcessController.php

@@ -100,7 +100,7 @@ class ProcessController extends Controller
 
     //驳回二次加工单
     public function reject($id){
-        if(!Gate::allows('二次加工管理-接单与驳回')){ return redirect(url('/'));  }
+        //if(!Gate::allows('二次加工管理-接单与驳回')){ return redirect(url('/'));  }
         $process=Process::select('id','status')->find($id);
         $process->status="已驳回";
         $process->update();
@@ -110,7 +110,7 @@ class ProcessController extends Controller
     }
     //接单
     public function receive($id){
-        if(!Gate::allows('二次加工管理-接单与驳回')){ return ["success"=>false,"data"=>"无权操作"];  }
+        //if(!Gate::allows('二次加工管理-接单与驳回')){ return ["success"=>false,"data"=>"无权操作"];  }
         /** @var Process|\stdClass $process */
         $process=Process::query()->select('id','status','amount','designate_id')->find($id);
         if ($process && $process->designate_id && $process->designate_id!=Auth::id())return ["success"=>false,"data"=>"无权操作"];
@@ -444,13 +444,17 @@ class ProcessController extends Controller
     {
         if(!Gate::allows('二次加工管理-录入')){ return view("exception.authority");  }
         $processMethods=ProcessMethod::query()->get();
-        $users = User::query()->whereNotNull("email")->whereHas("roles",function ($query){
-            /** @var Builder $query */
-            $query->whereHas("authorities",function($query){
-                /** @var Builder $query */
-                $query->where("alias_name","二次加工管理-接单与驳回");
-            });
-        })->orWhereIn("name",config("users.superAdmin"))->get();
+        $users = User::query()->whereNotNull("email")->get();
+        /*
+         * ->whereHas("roles",function ($query){
+             @var Builder $query
+                $query->whereHas("authorities",function($query){
+                     @var Builder $query
+                    $query->where("alias_name","二次加工管理-接单与驳回");
+                });
+            })->orWhereIn("name",config("users.superAdmin"))
+         *
+         * */
         return view('process/create',['processMethods'=>$processMethods,'process'=>null,"users"=>$users]);
     }
 
@@ -628,13 +632,16 @@ class ProcessController extends Controller
             }]);
         }])->find($id);
         $processMethods=ProcessMethod::get();
-        $users = User::query()->whereNotNull("email")->whereHas("roles",function ($query){
-            /** @var Builder $query */
-            $query->whereHas("authorities",function($query){
-                /** @var Builder $query */
-                $query->where("alias_name","二次加工管理-接单与驳回");
-            });
-        })->orWhereIn("name",config("users.superAdmin"))->get();
+        $users = User::query()->whereNotNull("email")->get();
+        /*
+         * ->whereHas("roles",function ($query){
+             @var Builder $query
+        $query->whereHas("authorities",function($query){
+             @var Builder $query
+            $query->where("alias_name","二次加工管理-接单与驳回");
+        });
+    })->orWhereIn("name",config("users.superAdmin"))
+         * */
         return view('process.create',['process'=>$process,'processMethods'=>$processMethods,"users"=>$users]);
     }
 

+ 2 - 53
app/Http/Controllers/TestController.php

@@ -53,61 +53,10 @@ class TestController extends Controller
             dd("方法不存在");
         }
     }
-    public function a1(){
-        dd(phpinfo());
-        dd(DB::table('BAS_CODES')->select('code', 'codename_c')->where('codeid', 'SO_STS')->orderBy('code', 'asc')->sql());
-        $response = Http::post("https://api.baoshi56.com/api/flux/getList", [
-            "sql" => "SELECT * FROM BAS_CODES WHERE CODEID = 'ABC'"
-        ]);
-        dd(json_decode($response->body(), true)->data);
-    }
     public function test(Request $request)
     {
-        dd(Hash::make("zhao123456"));
-    }
-
-    public function syncOrder($code)
-    {
-        $orderHeaders = app(OracleDOCOrderHeaderService::class)->getQuery()->where('DOC_Order_Header.WaveNo',$code)->get();
-        app(OrderService::class)->syncOrderByWMSOrderHeaders($orderHeaders);
-        app(OrderCommodityService::class)->syncOrderCommodity($orderHeaders);
-        $this->syncOrderBin($code);
-    }
-    public function syncOrderBin($code)
-    {
-        $wave = DB::connection("oracle")->selectOne(DB::raw("select * from DOC_WAVE_HEADER where WAVENO = ?"), [$code]);
-        if (!$wave) return;
-        $owner = app("OwnerService")->codeGetOwner($wave->customerid);
-        $obj = [
-            "wms_status" => $this->wms_status($wave),
-            "wms_type" => $wave->descr,
-            "created_at" => date("Y-m-d H:i:s"),
-            "wms_created_at" => $wave->addtime,
-            "updated_at" => $wave->edittime,
-            "owner_id" => $owner->id,
-        ];
-        $batch = Batch::query()->where("code", $code)->first();
-        if (!$batch) {
-            $obj["code"] = $code;
-            $batch = Batch::query()->create($obj);
-        } else {
-            Batch::query()->where("code", $code)->update($obj);
-        }
-        $order_nos = array_column(DB::connection("oracle")->select(DB::raw("select orderno from DOC_WAVE_DETAILS where WAVENO = ?"), [$code]), "orderno");
-
-        Order::query()->whereIn("code", $order_nos)->update(["batch_id" => $batch->id]);
-
-        Order::query()->with(["batch", "bin"])->whereIn("code", $order_nos)->get()->each(function ($order) {
-            if (!$order->bin) {
-                $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"), [$order->batch->code, $order->code]);
-                if ($bin) {
-                    OrderBin::query()->create([
-                        'order_id' => $order->id,
-                        'number' => $bin->seqno,
-                    ]);
-                }
-            }
-        });
+        app("UserService")->removeGroupUserBindOwner([21], 6);
+        //app("UserService")->insertGroupUserBindOwner($insertGroup, $owner->id);
     }
 }
 

+ 2 - 2
app/Http/Controllers/api/thirdPart/flux/WaybillController.php

@@ -181,10 +181,10 @@ class WaybillController extends Controller
         }
         $responseJson = $response->json();
         if(!$responseJson||!isset($responseJson['Response'])||!$responseJson['Response']['return']['returnFlag']=='1'){
-            Controller::logS(__METHOD__,'error_'.__FUNCTION__,"向WMS提交运单失败!!SO单号:{$waybill['wms_bill_number']}。提交:{$json},返回:{$response->body()}, URL:{$url}",Auth::user()['id']);
+            Controller::logS(__METHOD__,'error_'.__FUNCTION__,"向WMS提交运单失败!!SO单号:{$waybill['wms_bill_number']}。提交:{$json},返回:{$response->body()}, URL:{$url}",0);
             return false;
         }
-        Controller::logS(__METHOD__,''.__FUNCTION__,"向WMS提交运单成功,SO单号:{$waybill['wms_bill_number']}。返回:{$response->body()}",Auth::user()['id']);
+        Controller::logS(__METHOD__,''.__FUNCTION__,"向WMS提交运单成功,SO单号:{$waybill['wms_bill_number']}。返回:{$response->body()}",0);
         return true;
 
     }

+ 5 - 1
app/Process.php

@@ -16,7 +16,8 @@ class Process extends Model
     use ModelTimeFormat;
     use SoftDeletes;
     protected $fillable=[
-        'code','owner_id','process_method_id','unit_price','status','remark','balance_remark','amount','completed_amount','created_at','updated_at','deleted_at',"designate_id"
+        'code','owner_id','process_method_id','unit_price','status','remark','balance_remark','amount','completed_amount',
+        'created_at','updated_at','deleted_at',"designate_id"
     ];
     protected $appends=[
         'owner_name','process_method_name',
@@ -66,6 +67,9 @@ class Process extends Model
         return $this->hasOne('App\Sign','signable_id','id')
             ->where('signable_type','processes')->where('field','update_unit_price_value');
     }
+    public function designate() {
+        return $this->belongsTo('App\User','designate_id','id');
+    }
 
 
     public function getOwnerNameAttribute()

+ 14 - 2
app/Services/ObligationService.php

@@ -20,9 +20,11 @@ class ObligationService
     }
     public function getDepartmentIds($owner_id): array
     {
-        return DepartmentObligationOwner::query()
+        return DepartmentObligationOwner::query()->select("department_id")
             ->where('owner_id',$owner_id)
-            ->whereNull('failure_time')->pluck('department_id')->toArray();
+            ->whereNull('failure_time')
+            ->groupBy("department_id")
+            ->pluck('department_id')->toArray();
     }
     public function recombineCodeIdArr(){
         $obligations=$this->getSelection()->toArray();
@@ -31,6 +33,7 @@ class ObligationService
     public function createOrUpdate(array $param){
         $obligation=$this->recombineCodeIdArr();
         $owner=Owner::query()->with('departmentObligationOwner')->find($param['id']);
+        $oldGroupIdArr = $this->getDepartmentIds($owner->id);
         $departmentObligationOwner=$owner->departmentObligationOwner->toArray()??[];
         $time=Carbon::now()->subMonths(-1)->startOfMonth()->startOfDay()->toDateTimeString();
         if (empty($departmentObligationOwner)){//第一次新增 部门和职能及货主关联
@@ -157,9 +160,18 @@ class ObligationService
                 }
             }
         }
+        $newGroupIdArr = $this->getDepartmentIds($owner->id);
+        $removeGroup = array_diff($oldGroupIdArr, $newGroupIdArr);// 要移除的组
+        $insertGroup = array_diff($newGroupIdArr, $oldGroupIdArr);// 要新增的组
+        app("UserService")->removeGroupUserBindOwner($removeGroup, $owner->id);
+        app("UserService")->insertGroupUserBindOwner($insertGroup, $owner->id);
         return Owner::query()->with('departmentObligationOwner')->find($param['id']);
     }
 
+    public function separatingUniqueNode($source, $target) {
+
+    }
+
     public function getObligationUnderOwner($ids):array
     {
         if (!$ids || count($ids) == 0){

+ 7 - 0
app/Services/ProcessService.php

@@ -55,6 +55,13 @@ class ProcessService
         if (!($params['is_accomplish'] ?? false)){
             $processes=$processes->where('status','!=','交接完成');
         }else unset($params['is_accomplish']);
+        if ($params["designate"] ?? false) {
+            $designate = $params["designate"];
+            $processes=$processes->whereHas('designate', function ($builder)use($designate) {
+                $builder->where('name','like','%'.$designate.'%');
+            });
+            unset($params['designate']);
+        }
         $columnQueryRules=[
             'date_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
             'date_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],

+ 55 - 0
app/Services/UserService.php

@@ -194,4 +194,59 @@ class UserService
         $ownerIds = array_unique($ownerIds);
         $user->owners()->sync($ownerIds);
     }
+
+    /**
+     * 获取工作组关联用户ID
+     *
+     * @param $groupIds
+     * @return array
+     */
+    private function getGroupUser($groupIds) {
+        return User::query()->select("id")->whereHas("userWorkgroups", function ($builder) use($groupIds) {
+            $builder->whereIn("id", $groupIds);
+        })->pluck("id")->toArray();
+    }
+
+    /**
+     * 移除工作组用户的绑定货主
+     *
+     * @param array $groupIds
+     * @param $ownerId
+     */
+    public function removeGroupUserBindOwner($groupIds, $ownerId) {
+        if (!$groupIds || count($groupIds) == 0) {
+            return;
+        }
+        $userId = $this->getGroupUser($groupIds);
+        if (!$userId || count($userId) == 0) {
+            return;
+        }
+        DB::table("owner_user")->where("owner_id", $ownerId)
+            ->whereIn("user_id", $userId)
+            ->delete();
+    }
+
+    /**
+     * 新增工作组用户的绑定货主
+     *
+     * @param $groupIds
+     * @param $ownerId
+     */
+    public function insertGroupUserBindOwner($groupIds, $ownerId) {
+        if (!$groupIds || count($groupIds) == 0) {
+            return;
+        }
+        $userId = User::query()->select("id")
+            ->whereHas("owners", function ($builder)use($ownerId) {
+                $builder->where("id", '!=' , $ownerId);
+            })->whereHas("userWorkgroups", function ($builder) use($groupIds) {
+                $builder->whereIn("id", $groupIds);
+            })->pluck("id");
+        if (!$userId || $userId->count() == 0) {
+            return;
+        }
+        foreach ($userId as $user) {
+            DB::insert("INSERT INTO owner_user(owner_id,user_id) VALUES ({$ownerId},{$user->id})");
+        }
+    }
 }

+ 20 - 0
config/database.php

@@ -123,6 +123,26 @@ return [
             ]) : [],
         ],
 
+        'aliyunMysqlSys' => [
+            'driver' => 'mysql',
+            'url' => env('DATABASE_URL'),
+            'host' => 'rm-uf6f5v208b07hp198bo.mysql.rds.aliyuncs.com',
+            'port' => '3306',
+            'database' => 'system',
+            'username' => 'root',
+            'password' => 'baoshiSYSTEM123!',
+            'unix_socket' => env('DB_SOCKET', ''),
+            'charset' => 'utf8mb4',
+            'collation' => 'utf8mb4_unicode_ci',
+            'prefix' => '',
+            'prefix_indexes' => true,
+            'strict' => false,
+            'engine' => null,
+            'options' => extension_loaded('pdo_mysql') ? array_filter([
+                \PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
+            ]) : [],
+        ],
+
         'was_test' => [
             'driver' => 'mysql',
             'host' => '101.133.135.193',

+ 3 - 1
resources/views/order/index/index.blade.php

@@ -104,7 +104,9 @@
                             window.tempTip.setDuration(2000);
                             if (res.data.data.length>0) {
                                 this.models.unshift.apply(this.models,res.data.data);
-                                if (this.models.length>50) this.models = this.models.split(50);
+                                if (this.models.length>50) {
+                                    this.models = this.models.slice(50);
+                                }
                                 window.tempTip.showSuccess("导入成功!");
                             }else {
                                 window.tempTip.setDuration(3000);

+ 1 - 0
resources/views/process/index.blade.php

@@ -546,6 +546,7 @@
                         {name: 'commodity_barcode', type: 'input', tip: '可支持多商品条码,模糊搜索可在两侧增加百分号(%)进行', placeholder: '商品条码'},
                         {name: 'code', type: 'input', tip: '可支持多任务号,模糊搜索可在两侧增加百分号(%)进行', placeholder: '任务号'},
                         {name: 'is_accomplish', type: 'checkbox', data: [{name: 'sign', value: '显示交接完成的记录'}]},
+                        {name: 'designate', type: 'input', tip: '默认模糊', placeholder: '指定接单人'},
                     ],
                 ];
                 this.form = new query({

+ 1 - 1
resources/views/rejected/record.blade.php

@@ -287,7 +287,7 @@
                     if (!res.success){
                         status = false;
                         if (res.data==="unique"){
-                            this.buildToast(false,logisticNumber);
+                            this.buildToast(true,logisticNumber);
                             return;
                         }
                     }