Browse Source

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

曹鹤洋 1 năm trước cách đây
mục cha
commit
3ddc57eefb

+ 26 - 1
application/api/controller/Facility.php

@@ -335,10 +335,10 @@ class Facility extends Api
                 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 b.PD_WG = '1900-01-01 00:00:00' 
                 AND b.Gy0_sj1 <> '1900-01-01 00:00:00'
+                AND b.Gy0_sj1 < '2099-01-01 00:00:00'
             GROUP BY a.Gd_gdbh
             ORDER BY b.Gy0_sj1";
         $orderList = Db::query($sql);
@@ -1947,4 +1947,29 @@ class Facility extends Api
             $this->error('修改失败');
         }
     }
+
+    /**
+     * 产量上报数据删除
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function ChanliangDel()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $res = \db('设备_产量计酬')
+            ->where('UniqId',$param['UniqId'])
+            ->delete();
+        if ($res !== false){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
 }

+ 26 - 24
application/api/controller/Manufacture.php

@@ -656,34 +656,36 @@ class Manufacture extends Api
             $this->error('参数错误');
         }
         $machine = $param['machine'];
-        $list = \db('工单_工艺资料')
+        $list = \db('工单_基本资料')
             ->alias('a')
             ->field([
-                'rtrim(a.Gy0_gdbh)' => '工单编号',
-                'rtrim(a.Gy0_计划接货数)' => '计划接货数',
-                'rtrim(a.Gy0_小时产能)' => '小时产能',
-                'rtrim(a.Gy0_生产工时)' => '生产工时',
-                'rtrim(a.Gy0_辅助工时)' => '辅助工时',
-                'rtrim(a.Gy0_班次安排)' => '班次安排',
-                'rtrim(a.工序备注)' => '排单备注',
-                'rtrim(a.Gy0_最早开工时间)' => '最早开工时间',
-                'rtrim(a.Gy0_sj1)' => '计划开工时间',
-                'rtrim(a.Gy0_sj2)' => '计划完工时间',
-                'rtrim(a.Gy0_yjno)' => 'yjno',
-                'rtrim(a.Gy0_gxh)' => 'gxh',
-                'rtrim(a.Gy0_gxmc)' => 'gxmc',
-                'rtrim(a.Gy0_ls)' => 'ls',
-                'rtrim(a.UniqId)' => 'UniqId',
-                'SUM(b.sczl_cl)' => '已完成'
+                'rtrim(b.Gy0_gdbh)' => '工单编号',
+                'rtrim(b.Gy0_计划接货数)' => '计划接货数',
+                'rtrim(b.Gy0_小时产能)' => '小时产能',
+                'rtrim(b.Gy0_生产工时)' => '生产工时',
+                'rtrim(b.Gy0_辅助工时)' => '辅助工时',
+                'rtrim(b.Gy0_班次安排)' => '班次安排',
+                'rtrim(b.工序备注)' => '排单备注',
+                'rtrim(b.Gy0_最早开工时间)' => '最早开工时间',
+                'rtrim(b.Gy0_sj1)' => '计划开工时间',
+                'rtrim(b.Gy0_sj2)' => '计划完工时间',
+                'rtrim(b.Gy0_yjno)' => 'yjno',
+                'rtrim(b.Gy0_gxh)' => 'gxh',
+                'rtrim(b.Gy0_gxmc)' => 'gxmc',
+                'rtrim(b.Gy0_ls)' => 'ls',
+                'rtrim(b.UniqId)' => 'UniqId',
+                'SUM(c.sczl_cl)' => '已完成'
             ])
-            ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_gxh = b.sczl_gxh','LEFT')
+            ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh')
+            ->join('设备_产量计酬 c','a.Gd_gdbh = c.sczl_gdbh AND b.Gy0_gxh = c.sczl_gxh','LEFT')
             ->where([
-                'a.Gy0_sbbh' => $machine,
-                'a.Gy0_sj1' => ['>','1900-01-01 00:00:00'],
-                'a.PD_WG' => '1900-01-01 00:00:00'
+                'b.Gy0_sbbh' => $machine,
+                'b.Gy0_sj1' => ['>','1900-01-01 00:00:00'],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'a.gd_statu' => '2-生产中'
             ])
-            ->where('a.Gy0_sj1','<','2099-01-01 00:00:00')
-            ->group('a.Gy0_gdbh')
+            ->where('b.Gy0_sj1','<','2099-01-01 00:00:00')
+            ->group('a.Gd_gdbh')
             ->select();
         foreach ($list as $key=>$value){
             $list[$key]['计划接货数'] = (int)round($value['计划接货数']/$value['ls']);
@@ -726,7 +728,7 @@ class Manufacture extends Api
                 '工序备注' => $value['remark'],
                 'Gy0_最早开工时间' => $value['start'] === ''?'1900-01-01 00:00:00':date('Y-m-d H:i:s',strtotime($value['start'])),
                 'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($value['projectTime'])),
-                'Gy0_sj2' => date('Y-m-d H:i:s',strtotime($param[0]['projectTime'])+(ceil($param[0]['ProductionHours'])+ceil($param[0]['AuxiliaryHours']))*3600),
+                'Gy0_sj2' => date('Y-m-d H:i:s',strtotime($value['projectTime'])+(ceil($value['ProductionHours'])+ceil($value['AuxiliaryHours']))*3600),
             ];
             $sql = \db('工单_工艺资料')
                 ->where('UniqId',$value['UniqId'])

+ 13 - 12
application/api/controller/OrderSuperLoss.php

@@ -123,11 +123,12 @@ class OrderSuperLoss extends Api
         if (empty($pages)){
             $pages = 1;
         }
-        $str = '';
-        if (empty($params['search'])){
-            $str = '/'.$date . '/' . $params['code'].'/'.$pages;
-        }
-        $is_have_cache = Cache::get('OrderSuperLoss/getList'.$str);
+//        $str = '';
+//        if (empty($params['search'])){
+//            $str = '/'.$date . '/' . $params['code'].'/'.$pages;
+//        }
+//        $is_have_cache = Cache::get('OrderSuperLoss/getList'.$str);
+        $is_have_cache = false;
         if ($is_have_cache === false){
             if (!empty($params['code'])){
                 $data = db('成品入仓')->alias('a')
@@ -292,11 +293,11 @@ class OrderSuperLoss extends Api
                 'data'=>$data,
                 'total' => $total
             ];
-            if ($str != false){
-                Cache::set('OrderSuperLoss/getList'.$str,$res,3600);
-            }
+//            if ($str != false){
+//                Cache::set('OrderSuperLoss/getList'.$str,$res,3600);
+//            }
         }else{
-            $res = Cache::get('OrderSuperLoss/getList'.$str);
+//            $res = Cache::get('OrderSuperLoss/getList'.$str);
         }
         $this->success('请求成功',$res);
     }
@@ -461,7 +462,7 @@ class OrderSuperLoss extends Api
         $total['total_fp'] = 0;
         $total['waste_quality'] = 0;
         $total['waste_intangible'] = 0;
-        $total['reward'] = 0;
+        $total['reward'] = 0; //超节损奖励数组
         //按工序打印
         if ($params['type'] == 1){
             $total['total_waste'] = 0;
@@ -518,7 +519,7 @@ class OrderSuperLoss extends Api
                 $total['waste_intangible'] += $gy_data[$k]['intangible_loss'];
                 $total['total_waste'] += $gy_data[$k]['total_waste'];
                 $total['loss'] += $gy_data[$k]['loss'];
-                $total['reward'] += $gy_data[$k]['工序超节损金额'];
+                $total['reward'] += floatval(str_replace(',', '', $gy_data[$k]['工序超节损金额']));
             }
             $total['reward'] = number_format($total['reward'],2);
             $data['gy_data'] = $gy_data;
@@ -666,7 +667,7 @@ class OrderSuperLoss extends Api
                 $total['total_fp'] += $item['sczl_zcfp'];
                 $total['waste_quality'] += $item['质检废'];
                 $total['waste_intangible'] += $item['无形损分摊'];
-                $total['reward'] += $gy_data[$i]['节损奖'];
+                $total['reward'] += floatval(str_replace(',', '', $gy_data[$i]['节损奖']));
                 $i++;
             }
             $total['reward'] = number_format($total['reward'],2);

+ 84 - 0
application/api/controller/ReportingWork.php

@@ -467,4 +467,88 @@ class ReportingWork extends Api
         }
         $this->success('请求成功',$list);
     }
+
+
+    /**
+     * 设置当前生产工单
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function MachineWorkOrderEdit()
+    {
+        if (Request::instance()->isPost() === false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        $list = \db('工单_基本资料')
+            ->alias('a')
+            ->field([
+                'RTRIM( b.Gy0_sj1 )' => 'sj1',
+                'RTRIM( b.Gy0_sj2 )' => 'sj2',
+                'RTRIM( b.UniqId )' => 'id'
+            ])
+            ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+            ->where([
+                'a.gd_statu' => '2-生产中',
+                'a.行号' => '1',
+                'b.Gy0_sbbh' => ['LIKE', '%' . $params['machine'] . '%'],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'b.Gy0_sj1' => ['>', '1900-01-01 00:00:00'],
+            ])
+            ->where('b.Gy0_sj1', '<', '2099-01-01 00:00:00')
+            ->group('a.Gd_gdbh,b.Gy0_gxh')
+            ->order('Gy0_sj1')
+            ->select();
+        $start = date('Y-m-d H:i:s', time());
+        if ($start < date('Y-m-d H:15:00', time())) {
+            $start = date('Y-m-d H:00:00', time());
+        } elseif ($start > date('Y-m-d H:45:00', time())) {
+            $start = date('Y-m-d H+1:00:00', time());
+        } else {
+            $start = date('Y-m-d H:30:00', time());
+        }
+        $data = $time = [];
+        $i = 0;
+        foreach ($list as $key => $value) {
+            if ($value['id'] === $params['UniqId']) {
+                $time = [
+                    'Gy0_sj1' => $start,
+                    'Gy0_sj2' => date('Y-m-d H:i:s', strtotime($start) + (strtotime($value['sj1']) - strtotime($value['sj2']))),
+                    'id' => $value['id']
+                ];
+                unset($list[$key]);
+            }
+        }
+        $arr = array_values($list);
+        $data[0] = $time;
+        foreach ($arr as $key => $value){
+            $workTime = [
+                'Gy0_sj1' => $data[$key]['Gy0_sj2'],
+                'Gy0_sj2' => date('Y-m-d H:i:s', strtotime($data[$key]['Gy0_sj2']) + (strtotime($value['sj1']) - strtotime($value['sj2']))),
+                'id' => $value['id']
+            ];
+            array_push($data,$workTime);
+        }
+        foreach ($data as $key=>$value){
+            unset($value['id']);
+            $sql = \db('工单_工艺资料')
+                ->where('UniqId',$data[$key]['id'])
+                ->fetchSql(true)
+                ->update($value);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->error('失败');
+        }else{
+            $this->success('成功');
+        }
+    }
 }