ソースを参照

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 1 年間 前
コミット
01d7347b73

+ 30 - 11
application/api/controller/Facility.php

@@ -108,31 +108,47 @@ class Facility extends Api
         foreach ($list as $key=>$value){
             //产品名称
             $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
-            if (!empty($productName['成品名称'])){
-                $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
-                $list[$key]['cpmc'] = $productName['成品名称'];
+            if (!empty($productName)){
+                if (!empty($productName['成品名称'])){
+                    $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
+                    $list[$key]['cpmc'] = $productName['成品名称'];
+                }else{
+                    $list[$key]['产品名称'] = $value['工单编号'];
+                    $list[$key]['cpmc'] = '';
+                }
             }else{
                 $list[$key]['产品名称'] = $value['工单编号'];
                 $list[$key]['cpmc'] = '';
             }
+
             $process = \db('工单_工艺资料')
                 ->where('Gy0_gdbh',$value['工单编号'])
                 ->where('Gy0_gxh',$value['gxh'])
                 ->field('rtrim(工价系数) as 工价系数,rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距')
                 ->find();
-            if ($value['难度系数'] == 0){
-                $list[$key]['难度系数'] = $process['工价系数'];
+            if (!empty($process)){
+                if ($value['难度系数'] == 0){
+                    $list[$key]['难度系数'] = $process['工价系数'];
+                }else{
+                    $list[$key]['难度系数'] = $process['工价系数'].'x'.$value['难度系数'];
+                }
+                $list[$key]['印刷方式'] = $process['印刷方式'].' '.$process['版距'];
             }else{
-                $list[$key]['难度系数'] = $process['工价系数'].'x'.$value['难度系数'];
+                $list[$key]['难度系数'] = '';
+                $list[$key]['印刷方式'] = '';
             }
-            $list[$key]['印刷方式'] = $process['印刷方式'].' '.$process['版距'];
             if ($value['yjno']<10){
                 $list[$key]['yjno'] = '0'.$value['yjno'];
             }
+            if (!empty($machineDetail)){
+                $list[$key]['千件工价'] = $machineDetail['千件工价'];
+                $list[$key]['日定额'] = $machineDetail['日定额'];
+            }else{
+                $list[$key]['千件工价'] = '';
+                $list[$key]['日定额'] = '';
+            }
             $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
             $list[$key]['备注'] = $value['bzdh'].'('.$value['num'].')'.date('H:i',strtotime($value['sj1'])).'<-->'.date('H:i',strtotime($value['sj2']));
-            $list[$key]['千件工价'] = $machineDetail['千件工价'];
-            $list[$key]['日定额'] = $machineDetail['日定额'];
             for ($i=1;$i<11;$i++){
                 if (isset($value['sczl_bh'.$i])){
                     $name = \db('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
@@ -251,7 +267,9 @@ class Facility extends Api
             $list['工单编号'] = $data['工单编号'];
             $list['印件号'] = $data['印件号'];
             $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
+            $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品代号');
             $list['产品名称'] = rtrim($name);
+            $list['产品代号'] = rtrim($code);
             $where['Gy0_gdbh'] = $data['工单编号'];
             $where['Gy0_yjno'] = $data['印件号'];
             $where['Gy0_gxh'] = $data['工序号'];
@@ -270,6 +288,7 @@ class Facility extends Api
             $list['印件号'] = 0;
             $list['产品名称'] = '';
             $list['工序名称'] = '';
+            $list['产品代号'] = '';
         }
         $list['状态'] = rtrim($data['当前状态']);
         $list['班组编号'] = rtrim($data['班组编号']);
@@ -347,8 +366,8 @@ class Facility extends Api
                 AND b.Gy0_sbbh = '{$machine}' 
                 AND b.PD_WG = '1900-01-01 00:00:00' 
                 AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
-                AND b.Gy0_sj1 < '2099-01-01 00:00:00'
-            GROUP BY a.Gd_gdbh,b.Gy0_yjno,b.Gy0_gxh
+                AND b.Gy0_sj1 < '2099-01-01 00:00:00' 
+            GROUP BY a.Gd_gdbh,b.Gy0_yjno, b.Gy0_gxh
             ORDER BY b.Gy0_sj1";
         $orderList = Db::query($sql);
         if (empty($orderList)){

+ 7 - 4
application/api/controller/ProcessDocument.php

@@ -38,14 +38,16 @@ class ProcessDocument extends Api
         }
         $map = array();
         $map['a.Gd_gdbh'] = $order;
-        $map['a.行号'] = 1;
         //胶印车间计量单位为”张“,凹印车间计量单位一般为”吨“
         $info = db('工单_基本资料')->alias('a')
             ->join('工单_bom资料 b ',' a.Gd_gdbh=b.BOM_工单编号','left')
-            ->field('a.成品代号,a.产品版本号,b.BOM_计划用量,b.BOM_物料名称')
+            ->field('DISTINCT(b.BOM_物料名称),a.成品代号,a.产品版本号,b.BOM_计划用量')
             ->where($map)
             ->where('b.BOM_产出单位',['eq','张'],['eq','吨'],'or')
             ->select();
+        if(empty($info)){
+            $this->success('请求成功');
+        }
         $res =array();
         $product_number = '';
         if (count($info) > 1){
@@ -87,11 +89,13 @@ class ProcessDocument extends Api
 
         $where = array();
         $where['Gd_gdbh'] = $order;
-        $where['行号'] = 1;
         $product = db('工单_基本资料')
             ->where($where)
             ->field('成品代号')
             ->find();
+        if (empty($product)){
+            $this->success('请求成功');
+        }
         $map =array();
         $map['product_number'] = rtrim($product['成品代号']);
         if ($params['peijian'] > 0){
@@ -146,7 +150,6 @@ class ProcessDocument extends Api
         $data['data'] = substr($params['data'],0,-1);
         $where = array();
         $where['Gd_gdbh'] = $params['order'];
-        $where['行号'] = 1;
         $product = db('工单_基本资料')
             ->where($where)
             ->field('成品代号')

+ 24 - 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,8 @@ class Synchronization extends Api
                     $db3->execute($sqlString);
                 }
             }else{
-                $updateSql = \db('工单_基本资料')->where('Uniqid',$value['UniqId'])->fetchSql(true)->update($data);
+                unset($data['Uniqid']);
+                $updateSql = \db('工单_基本资料')->where('U8UID',$value['U8_UID'])->fetchSql(true)->update($data);
                 $updateRes = \db()->query($updateSql);
                 if ($updateRes === false){
                     $j++;
@@ -166,7 +167,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 +203,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()),
@@ -211,8 +212,9 @@ class Synchronization extends Api
                     $db3->execute($sqlString);
                 }
             }else{
+                unset($data['UNIQID']);
                 $updateSql = \db('工单_bom资料')
-                    ->where('UNIQID',$value['UNIQID'])
+                    ->where('U8UID',$value['U8_UID'])
                     ->fetchSql(true)
                     ->update($data);
                 $updateRes = \db()->query($updateSql);
@@ -220,7 +222,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 +285,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 +412,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 +432,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 +494,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 +514,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 +583,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 +603,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 +670,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 +690,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 +765,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 +785,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 +844,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 +864,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 +925,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 +945,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 +994,7 @@ class Synchronization extends Api
         $productData = $db5->name('设备_产量计酬')
             ->where($where)
             ->select();
+        var_dump($productData);
         //获取机台信息
         $machineData = \db('设备_基本资料')
             ->where('mn_设备编号','<>','')

+ 7 - 3
application/api/controller/WorkOrder.php

@@ -107,7 +107,11 @@ class WorkOrder extends Api
         $limit = input('limit');
         $where = [];
         if (!empty($clientNumber)){
-            $where['成品代号'] = ['like',$clientNumber.'%'];
+            if ($clientNumber === 'Y1401'){
+                $where['Gd_cpdh'] = ['like',$clientNumber.'%'];
+            }else{
+                $where['成品代号'] = ['like',$clientNumber.'%'];
+            }
         }
         if (!empty($workOrder)){
             $where['Gd_gdbh'] = $workOrder;
@@ -135,8 +139,8 @@ class WorkOrder extends Api
                 '工单编号' => rtrim($value['Gd_gdbh']),
                 '生产分类' => rtrim($value['Gd_生产分类']),
                 '销售订单号' => rtrim($value['销售订单号']),
-                '产品代号' => rtrim($value['Gd_cpdh']),
-                '产品名称' => rtrim($value['Gd_cpmc']),
+                '产品代号' => rtrim($value['成品代号']),
+                '产品名称' => rtrim($value['成品名称']),
                 '订单数量' => floatval($value['订单数量']),
                 '单位' => rtrim($value['计量单位']),
                 '折合大箱' => rtrim((int)$value['投料大箱']),