Browse Source

工单和工单BOM数据同步优化

qiuenguang 1 year ago
parent
commit
2646924618
1 changed files with 22 additions and 21 deletions
  1. 22 21
      application/api/controller/Synchronization.php

+ 22 - 21
application/api/controller/Synchronization.php

@@ -105,7 +105,7 @@ class Synchronization extends Api
                 'Uniqid' => $value['UniqId']
             ];
             $workOrderdata = \db('工单_基本资料')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($workOrderdata === 0){
                 $addSql = \db('工单_基本资料')->fetchSql(true)->insert($data);
@@ -123,7 +123,7 @@ class Synchronization extends Api
                     $db3->execute($sqlString);
                 }
             }else{
-                $updateSql = \db('工单_基本资料')->where('Uniqid',$value['UniqId'])->fetchSql(true)->update($data);
+                $updateSql = \db('工单_基本资料')->where('U8UID',$value['U8_UID'])->fetchSql(true)->update($data);
                 $updateRes = \db()->query($updateSql);
                 if ($updateRes === false){
                     $j++;
@@ -166,7 +166,7 @@ class Synchronization extends Api
         }
         $j = $m = 0;
         foreach ($BomDataList as $key=>$value){
-            $res = \db('工单_bom资料')->where('UNIQID',$value['UNIQID'])->count();
+            $res = \db('工单_bom资料')->where('U8UID',$value['U8_UID'])->count();
             if (preg_match("/[A-Za-z]/",$value['BOM_工单编号'])){
                 $workcode = $value['BOM_工单编号'];
             }else{
@@ -202,7 +202,7 @@ class Synchronization extends Api
                     $m++;
                 }else{
                     $sqlString = $db3->name('U8_09工单bom')
-                        ->where('UniqId', $value['UNIQID'])
+                        ->where('UNIQID', $value['UNIQID'])
                         ->fetchSql(true)
                         ->update([
                             'MES接收时间' => date('Y-m-d H:i:s', time()),
@@ -212,7 +212,7 @@ class Synchronization extends Api
                 }
             }else{
                 $updateSql = \db('工单_bom资料')
-                    ->where('UNIQID',$value['UNIQID'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->fetchSql(true)
                     ->update($data);
                 $updateRes = \db()->query($updateSql);
@@ -220,7 +220,7 @@ class Synchronization extends Api
                     $j++;
                 }else{
                     $sqlString = $db3->name('U8_09工单bom')
-                        ->where('UniqId', $value['UNIQID'])
+                        ->where('UNIQID', $value['UNIQID'])
                         ->fetchSql(true)
                         ->update([
                             'MES接收时间' => date('Y-m-d H:i:s', time()),
@@ -283,7 +283,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('物料_存货结构')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -410,7 +410,7 @@ class Synchronization extends Api
                 'UniqID'=>$value['UniqId']
             ];
             $number = \db('人事_基本资料')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('人事_基本资料')->fetchSql(true)->insert($data);
@@ -430,7 +430,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('人事_基本资料')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -492,7 +492,7 @@ class Synchronization extends Api
                 'UNIQID'=>$value['UniqId'],
             ];
             $number = \db('人事_组织结构')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('人事_组织结构')->fetchSql(true)->insert($data);
@@ -512,7 +512,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('人事_组织结构')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -581,7 +581,7 @@ class Synchronization extends Api
                 'UniqId'=>$value['UniqId'],
             ];
             $number = \db('物料_存货编码')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('物料_存货编码')->fetchSql(true)->insert($data);
@@ -601,7 +601,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('物料_存货编码')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -668,7 +668,7 @@ class Synchronization extends Api
                 'UniqId'=>$value['UniqId'],
             ];
             $number = \db('erp_客户供应商')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('erp_客户供应商')->fetchSql(true)->insert($data);
@@ -688,7 +688,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('erp_客户供应商')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -763,7 +763,7 @@ class Synchronization extends Api
                 'Uniqid'=>$value['UniqId'],
             ];
             $number = \db('物料_收发记录')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('物料_收发记录')->fetchSql(true)->insert($data);
@@ -783,7 +783,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('物料_收发记录')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -842,7 +842,7 @@ class Synchronization extends Api
                 'UniqId'=>$value['UniqId'],
             ];
             $number = \db('物料_仓库信息')
-                ->where('Uniqid',$value['UniqId'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('物料_仓库信息')->fetchSql(true)->insert($data);
@@ -862,7 +862,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('物料_仓库信息')
                     ->fetchSql(true)
-                    ->where('UniqId',$value['UniqId'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -923,7 +923,7 @@ class Synchronization extends Api
                 'UniqID'=>$value['UniqID'],
             ];
             $number = \db('人事_职位编码')
-                ->where('Uniqid',$value['UniqID'])
+                ->where('U8UID',$value['U8_UID'])
                 ->count();
             if ($number === 0){
                 $sql = \db('人事_职位编码')->fetchSql(true)->insert($data);
@@ -943,7 +943,7 @@ class Synchronization extends Api
             }else{
                 $sql = \db('人事_职位编码')
                     ->fetchSql(true)
-                    ->where('UniqID',$value['UniqID'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->update($data);
                 $res = \db()->query($sql);
                 if ($res === false){
@@ -992,6 +992,7 @@ class Synchronization extends Api
         $productData = $db5->name('设备_产量计酬')
             ->where($where)
             ->select();
+        var_dump($productData);
         //获取机台信息
         $machineData = \db('设备_基本资料')
             ->where('mn_设备编号','<>','')