Ver Fonte

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

曹鹤洋 há 1 ano atrás
pai
commit
8d784c72b3

+ 43 - 32
application/api/controller/Manufacture.php

@@ -38,6 +38,14 @@ class Manufacture extends Api
         }else{
             $status = '1-已完工';
         }
+        $page = 0;
+        $limit = 15;
+        if (isset($param['page'])){
+            $page = $param['page'];
+        }
+        if (isset($param['limit'])){
+            $limit = $param['limit'];
+        }
         $where = [
             'gd_statu' => $status,
             '行号' => '1',
@@ -49,7 +57,8 @@ class Manufacture extends Api
         rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
         rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
         rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
-        $list = \db('工单_基本资料')->where($where)->field($field)->limit(500)->order('Uniqid desc')->select();
+        $list = \db('工单_基本资料')->where($where)->field($field)->limit(($page-1)*$limit,$limit)->order('Uniqid desc')->select();
+        $total = \db('工单_基本资料')->where($where)->count();
         if (empty($list)){
             $this->success('',[]);
         }
@@ -64,7 +73,7 @@ class Manufacture extends Api
             }
             unset($list[$key]['成品名称']);
         }
-        $this->success('成功',$list);
+        $this->success('成功',['data'=>$list,'total'=>$total]);
     }
 
     /**
@@ -644,28 +653,36 @@ class Manufacture extends Api
         if (empty($param)){
             $this->error('参数错误');
         }
-        $where = [
-            'Gy0_sbbh' => $param['machine'],
-            'Gy0_sj1' => ['between',['1900-01-01 00:00:01','2098-12-31 23:59:59']],
-            'PD_WG' => '1900-01-01 00:00:00'
-        ];
-        $machine = $where['Gy0_sbbh'];
-        if (isset($param['class'])){
-            $where['Gy0_班次安排'] = $param['class'];
-        }
-        $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,
-        rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,rtrim(Gy0_班次安排) as 班次安排,rtrim(工序备注) as 排单备注,
-        rtrim(Gy0_最早开工时间) as 最早开工时间,rtrim(Gy0_sj1) as 计划开工时间,rtrim(Gy0_sj2) as 计划完工时间,rtrim(Gy0_yjno) as yjno,
-        rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_ls) as ls,rtrim(UniqId) as UniqId';
-        $list = \db('工单_工艺资料')->where($where)->field($filed)->cache(true)->select();
-        if (empty($list)){
-            $this->success('未找到该机台制程中产品');
-        }
-        $Sql = "SELECT SUM(c.sczl_cl) as 已完成,rtrim(c.sczl_gdbh) as gdbh
-                FROM `工单_工艺资料` AS a  JOIN `设备_产量计酬` AS c ON a.Gy0_gdbh = c.sczl_gdbh 
-                AND a.Gy0_gxh = c.sczl_gxh WHERE a.Gy0_sbbh = '{$machine}' AND a.Gy0_sj1 > '1900-01-01 00:00:00' 
-                AND a.Gy0_sj1 < '2099-01-01 00:00:00' AND a.PD_WG = '1900-01-01 00:00:00' GROUP BY a.Gy0_gdbh";
-        $res = Db::query($Sql);
+        $machine = $param['machine'];
+        $list = \db('工单_工艺资料')
+            ->alias('a')
+            ->field([
+                'rtrim(a.Gy0_gdbh)' => '工单编号',
+                'rtrim(a.Gy0_计划接货数)' => '计划接货数',
+                'rtrim(a.Gy0_小时产能)' => '小时产能',
+                'rtrim(a.Gy0_生产工时)' => '生产工时',
+                'rtrim(a.Gy0_辅助工时)' => '辅助工时',
+                'rtrim(a.Gy0_班次安排)' => '班次安排',
+                'rtrim(a.工序备注)' => '排单备注',
+                'rtrim(a.Gy0_最早开工时间)' => '最早开工时间',
+                'rtrim(a.Gy0_sj1)' => '计划开工时间',
+                'rtrim(a.Gy0_sj2)' => '计划完工时间',
+                'rtrim(a.Gy0_yjno)' => 'yjno',
+                'rtrim(a.Gy0_gxh)' => 'gxh',
+                'rtrim(a.Gy0_gxmc)' => 'gxmc',
+                'rtrim(a.Gy0_ls)' => 'ls',
+                'rtrim(a.UniqId)' => 'UniqId',
+                'SUM(b.sczl_cl)' => '已完成'
+            ])
+            ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh','LEFT')
+            ->where([
+                'a.Gy0_sbbh' => $machine,
+                'a.Gy0_sj1' => ['>','1900-01-01 00:00:00'],
+                'a.PD_WG' => '1900-01-01 00:00:00'
+            ])
+            ->where('a.Gy0_sj1','<','2099-01-01 00:00:00')
+            ->group('a.Gy0_gdbh')
+            ->select();
         foreach ($list as $key=>$value){
             $list[$key]['计划接货数'] = (int)round($value['计划接货数']/$value['ls']);
             if ($value['yjno']<10){
@@ -676,12 +693,6 @@ class Manufacture extends Api
             }
             $list[$key]['印件/工序'] = $value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
             unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['ls']);
-            $list[$key]['已完成'] = 0;
-            foreach ($res as $k=>$v){
-                if ($value['工单编号'] === $v['gdbh']){
-                    $list[$key]['已完成'] = $v['已完成'];
-                }
-            }
         }
         $this->success('成功',$list);
     }
@@ -699,11 +710,11 @@ class Manufacture extends Api
         if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-
         $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
+
         $i = 0;
         foreach ($param as $key=>$value){
             $data = [
@@ -714,7 +725,7 @@ class Manufacture extends Api
                 '工序备注' => $value['remark'],
                 'Gy0_最早开工时间' => $value['start'] === ''?'1900-01-01 00:00:00':date('Y-m-d H:i:s',strtotime($value['start'])),
                 'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($value['projectTime'])),
-                'Gy0_sj2' => date('Y-m-d HY-m-d',strtotime(($value['projectTime'])+(ceil($value['ProductionHours'])+ceil($value['AuxiliaryHours']))*3600)),
+                'Gy0_sj2' => date('Y-m-d H:i:s',strtotime($param[0]['projectTime'])+(ceil($param[0]['ProductionHours'])+ceil($param[0]['AuxiliaryHours']))*3600),
             ];
             $sql = \db('工单_工艺资料')
                 ->where('UniqId',$value['UniqId'])

+ 2 - 0
application/api/controller/OrderSuperLoss.php

@@ -136,6 +136,7 @@ class OrderSuperLoss extends Api
                 ->page($pages)
                 ->limit($limit)
                 ->select();
+
             $total = db('rec_月度废品汇总')->alias('a')
                 ->join('工单_基本资料 b', 'a.Gd_gdbh = b.Gd_gdbh','left')
                 ->join('工单_印件资料 c', 'a.Gd_gdbh = c.Yj_Gdbh','left')
@@ -143,6 +144,7 @@ class OrderSuperLoss extends Api
                 ->field('a.Gd_gdbh, SUM(a.废品数量) AS 废品合计, a.年月, rtrim(a.Gd_cpmc) as Gd_cpmc, a.Gd_cpdh, a.实际投料, b.计量单位, c.yj_Yjno, c.yj_ls')
                 ->group('a.Gd_gdbh')
                 ->count();
+
             foreach ($data as $key => $value){
                 //查出成品数量及日期
                 $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$value['Gd_gdbh']}' GROUP BY jjcp_gdbh";

+ 7 - 2
application/api/controller/PieceWorkSchedule.php

@@ -307,10 +307,15 @@ class PieceWorkSchedule extends Api
         if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
             $this->error('参数不能为空');
         }
-
+        $UniqId = db()->table('db_wgjs')->order('UniqId desc')->value('UniqId');
+        if ($UniqId < 1000000){
+            $UniqId = 1000000;
+        }else{
+            $UniqId = $UniqId + 1;
+        }
         $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
         $req['sys_rq'] = date('Y-m-d H:i:s');
-
+        $req['UniqId'] = $UniqId;
         //开启事务
         db()->startTrans();
         try{

+ 262 - 7
application/api/controller/Product.php

@@ -2,6 +2,7 @@
 
 namespace app\api\controller;
 
+use app\admin\model\EntrustLog;
 use app\common\controller\Api;
 use \think\Request;
 use \think\Db;
@@ -123,10 +124,11 @@ class Product extends Api
         $yjRes = db('产品_印件资料')->where($where)->field($field)->select();
         //印版资料
         $filter['a.YB_Cpdh'] = $code;
-        $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,rtrim(b.物料名称) as 印版名称,a.UniqID';
+        $yb_field = 'rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,rtrim(a.存货编码) as 存货编码,a.考核印数,rtrim(a.Sys_id) as Sys_id,a.Mod_rq,rtrim(b.物料名称) as 印版名称,rtrim(c.名称) as 印版类别,a.UniqID';
         $ybRes = db('产品_印版资料')->alias('a')
-            ->join('物料_存货编码 b','a.存货编码 = b.物料代码')
-            ->where($filter)->field($yb_field)->select();
+            ->join('物料_存货编码 b','a.存货编码 = b.物料代码','left')
+            ->join('物料_存货结构 c','LEFT(a.存货编码,4) = c.编号','left')
+            ->where($filter)->field($yb_field)->order('a.YB_Yjno,a.存货编码')->select();
         $list = [];
         $list['yjData'] = $yjRes;
         $list['gyData'] = $gyRes;
@@ -135,7 +137,7 @@ class Product extends Api
         $this->success('请求成功',$list);
     }
     /**
-     * 获取单个产品工艺数据
+     * 4.获取单个工艺数据(排产参数调整)
      *
      * @ApiMethod GET
      *@param string product_code
@@ -156,7 +158,7 @@ class Product extends Api
         $gy_field = 'rtrim(a.Gy0_方案) as programme,a.Gy0_yjno,a.Gy0_gxh,rtrim(a.gy0_gxmc) as gy0_gxmc,a.A类产能 as A_power,rtrim(a.Gy0_shdh) as Gy0_shdh,rtrim(a.Gy0_sbbh) as Gy0_sbbh,
         a.工价系数 as difficulty_coe,a.损耗系数 as loss_coe,a.Gy0_Ms as ms_coe,a.Gy0_Ks,a.Gy0_ls,rtrim(a.Gy0_site) as Gy0_site,rtrim(a.Add_gxmc) as Add_gxmc,a.UniqID,a.Gy0_辅助工时,
         rtrim(a.工序备注) as remark,a.人工检_正品板 as artificial_zp,a.人工检_次品板 as artificial_cp,a.人工检_废检 as artificial_fj,a.机检_正品板 as machine_zp,a.机检_次品板 as machine_cp,
-        a.机检_废检 as machine_fj,rtrim(b.客户名称) as custom_name,rtrim(b.产品名称) as product_name';
+        a.机检_废检 as machine_fj,rtrim(b.客户名称) as custom_name,rtrim(b.产品名称) as product_name,UniqId';
         $gyRes = db('产品_工艺资料')->alias('a')
             ->join('产品_基本资料 b','a.Gy0_cpdh = b.产品编号','left')
             ->where($option)->field($gy_field)->order('a.Gy0_yjno asc,a.Gy0_gxh asc')->select();
@@ -532,7 +534,7 @@ class Product extends Api
         }
         $field = "yj_yjno,rtrim(yj_yjdh) as yj_yjdh,rtrim(yj_yjmc) as yj_yjmc,rtrim(yj_zzdh) as yj_zzdh,rtrim(yj_zzmc) as yj_zzmc,rtrim(yj_zzdh1) as yj_zzdh1,rtrim(yj_zzdh2) as yj_zzdh2,
         rtrim(yj_zzdh3) as yj_zzdh3,rtrim(yj_zzdh4) as yj_zzdh4,rtrim(yj_zzmc1) as yj_zzmc1,rtrim(yj_zzmc2) as yj_zzmc2,rtrim(yj_zzmc3) as yj_zzmc3,
-        rtrim(yj_zzmc4) as yj_zzmc4,rtrim(yj_tlgg) as yj_tlgg,rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,KgToPages,rtrim(yj_desc) as yj_desc,";
+        rtrim(yj_zzmc4) as yj_zzmc4,rtrim(yj_tlgg) as yj_tlgg,rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,KgToPages,rtrim(yj_desc) as yj_desc,UniqId";
         $list = \db('产品_印件资料')->where('UniqId',$params['UniqId'])->field($field)->select();
         $this->success('请求成功',$list);
     }
@@ -646,6 +648,259 @@ class Product extends Api
         }
         $params = Request::instance()->get();
         $search = $params['search'];
-//        $list = \db('物料_存货结构')->where('LEFT(编号)')
+        if (!empty($search)){
+            $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
+                rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
+                FROM `物料_存货编码` a
+                LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,2) = b.编号
+                LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
+                LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
+                WHERE a.物料名称 LIKE '%{$search}%' AND (a.物料代码 LIKE '00%' or a.物料代码 LIKE '01%' or a.物料代码 LIKE '30%')";
+        }else{
+            $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,rtrim(b.编号) as oneCode,rtrim(b.名称) as oneName,
+                rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
+                FROM `物料_存货编码` a
+                LEFT JOIN `物料_存货结构` b ON LEFT(a.物料代码,2) = b.编号
+                LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
+                LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
+                WHERE  a.物料代码 LIKE '00%' or a.物料代码 LIKE '01%' or a.物料代码 LIKE '30%'";
+        }
+        $data = Db::query($sql);
+        $mergedArray = [];
+        foreach ($data as $item) {
+            $oneCode = $item['oneCode'];
+            $twoCode = $item['twoCode'];
+            $thrCode = $item['thrCode'];
+            $oneName = $item['oneName'];
+            $twoName = $item['twoName'];
+            $thrName = $item['thrName'];
+            // Create a unique key using the combination of oneCode, twoCode, and thrCode
+            $oneKey = "{$oneCode}/{$oneName}";
+            $twoKey = "{$twoCode}/{$twoName}";
+            $thrKey = "{$thrCode}/{$thrName}";
+            // Initialize arrays if not already set
+            if (!isset($mergedArray[$oneKey])) {
+                $mergedArray[$oneKey] = [];
+            }
+            if (!isset($mergedArray[$oneKey][$twoKey])) {
+                $mergedArray[$oneKey][$twoKey] = [];
+            }
+            // Append items to the arrays
+            $mergedArray[$oneKey][$twoKey][$thrKey][] = $item;
+        }
+        $this->success('请求成功',$mergedArray);
+    }
+    /**
+     *3.6工艺资料-获取产品工艺资料
+    */
+    public function getProductGyInfo(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (empty($params['UniqID']) || empty($params['UniqID'])){
+            $this->error('参数错误');
+        }
+        $field = "rtrim(a.Gy0_方案) as Gy0_方案,a.Gy0_yjno,a.Gy0_gxh,a.Gy0_Ks,a.Gy0_ls,rtrim(a.Gy0_site) as Gy0_site,rtrim(a.gy0_gxmc) as gy0_gxmc,rtrim(a.Add_gxmc) as Add_gxmc,a.Gy0_Ms,
+                  rtrim(a.Gy0_sbbh) as Gy0_sbbh,rtrim(a.Gy0_shdh) as Gy0_shdh,rtrim(b.sys_mc) as sys_mc,b.sys_rate0,b.sys_rate1,a.工价系数,a.损耗系数,rtrim(a.工序备注) as 工序备注,
+                  rtrim(a.质量要求) as 质量要求,rtrim(a.质量隐患) as 质量隐患,a.UniqID";
+        $data = \db('产品_工艺资料')->alias('a')
+            ->join('dic_lzsh b','a.Gy0_shdh = b.sys_bh','left')
+            ->where('a.UniqID',$params['UniqID'])
+            ->field($field)
+            ->find();
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 3.7工艺资料-获取车间及工艺名称
+     * @ApiMethod GET
+     *
+    */
+    public function getDepartName(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $data = \db('erp_常用字典')->where('分类','印刷工艺')->order('编号 asc')->column('名称');
+
+        $resultArray = [];
+        foreach ($data as $item) {
+            $parts = explode('_', $item);
+            // 使用第一个部分作为一级键,第二个部分作为二级键
+            $firstKey = $parts[0];
+            $secondKey = $parts[1];
+            $thirdValue = $parts[2];
+
+            $resultArray[$firstKey][$secondKey][] = $thirdValue;
+        }
+        $this->success('请求成功',$resultArray);
+    }
+    /**
+     * 3.8工艺资料-新增产品工艺
+    */
+    public function addProductGyInfo(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        $UniqId = \db('产品_工艺资料')->order('UniqID desc')->value('UniqID');
+        if ($UniqId < 2000000){
+            $UniqId = 2000000;
+        }else{
+            $UniqId = $UniqId + 1;
+        }
+        $params['UniqID'] = $UniqId;
+        $params['Sys_rq'] = date('Y-m-d H:i:s');
+        $sql = \db('产品_工艺资料')->fetchSql(true)->insert($params);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('新增成功');
+        }else{
+            $this->error('新增失败');
+        }
+    }
+    /**
+     * 3.9印版资料-获取产品印版资料
+     * @ApiMethod GET
+    */
+    public function getProductYbInfo(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (empty($params['UniqID']) || empty($params['UniqID'])){
+            $this->error('参数错误');
+        }
+        $field = "rtrim(a.YB_方案) as YB_方案,a.YB_Yjno,a.YB_gxh,rtrim(a.存货编码) as 存货编码,rtrim(a.印版名称) as 印版名称,a.UniqID,rtrim(b.gy0_gxmc) as gy0_gxmc,
+                rtrim(b.Add_gxmc) as Add_gxmc,rtrim(c.物料名称) as 物料名称,rtrim(a.YB_cpdh) as YB_cpdh";
+        $data = \db('产品_印版资料')->alias('a')
+            ->join('产品_工艺资料 b','a.YB_cpdh = b.Gy0_cpdh and a.YB_Yjno = b.Gy0_yjno and a.YB_gxh = b.Gy0_gxh','left')
+            ->join('物料_存货编码 c','a.存货编码 = c.物料代码','left')
+            ->where('a.UniqID',$params['UniqID'])->field($field)->order('存货编码')->find();
+        $where['Gy0_site'] = [
+            ['like','%胶印%'],
+            ['like','%烫模%'],
+            'or'
+        ];
+        $option['Gy0_cpdh'] = $data['YB_cpdh'];
+        $option['Gy0_gxh'] = ['<',10];
+        $option['Gy0_sbbh'] = ['neq',''];
+        $gyData = \db('产品_工艺资料')->where($option)->where($where)->field('Gy0_方案,Gy0_yjno,Gy0_gxh,gy0_gxmc')->order('Gy0_yjno,Gy0_gxh')->select();
+        halt($gyData);
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 3.10印版资料-修改产品印版资料
+     * @ApiMethod POST
+     * @params string UniqId
+    */
+    public function editProductYbInfo(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (empty($params) || !isset($params['UniqId'])){
+            $this->error('参数不能为空');
+        }
+        $UniqId = $params['UniqId'];
+        unset($params['UniqId']);
+        $sql = \db('产品_印版资料')->where('UniqId',$UniqId)->fetchSql(true)->update($params);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 印版资料-获取物料名称
+     * @ApiMethod GET
+     *
+    */
+    public function getProductYbMaterialList(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $sql = "SELECT rtrim(`编号`) as 编号, rtrim(`名称`) as 名称 FROM `物料_存货结构` WHERE `编号` IN ('0502','0503','0510','0511','0512','0513','0514','0520','0521','0523','0524','0525')";
+        $data = Db::query($sql);
+        $this->success('请求成功',$data);
+    }
+    /**
+     *3.12印版资料-获取详细存货名称
+     * @ApiMethod GET
+     * @params string code
+    */
+    public function getProductYbMaterialDetail(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->get();
+        if (empty($params) || !isset($params['code'])){
+            $this->error('参数不能为空');
+        }
+        $code = $params['code'];
+        $search = $params['search'];
+        if (!empty($search)){
+            $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,
+                rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
+                FROM `物料_存货编码` a
+                LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
+                LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
+                WHERE  a.物料代码 LIKE '{$code}%' AND a.物料名称 LIKE '%{$search}%'";
+        }else{
+            $sql = "SELECT rtrim(a.`物料代码`) as 物料代码,rtrim(a.`物料名称`) as 物料名称,rtrim(a.`规格`) as 规格,
+                rtrim(c.`编号`) as twoCode,rtrim(c.`名称`) as twoName,rtrim(d.`编号`) as thrCode,rtrim(d.`名称`) as thrName
+                FROM `物料_存货编码` a
+                LEFT JOIN `物料_存货结构` c ON LEFT(a.物料代码,4) = c.编号
+                LEFT JOIN `物料_存货结构` d ON LEFT(a.物料代码,6) = d.编号
+                WHERE  a.物料代码 LIKE '{$code}%'";
+        }
+        $data = Db::query($sql);
+        $mergedArray = [];
+        foreach ($data as $item) {
+            $oneCode = '05';
+            $twoCode = $item['twoCode'];
+            $thrCode = $item['thrCode'];
+            $oneName = '版材';
+            $twoName = $item['twoName'];
+            $thrName = $item['thrName'];
+            $oneKey = "{$oneCode}/{$oneName}";
+            $twoKey = "{$twoCode}/{$twoName}";
+            $thrKey = "{$thrCode}/{$thrName}";
+            if (!isset($mergedArray[$oneKey])) {
+                $mergedArray[$oneKey] = [];
+            }
+            if (!isset($mergedArray[$oneKey][$twoKey])) {
+                $mergedArray[$oneKey][$twoKey] = [];
+            }
+            $mergedArray[$oneKey][$twoKey][$thrKey][] = $item;
+        }
+        $this->success('请求成功',$mergedArray);
+    }
+    /**
+     * 3.13印版资料-新增产品印版资料
+     * @ApiMethod POST
+     * @params array data
+    */
+    public function addProductYbInfo(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        $UniqId = \db('产品_印版资料')->order('UniqID desc')->value('UniqID');
+        if ($UniqId < 2000000){
+            $UniqId = 2000000;
+        }else{
+            $UniqId = $UniqId + 1;
+        }
+        $params['UniqID'] = $UniqId;
+        $params['考核印数'] = '0.00';
+        $params['Sys_rq'] = date('Y-m-d H:i:s');
+        $sql = \db('产品_印版资料')->fetchSql(true)->insert($params);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('新增成功');
+        }else{
+            $this->error('新增失败');
+        }
     }
 }

+ 7 - 1
application/api/controller/WorkOrderSpotCheck.php

@@ -251,7 +251,13 @@ class WorkOrderSpotCheck extends Api
             $req['Sczl_rq'] = $req['Sczl_rq'].' 00:00:00';
         }
         $req['Sys_rq'] = date('Y-m-d H:i:s');
-
+        $UniqId = db()->table('db_抽检记录')->order('UniqId desc')->value('UniqId');
+        if ($UniqId < 1000000){
+            $UniqId = 1000000;
+        }else{
+            $UniqId = $UniqId + 1;
+        }
+        $req['UniqId'] = $UniqId;
         //开启事务
         db()->startTrans();
         try{