Pārlūkot izejas kodu

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

曹鹤洋 1 gadu atpakaļ
vecāks
revīzija
91f636c54c

+ 28 - 0
application/api/controller/Manufacture.php

@@ -844,4 +844,32 @@ class Manufacture extends Api
         }
         $this->success('成功',$data);
     }
+
+    /**
+     * 机组调整
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function MachineTeamEdit()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param) || isset($param['UniqId']) === false){
+            $this->error('参数错误');
+        }
+        $sql = \db('工单_工艺资料')
+            ->where('UniqId',$param['UniqId'])
+            ->fetchSql(true)
+            ->update(['Gy0_sbbh'=>$param['machine']]);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('修改成功');
+        }else{
+            $this->error('修改失败');
+        }
+    }
 }

+ 25 - 9
application/api/controller/OrderSuperLoss.php

@@ -96,13 +96,15 @@ class OrderSuperLoss extends Api
             if (!empty($params['search'])) {
                 $this->error('参数错误');
             }
-//            $where['a.成品编码'] = $params['code'];
         }
         if (!empty($params['date'])) {
             if (!empty($params['search'])) {
                 $this->error('参数错误');
             }
-            $where['a.jjcp_sj' ] = array('like',$params['date'].'%');
+            $date_year = substr($params['date'],0,4);
+            $date_mon = substr($params['date'],4);
+            $date = $date_year.'-'.$date_mon;
+            $where['a.jjcp_sj' ] = array('like',$date.'%');
         }
         if (!empty($params['search'])) {
             if (!empty($params['date']) || !empty($params['code'])) {
@@ -120,9 +122,10 @@ class OrderSuperLoss extends Api
         if (empty($pages)){
             $pages = 1;
         }
+//        halt($where);
         $is_have_cache = false;
         if ($is_have_cache === false){
-            if (isset($params['code'])){
+            if (!empty($params['code'])){
                 $data = db('成品入仓')->alias('a')
                     ->join('工单_基本资料 b', 'a.jjcp_gdbh = b.Gd_gdbh','left')
                     ->join('工单_印件资料 c', 'a.jjcp_gdbh = c.Yj_Gdbh','left')
@@ -173,14 +176,25 @@ class OrderSuperLoss extends Api
                 $arr = [];
                 $plan_loss = [];//工单计划损耗
                 foreach ($gy_data as $k=>$v){
-                    $rate =  round($v['Gy0_计划损耗'] / $v['Gy0_计划接货数'],5);
+                    if ($v['Gy0_计划接货数'] > 0){
+                        $rate =  round($v['Gy0_计划损耗'] / $v['Gy0_计划接货数'],5);
+                    }else{
+                        $rate = 0;
+                    }
+
                     $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) . '%';//实际合格率
+                if ($value['实际投料'] >0 ){
+                    $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) . '%';//实际合格率
+                }else{
+                    $data[$key]['target_rate'] = ''; //目标合格率
+                    $data[$key]['real_rate'] = '';//实际合格率
+                }
+
                 //奖惩系数及金额
                 $data[$key]['reward_rate'] = '1';
                 $data[$key]['reward_money'] = '';
@@ -251,7 +265,6 @@ class OrderSuperLoss extends Api
         }else{
 //            $res = Cache::get('OrderSuperLoss/getList'.$params['date']);
         }
-
         $this->success('请求成功',$res);
     }
     /**
@@ -308,6 +321,9 @@ class OrderSuperLoss extends Api
         //查出成品数量及日期
         $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);
+        if (empty($cp_data)){
+            $this->success('此工单未查询到成品入库信息,请核查该工单是否已进入超节损');
+        }
         $data['warehousing_num'] = $cp_data[0]['cp_sl'];
         $data['warehousing_date'] = substr($cp_data[0]['jjcp_sj'],0,10);
         //查出进入超节损的工序,有上报产量的工序就进入超节损