Browse Source

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

曹鹤洋 1 year ago
parent
commit
cc9a4272e1

+ 70 - 27
application/api/controller/Facility.php

@@ -163,7 +163,6 @@ class Facility extends Api
         $list = \db('制程检验_记录')
         $list = \db('制程检验_记录')
             ->where($where)
             ->where($where)
             ->field($field)
             ->field($field)
-            ->cache(true,86400)
             ->select();
             ->select();
         if (empty($list)){
         if (empty($list)){
             $this->success('未找到检验记录');
             $this->success('未找到检验记录');
@@ -804,6 +803,7 @@ class Facility extends Api
         }
         }
         $list = \db('设备_点检项目')
         $list = \db('设备_点检项目')
             ->where('部件名称',$param['unitName'])
             ->where('部件名称',$param['unitName'])
+            ->where('适用机型','like','%'.$param['machine'].'#%')
             ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
             ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
             ->select();
             ->select();
         if (empty($list)){
         if (empty($list)){
@@ -1096,8 +1096,8 @@ class Facility extends Api
                         b.`开工时间` 
                         b.`开工时间` 
                     FROM
                     FROM
                         `设备_产量采集` AS b
                         `设备_产量采集` AS b
-                        JOIN ( SELECT `设备编号`, MAX( `开工时间` ) AS `最新开工时间` FROM `设备_产量采集` GROUP BY `设备编号` ) AS c ON b.`设备编号` = c.`设备编号` 
-                        AND b.`开工时间` = c.`最新开工时间` 
+                        JOIN ( SELECT `设备编号`, MAX( `UniqId` ) AS `UniqId` FROM `设备_产量采集` GROUP BY `设备编号` ) AS c ON b.`设备编号` = c.`设备编号` 
+                        AND b.`UniqId` = c.`UniqId`  
                     ) AS d ON a.`设备编号` = d.`设备编号`
                     ) AS d ON a.`设备编号` = d.`设备编号`
                 WHERE
                 WHERE
                     a.`使用部门` = '{$workshop}' 
                     a.`使用部门` = '{$workshop}' 
@@ -1130,21 +1130,61 @@ class Facility extends Api
             $this->error('参数错误');
             $this->error('参数错误');
         }
         }
         $data = [];
         $data = [];
+        if ($param['start'] === ''){
+            if (date('Y-m-d H:i:s')>date('Y-m-d 08:30:00',time()) && date('Y-m-d H:i:s')<date('Y-m-d 20:30:00',time())){
+                $param['start'] = date('Y-m-d 08:30:00',time());
+            }elseif (date('Y-m-d H:i:s')>date('Y-m-d 20:30:00',time()) && date('Y-m-d H:i:s')<date('Y-m-d 23:59:59',time())){
+                $param['start'] = date('Y-m-d 20:30:00',time());
+            }else{
+                $param['start'] = date('Y-m-d 20:30:00',time()-86400);
+            }
+        }
+        $machineDetail = \db('设备_产量采集')
+            ->alias('a')
+            ->join('设备_基本资料 b','a.设备编号 = b.设备编号')
+            ->join('工单_工艺资料 c','a.工单编号 = c.Gy0_gdbh AND a.设备编号 = c.Gy0_sbbh')
+            ->join('工单_基本资料 d','a.工单编号 = d.Gd_gdbh')
+            ->field([
+                'rtrim(a.开工时间)' => '开工时间',
+                'rtrim(a.设备编号)' => '设备编号',
+                'rtrim(a.工单编号)' => '工单编号',
+                'rtrim(b.设备名称)' => '设备名称',
+                'rtrim(c.Gy0_gxh)' => '工序号',
+                'rtrim(c.Gy0_gxmc)' => '工序名称',
+                'rtrim(d.Gd_cpmc)' => '产品名称'
+            ])
+            ->where('a.设备编号', $param['machine'])
+            ->order('a.UniqId desc')
+            ->find();
+        $data['machine'] = [
+            '日期' => $machineDetail['开工时间'],
+            '设备' => $machineDetail['设备编号'].'-->'.$machineDetail['设备名称'],
+            '工单' => $machineDetail['工单编号'].'-->'.$machineDetail['产品名称'],
+            '工艺' => ($machineDetail['工序号']<10?'0'.$machineDetail['工序号']:$machineDetail['工序号']).'--'.$machineDetail['工序名称']
+        ];
         //机台状态时间
         //机台状态时间
         $startTime = \db('设备_产量采集')
         $startTime = \db('设备_产量采集')
             ->where('设备编号',$param['machine'])
             ->where('设备编号',$param['machine'])
             ->where('开工时间',$param['start'])
             ->where('开工时间',$param['start'])
             ->field('rtrim(时间) as 时间,当班产量,rtrim(当前状态) as 状态,MAX(时间) as 最大时间,MAX(当班产量) as 最大产量')
             ->field('rtrim(时间) as 时间,当班产量,rtrim(当前状态) as 状态,MAX(时间) as 最大时间,MAX(当班产量) as 最大产量')
-            ->order('UniqId')
             ->group('当前状态')
             ->group('当前状态')
-            ->find();
+            ->select();
         if (!empty($startTime)){
         if (!empty($startTime)){
-            $timeDifference = round((strtotime($startTime['最大时间'])-strtotime($startTime['时间']))/3600,2);
-            $data['timeDifference'] = $timeDifference;
-            $data['field'] = $startTime['最大产量']-$startTime['当班产量'];
+            foreach ($startTime as $key=>$value){
+                $data['timeDifference'][$key] = [
+                    '时间' => round((strtotime($value['最大时间'])-strtotime($value['时间']))/3600,2),
+                    '状态' => $value['状态'] = null?'待单':$value['状态'],
+                ];
+                if ($value['状态'] === '生产'){
+                    $data['当班产量'] = $value['最大产量']-$value['当班产量'];
+                }
+            }
         }else{
         }else{
-            $data['timeDifference'] = 0;
-            $data['field'] = 0;
+            $data['timeDifference'][0] = [
+                '时间' => 0,
+                '状态' => '待单'
+            ];
+            $data['当班产量'] = 0;
         }
         }
         //机台产能/时间明细
         //机台产能/时间明细
         $row = \db('设备_产量采集')
         $row = \db('设备_产量采集')
@@ -1153,7 +1193,7 @@ class Facility extends Api
             ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
             ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
             ->select();
             ->select();
         if (empty($row)){
         if (empty($row)){
-            $data['row'] = '';
+            $data['row'] = [];
         }
         }
         foreach ($row  as $key=>$value){
         foreach ($row  as $key=>$value){
             $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
             $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
@@ -1179,23 +1219,26 @@ class Facility extends Api
             ->field('rtrim(类别) as 类别,提交时间')
             ->field('rtrim(类别) as 类别,提交时间')
             ->select();
             ->select();
         $data['首件'] = $data['自检'] = $data['IPQC'] = [];
         $data['首件'] = $data['自检'] = $data['IPQC'] = [];
-        if (empty($list)){
-            $this->success('未找到检验记录');
-        }
-        foreach ($list as $key=>$value){
-            if ($value['类别'] == '现场巡查记录'){
-                array_push($data['首件'],$value['提交时间']);
-            }
-            if ($value['类别'] == '机台自检'){
-                array_push($data['自检'],$value['提交时间']);
-            }
-            if ($value['类别'] == 'IPQC检验'){
-                array_push($data['IPQC'],$value['提交时间']);
+        if (!empty($list)){
+            foreach ($list as $key=>$value){
+                if ($value['类别'] == '首件与过程确认'){
+                    array_push($data['首件'],$value['提交时间']);
+                }
+                if ($value['类别'] == '机台检验'){
+                    array_push($data['自检'],$value['提交时间']);
+                }
+                if ($value['类别'] == 'IPQC检验'){
+                    array_push($data['IPQC'],$value['提交时间']);
+                }
             }
             }
+            $data['首件'] = array_values(array_unique($data['首件']));
+            $data['自检'] = array_values(array_unique($data['自检']));
+            $data['IPQC'] = array_values(array_unique($data['IPQC']));
+        }else{
+            $data['首件'] = [];
+            $data['自检'] = [];
+            $data['IPQC'] = [];
         }
         }
-        $data['首件'] = array_values(array_unique($data['首件']));
-        $data['自检'] = array_values(array_unique($data['自检']));
-        $data['IPQC'] = array_values(array_unique($data['IPQC']));
         $this->success('成功',$data);
         $this->success('成功',$data);
     }
     }
 
 
@@ -1315,7 +1358,7 @@ class Facility extends Api
                 '印件号' => $value['yjno'],
                 '印件号' => $value['yjno'],
                 '工序名称' => $printName,
                 '工序名称' => $printName,
                 '流程单号' => $value['flow'],
                 '流程单号' => $value['flow'],
-                '设备编号' => $value['machine'],
+                '设备编号' => $value['machine'].'#',
                 '班组编号' => $startTime['班组编号'],
                 '班组编号' => $startTime['班组编号'],
                 '检验项目' => $value['item'],
                 '检验项目' => $value['item'],
                 '相关标准' => $value['standard'],
                 '相关标准' => $value['standard'],

+ 4 - 1
application/api/controller/ReportingWork.php

@@ -37,7 +37,10 @@ class ReportingWork extends Api
         $machine = $params['machine'].'#';
         $machine = $params['machine'].'#';
         $data = [];
         $data = [];
 //        $lastData = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
 //        $lastData = \db('设备_产量采集')->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){
         if ($lastData['UniqId'] < 160000000){
             $id = 160000000;
             $id = 160000000;
         }else{
         }else{

+ 179 - 7
application/api/controller/WorkOrder.php

@@ -1040,6 +1040,59 @@ class WorkOrder extends Api
         $this->success('成功',$data);
         $this->success('成功',$data);
     }
     }
 
 
+    /**
+     * 打印作业通知单->工单印件和工序获取
+     * @ApiMethod (GET)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function PrintCodeList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_印件资料')
+            ->field([
+                'rtrim(yj_Yjno)' => '印件号',
+                'rtrim(yj_yjmc)' => '印件名称'
+            ])
+            ->where('Yj_Gdbh',$param['workOrder'])
+            ->select();
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 打印作业通知单->工艺编号获取
+     * @ApiMethod (GET)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProcessCodeList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_工艺资料')
+            ->field('rtrim(Gy0_gxh) as 工序号')
+            ->where([
+                'Gy0_gdbh' => $param['workOrder'],
+                'Gy0_yjno' => $param['yjno']
+            ])
+            ->select();
+        $this->success('成功',$list);
+    }
     /**
     /**
      * 打印作业通知单
      * 打印作业通知单
      * @ApiMethod (POST)
      * @ApiMethod (POST)
@@ -1058,7 +1111,7 @@ class WorkOrder extends Api
         if (empty($param)){
         if (empty($param)){
             $this->error('参数错误');
             $this->error('参数错误');
         }
         }
-        $data = $this->workOrderDetailGet($param['workOrder']);
+        $data = $this->workOrderDetailGet($param['workOrder'],$param['yjno']);
         if (empty($data)){
         if (empty($data)){
             $this->success('未找到工单信息');
             $this->success('未找到工单信息');
         }
         }
@@ -1066,7 +1119,7 @@ class WorkOrder extends Api
         if (empty($materiel)){
         if (empty($materiel)){
             $this->success('未找到物料信息');
             $this->success('未找到物料信息');
         }
         }
-        $printDetail = $this->PrintDetailGet($param['workOrder']);
+        $printDetail = $this->PrintDetailGet($param['workOrder'],$param['yjno'],$param['gxh']);
         if (empty($printDetail)){
         if (empty($printDetail)){
             $this->success('未找到工艺信息');
             $this->success('未找到工艺信息');
         }
         }
@@ -1088,9 +1141,10 @@ class WorkOrder extends Api
      * @param $workOrder
      * @param $workOrder
      * @return mixed
      * @return mixed
      */
      */
-    public function workOrderDetailGet($workOrder)
+    public function workOrderDetailGet($workOrder,$yjno)
     {
     {
         $sql = "SELECT
         $sql = "SELECT
+                RTRIM( a.Gd_lx) AS  工单类型,
                 RTRIM( a.Gd_gdbh ) AS 生产批次号,
                 RTRIM( a.Gd_gdbh ) AS 生产批次号,
                 RTRIM( a.销售订单号 ) AS 销售订单号,
                 RTRIM( a.销售订单号 ) AS 销售订单号,
                 RTRIM( a.Gd_客户代号 ) AS 客户代号,
                 RTRIM( a.Gd_客户代号 ) AS 客户代号,
@@ -1121,7 +1175,7 @@ class WorkOrder extends Api
                 `工单_基本资料` AS a
                 `工单_基本资料` AS a
                 JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh 
                 JOIN `工单_印件资料` AS b ON b.Yj_Gdbh = a.Gd_gdbh 
             WHERE
             WHERE
-                a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1";
+                a.Gd_gdbh = '{$workOrder}' AND a.行号 = 1 AND b.yj_Yjno = '{$yjno}'";
         $list = Db::query($sql);
         $list = Db::query($sql);
         if (empty($list)){
         if (empty($list)){
             $this->success('未找到订单数据');
             $this->success('未找到订单数据');
@@ -1169,10 +1223,12 @@ class WorkOrder extends Api
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      * @throws \think\exception\DbException
      */
      */
-    public function PrintDetailGet($workOrder)
+    public function PrintDetailGet($workOrder,$yjno,$gxh)
     {
     {
         $where = [
         $where = [
             'Gy0_gdbh' => $workOrder,
             'Gy0_gdbh' => $workOrder,
+            'Gy0_yjno' => $yjno,
+            'Gy0_gxh'  => ['<=',$gxh]
         ];
         ];
         $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
         $filed = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc,
         rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
         rtrim(损耗系数) as 损耗系数,rtrim(Gy0_ls) as ls,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_计划损耗) as 计划损耗,
@@ -1233,7 +1289,18 @@ class WorkOrder extends Api
     }
     }
 
 
 
 
-    //新增工单
+    /**
+     * 新增工单->添加工单
+     * @ApiMethod (POST)
+     * @param 
+     * @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 WorkOrderAdd()
     public function WorkOrderAdd()
     {
     {
@@ -1244,7 +1311,97 @@ class WorkOrder extends Api
         if (empty($param)){
         if (empty($param)){
             $this->error('参数错误');
             $this->error('参数错误');
         }
         }
-
+        $num = \db('工单_基本资料')->where('Gd_gdbh',$param['gdbh'])->count();
+        $productDetail = \db('产品_基本资料')->where('产品编号',$param['cpdh'])->find();
+        $lastId = \db('工单_基本资料')->order('Uniqid desc')->value('Uniqid');
+        if ($lastId<1000000000){
+            $lastId = 1000000000;
+        }
+        $data = [
+            'Gd_lx' =>$param['zdgd'],
+            'Gd_生产分类' =>$param['sclx'],
+            '成本处理类别' =>'',
+            'Gd_gdbh' =>$param['gdbh'],
+            '行号' =>$num+1 ,
+            'Gd_客户代号' =>$param['khdh'],
+            'Gd_客户名称' =>$param['khmc'],
+            'Gd_khdh' =>$param['khdh'],
+            'Gd_khmc' =>$param['khmc'],
+            '客户料号' =>rtrim($productDetail['客户料号']),
+            '客户ERP编码' =>$param['erp'],
+            'Gd_cpdh' =>$param['cpdh'],
+            'Gd_cpmc' =>$param['cpmc'],
+            '成品代号' =>$param['cpdh'],
+            '成品名称' =>$param['cpmc'],
+            '产品版本号' =>$param['bbh'],
+            '销售订单号' =>$param['xsddh'],
+            '警语版面' =>$param['jybm'],
+            '码源数量' =>$param['mysl'],
+            '排产时库存' =>$param['kcdx'],
+            '投料大箱' =>$param['tldx'],
+            '投料率' =>$param['tll'],
+            '平均合格率' =>$param['hgl'],
+            '进程备注' =>$param['jcbz'],
+            'Gd_desc' =>$param['remark'],
+            '开单日期' =>date('Y-m-d H:i:s',time()),
+            '接单日期' =>$param['start'],
+            '交货日期' =>$param['end'],
+            '订单数量' =>$param['number'],
+            '计量单位' =>$param['tldw'],
+            '计划投料' =>$param['pztl'],
+            '实际投料' =>$param['wxz'],
+            '产品单价' =>0,
+            '入仓日期' =>'1900-01-01 00:00:00',
+            '工单入仓数量' =>0,
+            '工单制程废品' => 0,
+            '工单质检废品' => 0,
+            '工单无形损' => 0,
+            '工单计划损耗' => 0,
+            '工单完工日期' => $param['end'],
+            '投料确认' => '',
+            'gd_statu' => '3-计划中',
+            '直接人工' => 0,
+            '分摊人工' => 0,
+            '直接材料' => 0,
+            '考核直接材料' => 0,
+            '分摊材料' => 0,
+            '考核分摊材料' => 0,
+            '直接折旧' => 0,
+            '水电气费' => 0,
+            '分摊空调' => 0,
+            '分摊锅炉' => 0,
+            '分摊废气处理' => 0,
+            '分摊空压机' => 0,
+            '分摊鼓风机' => 0,
+            '分摊其他' => 0,
+            '待摊人工' => 0,
+            '待摊折旧' => 0,
+            '待摊场地租金' => 0,
+            '待摊其他费用' => 0,
+            '加工费' => 0,
+            '加工费单价' => 0,
+            '成本考核_胶印' => 0,
+            '成本考核_凹印' => 0,
+            '成本考核_丝印' => 0,
+            '成本考核_模切' => 0,
+            '成本考核_检验' => 0,
+            '印版费' => 0,
+            'V23制造成本' => 0,
+            'Prt_rq' => date('Y-m-d H:i:s',time()),
+            'Sys_id' => '',
+            'Sys_rq' => date('Y-m-d H:i:s',time()),
+            'Mod_rq' => date('Y-m-d H:i:s',time()),
+            'U8UID' => '',
+            'Uniqid' => $lastId+1,
+            '工序加工费' => 0,
+        ];
+        $sql= \db('工单_基本资料')->fetchSql(true)->insert($data);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
     }
     }
 
 
     /**
     /**
@@ -1306,4 +1463,19 @@ class WorkOrder extends Api
         }
         }
         $this->success('成功',$list);
         $this->success('成功',$list);
     }
     }
+
+
+    //新增印件资料->印件资料添加
+
+//    public function PrintDetailAdd()
+//    {
+//        if (Request::instance()->isPost() === false){
+//            $this->error('请求错误');
+//        }
+//        $param = Request::instance()->post();
+//        if (empty($param)){
+//            $this->error('参数错误');
+//        }
+//
+//    }
 }
 }