Bläddra i källkod

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

曹鹤洋 1 år sedan
förälder
incheckning
e491ec3427

+ 155 - 3
application/api/controller/PieceWorkSchedule.php

@@ -32,7 +32,7 @@ class PieceWorkSchedule extends Api
         if(!$this->request->isGet()){
             $this->error('请求方式错误');
         }
-        $rows = db()->table('db_wgjs')
+        $rows = db()->table('db_wgjs1')
             ->field('LEFT(wgjs_rq, 7) as date')
             ->group('date')
             ->order('UniqId desc')
@@ -70,7 +70,7 @@ class PieceWorkSchedule extends Api
             $this->error('参数错误');
         }
 
-        $rows = db()->table('db_wgjs')
+        $rows = db()->table('db_wgjs1')
             ->field('LEFT(wgjs_rq, 10) as wgjs_rq, 
             wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
             wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
@@ -82,7 +82,7 @@ class PieceWorkSchedule extends Api
             ->order('wgjs_rq desc, UniqId asc')
             ->page($page,$limit)
             ->select();
-        $total = db()->table('db_wgjs')->where($where)->count();
+        $total = db()->table('db_wgjs1')->where($where)->count();
 
         $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名, 所在部门');
 
@@ -164,4 +164,156 @@ class PieceWorkSchedule extends Api
         }
         halt($params);
     }
+    /**
+     * 详情
+     * @ApiMethod (GET)
+     * @param string $wgjs_rq 日期
+     * @param string $wgjs_bh1 员工编号
+    */
+    public function detail(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }else{
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+        $rows = db()->table('db_wgjs1')
+        ->field('LEFT(wgjs_rq, 10) as wgjs_rq, 
+        wgjs_bh1, CAST(wgjs_js1 AS SIGNED) as wgjs_js1, rtrim(wgjs_yy1) as wgjs_yy1, 
+        wgjs_bh2, CAST(wgjs_js2 AS SIGNED) as wgjs_js2, rtrim(wgjs_yy2) as wgjs_yy2, 
+        wgjs_bh3, CAST(wgjs_js3 AS SIGNED) as wgjs_js3, rtrim(wgjs_yy3) as wgjs_yy3, 
+        wgjs_bh4, CAST(wgjs_js4 AS SIGNED) as wgjs_js4, rtrim(wgjs_yy4) as wgjs_yy4, 
+        wgjs_bh5, CAST(wgjs_js5 AS SIGNED) as wgjs_js5, rtrim(wgjs_yy5) as wgjs_yy5, 
+        wgjs_bh6, CAST(wgjs_js6 AS SIGNED) as wgjs_js6, rtrim(wgjs_yy6) as wgjs_yy6,
+        rs1.员工姓名 as name1,rs2.员工姓名 as name2,rs3.员工姓名 as name3,rs4.员工姓名
+        as name4,rs5.员工姓名 as name5,rs6.员工姓名 as name6,wgjs_冲定额1,wgjs_冲定额2
+        ,wgjs_冲定额3,wgjs_冲定额4,wgjs_冲定额5,wgjs_冲定额6')
+        ->join('人事_基本资料 rs1','rs1.员工编号=db_wgjs1.wgjs_bh1','LEFT')
+        ->join('人事_基本资料 rs2','rs2.员工编号=db_wgjs1.wgjs_bh2','LEFT')
+        ->join('人事_基本资料 rs3','rs3.员工编号=db_wgjs1.wgjs_bh3','LEFT')
+        ->join('人事_基本资料 rs4','rs4.员工编号=db_wgjs1.wgjs_bh4','LEFT')
+        ->join('人事_基本资料 rs5','rs5.员工编号=db_wgjs1.wgjs_bh5','LEFT')
+        ->join('人事_基本资料 rs6','rs6.员工编号=db_wgjs1.wgjs_bh6','LEFT')
+        ->where(['wgjs_rq'=>$req['wgjs_rq'].' 00:00:00','wgjs_bh1'=>$req['wgjs_bh1']])
+        ->find();
+        if($rows){
+        $this->success('成功',$rows);
+        }else{
+            $this->error('失败');
+        }   
+    }
+     /**
+     * 修改
+     * @ApiMethod POST
+    */
+    public function edit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        // $req = ['wgjs_js1'=>12,'wgjs_rq'=>'2023-10-12','wgjs_bh1'=>'ZM01269'];
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->update($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+      /**
+     * 新增
+     * @ApiMethod POST
+    */
+    public function add()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->insert($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+    /**
+     * 删除
+     * @ApiMethod (GET)
+     * @param string $wgjs_rq 日期
+     * @param string $wgjs_bh1 员工编号
+    */
+    public function del(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+
+        if (!isset($req['wgjs_rq']) || !isset($req['wgjs_bh1']) ){
+            $this->error('参数错误');
+        }else{
+        }
+        if (empty($req['wgjs_rq']) || empty($req['wgjs_bh1'])){
+            $this->error('参数不能为空');
+        }
+        $rows = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'].' 00:00:00','wgjs_bh1'=>$req['wgjs_bh1']])
+        ->delete();
+        if($rows){
+        $this->success('成功');
+        }else{
+            $this->error('失败');
+        }   
+    }
 }

+ 110 - 9
application/api/controller/WorkOrderSpotCheck.php

@@ -31,14 +31,14 @@ class WorkOrderSpotCheck extends Api
         if(!$this->request->isGet()){
             $this->error('请求方式错误');
         }
-        $rows = db()->table('db_抽检记录')
+        $rows = db()->table('db_抽检记录1')
             ->field('LEFT(Sys_rq, 10) as date, COUNT(*) as counts')
             ->group('date')
             ->order('UniqId desc')
             ->limit(45)
             ->select();
 
-        $arr = db()->table('db_抽检记录')
+        $arr = db()->table('db_抽检记录1')
             ->field('LEFT(Sys_rq, 10) as date, rtrim(Sys_id) as Sys_id, COUNT(Sys_id) as count')
             ->where('Sys_rq','>=',$rows[44]['date'])
             ->group('date, Sys_id')
@@ -86,7 +86,7 @@ class WorkOrderSpotCheck extends Api
         }
         if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['Sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
 
-        $rows = db()->table('db_抽检记录')
+        $rows = db()->table('db_抽检记录1')
             ->field('LEFT(Sczl_rq, 10) as Sczl_rq, Sczl_bh, Sczl_gdbh, rtrim(Sczl_gxmc) as Sczl_gxmc,
             sczl_yjno, sczl_gxh, Sczl_num, Sczl_抽检数, sczl_A类废, sczl_B类废, sczl_C类废,
             rtrim(Sczl_desc) as Sczl_desc, rtrim(Sys_id) as Sys_id, Sys_rq, Mod_rq, UniqId')
@@ -95,7 +95,7 @@ class WorkOrderSpotCheck extends Api
             ->page($page,$limit)
             ->select();
 
-        $total = db()->table('db_抽检记录')->where($where)->count();
+        $total = db()->table('db_抽检记录1')->where($where)->count();
         $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
         $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
         foreach ($rows as $key=>$value) {
@@ -132,13 +132,114 @@ class WorkOrderSpotCheck extends Api
             $this->error('参数错误');
         }
 
-        $rows = db()->table('db_抽检记录')->alias('d')
-            ->field('d.*, ')
-            ->join('工单_基本资料 g', 'd.')
-            ->where('d.UniqId',$UniqId)
-            ->select();
+        $rows = db()->table('db_抽检记录1')
+        ->field('Sczl_bh,rs.员工姓名 as name,sczl_bzdh,LEFT(Sczl_rq, 10) as Sczl_rq,Sczl_gdbh,g.Gd_cpmc,
+        Sczl_gxmc,sczl_gxh,Sczl_num,Sczl_抽检数,Sczl_A类废,Sczl_B类废,Sczl_C类废,Sczl_desc')
+        ->join('人事_基本资料 rs','rs.员工编号=db_抽检记录1.Sczl_bh','LEFT')
+        ->join('工单_基本资料 g','g.Gd_gdbh=db_抽检记录1.Sczl_gdbh','LEFT')
+        ->where('db_抽检记录1.UniqId',$UniqId)->select();
 
 
         $this->success('成功',$rows);
     }
+    /**
+     * 修改
+     * @ApiMethod POST
+    */
+    public function edit()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['mod_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->update($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+      /**
+     * 新增
+     * @ApiMethod POST
+    */
+    public function add()
+    {
+        if(!$this->request->isPost()){
+            $this->error('请求方式错误');
+        }
+
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $req['wgjs_rq'] = $req['wgjs_rq'].' 00:00:00';
+        $req['sys_rq'] = date('Y-m-d H:i:s');
+
+        //开启事务
+        db()->startTrans();
+        try{
+            $sql = db()->table('db_wgjs1')->where(['wgjs_rq'=>$req['wgjs_rq'],'wgjs_bh1'=>$req['wgjs_bh1']])
+            ->fetchSql(true)->insert($req);
+            $res= db()->query($sql);
+            // 提交事务
+            db()->commit();
+        } catch (\Exception $e) {
+            // 回滚事务
+            db()->rollback();
+            $this->error($e->getMessage());
+        }
+
+        if($res===false) $this->error('失败');
+
+        $this->success('成功');
+    }
+   /**
+     * 删除
+     * @ApiMethod (GET)
+     * @param string $UniqId UniqId
+     */
+    public function del(){
+        //get请求
+        if(!$this->request->isGet()){
+            $this->error('请求方式错误');
+        }
+        $req = $this->request->param();
+        if (isset($req['UniqId']) && !empty($req['UniqId'])){
+            $UniqId = $req['UniqId'];
+        }else{
+            $this->error('参数错误');
+        }
+
+        $rows = db()->table('db_抽检记录1')->where('UniqId',$UniqId)->delete();
+        if($rows){
+           $this->success('成功');
+        }else{
+           $this->error('失败');
+        }
+
+    }
 }

+ 193 - 2
application/api/controller/WorkOrderVerification.php

@@ -81,8 +81,6 @@ class WorkOrderVerification extends Api
         $where = [];
         if (isset($req['date']) && !empty($req['date'])){
             $where['sys_rq'] = ['LIKE',$req['date'].'%'];
-        }else{
-            $this->error('参数错误');
         }
         if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
         if (isset($req['order']) && !empty($req['order'])) $where['qczl_gdbh'] = $req['order'];
@@ -160,6 +158,7 @@ class WorkOrderVerification extends Api
         if (!isset($params['UniqId']) || empty($params['UniqId'])){
             $this->error('参数错误');
         }
+        $field = '';
         $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->find();
         $list['fp_name1'] = '';
         if (!empty($list['fp_bh1'])){
@@ -350,5 +349,197 @@ class WorkOrderVerification extends Api
         $list[$count]['name'] = '计时工';
         $this->success('请求成功',$list);
     }
+    /**
+     * 修改工单核检单
+     * @ApiMethod POST
+     * @params array data
+    */
+    public function edit(){
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params['UniqId'])){
+            $this->error('参数不能为空');
+        }
+        $id = $params['UniqId'];
+        unset($params['UniqId']);
+        $sql = Db::name('db_qczl')->where('UniqId',$id)->fetchSql(true)->update($params);
+        $res = Db::query($sql);
+        if ($res !== 0){
+            $this->success('更新成功');
+        }else{
+            $this->error('更新失败');
+        }
+    }
+    /**
+     * 工单核检废品分布
+     * @ApiMethod GET
+     * @params string order
+    */
+    public function wasteDistribution(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])){
+            $this->error('参数错误');
+        }
+        $field = '
+        rtrim(fp_lb1) as fp_lb1,rtrim(fp_lb2) as fp_lb2,rtrim(fp_lb3) as fp_lb3,rtrim(fp_lb4) as fp_lb4,rtrim(fp_lb5) as fp_lb5,rtrim(fp_lb6) as fp_lb6,rtrim(fp_lb7) as fp_lb7,
+        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();
+        if (empty($data)){
+            $this->error('暂无废品数据');
+        }
+        // 用于存储废品类别和对应废品数量的数组
+        $categories = array();
+        // 循环遍历原始数组
+        foreach ($data as $item) {
+            // 提取废品类别和对应废品数量
+            foreach ($item as $key => $value) {
+                if (strpos($key, "fp_lb") === 0) {
+                    $categoryKey = $key;
+                    $quantityKey = str_replace("fp_lb", "fp_sl", $key);
+                    $quantityValue = $item[$quantityKey];
+
+                    if (!isset($categories[$value])) {
+                        $categories[$value] = 0;
+                    }
+
+                    $categories[$value] += (int)$quantityValue;
+                }
+            }
+        }
+        ksort($categories);
+        $wasteTotal = Db::name('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')
+            ->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');
+        $gdInfo['passRate'] = '';
+        if (!empty($finishNum)){
+            $gdInfo['passRate'] = number_format((int)$finishNum/$gdInfo['实际投料']*100,2).'%';
+        }
+        //左侧废品数据
+        $wasteData = array();
+        $i = 0;
+        foreach ($categories as $key=>$value){
+            if ($value != 0){
+                $wasteData[$i]['type'] = $key;
+                $wasteData[$i]['num'] = $value;
+                $wasteData[$i]['lossesRate'] = number_format($value/$gdInfo['实际投料']*100,4).'%';
+                $wasteData[$i]['wasteRate'] = number_format($value/$wasteTotal*100,2).'%';
+                $i++;
+            }
+        }
+        // 按首字母相同的键将值相加
+        $newArray = array();
+        foreach ($categories as $key => $value) {
+            $firstLetter = strtoupper(substr($key, 0, 1)); // 获取首字母并转换为大写
+
+            if (!isset($newArray[$firstLetter])) {
+                $newArray[$firstLetter] = 0;
+            }
+
+            $newArray[$firstLetter] += $value;
+        }
+        // 去掉值为零的项
+        $newArray = array_filter($newArray, function($value) {
+            return $value !== 0;
+        });
+        //右侧废品数据
+        $rightData = array();
+        $i = 0;
+        $name = array();
+        foreach ($newArray as $key=>$value){
+            $item = Db::name('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).'%';
+            $name[$i] = $item[1];
+            $i++;
+        }
+        $gdInfo['wasteData'] = $wasteData;
+        $gdInfo['rightData'] = $rightData;
+        $gdInfo['rightTitle'] = $name;
+        $this->success('请求成功',$gdInfo);
+    }
+    /**
+     * 工单工期异常调整
+     * @ApiMethod GET
+     * @params string order
+     * 计划产量计算方式:上个工序计划产量-(基础损耗+损耗率*上个工序计划产量)*损耗系数*计损色数)
+     * lastNum - (Gy0_Rate0 + Gy0_Rate1 * lastNum )* 损耗系数(Gy0_Rate3) * Gy0_Ms
+    */
+    public function getOrderDate(){
+        if (Request::instance()->isGet() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['order']) || empty($params['order'])){
+            $this->error('参数错误');
+        }
+        $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')
+            ->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,
+            sum(b.sczl_cl) as cl')
+            ->group('a.Gy0_gxh')
+            ->select();
+        $lastNum = $productNum;
+        $res = [];
+        foreach ($gyData as $key=> $process) {
+            $res[$key]['Gy0_yjno'] = $process['Gy0_yjno'] > 10 ? $process['Gy0_yjno'] : '0'.$process['Gy0_yjno'];
+            $res[$key]['Gy0_gxh'] = $process['Gy0_gxh'] > 10 ? $process['Gy0_gxh'] : '0'.$process['Gy0_gxh'];
+            $res[$key]['Gy0_gxmc'] = $process['Gy0_gxmc'];
+            $res[$key]['Gy0_sbbh'] = $process['Gy0_sbbh'];
+            $res[$key]['PD_WG'] = $process['PD_WG'];
+            $res[$key]['finish'] = empty($process['cl']) ? 0: (int)$process['cl'];
+            // 计算工序计划产量
+            if ($process["Gy0_gxh"] == "1") {
+                // 第一道工序直接使用初始计划产量
+                $Num = $lastNum;
+            } else {
+                $Gy0_Ms = $gyData[$key-1]['Gy0_Ms'];
+                $Gy0_Rate0 = $gyData[$key-1]['Gy0_Rate0'];
+                $Gy0_Rate1 = $gyData[$key-1]['Gy0_Rate1'];
+                $Gy0_Rate3 = $gyData[$key-1]['Gy0_Rate3'];
+                // 大于第一道工序,使用上一道工序的计划产量
+                // 根据公式计算工序计划产量
+                if ($Gy0_Ms != "0.00") {
+                    $Num = $lastNum - ($Gy0_Rate0 + $Gy0_Rate1 * $lastNum) * $Gy0_Rate3 * $Gy0_Ms;
+                } else {
+                    $Num = $lastNum - ($Gy0_Rate0 + $Gy0_Rate1 * $lastNum) * $Gy0_Rate3;
+                }
+            }
+            if (trim($process['Gy0_SITE']) == '检验车间'){
+                $res[$key]['plan'] = (int)$process['Gy0_计划接货数'];
+            }else{
+                $res[$key]['plan'] = (int)round($Num);
+            }
+            $finish_rate = $res[$key]['finish']/$res[$key]['plan'];
+            $res[$key]['finish_rate'] = '';
+            if ($finish_rate != 0){
+                $res[$key]['finish_rate'] = number_format($finish_rate*100,2).'%';
+            }
 
+            // 更新 $lastNum 为当前工序的计划产量
+            $lastNum = $Num;
+        }
+        $this->success('请求成功',$res);
+    }
 }