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

Merge branch 'zzd' of ssh://baoshi56.com:10022/var/git/bswas into Haozia

haozi 5 лет назад
Родитель
Сommit
d82c222d10

+ 155 - 3
app/Http/Controllers/TestController.php

@@ -24,6 +24,7 @@ use Carbon\Carbon;
 use Endroid\QrCode\Response\QrCodeResponse;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use function PHPSTORM_META\map;
 use Zttp\Zttp;
 
 class TestController extends Controller
@@ -135,10 +136,161 @@ class TestController extends Controller
     }
 
     public function test1(){
-        $str=",15984854564564,154484645684,874545454   4565546,";
-        $str=trim($str,',');
-        dd($str);
+        $s="IXCM";
+        $arr=str_split($s);
+        $temp=["I"=>1,"V"=>5,"X"=>10,"L"=>50,"C"=>100,"D"=>500,"M"=>1000];
+        $result=0;
+        for($i=0;$i<count($arr);$i++){
+            if($i!=count($arr)-1){
+                if($arr[$i]=="I"){
+                    if($arr[$i+1]=="V" || $arr[$i+1]=="X"){
+                        $result-=$temp["I"];
+                        continue;
+                    }
+                }
+                if($arr[$i]=="X"){
+                    if($arr[$i+1]=="L" || $arr[$i+1]=="C"){
+                        if($i>0&&$arr[$i-1]=="I"){$result+=$temp[$arr[$i]];continue;}
+                        $result-=$temp["X"];
+                        continue;
+                    }
+                }
+                if($arr[$i]=="C"){
+                    if($arr[$i+1]=="D" || $arr[$i+1]=="M"){
+                        if($i>0&&$arr[$i-1]=="X"){
+                            if ($i>1&&$arr[$i-2]=="I"){
+                                $result-=$temp["C"];
+                                continue;
+                            }
+                            $result+=$temp[$arr[$i]];continue;
+                        }
+                        $result-=$temp["C"];
+                        continue;
+                    }
+                }
+            }
+            $result+=$temp[$arr[$i]];
+        }
+        if($result<1 || $result>3999)$result=0;
+        return $result;
     }
+    public function test2(){
+        $s="VI";
+        $arr=str_split($s);
+        $temp=["I"=>1,"V"=>5,"X"=>10,"L"=>50,"C"=>100,"D"=>500,"M"=>1000];
+        $result=0;
+        $sign=false;
+        for($i=0;$i<count($arr);$i++){
+            if($i!=count($arr)-1){
+                if($arr[$i]=="I"){
+                    if($arr[$i+1]=="V" || $arr[$i+1]=="X"){
+                        $result-=$temp["I"];
+                        $sign=true;
+                        continue;
+                    }
+                }
+                if($arr[$i]=="X"){
+                    if($arr[$i+1]=="L" || $arr[$i+1]=="C"){
+                        if($sign){$result+=$temp[$arr[$i]];$sign=false;continue;}
+                        $result-=$temp["X"];
+                        $sign=true;
+                        continue;
+                    }
+                }
+                if($arr[$i]=="C"){
+                    if($arr[$i+1]=="D" || $arr[$i+1]=="M"){
+                        if($sign){
+                            $sign=false;
+                            $result+=$temp[$arr[$i]];continue;
+                        }
+                        $result-=$temp["C"];
+                        $sign=true;
+                        continue;
+                    }
+                }
+            }
+            $result+=$temp[$arr[$i]];
+            if ($sign)$sign=false;
+        }
+        if($result<1 || $result>3999)$result=0;
+        return $result;
+    }
+    public function test3()
+    {
+        $strs=["auibh","aopk","bikon"];
+        if (!$strs[0])return "";
+        $len=strlen($strs[0]);
+        for ($i=1;$i<count($strs);$i++){
+            if ($len<1)break;
+            for ($j=0;$j<$len;$j++){
+                if ($strs[$i][$j]!=$strs[0][$j]){
+                    if ($j==0)return "";
+                    break;
+                }
+                $sum=$j+1;
+            }
+            $len=isset($sum)?$sum:0;
+        }
+        return substr($strs[0],0,$len);
+    }
+    public function test4(){
+        $s="{([{()()[]{}}])[{()()[}]{}}](){[]}";
+        $map = [
+            ")" => "(",
+            "}" => "{",
+            "]" => "[",
+        ];
+
+        $len = strlen($s);
+        $stack = [];
+        if ($len%2!=0)dd(false);
+        //s中出现map的key则弹出,没有出现则入栈
+        for ($i =0; $i<$len; $i++) {
+            var_dump("data:".$s[$i]);
+            if (isset($map[$s[$i]])){
+                //s中出现map的key:如果能找到对应的map的值 (,{,[ 则说明有配对,则弹出
+                if (isset($stack)  && $stack[0] == $map[$s[$i]]) {
+                    array_shift($stack);
+                } else { //仅找到后面的一部分,说明是不匹配的
+                    dd(false);
+                }
+                var_dump("value1:".$map[$s[$i]]);
+                var_dump($stack);
+            } else {
+                array_unshift($stack, $s[$i]);
+                var_dump("value2:".$s[$i]);
+                var_dump($stack);
+            }
+        }
 
+        if (count($stack) > 0) {
+            dd(false);
+        }
+        dd(true);
+        //利用栈的先进后出 一个正确的括号组对应都为1对1或N对N
+        // 先进后出“([{”入栈,")]}"出栈,轮询到出栈元素去映射栈顶,符合出栈,不符合直接返回
+        //依次轮询 如果映射正确那么最后栈为空栈 否则返回false
 
+        /*
+        $r=[];
+        $sTemp=["("=>1,"["=>2,"{"=>3,")"=>-1,"]"=>-2,"}"=>-3];
+        for ($i=0;$i<strlen($s);$i++){
+            if ($i!=strlen($s)-1){
+                if (($sTemp[$s[$i]]+$sTemp[$s[$i+1]])==0){
+                    $i++;
+                    var_dump($s[$i],$i);
+                    continue;
+                }
+            }
+            array_push($r,$sTemp[$s[$i]]);
+        }
+        $sum=count($r);
+        if ($sum==0)return "a";
+        if ($sum%2!=0)return "b";
+        $svg=$sum/2;
+        for ($i=0;$i<$svg;$i++){
+            if ($r[$i]>0&&$r[$i]+$r[$sum-1-$i]!=0)return "b";
+        }
+        return "a";*/
+    }
 }

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

@@ -6,6 +6,7 @@ use App\Carrier;
 use App\City;
 use App\Http\Controllers\Controller;
 use App\Owner;
+use App\Unit;
 use App\Waybill;
 use App\OraccleBasCustomer;
 use App\WMSWaybill;
@@ -39,7 +40,12 @@ class WaybillController extends Controller
                     ->setEncodingOptions(JSON_UNESCAPED_UNICODE);
             }
             if(isset($receiveInputting['order_list'])&&$receiveInputting['order_list'])
+                $warehouseWeight=0;
+                $warehouseWeightOther=0;
                 foreach ($receiveInputting['order_list'] as $orderInputting){
+                    if ($orderInputting['Qtyordered_each'])$warehouseWeight += $orderInputting['Qtyordered_each'];
+                    if ($orderInputting['GrossWeight'])$warehouseWeightOther +=$orderInputting['GrossWeight'];
+                    if (!$orderInputting['GrossWeight'] && $orderInputting['NetWeight']) $warehouseWeightOther +=$orderInputting['NetWeight'];
                     $orderInputting['OrderNo']=$receiveInputting['OrderNo'];
                     if(!WMSWaybillOrder::create($orderInputting)){
                         Controller::logS(__METHOD__,'error_'.__FUNCTION__,'运单订单行WMS写入错误'.'|'.json_encode($orderInputting));
@@ -73,6 +79,16 @@ class WaybillController extends Controller
                 'source_bill'=>$receiveInputting['ReservedField01']??'',
                 'destination_city_id'=>$city['id'],
             ]);
+            if (isset($warehouseWeight)){
+                $waybill->warehouse_weight=$warehouseWeight;
+                $unit=Unit::where('name','m³')->first();
+                if ($unit)$waybill->warehouse_weight_unit=$unit->id;
+            }
+            if (isset($warehouseWeightOther)){
+                $waybill->warehouse_weight_other=$warehouseWeightOther;
+                $unit=Unit::where('name','kg')->first();
+                if ($unit)$waybill->warehouse_weight_unit_other=$unit->id;
+            }
             $waybill->save();
             if ($waybill->type=='直发车'){
                 $waybill_number='BSZF'.date ("ymd").str_pad($waybill->id>99999?$waybill->id%99999:$waybill->id,4,"0",STR_PAD_LEFT);

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

@@ -0,0 +1,47 @@
+<?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.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('waybills',function (Blueprint $table){
+            $table->string('mileage')->nullable()->comment('里程');
+            $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();
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('waybills',function (Blueprint $table){
+            $table->dropColumn('mileage');
+            $table->dropColumn('amount');
+            $table->dropColumn('inquire_tel');
+        });
+        foreach ($this->authNames as $name){
+            Authority::where('name',$name)->delete();
+        }
+    }
+}

+ 4 - 0
resources/views/waybill/menu.blade.php

@@ -10,6 +10,10 @@
             <li class="nav-item">
                 <a class="nav-link" href="{{url('waybill/create/ZX')}}" :class="{active:isActive('create',2)}">录入</a>
             </li> @endcan
+            @can('运输管理-发运')
+            <li class="nav-item">
+                <a class="nav-link" href="{{url('waybill/create/ZX')}}" :class="{active:isActive('create',2)}">发运</a>
+            </li> @endcan
             {{$slot}}
             <li class="nav-item">
                 <a class="nav-link text-dark" href="{{url('waybill/relating')}}" :class="{active:isActive('relating',2)}">相关设置</a>