Quellcode durchsuchen

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

曹鹤洋 vor 1 Jahr
Ursprung
Commit
a244e6afd9

+ 4 - 4
application/api/controller/Custom.php

@@ -33,7 +33,7 @@ class Custom extends Api
             $this->error('非法请求');
         }
         $field = 'rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称';
-        $list = Db::name('产品_基本资料')->distinct(true)->field($field)->order('客户编号 asc')->select();
+        $list = db('产品_基本资料')->distinct(true)->field($field)->order('客户编号 asc')->select();
         $this->success('请求成功',$list);
     }
     /**
@@ -70,8 +70,8 @@ class Custom extends Api
             $where['编号|名称|地址|联系人|业务员'] = array('like','%'.$search.'%');
         }
         $field = 'rtrim(编号) as 编号,rtrim(名称) as 名称,rtrim(简称) as 简称,rtrim(地址) as 地址,rtrim(联系人) as 联系人,rtrim(电话) as 电话,业务员,rtrim(币种) as 币种,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqId';
-        $list = Db::name('erp_客户供应商')->where($where)->field($field)->limit($limit)->page($pages)->select();
-        $total = Db::name('erp_客户供应商')->where($where)->count();
+        $list = db('erp_客户供应商')->where($where)->field($field)->limit($limit)->page($pages)->select();
+        $total = db('erp_客户供应商')->where($where)->count();
         $data['data'] = $list;
         $data['total'] = $total;
         $this->success('请求成功',$data);
@@ -118,7 +118,7 @@ class Custom extends Api
         if (!empty($params['currency'])){
             $data['币种'] = $params['currency'];
         }
-        $sql = Db::name('erp_客户供应商')->where('UniqId',$params['UniqId'])->fetchSql(true)->update($data);
+        $sql = db('erp_客户供应商')->where('UniqId',$params['UniqId'])->fetchSql(true)->update($data);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');

+ 3 - 3
application/api/controller/Dictionary.php

@@ -30,7 +30,7 @@ class Dictionary extends Api
         if (Request::instance()->isGet() == false){
             $this->error('非法请求');
         }
-        $list = Db::name('erp_常用字典')->order('编号 asc')->column('trim(名称) as name');
+        $list = db('erp_常用字典')->order('编号 asc')->column('trim(名称) as name');
 
         // 分割字符串并合并相同项
         $resultArray = [];
@@ -77,7 +77,7 @@ class Dictionary extends Api
         if (!empty($params['search'])){
             $where['名称'] = array('like','%'.$params['search'].'%');
         }
-        $list = Db::name('erp_常用字典')->where($where)->order('次序 desc,UniqId asc')->select();
+        $list = db('erp_常用字典')->where($where)->order('次序 desc,UniqId asc')->select();
         $this->success('请求成功',$list);
 
     }
@@ -112,7 +112,7 @@ class Dictionary extends Api
             if (!empty($value['次序'])){
                 $data['次序'] = $value['次序'];
             }
-            $sql = Db::name('erp_常用字典')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+            $sql = db('erp_常用字典')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
 
             $res = Db::query($sql);
             if ($res !== false){

+ 104 - 103
application/api/controller/Facility.php

@@ -5,6 +5,7 @@ namespace app\api\controller;
 
 use app\common\controller\Api;
 use think\Db;
+use think\Request;
 
 /**
  * 设备运行跟踪
@@ -93,7 +94,6 @@ class Facility extends Api
         $productName = Db::table('工单_基本资料')->whereIn('Gd_gdbh',$Gd_gdbh)->column('Gd_cpmc','Gd_gdbh');
         //组员信息
         $list = Db::table('设备_产量计酬')->where($where)->field($field)->select();
-        halt($list);
         $totalA = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','A班')->field('SUM(sczl_cl) as 产量')->select();
         $totalB = Db::table('设备_产量计酬')->where($where)->where('sczl_bzdh','B班')->field('SUM(sczl_cl) as 产量')->select();
         if (empty($list)){
@@ -232,49 +232,44 @@ class Facility extends Api
         if (empty($machine)){
             $this->error('参数错误');
         }
-//        $lastUniqid = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
-//        $startUniqid = $lastUniqid['UniqId']-10000;
-//        halt($lastUniqid);
-        $workOrder = Db::table('设备_产量计酬')->where('sczl_jtbh',$machine)->field('sczl_gdbh')->order('UniqId desc')->find();
-
-        if (empty($workOrder)){
-            $this->error('未找到正在生产工单');
-        }
-        $where = [
-            'Gy0_sbbh' => $machine,
-            'Gy0_gdbh' => $workOrder['sczl_gdbh']
-        ];
-        $list = Db::table('工单_工艺资料')->where($where)->find();
+        $sql = "SELECT
+                rtrim(b.Gy0_gdbh) AS 工单编号,
+                rtrim(b.Gy0_yjno) AS 印件号,
+                rtrim(b.Gy0_gxh) AS gxh,
+                rtrim(b.Gy0_gxmc) AS gxmc,
+                rtrim(b.Add_gxmc) AS add_gxmc,
+                RTRIM(a.Gd_cpmc) AS 产品名称
+            FROM
+                `工单_基本资料` AS a
+            JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+            JOIN `产品_基本资料` AS c ON a.`成品代号` = c.`产品编号`
+            JOIN `工单_印件资料` AS d ON a.Gd_gdbh = d.Yj_Gdbh
+            LEFT JOIN `设备_产量计酬` AS e ON e.sczl_gdbh = a.Gd_gdbh
+            AND e.sczl_jtbh = b.Gy0_sbbh
+            WHERE
+                a.gd_statu = '2-生产中'
+                AND a.`行号` = '1'
+                AND b.Gy0_sbbh = '{$machine}'
+                AND c.`状态` = ''
+                AND b.PD_WG = '1900-01-01 00:00:00'
+                AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
+            GROUP BY
+                a.Gd_gdbh
+            ORDER BY
+                b.Gy0_sj1
+            LIMIT 1";
+        $list = Db::query($sql);
         if (empty($list)){
-            $this->error('未找到正在生产工单');
+            $this->error('未找到产工单');
         }
-        $facilityWhere = [
-            'sczl_jtbh'=>$machine,
-            'sczl_gdbh'=>$list['Gy0_gdbh']
-        ];
-        $facilityField = 'sczl_bh1,sczl_bh2,sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10';
-        $Ctaff = Db::table('设备_产量计酬')->where($facilityWhere)->field($facilityField)->order('UniqId desc')->find();
-        $data = [];
-        foreach ($Ctaff as $key=>$value){
-            if (!empty($value)){
-                $staffName = Db::table('人事_基本资料')->where('员工编号',$value)->field('员工姓名,员工编号')->find();
-                $data[$key] = [
-                    '员工编号' => rtrim($staffName['员工编号']),
-                    '员工姓名' => rtrim($staffName['员工姓名']),
-                ];
+        foreach ($list as $key=>$value){
+            if ($value['gxh']<10){
+                $list[$key]['gxh'] = '0'.$value['gxh'];
             }
+            $list[$key]['工序名称'] = $list[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
+            unset($list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['add_gxmc']);
         }
-        if ($list['Gy0_yjno']<10){
-            $list['Gy0_yjno'] = '0'.$list['Gy0_yjno'];
-        }
-        if ($list['Gy0_gxh']<10){
-            $list['Gy0_gxh'] = '0'.$list['Gy0_gxh'];
-        }
-        $data['工单编号'] = rtrim($list['Gy0_gdbh']);
-        $data['印件编号'] = rtrim($list['Gy0_yjno']);
-        $data['工序名称'] = rtrim($list['Gy0_gxh']).'-'.rtrim($list['Gy0_gxmc']).'【'.rtrim($list['Add_gxmc']).'】';
-        $data['产品名称'] = Db::table('工单_基本资料')->where('Gd_gdbh',rtrim($list['Gy0_gdbh']))->field('rtrim(Gd_cpmc) as 产品名称')->find()['产品名称'];
-        $this->success('成功',$data);
+        $this->success('成功',$list);
     }
 
     /**
@@ -296,49 +291,57 @@ class Facility extends Api
         if (empty($machine)){
             $this->error('参数错误');
         }
-        $lastTechonUniqId = Db::table('工单_工艺资料')->field('UniqId')->order('UniqId desc')->find();
-        $startTechonUniqId = $lastTechonUniqId['UniqId']-10000;
-//        $lastYieldUniqId = Db::table('设备_产量计酬')->field('UniqId')->order('UniqId desc')->find();
-//        $startYieldUniqId = $lastYieldUniqId['UniqId']-100000;
-        $workOrder = Db::table('设备_产量计酬')->where('sczl_jtbh',$machine)->field('sczl_gdbh')->where('UniqId','>',$startYieldUniqId)->order('UniqId desc')->find();
-        $startTime = Db::table('工单_工艺资料')->where('Gy0_gdbh',$workOrder['sczl_gdbh'])->where('Gy0_sbbh',$machine)->where('UniqId','>',$startTechonUniqId)->field('Gy0_sj1')->order('UniqId desc')->find();
-        $where = [
-//            'UniqId' => ['>',$startTechonUniqId],
-            'Gy0_sbbh' => $machine,
-            'Gy0_sj1' => ['>= time',$startTime['Gy0_sj1']],
-        ];
-        $field = 'rtrim(Gy0_gdbh) as gdbh,rtrim(质量要求) as 质量信息,rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,
-        rtrim(Add_gxmc) as add_gxmc,rtrim(Gy0_辅助工时) as 装版时数,rtrim(Gy0_小时产能) as 工序产能,rtrim(Gy0_生产工时) as 计划工时,
-        rtrim(Gy0_sj1) as sj1,rtrim(Gy0_sj2) as sj2,rtrim(工序备注) as 排产备注';
-        $orderList = Db::table('工单_工艺资料')
-            ->where($where)
-            ->where('Gy0_sj1','<','2099-01-01 00:00:00')
-            ->field($field)
-            ->order('UniqId desc')
-            ->select();
+        $sql = "SELECT
+                rtrim( b.Gy0_gdbh ) AS gdbh,
+                rtrim(b.质量要求) AS 质量信息,
+                rtrim( b.Gy0_yjno ) AS yjno,
+                rtrim( b.Gy0_gxh ) AS gxh,
+                rtrim( b.Gy0_gxmc ) AS gxmc,
+                rtrim( b.Add_gxmc ) AS add_gxmc,
+                rtrim( b.Gy0_辅助工时 ) AS 装版时数,
+                rtrim( b.Gy0_小时产能 ) AS 工序产能,
+                rtrim( b.Gy0_生产工时 ) AS 计划工时,
+                rtrim( b.Gy0_sj1 ) AS sj1,
+                rtrim( b.Gy0_sj2 ) AS sj2,
+                rtrim(b.工序备注) AS 排产备注,
+                RTRIM(d.yj_yjmc) AS 印件名称,
+                RTRIM(a.Gd_cpmc) AS 产品名称,
+                RTRIM(a.成品代号) AS 产品代号,
+                SUM(E.sczl_cl) AS 已完成,
+                rtrim(b.Gy0_计划接货数) AS 计划接货数,
+                RTRIM(b.Gy0_ls) AS ls 
+            FROM
+                `工单_基本资料` AS a
+                JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+                JOIN `产品_基本资料` AS c ON a.`成品代号` = c.`产品编号` 
+                JOIN `工单_印件资料` AS d ON a.Gd_gdbh = d.Yj_Gdbh
+                LEFT JOIN `设备_产量计酬` AS e ON e.sczl_gdbh = a.Gd_gdbh AND e.sczl_jtbh = b.Gy0_sbbh
+            WHERE
+                a.gd_statu = '2-生产中' 
+                AND a.`行号` = '1' 
+                AND b.Gy0_sbbh = '{$machine}' 
+                AND c.`状态` = '' 
+                AND b.PD_WG = '1900-01-01 00:00:00' 
+                AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
+            GROUP BY a.Gd_gdbh
+            ORDER BY b.Gy0_sj1";
+        $orderList = Db::query($sql);
+        if (empty($orderList)){
+            $this->error('未找到排产工单');
+        }
         foreach ($orderList as $key=>$value){
             $orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
-            $name = Db::table('工单_印件资料')->where(['Yj_Gdbh'=>$value['gdbh'],'yj_Yjno'=>$value['yjno']])->field('yj_yjmc')->find();
             if ($value['yjno']<10){
                 $orderList[$key]['yjno'] = '0'.$value['yjno'];
             }
             if ($value['gxh']<10){
                 $orderList[$key]['gxh'] = '0'.$value['gxh'];
             }
-            $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.rtrim($name['yj_yjmc']);
+            $orderList[$key]['印件资料'] = $orderList[$key]['yjno'].'-'.$value['印件名称'];
             $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
-            $scheduled = Db::table('工单_基本资料')->where('Gd_gdbh',$value['gdbh'])->field('rtrim(计划投料) as 计划产量')->find();
-            $finished = Db::table('设备_产量计酬')
-                ->where('sczl_gdbh',$value['gdbh'])
-                ->where('sczl_jtbh',$machine)
-//                ->where('UniqId','>',$startYieldUniqId)
-                ->order('UniqId desc')
-                ->field('SUM(sczl_cl) as cl')
-                ->select();
-            $orderList[$key]['计划产量/已完成'] = $scheduled['计划产量'].'/'.$finished[0]['cl']=null?'':(int)$finished[0]['cl'];
+            $orderList[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$value['已完成']=null?'':(int)$value['已完成'];
             $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
-            $orderList[$key]['产品名称'] = rtrim($name['yj_yjmc']);
-            unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['yjno'],$orderList[$key]['gxh'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['sj1'],$orderList[$key]['sj2']);
+            unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['yjno'],$orderList[$key]['gxh'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['sj1'],$orderList[$key]['sj2'],$orderList[$key]['计划接货数'],$orderList[$key]['已完成'],$orderList[$key]['印件名称'],$orderList[$key]['ls']);
         }
         $this->success('成功',$orderList);
     }
@@ -575,10 +578,10 @@ class Facility extends Api
 
     public function TeamMaintenance()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -602,11 +605,15 @@ class Facility extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
-        $list = Db::table('设备_基本资料')->column('设备编号');
+        $list = Db::table('设备_基本资料')->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
         if (empty($list)){
             $this->error('未找到机台编号');
         }
-        $this->success('成功',$list);
+        $data = [];
+        foreach ($list as $key=>$value){
+            $data[$key] = $value['设备编号'] . '||' . $value['设备名称'];
+        }
+        $this->success('成功',$data);
     }
 
     /**
@@ -619,10 +626,10 @@ class Facility extends Api
      */
     public function teamDel()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
@@ -713,10 +720,10 @@ class Facility extends Api
 
     public function FieldInspectionRecordAdd()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
@@ -822,40 +829,32 @@ class Facility extends Api
      */
     public  function InspectionItemAdd()
     {
-        if ($this->request->isPost()  === false){
+        if (Request::instance()->isPost()  === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
-        $data = [
-            'team' => $param['team'],
-            'machine' => $param['machine'],
-            'unitName' => $param['unitName']
-        ];
-        unset($param['team'],$param['machine'],$param['unitName']);
-        $lastId = Db::table('设备_点检记录')->field('rtrim(Uniqid) as id')->order('Uniqid desc')->find();
-        $unitCode = Db::table('设备_点检项目')->where('部件名称',$data['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
+        $lastId = 10000000;
         $row = [];
-        $param = array_values($param);
         foreach ($param as $key=>$value){
-            $value = explode(';',$value);
+            $unitCode = Db::table('设备_点检项目')->where('部件名称',$value['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
             $row[$key] = [
                 '日期' => date('Y-m-d 00:00:00',time()),
-                '班组编号' => $data['team'],
-                '点检设备' => $data['machine'],
+                '班组编号' => $value['team'],
+                '点检设备' => $value['machine'],
                 '部件编号' => $unitCode['部件编号'],
-                '部件名称' => $data['unitName'],
-                '检验项目' => $value[0],
-                '判定标准' => $value[4],
-                '点检方法' => $value[1],
-                '点检结果' => $value[2],
-                '备注说明' => $value[3],
+                '部件名称' => $value['unitName'],
+                '检验项目' => $value['itemName'],
+                '判定标准' => $value['standard'],
+                '点检方法' => $value['method'],
+                '点检结果' => $value['status'],
+                '备注说明' => $value['remark'],
                 'Sys_id'  =>'',
                 'Sys_rq'  => date('Y-m-d H:i:s',time()),
-                'Mod_rq'  => '',
-                'Uniqid'  => $lastId['id']+$key+1
+                'Mod_rq'  => date('Y-m-d H:i:s',time()),
+                'Uniqid'  => $lastId+$key+1
             ];
 
         }
@@ -1027,4 +1026,6 @@ class Facility extends Api
         $nowTime = date('Y-m-d H:i:s',time());
 
     }
+
+    //
 }

+ 2 - 2
application/api/controller/Machine.php

@@ -47,8 +47,8 @@ class Machine extends Api
         }
         $where['使用部门'] = $department;
         $field = '设备编号,rtrim(设备名称) as 设备名称,rtrim(生产工序) as 生产工序,日定额,千件工价,机长,副机,调墨,二手,飞达,辅助,放卷,分切1,分切2,检验,rtrim(使用部门) as 使用部门,sys_id,sys_rq,mod_rq,UniqId';
-        $list = Db::name('设备_基本资料')->where($where)->field($field)->limit($limit)->page($pages)->order('设备编号 asc')->select();
-        $count = Db::name('设备_基本资料')->where($where)->field($field)->count();
+        $list = db('设备_基本资料')->where($where)->field($field)->limit($limit)->page($pages)->order('设备编号 asc')->select();
+        $count = db('设备_基本资料')->where($where)->field($field)->count();
         $data['data'] = $list;
         $data['total'] = $count;
         $this->success('请求成功',$data);

+ 279 - 67
application/api/controller/Manufacture.php

@@ -4,7 +4,9 @@ namespace app\api\controller;
 
 
 use app\common\controller\Api;
+use Monolog\Handler\IFTTTHandler;
 use think\Db;
+use think\Request;
 /**
  *
  * 生产排单管理
@@ -14,34 +16,6 @@ class Manufacture extends Api
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
 
-    //查找工单
-    public function WorkOrderSearch(){
-        if ($this->request->isGet() === false){
-            $this->error('请求错误');
-        }
-        $workOder = input('workOrder');
-        $printName = input('printName');
-        if (empty($workOder)){
-            $this->error('参数错误');
-        }
-        $where = [
-            'Gd_gdbh' => $workOder
-        ];
-        if (!empty($printName)){
-            $where['成品名称'] = $printName;
-        }
-        $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
-        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::table('工单_基本资料')->where($where)->field($field)->find();
-        if (empty($list)){
-            $this->error('未找到该工单');
-        }
-        $this->success('成功',$list);
-    }
-
-
     /**
      * 计划中工单
      * @ApiMethod (GET)
@@ -55,26 +29,40 @@ class Manufacture extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        if ($param['status'] === '计划中'){
+            $status = '3-计划中';
+        }else{
+            $status = '1-已完工';
+        }
         $where = [
-            'gd_statu' => '3-计划中',
+            'gd_statu' => $status,
             '行号' => '1',
         ];
-        $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,
+        if (isset($param['search'])){
+            $where['Gd_lx|Gd_gdbh|Gd_客户代号|Gd_客户名称|Gd_khdh|Gd_khmc|Gd_cpdh|Gd_cpmc|成品代号|成品名称|产品版本号'] = ['like','%'.$param['search'].'%'];
+        }
+        $field = 'rtrim(Gd_生产分类) as 生产分类,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(成品名称) as 成品名称,
         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::table('工单_基本资料')->where($where)->field($field)->select();
+        $list = Db::table('工单_基本资料')->where($where)->field($field)->limit(500)->order('Uniqid desc')->select();
         if (empty($list)){
             $this->error('失败');
         }
         foreach ($list as $key=>$value){
             $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
+            $list[$key]['产品名称'] = $value['产品名称'] != '' ? $value['产品名称']:$value['成品名称'];
             $number = Db::table('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
             if ($number === 0){
                 $list[$key]['status'] = 0;
             }else{
                 $list[$key]['status'] = 1;
             }
+            unset($list[$key]['成品名称']);
         }
         $this->success('成功',$list);
     }
@@ -105,7 +93,7 @@ class Manufacture extends Api
         rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
         $list = Db::table('工单_工艺资料')->where($where)->field($filed)->select();
         if (empty($list)){
-            $this->error('失败');
+            $this->success('',[]);
         }
         foreach ($list as $key=>$value){
             if ((int)$value['Gy0_yjno'] <10){
@@ -168,14 +156,89 @@ class Manufacture extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
-        $where = [
-            'gd_statu' => '2-生产中',
-            '行号' => 1
-        ];
-        $field = 'rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(接单日期) as 接单日期,
-        rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(销售订单号) as 销售订单号,rtrim(Gd_客户代号) as 客户编号,
-        rtrim(Gd_客户名称) as 客户名称,rtrim(客户料号) as 客户料号,rtrim(Uniqid) as GDUID';
-        $list = Db::table('工单_基本资料')->where($where)->field($field)->select();
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $where = '';
+        if (isset($param['search'])){
+            $where = "
+                        a.Gd_lx LIKE '%{$param['search']}%' 
+                        OR a.Gd_gdbh LIKE '%{$param['search']}%' 
+                        OR a.`Gd_客户代号` LIKE '%{$param['search']}%' 
+                        OR a.`Gd_客户名称` LIKE '%{$param['search']}%' 
+                        OR a.Gd_khdh LIKE '%{$param['search']}%' 
+                        OR a.Gd_khmc LIKE '%{$param['search']}%' 
+                        OR a.Gd_cpdh LIKE '%{$param['search']}%' 
+                        OR a.Gd_cpmc LIKE '%{$param['search']}%' 
+                        OR a.`成品代号` LIKE '%{$param['search']}%' 
+                        OR a.`成品名称` LIKE '%{$param['search']}%' 
+                        OR a.`产品版本号` LIKE '%{$param['search']}%' 
+                    ";
+        }
+        if ($param['status'] === '排程中'){
+            $sql = "SELECT
+                    rtrim( a.Gd_gdbh ) AS 工单编号,
+                    rtrim( a.Gd_cpdh ) AS 产品代号,
+                    rtrim( a.Gd_cpmc ) AS 产品名称,
+                    rtrim( a.接单日期 ) AS 接单日期,
+                    rtrim( a.交货日期 ) AS 交货日期,
+                    rtrim( a.订单数量 ) AS 订单数量,
+                    rtrim( a.计量单位 ) AS 计量单位,
+                    rtrim( a.销售订单号 ) AS 销售订单号,
+                    rtrim( a.Gd_客户代号 ) AS 客户编号,
+                    rtrim( a.Gd_客户名称 ) AS 客户名称,
+                    rtrim( a.客户料号 ) AS 客户料号,
+                    rtrim( a.Uniqid ) AS GDUID 
+                FROM
+                    `工单_基本资料` AS a
+                    INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+                    JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号 
+                WHERE
+                    a.gd_statu = '2-生产中' 
+                    AND a.行号 = '1' 
+                    AND b.PD_WG = '1900-01-01 00:00:00' 
+                    AND b.Gy0_sj1 = '1900-01-01 00:00:00' 
+                    AND c.状态 = ''
+                    AND (".
+                        $where
+                    .")
+                GROUP BY
+                    a.Gd_gdbh";
+        }else{
+            $sql = "SELECT
+                rtrim(a.Gd_gdbh) AS 工单编号,
+                rtrim(a.Gd_cpdh) AS 产品代号,
+                rtrim(a.Gd_cpmc) AS 产品名称,
+                rtrim(a.接单日期) AS 接单日期,
+                rtrim(a.交货日期) AS 交货日期,
+                rtrim(a.订单数量) AS 订单数量,
+                rtrim(a.计量单位) AS 计量单位,
+                rtrim(a.销售订单号) AS 销售订单号,
+                rtrim(a.Gd_客户代号) AS 客户编号,
+                rtrim(a.Gd_客户名称) AS 客户名称,
+                rtrim(a.客户料号) AS 客户料号,
+                rtrim(a.Uniqid) AS GDUID
+            FROM
+                `工单_基本资料` AS a
+            INNER JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+            JOIN `产品_基本资料` AS c ON a.Gd_cpdh = c.产品编号
+            WHERE
+                a.gd_statu = '2-生产中'
+                AND a.行号 = '1'
+                AND b.PD_WG = '1900-01-01 00:00:00'
+                AND b.Gy0_sj1 != '1900-01-01 00:00:00'
+                AND c.状态 = ''
+                AND (".
+                    $where
+                    .")
+                GROUP BY
+                    a.Gd_gdbh";
+        }
+        $list = Db::query($sql);
+        if (empty($list)){
+            $this->error('未找到工单信息');
+        }
         $this->success('成功',$list);
     }
 
@@ -280,7 +343,7 @@ class Manufacture extends Api
      */
     public function StatusEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $workOrder = input('workOrder');
@@ -341,10 +404,10 @@ class Manufacture extends Api
 
     public function ProductionSchedulingAdd()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -363,6 +426,9 @@ class Manufacture extends Api
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
+        if (empty($row)){
+            $this->error('未找到该工单工艺资料');
+        }
         $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
         $sql = Db::table('工单_工艺资料')
             ->where($where)
@@ -390,10 +456,10 @@ class Manufacture extends Api
 
     public function ProductionSchedulingPause()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $data = $this->request->param();
+        $data = Request::instance()->post();
         if (empty($data)){
             $this->error('参数错误');
         }
@@ -405,6 +471,9 @@ class Manufacture extends Api
         ];
         $machine = $where['Gy0_sbbh'];
         $endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
+        if (empty($endTime)){
+            $this->error('未找到该工序');
+        }
         if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
             $this->error('该工单不是制程中工单');
         }
@@ -416,6 +485,9 @@ class Manufacture extends Api
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
+        if (empty($row)){
+            $this->error('未找到该工序');
+        }
         $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
         $res = Db::query($sql);
         $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh = '{$machine}' AND Gy0_sj1 >= '{$endTime}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
@@ -450,7 +522,7 @@ class Manufacture extends Api
             'Gy0_sbbh' => ['<>','']
         ];
         $workOrder = $where['Gy0_gdbh'];
-        $field = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_sbbh) as 设备代号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_ls) as ls,rtrim(PD_WG) as 完工时间';
+        $field = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_sbbh) as 设备代号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_ls) as ls,rtrim(PD_WG) as 完工时间,rtrim(UniqId) as UniqId';
         $list = Db::table('工单_工艺资料')->where($where)->field($field)->order('Gy0_gxh')->select();
         if (empty($list)){
             $this->error('未找到该工单工艺资料');
@@ -467,7 +539,7 @@ class Manufacture extends Api
             $list[$key]['印件及工序'] = $value['yjno'].'-'.$value['gxh'].'-->'.$value['gxmc'];
             foreach ($yield as $k=>$v){
                 if ($v['gxh'] === $list[$key]['gxh']){
-                    $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/'.$v['cl'];
+                    $list[$key]['计划产量/已完成'] = (int)($value['计划接货数']/$value['ls']).'/'.$v['cl'];
                     $list[$key]['完成率'] = number_format($v['cl']/($value['计划接货数']/$value['ls']),4)*100 . '%';
                 }else{
                     $list[$key]['计划产量/已完成'] = ($value['计划接货数']/$value['ls']).'/0';
@@ -482,6 +554,48 @@ class Manufacture extends Api
         $this->success('成功',$list);
     }
 
+
+    /**
+     * 工序状态更正->工序状态编辑
+     * @ApiMethod (POST)
+     * @param  void
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function ProcessStatusCorrectionEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $i = 0;
+        foreach ($param as $key=>$value){
+            if ($value['PD_WG'] === null || $value['PD_WG'] === ''){
+                $endTime = '1900-01-01 00:00:00';
+            }else{
+                $endTime = $value['PD_WG'];
+            }
+            $sql = Db::table('工单_工艺资料')
+                ->where('UniqId',$value['UniqId'])
+                ->fetchSql(true)
+                ->update(['PD_WG'=>$endTime]);
+            $res = Db::query($sql);
+            if ($res !== false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+
+    }
+
     /**
      * 班次选择
      * @ApiMethod (GET)
@@ -507,7 +621,7 @@ class Manufacture extends Api
     }
 
     /**
-     * 车间设备程展示
+     * 车间设备程展示
      * @ApiMethod (GET)
      * @param  void $param
      * @return void
@@ -537,7 +651,7 @@ class Manufacture extends Api
         $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(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_ls) as ls,rtrim(UniqId) as UniqId';
         $list = Db::table('工单_工艺资料')->where($where)->field($filed)->cache(true)->select();
         if (empty($list)){
             $this->error('未找到该机台制程中产品');
@@ -577,33 +691,131 @@ class Manufacture extends Api
      */
     public function EquipmentSchedulingEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
 
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param)){
             $this->error('参数错误');
         }
-        $data = [
-            'Gy0_小时产能' => $param['capacity'],
-            'Gy0_生产工时' => $param['ProductionHours'],
-            'Gy0_辅助工时' => $param['AuxiliaryHours'],
-            'Gy0_班次安排' => $param['shift'],
-            '工序备注' => $param['remark'],
-            'Gy0_最早开工时间' => $param['start']=''?'1900-01-01 00:00:00':$param['start'],
-            'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($param['projectTime'])),
-            'Gy0_sj2' => date('Y-m-d HY-m-d',strtotime($param['projectTime'])+(ceil($param['ProductionHours'])+ceil($param['AuxiliaryHours']))*3600),
-        ];
-        $sql = Db::table('工单_工艺资料')
-            ->where(['Gy0_gdbh'=>$param['workOrder'],'Gy0_sbbh'=>$param['machine']])
-            ->fetchSql(true)
-            ->update($data);
-        $res = Db::query($sql);
-        if ($res !== false){
+        $i = 0;
+        foreach ($param as $key=>$value){
+            $data = [
+                'Gy0_小时产能' => $value['capacity'],
+                'Gy0_生产工时' => $value['ProductionHours'],
+                'Gy0_辅助工时' => $value['AuxiliaryHours'],
+                'Gy0_班次安排' => $value['shift'],
+                '工序备注' => $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)),
+            ];
+            $sql = Db::table('工单_工艺资料')
+                ->where('UniqId',$value['UniqId'])
+                ->fetchSql(true)
+                ->update($data);
+            $res = Db::query($sql);
+            if ($res !== false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
             $this->success('成功');
         }else{
             $this->error('失败');
         }
     }
+
+    //机台显示工单
+
+    public function MachineWorkOrderList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求失败');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        if ($param['status'] === '制程'){
+            $where = "a.gd_statu = '2-生产中' 
+                        AND a.`行号` = '1' 
+                        AND b.Gy0_sbbh LIKE '%{$param['machine']}%' 
+                        AND b.PD_WG = '1900-01-01 00:00:00' 
+                        AND b.Gy0_sj1 != '1900-01-01 00:00:00' ";
+        }else{
+            $where = "a.gd_statu = '2-生产中' 
+                        AND a.`行号` = '1' 
+                        AND b.Gy0_sbbh LIKE '%{$param['machine']}%' 
+                        AND b.PD_WG = '1900-01-01 00:00:00' 
+                        AND b.Gy0_sj1 = '1900-01-01 00:00:00' ";
+        }
+        $sql = "SELECT
+                RTRIM( a.Gd_gdbh ) AS 工单编号,
+                RTRIM( a.`销售订单号` ) AS 销售订单号,
+                RTRIM( c.yj_yjmc ) AS 印件名称,
+                RTRIM( b.Gy0_yjno ) AS yjno,
+                RTRIM( b.Gy0_gxh ) AS gxh,
+                RTRIM( b.Gy0_gxmc ) AS gxmc,
+                RTRIM( b.Add_gxmc ) AS Add_gxmc,
+                RTRIM( b.`Gy0_计划接货数` ) AS 计划接货数,
+                RTRIM( b.`Gy0_小时产能` ) AS 小时产能,
+                RTRIM( b.`工价系数` ) AS 产能系数,
+                RTRIM( b.`Gy0_生产工时` ) AS 生产工时,
+                RTRIM( b.Gy0_ls ) AS ls,
+                RTRIM( b.`Gy0_辅助工时` ) AS 辅助工时,
+                RTRIM( b.`Gy0_最早开工时间` ) AS 最早开工时间,
+                RTRIM( b.Gy0_sj1 ) AS 计划开工时间,
+                RTRIM( b.Gy0_sj2 ) AS 计划完工时间,
+                RTRIM( b.`Gy0_班次安排` ) AS 班次安排,
+                RTRIM( b.`工序备注` ) AS 排单备注,
+                RTRIM( a.Gd_cpmc ) AS 产品名称,
+                RTRIM( a.`成品名称` ) AS 成品名称,
+                RTRIM( a.`订单数量` ) AS 订单数量,
+                RTRIM( a.`计量单位` ) AS 计量单位,
+                RTRIM( a.`交货日期` ) AS 交货日期,
+                RTRIM( a.Gd_cpdh ) AS 产品代号,
+                RTRIM( a.`成品代号` ) AS 成品代号,
+                RTRIM( b.Gy0_sbbh ) AS 设备编号,
+                RTRIM( b.Gy0_SITE ) AS 车间名称,
+                RTRIM( b.UniqId ) AS GYUID,
+                SUM( d.sczl_cl ) AS 已完成产量 
+            FROM
+                `工单_基本资料` AS a
+                JOIN `工单_工艺资料` AS b ON a.Gd_gdbh = b.Gy0_gdbh
+                JOIN `工单_印件资料` AS c ON c.Yj_Gdbh = a.Gd_gdbh
+                LEFT JOIN `设备_产量计酬` AS d ON a.Gd_gdbh = d.sczl_gdbh 
+                AND b.Gy0_sbbh = d.sczl_jtbh 
+            WHERE
+                ".$where."
+            GROUP BY
+                A.Gd_gdbh";
+        $list = \db()->query($sql);
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['yjno'] <10){
+                $value['yjno'] = '0'.rtrim($value['yjno']);
+            }
+            if ((int)$value['gxh'] <10){
+                $value['gxh'] = '0'.rtrim($value['gxh']);
+            }
+            if (rtrim($value['Add_gxmc']) == ''){
+                $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']);
+            }else{
+                $list[$key]['印件工序及名称'] = $value['yjno'].'-'.$value['gxh'].'-->'.rtrim($value['gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
+            }
+            unset($list[$key]['gxmc'],$list[$key]['Add_gxmc']);
+            if ($value['产品名称'] == ''){
+                $list[$key]['产品名称'] = $value['成品名称'];
+            }
+            if ($value['产品代号'] == ''){
+                $list[$key]['产品代号'] = $value['成品代号'];
+            }
+            unset($list[$key]['成品代号'],$list[$key]['成品名称']);
+        }
+        $this->success('成功',$list);
+    }
 }

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

@@ -0,0 +1,657 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use \think\Request;
+use \think\Db;
+/**
+ * 工单超节损核算接口
+ */
+class OrderSuperLoss extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 首页
+     *
+     */
+    public function index()
+    {
+        $this->success('请求成功');
+    }
+    /**
+     * 获取左侧菜单栏
+     * @ApiMethod GET
+    */
+    public function getTab()
+    {
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $sql = "SELECT DISTINCT(Gd_gdbh),`年月`,rtrim(`客户编号`) as 客户编号,rtrim(`客户名称`) as 客户名称 FROM `rec_月度废品汇总` 
+                WHERE STR_TO_DATE(`年月`, '%Y%m') >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH) order by 年月 desc,客户编号 asc";
+        $data = Db::query($sql);
+
+        $outputArray = [];
+
+        foreach ($data as $item) {
+            $yearMonth = $item['年月'];
+
+            if (!isset($outputArray[$yearMonth])) {
+                // If key doesn't exist in output array, initialize it
+                $outputArray[$yearMonth] = [];
+            }
+
+            // Check if the customer already exists in the current yearMonth array
+            $existingCustomerIndex = null;
+            foreach ($outputArray[$yearMonth] as $index => $customer) {
+                if ($customer['客户编号'] === $item['客户编号']) {
+                    $existingCustomerIndex = $index;
+                    break;
+                }
+            }
+
+            if ($existingCustomerIndex !== null) {
+                // If customer exists, increment the total
+                $outputArray[$yearMonth][$existingCustomerIndex]['total']++;
+            } else {
+                // If customer doesn't exist, add a new entry
+                $outputArray[$yearMonth][] = [
+                    '客户名称' => $item['客户名称'],
+                    '客户编号' => $item['客户编号'],
+                    'total' => 1,
+                ];
+            }
+        }
+        // 遍历每个年月的数组
+        $list = [];
+        foreach ($outputArray as $yearMonth => $orders) {
+            $totalOrders = 0;
+
+            // 遍历每个订单,累加订单数量
+            foreach ($orders as $order) {
+                $totalOrders += $order['total'];
+            }
+            // 输出每个年月的订单数量
+            $list[$yearMonth.'-'.$totalOrders] = $orders;
+        }
+        $this->success('请求成功',$list);
+    }
+    /**
+     * 获取超节损工单列表
+     * @ApiMethod GET
+     * @params string date
+     * @params string code
+     * 报废定额=(基础损耗+损耗率*计划产量)*损耗系数*计损色数(特定工序会有,如果无就不乘)
+     * 允损比例=报废定额/计划产量
+     * 目标合格率 = 100%-超节损工单中显示工序的允损比例之和
+     *
+    */
+    public function getList(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+
+        $where = [];
+        if (!empty($params['code'])) {
+            if (!empty($params['search'])) {
+                $this->error('参数错误');
+            }
+            $where['a.客户编号' ] = $params['code'];
+        }
+        if (!empty($params['date'])) {
+            if (!empty($params['search'])) {
+                $this->error('参数错误');
+            }
+            $where['a.年月' ] = $params['date'];
+        }
+        if (!empty($params['search'])) {
+            if (!empty($params['date']) || !empty($params['code'])) {
+               $this->error('参数错误');
+            }
+            $where['a.产品名称'] = array('like','%'.$params['search'].'%');
+        }
+        $where['b.行号' ] = 1;
+        $limit = $params['limit'];
+        if (empty($limit)){
+            $limit = 15;
+        }
+        $pages = $params['page'];
+        if (empty($pages)){
+            $pages = 1;
+        }
+        $data = Db::table('rec_月度废品汇总')->alias('a')
+            ->join('工单_基本资料 b', 'a.Gd_gdbh = b.Gd_gdbh','left')
+            ->join('工单_印件资料 c', 'a.Gd_gdbh = c.Yj_Gdbh','left')
+            ->where($where)
+            ->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')
+            ->order('a.Gd_cpdh asc,a.年月 desc')
+            ->fetchSql(true)
+            ->page($pages)
+            ->limit($limit)
+            ->select();
+        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";
+            $cp_data = Db::query($cp_sql);
+            $data[$key]['warehousing_num'] = $cp_data[0]['cp_sl'];
+            $data[$key]['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
+            //查出进入超节损的工序,有上报产量的工序就进入超节损
+            $gxh_sql = "SELECT sczl_gxh FROM 
+                        (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$value['Gd_gdbh']}' 
+                        UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$value['Gd_gdbh']}') AS combined_result";
+            $gxh_arr = Db::query($gxh_sql);
+            $gxh_values = array_column($gxh_arr, 'sczl_gxh');
+            $gy_data = Db::name('工单_工艺资料')->where('Gy0_gdbh',$value['Gd_gdbh'])->where('Gy0_gxh','in',$gxh_values)->field('Gy0_计划接货数,Gy0_计划损耗')->select();
+            $arr = [];
+            $plan_loss = [];//工单计划损耗
+            foreach ($gy_data as $k=>$v){
+                $rate =  round($v['Gy0_计划损耗'] / $v['Gy0_计划接货数'],5);
+                $arr[$k] = floor($rate * 10000) /10000;
+                $plan_loss[$k] = $v['Gy0_计划损耗'];
+            }
+            $target_rate =  (1-array_sum($arr))*100;
+            $data[$key]['target_rate'] =$target_rate.'%'; //目标合格率
+            $real_rate = $cp_data[0]['cp_sl'] / ($value['实际投料'] * 10000) *100;
+            $data[$key]['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
+            //奖惩系数及金额
+            $data[$key]['reward_rate'] = '';
+            $data[$key]['reward_money'] = '';
+            //制程废品
+            $zzfp_data = Db::name('设备_产量计酬')->where('sczl_gdbh',$value['Gd_gdbh'])->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
+            $data[$key]['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $value['yj_ls'];//制程废品
+            $data[$key]['废品合计'] = $data[$key]['zcfp'] + $value['废品合计'];//废品合计
+            $data[$key]['intangible_loss'] = $value['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $data[$key]['废品合计'];//工单无形损
+            //材料废
+            $waste_l = Db::name('rec_月度废品汇总')->where('Gd_gdbh',$value['Gd_gdbh'])->where('废品类别','like','%L%')->field('SUM(废品数量) as 废品数量')->select();
+            $data[$key]['material_waste'] = $waste_l[0]['废品数量'];
+            //零头处理
+            $waste_w =  Db::name('rec_月度废品汇总')->where('Gd_gdbh',$value['Gd_gdbh'])->where('废品类别','like','%M%')->field('SUM(废品数量) as 废品数量')->select();
+            $data[$key]['minor_processing'] = $waste_w[0]['废品数量'];
+            //外发废
+            $out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
+                        fp_lb1,fp_lb2,fp_lb3,fp_lb4,fp_lb5,fp_lb6,fp_lb7,fp_lb8,fp_lb9,fp_lb10,fp_lb11,fp_lb12,fp_lb13, 
+                        fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
+                        fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13 
+                        FROM db_qczl WHERE qczl_gdbh = '{$value['Gd_gdbh']}'";
+            $waste_out = Db::query($out_sql);
+            $list = [];
+            $quality = [];
+            $j = 0;
+            $m = 0;
+            foreach ($waste_out as $entry) {
+                for ($i = 1; $i <= 13; $i++) {
+                    $labelKey = "fp_lb" . $i;
+                    $bhKey = "fp_bh" . $i;
+                    $gxmcKey = "fp_gxmc" . $i;
+                    $slKey = "fp_sl" . $i;
+                    if (!empty($entry[$labelKey])) {
+                        if (substr($entry[$gxmcKey],0,2) == '99'){
+                            $list[$j]= $entry[$slKey];
+                            $j++;
+                        }
+                    }
+                    if (!empty($entry[$bhKey])) {
+                        if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
+                            $quality[$m]= $entry[$slKey];
+                            $m++;
+                        }
+                    }
+                }
+            }
+            $data[$key]['waste_out'] = array_sum($list);//外发废
+            $data[$key]['waste_share'] = '';//分摊废
+            $data[$key]['plan_loss'] = array_sum($plan_loss);//工单计划损耗
+            $data[$key]['waste_quality'] =  array_sum($quality);  //质检废
+        }
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 获取工单超节损工艺
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderSuperLossGy(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])) {
+            $this->error('参数错误');
+        }
+        $sql = "SELECT a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh,rtrim(a.Gy0_gxmc) as Gy0_gxmc,rtrim(a.Add_gxmc) as Add_gxmc,a.Gy0_ls,a.Gy0_Rate0,a.Gy0_Rate1,a.损耗系数,a.Gy0_ms,
+                a.Gy0_计划接货数,a.Gy0_计划损耗,sum(b.sczl_cl) as total_cl,sum(b.sczl_zcfp) as total_fp,sum(c.sczl_cl) as cl,SUM(c.sczl_fp) as fp FROM `工单_工艺资料` a
+                LEFT JOIN `设备_产量计酬` b ON a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh
+                LEFT JOIN `db_sczl` c ON a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh
+                WHERE a.Gy0_gdbh = '{$params['order']}' GROUP BY a.Gy0_gxh";
+        $data = Db::query($sql);
+        foreach ($data as $key=>$value){
+            if (!empty($value['total_cl'])){
+                $data[$key]['total_cl'] = $value['total_cl'] *$value['Gy0_ls'];
+            }else{
+                $data[$key]['total_cl'] =$value['cl'] *$value['Gy0_ls'];
+            }
+            if (!empty($value['total_fp'])){
+                $data[$key]['total_fp'] = $value['total_fp'] *$value['Gy0_ls'];
+            }else{
+                $data[$key]['total_fp'] = $value['fp'] *$value['Gy0_ls'];
+            }
+            unset($data[$key]['cl']);
+            unset($data[$key]['fp']);
+        }
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 工单超节损统计
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderSuperLossCount(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])) {
+            $this->error('参数错误');
+        }
+        $order = $params['order'];
+        $field = 'Gd_gdbh,rtrim(成品代号) as 成品代号,rtrim(成品名称) as 成品名称,rtrim(销售订单号) as 销售订单号,订单数量,实际投料';
+        $data = Db::name('工单_基本资料')->where('Gd_Gdbh',$order)->where('行号',1)->field($field)->find();
+        //查出成品数量及日期
+        $cp_sql = "SELECT SUM(jjcp_sl) as cp_sl,MAX(jjcp_sj) as jjcp_sj FROM `成品入仓` WHERE jjcp_gdbh = '{$order}' GROUP BY jjcp_gdbh";
+        $cp_data = Db::query($cp_sql);
+        $data['warehousing_num'] = $cp_data[0]['cp_sl'];
+        $data['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
+        //查出进入超节损的工序,有上报产量的工序就进入超节损
+        $gxh_sql = "SELECT sczl_gxh FROM 
+                        (SELECT sczl_gxh FROM 设备_产量计酬 WHERE sczl_gdbh = '{$order}' 
+                        UNION SELECT sczl_gxh FROM db_sczl WHERE sczl_gdbh = '{$order}') AS combined_result";
+        $gxh_arr = Db::query($gxh_sql);
+        $gxh_values = array_column($gxh_arr, 'sczl_gxh');
+        $gy_data = Db::name('工单_工艺资料')
+            ->alias('a')
+            ->field([
+                'a.Gy0_yjno', 'a.Gy0_gxh', 'RTRIM(a.Gy0_gxmc) as Gy0_gxmc','RTRIM(a.Add_gxmc) as Add_gxmc', 'a.Gy0_ls', 'a.Gy0_计划接货数',
+                'a.Gy0_计划损耗', 'a.超节损承担比例','SUM(b.sczl_zcfp) as total_fp','SUM(b.sczl_cl) as total_cl','SUM(c.sczl_cl) as cl','SUM(c.sczl_fp) as fp',
+            ])
+            ->join('设备_产量计酬 b', 'a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh','left')
+            ->join('db_sczl c', 'a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh','left')
+            ->where([
+                'a.Gy0_gdbh' => $order,
+                'a.Gy0_gxh' => ['in', $gxh_values]
+            ])
+            ->group('a.Gy0_gxh')
+            ->select();
+        $arr = [];
+        $plan_loss = [];//工单计划损耗
+        foreach ($gy_data as $k=>$v){
+            $rate =  round($v['Gy0_计划损耗'] / $v['Gy0_计划接货数'],5);
+            $arr[$k] = floor($rate * 10000) /10000;
+            $plan_loss[$k] = $v['Gy0_计划损耗'];
+        }
+        $target_rate =  (1-array_sum($arr))*100;
+        $data['target_rate'] =$target_rate.'%'; //目标合格率
+        $real_rate = $cp_data[0]['cp_sl'] / ($data['实际投料'] * 10000) *100;
+        $data['real_rate'] = number_format($real_rate,2) . '%';//实际合格率
+        //制程废品
+        $zzfp_data = Db::name('设备_产量计酬')->where('sczl_gdbh',$order)->field('SUM(sczl_zcfp) as sczl_zcfp')->select();
+        //联数
+        $ls = Db::name('工单_印件资料')->where('Yj_Gdbh',$order)->value('yj_ls');
+        //制程废品*ls
+        $data['zcfp'] = $zzfp_data[0]['sczl_zcfp'] * $ls;
+        //废品数量
+        $waste = Db::name('rec_月度废品汇总')->where('Gd_gdbh',$order)->field('SUM(废品数量) as 废品合计')->select();
+        //废品合计
+        $waste_total = $data['zcfp'] + $waste[0]['废品合计'];
+        //工单无形损
+        $data['intangible_loss'] = $data['实际投料'] *10000 - $cp_data[0]['cp_sl'] - $waste_total;
+        //材料废
+        $waste_l = Db::name('rec_月度废品汇总')->where('Gd_gdbh',$order)->where('废品类别','like','%L%')->field('SUM(废品数量) as 废品数量')->select();
+        $data['material_waste'] = $waste_l[0]['废品数量'];
+        //零头处理
+        $waste_w =  Db::name('rec_月度废品汇总')->where('Gd_gdbh',$order)->where('废品类别','like','%M%')->field('SUM(废品数量) as 废品数量')->select();
+        $data['minor_processing'] = $waste_w[0]['废品数量'];
+        //外发废
+        $out_sql = "SELECT fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13,
+                        fp_lb1,fp_lb2,fp_lb3,fp_lb4,fp_lb5,fp_lb6,fp_lb7,fp_lb8,fp_lb9,fp_lb10,fp_lb11,fp_lb12,fp_lb13, 
+                        fp_bh1,fp_bh2,fp_bh3,fp_bh4,fp_bh5,fp_bh6,fp_bh7,fp_bh8,fp_bh9,fp_bh10,fp_bh11,fp_bh12,fp_bh13,
+                        fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13 
+                        FROM db_qczl WHERE qczl_gdbh = '{$order}'";
+        $waste_out = Db::query($out_sql);
+        $list = [];
+        $quality = [];
+        $j = 0;
+        $m = 0;
+        foreach ($waste_out as $entry) {
+            for ($i = 1; $i <= 13; $i++) {
+                $labelKey = "fp_lb" . $i;
+                $bhKey = "fp_bh" . $i;
+                $gxmcKey = "fp_gxmc" . $i;
+                $slKey = "fp_sl" . $i;
+                if (!empty($entry[$labelKey])) {
+                    if (substr($entry[$gxmcKey],0,2) == '99'){
+                        $list[$j]= $entry[$slKey];
+                        $j++;
+                    }
+                }
+                if (!empty($entry[$bhKey])) {
+                    if ($entry[$bhKey] != '000000' && $entry[$slKey] > 0){
+                        $quality[$m]= $entry[$slKey];
+                        $m++;
+                    }
+                }
+
+            }
+        }
+        $data['waste_out'] = array_sum($list);//外发废
+        //质检废
+        $data['waste_quality'] =  array_sum($quality);
+        $plan_total = Db::name('工单_工艺资料')->where(['Gy0_gdbh' => $order, 'Gy0_gxh' => ['in', $gxh_values]])->value('SUM(Gy0_计划损耗)');
+//        halt($plan_total);
+        //按工序打印
+        if ($params['type'] == 1){
+            $total = [];
+            $total['plan_loss'] = 0;
+            $total['total_fp'] = 0;
+            $total['waste_quality'] = 0;
+            $total['waste_intangible'] = 0;
+            $total['total_waste'] = 0;
+            $total['loss'] = 0;
+            foreach ($gy_data as $k=>$item){
+                $gy_data[$k]['waste_quality'] = 0;
+                $gy_data[$k]['total_fp'] = $item['total_fp'] * $item['Gy0_ls'];
+                $gy_data[$k]['total_cl'] = $item['total_cl'] * $item['Gy0_ls'];
+                $gy_data[$k]['intangible_loss'] = round($item['Gy0_计划损耗'] / $plan_total * $data['intangible_loss']);
+                foreach ($waste_out as $entry) {
+                    for ($i = 1; $i <= 13; $i++) {
+                        $gxmcKey = "fp_gxmc" . $i;
+                        $slKey = "fp_sl" . $i;
+                        if ((int)substr($entry[$gxmcKey],0,2) == $item['Gy0_gxh']){
+                            $gy_data[$k]['waste_quality'] += $entry[$slKey];
+
+                        }
+                    }
+                }
+                $gy_data[$k]['total_waste'] = $gy_data[$k]['waste_quality'] + $gy_data[$k]['intangible_loss'] +  $gy_data[$k]['total_fp'];
+                $gy_data[$k]['loss'] = $item['Gy0_计划损耗'] - $gy_data[$k]['total_waste'];
+                $gy_data[$k]['loss_rate'] = number_format($gy_data[$k]['loss'] / $item['Gy0_计划接货数'],4) * 100 .'%';
+                $gy_data[$k]['target_loss_rate'] = number_format($item['Gy0_计划损耗'] / $item['Gy0_计划接货数'],4) * 100 .'%';
+                $gy_data[$k]['actual_loss_rate'] = number_format($gy_data[$k]['total_waste'] / $item['Gy0_计划接货数'],4) * 100 .'%';
+                $gy_data[$k]['超节损承担比例'] = number_format($item['超节损承担比例'],4) * 100 .'%';
+
+                $total['plan_loss'] += $gy_data[$k]['Gy0_计划损耗'];
+                $total['total_fp'] += $gy_data[$k]['total_fp'];
+                $total['waste_quality'] += $gy_data[$k]['waste_quality'];
+                $total['waste_intangible'] += $gy_data[$k]['intangible_loss'];
+                $total['total_waste'] += $gy_data[$k]['total_waste'];
+                $total['loss'] += $gy_data[$k]['loss'];
+            }
+            $data['gy_data'] = $gy_data;
+            $data['total'] = $total;
+            $this->success('请求成功',$data);
+        }else{ //按班组打印
+
+        }
+    }
+    /**
+     * 获取工单工艺
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderGy(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])) {
+            $this->error('参数错误');
+        }
+        $order = $params['order'];
+        $field = 'Gy0_yjno,Gy0_gxh,rtrim(Gy0_gxmc) as Gy0_gxmc,rtrim(Add_gxmc) as Add_gxmc,Gy0_rate0,Gy0_rate1,损耗系数,无形损承担比例 as loss_one,超节损承担比例 as loss_two,超节损核算单价 as loss_thr,UniqId';
+        $data = Db::name('工单_工艺资料')->where('Gy0_gdbh',$order)->field($field)->select();
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 更新工单工艺
+     * @ApiMethod POST
+     * @params array data
+    */
+    public function updateOrderGy(){
+        if (Request::instance()->isPost() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->request();
+        if (!isset($params) || !isset($params[0]['UniqId'])){
+            $this->error('参数不能为空');
+        }
+        $i = 0;
+        foreach ($params as $key=>$value){
+            $data = [];
+            $data['无形损承担比例'] = $value['loss_one'];
+            $data['超节损承担比例'] = $value['loss_two'];
+            $data['超节损核算单价'] = $value['loss_thr'];
+            $sql = Db::name('工单_工艺资料')->where('UniqId',$value['UniqId'])->fetchSql(true)->update($data);
+            $res = Db::query($sql);
+            if ($res !== false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 获取工单印件考核资料
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderYj(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->request();
+        if (!isset($params['order']) || empty($params['order'])) {
+            $this->error('参数错误');
+        }
+        $data = Db::name('工单_印件资料')->where('Yj_gdbh',$params['order'])->field('Yj_gdbh,rtrim(yj_Yjdh) as yj_Yjdh,yj_Yjno,rtrim(yj_yjmc) as yj_yjmc,质量考核')->find();
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 更新工单印件考核资料
+     * @ApiMethod POST
+     * @params array data
+    */
+    public function updateOrderYj(){
+        if (Request::instance()->isPost() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->request();
+        if (!isset($params['order'])){
+            $this->error('参数不能为空');
+        }
+        if (!isset($params['yj_yjno'])){
+            $this->error('参数不能为空');
+        }
+        if (!isset($params['examine'])){
+            $this->error('参数不能为空');
+        }
+        $where['Yj_gdbh'] = $params['order'];
+        $where['yj_Yjno'] = $params['yj_yjno'];
+        $res = Db::name('工单_印件资料')->where($where)->setField('质量考核',$params['examine']);
+        if ($res !== false){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 获取修正工单实际投料列表
+     * @ApiMethod GET
+     * @params string year
+     * @params string month
+    */
+    public function getOrderFeedList(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->request();
+        if (empty($params['year']) || empty($params['month'])) {
+            $this->error('参数错误');
+        }
+        $search = $params['year'].'.'.$params['month'];
+        $field = "a.Gd_gdbh,rtrim(c.yj_yjdh) as yj_yjdh,c.yj_Yjno, c.yj_ks,c.yj_ls,rtrim(c.yj_zzdh) as yj_zzdh,
+                  rtrim(b.BOM_物料名称) as BOM_物料名称,rtrim(c.yj_tlgg) as yj_tlgg,rtrim(b.BOM_投料单位) as BOM_投料单位,a.订单数量,c.yj_平张投料, b.BOM_实际用量,a.实际投料,a.投料确认,a.UniqId";
+        $data = Db::name('工单_基本资料')->alias('a')
+            ->join('工单_印件资料 c','a.Gd_gdbh = c.Yj_Gdbh','left')
+            ->join('工单_bom资料 b','c.Yj_Gdbh = b.BOM_工单编号 AND c.yj_zzdh = b.BOM_物料编码','left')
+            ->where('a.投料确认','like','%'.$search.'%')
+            ->field($field)
+            ->group('a.Gd_gdbh')
+            ->order('b.BOM_投料单位,a.UniqId asc')
+            ->select();
+        if (empty($data)){
+            $this->success('请求成功');
+        }
+        foreach ($data as $key=>$value){
+            $len = stripos($value['yj_tlgg'],'/');
+            if ($len){
+                $name = substr($value['yj_tlgg'],0,$len);
+                $len_two = stripos($value['yj_tlgg'],'(');
+                if ($len_two){
+                    $name = substr($name,0,$len_two);
+                }
+                $data[$key]['yj_tlgg'] = $name;
+            }
+            $data[$key]['rate'] = '';
+        }
+        $this->success('请求成功',$data);
+    }
+    /**
+     * 更新工单实际投料
+     * @ApiMethod POST
+     * @params int UniqId
+     * @params string number
+    */
+    public function updateOrderFeed(){
+        if (Request::instance()->isPost() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params[0]['UniqId']) || empty($params[0]['UniqId'])){
+            $this->error('参数错误');
+        }
+        $i = 0;
+        foreach ($params as $key=>$value){
+            if (!empty($value['number'])){
+                $info = Db::name('工单_基本资料')->where('UniqId',$value['UniqId'])->value('Gd_gdbh');
+                $res = Db::name('工单_基本资料')->where('UniqId',$value['UniqId'])->setField('实际投料',$value['number']);
+                $yjRes = Db::name('工单_印件资料')->where('Yj_Gdbh',$info)->setField('yj_实际投料',$value['number']);
+                if (!$res && !$yjRes){
+                    $i++;
+                }
+            }
+        }
+        if ($i != 0){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 工单工序产量统计
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function getOrderProcessCount(){
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->request();
+        if (empty($params['order']) || empty($params['order'])) {
+            $this->error('参数错误');
+        }
+        $order = $params['order'];
+        $sql = "SELECT a.Gy0_yjno,a.Gy0_gxh,rtrim(a.Gy0_gxmc) as Gy0_gxmc,rtrim(a.Add_gxmc) as Add_gxmc,a.Gy0_计划接货数, a.Gy0_ls,a.Gy0_sbbh,a.PD_WG,SUM(b.sczl_cl) as sczl_cl,
+                SUM(b.sczl_zcfp) as sczl_zcfp,SUM(b.sczl_来料少数) as 来料异常,COUNT(DISTINCT b.sczl_num) as process_num,b.sczl_Pgcl,SUM(c.sczl_cl) as cl,b.sczl_rq
+                FROM `工单_工艺资料` a
+                LEFT JOIN `设备_产量计酬` b ON a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh
+                LEFT JOIN db_sczl c ON a.Gy0_gdbh = c.sczl_gdbh AND a.Gy0_gxh = c.sczl_gxh
+                WHERE a.Gy0_gdbh = '{$order}' GROUP BY a.Gy0_gxh";
+        $data = Db::query($sql);
+//        halt($data);
+        //手检数据
+        $handData = Db::name('db_手工检验')->where('sczl_gdbh',$order)->field('sum(sczl_cl) as cl,rtrim(sczl_yjgx) as sczl_gxh')->select();
+//        halt($handData);
+        //包装及成品防护数据
+        $sql = "SELECT sczl_gdbh1,sczl_gdbh2,sczl_gdbh3,sczl_gdbh4,sczl_gdbh5,sczl_gdbh6,rtrim(sczl_gxmc1) as sczl_gxmc1,rtrim(sczl_gxmc2) as sczl_gxmc2,
+                rtrim(sczl_gxmc3) as sczl_gxmc3,rtrim(sczl_gxmc4) as sczl_gxmc4,rtrim(sczl_gxmc5) as sczl_gxmc5,rtrim(sczl_gxmc6) as sczl_gxmc6,
+                sczl_cl1,sczl_cl2,sczl_cl3,sczl_cl4,sczl_cl5,sczl_cl6,sczl_PgCl1,sczl_PgCl2,sczl_PgCl3,sczl_PgCl4,sczl_PgCl5,sczl_PgCl6
+                FROM `mesdb`.`db_包装计件` WHERE `sczl_gdbh1` LIKE '%{$order}%' OR `sczl_gdbh2` LIKE '%{$order}%' 
+                OR `sczl_gdbh3` LIKE '%{$order}%' OR `sczl_gdbh4` LIKE '%{$order}%' OR `sczl_gdbh5` LIKE '%{$order}%' OR `sczl_gdbh6` LIKE '%{$order}%'";
+        $package = Db::query($sql);
+        $list = [];
+        $j = 0;
+        foreach ($package as $value){
+            for ($i = 1; $i <= 6; $i++) {
+                $gdbhlKey = "sczl_gdbh" . $i;
+                $gxmcKey = "sczl_gxmc" . $i;
+                $clKey = "sczl_cl" . $i;
+                $pgclKey = "sczl_PgCl" . $i;
+                if ($value[$gdbhlKey] == '2311743' && $value[$clKey] > 0) {
+                    $list[$j]['sczl_gdbh'] = $value[$gdbhlKey];
+                    $list[$j]['sczl_gxmc'] =  $value[$gxmcKey];
+                    $list[$j]['sczl_cl'] =  $value[$clKey];
+                    $list[$j]['sczl_PgCl'] =  $value[$pgclKey];
+                    $j++;
+                }
+            }
+        }
+        // 创建一个关联数组,用于存储相同 sczl_gxmc 的值和对应的乘积之和
+        $sumArray = [];
+        foreach ($list as $item) {
+            $key = $item['sczl_gxmc'];
+            $cl = floatval($item['sczl_cl']);
+            $pgCl = intval($item['sczl_PgCl']);
+            $product = $cl * $pgCl;
+            if (!isset($sumArray[$key])) {
+                $sumArray[$key] = 0;
+            }
+            $sumArray[$key] += $product;
+        }
+        $handGxh = substr($handData[0]['sczl_gxh'],-2);
+//        halt($sumArray['包装']);
+        foreach ($data as $key=>$item){
+            $data[$key]['折算车头产量'] = round($item['Gy0_计划接货数']/$item['Gy0_ls']);
+            $data[$key]['制程废品率'] = '';
+            if ($item['sczl_zcfp'] > 0){
+                $data[$key]['制程废品率'] = number_format($item['sczl_zcfp']/$item['sczl_cl']*100,4).'%';
+            }
+            if ($item['cl'] > 0){
+                $data[$key]['sczl_cl'] = $item['cl'];
+            }
+            if ($item['sczl_Pgcl'] > 0){
+                $data[$key]['sczl_cl'] = $item['sczl_cl'] * $item['sczl_Pgcl'];
+            }
+            if ($item['Gy0_gxh'] == (int)$handGxh){
+                $data[$key]['sczl_cl'] = $handData[0]['cl'];
+            }
+            foreach ($sumArray as $k=>$v){
+                if ($item['Gy0_gxmc'] == $k){
+                    $data[$key]['sczl_cl'] = $v;
+                }
+            }
+            if (substr($item['PD_WG'],0,4) == '1900'){
+                $data[$key]['PD_WG'] = '计划';
+            }else{
+                $data[$key]['PD_WG'] = '完工';
+            }
+        }
+        $this->success('请求成功',$data);
+    }
+}

+ 8 - 8
application/api/controller/PieceWork.php

@@ -41,7 +41,7 @@ class PieceWork extends Api
                     日定额 as daily_quota,千件工价 as thousand_piece ,补产标准 as production_standard,机长比例 as fir_proportion,副机比例 as sec_proportion,
                     调墨比例 as ink_proportion,二手比例 as second_hand_proportion,飞达比例 as feeder_proportion,辅助比例 as auxiliary_proportion,放卷比例 as unwinder_proportion,
                     分切1比例 as cutting_one_proportion,分切2比例 as cutting_two_proportion,检验比例 as inspect_proportion';
-        $data = Db::name('dic_lzde')->where($where)->field($field)->select();
+        $data = db('dic_lzde')->where($where)->field($field)->select();
         $this->success('请求成功',$data);
 
     }
@@ -56,7 +56,7 @@ class PieceWork extends Api
             $this->error('非法请求');
         }
         $field = 'Key_,Parent,rtrim(sys_bh) as sys_bh, rtrim(sys_mc) as sys_mc,rtrim(适用工序) as gx,rtrim(适用机型) as jx';
-        $list = Db::name('dic_lzde')->field($field)->order('sys_bh')->select();
+        $list = db('dic_lzde')->field($field)->order('sys_bh')->select();
         $data = [];
         $machineData = [];
         $handData = [];
@@ -72,12 +72,12 @@ class PieceWork extends Api
         //对机器作业计件定额的数组进行处理
         $machineData = array_values($machineData);
         foreach ($machineData as $k=>$v){
-            $child = Db::name('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
+            $child = db('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
             if (!empty($child)){
                 $machineData[$k]['child'] = $child;
                 foreach ($child as $i=>$j){
                     if ($v['sys_mc'] == '检验车间'){ //找出检验车间机器下面的数据
-                        $children = Db::name('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
+                        $children = db('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
                         $machineData[$k]['child'][$i]['children'] = $children;
                     } else{
                         $machineData[$k]['child'][$i]['children'] = [];
@@ -89,11 +89,11 @@ class PieceWork extends Api
         //对手工作业计件定额的数组进行处理
         $handData = array_values($handData);
         foreach ($handData as $k=>$v){
-            $child = Db::name('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
+            $child = db('dic_lzde')->where('Parent',$v['Key_'])->field($field)->select();
             if (!empty($child)){
                 $handData[$k]['child'] = $child;
                 foreach ($child as $i=>$j){
-                    $children = Db::name('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
+                    $children = db('dic_lzde')->where('Parent',$j['Key_'])->field($field)->select();
                     if (!empty($children)){
                         $handData[$k]['child'][$i]['children'] = $children;
                     } else{
@@ -125,7 +125,7 @@ class PieceWork extends Api
         $where['sys_bh'] = array('like','%'.$req['code'].'%');
         $field = 'rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc,rtrim(适用工序) as use_gx,rtrim(适用机型) as use_machine,日定额 as daily_quota,千件工价 as thousand_piece,
         补产标准 as production_standard,UniqId';
-        $list = Db::name('dic_lzde')->where($where)->field($field)->select();
+        $list = db('dic_lzde')->where($where)->field($field)->select();
         $this->success('请求成功',$list);
     }
     /**
@@ -154,7 +154,7 @@ class PieceWork extends Api
                 $data['补产标准'] = $value['production_standard'];
             }
 
-            $sql = Db::name('dic_lzde')->where('UniqId',$value['UniqId'])->fetchSql(true)->update($data);
+            $sql = db('dic_lzde')->where('UniqId',$value['UniqId'])->fetchSql(true)->update($data);
             $res = Db::query($sql);
             if ($res !== false){
                 $i++;

+ 14 - 14
application/api/controller/Process.php

@@ -38,7 +38,7 @@ class Process extends Api
         }
         $where['sys_bh'] = $code;
         $field = 'rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc,sys_rate0,sys_rate1,rtrim(适用机型) as remark';
-        $data = Db::name('dic_lzsh')->where($where)->field($field)->select();
+        $data = db('dic_lzsh')->where($where)->field($field)->select();
         $this->success('请求成功',$data);
     }
     /**
@@ -50,26 +50,26 @@ class Process extends Api
             $this->error('非法请求');
         }
         $field = 'Key_,Parent,rtrim(sys_bh) as sys_bh,rtrim(sys_mc) as sys_mc';
-        $list = Db::name('dic_lzsh')->field($field)->select();
+        $list = db('dic_lzsh')->field($field)->select();
         $data = [];
         $i = 0;
         foreach ($list as $value){
             if ($value['Parent'] == '0_'){
                 $data[$i] = $value;
                 //一级菜单
-                $data[$i]['child'] = Db::name('dic_lzsh')->where('Parent',$value['Key_'])->field($field)->select();
+                $data[$i]['child'] = db('dic_lzsh')->where('Parent',$value['Key_'])->field($field)->select();
                 foreach ($data[$i]['child'] as $k=>$v){
-                    $children = Db::name('dic_lzsh')->where('Parent',$v['Key_'])->field($field)->select();
+                    $children = db('dic_lzsh')->where('Parent',$v['Key_'])->field($field)->select();
                     //二级菜单
                     $data[$i]['child'][$k]['children'] =  $children;
                     if (!empty($children)){
                         foreach ($children as $key=>$item){
-                            $childrens = Db::name('dic_lzsh')->where('Parent',$item['Key_'])->field($field)->select();
+                            $childrens = db('dic_lzsh')->where('Parent',$item['Key_'])->field($field)->select();
                             //三级菜单
                             $data[$i]['child'][$k]['children'][$key]['childrens'] =  $childrens;
                             if (!empty($childrens)){
                                 foreach ($childrens as $k1=>$v1){
-                                    $fiveChild = Db::name('dic_lzsh')->where('Parent',$v1['Key_'])->field($field)->select();
+                                    $fiveChild = db('dic_lzsh')->where('Parent',$v1['Key_'])->field($field)->select();
                                     $data[$i]['child'][$k]['children'][$key]['childrens'][$k1]['fiveChild'] =  $fiveChild;
                                 }
                             }else{
@@ -102,7 +102,7 @@ class Process extends Api
         }
         $code = $params['code'];
         if (empty($code)){//科目编码为空,表示需要增加一级科目
-           $res = Db::name('dic_lzsh')->where('Parent','0_')->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
+           $res = db('dic_lzsh')->where('Parent','0_')->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
            $num = (int)$res['sys_bh'] + 1;
            $new_code = $num > 10 ? '0'.$num : '00'.$num;
            $this->success('请求成功',$new_code);
@@ -110,15 +110,15 @@ class Process extends Api
             if (($params['same_item'] == 0 && $params['child_item'] == 0) || ($params['same_item'] == 1 && $params['child_item'] == 1) ){
                 $this->error('参数错误');
             }
-            $res = Db::name('dic_lzsh')->where('sys_bh',$code)->find();
+            $res = db('dic_lzsh')->where('sys_bh',$code)->find();
             if ($params['same_item'] == 1){ //表示增加同级科目
-                $list = Db::name('dic_lzsh')->where('Parent',$res['Parent'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
+                $list = db('dic_lzsh')->where('Parent',$res['Parent'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
                 $num = (int)$list['sys_bh'] + 1;
                 $num = substr($num,-3);
                 $str = substr($code,0,-3);
                 $new_code = $str . $num;
             }else{
-                $list = Db::name('dic_lzsh')->where('Parent',$res['Key_'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
+                $list = db('dic_lzsh')->where('Parent',$res['Key_'])->field('rtrim(sys_bh) as sys_bh')->order('UniqId desc')->find();
                 if (!empty($list)){
                     $num = (int)$list['sys_bh'] + 1;
                     $num = substr($num,-3);
@@ -152,7 +152,7 @@ class Process extends Api
         if (empty($parentCode)){
             $parentCode = $params['code'];
         }
-        $list = Db::name('dic_lzsh')->where('sys_bh',$parentCode)->field('Key_')->find();
+        $list = db('dic_lzsh')->where('sys_bh',$parentCode)->field('Key_')->find();
         $data = [];
         $data['sys_bh'] = $params['code'];
         $data['Parent'] = empty($list)? '0_':$list['Key_'];
@@ -162,7 +162,7 @@ class Process extends Api
         if (!empty($params['remark'])){
             $data['适用机型'] = $params['remark'];
         }
-        $sql = Db::name('dic_lzsh')->fetchSql(true)->insert($data);
+        $sql = db('dic_lzsh')->fetchSql(true)->insert($data);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('新增成功');
@@ -194,7 +194,7 @@ class Process extends Api
         if (!empty($params['remark'])){
             $data['适用机型'] = $params['remark'];
         }
-        $sql = Db::name('dic_lzsh')->where('sys_bh',$params['code'])->fetchSql(true)->update($data);
+        $sql = db('dic_lzsh')->where('sys_bh',$params['code'])->fetchSql(true)->update($data);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');
@@ -215,7 +215,7 @@ class Process extends Api
         if (empty($params) || !isset($params['code'])){
             $this->error('参数不能为空');
         }
-        $res = Db::name('dic_lzsh')->where('sys_bh',$params['code'])->delete();
+        $res = db('dic_lzsh')->where('sys_bh',$params['code'])->delete();
         if ($res !== false){
             $this->success('删除成功');
         }else{

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

@@ -40,7 +40,7 @@ class ProcessDocument extends Api
         $map['a.Gd_gdbh'] = $order;
         $map['a.行号'] = 1;
         //胶印车间计量单位为”张“,凹印车间计量单位一般为”吨“
-        $info = Db::name('工单_基本资料')->alias('a')
+        $info = db('工单_基本资料')->alias('a')
             ->join('工单_bom资料 b ',' a.Gd_gdbh=b.BOM_工单编号','left')
             ->field('a.成品代号,a.产品版本号,b.BOM_计划用量,b.BOM_物料名称')
             ->where($map)
@@ -88,7 +88,7 @@ class ProcessDocument extends Api
         $where = array();
         $where['Gd_gdbh'] = $order;
         $where['行号'] = 1;
-        $product = Db::name('工单_基本资料')
+        $product = db('工单_基本资料')
             ->where($where)
             ->field('成品代号')
             ->find();
@@ -147,7 +147,7 @@ class ProcessDocument extends Api
         $where = array();
         $where['Gd_gdbh'] = $params['order'];
         $where['行号'] = 1;
-        $product = DB::name('工单_基本资料')
+        $product = db('工单_基本资料')
             ->where($where)
             ->field('成品代号')
             ->find();
@@ -192,7 +192,7 @@ class ProcessDocument extends Api
         ];
         $field  = 'Gd_gdbh,rtrim(销售订单号) as 销售订单号,rtrim(Gd_cpmc) as Gd_cpmc,rtrim(成品名称) as 成品名称,计划投料,实际投料,rtrim(产品版本号) as 产品版本号,rtrim(警语版面) as 警语版面,
         rtrim(Gd_desc) as Gd_desc';
-        $gdinfo =  Db::name('工单_基本资料')
+        $gdinfo =  db('工单_基本资料')
             ->where($where)
             ->field($field)
             ->select();

+ 24 - 24
application/api/controller/Product.php

@@ -50,7 +50,7 @@ class Product extends Api
                     rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
                     FROM `产品_基本资料` WHERE `客户编号` = '{$customCode}' ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END, 
                     `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
-            $total = Db::name('产品_基本资料')->where('客户编号',$customCode)->count();
+            $total = db('产品_基本资料')->where('客户编号',$customCode)->count();
         }else{
             if (isset($params['search']) && !empty($params['search'])){
                 $search = $params['search'];
@@ -58,13 +58,13 @@ class Product extends Api
                     rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
                     FROM `产品_基本资料` WHERE `产品名称` LIKE '%{$search}%' OR `产品编号` LIKE '%{$search}%' ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END, 
                     `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
-                $total = Db::name('产品_基本资料')->where('产品名称','like','%'.$search.'%')->count();
+                $total = db('产品_基本资料')->where('产品名称','like','%'.$search.'%')->count();
             }else{
                 $sql = "SELECT rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,客户料号,rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,版本号,成品规格,
                     rtrim(计量单位) as 计量单位,rtrim(产品类别) as 产品类别,生产类别,产品备注,投产日期,状态,U8UID,rtrim(Sys_id) as Sys_id,Sys_rq,Mod_rq,UniqID
                     FROM `产品_基本资料` ORDER BY CASE WHEN `状态` IS NULL THEN 0 ELSE 1 END, 
                     `客户编号`ASC,`状态` ASC,`产品编号` DESC LIMIT {$limit} OFFSET {$pages}";
-                $total = Db::name('产品_基本资料')->count();
+                $total = db('产品_基本资料')->count();
             }
         }
         $list = Db::query($sql);
@@ -113,18 +113,18 @@ class Product extends Api
         $gy_field = 'rtrim(a.Gy0_方案) as 方案,a.Gy0_yjno,a.Gy0_gxh,rtrim(a.gy0_gxmc) as gy0_gxmc,rtrim(a.Add_gxmc) as add_gxmc,a.Gy0_Ks,a.Gy0_ls,rtrim(a.工序备注) as 备注,
         a.工价系数,a.损耗系数,a.Gy0_Ms,a.人工检_正品板,a.人工检_次品板,a.人工检_废检,a.机检_正品板,a.机检_次品板,a.机检_废检,rtrim(a.Gy0_sbmc) as Gy0_sbmc,rtrim(a.Sys_id) as Sys_id,
         a.Sys_rq,a.Mod_rq,b.sys_rate0 as 基础损耗,b.sys_rate1 as 损耗率';
-        $gyRes = Db::name('产品_工艺资料')->alias('a')
+        $gyRes = db('产品_工艺资料')->alias('a')
             ->join('dic_lzsh b','a.Gy0_shdh = b.sys_bh','left')
             ->where($option)->field($gy_field)->order('a.Gy0_yjno asc,a.Gy0_gxh asc')->select();
         //印件资料
         $where['yj_cpdh'] = $code;
         $field = 'yj_yjno,rtrim(yj_yjdh) as yj_yjdh,yj_yjmc,rtrim(yj_zzdh) as yj_zzdh,rtrim(yj_zzmc) as yj_zzmc,rtrim(yj_tlgg) as yj_tlgg,
         rtrim(yj_klgg) as yj_klgg,yj_ks,yj_ls,rtrim(yj_desc) as yj_desc,rtrim(sys_id) as sys_id,sys_rq,mod_rq';
-        $yjRes = Db::name('产品_印件资料')->where($where)->field($field)->select();
+        $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 印版名称';
-        $ybRes = Db::name('产品_印版资料')->alias('a')
+        $ybRes = db('产品_印版资料')->alias('a')
             ->join('物料_存货编码 b','a.存货编码 = b.物料代码')
             ->where($filter)->field($yb_field)->select();
         $list = [];
@@ -157,7 +157,7 @@ class Product extends Api
         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';
-        $gyRes = Db::name('产品_工艺资料')->alias('a')
+        $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();
         $this->success('请求成功',$gyRes);
@@ -200,7 +200,7 @@ class Product extends Api
             if (!empty($value['ms_coe'])){
                 $data['Gy0_Ms'] = $value['ms_coe'];
             }
-            $sql = Db::name('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+            $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
             $res = Db::query($sql);
             if ($res !== false){
                 $i++;
@@ -232,7 +232,7 @@ class Product extends Api
         }
         $code = $params['印品代号'];
         unset($params['印品代号']);
-        $sql = Db::name('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->update($params);
+        $sql = db('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->update($params);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');
@@ -260,7 +260,7 @@ class Product extends Api
         if ($params['status'] == 2){
             $status = '停产';
         }
-        $sql = Db::name('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->setField('状态',$status);
+        $sql = db('产品_基本资料')->where('产品编号',$code)->fetchSql(true)->setField('状态',$status);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');
@@ -283,9 +283,9 @@ class Product extends Api
         if (!isset($code)){
             $this->error('参数不能为空');
         }
-        $res = Db::name('产品_工艺资料')->where('Gy0_cpdh',$code)->distinct(true)->column('rtrim(Gy0_方案) as gy_plan');
+        $res = db('产品_工艺资料')->where('Gy0_cpdh',$code)->distinct(true)->column('rtrim(Gy0_方案) as gy_plan');
         $data['gy'] = $res;
-        $product = Db::name('产品_基本资料')->where('产品编号',$code)->find();
+        $product = db('产品_基本资料')->where('产品编号',$code)->find();
         $data['name'] = rtrim($product['产品名称']);
         $this->success('请求成功',$data);
     }
@@ -314,11 +314,11 @@ class Product extends Api
             //查出参考的工艺数据
             $where['Gy0_cpdh'] = $params['from_code'];
             $where['Gy0_方案'] = $params['from_pro'];
-            $gyList = Db::name('产品_工艺资料')->where($where)->select();
+            $gyList = db('产品_工艺资料')->where($where)->select();
             if (empty($gyList)){
                 $this->error('参考产品无工艺资料数据');
             }
-            $UniqID = Db::name('产品_工艺资料')->order('UniqID desc')->value('UniqID');
+            $UniqID = db('产品_工艺资料')->order('UniqID desc')->value('UniqID');
             foreach ($gyList as $key=>$value){
                 unset($gyList[$key]['UniqID']);
                 $UniqID ++;
@@ -328,9 +328,9 @@ class Product extends Api
             }
         }
         if ($params['is_copy_yb'] == 1){
-            $UniqId = Db::name('产品_印版资料')->order('UniqID desc')->value('UniqID');
+            $UniqId = db('产品_印版资料')->order('UniqID desc')->value('UniqID');
             $option['YB_Cpdh'] = $params['from_code'];
-            $ybList = Db::name('产品_印版资料')->where($option)->select();
+            $ybList = db('产品_印版资料')->where($option)->select();
             if (empty($ybList)){
                 $this->error('参考产品无印版资料数据');
             }
@@ -342,21 +342,21 @@ class Product extends Api
             }
         }
         if ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 1){
-            $gyResult = Db::name('产品_工艺资料')->insertAll($gyList);
+            $gyResult = db('产品_工艺资料')->insertAll($gyList);
             if (!$gyResult){
                 $this->error('复制产品工艺资料数据失败');
             }
-            $ybResult = Db::name('产品_印版资料')->insertAll($ybList);
+            $ybResult = db('产品_印版资料')->insertAll($ybList);
             if (!$ybResult){
                 $this->error('复制产品印版资料数据失败');
             }
         }elseif ($params['is_copy_gy'] == 1 && $params['is_copy_yb'] == 0){
-            $gyResult = Db::name('产品_工艺资料')->insertAll($gyList);
+            $gyResult = db('产品_工艺资料')->insertAll($gyList);
             if (!$gyResult){
                 $this->error('复制产品工艺资料数据失败');
             }
         }else{
-            $ybResult = Db::name('产品_印版资料')->insertAll($ybList);
+            $ybResult = db('产品_印版资料')->insertAll($ybList);
             if (!$ybResult){
                 $this->error('复制产品印版资料数据失败');
             }
@@ -380,7 +380,7 @@ class Product extends Api
         }
         $where['Gy0_cpdh'] = $params['code'];
         $where['Gy0_方案'] = $params['old_name'];
-        $sql = Db::name('产品_工艺资料')->where($where)->fetchSql(true)->setField('Gy0_方案',$params['new_name']);
+        $sql = db('产品_工艺资料')->where($where)->fetchSql(true)->setField('Gy0_方案',$params['new_name']);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');
@@ -417,7 +417,7 @@ class Product extends Api
             if (!empty($value['Gy0_ls'])){
                 $data['Gy0_ls'] = $value['Gy0_ls'];
             }
-            $sql = Db::name('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+            $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
             $res = Db::query($sql);
             if ($res !== false){
                 $i++;
@@ -458,7 +458,7 @@ class Product extends Api
             $data['Add_gxmc'] = $value['Add_gxmc'];
             $data['工序备注'] = $value['remark'];
 
-            $sql = Db::name('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+            $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
             $res = Db::query($sql);
             if ($res !== false){
                 $i++;
@@ -505,7 +505,7 @@ class Product extends Api
             if (!empty($value['machine_fj'])){
                 $data['机检_废检'] = $value['machine_fj'];
             }
-            $sql = Db::name('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
+            $sql = db('产品_工艺资料')->where('UniqID',$value['UniqID'])->fetchSql(true)->update($data);
             $res = Db::query($sql);
             if ($res !== false){
                 $i++;

+ 40 - 33
application/api/controller/ReportingWork.php

@@ -30,13 +30,14 @@ class ReportingWork extends Api
         if (Request::instance()->isPost() == false){
             $this->error('非法请求');
         }
-        $params = Request::instance()->post();
+        $params = Request::instance()->request();
         if (!isset($params['machine']) || empty($params['machine'])){
             $this->error('参数不能为空');
         }
         $machine = $params['machine'].'#';
         $data = [];
-        $lastData = Db::name('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+//        $lastData = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $lastData = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
         if ($lastData['UniqId'] < 160000000){
             $id = 160000000;
         }else{
@@ -62,7 +63,8 @@ class ReportingWork extends Api
             for ($i=1;$i<=count($class);$i++){
                 $where['sczl_bh'.$i] = $class[$i-1];
             }
-            $classData = Db::name('设备_班组资料')->where($where)->field('sczl_bzdh,UniqId')->find();
+//            $classData = \db('设备_班组资料')->where($where)->field('sczl_bzdh,UniqId')->find();
+            $classData = \db('设备_班组资料')->where($where)->field('sczl_bzdh,UniqId')->find();
             $data['班组编号'] = $classData['sczl_bzdh'];
             $data['班组ID'] = $classData['UniqId'];
             // 获取当前时间
@@ -84,15 +86,16 @@ class ReportingWork extends Api
             $option['Gy0_gdbh'] = $params['order'];
             $option['Gy0_yjno'] = $params['yjno'];
             $option['Gy0_gxh'] = $data['工序号'];
-            $data['任务ID'] = Db::name('工单_工艺资料')->where($option)->value('UniqId');
+            $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
         }
         $data['UniqId'] = $id;
-        $sql = Db::name('设备_产量采集')->fetchSql(true)->insert($data);
+//        $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
+        $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
         $res = Db::query($sql);
         if ($res === false){
-            $this->success('设置失败');
+            $this->error('设置失败');
         }else{
-            $this->error('设置成功');
+            $this->success('设置成功');
         }
     }
     /**
@@ -106,7 +109,7 @@ class ReportingWork extends Api
         if (Request::instance()->isPost() == false){
             $this->error('非法请求');
         }
-        $params = Request::instance()->post();
+        $params = Request::instance()->request();
         if (!isset($params['order']) || empty($params['order'])){
             $this->error('参数不能为空');
         }
@@ -120,11 +123,11 @@ class ReportingWork extends Api
         $where['Gy0_yjno'] = $params['yjno'];
         $where['Gy0_gxh'] = $params['gxh'];
         $date = date('Y-m-d H:i:s');
-        $res = Db::name('工单_工艺资料')->where($where)->setField('PD_WG',$date);
+        $res = \db('工单_工艺资料')->where($where)->setField('PD_WG',$date);
         if ($res === false){
-            $this->success('设置失败');
+            $this->error('设置失败');
         }else{
-            $this->error('设置成功');
+            $this->success('设置成功');
         }
     }
     /**
@@ -141,16 +144,16 @@ class ReportingWork extends Api
             $this->error('参数错误');
         }
         $machine = $params['machine'].'#';
-        $data = Db::name('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
         $list = [];
         $list['order'] = $data['工单编号'];
         $list['yjno'] = $data['印件号'];
-        $name = Db::name('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
+        $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
         $list['product_name'] = rtrim($name);
         $where['Gy0_gdbh'] = $data['工单编号'];
         $where['Gy0_yjno'] = $data['印件号'];
         $where['Gy0_gxh'] = $data['工序号'];
-        $gxmc = Db::name('工单_工艺资料')->where($where)->value('Gy0_gxmc');
+        $gxmc = \db('工单_工艺资料')->where($where)->value('Gy0_gxmc');
         $list['gxmc'] = rtrim($gxmc);
         $this->success('请求成功',$list);
     }
@@ -182,7 +185,7 @@ class ReportingWork extends Api
                 $code = 'ZM'.$params['code'];
             }
         }
-        $data = Db::name('人事_基本资料')->where('员工编号',$code)->value('员工姓名');
+        $data = \db('人事_基本资料')->where('员工编号',$code)->value('员工姓名');
         $this->success('请求成功',rtrim($data));
     }
     /**
@@ -194,7 +197,7 @@ class ReportingWork extends Api
         if (Request::instance()->isPost() == false){
             $this->error('非法请求');
         }
-        $params = Request::instance()->post();
+        $params = Request::instance()->request();
         if (empty($params['machine']) || empty($params['type']) || empty($params['order'])) {
             $this->error('参数错误');
         }
@@ -213,24 +216,28 @@ class ReportingWork extends Api
         $data['检验项目'] = '['.$params['no'].'/'.$params['name'].']';
         $data['检验备注'] = $params['remark'];
         $data['提交时间'] = date('Y-m-d H:i:s');
-        $produce = Db::name('设备_产量采集')->where('设备编号',$params['machine'].'#')->where('工单编号',$params['order'])->order('UniqId desc')->find();
+        $data['sys_rq'] = date('Y-m-d H:i:s');
+        $produce = \db('设备_产量采集')->where('设备编号',$params['machine'].'#')->where('工单编号',$params['order'])->order('UniqId desc')->find();
+//        $produce = \db('设备_产量采集')->where('设备编号',$params['machine'].'#')->where('工单编号',$params['order'])->order('UniqId desc')->find();
         if (!empty($produce)){
             $data['工序名称'] = $produce['工序名称'];
             $data['班组编号'] = rtrim($produce['班组编号']);
             $data['开工时间'] = $produce['开工时间'];
         }
-        $res = Db::name('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
+//        $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
+        $res = \db('制程检验_记录')->field('UniqId')->order('UniqId desc')->find();
         if ($res['UniqId'] < 100000000){
             $data['UniqId'] = 100000000;
         }else{
             $data['UniqId'] = $res['UniqId'] + 1;
         }
-        $sql = Db::name('制程检验_记录')->fetchSql(true)->insert($data);
+//        $sql = \db('制程检验_记录')->fetchSql(true)->insert($data);
+        $sql = \db('制程检验_记录')->fetchSql(true)->insert($data);
         $result = Db::query($sql);
         if ($result === false){
-            $this->success('提交失败');
+            $this->error('提交失败');
         }else{
-            $this->error('提交成功');
+            $this->success('提交成功');
         }
     }
     /**
@@ -248,12 +255,12 @@ class ReportingWork extends Api
         }
         $machine = $params['machine'].'#';
         $data = [];
-        $produce = Db::name('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $produce = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
         $data['order_info']['order'] = $produce['工单编号'];
         $data['order_info']['yjno'] = $produce['印件号'];
         $data['order_info']['gxh'] = $produce['工序号'];
         $data['order_info']['gxmc'] = $produce['工序名称'];
-        $product = Db::name('工单_基本资料')->alias('a')
+        $product = \db('工单_基本资料')->alias('a')
             ->join('工单_工艺资料 b','a.Gd_Gdbh = b.Gy0_gdbh','left')
             ->join('工单_印件资料 c','a.Gd_Gdbh = c.Yj_gdbh','left')
             ->field('a.成品名称,b.Gy0_gxmc,c.yj_yjmc')
@@ -270,11 +277,11 @@ class ReportingWork extends Api
             $data['order_info']['yj_name'] = rtrim($product[0]['yj_yjmc']);
             $data['order_info']['gy_name'] = rtrim($product[0]['Gy0_gxmc']);
         }
-        $class = Db::name('设备_班组资料')->where('UniqId',$produce['班组ID'])->find();
+        $class = \db('设备_班组资料')->where('UniqId',$produce['班组ID'])->find();
         for ($i=1;$i<11;$i++){
             $name = '';
             if (!empty($class['sczl_bh'.$i])){
-                $name = Db::name('人事_基本资料')->where('员工编号',$class['sczl_bh'.$i])->value('员工姓名');
+                $name = \db('人事_基本资料')->where('员工编号',$class['sczl_bh'.$i])->value('员工姓名');
             }
             $class['sczl_name'.$i] = rtrim($name);
         }
@@ -310,7 +317,7 @@ class ReportingWork extends Api
         if (Request::instance()->isPost() == false){
             $this->error('非法请求');
         }
-        $params = Request::instance()->post();
+        $params = Request::instance()->request();
         $machine = $params['sczl_jtbh'].'#';
         $batchData = []; //批次追踪数据
         $batch = $params['bom'];
@@ -334,11 +341,11 @@ class ReportingWork extends Api
         unset($data['main_meter']);
         unset($data['auxiliary_meter']);
         unset($data['bom']);
-        $start_time = Db::name('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $start_time = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
         $data['开工时间'] = $start_time['开工时间'];
-        $sys_id = Db::name('设备_基本资料')->where('设备编号',$machine)->value('sys_sbID');
+        $sys_id = \db('设备_基本资料')->where('设备编号',$machine)->value('sys_sbID');
         $data['sys_id'] = '['.$sys_id.'/'.$machine.']';
-        $UniqId = Db::name('设备_产量计酬')->order('UniqId desc')->value('UniqId');
+        $UniqId = \db('设备_产量计酬')->order('UniqId desc')->value('UniqId');
         if ($UniqId < 10000000){
             $data['UniqId'] = 10000000;
         }else{
@@ -364,7 +371,7 @@ class ReportingWork extends Api
 
         $batchData = explode(',',$batch);
         $newData = [];
-        $batchUniqId = Db::name('物料_批次跟踪')->order('UniqId desc')->value('UniqId');
+        $batchUniqId = \db('物料_批次跟踪')->order('UniqId desc')->value('UniqId');
         if ($batchUniqId < 10000000){
             $batchUniqId = 10000000;
         }
@@ -386,9 +393,9 @@ class ReportingWork extends Api
         $batch_res = true;
         Db::startTrans();
         try {
-            $sql = Db::name('设备_产量计酬')->fetchSql(true)->insert($data);
+            $sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
             $res = Db::query($sql);
-            $batch_sql = Db::name('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
+            $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
             $batch_res = Db::query($batch_sql);
             Db::commit();
         }catch (\Exception $e){
@@ -411,7 +418,7 @@ class ReportingWork extends Api
             $this->error('非法请求');
         }
         $params = Request::instance()->get();
-        $data = Db::name('设备_基本资料')->where('sys_sbID',$params['addr'])->field('设备编号')->find();
+        $data = \db('设备_基本资料')->where('sys_sbID',$params['addr'])->field('设备编号,rtrim(使用部门) as 使用部门')->find();
         $this->success('请求成功',$data);
     }
 }

+ 10 - 10
application/api/controller/Staff.php

@@ -59,14 +59,14 @@ class Staff extends Api
         $field = '员工编号,rtrim(员工姓名) as 员工姓名,性别,聘用日期,转正日期,rtrim(所在部门) as 所在部门,rtrim(部门编码) as 部门编码,rtrim(职称职务) as 职称职务,rtrim(身份证号) as 身份证号,出生日期,
         rtrim(人员性质) as 人员性质,rtrim(人员类别) as 人员类别,班次类型,工资表类别,薪酬核算分组,rtrim(在职状态) as 在职状态,rtrim(U8在职) as U8在职,U8离职日期,rtrim(sys_id) as sys_id,sys_rq,mod_rq';
         if (strlen($params['department_code']) > 1){
-            $list = Db::name('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
-            $total = Db::name('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->count();
+            $list = db('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
+            $total = db('人事_基本资料')->where($where)->where('部门编码',$params['department_code'])->count();
         }else if (strlen($params['department_code']) == 1){
-            $list = Db::name('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
-            $total = Db::name('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->count();
+            $list = db('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
+            $total = db('人事_基本资料')->where($where)->where('LEFT(部门编码,1)='.$params['department_code'])->count();
         }else{
-            $list = Db::name('人事_基本资料')->where($where)->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
-            $total = Db::name('人事_基本资料')->where($where)->count();
+            $list = db('人事_基本资料')->where($where)->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select();
+            $total = db('人事_基本资料')->where($where)->count();
         }
         $data['list'] = $list;
         $data['total'] = $total;
@@ -100,11 +100,11 @@ class Staff extends Api
                 $list[$key] = $value;
             }
         }
-        $six = Db::name('人事_基本资料')->where('在职状态','在职')->where('U8在职','离职')->count();
+        $six = db('人事_基本资料')->where('在职状态','在职')->where('U8在职','离职')->count();
         $sixArr['编号'] = '';
         $sixArr['名称'] = '离职工资结算中';
         $sixArr['total'] = $six;
-        $sev = Db::name('人事_基本资料')->where('在职状态','离职')->where('U8在职','离职')->count();
+        $sev = db('人事_基本资料')->where('在职状态','离职')->where('U8在职','离职')->count();
         $sevArr['编号'] = '';
         $sevArr['名称'] = '离职清单';
         $sevArr['total'] = $sev;
@@ -141,7 +141,7 @@ class Staff extends Api
         }
         $field = '员工编号,rtrim(员工姓名) as 员工姓名,性别,聘用日期,转正日期,rtrim(所在部门) as 所在部门,rtrim(部门编码) as 部门编码,rtrim(职称职务) as 职称职务,rtrim(身份证号) as 身份证号,出生日期,
         rtrim(人员性质) as 人员性质,rtrim(人员类别) as 人员类别,班次类型,工资表类别,薪酬核算分组,rtrim(在职状态) as 在职状态,rtrim(U8在职) as U8在职,U8离职日期,rtrim(sys_id) as sys_id,sys_rq,mod_rq';
-        $data = Db::name('人事_基本资料')->where($where)->field($field)->find();
+        $data = db('人事_基本资料')->where($where)->field($field)->find();
         $this->success('请求成功',$data);
     }
     /**
@@ -160,7 +160,7 @@ class Staff extends Api
         }
         $staffCode = $params['员工编号'];
         unset($params['员工编号']);
-        $sql = Db::name('人事_基本资料')->where('员工编号',$staffCode)->fetchSql(true)->update($params);
+        $sql = db('人事_基本资料')->where('员工编号',$staffCode)->fetchSql(true)->update($params);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('更新成功');

+ 26 - 27
application/api/controller/WorkOrder.php

@@ -81,13 +81,12 @@ class WorkOrder extends Api
         $endTime = input('end');
         $workOrder = input('workOrder');
         $productCode = input('productCode');
+        $where = [];
         if (!empty($clientNumber)){
             $where['成品代号'] = ['like',$clientNumber.'%'];
         }
         if (!empty($workOrder)){
             $where['Gd_gdbh'] = $workOrder;
-        }else{
-            $this->error();
         }
         if (!empty($productCode)){
             $where['Gd_cpdh'] = $productCode;
@@ -215,7 +214,6 @@ class WorkOrder extends Api
         $list = Db::table('工单_工艺资料')
             ->where('Gy0_gdbh',$Gd_gdbh)
             ->select();
-        $Gd_cpdh = Db::table('工单_基本资料')->where('Gd_gdbh',$Gd_gdbh)->field('Gd_cpdh')->find();
         $data = [];
         if ($list){
             foreach ($list as $key=>$value){
@@ -225,24 +223,23 @@ class WorkOrder extends Api
                 if ($value['Gy0_gxh']<10){
                     $value['Gy0_gxh'] = '0'.$value['Gy0_gxh'];
                 }
-                $where = [
-                    'Gy0_cpdh' => $Gd_cpdh['Gd_cpdh'],
-                    'Gy0_yjno' => $value['Gy0_yjno'],
-                    'Gy0_gxh' => $value['Gy0_gxh'],
-                ];
-                $product = Db::table('产品_工艺资料')->where($where)->field('工价系数,损耗系数')->find();
+                if ($value['Gy0_计划损耗'] !== 0){
+                    $number = round(($value['Gy0_计划损耗']/(int)($value['Gy0_计划接货数']/$value['Gy0_ls'])),2).'%';
+                }else{
+                    $number = 0;
+                }
                 $data[$key] = [
                     '重点工序' => rtrim($value['重点工序']),
                     '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
-                    '备选工序' => '',
+                    '备选工序' => rtrim($value['备选工序']),
                     '工序名称' => rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】',
-                    '计划产量' => rtrim($value['Gy0_计划接货数']),
+                    '计划产量' => (int)($value['Gy0_计划接货数']/$value['Gy0_ls']),
                     '基础损耗' => rtrim($value['Gy0_Rate0']),
                     '损耗率' => rtrim($value['Gy0_Rate1']),
-                    '报废定额' => '',
-                    '允损比例' => '',
-                    '难度系数' => isset($product['工价系数'])?rtrim($product['工价系数']):'',
-                    '损耗系数' => isset($product['损耗系数'])?rtrim($product['损耗系数']):'',
+                    '报废定额' => rtrim($value['Gy0_计划损耗']),
+                    '允损比例' => $number,
+                    '难度系数' => isset($value['工价系数'])?rtrim($value['工价系数']):'',
+                    '损耗系数' => isset($value['损耗系数'])?rtrim($value['损耗系数']):'',
                     '人工检_次品板' => (int)$value['人工检_次品板']=0?'':$value['人工检_次品板'],
                     '人工检_废检' => (int)$value['人工检_废检']=0?'':$value['人工检_废检'],
                     '机检_正品板' => (int)$value['机检_正品板']=0?'':$value['机检_正品板'],
@@ -354,10 +351,10 @@ class WorkOrder extends Api
 
     public function WorkOrderEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['Uniqid']) === false){
             $this->error('参数错误');
         }
@@ -487,7 +484,7 @@ class WorkOrder extends Api
 
     public function ProductInformationEdit()
     {
-        if ($this->request->isPost() === false)
+        if (Request::instance()->isPost() === false)
         {
             $this->error('请求错误');
         }
@@ -614,7 +611,7 @@ class WorkOrder extends Api
      */
     public function ProcessCopy()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $oldWorkOrder = input('oldWorkOrder');
@@ -772,7 +769,7 @@ class WorkOrder extends Api
      */
     public function TestCoefficientEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
         $workOrder = input('workOrder');
@@ -900,13 +897,14 @@ class WorkOrder extends Api
 
     public function PrintedEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['Uniqid']) === false){
             $this->error('参数错误');
         }
+//        halt($param);
         $data = [
             'yj_Yjno' => isset($param['yjno'])?$param['yjno']:'',
             'yj_Yjdh' => isset($param['yjdh'])?$param['yjdh']:'',
@@ -931,6 +929,7 @@ class WorkOrder extends Api
             'yj_ls' => isset($param['ls'])?$param['ls']:'',
             'yj_desc' => isset($param['desc'])?$param['desc']:'',
         ];
+        halt($data);
         $sql = Db::table('工单_印件资料')->where('Uniqid',$param['Uniqid'])->fetchSql(true)->update($data);
         $res = Db::query($sql);
         if ($res !== false){
@@ -954,10 +953,10 @@ class WorkOrder extends Api
      */
     public function ProcessDetailEdit()
     {
-        if ($this->request->isPost() === false){
+        if (Request::instance()->isPost() === false){
             $this->error('请求错误');
         }
-        $param = $this->request->param();
+        $param = Request::instance()->post();
         if (empty($param) || isset($param['UniqId']) === false){
             $this->error('参数错误');
         }
@@ -966,8 +965,8 @@ class WorkOrder extends Api
             '重点工序' => isset($param['zdgx'])?$param['zdgx']:'',
             '备选工序' => isset($param['bxgx'])?$param['bxgx']:'',
             'Gy0_sbbh' => isset($param['sbbh'])?$param['sbbh']:'',
-            'Gy0_Rate0' => $rate['rate0'],
-            'Gy0_Rate1' => $rate['rate1'],
+            'Gy0_Rate0' => isset($rate['rate0'])?$rate['rate0']:'',
+            'Gy0_Rate1' => isset($rate['rate1'])?$rate['rate1']:'',
             'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
             '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
             '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
@@ -1028,7 +1027,7 @@ class WorkOrder extends Api
      */
     public function PrintJobOrder()
     {
-        if ($this->request->isPost() === false) {
+        if ($this->request->isGet() === false) {
             $this->error('请求错误');
         }
         $param = $this->request->param();

+ 39 - 39
application/api/controller/WorkOrderVerification.php

@@ -166,60 +166,60 @@ class WorkOrderVerification extends Api
         fp_bz1,fp_bz2,fp_bz3,fp_bz4,fp_bz5,fp_bz6,fp_bz7,fp_bz8,fp_bz9,fp_bz10,fp_bz11,fp_bz12,fp_bz13,
         fp_gxmc1,fp_gxmc2,fp_gxmc3,fp_gxmc4,fp_gxmc5,fp_gxmc6,fp_gxmc7,fp_gxmc8,fp_gxmc9,fp_gxmc10,fp_gxmc11,fp_gxmc12,fp_gxmc13,
         sys_id,rtrim(sys_rq) as sys_rq,UniqId';
-        $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->field($field)->find();
+        $list = db('db_qczl')->where('UniqId',$params['UniqId'])->field($field)->find();
         $list['fp_name1'] = '';
         if (!empty($list['fp_bh1'])){
-            $list['fp_name1'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh1'])->value('rtrim(员工姓名)');
+            $list['fp_name1'] = db('人事_基本资料')->where('员工编号',$list['fp_bh1'])->value('rtrim(员工姓名)');
         }
         $list['fp_name2'] = '';
         if (!empty($list['fp_bh2'])){
-            $list['fp_name2'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh2'])->value('rtrim(员工姓名)');
+            $list['fp_name2'] = db('人事_基本资料')->where('员工编号',$list['fp_bh2'])->value('rtrim(员工姓名)');
         }
         $list['fp_name3'] = '';
         if (!empty($list['fp_bh3'])){
-            $list['fp_name3'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh3'])->value('rtrim(员工姓名)');
+            $list['fp_name3'] = db('人事_基本资料')->where('员工编号',$list['fp_bh3'])->value('rtrim(员工姓名)');
         }
         $list['fp_name4'] = '';
         if (!empty($list['fp_bh4'])){
-            $list['fp_name4'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh4'])->value('rtrim(员工姓名)');
+            $list['fp_name4'] = db('人事_基本资料')->where('员工编号',$list['fp_bh4'])->value('rtrim(员工姓名)');
         }
         $list['fp_name5'] = '';
         if (!empty($list['fp_bh5'])){
-            $list['fp_name5'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh5'])->value('rtrim(员工姓名)');
+            $list['fp_name5'] = db('人事_基本资料')->where('员工编号',$list['fp_bh5'])->value('rtrim(员工姓名)');
         }
         $list['fp_name6'] = '';
         if (!empty($list['fp_bh6'])){
-            $list['fp_name6'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh6'])->value('rtrim(员工姓名)');
+            $list['fp_name6'] = db('人事_基本资料')->where('员工编号',$list['fp_bh6'])->value('rtrim(员工姓名)');
         }
         $list['fp_name7'] = '';
         if (!empty($list['fp_bh7'])){
-            $list['fp_name7'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh7'])->value('rtrim(员工姓名)');
+            $list['fp_name7'] = db('人事_基本资料')->where('员工编号',$list['fp_bh7'])->value('rtrim(员工姓名)');
         }
         $list['fp_name8'] = '';
         if (!empty($list['fp_bh8'])){
-            $list['fp_name8'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh8'])->value('rtrim(员工姓名)');
+            $list['fp_name8'] = db('人事_基本资料')->where('员工编号',$list['fp_bh8'])->value('rtrim(员工姓名)');
         }
         $list['fp_name9'] = '';
         if (!empty($list['fp_bh9'])){
-            $list['fp_name9'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh9'])->value('rtrim(员工姓名)');
+            $list['fp_name9'] = db('人事_基本资料')->where('员工编号',$list['fp_bh9'])->value('rtrim(员工姓名)');
         }
         $list['fp_name10'] = '';
         if (!empty($list['fp_bh10'])){
-            $list['fp_name10'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh10'])->value('rtrim(员工姓名)');
+            $list['fp_name10'] = db('人事_基本资料')->where('员工编号',$list['fp_bh10'])->value('rtrim(员工姓名)');
         }
         $list['fp_name11'] = '';
         if (!empty($list['fp_bh11'])){
-            $list['fp_name11'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh11'])->value('rtrim(员工姓名)');
+            $list['fp_name11'] = db('人事_基本资料')->where('员工编号',$list['fp_bh11'])->value('rtrim(员工姓名)');
         }
         $list['fp_name12'] = '';
         if (!empty($list['fp_bh12'])){
-            $list['fp_name12'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh12'])->value('rtrim(员工姓名)');
+            $list['fp_name12'] = db('人事_基本资料')->where('员工编号',$list['fp_bh12'])->value('rtrim(员工姓名)');
         }
         $list['fp_name13'] = '';
         if (!empty($list['fp_bh13'])){
-            $list['fp_name13'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh13'])->value('rtrim(员工姓名)');
+            $list['fp_name13'] = db('人事_基本资料')->where('员工编号',$list['fp_bh13'])->value('rtrim(员工姓名)');
         }
-        $max = Db::name('设备_产量计酬')->where('sczl_gdbh',$list['qczl_gdbh'])->field('MAX(sczl_num) as sczl_num')->find();
+        $max = db('设备_产量计酬')->where('sczl_gdbh',$list['qczl_gdbh'])->field('MAX(sczl_num) as sczl_num')->find();
         $list['total_liucheng'] = $max['sczl_num'];
         $this->success('请求成功',$list);
     }
@@ -236,7 +236,7 @@ class WorkOrderVerification extends Api
         if (!isset($params['order']) || empty($params['order'])){
             $this->error('参数错误');
         }
-        $list = Db::name('工单_基本资料')->alias('a')
+        $list = db('工单_基本资料')->alias('a')
             ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh','left')
             ->where('a.Gd_gdbh',$params['order'])
             ->where('a.行号',1)
@@ -263,13 +263,13 @@ class WorkOrderVerification extends Api
         }
         $where['Yj_Gdbh'] = $params['order'];
         $where['yj_Yjno'] = $params['yj_no'];
-        $list = Db::name('工单_印件资料')->where($where)->field('yj_yjmc')->find();
+        $list = db('工单_印件资料')->where($where)->field('yj_yjmc')->find();
         $option['Gy0_gdbh'] = $params['order'];
         $option['Gy0_yjno'] = $params['yj_no'];
         $option['Gy0_site'] = '检验车间';
         $option['Gy0_gxmc'] = array('not in',['包装','外发加工','废挑正','成品防护']);
-        $gxList = Db::name('工单_工艺资料')->where($option)->field('Gy0_gxh,rtrim(Gy0_gxmc) as Gy0_gxmc,rtrim(Add_gxmc) as Add_gxmc')->select();
-        $max = Db::name('设备_产量计酬')->where('sczl_gdbh',$params['order'])->where('sczl_yjno',$params['yj_no'])->field('MAX(sczl_num) as sczl_num')->value('sczl_num');
+        $gxList = db('工单_工艺资料')->where($option)->field('Gy0_gxh,rtrim(Gy0_gxmc) as Gy0_gxmc,rtrim(Add_gxmc) as Add_gxmc')->select();
+        $max = db('设备_产量计酬')->where('sczl_gdbh',$params['order'])->where('sczl_yjno',$params['yj_no'])->field('MAX(sczl_num) as sczl_num')->value('sczl_num');
         $list['gx_data'] = $gxList;
         $list['max_num'] = $max;
         $this->success('请求成功',$list);
@@ -290,7 +290,7 @@ class WorkOrderVerification extends Api
         }
         $where['分类'] = '废品分类';
         $where['名称'] = array('like','%'.$params['search'].'%');
-        $data = Db::name('erp_常用字典')->where($where)->column('名称');
+        $data = db('erp_常用字典')->where($where)->column('名称');
         // 分割字符串并合并相同项
         $resultArray = [];
         foreach ($data as $item) {
@@ -335,7 +335,7 @@ class WorkOrderVerification extends Api
             $this->error('参数错误');
         }
         $type = trim($params['type']);
-        $waste = Db::name('erp_常用字典')->where('名称','like','%'.$type.'%')->find();
+        $waste = db('erp_常用字典')->where('名称','like','%'.$type.'%')->find();
         if (empty($waste)){
             $this->error('未查询到废品分类');
         }
@@ -344,7 +344,7 @@ class WorkOrderVerification extends Api
         $search = substr($searchArr[1],0,6);
         $where['a.sczl_gdbh'] = $params['order'];
         $where['a.sczl_type'] = array('like','%'.$search.'%');
-        $list = Db::name('设备_产量计酬')->alias('a')
+        $list = db('设备_产量计酬')->alias('a')
             ->join('人事_基本资料 b','a.sczl_bh1 = b.员工编号','left')
             ->where($where)->field('distinct(a.sczl_gxmc),a.sczl_bzdh,a.sczl_jtbh,a.sczl_bh1,b.员工姓名 as name')
             ->select();
@@ -371,7 +371,7 @@ class WorkOrderVerification extends Api
         }
         $id = $params['UniqId'];
         unset($params['UniqId']);
-        $sql = Db::name('db_qczl')->where('UniqId',$id)->fetchSql(true)->update($params);
+        $sql = db('db_qczl')->where('UniqId',$id)->fetchSql(true)->update($params);
         $res = Db::query($sql);
         if ($res !== 0){
             $this->success('更新成功');
@@ -397,7 +397,7 @@ class WorkOrderVerification extends Api
         rtrim(fp_lb8) as fp_lb8,rtrim(fp_lb9) as fp_lb9,rtrim(fp_lb10) as fp_lb10,rtrim(fp_lb11) as fp_lb11,rtrim(fp_lb12) as fp_lb12,rtrim(fp_lb13) as fp_lb13,
         fp_sl1,fp_sl2,fp_sl3,fp_sl4,fp_sl5,fp_sl6,fp_sl7,fp_sl8,fp_sl9,fp_sl10,fp_sl11,fp_sl12,fp_sl13
         ';
-        $data = Db::name('db_qczl')->name('db_qczl')->where('qczl_gdbh',$params['order'])->field($field)->select();
+        $data = db('db_qczl')->name('db_qczl')->where('qczl_gdbh',$params['order'])->field($field)->select();
         if (empty($data)){
             $this->error('暂无废品数据');
         }
@@ -421,19 +421,19 @@ class WorkOrderVerification extends Api
             }
         }
         ksort($categories);
-        $wasteTotal = Db::name('db_qczl')->where('qczl_gdbh',$params['order'])->sum('qczl_fp');
+        $wasteTotal = db('db_qczl')->where('qczl_gdbh',$params['order'])->sum('qczl_fp');
         if (empty($wasteTotal)){
             $wasteTotal = 0;
         }
         $where['a.Gd_gdbh'] = $params['order'];
         $where['a.行号'] = 1;
-        $gdInfo = Db::name('工单_基本资料')->alias('a')
+        $gdInfo = db('工单_基本资料')->alias('a')
             ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh','left')
             ->where($where)->field('a.Gd_gdbh,a.实际投料,b.yj_Yjno,b.yj_yjmc')->find();
         $gdInfo['yj_Yjno'] = $gdInfo['yj_Yjno'] > 10 ? $gdInfo['yj_Yjno']:'0'.$gdInfo['yj_Yjno'];
         $gdInfo['实际投料'] = (int)($gdInfo['实际投料'] * 10000);
         $gdInfo['wasteTotal'] = $wasteTotal;
-        $finishNum = Db::name('成品入仓')->where('jjcp_gdbh',$params['order'])->sum('jjcp_sl');
+        $finishNum = db('成品入仓')->where('jjcp_gdbh',$params['order'])->sum('jjcp_sl');
         $gdInfo['passRate'] = '';
         if (!empty($finishNum)){
             $gdInfo['passRate'] = number_format((int)$finishNum/$gdInfo['实际投料']*100,2).'%';
@@ -470,7 +470,7 @@ class WorkOrderVerification extends Api
         $i = 0;
         $name = array();
         foreach ($newArray as $key=>$value){
-            $item = Db::name('erp_常用字典')->where('名称','like','%'.$key.'%')->value('名称');
+            $item = db('erp_常用字典')->where('名称','like','%'.$key.'%')->value('名称');
             $item = explode('_',substr($item,0,-1));
             $rightData[$i]['type'] = $item[1];
             $rightData[$i]['rate'] = number_format($value/$wasteTotal*100,0).'%';
@@ -499,8 +499,8 @@ class WorkOrderVerification extends Api
         }
         $where['a.Gy0_gdbh'] = $params['order'];
         $where['a.Gy0_sbbh'] = array('neq',' ');
-        $productNum = Db::name('工单_基本资料')->where('Gd_gdbh',$params['order'])->value('计划投料');
-        $gyData = Db::name('工单_工艺资料')->alias('a')
+        $productNum = db('工单_基本资料')->where('Gd_gdbh',$params['order'])->value('计划投料');
+        $gyData = db('工单_工艺资料')->alias('a')
             ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh and a.Gy0_gxh = b.sczl_gxh','left')
             ->where($where)
             ->field('a.Gy0_yjno,a.Gy0_gxh,rtrim(a.Gy0_gxmc) as Gy0_gxmc,a.Gy0_sbbh,a.Gy0_Rate0,a.Gy0_Rate1,a.损耗系数 as Gy0_Rate3,a.Gy0_Ms,a.Gy0_SITE,a.Gy0_计划接货数,a.PD_WG,
@@ -570,7 +570,7 @@ class WorkOrderVerification extends Api
         if (empty($params['date'])){
             $params['date'] = '1900-01-01 00:00:00';
         }
-        $res = Db::name('工单_工艺资料')->where('UniqId',$params['UniqId'])->setField('PD_WG',$params['date']);
+        $res = db('工单_工艺资料')->where('UniqId',$params['UniqId'])->setField('PD_WG',$params['date']);
         if ($res != false){
             $this->success('更新成功');
         }else{
@@ -593,10 +593,10 @@ class WorkOrderVerification extends Api
         $where['Gd_gdbh'] = $params['order'];
         $where['行号'] = 1;
         //工单基本资料
-        $info = Db::name('工单_基本资料')->where($where)->field('rtrim(成品代号)  as code,rtrim(成品名称) as name')->find();
+        $info = db('工单_基本资料')->where($where)->field('rtrim(成品代号)  as code,rtrim(成品名称) as name')->find();
         //工艺资料
         $option['Gy0_gdbh'] = $params['order'];
-        $gyInfo = Db::name('工单_工艺资料')
+        $gyInfo = db('工单_工艺资料')
             ->where($option)
             ->where(function ($query) {
                 $query->where('Gy0_sbbh', '<>', '')
@@ -630,10 +630,10 @@ class WorkOrderVerification extends Api
         if (!isset($params['gxNo']) || empty($params['gxNo'])){
             $this->error('参数错误');
         }
-        $total = Db::name('设备_产量计酬')->where('sczl_gdbh',$params['order'])->order('sczl_num')->column('distinct(sczl_num)');
+        $total = db('设备_产量计酬')->where('sczl_gdbh',$params['order'])->order('sczl_num')->column('distinct(sczl_num)');
         $where['sczl_gxh'] = (int)$params['gxNo'];
         $where['sczl_gdbh'] = $params['order'];
-        $process = Db::name('设备_产量计酬')->where($where)->order('sczl_num')->column('distinct(sczl_num)');
+        $process = db('设备_产量计酬')->where($where)->order('sczl_num')->column('distinct(sczl_num)');
         $res['total_process'] = $total;
         $res['process'] = $process;
         $this->success('请求成功',$res);
@@ -667,7 +667,7 @@ class WorkOrderVerification extends Api
         qczl_rq
         ';
 
-        $data = Db::name('db_qczl')
+        $data = db('db_qczl')
             ->where($where)
             ->where(function ($query) {
                 for ($i = 1; $i <= 13; $i++) {
@@ -688,7 +688,7 @@ class WorkOrderVerification extends Api
                         $list[$j]['fp_lb'] = $entry[$labelKey];
                         $list[$j]['fp_sl'] = $entry[$slKey];
                         $list[$j]['fp_bh'] = $entry[$bhKey];
-                        $name = Db::name('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
+                        $name = db('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
                         $list[$j]['fp_name'] = empty($name) ? '计时工' : $name;
                         $list[$j]['fp_bz'] = $entry[$bzKey];
                         $list[$j]['qczl_rq'] = $entry['qczl_rq'];
@@ -771,7 +771,7 @@ class WorkOrderVerification extends Api
         ';
         $where['a.qczl_gdbh'] = $params['order'];
         $where['b.行号'] = 1;
-        $data = Db::name('db_qczl')->alias('a')
+        $data = db('db_qczl')->alias('a')
             ->join('工单_基本资料 b','a.qczl_gdbh = b.Gd_gdbh','left')
             ->join('工单_印件资料 c','a.qczl_gdbh = c.Yj_Gdbh','left')
             ->join('成品入仓 d','a.qczl_gdbh = d.jjcp_gdbh','left')
@@ -789,7 +789,7 @@ class WorkOrderVerification extends Api
                     $list[$j]['fp_lb'] = $entry[$labelKey];
                     $list[$j]['fp_sl'] = $entry[$slKey];
                     $list[$j]['fp_bh'] = $entry[$bhKey];
-                    $name = Db::name('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
+                    $name = db('人事_基本资料')->where('员工编号',$entry[$bhKey])->value('rtrim(员工姓名)');
                     $list[$j]['fp_name'] =  $name;
                     $list[$j]['fp_gxh'] = empty(substr($entry[$gxhKey],0,2)) ? "0" : substr($entry[$gxhKey],0,2);
                     $list[$j]['qczl_num'] = $entry['qczl_num'];

+ 12 - 9
application/config.php

@@ -183,16 +183,19 @@ return [
     // +----------------------------------------------------------------------
     // | 缓存设置
     // +----------------------------------------------------------------------
-    'cache'                  => [
-        // 驱动方式
-        'type'   => 'File',
-        // 缓存保存目录
-        'path'   => CACHE_PATH,
-        // 缓存前缀
-        'prefix' => '',
-        // 缓存有效期 0表示永久缓存
-        'expire' => 0,
+    'cache'   =>  [
+        // 默认缓存驱动
+        'default' => 'redis',
+        // 缓存连接方式为Redis缓存
+        'type'    => 'redis',
+        // Redis服务器连接信息
+        'host'    => Env::get('redis.hostname', '127.0.0.1'),
+        'port'    => Env::get('redis.hostport', '6379'),
+        'password' => Env::get('redis.password', '123456'),
+        'select'   => Env::get('redis.select', 1),
+        'timeout'  => Env::get('redis.timeout', 500),
     ],
+
     // +----------------------------------------------------------------------
     // | 会话设置
     // +----------------------------------------------------------------------