فهرست منبع

Merge branch 'fyy' of http://121.41.102.225:3000/gogs/jf_admin2.0 into fyy

root 2 سال پیش
والد
کامیت
7e36e8480b

+ 158 - 5
.idea/workspace.xml

@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="b5852db3-28ab-419d-82cf-b6c0f6b99397" name="变更" comment="">
+    <list default="true" id="b5852db3-28ab-419d-82cf-b6c0f6b99397" name="变更" comment="fyy">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Api/TechnologyController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Api/TechnologyController.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/Service/TechnologyService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/TechnologyService.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Api/FyyOrderController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Api/FyyOrderController.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Service/FyyOrderService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/FyyOrderService.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Service/FyySqlServerService.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Service/FyySqlServerService.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -17,8 +18,21 @@
     <execution />
   </component>
   <component name="Git.Settings">
+    <option name="RECENT_BRANCH_BY_REPOSITORY">
+      <map>
+        <entry key="$PROJECT_DIR$" value="master" />
+      </map>
+    </option>
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
+  <component name="GitSEFilterConfiguration">
+    <file-type-list>
+      <filtered-out-file-type name="LOCAL_BRANCH" />
+      <filtered-out-file-type name="REMOTE_BRANCH" />
+      <filtered-out-file-type name="TAG" />
+      <filtered-out-file-type name="COMMIT_BY_MESSAGE" />
+    </file-type-list>
+  </component>
   <component name="PhpWorkspaceProjectConfiguration">
     <include_path>
       <path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
@@ -124,7 +138,7 @@
     <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
     <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
     <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/app/Model" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
     <property name="nodejs_package_manager_path" value="npm" />
@@ -132,9 +146,9 @@
   </component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\phpstudy_pro\WWW\jf_admin2.0\app\Http\Controllers\Api" />
       <recent name="D:\phpstudy_pro\WWW\jf_admin2.0\app\Model" />
       <recent name="D:\phpstudy_pro\WWW\jf_admin2.0\app\Service" />
-      <recent name="D:\phpstudy_pro\WWW\jf_admin2.0\app\Http\Controllers\Api" />
     </key>
   </component>
   <component name="RunManager">
@@ -158,12 +172,123 @@
       <workItem from="1686021203384" duration="14595000" />
       <workItem from="1686099374239" duration="19779000" />
       <workItem from="1686185795830" duration="871000" />
+      <workItem from="1689295780705" duration="24032000" />
+      <workItem from="1689556098917" duration="6752000" />
+      <workItem from="1689641978733" duration="1873000" />
+      <workItem from="1689728531740" duration="5283000" />
+      <workItem from="1689837620108" duration="2910000" />
+      <workItem from="1689902257272" duration="2250000" />
+      <workItem from="1690035782838" duration="103000" />
+      <workItem from="1690077617133" duration="2033000" />
+      <workItem from="1690177920127" duration="10062000" />
+      <workItem from="1690247765342" duration="7116000" />
+      <workItem from="1690366710827" duration="615000" />
+      <workItem from="1690438112349" duration="1922000" />
+      <workItem from="1690521339535" duration="8403000" />
+      <workItem from="1690599347262" duration="1259000" />
+      <workItem from="1690603154164" duration="261000" />
+      <workItem from="1690605045643" duration="87000" />
+      <workItem from="1690625873796" duration="19000" />
+      <workItem from="1690720108633" duration="4211000" />
+      <workItem from="1690765520010" duration="19174000" />
+      <workItem from="1690852371561" duration="9800000" />
+      <workItem from="1690938513232" duration="8893000" />
+      <workItem from="1691023846625" duration="6703000" />
+      <workItem from="1691110525530" duration="2375000" />
+      <workItem from="1691382914683" duration="297000" />
+      <workItem from="1691489537588" duration="6041000" />
+      <workItem from="1691542453161" duration="8574000" />
+    </task>
+    <task id="LOCAL-00001" summary="jf2.0">
+      <created>1689228284141</created>
+      <option name="number" value="00001" />
+      <option name="presentableId" value="LOCAL-00001" />
+      <option name="project" value="LOCAL" />
+      <updated>1689228284141</updated>
+    </task>
+    <task id="LOCAL-00002" summary="fyy">
+      <created>1689316707927</created>
+      <option name="number" value="00002" />
+      <option name="presentableId" value="LOCAL-00002" />
+      <option name="project" value="LOCAL" />
+      <updated>1689316707927</updated>
+    </task>
+    <task id="LOCAL-00003" summary="fyy">
+      <created>1689732347737</created>
+      <option name="number" value="00003" />
+      <option name="presentableId" value="LOCAL-00003" />
+      <option name="project" value="LOCAL" />
+      <updated>1689732347737</updated>
+    </task>
+    <task id="LOCAL-00004" summary="fyy">
+      <created>1690248269830</created>
+      <option name="number" value="00004" />
+      <option name="presentableId" value="LOCAL-00004" />
+      <option name="project" value="LOCAL" />
+      <updated>1690248269831</updated>
+    </task>
+    <task id="LOCAL-00005" summary="fyy">
+      <created>1690249897762</created>
+      <option name="number" value="00005" />
+      <option name="presentableId" value="LOCAL-00005" />
+      <option name="project" value="LOCAL" />
+      <updated>1690249897762</updated>
+    </task>
+    <task id="LOCAL-00006" summary="fyy 测试接口">
+      <created>1690530139470</created>
+      <option name="number" value="00006" />
+      <option name="presentableId" value="LOCAL-00006" />
+      <option name="project" value="LOCAL" />
+      <updated>1690530139470</updated>
+    </task>
+    <task id="LOCAL-00007" summary="fyy 测试数据">
+      <created>1690532867480</created>
+      <option name="number" value="00007" />
+      <option name="presentableId" value="LOCAL-00007" />
+      <option name="project" value="LOCAL" />
+      <updated>1690532867480</updated>
+    </task>
+    <task id="LOCAL-00008" summary="fyy">
+      <created>1690953748966</created>
+      <option name="number" value="00008" />
+      <option name="presentableId" value="LOCAL-00008" />
+      <option name="project" value="LOCAL" />
+      <updated>1690953748966</updated>
+    </task>
+    <task id="LOCAL-00009" summary="fyy">
+      <created>1691042581507</created>
+      <option name="number" value="00009" />
+      <option name="presentableId" value="LOCAL-00009" />
+      <option name="project" value="LOCAL" />
+      <updated>1691042581507</updated>
+    </task>
+    <task id="LOCAL-00010" summary="fyy">
+      <created>1691489715976</created>
+      <option name="number" value="00010" />
+      <option name="presentableId" value="LOCAL-00010" />
+      <option name="project" value="LOCAL" />
+      <updated>1691489715976</updated>
     </task>
+    <task id="LOCAL-00011" summary="fyy">
+      <created>1691495150166</created>
+      <option name="number" value="00011" />
+      <option name="presentableId" value="LOCAL-00011" />
+      <option name="project" value="LOCAL" />
+      <updated>1691495150166</updated>
+    </task>
+    <option name="localTasksCounter" value="12" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
     <option name="version" value="3" />
   </component>
+  <component name="VcsManagerConfiguration">
+    <MESSAGE value="jf2.0" />
+    <MESSAGE value="fyy 测试接口" />
+    <MESSAGE value="fyy 测试数据" />
+    <MESSAGE value="fyy" />
+    <option name="LAST_COMMIT_MESSAGE" value="fyy" />
+  </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>
       <breakpoints>
@@ -185,6 +310,34 @@
           </properties>
           <option name="timeStamp" value="3" />
         </line-breakpoint>
+        <line-breakpoint enabled="true" type="php-line-method">
+          <url>file://$PROJECT_DIR$/app/Http/Controllers/Api/TestController.php</url>
+          <line>111</line>
+          <properties>
+            <option name="className" value="\App\Http\Controllers\Api\TestController" />
+            <option name="methodName" value="output_value_month1" />
+          </properties>
+          <option name="timeStamp" value="5" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="php-line-method">
+          <url>file://$PROJECT_DIR$/app/Service/FyyOrderService.php</url>
+          <line>98</line>
+          <properties>
+            <option name="className" value="\App\Service\FyyOrderService" />
+            <option name="methodName" value="orderList" />
+          </properties>
+          <option name="timeStamp" value="7" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="php">
+          <url>file://$PROJECT_DIR$/routes/api.php</url>
+          <line>21</line>
+          <option name="timeStamp" value="4" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="php">
+          <url>file://$PROJECT_DIR$/app/Service/FyySqlServerService.php</url>
+          <line>326</line>
+          <option name="timeStamp" value="6" />
+        </line-breakpoint>
       </breakpoints>
     </breakpoint-manager>
   </component>

+ 38 - 0
app/Http/Controllers/Api/DeleteOrderController.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+
+use App\Service\DeleteOrderService;
+use Illuminate\Http\Request;
+use Symfony\Component\Process\Process;
+
+
+class DeleteOrderController extends BaseController
+{
+    public function del(Request $request)
+    {
+        $service = new DeleteOrderService();
+        list($status,$data) = $service->del($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function test(){
+        ini_set('default_charset', 'UTF-8');
+        $process = Process::fromShellCommandline('php D:\phpstudy_pro\WWW\cs.php');
+        //$process->run();//等待外部命令执行完毕
+        $process->start();
+        dump("直接输出222不等待!");
+
+        if ($process->isSuccessful()) {
+            dump($process->getOutput() . '1');
+        } else {
+            dump($process->getErrorOutput() . '2');
+        }dump(1);die;
+    }
+}

+ 26 - 0
app/Http/Controllers/Api/DispatchController.php

@@ -88,4 +88,30 @@ class DispatchController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function dispatchMobileOrderList(Request $request)
+    {
+        $service = new DispatchService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->dispatchMobileOrderList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function dispatchMobileOrderDetailsList(Request $request)
+    {
+        $service = new DispatchService();
+        $user = $request->get('auth');
+        list($status,$data) = $service->dispatchMobileOrderDetailsList($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 4 - 4
app/Http/Controllers/Api/EmployeeController.php

@@ -20,8 +20,8 @@ class EmployeeController extends BaseController
 
 
         $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeEdit($request->all());
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->employeeEdit($request->all(),$user);
 
         if($status){
             return $this->json_return(200,'',$data);
@@ -37,8 +37,8 @@ class EmployeeController extends BaseController
 
 
         $service = new EmployeeService();
-        $user = $request->get('auth');
-        list($status,$data) = $service->employeeAdd($request->all(),$request->all());
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->employeeAdd($request->all(),$user);
 
         if($status){
             return $this->json_return(200,'',$data);

+ 12 - 0
app/Http/Controllers/Api/FinishedOrderController.php

@@ -74,4 +74,16 @@ class FinishedOrderController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function mobileAdd(Request $request){
+        $service = new FinishedOrderService();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->mobileAdd($request->all(),$userData);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 29 - 0
app/Http/Controllers/Api/FyyOrderController.php

@@ -5,10 +5,39 @@ namespace App\Http\Controllers\Api;
 
 use App\Service\FyyOrderService;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Redis;
 
 
 class FyyOrderController extends BaseController
 {
+    public function setFyy(Request $request)
+    {
+        $data = $request->all();
+        if(! isset($data['host']) || ! isset($data['port']) || ! isset($data['database'])) return;
+
+        $array = [
+            'sqlserver_host' => $data['host'],
+            'sqlserver_port' => $data['port'],
+            'sqlserver_database' => $data['database']
+        ];
+        Redis::set('fyy_sql_server',json_encode($array));
+        Redis::expire('fyy_sql_server', 86400);
+        dump('ok');die;
+    }
+
+    public function fyySaveOutOrder(Request $request)
+    {
+        $service = new FyyOrderService();
+        $userData = $request->userData->toArray();
+        list($status,$data) = $service->fyySaveOutOrder($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
     public function add(Request $request)
     {
         $service = new FyyOrderService();

+ 34 - 0
app/Http/Controllers/Api/HeaderWordController.php

@@ -26,5 +26,39 @@ class HeaderWordController extends BaseController
 
     }
 
+    public function getHeaderSettings(Request $request){
+        $service =  HeaderWordHookService::getInstance();
+        $data = $request->all();
+        list($status,$data) = $service->getHeaderSettings($data);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function add(Request $request){
+        $service =  HeaderWordHookService::getInstance();
+        $data = $request->all();
+        list($status,$data) = $service->add($data);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function detail(Request $request){
+        $service =  HeaderWordHookService::getInstance();
+        $data = $request->all();
+        list($status,$data) = $service->detail($data);
 
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 24 - 0
app/Http/Controllers/Api/LoginController.php

@@ -9,6 +9,14 @@ use Illuminate\Support\Facades\Log;
 //登录
 class LoginController extends BaseController
 {
+    const MOBILE = '[mobile]';// 手机端
+    const PERSONAL_COMPUTER = '[personalComputer]';// 电脑端
+
+    public static $port = [
+        self::MOBILE => '',
+        self::PERSONAL_COMPUTER => '',
+    ];
+
     public function login(Request $request){
         $data = $request->only("account","password");
 
@@ -22,7 +30,23 @@ class LoginController extends BaseController
 
         //生成token
         $jwtToken = TokenService::getToken($return['id']);
+        $jwtToken = self::PERSONAL_COMPUTER . $jwtToken;
 
         return $this->json_return(200,'', ['token' => $jwtToken, 'emp_name'=>$return['name']]);
     }
+
+    public function loginMobile(Request $request){
+        $data = $request->only("account","password");
+
+        //登录
+        $result = (new EmployeeService())->loginRule($data);
+        list($bool, $return) = $result;
+        if(! $bool) return $this->json_return(201,'',$return);
+
+        //生成token
+        $jwtToken = TokenService::getToken($return['id']);
+        $jwtToken = self::MOBILE . $jwtToken;
+
+        return $this->json_return(200,'', ['token' => $jwtToken]);
+    }
 }

+ 9 - 0
app/Http/Controllers/Api/SysMenuController.php

@@ -82,6 +82,15 @@ class SysMenuController extends BaseController
     }
 
 
+    public function menuMove(Request $request){
+        $service = new SysMenuService();
+        list($status,$data) = $service->menuMove($request->all());
 
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 
 }

+ 960 - 0
app/Http/Controllers/Api/TestController.php

@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Api;
 use App\Model\BoxDetail;
 use App\Service\MeasureService;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
 
 
 class TestController extends BaseController
@@ -63,9 +64,968 @@ class TestController extends BaseController
 //    }
 
 
+public function testData(Request $request){
+        date_default_timezone_set('PRC');
+        $arr = ['title' => json_encode($request->all()),
+            'crt_time' => date('Y-m-d H:i:s')
+        ];
+        DB::table('test_shebei')->insert($arr);
+//        DB::table('test_shebei')->insert(['title' => '2223354']);
+}
+
+
+public function order_process1(Request $request) {
+    $arr = [
+        0 => ['Code' => "SO202307270001", 'CustomerName' => "金华市金东区方氏防火建材经营部", 'rate' => 55],
+        1 => ['Code' => "SO202307270002", 'CustomerName' => "岳阳耀东翔建筑材料有限公司", 'rate' => 20],
+        2 => ['Code' => "SO202307270003", 'CustomerName' => "森泓(内蒙古)建材有限公司", 'rate' => 99],
+        3 => ['Code' => "SO202307270004", 'CustomerName' => "重庆渝人实业有限公司", 'rate' => 65],
+        4 => ['Code' => "SO202307270005", 'CustomerName' => "九龙坡区优源木业销售中心", 'rate' => 37],
+        5 => ['Code' => "SO202307270006", 'CustomerName' => "湖北嘉宜木业有限公司", 'rate' => 16],
+        6 => ['Code' => "SO202307270007", 'CustomerName' => "中牟县国威家居建材商行", 'rate' => 44],
+        7 => ['Code' => "SO202307270008", 'CustomerName' => "绵阳市森元高科林业有限公司", 'rate' => 66],
+        8 => ['Code' => "SO202307270009", 'CustomerName' => "红花岗区美梦晨建材经营部", 'rate' => 22],
+        9 => ['Code' => "SO202307270010", 'CustomerName' => "茅箭区火车站鸿发装饰部", 'rate' => 15],
+        10 => ['Code' => "SO202307270011", 'CustomerName' => "郯城县王钦红建材五金店", 'rate' => 80],
+        11 => ['Code' => "SO202307270012", 'CustomerName' => "合肥麦凯森新材料科技有限公司", 'rate' => 15],
+        12 => ['Code' => "SO202307270013", 'CustomerName' => "湖北旺百福建材有限公司", 'rate' => 78],
+        13 => ['Code' => "SO202307270014", 'CustomerName' => "义乌市鼎泰建材有限公司", 'rate' => 15],
+        14 => ['Code' => "SO202307270015", 'CustomerName' => "平舆县艾力熊板材销售店", 'rate' => 40],
+        15 => ['Code' => "SO202307270016", 'CustomerName' => "杭州德兔装饰材料有限公司", 'rate' => 14],
+        16 => ['Code' => "SO202307270017", 'CustomerName' => "徐州美尔娜装饰材料有限公司", 'rate' => 88],
+        17 => ['Code' => "SO202307270018", 'CustomerName' => "合肥市包河区郭玉春建材经营部", 'rate' => 84],
+        18 => ['Code' => "SO202307270019", 'CustomerName' => "深圳雅匠新材料科技有限公司", 'rate' => 82],
+        19 => ['Code' => "SO202307270020", 'CustomerName' => "乌鲁木齐市米东区信和建材商行", 'rate' => 72],
+    ];
+    return $this->json_return(200,'',$arr);
+}
+
+
+public function project_region(Request $request){
+    $arr = [
+        "all_num" => 2373,
+        "num" => 188,
+    ];
+    return $this->json_return(200,'',$arr);
+}
+
+public function output_value_month1(Request $request){
+        $arr = [
+            [
+                "value"=> "2023-01-01",
+                "num"=> "20"
+            ],
+            [
+                "value"=> "2023-01-02",
+                "num"=> "40"
+            ],
+            [
+                "value"=> "2023-01-03",
+                "num"=> "35"
+            ],
+            [
+                "value"=> "2023-01-04",
+                "num"=> "15"
+            ],
+            [
+                "value"=> "2023-01-05",
+                "num"=> "40",
+            ]
+        ];
+    return $this->json_return(200,'',$arr);
+}
+
+public function output_value_efficiency(Request $request){
+   $arr = [
+       [
+           "time"=> "2023-01-01",
+           "output"=> "0"
+       ],
+       [
+           "time"=> "2023-01-02",
+           "output"=> "0"
+       ],
+       [
+           "time"=> "2023-01-03",
+           "output"=> "2711"
+       ],
+       [
+           "time"=> "2023-01-04",
+           "output"=> "2239"
+       ],
+       [
+           "time"=> "2023-01-05",
+           "output"=> "1101"
+       ]
+   ];
+    return $this->json_return(200,'',$arr);
+}
+
+public function capacity(Request $request){
+    $arr = [
+        [
+            [
+                "title"=> "压贴",
+                "rate"=> "70"
+            ],
+            [
+                "title"=> "包装",
+                "rate"=> "50"
+            ]
+        ],
+    ];
+    return $this->json_return(200,'',['data' => $arr]);
+
+}
+
+
+
+public function product_num(Request $request){
+    $arr = [
+        [
+            "machine_day_num"=> "4903.69",
+            "machine_month_num"=> "139.64",
+            "machine_week_num"=> "47.21",
+            "break_day_num"=> "0",
+            "break_month_num"=> "10",
+            "break_week_num"=> "3",
+            "start_time"=> date("Y-m-d H:i:s",time()),
+            "day_num"=> "766",
+            "week_num"=> "4598",
+            "month_num"=> "14489",
+            "rate"=> "72"
+        ],
+        [
+            "machine_day_num"=> "469591.19",
+            "machine_month_num"=> "107.03",
+            "machine_week_num"=> "35.23",
+            "break_day_num"=> 0,
+            "break_month_num"=> "210",
+            "break_week_num"=> "18",
+            "start_time"=> date("Y-m-d H:i:s",time()),
+            "day_num"=> 0,
+            "week_num"=> "2353",
+            "month_num"=> "6255",
+            "rate"=> 0
+        ],
+        [
+            "machine_day_num"=> "0",
+            "machine_month_num"=> "14.02",
+            "machine_week_num"=> "6.88",
+            "break_day_num"=> "0",
+            "break_month_num"=> "0",
+            "break_week_num"=> "0",
+            "start_time"=> date("Y-m-d H:i:s",time()),
+            "day_num"=> "0",
+            "week_num"=> "494",
+            "month_num"=> "3058",
+            "rate"=> "0"
+        ],
+        [
+            "machine_day_num"=> "4903.77",
+            "machine_month_num"=> "149.14",
+            "machine_week_num"=> "56.72",
+            "break_day_num"=> "0",
+            "break_month_num"=> "0",
+            "break_week_num"=> "0",
+            "start_time"=> date("Y-m-d H:i:s",time()),
+            "day_num"=> "626",
+            "week_num"=> "4460",
+            "month_num"=> "13034",
+            "rate"=> "48"
+        ]
+    ];
+    return $this->json_return(200,'',$arr);
+}
 
+public function work_order(Request $request){
+    $arr = [
+        "K23070127_1_8"=>[
+        "order_no"=>"SO202307270001",
+    "product_title"=>"大王椰600经典型E0全桉-免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_5"=>[
+        "order_no"=>"SO202307270002",
+    "product_title"=>"大王椰600经典型E0全桉-免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_41"=>[
+        "order_no"=>"SO202307270003",
+    "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_40"=>[
+        "order_no"=>"SO202307270004",
+    "product_title"=>"大王椰1700金装型ENF香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_12"=>[
+        "order_no"=>"SO202307270005",
+    "product_title"=>"大王椰900尊贵型E0-家具专用背板BW",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_3"=>[
+        "order_no"=>"SO202307270006",
+    "product_title"=>"家具A6森芯背板E0商标使用费",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_46"=>[
+        "order_no"=>"SO202307270007",
+    "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_43"=>[
+        "order_no"=>"SO202307270008",
+    "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_39"=>[
+        "order_no"=>"SO202307270009",
+    "product_title"=>"大王椰1800尊贵型ENF指接芯香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_36"=>[
+        "order_no"=>"SO202307270010",
+    "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_37"=>[
+        "order_no"=>"SO202307270011",
+    "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_33"=>[
+        "order_no"=>"SO202307270012",
+    "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_11"=>[
+        "order_no"=>"SO202307270013",
+    "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+    "procedure"=>"压贴",
+    "product_num"=>12,
+    "finish_num"=>0
+  ],
+  "K23070127_1_28"=>[
+        "order_no"=>"SO202307270014",
+    "product_title"=>"大王椰1800尊贵型E0-家具柜门板PLW",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_27"=>[
+        "order_no"=>"SO202307270015",
+    "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_26"=>[
+        "order_no"=>"SO202307270016",
+    "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],
+  "K23070127_1_24"=>[
+        "order_no"=>"SO202307270017",
+    "product_title"=>"大王椰700尊贵型E0全桉-免漆板W",
+    "procedure"=>"压贴",
+    "product_num"=>6,
+    "finish_num"=>0
+  ],"K23070127_1_34"=>[
+            "order_no"=>"SO202307270018",
+            "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>61,
+            "finish_num"=>0
+        ],
+        "K23070127_1_55"=>[
+            "order_no"=>"SO202307270019",
+            "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_22"=>[
+            "order_no"=>"SO202307270020",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_31"=>[
+            "order_no"=>"SO202307270021",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_54"=>[
+            "order_no"=>"SO202307270022",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+    ];
 
+    return $this->json_return(200,'',$arr);
+}
+
+public function nu_work_order(Request $request){
+    $arr = [
+        "K23070127_1_8"=>[
+            "order_no"=>"SO202307270001",
+            "product_title"=>"大王椰600经典型E0全桉-免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_5"=>[
+            "order_no"=>"SO202307270002",
+            "product_title"=>"大王椰600经典型E0全桉-免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_41"=>[
+            "order_no"=>"SO202307270003",
+            "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_40"=>[
+            "order_no"=>"SO202307270004",
+            "product_title"=>"大王椰1700金装型ENF香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_12"=>[
+            "order_no"=>"SO202307270005",
+            "product_title"=>"大王椰900尊贵型E0-家具专用背板BW",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_3"=>[
+            "order_no"=>"SO202307270006",
+            "product_title"=>"家具A6森芯背板E0商标使用费",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_46"=>[
+            "order_no"=>"SO202307270007",
+            "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_43"=>[
+            "order_no"=>"SO202307270008",
+            "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_39"=>[
+            "order_no"=>"SO202307270009",
+            "product_title"=>"大王椰1800尊贵型ENF指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_36"=>[
+            "order_no"=>"SO202307270010",
+            "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_37"=>[
+            "order_no"=>"SO202307270011",
+            "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_33"=>[
+            "order_no"=>"SO202307270012",
+            "product_title"=>"大王椰封边皮家具2.2CM×1.0×6卷/件",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_11"=>[
+            "order_no"=>"SO202307270013",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_28"=>[
+            "order_no"=>"SO202307270014",
+            "product_title"=>"大王椰1800尊贵型E0-家具柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_27"=>[
+            "order_no"=>"SO202307270015",
+            "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_26"=>[
+            "order_no"=>"SO202307270016",
+            "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_24"=>[
+            "order_no"=>"SO202307270017",
+            "product_title"=>"大王椰700尊贵型E0全桉-免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_34"=>[
+            "order_no"=>"SO202307270018",
+            "product_title"=>"大王椰1700金装型E0香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>61,
+            "finish_num"=>0
+        ],
+        "K23070127_1_55"=>[
+            "order_no"=>"SO202307270019",
+            "product_title"=>"大王椰1800尊贵型E0指接芯香杉木-智能生态免漆板W",
+            "procedure"=>"压贴",
+            "product_num"=>6,
+            "finish_num"=>0
+        ],
+        "K23070127_1_22"=>[
+            "order_no"=>"SO202307270020",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_31"=>[
+            "order_no"=>"SO202307270021",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+        "K23070127_1_54"=>[
+            "order_no"=>"SO202307270022",
+            "product_title"=>"大王椰1800尊贵型ENF-柜门板PLW",
+            "procedure"=>"压贴",
+            "product_num"=>12,
+            "finish_num"=>0
+        ],
+    ];
+    return $this->json_return(200,'',$arr);
+}
+
+
+//    public function product_num(Request $request){
+//        $arr = [
+//            [
+//                "machine_day_num"=> "5.69",
+//                "machine_month_num"=> "139.64",
+//                "machine_week_num"=> "47.21",
+//                "break_day_num"=> "0",
+//                "break_month_num"=> "10",
+//                "break_week_num"=> "3",
+//                "start_time"=> date("Y-m-d H:i:s",time()),
+//                "day_num"=> "766",
+//                "week_num"=> "4598",
+//                "month_num"=> "14489",
+//                "rate"=> "72"
+//            ],
+//            [
+//                "machine_day_num"=> "4.19",
+//                "machine_month_num"=> "107.03",
+//                "machine_week_num"=> "35.23",
+//                "break_day_num"=> 0,
+//                "break_month_num"=> "210",
+//                "break_week_num"=> "18",
+//                "start_time"=> date("Y-m-d H:i:s",time()),
+//                "day_num"=> 0,
+//                "week_num"=> "2353",
+//                "month_num"=> "6255",
+//                "rate"=> 0
+//            ],
+//            [
+//                "machine_day_num"=> "0",
+//                "machine_month_num"=> "14.02",
+//                "machine_week_num"=> "6.88",
+//                "break_day_num"=> "0",
+//                "break_month_num"=> "0",
+//                "break_week_num"=> "0",
+//                "start_time"=> date("Y-m-d H:i:s",time()),
+//                "day_num"=> "0",
+//                "week_num"=> "494",
+//                "month_num"=> "3058",
+//                "rate"=> "0"
+//            ],
+//            [
+//                "machine_day_num"=> "4.77",
+//                "machine_month_num"=> "149.14",
+//                "machine_week_num"=> "56.72",
+//                "break_day_num"=> "0",
+//                "break_month_num"=> "0",
+//                "break_week_num"=> "0",
+//                "start_time"=> date("Y-m-d H:i:s",time()),
+//                "day_num"=> "626",
+//                "week_num"=> "4460",
+//                "month_num"=> "13034",
+//                "rate"=> "48"
+//            ]
+//        ];
+//        return $this->json_return(200,'',$arr);
+//    }
+//
+//    public function work_order(Request $request){
+//        $arr = [
+//            "K23070127_1_8"=>[
+//                "order_no"=>"SO202307270001",
+//                "product_title"=>"银梨4号 AH68491-3油 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_5"=>[
+//                "order_no"=>"SO202307270002",
+//                "product_title"=>"K4001K 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_41"=>[
+//                "order_no"=>"SO202307270003",
+//                "product_title"=>"尤加利 AH53386-2-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_40"=>[
+//                "order_no"=>"SO202307270004",
+//                "product_title"=>"混油橡木-2  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_12"=>[
+//                "order_no"=>"SO202307270005",
+//                "product_title"=>"混油胡桃-2  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_3"=>[
+//                "order_no"=>"SO202307270006",
+//                "product_title"=>"混油胡桃-3  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_46"=>[
+//                "order_no"=>"SO202307270007",
+//                "product_title"=>"科技木2号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_43"=>[
+//                "order_no"=>"SO202307270008",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_39"=>[
+//                "order_no"=>"SO202307270009",
+//                "product_title"=>"科技木2号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_36"=>[
+//                "order_no"=>"SO202307270010",
+//                "product_title"=>"90167-6橡木色1号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_37"=>[
+//                "order_no"=>"SO202307270011",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_33"=>[
+//                "order_no"=>"SO202307270012",
+//                "product_title"=>"6293-70 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_11"=>[
+//                "order_no"=>"SO202307270013",
+//                "product_title"=>"时光流离-6  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_28"=>[
+//                "order_no"=>"SO202307270014",
+//                "product_title"=>"风调雨顺  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_27"=>[
+//                "order_no"=>"SO202307270015",
+//                "product_title"=>"科技木3号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_26"=>[
+//                "order_no"=>"SO202307270016",
+//                "product_title"=>"诗和远方-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_24"=>[
+//                "order_no"=>"SO202307270017",
+//                "product_title"=>"88036-1Y 银梨1007-7 -科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],"K23070127_1_34"=>[
+//                "order_no"=>"SO202307270018",
+//                "product_title"=>"天使白小浮雕 -科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>61,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_55"=>[
+//                "order_no"=>"SO202307270019",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_22"=>[
+//                "order_no"=>"SO202307270020",
+//                "product_title"=>"烟熏橡木 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_31"=>[
+//                "order_no"=>"SO202307270021",
+//                "product_title"=>"博尔诺胡桃-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_54"=>[
+//                "order_no"=>"SO202307270022",
+//                "product_title"=>"整装1号-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//        ];
+//
+//        return $this->json_return(200,'',$arr);
+//    }
+//
+//    public function nu_work_order(Request $request){
+//        $arr = [
+//            "K23070127_1_8"=>[
+//                "order_no"=>"SO202307270001",
+//                "product_title"=>"银梨4号 AH68491-3油 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_5"=>[
+//                "order_no"=>"SO202307270002",
+//                "product_title"=>"K4001K 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_41"=>[
+//                "order_no"=>"SO202307270003",
+//                "product_title"=>"尤加利 AH53386-2-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_40"=>[
+//                "order_no"=>"SO202307270004",
+//                "product_title"=>"混油橡木-2  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_12"=>[
+//                "order_no"=>"SO202307270005",
+//                "product_title"=>"混油胡桃-2  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_3"=>[
+//                "order_no"=>"SO202307270006",
+//                "product_title"=>"混油胡桃-3  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_46"=>[
+//                "order_no"=>"SO202307270007",
+//                "product_title"=>"科技木2号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_43"=>[
+//                "order_no"=>"SO202307270008",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_39"=>[
+//                "order_no"=>"SO202307270009",
+//                "product_title"=>"科技木2号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_36"=>[
+//                "order_no"=>"SO202307270010",
+//                "product_title"=>"90167-6橡木色1号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_37"=>[
+//                "order_no"=>"SO202307270011",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_33"=>[
+//                "order_no"=>"SO202307270012",
+//                "product_title"=>"6293-70 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_11"=>[
+//                "order_no"=>"SO202307270013",
+//                "product_title"=>"时光流离-6  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_28"=>[
+//                "order_no"=>"SO202307270014",
+//                "product_title"=>"风调雨顺  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_27"=>[
+//                "order_no"=>"SO202307270015",
+//                "product_title"=>"科技木3号科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_26"=>[
+//                "order_no"=>"SO202307270016",
+//                "product_title"=>"诗和远方-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_24"=>[
+//                "order_no"=>"SO202307270017",
+//                "product_title"=>"88036-1Y 银梨1007-7 -科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],"K23070127_1_34"=>[
+//                "order_no"=>"SO202307270018",
+//                "product_title"=>"天使白小浮雕 -科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>61,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_55"=>[
+//                "order_no"=>"SO202307270019",
+//                "product_title"=>"YC 71310-2油 半透胡桃3号  科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>6,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_22"=>[
+//                "order_no"=>"SO202307270020",
+//                "product_title"=>"烟熏橡木 科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_31"=>[
+//                "order_no"=>"SO202307270021",
+//                "product_title"=>"博尔诺胡桃-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//            "K23070127_1_54"=>[
+//                "order_no"=>"SO202307270022",
+//                "product_title"=>"整装1号-科技木皮",
+//                "procedure"=>"压贴",
+//                "product_num"=>12,
+//                "finish_num"=>0
+//            ],
+//        ];
+//        return $this->json_return(200,'',$arr);
+//    }
+
+public function testaa(Request $request){
+        $data = $request->all();
+
+        $url = $data['url'];
+        $post = $data['post'];
+        $header = $data['header'];
 
+        $curl = curl_init();
 
+    curl_setopt_array($curl, array(
+        CURLOPT_URL => $url,
+        CURLOPT_RETURNTRANSFER => true,
+        CURLOPT_ENCODING => '',
+        CURLOPT_MAXREDIRS => 10,
+        CURLOPT_TIMEOUT => 0,
+        CURLOPT_FOLLOWLOCATION => true,
+        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+        CURLOPT_CUSTOMREQUEST => 'POST',
+        CURLOPT_POSTFIELDS => json_encode($post),
+        CURLOPT_HTTPHEADER => $header,
+    ));
+    $response = curl_exec($curl);
+    curl_close($curl);
+    return $this->json_return(200,'',json_decode($response,true));
 
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $data['url'],
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS => json_encode($data['post']),
+            CURLOPT_HTTPHEADER => $header,
+        ));
+
+        $response = curl_exec($curl);
+        curl_close($curl);
+        return $this->json_return(200,'',json_decode($response,true));
+    }
+
+public function testa(Request $request){
+        $data = $request->all();
+
+        $url = $data['url'];
+        $header = $data['header'];
+
+        $curl = curl_init();
+
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => $url,
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'GET',
+            CURLOPT_HTTPHEADER => $header,
+        ));
+        $response = curl_exec($curl);
+        curl_close($curl);
+        return $this->json_return(200,'',json_decode($response,true));
+    }
+
+    public function testaa1(Request $request){
+        $curl = curl_init();
+
+        curl_setopt_array($curl, array(
+            CURLOPT_URL => 'http://121.36.142.167:7774/jbl/api/module-data/team_list/page',
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING => '',
+            CURLOPT_MAXREDIRS => 10,
+            CURLOPT_TIMEOUT => 0,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST => 'POST',
+            CURLOPT_POSTFIELDS =>'{"direction":"DESC","property":"id","fromClientType":"pc","number":0,"sorts":[],"rules":[],"size":15,"specialConditions":[],"dynamicFormCode":"team","developmentSystemId":null,"debugFlag":true}',
+            CURLOPT_HTTPHEADER => array(
+                'Content-Sign: 88cb27fd67215452422c18f3ed71028e',
+                'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfSU5ORVJfVVNFUixST0xFX0FETUlOIiwidG9rZW5JZCI6IjM1IiwiZXhwIjoxNjk0MTUwODMxfQ.1_Adx5tdReisZdgyyQfBjU4VCXzGDKNiztJ-WjPlZ3bG0EQHzcKZs7Pi0yk2xxQn1XWp0dNVHqUPbTMpkEU1aA',
+                'Content-Type: application/json',
+            ),
+        ));
+
+        $response = curl_exec($curl);
+
+        curl_close($curl);
+        echo $response;
+    }
 }

+ 10 - 0
app/Http/Middleware/CheckLogin.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Middleware;
 
+use App\Http\Controllers\Api\LoginController;
 use App\Service\EmployeeService;
 use Closure;
 use App\Service\TokenService;
@@ -21,6 +22,15 @@ class CheckLogin
         if (!isset($token)){
             return  response()->json(['code'=>1,'msg'=>'缺少token','data'=>null]);
         }
+
+        //登录来源前缀清除
+        foreach (LoginController::$port as $key => $value){
+            if (strpos($token,$key) !== false) {
+                $token = str_replace($key, $value, $token);
+                break;
+            }
+        }
+
         //校验token
         $result = TokenService::verifyToken($token);
         if ($result < 0){

+ 19 - 0
app/Model/DispatchEmpSub.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class DispatchEmpSub extends Model
+{
+    protected $table = "dispatch_emp_sub"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+}

+ 19 - 0
app/Model/Header_ext_sub.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class Header_ext_sub extends Model
+{
+    protected $table = "header_ext_sub"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+}

+ 309 - 0
app/Service/DeleteOrderService.php

@@ -0,0 +1,309 @@
+<?php
+
+namespace App\Service;
+
+use App\Model\Dispatch;
+use App\Model\DispatchEmpSub;
+use App\Model\DispatchSub;
+use App\Model\Orders;
+use App\Model\OrdersProduct;
+use App\Model\OrdersProductBom;
+use App\Model\OrdersProductMain;
+use App\Model\OrdersProductProcess;
+use App\Model\SaleOrdersProduct;
+use Illuminate\Support\Facades\DB;
+
+class DeleteOrderService extends Service
+{
+    public function del($data){
+        if($this->isEmpty($data,'id')) return [false,'数据必须选择!'];
+        if($this->isEmpty($data,'type')) return [false,'单据类型不能为空!'];
+
+        switch ($data['type']){
+            case 1:
+                list($status,$msg) = $this->delSaleOrdersProduct($data['id']);
+                break;
+            case 2:
+                list($status,$msg) = $this->delOrdersProduct($data['id']);
+                break;
+            case 3:
+                list($status,$msg) = $this->delDispatch($data['id']);
+                break;
+            case 4:
+                list($status,$msg) = $this->delFinished($data['id']);
+                break;
+            default:
+                list($status,$msg) = [false,'删除失败!'];
+        }
+
+        return [$status,$msg];
+    }
+
+    //销售订单删除
+    public function delSaleOrdersProduct($id){
+        $bool = OrdersProduct::where('del_time',0)
+            ->whereIn('sale_orders_product_id',$id)
+            ->exists();
+        if($bool) return [false,'销售订单已生成生产订单,删除失败!'];
+
+        try {
+            DB::beginTransaction();
+
+            //销售订单
+            SaleOrdersProduct::whereIn('id',$id)->update([
+                'del_time' => time()
+            ]);
+
+            //内部订单号与销售订单关联表
+            $subquery = DB::table('sale_orders_product')
+                ->select('order_no')
+                ->whereIn('id',$id);
+            $order_no = DB::table('sale_orders_product')
+                ->select('order_no','del_time')
+                ->joinSub($subquery, 'sub', function ($join) {
+                    $join->on('sale_orders_product.order_no', '=', 'sub.order_no');
+                })->get()->toArray();
+            $update_order = [];
+            if(! empty($order_no)){
+                $tmp = [];
+                foreach ($order_no as $value){
+                    if($value['del_time'] == 0){
+                        $tmp[] = $value['order_no'];
+                    }else{
+                        $update_order[] = $value['order_no'];
+                    }
+                }
+                $tmp = array_unique($tmp);
+                $update_order = array_unique($update_order);
+                $update_order = array_diff($update_order, $tmp);
+            }
+            if(! empty($update_order)) Orders::whereIn('order_no',$update_order)->update(['del_time' => time()]);
+
+            DB::commit();
+        }catch (\Throwable $e){
+            DB::rollBack();
+            return [false,$e->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    //生产订单删除
+    public function delOrdersProduct($id){
+        $bool = DispatchSub::where('del_time',0)
+            ->whereIn('order_product_id',$id)
+            ->exists();
+        if($bool) return [false,'生产订单已生成派工单,删除失败!'];
+
+        try {
+            DB::beginTransaction();
+
+            //生产订单
+            OrdersProduct::whereIn('id',$id)->update([
+                'del_time' => time()
+            ]);
+
+            //生产订单主表
+            $subquery = DB::table('orders_product')
+                ->select('production_no')
+                ->whereIn('id',$id);
+            $order_no = DB::table('orders_product')
+                ->select('orders_product.production_no','orders_product.del_time')
+                ->joinSub($subquery, 'sub', function ($join) {
+                    $join->on('orders_product.production_no', '=', 'sub.production_no');
+                })->get()->toArray();
+            $update_order = [];
+            if(! empty($order_no)){
+                $tmp = [];
+                foreach ($order_no as $value){
+                    if($value['del_time'] == 0){
+                        $tmp[] = $value['production_no'];
+                    }else{
+                        $update_order[] = $value['production_no'];
+                    }
+                }
+                $tmp = array_unique($tmp);
+                $update_order = array_unique($update_order);
+                $update_order = array_diff($update_order, $tmp);
+            }
+            if(! empty($update_order)) OrdersProductMain::whereIn('production_no',$update_order)->update(['del_time' => time()]);
+
+            //生产订单子表
+            $message = OrdersProduct::whereIn('id',$id)->select('out_order_no_time','sale_orders_product_id')->get()->toArray();
+            $time = array_unique(array_column($message,'out_order_no_time'));
+            $arr_time = [];
+            if(! empty($time)){
+                date_default_timezone_set("PRC");
+                foreach ($time as $value){
+                    $time_tmp = date("Ymd", $value);
+                    if(! in_array($time_tmp,$arr_time)) $arr_time[] = $time_tmp;
+                }
+            }
+            if(! empty($arr_time)){
+                foreach ($arr_time as $value){
+                    $modelBom = new OrdersProductBom(['channel'=> $value]);
+                    $modelBom->where('order_product_id',$id)->update(['del_time' => time()]);
+
+                    $modelProcess = new OrdersProductProcess(['channel' => $value]);
+                    $modelProcess->where('order_product_id',$id)->update(['del_time' => time()]);
+                }
+            }
+
+            //销售订单里的已生产数量
+            (new ProductionOrderService())->writeProductionQuantity(array_column($message,'sale_orders_product_id'));
+
+            DB::commit();
+        }catch (\Throwable $e){
+            DB::rollBack();
+            return [false,$e->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    //派工单删除
+    public function delDispatch($id){
+        $bool = DispatchSub::where('del_time',0)
+            ->whereIn('id',$id)
+            ->where('finished_num','>',0)
+            ->exists();
+        if($bool) return [false,'工序派工单已有完工操作,删除失败!'];
+
+        try {
+            DB::beginTransaction();
+
+            //工序派工单
+            DispatchSub::whereIn('id',$id)->update([
+                'del_time' => time()
+            ]);
+
+            //工序派工单主表
+            $subquery = DB::table('dispatch_sub')
+                ->select('dispatch_no')
+                ->whereIn('id',$id);
+            $order_no = DB::table('dispatch_sub')
+                ->select('dispatch_no','del_time')
+                ->joinSub($subquery, 'sub', function ($join) {
+                    $join->on('dispatch_sub.dispatch_no', '=', 'sub.dispatch_no');
+                })->get()->toArray();
+            $update_order = [];
+            if(! empty($order_no)){
+                $tmp = [];
+                foreach ($order_no as $value){
+                    if($value['del_time'] == 0){
+                        $tmp[] = $value['dispatch_no'];
+                    }else{
+                        $update_order[] = $value['dispatch_no'];
+                    }
+                }
+                $tmp = array_unique($tmp);
+                $update_order = array_unique($update_order);
+                $update_order = array_diff($update_order, $tmp);
+            }
+            if(! empty($update_order)) Dispatch::whereIn('dispatch_no',$update_order)->update(['del_time' => time()]);
+
+            //工序表
+            $message = DispatchSub::whereIn('id',$id)->select('out_order_no_time','sale_orders_product_id','dispatch_no','dispatch_quantity','order_product_id','process_id')->get()->toArray();
+            if(! empty($message)){
+                date_default_timezone_set("PRC");
+
+                foreach ($message as $value){
+                    $tmp_time = date('Ymd',$value['out_order_no_time']);
+                    $modelProcess = new OrdersProductProcess(['channel' => $tmp_time]);
+                    $modelProcess->where('order_product_id',$value['order_product_id'])
+                        ->where('process_id',$value['process_id'])
+                        ->where('dispatch_no',$value['dispatch_no'])
+                        ->take($value['dispatch_quantity'])
+                        ->update([
+                            'dispatch_no' => '',
+                            'status' => 0
+                        ]);
+
+                    DispatchEmpSub::where('order_product_id',$value['order_product_id'])
+                        ->where('dispatch_no',$value['dispatch_no'])
+                        ->update([
+                            'del_time' => time()
+                        ]);
+                }
+            }
+
+            //已派工数量
+            (new DispatchService())->writeDispatchQuantity(array_column($message,'order_product_id'));
+
+            DB::commit();
+        }catch (\Throwable $e){
+            DB::rollBack();
+            return [false,$e->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    //完工单删除
+    public function delFinished($id){
+        $result = DispatchSub::whereIn('id',$id)
+            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title','price')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+
+        try {
+            DB::beginTransaction();
+
+            date_default_timezone_set('PRC');
+
+            $insertSqlServer = [];
+            foreach ($result as $key => $value){
+                SaleOrdersProduct::where('id',$value['sale_orders_product_id'])->decrement('finished_num', $value['finished_num']);
+
+                $process_model = new OrdersProductProcess(['channel' => date("Ymd",$value['out_order_no_time'])]);
+
+                $process_model->where('order_product_id',$value['order_product_id'])
+                    ->where('process_id',$value['process_id'])
+                    ->where('dispatch_no',$value['dispatch_no'])
+                    ->take($value['finished_num'])
+                    ->update([
+                        'finished_time' => 0,
+                        'status' => 1,
+                        'finished_id' => 0,
+                        'team_id' => 0,
+                        'equipment_id' => 0
+                    ]);
+                $process_model->where('order_product_id',$value['order_product_id'])
+                    ->where('process_id',$value['process_id'])
+                    ->where('dispatch_no',$value['dispatch_no'])
+                    ->where('status',4)
+                    ->update([
+                        'del_time' => time()
+                    ]);
+
+                $result[$key]['quantity'] = $value['finished_num'];
+                $insertSqlServer[] = $result[$key];
+            }
+
+            DispatchSub::whereIn('id',$id)->update([
+                'finished_num' => 0,
+                'waste_num' => 0
+            ]);
+
+            //入库单红字生成
+            $this->insertSqlServer($insertSqlServer);
+
+            DB::commit();
+        }catch (\Throwable $e){
+            DB::rollBack();
+            return [false,$e->getMessage()];
+        }
+
+        return [true,''];
+    }
+
+    //产成品入库
+    public function insertSqlServer($array){
+        if(empty($array)) return [true,''];
+
+        $sqlServerModel = new FyySqlServerService();
+        list($status,$msg) = $sqlServerModel->U8Rdrecord10Save($array,1);
+
+        return [$status,$msg];
+    }
+}

+ 239 - 52
app/Service/DispatchService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\Dispatch;
+use App\Model\DispatchEmpSub;
 use App\Model\DispatchSub;
 use App\Model\Employee;
 use App\Model\EmployeeTeamPermission;
@@ -51,7 +52,7 @@ class DispatchService extends Service
             DB::beginTransaction();
 
             //主表
-            Dispatch::insert(['dispatch_no' => $dispatch_no,'process_id' => $data['process_id'],'equipment_id' => $data['equipment_id'], 'team_id' => $data['team_id'],'dispatch_time_start' => $data['dispatch_time'][0],'dispatch_time_end' => $data['dispatch_time'][1], 'crt_time' => time()]);
+            Dispatch::insert(['dispatch_no' => $dispatch_no,'crt_time' => time()]);
 
             //生产数据的源数据
             $result = $msg;
@@ -61,18 +62,25 @@ class DispatchService extends Service
             $process_model = new OrdersProductProcess(['channel' => $time_tmp]);
 
             $time = time();
+            $equipment_id = is_array($data['equipment_id']) ? $data['equipment_id'] : [$data['equipment_id']];
+            $equipment_id = array_filter($equipment_id);
+            $team_id = is_array($data['team_id']) ? $data['team_id'] : [$data['team_id']];
+            $team_id = array_filter($team_id);
+
+            $insert_emp_sub = [];
             foreach ($result as $key => $value){
                 $quantity_tmp = $data['quantity'][$key];
                 $result[$key]['dispatch_no'] = $dispatch_no;
                 $result[$key]['process_id'] = $data['process_id'];
-                $result[$key]['equipment_id'] = $data['equipment_id'];
-                $result[$key]['team_id'] = $data['team_id'];
                 $result[$key]['dispatch_time_start'] = $data['dispatch_time'][0];
                 $result[$key]['dispatch_time_end'] = $data['dispatch_time'][1];
                 $result[$key]['dispatch_quantity'] = $quantity_tmp;
                 $result[$key]['crt_time'] = $time;
                 $result[$key]['crt_id'] = $user['id'];
 
+                $tmp = $this->makeData($equipment_id,$team_id,$data['employee_id'],$result[$key]);
+                $insert_emp_sub = array_merge_recursive($insert_emp_sub,$tmp);
+
                 $process_model->where('order_product_id',$value['order_product_id'])
                     ->where('process_id',$data['process_id'])
                     ->where('dispatch_no','')
@@ -85,6 +93,8 @@ class DispatchService extends Service
 
             DispatchSub::insert($result);
 
+            if(! empty($insert_emp_sub)) DispatchEmpSub::insert($insert_emp_sub);
+
             //反写已派工数量
             $this->writeDispatchQuantity(array_column($result,'order_product_id'));
 
@@ -97,6 +107,80 @@ class DispatchService extends Service
         return [true,'保存成功!'];
     }
 
+    public function makeData($equipment_id, $team_id,$employee_id,$message){
+        $arr = [];
+        if(! empty($equipment_id)){
+            foreach ($equipment_id as $v_e){
+                if(! empty($team_id)){
+                    foreach ($team_id as $t){
+                        if(! empty($employee_id)){
+                            foreach ($employee_id as $e){
+                                $arr[] = [
+                                    'equipment_id' => $v_e,
+                                    'team_id' => $t,
+                                    'employee_id' => $e,
+                                    'order_product_id' => $message['order_product_id'],
+                                    'dispatch_no' => $message['dispatch_no'],
+                                ];
+                            }
+                        }else{
+                            $arr[] = [
+                                'equipment_id' => $v_e,
+                                'team_id' => $t,
+                                'order_product_id' => $message['order_product_id'],
+                                'dispatch_no' => $message['dispatch_no'],
+                            ];
+                        }
+                    }
+                }elseif(! empty($employee_id)){
+                    foreach ($employee_id as $e){
+                        $arr[] = [
+                            'equipment_id' => $v_e,
+                            'employee_id' => $e,
+                            'order_product_id' => $message['order_product_id'],
+                            'dispatch_no' => $message['dispatch_no'],
+                        ];
+                    }
+                }else{
+                    $arr[] = [
+                        'equipment_id' => $v_e,
+                        'order_product_id' => $message['order_product_id'],
+                        'dispatch_no' => $message['dispatch_no'],
+                    ];
+                }
+            }
+        }elseif (! empty($team_id)){
+            foreach ($team_id as $t){
+                if(! empty($employee_id)){
+                    foreach ($employee_id as $e){
+                        $arr[] = [
+                            'team_id' => $t,
+                            'employee_id' => $e,
+                            'order_product_id' => $message['order_product_id'],
+                            'dispatch_no' => $message['dispatch_no'],
+                        ];
+                    }
+                }else{
+                    $arr[] = [
+                        'team_id' => $t,
+                        'order_product_id' => $message['order_product_id'],
+                        'dispatch_no' => $message['dispatch_no'],
+                    ];
+                }
+            }
+        }elseif(! empty($employee_id)){
+            foreach ($employee_id as $e){
+                $arr[] = [
+                    'employee_id' => $e,
+                    'order_product_id' => $message['order_product_id'],
+                    'dispatch_no' => $message['dispatch_no'],
+                ];
+            }
+        }
+
+        return $arr;
+    }
+
     public function del($data){
         if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
 
@@ -130,7 +214,7 @@ class DispatchService extends Service
 
         $model = OrdersProduct::where('del_time',0)
             ->select('id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','production_time','production_no','status','crt_id')
-//            ->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]])
+            ->whereBetween('out_order_no_time',[$data['out_order_no_time'][0],$data['out_order_no_time'][1]])
             ->whereIn('id',$msg)
             ->orderBy('id','desc');
 
@@ -186,11 +270,10 @@ class DispatchService extends Service
         if(empty($data['dispatch_time'][0]) || empty($data['dispatch_time'][1])) return [false,'计划生产时间不能为空!'];
         if(empty($data['out_order_no_time'][0]) || empty($data['out_order_no_time'][1])) return [false,'制单时间不能为空!'];
         if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
-        if($this->isEmpty($data,'equipment_id')) return [false,'设备不能为空!'];
-        if($this->isEmpty($data,'team_id')) return [false,'班组不能为空!'];
 
         $result = OrdersProduct::whereIn('id',$data['id'])
-            ->select('id as order_product_id','sale_orders_product_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','production_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','sale_orders_product_id','out_order_no_time')
+            ->select('id as order_product_id','sale_orders_product_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','production_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','sale_orders_product_id','out_order_no_time','price','customer_name')
+            ->orderBy('id','desc')
             ->get()->toArray();
 
         //已派工数据
@@ -246,28 +329,43 @@ class DispatchService extends Service
 
     public function dispatchOrderList($data){
         $model = DispatchSub::where('del_time',0)
-            ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','production_quantity','dispatch_no','status','crt_id','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','crt_time')
+            ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','production_quantity','dispatch_no','status','crt_id','process_id','dispatch_time_start','dispatch_time_end','crt_time','finished_num','waste_num','customer_name')
             ->orderBy('id','desc');
 
+        if(isset($data['finished_num'])) $model->where('finished_num', '>',0);
+
         if(! empty($data['order_no'])) $model->where('order_no', 'LIKE', '%'.$data['order_no'].'%');
         if(! empty($data['dispatch_no'])) $model->where('dispatch_no', 'LIKE', '%'.$data['dispatch_no'].'%');
         if(! empty($data['process_id'])) $model->where('process_id',$data['process_id']);
-        if(! empty($data['team_id'])) $model->where('team_id',$data['team_id']);
-        if(! empty($data['equipment_id'])) $model->where('equipment_id',$data['equipment_id'].'%');
         if(! empty($data['technology_material'])) $model->where('technology_material', 'LIKE', '%'.$data['technology_material'].'%');
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) $model->whereBetween('crt_time',[$data['crt_time'][0],$data['crt_time'][1]]);
         if(! empty($data['dispatch_time'][0]) && ! empty($data['dispatch_time'][1])){
             $model->where('dispatch_time_start','<=',$data['dispatch_time'][0]);
             $model->where('dispatch_time_end','>=',$data['dispatch_time'][1]);
         }
+        if(! empty($data['team_id'])) {
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('team_id',$data['team_id'])
+                ->distinct()
+                ->select('dispatch_no')
+                ->get()->toArray();
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
+        }
+        if(! empty($data['equipment_id'])) {
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('equipment_id',$data['equipment_id'])
+                ->distinct()
+                ->select('dispatch_no')
+                ->get()->toArray();
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
+        }
         if(! empty($data['employee_id'])) {
-            $team_id = Employee::from('employee as a')
-                ->leftJoin('employee_team_permission as b','b.employee_id','a.id')
-                ->where('a.id', $data['employee_id'])
-                ->select('b.team_id')
+            $res = DispatchEmpSub::where('del_time',0)
+                ->where('employee_id',$data['employee_id'])
+                ->distinct()
+                ->select('dispatch_no')
                 ->get()->toArray();
-            $team_id = array_column($team_id,'team_id');
-            $model->where('team_id',$team_id ?? []);
+            $model->whereIn('dispatch_no',array_column($res,'dispatch_no'));
         }
 
         $list = $this->limit($model,'',$data);
@@ -279,34 +377,40 @@ class DispatchService extends Service
     public function fillDispatchOrderListData($data){
         if(empty($data['data'])) return $data;
 
-        $team = EmployeeTeamPermission::from('employee_team_permission as a')
-            ->leftJoin('employee as b','b.id','a.employee_id')
-            ->whereIn('a.team_id',array_column($data['data'],'team_id'))
-            ->select('b.emp_name','a.team_id')
-            ->get()
-            ->toArray();
-        $team_map = [];
-        if(! empty($team)){
-            foreach ($team as $value){
-                if(isset($team_map[$value['team_id']])){
-                    $team_map[$value['team_id']] .= ','. $value['emp_name'];
-                }else{
-                    $team_map[$value['team_id']] = $value['emp_name'];
-                }
+        $emp_sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($data['data'],'dispatch_no'))
+            ->select('dispatch_no','equipment_id','team_id','employee_id')
+            ->get()->toArray();
+        if(! empty($emp_sub)){
+            $team_map = Team::whereIn('id',array_unique(array_column($emp_sub,'team_id')))
+                ->pluck('title','id')
+                ->toArray();
+            $equipment_map = Equipment::whereIn('id',array_unique(array_column($emp_sub,'equipment_id')))
+                ->pluck('title','id')
+                ->toArray();
+            $emp_map = Employee::whereIn('id',array_unique(array_column($emp_sub,'employee_id')))
+                ->pluck('emp_name','id')
+                ->toArray();
+
+            $equipment_map1 = $team_map1 = $employee_map1 = $employee_map2 = $equipment_map2 = $team_map2 =  [];
+            foreach ($emp_sub as $value){
+                $equipment_name = $equipment_map[$value['equipment_id']] ?? '';
+                $team_name = $team_map[$value['team_id']] ?? '';
+                $employee_name = $emp_map[$value['employee_id']] ?? '';
+
+                $equipment_map1[$value['dispatch_no']][] = $equipment_name;
+                $equipment_map2[$value['dispatch_no']][] = $value['equipment_id'];
+                $team_map1[$value['dispatch_no']][] = $team_name;
+                $team_map2[$value['dispatch_no']][] = $value['team_id'];
+                $employee_map1[$value['dispatch_no']][] = $employee_name;
+                $employee_map2[$value['dispatch_no']][] = $value['employee_id'];
             }
         }
 
         $process_map = Process::whereIn('id',array_column($data['data'],'process_id'))
             ->pluck('title','id')
             ->toArray();
-        $team_maps = Team::whereIn('id',array_column($data['data'],'team_id'))
-            ->pluck('title','id')
-            ->toArray();
-        $equipment_map = Equipment::whereIn('id',array_column($data['data'],'equipment_id'))
-            ->pluck('title','id')
-            ->toArray();
 
-        $finished_map = $this->getFinishedQuantity(array_column($data['data'],'id'));
         date_default_timezone_set("PRC");
         foreach ($data['data'] as $key => $value){
             $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d',$value['crt_time']) : '';
@@ -314,18 +418,21 @@ class DispatchService extends Service
             $time1 = $value['dispatch_time_start'] ? date('Y-m-d',$value['dispatch_time_start']) : '';
             $time2 = $value['dispatch_time_end'] ? date('Y-m-d',$value['dispatch_time_end']) : '';
             $data['data'][$key]['dispatch_time'] = $time1 . ' ' . $time2;
-            $data['data'][$key]['team_man'] = $team_map[$value['team_id']] ?? '';
             $data['data'][$key]['process_name'] = $process_map[$value['process_id']] ?? '';
-            $data['data'][$key]['team_name'] = $team_maps[$value['team_id']] ?? '';
-            $data['data'][$key]['equipment_name'] = $equipment_map[$value['equipment_id']] ?? '';
-            $data['data'][$key]['un_finished_quantity'] = $value['dispatch_quantity'] - ($finished_map[$value['id']] ?? 0);
+            $data['data'][$key]['team_man'] = implode(',',array_unique($employee_map1[$value['dispatch_no']]));
+            $data['data'][$key]['team_man_id'] = array_unique($employee_map2[$value['dispatch_no']]);
+            $data['data'][$key]['team_name'] = implode(',',array_unique($team_map1[$value['dispatch_no']]));
+            $data['data'][$key]['team_id'] = implode(',',array_unique($team_map2[$value['dispatch_no']]));
+            $data['data'][$key]['equipment_name'] = implode(',',array_unique($equipment_map1[$value['dispatch_no']]));
+            $data['data'][$key]['equipment_id'] = implode(',',array_unique($equipment_map2[$value['dispatch_no']]));
+            $data['data'][$key]['un_finished_quantity'] = $value['dispatch_quantity'] - $value['finished_num'];
         }
         $data['dispatch_quantity'] = array_sum(array_column($data['data'], 'dispatch_quantity'));
 
         return $data;
     }
 
-    //反写写工数量
+    //反写写工数量
     public function writeDispatchQuantity($order_product_id){
         if(empty($order_product_id)) return;
 
@@ -345,17 +452,97 @@ class DispatchService extends Service
         }
     }
 
-    //返回已完工数量
-    public function getFinishedQuantity($dispatch_id = []){
-        if(empty($dispatch_id)) return [];
+    //设备上的去完工列表
+    public function dispatchMobileOrderList($data){
+        $model = DispatchSub::where('del_time',0)
+            ->select('id','product_title','product_no','dispatch_quantity','finished_num','dispatch_no')
+            ->where('process_id',$data['process_id'])
+            ->whereRaw('dispatch_quantity > finished_num')
+            ->orderBy('id','desc');
+
+        $list = $model->get()->toArray();
+        $list = $this->fillDispatchMobileOrderList($list);
+
+        return [true,$list];
+    }
+
+    public function fillDispatchMobileOrderList($data){
+        if(empty($data)) return $data;
+
+        date_default_timezone_set("PRC");
+        foreach ($data as $key => $value){
+            $data[$key]['un_finished_quantity'] = $value['dispatch_quantity'] - $value['finished_num'];
+        }
+
+        $return['product_num'] = count($data);
+        $return['finished_num'] = array_sum(array_column($data, 'finished_num'));
+        $return['un_finished_quantity'] = array_sum(array_column($data, 'un_finished_quantity'));
+        $return['data'] = $data;
+        unset($data);
+
+        return $return;
+    }
+
+    //设备上完工填写数据的页面
+    public function dispatchMobileOrderDetailsList($data){
+        if(empty($data['id'])) return [false,'派工单ID不能为空!'];
 
-        $result = FinishedOrderSub::where('del_time',0)
-            ->whereIn("dispatch_id",$dispatch_id)
-            ->select(DB::raw("sum(finished_num) as finished_num"),'dispatch_id')
-            ->groupby('dispatch_id')
-            ->pluck('finished_num','dispatch_id')
-            ->toArray();
+        $dispatch = DispatchSub::whereIn('id',$data['id'])
+            ->where('del_time',0)
+            ->select('id','product_title','product_no','dispatch_no',DB::raw('(dispatch_quantity - finished_num) as quantity'))
+            ->get()->toArray();
 
-        return $result;
+        $sub = DispatchEmpSub::where('del_time',0)
+            ->whereIn('dispatch_no',array_column($dispatch,'dispatch_no'))
+            ->select('dispatch_no','equipment_id','team_id','employee_id')
+            ->get()->toArray();
+
+        $sub_map = [];
+        foreach ($sub as $s){
+            $array = [
+                'equipment_id' => $s['equipment_id'],
+                'team_id' => $s['team_id'],
+                'employee_id' => $s['employee_id'],
+            ];
+            if(empty($sub_map[$s['dispatch_no']])){
+                $sub_map[$s['dispatch_no']][] = $array;
+            }else{
+                if(! in_array($array,$sub_map[$s['dispatch_no']])) {
+                    $sub_map[$s['dispatch_no']][] = $array;
+                }
+            }
+        }
+
+        $return_list = $return_details = [];
+        foreach ($dispatch as $value){
+            $dispatch_tmp = $sub_map[$value['dispatch_no']];
+            $counts = count($dispatch_tmp) ?? 1;
+            // 计算每个人应该得到的数量
+            $per_person = floor($value['quantity'] / $counts);
+            // 计算最后一个人拿到的数量
+            $last_person = $value['quantity'] - ($per_person * ($counts - 1));
+            foreach ($dispatch_tmp as $k => $t){
+                $dispatch_tmp[$k]['id'] = $value['id'];
+                $dispatch_tmp[$k]['product_title'] = $value['product_title'];
+                $dispatch_tmp[$k]['product_no'] = $value['product_no'];
+                $dispatch_tmp[$k]['dispatch_no'] = $value['dispatch_no'];
+                if ($k == $counts - 1) {
+                    $dispatch_tmp[$k]['quantity'] = (int)$last_person;
+                }else{
+                    $dispatch_tmp[$k]['quantity'] = (int)$per_person;
+                }
+            }
+
+            //列数据
+            $return_list = array_merge_recursive($return_list,$dispatch_tmp);
+
+            //总数量
+            $return_details[$value['id']] = $value['quantity'];
+        }
+
+        $return['list'] = $return_list;
+        $return['list_details'] = $return_details;
+
+        return [true, $return];
     }
 }

+ 159 - 60
app/Service/EmployeeService.php

@@ -21,55 +21,51 @@ use Illuminate\Support\Facades\Hash;
  */
 class EmployeeService extends Service
 {
-
-    public function employeeEdit($data){
-        list($status,$msg) = $this->employeeRule($data);
+    public function employeeEdit($data,$user){
+        list($status,$msg) = $this->employeeRule($data,false);
         if(!$status) return [$status,$msg];
-        $first = SysMenu::where('emp_id',$data['emp_id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'工号已存在!'];
 
         $model = new Employee();
         $model = $model->where('id',$data['id'])->first();
-
         $model->id_card = $data['id_card']??'';
-        $model->emp_id = $data['emp_id'] ;
-        $model->mobile = $data['mobile'];
+        $model->number = $data['number'] ;
+        $model->mobile = $data['mobile']??'';
         $model->emp_name = $data['emp_name'];
-        $model->state = 1;
-//        $model->crt_id = $user->id;
-//        $model->crt_time = time();
         $model->is_admin = $data['is_admin'];
         if($model->is_admin == 1){
             $model->account = $data['account'];
             if($data['password'] !== '********'){
                 $model->password   = Hash::make($data['password']);
             }
-
         }
         $model->save();
-        return [true,'保存成功!'];
 
+        $permisson_model = new EmployeeDepartPermission();
+        $permisson_model = $permisson_model->where('employee_id',$data['id'])->first();
+        if($permisson_model){
+            $permisson_model->depart_id = $data['depart_id'] ?? 0;
+            $permisson_model->save();
+        }else{
+            $permisson_model = new EmployeeDepartPermission();
+            $permisson_model->employee_id = $data['id'];
+            $permisson_model->depart_id = $data['depart_id'] ?? 0;
+            $permisson_model->save();
+        }
+
+        return [true,'保存成功!'];
     }
 
     public function employeeAdd($data,$user){
-
-
-//        if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
         list($status,$msg) = $this->employeeRule($data);
         if(!$status) return [$status,$msg];
-//        $first = SysMenu::where('title',$data['title'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
 
         $model = new Employee();
-
         $model->id_card = $data['id_card']??'';
-        $model->emp_id = $data['emp_id'] ;
-        $model->mobile = $data['mobile'];
+        $model->number = $data['number'] ;
+        $model->mobile = $data['mobile']??'';
         $model->emp_name = $data['emp_name'];
         $model->state = 1;
-//        $model->crt_id = $user->id;
-        $model->crt_id = 1;
-//        $model->crt_time = time();
+        $model->crt_id = $user['id'];
         $model->is_admin = $data['is_admin'];
         if($model->is_admin == 1){
             $model->account = $data['account'];
@@ -77,8 +73,14 @@ class EmployeeService extends Service
         }
         $model->save();
 
-        return [true,'保存成功!'];
+        if(! empty($data['depart_id'])){
+            $permisson_model = new EmployeeDepartPermission();
+            $permisson_model->employee_id = $model->id;
+            $permisson_model->depart_id = $data['depart_id'];
+            $permisson_model->save();
+        }
 
+        return [true,'保存成功!'];
     }
 
     public function employeeDel($data){
@@ -93,7 +95,7 @@ class EmployeeService extends Service
 
     public function employeeList($data){
         $model = Employee::where('del_time',0)
-            ->select('id_card','emp_name','mobile','emp_name','crt_time','account','is_admin','upd_time','id')
+            ->select('id_card','emp_name','mobile','crt_time','account','is_admin','upd_time','id','number')
             ->orderBy('id','desc');
 
         if(! empty($data['depart_id'])) {
@@ -108,22 +110,64 @@ class EmployeeService extends Service
             $employee_id = array_column($employee_id,'employee_id');
             $model->whereIn("id", $employee_id);
         }
+        if(! empty($data['number'])) $model->where('number', 'LIKE', '%'.$data['number'].'%');
+        if(! empty($data['emp_name'])) $model->where('emp_name', 'LIKE', '%'.$data['emp_name'].'%');
 
         $list = $this->limit($model,'',$data);
 
+        //组织数据
+        $list = $this->organizationEmployeeData($list);
+
         return [200,$list];
     }
 
-    public function employeeRule($data){
-        if($this->isEmpty($data,'emp_id')) return [false,'工号不存在!'];
-//        if($this->isEmpty($data,'icon')) return [201,'d不存在!'];
-        if($this->isEmpty($data,'mobile')) return [false,'手机号不存在!'];
+    public function organizationEmployeeData($data) {
+        if (empty($data['data'])) return $data;
+
+        $res = DB::table('employee_depart_permission as a')
+            ->select('a.employee_id','b.title','b.id')
+            ->join('depart as b','a.depart_id','=','b.id')
+            ->whereIn("a.employee_id",array_column($data['data'],'id'))
+            ->get()->toArray();
+        $map = array_column($res,null,'employee_id');
+
+        $res = DB::table('employee_team_permission as a')
+            ->select('a.employee_id','b.title','b.id')
+            ->join('team as b','a.team_id','=','b.id')
+            ->whereIn("a.employee_id",array_column($data['data'],'id'))
+            ->get()->toArray();
+        $map2 = array_column($res,null,'employee_id');
+
+        foreach ($data['data'] as $key => $value){
+            $data['data'][$key]['depart_id'] = $map[$value['id']]->id ?? '';
+            $data['data'][$key]['depart_title'] = $map[$value['id']]->title ?? '';
+        }
+        return $data;
+    }
+
+    public function employeeRule($data,$is_add = true){
+        if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
         if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
+        if(! $is_add){
+            if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
+            $bool = Employee::where('number',$data['number'])
+                ->where('id','<>',$data['id'])
+                ->where('del_time',0)->exists();
+            $bool_account = Employee::where('account',$data['account'])
+                ->where('id','<>',$data['id'])
+                ->where('del_time',0)->exists();
+        }else{
+            $bool = Employee::where('number',$data['number'])
+                ->where('del_time',0)->exists();
+            $bool_account = Employee::where('account',$data['account'])
+                ->where('del_time',0)->exists();
+        }
+        if($bool) return [false,'工号已存在!'];
+        if($bool_account) return [false,'账号已存在!'];
 
         return [true,''];
     }
 
-
     public function roleEdit($data){
         list($status,$msg) = $this->roleRule($data);
         if(!$status) return [$status,$msg];
@@ -182,47 +226,32 @@ class EmployeeService extends Service
         return [true,''];
     }
 
-
     public function departEdit($data){
-        list($status,$msg) = $this->departRule($data);
+        list($status,$msg) = $this->departRule($data,false);
         if(!$status) return [$status,$msg];
-        $first = Depart::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
+
+        $update = $msg['data'][0];
 
         $model = new Depart();
-        $model = $model->where('id',$data['id'])->first();
+        $model->where('id',$data['id'])->update($update);
 
-        $model->title = $data['title'];
-        $model->code = $data['code']??'';
-        $model->save();
         return [true,'保存成功!'];
-
     }
 
-    public function departAdd($data,$user){
-
-
-//        if($this->isEmpty($data,'title')) return [201,'名称不存在!'];
+    public function departAdd($data){
         list($status,$msg) = $this->departRule($data);
         if(!$status) return [$status,$msg];
-        $first = Depart::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
-        if(!empty($first))return [false,'名称已存在!'];
-
-        $model = new Depart();
-
-        $model->title = $data['title'] ;
-        $model->code = $data['code'] ?? '' ;
 
-        $model->save();
+        Depart::insert($msg['data']);
 
         return [true,'保存成功!'];
-
     }
 
     public function departDel($data){
-        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
+        list($status,$msg) = $this->checkDepartDel($data);
+        if(! $status) return [false, $msg];
 
-        Depart::where('id',$data['id'])->update([
+        Depart::whereIn('id',$data['id'])->update([
             'del_time'=>time()
         ]);
 
@@ -231,7 +260,7 @@ class EmployeeService extends Service
 
     public function departList($data){
         $model = Depart::where('del_time',0)
-            ->select('title','id','code','parent_id')
+            ->select('title','id','code','parent_id','is_use')
             ->orderby('code', 'asc');
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
         if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
@@ -245,12 +274,82 @@ class EmployeeService extends Service
         return [200,$list];
     }
 
-    public function departRule($data){
-        if($this->isEmpty($data,'title')) return [false,'名称不存在!'];
+    public function departRule($data, $is_check = true){
+        if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
+
+        $code = array_column($data['data'],'code');
+        $title = array_column($data['data'],'title');
+        $code = array_map(function($val) {
+            return $val !== null ? $val : 0;
+        }, $code);
+        $title = array_map(function($val) {
+            return $val !== null ? $val : 0;
+        }, $title);
+        $code_count = array_count_values($code);
+        $title_count = array_count_values($title);
+        foreach ($code as $value){
+            if(empty($value)) return [false,'编码不能为空!'];
+            if($code_count[$value] > 1) return [false,'编码不能重复'];
+        }
+        foreach ($title as $value){
+            if(empty($value)) return [false,'名称不能为空!'];
+            if($title_count[$value] > 1) return [false,'名称不能重复'];
+        }
 
-        return [true,''];
+        $depart_id = array_filter(array_column($data['data'],'parent_id'));
+        $res = $this->checkDepartHasPerson($depart_id);
+        if($res) return [false,'部门下已有人员,不能新建子部门!'];
+
+        foreach ($data['data'] as $key => $value){
+            if(empty($value['parent_id'])) $data['data'][$key]['parent_id'] = 0;
+
+            $data['data'][$key]['upd_time'] = time();
+            if($is_check){
+                $data['data'][$key]['crt_time'] = time();
+                $bool = Depart::whereRaw("(binary code = '{$value['code']}' OR title = '{$value['title']}')")
+                    ->where('del_time',0)
+                    ->exists();
+            }else{
+                if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
+
+                if(! $value['is_use']) {
+                    $bool_is = $this->checkDepartHasPerson([$data['id']]);
+                    if($bool_is) return [false,'部门下已经有人员,停用失败!'];
+                }
+                $bool = Depart::whereRaw("(binary code = '{$value['code']}' OR title = '{$value['title']}')")
+                    ->where('id','<>',$data['id'])
+                    ->where('del_time',0)
+                    ->exists();
+            }
+            if($bool) return [false,'编码或部门名称不能重复'];
+        }
+
+        return [true, $data];
     }
 
+    public function checkDepartDel($data){
+        if($this->isEmpty($data,'id')) return [false,'ID必须!'];
+
+        $bool = Depart::whereIn('parent_id',$data['id'])->where('del_time',0)->exists();
+        if($bool) return [false,'部门下有子部门!'];
+
+        if($this->checkDepartHasPerson($data['id'])) return [false,'部门下有人员档案!'];
+
+        return [true, ''];
+    }
+
+    //检测部门下是否存在人员
+    public function checkDepartHasPerson($depart_id = []){
+        if(empty($depart_id)) return false;
+
+        $bool = EmployeeDepartPermission::from('employee_depart_permission as a')
+            ->leftJoin('employee as b','b.id','a.employee_id')
+            ->where('b.del_time',0)
+            ->whereIn('a.depart_id',$depart_id)
+            ->exists();
+
+        return $bool;
+    }
 
     public function teamEdit($data){
         list($status,$msg) = $this->teamRule($data,false);
@@ -425,7 +524,7 @@ class EmployeeService extends Service
 
         $res = reset($res);
         if(! Hash::check($data['password'], $res['password'])) return [false,'密码错误!'];
-        if($res['is_admin'] != Employee::IS_ADMIN) return [false,'非管理员账号!'];
+        if($res['is_admin'] != Employee::IS_ADMIN) return [false,'该账号不能登录!'];
         if($res['state'] == Employee::NOT_USE) return [false,'账号停用!'];
 
         return [true, ['id'=>$res['id'], 'name'=>$res['emp_name'], 'account' => $res['account']]];

+ 225 - 71
app/Service/FinishedOrderService.php

@@ -14,6 +14,7 @@ use App\Model\OrdersProduct;
 use App\Model\OrdersProductProcess;
 use App\Model\Process;
 use App\Model\SaleOrdersProduct;
+use App\Model\Scrapp;
 use App\Model\Team;
 use Illuminate\Support\Facades\DB;
 
@@ -49,64 +50,102 @@ class FinishedOrderService extends Service
         list($status,$msg) = $this->orderRule($data);
         if(!$status) return [$status,$msg];
 
-        $finished_no = $this->setOrderNO();
         try{
             DB::beginTransaction();
 
-            //主表
-            FinishedOrder::insert(['finished_no' => $finished_no, 'crt_time' => time()]);
+            $waste = [];
+            foreach ($data['waste'] as $key => $value){
+                $waste[$key] = array_sum(array_column($value,'num'));
+            }
 
             //生产数据的源数据
             $result = $msg;
             $time = time();
 
             date_default_timezone_set("PRC");
+
+            $insert_sql_server = [];
             foreach ($result as $key => $value){
                 $quantity_tmp = $data['quantity'][$key];
+                $finished_id_tmp = $data['finish_id'][$key];
+                $team_tmp = $data['team_id'][$key];
+                $equipment_id_tmp = $data['equipment_id'][$key];
+                $result[$key]['quantity'] = $quantity_tmp;
 
-                $team_id_tmp = $data['team_id'][$key] ?? 0;
-                $equipment_id_tmp = $data['equipment_id'][$key] ?? 0;
+                $finished_num = $quantity_tmp + $value['finished_num'];
+                DispatchSub::where('id',$value['id'])
+                    ->update([
+                        'finished_num' => $finished_num,
+                        'waste_num' => $waste[$key]
+                    ]);
 
-                $result[$key]['team_id'] = $team_id_tmp;
-                $result[$key]['equipment_id'] = $equipment_id_tmp;
-                $result[$key]['finished_no'] = $finished_no;
-                $result[$key]['finished_num'] = $quantity_tmp;
-                $result[$key]['crt_time'] = $time;
-                $result[$key]['crt_id'] = $user['id'];
+                $insert_waste = [];
+                if(! empty($data['waste'][$key])){
+                    foreach ($data['waste'][$key] as $v){
+                        for($i = 0 ;$i < $v['num']; $i++){
+                            $insert_waste[] = [
+                                'order_product_id' => $value['order_product_id'],
+                                'order_no' => $value['order_no'],
+                                'product_no' => $value['product_no'],
+                                'product_title' => $value['product_title'],
+                                'process_id' => $value['process_id'],
+                                'crt_time' => $time,
+                                'dispatch_no' => $value['dispatch_no'],
+                                'status' => 4,
+                                'team_id' => $team_tmp,
+                                'finished_id' => $finished_id_tmp,
+                                'equipment_id' => $equipment_id_tmp,
+                                'scrapp_id' => $v['scrapp_id']
+                            ];
+                        }
+                    }
+                }
 
+                //工序表
                 $process_model = new OrdersProductProcess(['channel' => date("Ymd",$value['out_order_no_time'])]);
+
+                $process_id = $process_model->select('process_id')
+                    ->where('sort',$process_model->where('del_time',0)
+                        ->where('order_product_id',$value['order_product_id'])
+                        ->max('sort'))
+                    ->first();
+
+                if(empty($process_id)){
+                    DB::rollBack();
+                    return [false,"未找到最后一道工序"];
+                }
+                $process_id = $process_id->process_id;
+                if($process_id == $value['process_id']){
+                    $insert_sql_server[] = $result[$key];
+                }
+
                 $process_model->where('order_product_id',$value['order_product_id'])
                     ->where('process_id',$value['process_id'])
                     ->where('dispatch_no',$value['dispatch_no'])
                     ->take($quantity_tmp)
                     ->update([
-                        'finished_no' => $finished_no,
-                        'status' => 2
+                        'finished_time' => $time,
+                        'status' => 2,
+                        'finished_id' => $finished_id_tmp,
+                        'team_id' => $team_tmp,
+                        'equipment_id' => $equipment_id_tmp
                     ]);
 
-                unset($result[$key]['order_product_id']);
+                if(! empty($insert_waste)) $process_model->insert($insert_waste);
             }
 
-            FinishedOrderSub::insert($result);
+            //反写数量
+            $this->writeFinishedQuantity(array_column($result,'sale_orders_product_id'));
 
-            //获取上一次插入订单的所有id
-            $insert = [];
-            $last_insert_id = FinishedOrderSub::where('finished_no',$finished_no)->select('id')->get()->toArray();
-            $last_insert_id = array_column($last_insert_id,'id');
-            foreach ($data['waste'] as $key => $value){
-                foreach ($value as $v){
-                    if(empty($value)) continue;
-
-                    $insert[] = [
-                        'finished_order_id' => $last_insert_id[$key],
-                        'num' => $v['num'],
-                        'scrapp_id' => $v['scrapp_id']
-                    ];
+            if(! empty($insert_sql_server)){
+                foreach ($insert_sql_server as $value){
+                    list($status,$msg) = $this->insertSqlServer($value);
+                    if(! $status) {
+                        DB::rollBack();
+                        return [false,$msg];
+                    }
                 }
             }
-            if(!empty($insert)) FinishedOrderScrapp::insert($insert);
-
-            $this->writeFinishedQuantity(array_column($result,'sale_orders_product_id'));
 
             DB::commit();
         }catch (\Exception $e){
@@ -124,7 +163,29 @@ class FinishedOrderService extends Service
     }
 
     public function orderDetail($data){
-        return [200,''];
+        if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
+
+        date_default_timezone_set("PRC");
+
+        $first = DispatchSub::where('id',$data['id'])->first();
+        $process_model = new OrdersProductProcess(['channel' => date("Ymd",$first->out_order_no_time)]);
+
+        $result = $process_model->where('del_time',0)
+            ->where('dispatch_no',$first->dispatch_no)
+            ->where('order_product_id',$first->order_product_id)
+            ->where('status',4)
+            ->select(DB::raw('count(id) as num'),'scrapp_id')
+            ->groupBy('scrapp_id')
+            ->get()->toArray();
+
+        $map = Scrapp::whereIn('id',array_column($result,'scrapp_id'))
+            ->pluck('title','id')
+            ->toArray();
+        foreach ($result as $key => $value){
+            $result[$key]['scrapp_name'] = $map[$value['scrapp_id']] ?? '';
+        }
+
+        return [true,$result];
     }
 
     public function is_same_month($timestamp1,$timestamp2){
@@ -144,6 +205,23 @@ class FinishedOrderService extends Service
         }
     }
 
+    public function orderRule($data){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+        if($this->isEmpty($data,'quantity')) return [false,'请填写完工数量!'];
+        if($this->isEmpty($data,'finish_id') && $this->isEmpty($data,'team_id')) return [false,'人员和班组不能都为空!'];
+
+        $result = DispatchSub::whereIn('id',$data['id'])
+            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title','price','customer_name')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+
+        foreach ($result as $key => $value){
+            if(($data['quantity'][$key] + $value['finished_num']) > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
+        }
+
+        return [true, $result];
+    }
+
     public function orderList($data){
         $model = FinishedOrderSub::where('del_time',0)
             ->select('id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','dispatch_quantity','finished_num','status','crt_id','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','dispatch_time','crt_time','dispatch_no')
@@ -176,30 +254,6 @@ class FinishedOrderService extends Service
         return [true,$list];
     }
 
-    public function orderRule($data){
-        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
-        if($this->isEmpty($data,'quantity')) return [false,'请填写完工数量!'];
-        if($this->isEmpty($data,'team_id')) return [false,'班组不能为空!'];
-        if($this->isEmpty($data,'equipment_id')) return [false,'设备不能为空!'];
-
-        $result = DispatchSub::whereIn('id',$data['id'])
-            ->select('order_product_id','dispatch_no','id as dispatch_id','order_no','table_header_mark','product_no','product_title','product_size','product_unit','dispatch_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','process_id','equipment_id','team_id','dispatch_time_start','dispatch_time_end','crt_time as dispatch_time','sale_orders_product_id','out_order_no_time')
-            ->get()->toArray();
-
-        //已完工数据
-        $map = $this->getFinishedQuantity($data['id']);
-
-        foreach ($result as $key => $value){
-            if(isset($map[$value['dispatch_id']])){
-                if($map[$value['dispatch_id']] + $data['quantity'][$key] > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
-            }else{
-                if($data['quantity'][$key] > $value['dispatch_quantity']) return [false,'完工数量不能大于派工数量'];
-            }
-        }
-
-        return [true, $result];
-    }
-
     public function fillData($data){
         if(empty($data['data'])) return $data;
 
@@ -273,25 +327,11 @@ class FinishedOrderService extends Service
         return $data;
     }
 
-    //返回已完工工数量
-    public function getFinishedQuantity($dispatch_id = []){
-        if(empty($dispatch_id)) return [];
-
-        $result = FinishedOrderSub::where('del_time',0)
-            ->whereIn("dispatch_id",$dispatch_id)
-            ->select(DB::raw("sum(dispatch_quantity) as finished_num"),'dispatch_id')
-            ->groupby('dispatch_id')
-            ->pluck('finished_num','dispatch_id')
-            ->toArray();
-
-        return $result;
-    }
-
     //反写写完工数量
     public function writeFinishedQuantity($sale_orders_product_id){
         if(empty($sale_orders_product_id)) return;
 
-        $result = FinishedOrderSub::where('del_time',0)
+        $result = DispatchSub::where('del_time',0)
             ->whereIn('sale_orders_product_id',$sale_orders_product_id)
             ->select(DB::raw("sum(finished_num) as finished_num"),'sale_orders_product_id')
             ->groupby('sale_orders_product_id')
@@ -306,4 +346,118 @@ class FinishedOrderService extends Service
             ]);
         }
     }
+
+    public function mobileAdd($data,$user){
+        //数据校验以及填充
+        list($status,$msg,$count_arr) = $this->orderMobileRule($data);
+        if(!$status) return [$status,$msg];
+
+        try{
+            DB::beginTransaction();
+
+            //生产数据的源数据
+            $result = $msg;
+            $time = time();
+
+            date_default_timezone_set("PRC");
+
+            $insert_sql_server = [];
+            foreach ($result as $key => $value){
+                $quantity_tmp = $count_arr[$value['id']];
+                $result[$key]['quantity'] = $quantity_tmp;
+
+                $finished_num = $quantity_tmp + $value['finished_num'];
+                DispatchSub::where('id',$value['id'])
+                    ->update([
+                        'finished_num' => $finished_num,
+                    ]);
+
+                //工序表
+                $process_model = new OrdersProductProcess(['channel' => date("Ymd",$value['out_order_no_time'])]);
+
+                foreach ($data as $d){
+                    if($d['id'] == $value['id']){
+                        $process_model->where('order_product_id',$value['order_product_id'])
+                            ->where('process_id',$value['process_id'])
+                            ->where('dispatch_no',$value['dispatch_no'])
+                            ->take($d['quantity'])
+                            ->update([
+                                'finished_time' => $time,
+                                'status' => 2,
+                                'finished_id' => $d['finished_id'],
+                                'team_id' => $d['team_id'],
+                                'equipment_id' => $d['equipment_id']
+                            ]);
+                    }
+                }
+
+                $process_id = $process_model->select('process_id')
+                    ->where('sort',$process_model->where('del_time',0)
+                        ->where('order_product_id',$value['order_product_id'])
+                        ->max('sort'))
+                    ->first();
+
+                if(empty($process_id)){
+                    DB::rollBack();
+                    return [false,"未找到最后一道工序"];
+                }
+                $process_id = $process_id->process_id;
+                if($process_id == $value['process_id']){
+                    $insert_sql_server[] = $result[$key];
+                }
+            }
+
+            //反写数量
+            $this->writeFinishedQuantity(array_column($result,'sale_orders_product_id'));
+
+            list($status,$msg) = $this->insertSqlServer($insert_sql_server);
+            if(! $status) {
+                DB::rollBack();
+                return [false,$msg];
+            }
+
+            DB::commit();
+        }catch (\Exception $e){
+            DB::rollBack();
+            return [false,$e->getLine().':'.$e->getMessage()];
+        }
+
+        return [true,'保存成功!'];
+    }
+
+    public function orderMobileRule($data){
+        if(empty($data)) return [false,'数据不能为空!',''];
+
+        $post = [];
+        foreach ($data as $value){
+            if(empty($value['quantity'])) return [false,'数量必须填写!',''];
+            if(empty($value['finished_id']) && empty($value['team_id'])) return [false,'人员和班组必须填写一项!',''];
+            if(isset($post[$value['id']])){
+                $post[$value['id']] += $value['quantity'];
+            }else{
+                $post[$value['id']] = $value['quantity'];
+            }
+        }
+
+        $result = DispatchSub::whereIn('id',array_unique(array_column($data,'id')))
+            ->select('id','finished_num','dispatch_quantity','out_order_no_time','process_id','dispatch_no','order_product_id','sale_orders_product_id','order_no','product_no','product_title','price')
+            ->orderBy('id','desc')
+            ->get()->toArray();
+
+        foreach ($result as $key => $value){
+            if(($post[$value['id']] + $value['finished_num']) > $value['dispatch_quantity']) return [false,"{$value['dispatch_no']}单号的完工数量不能大于派工数量",''];
+        }
+
+        return [true, $result,$post];
+    }
+
+    //产成品入库
+    public function insertSqlServer($array){
+        if(empty($array)) return [true,''];
+
+        $sqlServerModel = new FyySqlServerService();
+        list($status,$msg) = $sqlServerModel->U8Rdrecord10Save($array);
+
+        return [$status,$msg];
+    }
 }

+ 14 - 2
app/Service/FyyOrderService.php

@@ -26,8 +26,8 @@ class FyyOrderService extends Service
         if(! $status) return [false, $return];
 
         //数据校验
-        list($status,$msg) = $this->orderRule($return);
-        if(!$status) return [$status,$msg];
+//        list($status,$msg) = $this->orderRule($return);
+//        if(!$status) return [$status,$msg];
 
         try{
             DB::beginTransaction();
@@ -157,6 +157,7 @@ class FyyOrderService extends Service
         }
         $data['order_quantity'] = array_sum(array_column($data['data'], 'order_quantity'));
         $data['finished_num'] = array_sum(array_column($data['data'], 'finished_num'));
+        $data['product_quantity_on_hand'] = array_sum(array_column($data['data'], 'product_quantity_on_hand'));
 
         return $data;
     }
@@ -198,4 +199,15 @@ class FyyOrderService extends Service
 
         return [true,''];
     }
+
+    public function fyySaveOutOrder($data){
+        if(empty($data['order_number'])) return [false,'包装单号不能为空!'];
+
+        //销售出库单生成
+        $sqlServerModel = new FyySqlServerService();
+        list($status,$return) = $sqlServerModel->U8Rdrecord32Save($data);
+        if(! $status) return [false, $return];
+
+        return [true,''];
+    }
 }

+ 327 - 3
app/Service/FyySqlServerService.php

@@ -2,17 +2,64 @@
 
 namespace App\Service;
 
+use App\Model\BoxDetail;
+use App\Model\Orders;
 use App\Model\SaleOrdersProduct;
+use Illuminate\Support\Facades\Config;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Redis;
 
 class FyySqlServerService extends Service
 {
     public $db = null;
+    public $error = null;
+    public $host = "";
+    public $port = 0;
+    public $database = "";
+    public $url = "";
 
     public function __construct()
     {
-        $domain_name = $_SERVER['HTTP_HOST'];
-        if(! $this->db) $this->db = DB::connection('sqlsrvs');
+        $fyy_array = Redis::get('fyy_sql_server');
+        if(empty($fyy_array)) {
+            $this->error = 'SQLSERVER设置不存在!';
+            return;
+        }
+        $fyy_array = json_decode($fyy_array,true);
+
+        $this->host = $fyy_array['sqlserver_host'] ?? '';
+        $this->port = $fyy_array['sqlserver_port'] ?? 0;
+        $this->database = $fyy_array['sqlserver_database'] ?? '';
+        $this->url = empty($this->host)?: "http://" . $this->host . ":12365/U8Sys/U8API";
+
+        if(! $this->db){
+            $config = [
+                'driver' => 'sqlsrv',
+                'host' =>  $fyy_array['sqlserver_host'] ?? '',
+                'port' => $fyy_array['sqlserver_port'] ?? '',
+                'database' => $fyy_array['sqlserver_database'] ?? '',
+                'username' => env('SQLSRV_USERNAME'),
+                'password' => env('SQLSRV_PASSWORD'),
+            ];
+
+            // 进行数据库连接
+            Config::set('database.connections.sqlsrvs', $config);
+
+            try {
+                $pdo = DB::connection('sqlsrvs')->getPdo();
+                if ($pdo instanceof \PDO) {
+                    // 连接成功的逻辑代码
+                    $this->db = DB::connection('sqlsrvs');
+                } else {
+                    $this->error = '连接失败!';
+                    return;
+                }
+
+            } catch (\Throwable $e) {
+                $this->error = $e->getMessage();
+            }
+        }
     }
 
     private function fakeData(){
@@ -103,6 +150,8 @@ class FyySqlServerService extends Service
 
     //获取数据(点击引入)
     public function getDataFromSqlServer($data){
+        if(! empty($this->error)) return [false,$this->error,''];
+
         if(empty($data['out_order_no_time'][0]) || empty($data['out_order_no_time'][1])) return [false,'制单日期不能为空!',''];
         $bool = $this->is_same_month($data['out_order_no_time'][0],$data['out_order_no_time'][1]);
         if(! $bool) return [false,'制单日期必须同月!',''];
@@ -114,7 +163,8 @@ class FyySqlServerService extends Service
         $model = $this->db->table('SO_SOMain as a')
             ->leftJoin('SO_SODetails as b','b.cSOCode','a.cSOCode')
             ->whereBetween('a.dDate',[$start, $end])
-            ->select('a.cSOCode as out_order_no','a.dDate as out_order_no_time','a.cCusCode as customer_no','a.cCusName as customer_name','a.cMemo as table_header_mark','a.cMaker as out_crt_man','a.cVerifier as out_checker_man','a.dverifydate as out_checker_time','b.cInvCode as product_no','b.iQuantity as order_quantity','b.cDefine28 as technology_material','b.cFree1 as technology_name','b.cFree2 as wood_name','b.cDefine30 as process_mark','b.cMemo as table_body_mark');
+            ->whereNotNull('a.cVerifier')
+            ->select('a.cSOCode as out_order_no','a.dDate as out_order_no_time','a.cCusCode as customer_no','a.cCusName as customer_name','a.cMemo as table_header_mark','a.cMaker as out_crt_man','a.cVerifier as out_checker_man','a.dverifydate as out_checker_time','b.cInvCode as product_no','b.iQuantity as order_quantity','b.cDefine28 as technology_material','b.cFree1 as technology_name','b.cFree2 as wood_name','b.cDefine30 as process_mark','b.cMemo as table_body_mark','b.iTaxUnitPrice as price');
 
         if(! empty($data['out_order_no'])) $model->where('a.cSOCode', 'LIKE', '%'.$data['out_order_no'].'%');
         if(! empty($data['customer_no'])) $model->where('a.cCusCode', 'LIKE', '%'.$data['customer_no'].'%');
@@ -130,6 +180,9 @@ class FyySqlServerService extends Service
 
         $result = $model->get()->toArray();
         if(empty($result)) return [false,'暂无数据,更新结束!',''];
+        list($status,$msg) = $this->orderRule($result);
+        if(empty($msg)) return [false,'暂无数据,更新结束!',''];
+        $result = $msg;
 
         //查询附带的一些信息(比较少)
         $product_no = array_column($result,'product_no');
@@ -168,6 +221,13 @@ class FyySqlServerService extends Service
         //现存量查询结束
 
         foreach ($result as $key => $value){
+            $result[$key]->technology_material = $value->technology_material ?? '';
+            $result[$key]->technology_name = $value->technology_name ?? '';
+            $result[$key]->wood_name = $value->wood_name ?? '';
+            $result[$key]->process_mark = $value->process_mark ?? '';
+            $result[$key]->table_body_mark = $value->table_body_mark ?? '';
+            $result[$key]->table_header_mark = $value->table_header_mark ?? '';
+
             $keys = $value->product_no . $value->technology_name . $value->wood_name;
             $result[$key]->out_order_no_time = $value->out_order_no_time ? strtotime($value->out_order_no_time) : 0;
             $result[$key]->out_checker_time = $value->out_checker_time ? strtotime($value->out_checker_time) : 0;
@@ -180,8 +240,27 @@ class FyySqlServerService extends Service
         return [true,$result,$messageTwo];
     }
 
+    public function orderRule($data){
+        $result = Orders::where('del_time',0)
+            ->whereIn('out_order_no',array_column($data,'out_order_no'))
+            ->select('out_order_no')
+            ->get()->toArray();
+        $out_order_no = array_column($result,'out_order_no');
+        if(! empty($out_order_no)) {
+            foreach ($data as $key => $value){
+                if(in_array($value->out_order_no,$out_order_no)){
+                    unset($data[$key]);
+                }
+            }
+        }
+
+        return [true,$data];
+    }
+
     //获取数据(刷新现存量)
     public function getDataFromSqlServerForOnHand($data){
+        if(! empty($this->error)) return [false,$this->error,''];
+
         if(empty($data['id'])) return [false,'数据不能为空!',''];
 
         $product = SaleOrdersProduct::whereIn('id',$data['id'])
@@ -211,4 +290,249 @@ class FyySqlServerService extends Service
 
         return [true,$message,$product];
     }
+
+    //产成品入库单保存接口以及审核
+    public function U8Rdrecord10Save($data,$bredvouch = 0){
+        if(! empty($this->error)) return [false,$this->error];
+        date_default_timezone_set("PRC");
+
+        list($bool,$msg) = $this->createOrderNumberAboutSCRK();
+        if(! $bool) return [false,$msg];
+
+        if($bredvouch){
+            $cmemo = '来源:福羊羊完工操作撤回';
+        }else{
+            $cmemo = '来源:福羊羊完工操作 派工单号:'. $data['dispatch_no'];
+        }
+
+        //数据
+        $bodys[] = [
+            "cinvcode" => $data["product_no"],
+            "cposition" => "",
+            "cbatch" => "",
+            "iquantity" => $data["quantity"],
+            "inum" => $data["quantity"],
+            "iunitcost" => $data["price"] * 0.95,
+            "iprice" => $data["price"] * 0.95 * $data['quantity'],
+            "iinvexchrate" => "1.00",
+            "impoids" => "",
+            "cmocode" => "",
+            "imoseq" => "",
+            "cbmemo" => "",
+            "cfree1" => "",
+            "cfree2" => "",
+        ];
+        $post = [
+            "password"=>"cloud@123456",
+            "entity"=>"U8Rdrecord10Save",
+            "login"=>[
+                "sAccID"=> "(default)@001",
+                "sDate"=> date("Y-m-d"),
+                "sServer"=> '127.0.0.1',
+                "sUserID"=> "董晓磊",
+                "sSerial"=> "",
+                "sPassword"=> ""
+            ],
+            "data"=>[
+                "ccode"=>'',
+                "ddate"=>date("Y-m-d"),
+                "cmaker"=>"董晓磊",
+                "dnmaketime"=> date("Y-m-d"),
+                "IsExamine"=>true,
+                "bredvouch"=> $bredvouch,
+                "cwhcode"=>"02",
+                "cdepcode"=>"06",
+                "crdcode"=>"102", //生产入库
+                "cmemo"=> $cmemo,
+                "cdefine10" => $data['customer_name'], //客户名称
+                "bodys"=>$bodys
+            ]
+        ];
+
+        $return = $this->post_helper($this->url,json_encode($post), ['Content-Type:application/json']);
+        return [$return['flag'], $return['msg']];
+    }
+
+    //销售出库单保存接口给以及审核
+    public function U8Rdrecord32Save($data,$bredvouch = 0){
+        if(! empty($this->error)) return [false,$this->error];
+        date_default_timezone_set("PRC");
+
+        //获取包装单内数据
+        $box = $this->getBoxData($data);
+        if(empty($box)) return [false,'包装单不能为空!'];
+
+        //获取发货单的数据
+        $return = $this->getDataFromDispatchList(array_column($box,'cSOCode'));
+        if(empty($return)) return [false,'没有找到发货单!'];
+
+        //组织发货单的数据
+        $map = [];
+        foreach ($return as $value){
+            $map[$value['cSOCode']][] = $value;
+        }
+
+        $detail = [];
+        foreach ($box as $value){
+            if(! isset($map[$value['cSOCode']])) {
+                return [false,'包装单内销售订单号:' . $value['cSOCode'] .'没有找到发货单!'];
+            }
+            $is_flag = 0;
+            foreach ($map[$value['cSOCode']] as $m){
+                if($value['cinvcode'] == $m['cinvcode'] && $value['cfree1'] == $m['cfree1'] && $value['cfree2'] == $m['cfree2']) {
+                    $is_flag = 1;
+                    $m['iquantity'] = $value['iquantity'];
+                    $detail[$m['cSOCode']][] = $m;
+                }
+            }
+            if(! $is_flag) return [false,'包装单内销售订单号:' . $value['cSOCode'] .'产品:' . $value['cinvcode'] . $value['cfree1'] . $value['cfree2'] . '在发货单中不存在!'];
+        }
+
+        foreach ($detail as $value){
+            $main_tmp = $value[0];
+            foreach ($value as $val){
+                $bodys_tmp[] = [
+                    "idlsid"=>$val['idlsid'],
+                    "cdlcode"=>"",
+                    "dlrowno"=>"",
+                    "cbdlcode"=>"",
+                    "cinvcode"=>$val['cinvcode'],
+                    "cposition"=>$val['cposition'],
+                    "cbatch"=>$val['cbatch'],
+                    "iquantity"=>$val['iquantity'],
+                    "inum"=>$val['iquantity'],
+                    "iinvexchrate"=>$value['iinvexchrate'],
+                    "iunitcost"=>"",
+                    "iprice"=>"",
+                    "cbmemo"=>"",
+                ];
+            }
+            $post_tmp = [
+                "password"=>"cloud@123456",
+                "entity"=>"U8Rdrecord32Save",
+                "login"=>[
+                    "sAccID"=> "(default)@001",
+                    "sDate"=> date("Y-m-d"),
+                    "sServer"=> '127.0.0.1',
+                    "sUserID"=> "董晓磊",
+                    "sSerial"=> "",
+                    "sPassword"=> ""
+                ],
+                "data"=>[
+                    "ccode"=>'',
+                    "ddate"=>date("Y-m-d"),
+                    "cmaker"=>"董晓磊",
+                    "dnmaketime"=> date("Y-m-d"),
+                    "IsExamine"=>true,
+                    "bredvouch"=> $bredvouch,
+                    "cwhcode"=>"02",
+                    "cdepcode"=>"06",
+                    "crdcode"=>"102",
+                    "cmemo"=> '',
+                    "cdefine10" => $main_tmp['customer_name'], //客户名称
+                    "bodys"=>$bodys_tmp
+                ]
+            ];
+
+            $return = $this->post_helper($this->url,json_encode($post_tmp), ['Content-Type:application/json']);
+            if(! $return['flag']) return [false,$return['msg']];
+        }
+
+        return [true,''];
+    }
+
+    public function getBoxData($data){
+        $boxData = BoxDetail::from('box_detail as a')
+            ->leftJoin('sale_orders_product as b','b.id','a.top_id')
+            ->where('a.del_time',0)
+            ->where('a.order_no',$data['order_number']) //包装单号
+            ->select('a.num as iquantity','b.product_no as cinvcode','b.technology_name as cfree1','b.wood_name as cfree2','b.out_order_no as cSOCode');
+
+        return $boxData;
+    }
+
+    public function getDataFromDispatchList($order_number){
+        $message = $this->db->table('DispatchList as a')
+            ->leftJoin('DispatchLists as b','b.DLID','a.DLID')
+            ->whereIn('a.cSOcode',$order_number)
+//            ->whereColumn('b.iQuantity', '>', 'b.fOutQuantity')
+            ->select('a.cDefine10 as customer_name','a.cSOCode','b.iDLsID as idlsid','b.cInvCode as cinvcode','b.cFree1 as cfree1','b.cFree2 as cfree2','b.cPosition as cposition','b.cBatch as cbatch','b.iQuantity as iquantity','b.iNum as inum','b.iInvExchRate as iinvexchrate','b.fOutQuantity as out_quantity')
+            ->get()->toArray();
+        if(! empty($message)){
+            foreach ($message as $key => $value){
+//                $message[$key]->iquantity = $value->iquantity - $value->out_quantity;
+                $message[$key] = (array)$value;
+            }
+        }
+
+        return $message;
+    }
+
+    //产成品入库单单据号
+    public function createOrderNumberAboutSCRK(){
+        date_default_timezone_set("PRC");
+
+        $current_month = date('m'); // 获取当前月份
+        $date1 = date('y') . $current_month  ; // 格式 "2307"
+        $date2 = date('Y') . $current_month; // 格式 "202307"
+
+        $record = $this->db->table('VoucherHistory')
+            ->where('CardNumber','0411')
+            ->whereRaw("(cSeed = '{$date1}' or cSeed = '{$date2}')")
+            ->select('cNumber')
+            ->first();
+        $record = (array)$record;
+        if(empty($record)) return [false,'未找到产成品入库当月流水号信息!'];
+
+        $tmp = $record['cNumber'] + 1;
+        if(strlen($tmp) > 4) return [false,'产成品入库当月流水号超过四位数!'];
+
+        $number = str_pad($tmp,4,'0',STR_PAD_LEFT);
+        $number = $tmp . $number;
+        $ccode = "SCRK" . $date2 . $number;
+
+        return [true,$ccode];
+    }
+
+    //销售出库单单据号
+    public function createOrderNumberAboutXC(){
+        date_default_timezone_set("PRC");
+
+        $current_month = date('m'); // 获取当前月份
+        $date1 = date('y') . $current_month  ; // 格式 "2307"
+        $date2 = date('Y') . $current_month; // 格式 "202307"
+
+        $record = $this->db->table('VoucherHistory')
+            ->where('CardNumber','0303')
+            ->whereRaw("(cSeed = '{$date1}' or cSeed = '{$date2}')")
+            ->select('cNumber')
+            ->first();
+        $record = (array)$record;
+        if(empty($record)) return [false,'未找到销售出库单当月流水号信息!'];
+
+        $tmp = $record['cNumber'] + 1;
+        if(strlen($tmp) > 4) return [false,'销售出库单当月流水号超过四位数!'];
+
+        $number = str_pad($tmp,4,'0',STR_PAD_LEFT);
+        $number = $tmp . $number;
+        $ccode = "XC" . $date2 . $number;
+
+        return [true,$ccode];
+    }
+
+    public function post_helper($url, $data,$header = [],$timeout = 60){
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch,  CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_ENCODING, '');
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+        if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        $r = curl_exec($ch);
+        curl_close($ch);
+        return json_decode($r, true);
+    }
 }

+ 114 - 1
app/Service/HeaderWord/HeaderWordHookService.php

@@ -6,7 +6,9 @@ namespace App\Service\HeaderWord;
 
 
 use App\Model\Header_ext;
+use App\Model\Header_ext_sub;
 use App\Service\Service;
+use Illuminate\Support\Facades\DB;
 
 /**
  * 表头相关工厂模式
@@ -35,17 +37,128 @@ class HeaderWordHookService extends Service
 
         if(!isset($data['type'])) return [false,'not found type'];
         $type = $data['type'];
-        $list = Header_ext::where('type',$type)->orderBy('sort','asc')->select('*')->get()->toArray();
+        $list = Header_ext::where('type',$type)->orderBy('sort_type','asc')->select('*')->get()->toArray();
 //        self::$header_detail = Header_ext::where('type',$type_detail)->pluck('value','key')->toArray();
 
         return [true,$list];
     }
 
+    public function getHeaderSettings($data){
+        if($this->isEmpty($data,'menu_id')) return [false,'菜单ID不能为空!'];
+        $type = 1;
+        if(! $this->isEmpty($data,'type')) $type = $data['type'];
 
+        $header = config("header.{$data['menu_id']}")[$type] ?? [];
 
+        return [true,$header];
+    }
+
+    public function edit($data){
+        list($status,$msg) = $this->headerRule($data,false);
+        if(!$status) return [$status,$msg];
+
+        return [true,'保存成功!'];
+    }
+
+    public function add($data){
+        list($status,$msg) = $this->headerRule($data);
+        if(!$status) return [$status,$msg];
+
+        DB::beginTransaction();
+        try{
+            Header_ext::where('menu_id',$data['menu_id'])
+                ->where('type',$data['type'])
+                ->where('del_time',0)
+                ->update(['del_time'=>time()]);
+            Header_ext_sub::where('menu_id',$data['menu_id'])
+                ->where('type',$data['type'])
+                ->where('del_time',0)
+                ->update(['del_time'=>time()]);
+
+            $insert = [];
+            foreach ($data['data'] as $value){
+                $insert[] = [
+                    'key' => $value['key'] ?? '',
+                    'value' => $value['value'],
+                    'type' => $value['type'],
+                    'menu_id' => $value['menu_id'],
+                    'position' => $value['position'],
+                    'x_axis' => $value['x'],
+                    'y_axis' => $value['y'],
+                ];
+            }Header_ext::insert($insert);
+
+            Header_ext_sub::insert([
+                'type' => $data['type'],
+                'menu_id' => $data['menu_id'],
+                'merge_cells' => json_encode($data['mergeCells']),
+                'max_length' => $data['maxLength'],
+            ]);
+
+            DB::commit();
+        }catch (\Exception $e){
+            DB::rollBack();
+            return [false,$e->getMessage()];
+        }
 
+        return [true,'保存成功!'];
+    }
+
+    public function del($data){
+        if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
 
+        return [true,'删除成功'];
+    }
 
+    public function detail($data){
+        if($this->isEmpty($data,'menu_id')) return [false,'菜单ID不能为空!'];
+        if($this->isEmpty($data,'type')) return [false,'TYPE不能为空!'];
+
+        $result = Header_ext::where('del_time',0)
+            ->select('key','value','position','x_axis as x','y_axis as y')
+            ->where('menu_id',$data['menu_id'])
+            ->where('type',$data['type'])
+            ->get()->toArray();
+        $result_sub = Header_ext_sub::where('del_time',0)
+            ->select('merge_cells','max_length')
+            ->where('menu_id',$data['menu_id'])
+            ->where('type',$data['type'])
+            ->get()->toArray();
+
+        $return['data'] = $result;
+        $return['mergeCells'] = ! empty($result_sub[0]['merge_cells']) ? json_decode($result_sub[0]['merge_cells'],true) : [];
+        $return['maxLength'] = $result_sub[0]['max_length'] ?? 1;
+
+        return [true,$return];
+    }
 
+    public function headerRule(&$data,$is_add = true){
+        if($this->isEmpty($data,'menu_id')) return [false,'菜单ID不能为空!'];
+        if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
+
+        foreach ($data['data'] as $key => $value){
+            if (strpos($value['position'], ',') !== false) {
+                $tmp = explode(',',$value['position']);
+                $str_col = $str_ros =  '';
+                foreach ($tmp as $v){
+                    $tmp_v = explode(':',$v);
+                    if($tmp_v[0] != $tmp_v[1]) {
+                        // 截取头部
+                        $head = explode(':', $tmp[0])[0];
+                        // 截取尾部
+                        $tail = explode(':', end($tmp))[1];
+                        $str_ros = $head . ":" . $tail;
+                        continue;
+                    }else{
+                        $str_col .= $tmp_v[0] . ':';
+                    }
+                }
+                $str_col = rtrim($str_col,':');
+                if($str_col) $data['data'][$key]['position'] = $str_col;
+                if($str_ros) $data['data'][$key]['position'] = $str_ros;
+            }
+        }
 
+        return [true,''];
+    }
 }

+ 10 - 10
app/Service/ProcessService.php

@@ -97,11 +97,11 @@ class ProcessService extends Service
         $model = $model->where('id',$data['id'])->first();
         $model->title = $data['title'];
         $model->p_id = $data['p_id'];
-        $model->time = $data['time'];
-        $model->capacity = $data['capacity'];
-        $model->wages_unit = $data['wages_unit'];
-        $model->wages = $data['wages'];
-        $model->team_id = $data['team_id'];
+        $model->time = $data['time'] ?? '';
+        $model->capacity = $data['capacity'] ?? '';
+        $model->wages_unit = $data['wages_unit'] ?? 0;
+        $model->wages = $data['wages'] ?? '';
+        $model->team_id = $data['team_id'] ?? 0;
         $model->save();
 
         return [true,'保存成功!'];
@@ -117,11 +117,11 @@ class ProcessService extends Service
 
         $model->title = $data['title'];
         $model->p_id = $data['p_id'];
-        $model->time = $data['time'];
-        $model->capacity = $data['capacity'];
-        $model->wages_unit = $data['wages_unit'];
-        $model->wages = $data['wages'];
-        $model->team_id = $data['team_id'];
+        $model->time = $data['time'] ?? '';
+        $model->capacity = $data['capacity'] ?? '';
+        $model->wages_unit = $data['wages_unit'] ?? 0;
+        $model->wages = $data['wages'] ?? '';
+        $model->team_id = $data['team_id'] ?? '';
         $model->save();
 
         return [true,'保存成功!'];

+ 6 - 3
app/Service/ProductionOrderService.php

@@ -101,7 +101,7 @@ class ProductionOrderService extends Service
                         'crt_time' => $time
                     ];
 
-                    foreach ($process_arr as $v){
+                    foreach ($process_arr as $k => $v){
                         $process[$time_tmp][] = [
                             'order_product_id' => $last_insert_id[$key],
                             'production_no' => $production_no,
@@ -110,7 +110,8 @@ class ProductionOrderService extends Service
                             'out_order_no' => $value['out_order_no'],
                             'product_no' => $value['product_no'],
                             'product_title' => $value['product_title'],
-                            'crt_time' => $time
+                            'crt_time' => $time,
+                            'sort' => $k,
                         ];
                     }
                 }
@@ -183,7 +184,9 @@ class ProductionOrderService extends Service
         if(in_array(false, $data['quantity'], true) || in_array(0, $data['quantity'], true) || in_array('', $data['quantity'], true))return [false,'数量不能为空!'];
 
         $result = SaleOrdersProduct::whereIn('id',$data['id'])
-            ->select('id as sale_orders_product_id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity')->get()->toArray();
+            ->select('id as sale_orders_product_id','order_no','out_order_no','out_order_no_time','customer_no','customer_name','table_header_mark','product_no','product_title','product_size','product_unit','order_quantity','technology_material','technology_name','wood_name','process_mark','table_body_mark','out_crt_man','out_checker_man','out_checker_time','production_quantity','price')
+            ->orderBy('id','desc')
+            ->get()->toArray();
 
         foreach ($result as $key => $value){
             if($value['production_quantity'] + $data['quantity'][$key] > $value['order_quantity']) return [false,'生产数量不能大于订单数量'];

+ 41 - 0
app/Service/SysMenuService.php

@@ -90,5 +90,46 @@ class SysMenuService extends Service
         return [true,''];
     }
 
+    public function menuMove($data){
+        if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
+        if($this->isEmpty($data,'move')) return [false,'移动不能能为空!'];
 
+        //移动项
+        $model = new SysMenu();
+        $res = $model->where('id', $data['id'])->first();
+
+        if($data['move'] == 1 || $data['move'] == -1){
+            //替项目
+            $moveModel = $model->where('del_time',0)->where('parent_id',$res->parent_id);
+
+            //下移-1 上移1
+            $data['move'] == 1 ? $moveModel->orderby('sort','desc')->where('sort','<', $res['sort']) : $moveModel->orderby('sort','asc')->where('sort','>', $res['sort']);
+
+            $moveRes = $moveModel->first();
+            if(! $moveRes) return [false, '移动失败'];
+
+            $weightOne = $res->sort;
+            $weightTwo = $moveRes->sort;
+
+            $res->sort = $weightTwo;
+            $res->save();
+            $moveRes->sort = $weightOne;
+            $moveRes->save();
+        }elseif($data['move'] == 'top' || $data['move'] == 'bottom'){
+            if($data['move'] == 'top'){
+                $sort = $model->where('del_time',0)->where('parent_id',$res->parent_id)->max('sort');
+                if($sort == $res->sort) return [false,'已经置顶,移动失败!'];
+                $res->sort = $sort + 1;
+            }elseif($data['move'] == 'bottom'){
+                $sort = $model->where('del_time',0)->where('parent_id',$res->parent_id)->min('sort');
+                if($sort == $res->sort) return [false,'已经置底部,移动失败!'];
+                $res->sort = $sort - 1;
+            }
+            $res->save();
+        }else{
+            return [false, '移动失败'];
+        }
+
+        return [true,'移动成功'];
+    }
 }

+ 35 - 0
config/header/210.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    1 => [
+      'order_no' => '内部订单编号',
+      'out_order_no' => '销售订单号',
+      'out_order_no_time' => '销售订单时间',
+      'customer_no' => '客户编码',
+      'customer_name' => '客户名称',
+      'table_header_mark' => '表头备注',
+      'product_no' => '产品编码',
+      'product_title' => '产品名称',
+      'product_size' => '规格型号',
+      'product_unit' => '计量单位',
+      'order_quantity' => '计量单位',
+      'product_quantity_on_hand' => '现存量',
+      'technology_material'=> '工艺/材质',
+      'technology_name'=> '工艺名称',
+      'wood_name'=> '木皮名称',
+      'process_mark'=> '加工备注',
+      'table_body_mark'=> '表体备注',
+      'out_crt_man'=> '制单人',
+      'out_checker_man'=> '审核人',
+      'out_checker_time'=> '审核日期',
+      'crt_time'=> '引入时间',
+      'box_num'=> '已包装数量',
+      'production_quantity' => '已生产数量',
+      'finished_num' => '已完工数量',
+    ],
+];

+ 35 - 0
config/headerSettings.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * '菜单ID' => [
+ *     '字段英文名' =》 '字段中文名'
+ * ]
+ */
+
+return [
+    210 => [
+      'order_no' => '内部订单编号',
+      'out_order_no' => '销售订单号',
+      'out_order_no_time' => '销售订单时间',
+      'customer_no' => '客户编码',
+      'customer_name' => '客户名称',
+      'table_header_mark' => '表头备注',
+      'product_no' => '产品编码',
+      'product_title' => '产品名称',
+      'product_size' => '规格型号',
+      'product_unit' => '计量单位',
+      'order_quantity' => '计量单位',
+      'product_quantity_on_hand' => '现存量',
+      'technology_material'=> '工艺/材质',
+      'technology_name'=> '工艺名称',
+      'wood_name'=> '木皮名称',
+      'process_mark'=> '加工备注',
+      'table_body_mark'=> '表体备注',
+      'out_crt_man'=> '制单人',
+      'out_checker_man'=> '审核人',
+      'out_checker_time'=> '审核日期',
+      'crt_time'=> '引入时间',
+      'box_num'=> '已包装数量',
+      'production_quantity' => '已生产数量',
+      'finished_num' => '已完工数量',
+    ],
+];

+ 37 - 4
routes/api.php

@@ -18,14 +18,38 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
 });
 
 Route::any('login', 'Api\LoginController@login');
-Route::any('test', 'Api\TestController@aa');
+Route::any('loginMobile', 'Api\LoginController@loginMobile');
 Route::any('getHeaderWord', 'Api\HeaderWordController@getHeaderWord');
+Route::any('getHeaderSetting', 'Api\HeaderWordController@getHeaderSettings');
 Route::any('deviceList', 'Api\Device\DeviceController@deviceList');
+Route::any('fyy_set','Api\FyyOrderController@setFyy');
+Route::any('fyySaveOutOrder','Api\FyyOrderController@fyySaveOutOrder');
+
+//测试接口
+Route::any('job', 'Api\JobController@processDataJobAdd');
+Route::any('job2', 'Api\JobController@processDataJobAdd2');
+Route::any('test', 'Api\TestController@aa');
+Route::any('testData','Api\TestController@testData');
+Route::any('testdwy','Api\TestController@testaa');
+Route::any('testdwyget','Api\TestController@testa');
+Route::any('testaa1','Api\TestController@testaa1');
+Route::any('order_process1','Api\TestController@order_process1');
+Route::any('project_region','Api\TestController@project_region');
+Route::any('output_value_month1','Api\TestController@output_value_month1');
+Route::any('output_value_efficiency','Api\TestController@output_value_efficiency');
+Route::any('capacity','Api\TestController@capacity');
+Route::any('product_num','Api\TestController@product_num');
+Route::any('work_order','Api\TestController@work_order');
+Route::any('nu_work_order','Api\TestController@nu_work_order');
 Route::group(['middleware'=> ['checkLogin']],function ($route){
+    $route->any('HeaderSettingsAdd', 'Api\HeaderWordController@add');
+    $route->any('HeaderSettingsDetail', 'Api\HeaderWordController@detail');
+
     $route->any('menuAdd', 'Api\SysMenuController@add');
     $route->any('menuEdit', 'Api\SysMenuController@edit');
     $route->any('menuDel', 'Api\SysMenuController@del');
     $route->any('menuList', 'Api\SysMenuController@menuList');
+    $route->any('menuMove', 'Api\SysMenuController@menuMove');
 
     $route->any('employeeAdd', 'Api\EmployeeController@employeeAdd');
     $route->any('employeeEdit', 'Api\EmployeeController@employeeEdit');
@@ -123,11 +147,20 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('dispatchOrderList', 'Api\DispatchController@dispatchOrderList');
     $route->any('dispatchOrderDel', 'Api\DispatchController@dispatchOrderDel');
 
-    //工序完工
+    //设备上的工序去完工列表
+    $route->any('finishedOrderList', 'Api\DispatchController@dispatchMobileOrderList');
+    $route->any('finishedOrderDetailsList', 'Api\DispatchController@dispatchMobileOrderDetailsList');
+    $route->any('mobileFinishedOrderAdd', 'Api\FinishedOrderController@mobileAdd');
+
+    //工序完工(暂时没用)
     $route->any('finishedOrderAdd', 'Api\FinishedOrderController@add');
     $route->any('finishedOrderEdit', 'Api\FinishedOrderController@edit');
-    $route->any('finishedOrderDel', 'Api\FinishedOrderController@del');
-    $route->any('finishedOrderList', 'Api\FinishedOrderController@orderList');
+    $route->any('finishedOrderDetail', 'Api\FinishedOrderController@orderDetail');
+//    $route->any('finishedOrderDel', 'Api\FinishedOrderController@del');
+//    $route->any('finishedOrderList', 'Api\FinishedOrderController@orderList');
+
+    //删除单据统一入口
+    $route->any('delOrders','Api\DeleteOrderController@del');
 
     $route->any('productList', 'Api\MaterialController@productList');
     $route->any('productEdit', 'Api\MaterialController@edit');