Selaa lähdekoodia

翌星单独页面

unknown 9 kuukautta sitten
vanhempi
sitoutus
57a238875f
2 muutettua tiedostoa jossa 3198 lisäystä ja 0 poistoa
  1. 2653 0
      application/api/controller/YxFaility.php
  2. 545 0
      application/api/controller/YxManufacture.php

+ 2653 - 0
application/api/controller/YxFaility.php

@@ -0,0 +1,2653 @@
+<?php
+
+namespace app\api\controller;
+
+
+use app\common\controller\Api;
+use think\Db;
+use think\Request;
+
+/**
+ * 设备运行跟踪
+ */
+
+class YxFaility extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+
+    /**
+     * 左侧菜单栏
+     * @ApiMethod (GET)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getTab()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+    //    if (isset($param['sort'])){
+    //        $where['使用部门'] = '智能车间';
+    //    }else{
+    //        $where['使用部门'] = ['<>','智能车间'];
+    //    }
+        $machineList = db('设备映射表')->column('MNmachine');
+        $where['设备编号'] = ['in',$machineList];
+        $data = [];
+        $date = date('Y-m-d 00:00:00',time()-3888000);
+        $department = \db('设备_基本资料')
+            ->distinct(true)
+            ->where('使用部门','<>','研发中心')
+            ->where('设备编组','<>','')
+            ->where('sys_sbID','<>','')
+            ->where($where)
+            ->order('设备编组')
+            ->column('rtrim(使用部门) as 使用部门');
+        if (empty($department)){
+            $this->success('为获取到机台数据');
+        }
+        $list = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('设备映射表 b','a.sczl_jtbh = b.MNmachine')
+            ->field([
+                'DISTINCT(a.sczl_rq)' => '时间',
+                'rtrim(b.YXmachine)' => '机台编号'
+            ])
+            ->where('sczl_rq','>',$date)
+            ->order('sczl_rq desc')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到机台生产记录');
+        }
+        foreach ($department as $value){
+            $machine = \db('设备_基本资料')
+                ->alias('a')
+                ->join('设备映射表 b','a.设备编号 = b.MNmachine')
+                ->where('a.使用部门',$value)
+                ->where('a.sys_sbID','<>','')
+                ->field('b.YXmachine as 设备编号,rtrim(设备名称) as 设备名称')
+                ->order('设备编号')
+                ->select();
+            foreach ($machine as $k=>$v){
+                $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
+                foreach ($list as $kk=>$vv){
+                    if ($v['设备编号'] === $vv['机台编号']){
+                        array_push($data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']],date('Y-m-d',strtotime($vv['时间'])));
+                    }
+                }
+            }
+        }
+        $this->success('成功',$data);
+    }
+
+
+    /**
+     * 机台每日产量
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $date 日期
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function chanLiang()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        $where = [
+            'sczl_jtbh' => $machine,
+            'sczl_rq' => date('Y-m-d H:i:s',strtotime($param['date'].' 00:00:00')),
+        ];
+        $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,
+        rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,
+        rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,IF(sczl_zcfp = 0, "",sczl_zcfp) as 制程废品,
+        IF(sczl_zccp = 0, "",sczl_zccp) as 制程次品,IF(sczl_前工序废 = 0, "",sczl_前工序废) as 前工序废,
+        IF(sczl_来料少数 = 0, "",sczl_来料少数) as 来料异常,IF(sczl_装版总工时 = 0, "",sczl_装版总工时) as 装版总工时,
+        IF(sczl_打样总工时 = 0, "",sczl_打样总工时) as 打样总工时,
+        IF(sczl_装版工时 = 0, "",sczl_装版工时) as 装版工时, IF(sczl_保养工时 = 0, "",sczl_保养工时) as 保养工时,
+        IF(sczl_打样工时 = 0, "",sczl_打样工时) as 打样工时,IF(sczl_异常停机工时 = 0, "",sczl_异常停机工时) as 异常总工时,
+        IF(sczl_设备运行工时 = 0, "",sczl_设备运行工时) as 通电工时,
+        IF(码开始行 = 0, "",码开始行) as 码开始行,IF(码结束行 = 0, "",码结束行) as 码结束行,
+        IF(码包 = 0, "",码包) as 码包,IF(主电表 = 0, "",主电表) as 主电表,IF(辅电表 = 0, "",辅电表) as 辅电表,
+        IF(sczl_ms = 0, "",sczl_ms) as 色度数,
+        rtrim(sys_id) as 用户,rtrim(sys_rq) as 更新时间,IF(sczl_异常工时1 = 0, "",sczl_异常工时1) as 异常补时,
+        IF(sczl_异常类型1 = 0, "",sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
+        sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,
+        sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
+        sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId,rtrim(sczl_工价系数) as 难度系数,
+        rtrim(sczl_dedh) as 定额代号';
+        //机台信息
+        $machineDetail = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
+        //组员信息
+        $list = \db('设备_产量计酬')->where($where)->field($field)->select();
+        $totalA = \db('设备_产量计酬')
+            ->where($where)
+            ->where('sczl_bzdh','like','A%')
+            ->field('SUM(sczl_cl) as 产量, SUM(sczl_zcfp) as 制程废品, SUM(sczl_zccp) as 制程次品, SUM(sczl_来料少数) as 来料异常, SUM(sczl_装版工时) as 装版工时, SUM(sczl_保养工时) as 保养工时, SUM(sczl_打样工时) as 打样工时,SUM(sczl_异常停机工时) as 异常工时,SUM(sczl_异常工时1) as 异常补时工时,SUM(sczl_设备运行工时) as 通电工时,SUM(sczl_前工序废) as 前工序废')
+            ->select();
+        $totalB = \db('设备_产量计酬')
+            ->where($where)
+            ->where('sczl_bzdh','like','B%')
+            ->field('SUM(sczl_cl) as 产量, SUM(sczl_zcfp) as 制程废品, SUM(sczl_zccp) as 制程次品, SUM(sczl_来料少数) as 来料异常, SUM(sczl_装版工时) as 装版工时, SUM(sczl_保养工时) as 保养工时, SUM(sczl_打样工时) as 打样工时,SUM(sczl_异常停机工时) as 异常工时,SUM(sczl_异常工时1) as 异常补时工时,SUM(sczl_设备运行工时) as 通电工时,SUM(sczl_前工序废) as 前工序废')
+            ->select();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            //产品名称
+            $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
+            if (!empty($productName)){
+                if (!empty($productName['成品名称'])){
+                    $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
+                    $list[$key]['cpmc'] = $productName['成品名称'];
+                }else{
+                    $list[$key]['产品名称'] = $value['工单编号'];
+                    $list[$key]['cpmc'] = '';
+                }
+            }else{
+                $list[$key]['产品名称'] = $value['工单编号'];
+                $list[$key]['cpmc'] = '';
+            }
+            $process = \db('工单_工艺资料')
+                ->where('Gy0_gdbh',$value['工单编号'])
+                ->where('Gy0_yjno',$value['yjno'])
+                ->where('Gy0_gxh',$value['gxh'])
+                ->field('rtrim(工价系数) as 工价系数,rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距')
+                ->find();
+            if (!empty($process)){
+                if ($value['难度系数'] == 0){
+                    $list[$key]['难度系数'] = $process['工价系数'];
+                }else{
+                    $list[$key]['难度系数'] = $process['工价系数'].'x'.$value['难度系数'];
+                }
+                $list[$key]['印刷方式'] = $process['印刷方式'].' '.$process['版距'];
+            }else{
+                $list[$key]['难度系数'] = '';
+                $list[$key]['印刷方式'] = '';
+            }
+            if ($value['yjno']<10){
+                $list[$key]['yjno'] = '0'.$value['yjno'];
+            }
+            if (empty($value['定额代号'])){
+                $list[$key]['千件工价'] = '';
+                $list[$key]['日定额'] = '';
+                $list[$key]['补产标准'] = '';
+            }else{
+                $row = \db('dic_lzde')->where('sys_bh',$value['定额代号'])->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额,rtrim(补产标准) as 补产标准')->find();
+                $list[$key]['千件工价'] = $row['千件工价'];
+                $list[$key]['日定额'] = $row['日定额'];
+                $list[$key]['补产标准'] = $row['补产标准'];
+            }
+            $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxmc'];
+            $list[$key]['备注'] = $value['bzdh'].'('.$value['num'].')'.date('H:i',strtotime($value['sj1'])).'<-->'.date('H:i',strtotime($value['sj2']));
+            for ($i=1;$i<11;$i++){
+                if (isset($value['sczl_bh'.$i])){
+                    $name = \db('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
+                    if (isset($name['name'])){
+                        $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
+                    }
+                }
+                unset($list[$key]['sczl_bh'.$i],$list[$key]['sczl_rate'.$i]);
+            }
+        }
+        $list['totalA'] = $totalA[0]['产量'];
+        $list['totalB'] = $totalB[0]['产量'];
+        $list['制程废品A'] = $totalA[0]['制程废品'];
+        $list['制程废品B'] = $totalB[0]['制程废品'];
+        $list['制程次品A'] = $totalA[0]['制程次品'];
+        $list['制程次品B'] = $totalB[0]['制程次品'];
+        $list['来料异常A'] = $totalA[0]['来料异常'];
+        $list['来料异常B'] = $totalB[0]['来料异常'];
+        $list['装版工时A'] = $totalA[0]['装版工时'];
+        $list['装版工时B'] = $totalB[0]['装版工时'];
+        $list['保养工时A'] = $totalA[0]['保养工时'];
+        $list['保养工时B'] = $totalB[0]['保养工时'];
+        $list['打样工时A'] = $totalA[0]['打样工时'];
+        $list['打样工时B'] = $totalB[0]['打样工时'];
+        $list['异常工时A'] = $totalA[0]['异常工时'];
+        $list['异常工时B'] = $totalB[0]['异常工时'];
+        $list['异常补时工时A'] = $totalA[0]['异常补时工时'];
+        $list['异常补时工时B'] = $totalB[0]['异常补时工时'];
+        $list['通电工时A'] = $totalA[0]['通电工时'];
+        $list['通电工时B'] = $totalB[0]['通电工时'];
+        $list['前工序废A'] = $totalA[0]['前工序废'];
+        $list['前工序废B'] = $totalB[0]['前工序废'];
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 当日制程检验记录
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $date   日期
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Inspect()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        // 获取当前时间
+        $current_time = time();
+        // 设置时间范围
+        $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
+        $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
+        $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
+        $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
+        $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $startTime = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $startTime = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $startTime = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
+            $startTime = date('Y-m-d') . ' 20:30:00';
+        }
+        if (empty($machine)){
+            $this->error('参数错误');
+        }
+        $where = [
+            '设备编号' => $machine,
+            '开工时间' => $startTime,
+            '类别' => ['in',['IPQC检验','机台检验']],
+        ];
+        $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,提交时间,rtrim(检验项目) as 检验项目';
+        $list = \db('制程检验_记录')
+            ->where($where)
+            ->field($field)
+            ->select();
+        if (empty($list)){
+            $this->success('未找到检验记录');
+        }
+        $data = [];
+        foreach ($list as $key=>$value)
+        {
+            $data['item'][$key] = $value['检验项目'];
+            $data['InspectionTime'][$key] = date('H:i',strtotime($value['提交时间']));
+            $data['工单编号'][$key] = $value['工单编号'];
+        }
+        $data['item'] = array_unique($data['item']);
+        $data['InspectionTime'] = array_values(array_unique($data['InspectionTime']));
+        $data['工单编号'] = array_values(array_unique($data['工单编号']));
+        foreach ($data['工单编号'] as $key => $value){
+            foreach ($data['item'] as $k=>$v){
+                $time = '';
+                foreach ($list as $kk=>$vv){
+                    if ($vv['工单编号'] === $value && $vv['检验项目'] === $v){
+                        $time = $time.date('H:i',strtotime($vv['提交时间'])).',';
+                        $data['row'][$key][$k] = [
+                            '工单编号' => $value,
+                            '印件号' => $vv['印件号'],
+                            '工序名称' => $vv['工序名称'],
+                            '检验项目' => $v,
+                            'time' => substr($time,0,-1),
+                        ];
+                    }
+                }
+            }
+            $data['row'][$key] = array_values($data['row'][$key]);
+        }
+        unset($data['item'],$data['工单编号']);
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 设备生产中工单信息
+     * @ApiMethod (GET)
+     * @param string $machine   机台编号
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Production()
+    {
+        if (Request::instance()->isGet() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->param();
+        if (!isset($params['machine']) || empty($params['machine'])) {
+            $this->error('参数错误');
+        }
+        $machine = db('设备映射表')
+            ->where('YXmachine',$params['machine'])
+            ->value('MNmachine');
+        $machineCode = \db('dic_lzde')->where('适用机型',$machine)->value('sys_bh');
+        $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+        $list = [];
+        $row = [];
+        if (!empty($data['工单编号'])){
+            $endTime = \db('工单_工艺资料')
+                ->where('Gy0_gdbh',$data['工单编号'])
+                ->where('Gy0_yjno',$data['印件号'])
+                ->where('Gy0_gxh',$data['工序号'])
+                ->find();
+            $list['工单编号'] = $data['工单编号'];
+            if (!empty($endTime)){
+                    $list['印件号'] = $data['印件号'];
+                    $name = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品名称');
+                    $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品代号');
+                    $list['产品名称'] = rtrim($name);
+                    $list['产品代号'] = rtrim($code);
+                    $list['工序名称'] = $data['工序名称'];
+            }
+            $list['状态'] = rtrim($data['当前状态']);
+            $list['开工时间'] = $data['开工时间'];
+        }else{
+            $list['工单编号'] = '';
+            $list['印件号'] = 0;
+            $list['产品名称'] = '';
+            $list['工序名称'] = '';
+            $list['产品代号'] = '';
+            $list['状态'] = '';
+            $list['开工时间'] = '';
+        }
+        $list['班组编号'] = rtrim($data['班组编号']);
+        $list['班组Id'] = rtrim($data['班组ID']);
+        $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
+        rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
+        rtrim(sczl_bh10) as bh10")->find();
+        if (!empty($class)){
+            for ($i=1;$i<11;$i++) {
+                if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
+                    $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
+                    $row[$i] = [
+                        '编号' => $class['bh' . $i],
+                        '姓名' => $name['姓名']
+                    ];
+                }
+            }
+            $row = array_values($row);
+        }
+        $list['班组成员'] = $row;
+        $list['定额代号'] = $machineCode;
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 设备工作清单
+     * @ApiMethod (GET)
+     * @param string $machine 机台编号
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function EquipmentWorklist()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        if (empty($machine)){
+            $this->error('参数错误');
+        }
+        $orderList = \db('工单_工艺资料')
+            ->alias('a')
+//            ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','LEFT')
+            ->join('工单_基本资料 c','a.Gy0_gdbh = c.Gd_gdbh')
+            ->join('工单_印件资料 d','a.Gy0_gdbh = d.Yj_Gdbh AND a.Gy0_yjno = d.yj_Yjno')
+            ->field('a.Gy0_gdbh as gdbh,rtrim(a.质量要求) as 质量信息,a.Gy0_yjno as yjno,a.Gy0_gxh as gxh,a.Gy0_sbbh as sbbh,
+    rtrim(a.Gy0_gxmc) as gxmc,rtrim(a.Add_gxmc) as add_gxmc,a.Gy0_辅助工时 as 装版工时,a.Gy0_小时产能 as 工序产能,a.Gy0_生产工时 as 计划工时,
+    a.Gy0_sj1 as sj1,a.Gy0_sj2 as sj2,rtrim(a.工序备注) as 排产备注,d.yj_yjmc as 印件名称,c.成品名称 as 产品名称,c.成品代号 as 产品代号,
+    a.Gy0_计划接货数 as 计划接货数,a.Gy0_ls as ls,a.Gy0_班次安排 as 班组,a.UniqId as UniqId,a.Gy0_最早开工时间 as 最早开工时间')
+            ->where('a.Gy0_sbbh','like','%'.$machine.'%')
+            ->where('a.PD_WG','1900-01-01 00:00:00')
+            ->where('a.Gy0_sj1','<>','1900-01-01 00:00:00')
+            ->where('c.gd_statu','2-生产中')
+            ->group('a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh')
+            ->order('a.Gy0_sj1')
+            ->select();
+        if (!empty($orderList)){
+            $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
+            foreach ($orderList as $key=>$value){
+                $machineList = explode(' ',$value['sbbh']);
+
+                $cl_data = \db('设备_产量计酬')
+                    ->field('SUM(sczl_cl) as 已完成,SUM(sczl_zcfp) as 制程废品')
+                    ->where('sczl_gdbh',$value['gdbh'])
+                    ->where('sczl_yjno',$value['yjno'])
+                    ->where('sczl_gxh',$value['gxh'])
+                    ->select();
+                $orderList[$key]['status'] = 0;
+                if (!empty($data)){
+                    if ($value['gdbh'] === $data['工单编号'] && $value['yjno'] === $data['印件号'] && $value['gxh'] === $data['工序号']) {
+                        $orderList[$key]['status'] = 1;
+                    }
+                }
+
+                $orderList[$key]['工单编号|质量信息'] = $value['gdbh'].'|'.$value['质量信息'];
+                $orderList[$key]['印件号'] = $value['yjno'];
+                $orderList[$key]['工序号'] = $value['gxh'];
+                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'].'-'.$value['印件名称'];
+                $orderList[$key]['工序名称'] = $orderList[$key]['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
+                if ((int)$cl_data[0]['制程废品'] === 0){
+                    $orderList[$key]['计划产量/已完成'] = (int)$value['计划接货数'].'/'.$cl_data[0]['已完成']=null?'':(int)$cl_data[0]['已完成'];
+                }else{
+                    $orderList[$key]['计划产量/已完成'] = (int)$value['计划接货数'].'/'.$cl_data[0]['已完成']=null?'':(int)$cl_data[0]['已完成'].'('.$cl_data[0]['制程废品'].')';
+                }
+
+                $orderList[$key]['计划生产时段'] =substr($value['sj1'],5,5).' '.substr($value['sj1'],11,5).'<-->'.substr($value['sj2'],5,5).' '.substr($value['sj2'],11,5);
+                unset($orderList[$key]['gdbh'],$orderList[$key]['质量信息'],$orderList[$key]['gxh'],$orderList[$key]['yjno'],$orderList[$key]['gxmc'],$orderList[$key]['add_gxmc'],$orderList[$key]['计划接货数'],$orderList[$key]['已完成'],$orderList[$key]['印件名称'],$orderList[$key]['ls'],$orderList[$key]['制程废品']);
+                if (in_array($machine,$machineList) === false){
+                    unset($orderList[$key]);
+                }
+            }
+            $data = array_values($orderList);
+            $this->success('成功',$data);
+        }else{
+            $this->error('未找到数据');
+        }
+
+    }
+
+
+
+    /**
+     * 工序、印件、完成数量
+     * @ApiMethod (GET)
+     * @param string $workOrder  工单编号
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Procedure()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $workOrder = input('Gd_gdbh');
+        $data = [];
+        if (!empty($workOrder)){
+            //右边工艺及完成数量
+            $Process = \db('设备_产量计酬')->where('sczl_gdbh',$workOrder)
+                ->distinct(true)->order('sczl_gxh')
+                ->column('sczl_gxh');
+            foreach ($Process as $k=>$v){
+                $res= \db('设备_产量计酬')->where('sczl_gdbh',$workOrder)
+                    ->where('sczl_gxh',$v)
+                    ->field('rtrim(sczl_yjno) as sczl_yjno,rtrim(sczl_gxmc) as sczl_gxmc')
+                    ->find();
+                if ($res['sczl_yjno']<10){
+                    $res['sczl_yjno'] = '0'.$res['sczl_yjno'];
+                }
+                $processList['process'] = $res['sczl_yjno'].'-'.$res['sczl_gxmc'];
+                $processList['completed'] = \db('设备_产量计酬')
+                    ->where('sczl_gdbh',$workOrder)
+                    ->where('sczl_gxh',$v)
+                    ->count('DISTINCT sczl_num');
+                array_push($data,$processList);
+            }
+        }
+        $this->success('成功',$data);
+    }
+
+
+    /**
+     * 班组人员及分配比例
+     * @ApiMethod (GET)
+     * @param string $machine 机台编号
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function Team()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+         $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        if (empty($machine)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'sczl_jtbh' => $machine,
+        ];
+        $field = 'rtrim(sczl_bzdh) as 班组号,rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
+        rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
+        rtrim(sczl_bh10) as bh10,rtrim(sczl_rate1) as rate1,rtrim(sczl_rate2) as rate2,rtrim(sczl_rate3) as rate3,rtrim(sczl_rate4) as rate4,
+        rtrim(sczl_rate5) as rate5,rtrim(sczl_rate6) as rate6,rtrim(sczl_rate7) as rate7,rtrim(sczl_rate8) as rate8,
+        rtrim(sczl_rate9) as rate9,rtrim(sczl_rate10) as rate10,rtrim(UniqId) as ID';
+        $team = \db('设备_产量计酬')
+            ->where('sczl_jtbh',$machine)
+            ->field($field)
+            ->order('UniqId desc')
+            ->find();
+        $list = \db('设备_班组资料')->where($where)->field($field)->select();
+        $data = [];
+        foreach ($list as $k=>$v){
+            if ($team == $v){
+                $data[$k]['status'] = 1;
+            }else{
+                $data[$k]['status'] = 0;
+            }
+            $data[$k]['ID'] = $v['ID'];
+            $data[$k]['班组号'] = $v['班组号'];
+            for ($i=1;$i<11;$i++){
+                if ($v['bh'.$i] != ''){
+                    $name = \db('人事_基本资料')->where('员工编号',$v['bh'.$i])->field('rtrim(员工姓名) as 姓名')->find();
+                    if ($v['rate'.$i] > 0){
+                        $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' ('.number_format($v['rate'.$i]*100,2).'%'.')';
+                    }else{
+                        $data[$k][$i-1] = $v['bh'.$i].' '.$name['姓名'].' (0.00%'.')';
+                    }
+
+                }
+            }
+        }
+        $this->success('成功',$data);
+    }
+
+
+    /**
+     * 当班产量明细
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $workOrder  工单编号
+     * @param string $team   班次
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function OutputDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        $machine = $param['machine'];
+        $workOrder = $param['Gd_gdbh'];
+        $team = substr($param['team'],0,1);
+        if (empty($machine) || empty($team)){
+            $this->success('');
+        }
+        $sczlTime = date('Y-m-d H:i:s',time());
+        if ($sczlTime>date('Y-m-d 00:00:00') && $sczlTime<date('Y-m-d 08:30:00')){
+            $time = date('Y-m-d 00:00:00',time()-86400);
+        }else{
+            $time = date('Y-m-d 00:00:00');
+        }
+        $where = [
+            'sczl_jtbh' => $machine,
+            'sczl_bzdh' => ['like',$team.'%'],
+            'sczl_rq' => $time,
+        ];
+        $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_num) as 流程单号,rtrim(sczl_dedh) as dedh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as 标牌号,rtrim(sczl_cl) as 产量,
+        rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,rtrim(sczl_装版工时) as 装版工时,
+        rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,rtrim(sczl_异常停机工时) as 异常停机工时,rtrim(sczl_设备运行工时) as 通电工时,
+        rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度,
+        rtrim(sczl_sj1) as sj1,rtrim(sczl_sj2) as sj2,rtrim(UniqId) as UniqId,rtrim(sczl_bh98) as 拉料,rtrim(sczl_ls) as ls';
+        $list = \db('设备_产量计酬')->where($where)->field($field)->order('UniqId desc')->select();
+        if (!empty($list)){
+            foreach ($list as $k=>$v){
+                $name = \db('工单_印件资料')->where('Yj_Gdbh',$v['工单编号'])->where('yj_Yjno',$v['yjno'])->field('rtrim(yj_yjmc) as cpmc')->find();
+                if ($v['yjno']<10){
+                    $list[$k]['yjno'] = '0'.$v['yjno'];
+                }
+                if (!empty($v['拉料'])){
+                    $list[$k]['拉料姓名'] = \db('人事_基本资料')->where('员工编号',$v['拉料'])->value('rtrim(员工姓名) as 员工姓名');
+                }
+                if (isset($list[$k]['拉料姓名']) === false){
+                    $list[$k]['拉料姓名'] = '';
+                }
+                $list[$k]['印件及工序'] = $list[$k]['yjno'].'-'.$v['gxmc'];
+                $list[$k]['生产时间段'] = substr($v['sj1'],5,5).' '.substr($v['sj1'],11,5).'<-->'.substr($v['sj2'],5,5).' '.substr($v['sj2'],11,5);
+                $list[$k]['产品名称'] = $name['cpmc'];
+            }
+            $field1 = 'SUM(sczl_cl) as 产量,SUM(sczl_zcfp) as 制程废品,SUM(sczl_zccp) as 制程次品,SUM(sczl_前工序废) as 前工序废,
+        SUM(sczl_来料少数) as 来料异常,SUM(sczl_装版工时) as 装版工时,SUM(sczl_保养工时) as 保养工时,SUM(sczl_打样工时) as 打样工时,
+        SUM(sczl_异常停机工时) as 异常停机工时,SUM(sczl_设备运行工时) as 通电工时,SUM(码开始行) as 码开始行,SUM(码结束行) as 码结束行,
+        SUM(码包) as 码包,SUM(主电表) as 主电表,SUM(辅电表) as 辅电表';
+            $total = \db('设备_产量计酬')->where($where)->field($field1)->order('UniqId desc')->select();
+            $total[0]['版数'] = count($list);
+            $list['total'] = $total[0];
+        }
+
+
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 检验记录
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $workOrder  工单编号
+     * @param string $team   班次
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function InspectionRecord()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求失败');
+        }
+       $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        $machine = $param['machine'];
+        $workOrder = $param['Gd_gdbh'];
+        $team = substr($param['team'],0,1);
+        if (empty($machine) || empty($workOrder) || empty($team)){
+            $this->success('');
+        }
+        $where = [
+            '设备编号' => $machine,
+            '工单编号' => $workOrder,
+            '班组编号' => $team,
+            '类别' => ['in',['IPQC检验','机台检验']],
+        ];
+        //检验项目筛选
+        $item = \db('制程检验_记录')->where($where)->distinct(true)->column('rtrim(检验项目)');
+        //检验时间
+        $InspectionTime = \db('制程检验_记录')->where($where)->distinct(true)->column('提交时间');
+        foreach ($InspectionTime as $k=>$v){
+            $InspectionTime[$k] = date('H:i',strtotime($v));
+        }
+        //检测记录详情
+        $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称';
+        $nameDetail = \db('制程检验_记录')->where($where)->field($field)->find();
+        $data = [];
+        //检测数据
+        foreach ($item as $key=>$value){
+            $SubmissionTime = \db('制程检验_记录')->where($where)
+                ->where('检验项目',$value)
+                ->where('检验结果','合格')
+                ->field('rtrim(提交时间) as 提交时间')
+                ->select();
+            $time = [];
+            foreach ($SubmissionTime as $k=>$v){
+                $time[$k] = date('H:i',strtotime($v['提交时间']));
+            }
+            $data[$key] = [
+                '工单编号' => $nameDetail['工单编号'],
+                '印件号' => $nameDetail['印件号'],
+                '工序名称' => $nameDetail['工序名称'],
+                '检验项目' => $value,
+                'inspectresult' => implode(',',$time),
+            ];
+        }
+        $data['inspectiontime'] = $InspectionTime;
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 管理人员现场巡检记录->展示
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function FieldInspectionRecord()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+//        $date = date('Y-m-d H:i:s',time());
+//        if (empty($param['start'])){
+//            $startTime = date('Y-m-d 08:30:00',time());
+//        }else{
+//            $startTime = date('Y-m-d H:i:s',strtotime($param['start']));
+//        }
+//        if ($date<$startTime){
+//            $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
+//        }
+        // 获取当前时间
+        $current_time = time();
+        // 设置时间范围
+        $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
+        $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
+        $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
+        $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
+        $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $startTime = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $startTime = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $startTime = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
+            $startTime = date('Y-m-d') . ' 20:30:00';
+        }
+        $where = [
+            '工单编号' => $param['workOrder'],
+            '开工时间' => $startTime,
+            '类别' => '现场巡查记录',
+            '班组编号' => ['like',substr($param['team'],0,1).'%']
+        ];
+        $filed = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,rtrim(流程单号) as 流程单号,
+        rtrim(设备编号) as 设备编号,rtrim(班组编号) as 班组编号,rtrim(检验项目) as 现场管理人员,rtrim(检验备注) as 检验备注,
+        rtrim(提交时间) as 提交时间,rtrim(开工时间) as 开工时间';
+        $list = \db('制程检验_记录')->where($where)
+            ->field($filed)
+            ->select();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            $number = floor((strtotime($value['提交时间'])-strtotime($value['开工时间']))/(15*60));
+            $list[$key]['归属时段'] = $value['开工时间'];
+            $list[$key]['分钟差数'] = $number;
+            if ($number != 0){
+                $list[$key]['归属时段'] = date('Y-m-d H:i:s',strtotime($value['开工时间'])+$number*15*60);
+            }
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 设备点检->左侧菜单栏
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     */
+    public function SpotCheckItem()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('设备_点检项目')
+            ->where('适用机型','LIKE','%;'.$machine.';%')
+            ->distinct(true)
+            ->column('rtrim(部件名称) as 部件名称','部件编号');
+        if (empty($list)){
+            $this->success('');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 设备点检->检测项目
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function  InspectionItem()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $machine = db('设备映射表')
+            ->where('YXmachine',$param['machine'])
+            ->value('MNmachine');
+        $list = \db('设备_点检项目')
+            ->where('部件名称',$param['unitName'])
+            ->where('适用机型','like','%'.$machine.'%')
+            ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到检测项目');
+        }
+        $this->success('成功',$list);
+    }
+
+
+    /**
+     * 设备点检->检测记录添加
+     * @ApiMethod (POST)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public  function InspectionItemAdd()
+    {
+        if (Request::instance()->isPost()  === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $lastNumber =  \db("设备_点检记录")->field('Uniqid as ID')->order('Uniqid desc')->find()['ID'];
+        if (empty($lastNumber)){
+            $lastId = 0;
+        }else{
+            $lastId = $lastNumber;
+        }
+        $row = [];
+        foreach ($param as $key=>$value){
+            $unitCode = \db('设备_点检项目')->where('部件名称',$value['unitName'])->field('rtrim(部件编号) as 部件编号')->find();
+            $row[$key] = [
+                '日期' => date('Y-m-d 00:00:00',time()),
+                '班组编号' => $value['team'],
+                '点检设备' => $value['machine'],
+                '部件编号' => $unitCode['部件编号'],
+                '部件名称' => $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'  => date('Y-m-d H:i:s',time()),
+                'Uniqid'  => $lastId+$key+1
+            ];
+
+        }
+        $sql = \db('设备_点检记录')->fetchSql(true)->insertAll($row);
+        $res = Db::query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 机台印版领用->左侧菜单
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     */
+    public function PrintGetTab()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $productCode = $param['productCode'];
+        $sql = "SELECT DISTINCT(RTRIM(b.`名称`)) as `印版分类`,RTRIM(b.`编号`) as `编号` FROM `产品_印版资料` as a
+                JOIN `物料_存货结构` as b ON b.`编号` = SUBSTRING(a.`存货编码`,1,4)
+                WHERE a.YB_Cpdh = '{$productCode}'";
+        $res = Db::query($sql);
+        if (empty($res)){
+            $this->success('');
+        }
+        $this->success('成功',$res);
+    }
+
+    /**
+     * 机台印版领用记录->数据详情
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     */
+    public function PrintDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求失败');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $productCode = $param['productCode'];
+        $code = $param['code'].'%';
+        $workOrder = $param['workOrder'];
+        $sql = "SELECT 
+                    RTRIM(a.`存货编码`) AS `存货编码`,
+                    RTRIM(c.`物料名称`) AS `存货名称`,
+                    RTRIM(b.`印版名称`) AS `印版名称`,
+                    RTRIM(b.`供方批号`) AS `供方批号`,
+                    RTRIM(b.`制造日期`) AS `制造日期`,
+                    SUM(d.`Yb_印数`) AS `印数`,
+                    RTRIM(e.`名称`) AS `印版类别`,
+                    SUBSTRING(a.YB_Cpdh, 1, 4) AS `客户编号`,
+                    RTRIM(f.`Gd_客户名称`) AS `客户名称`,
+                    RTRIM(a.YB_Cpdh) AS `产品编号`,
+                    RTRIM(f.Gd_cpmc) AS `产品名称`,
+                    d.UniqID AS UniqId,
+                    MAX(CASE 
+                        WHEN d.`Yb_领用日期` IS NOT NULL AND d.`Yb_退还日期` IS NULL THEN d.`Yb_工单编号`
+                        ELSE NULL 
+                    END) AS `工单编号`
+                FROM `产品_印版资料` a 
+                JOIN `物料_存货编码` c ON c.`物料代码` = a.`存货编码`
+                JOIN `物料_存货结构` e ON e.`编号` = (
+                    CASE 
+                        WHEN a.`存货编码` REGEXP '[A-Za-z]' 
+                        THEN SUBSTRING(a.`存货编码`, 1, 5)
+                        ELSE SUBSTRING(a.`存货编码`, 1, 4) 
+                    END
+                )
+                JOIN `工单_基本资料` f ON a.YB_Cpdh = f.Gd_cpdh
+                LEFT JOIN `产品_印版库` b ON b.`存货编码` = a.`存货编码`
+                    AND b.`报废日期` = '1900-01-01 00:00:00'
+                LEFT JOIN `工单_印版领用记录` d ON d.`Yb_供方批号` = b.`供方批号`
+                    AND d.`Yb_工单编号` IS NOT NULL
+                WHERE 
+                    a.YB_Cpdh = '{$productCode}' 
+                    AND a.`存货编码` LIKE '{$code}'
+                    AND f.Gd_gdbh = '{$workOrder}'
+                GROUP BY 
+                    a.`存货编码`,
+                    c.`物料名称`,
+                    b.`印版名称`,
+                    b.`供方批号`,
+                    b.`制造日期`,
+                    e.`名称`,
+                    f.`Gd_客户名称`,
+                    a.YB_Cpdh,
+                    f.Gd_cpmc
+                ORDER BY a.`存货编码`";
+        $list = Db::query($sql);
+        if (empty($list)){
+            $this->success('');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 换型清场->左侧菜单栏
+     * @ApiMethod  (GET)
+     * @param  void
+     * @return void
+     */
+    public function remodelGetTab()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $date = date('Y-m-d 00:00:00',time()-3456000);
+        $nowTime = date('Y-m-d H:i:s',time());
+        $list = \db('设备_基本资料')->where('使用状态',1)->order('设备编号')->column('设备编号');
+        if (empty($list)){
+            $this->error('失败');
+        }
+        $sql = "SELECT RTRIM(a.`设备编号`) as `设备编号`,RTRIM(b.`日期`) as `日期`,RTRIM(b.UniqId) as UniqId 
+                FROM `设备_基本资料` as a 
+                LEFT JOIN `制程_换型清场` as b ON b.`机台编号` = a.`设备编号`
+                WHERE b.`日期` > '{$date}' AND b.日期 < '{$nowTime}' AND b.`工单编号A` <> '' AND b.`工单编号B` <> '' ORDER BY b.`UniqId`";
+        $res = Db::query($sql);
+        $data = $result = [];
+        foreach ($list as $key=>$value){
+            $data[$value] = $result[$value]= $time = [];
+            foreach ($res as $k=>$v){
+                if ($value === $v['设备编号']){
+                    $row = [
+                        '日期' => $v['日期'],
+                        'id' => $v['UniqId']
+                    ];
+                    array_push($data[$value],$row);
+
+                }
+            }
+            foreach ($data[$value] as $m=>$n){
+                $time[$m] = $n['日期'];
+            }
+            $time = array_values(array_unique($time));
+            foreach ($time as $kk=>$vv){
+                $i=1;
+                foreach ($data[$value] as $kkk=>$vvv){
+                    if ($kkk>=$kk  && $vv === $vvv['日期']){
+                        array_push($result[$value],date('Y-m-d',strtotime($vv)).'第'.$i.'次换型/'.$vvv['id']);
+                        $i++;
+                    }
+                }
+            }
+        }
+        $this->success('成功',$result);
+    }
+
+    /**
+     * 换型清场->详情
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function RemodelDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $field = 'rtrim(日期) as 日期,rtrim(班组) as 班组,rtrim(机台编号) as 机台编号,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
+        rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包B,
+        rtrim(清场项目A) as 项目1,rtrim(清场项目B) as 项目2,rtrim(清场项目C) as 项目3,rtrim(清场项目D) as 项目4,rtrim(清场项目E) as 项目5,
+        rtrim(机长) as 机长,rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员';
+        $list = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->field($field)->find();
+        if (empty($list)){
+            $this->success('未找到该条清场记录');
+        }
+        $list['日期'] = date('Y-m-d',strtotime($list['日期']));
+        $printNameA = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号A'])->field('rtrim(yj_yjmc) as yjmc')->find();
+        if (empty($printNameA)){
+            $list['印件名称A'] = '';
+        }else{
+            $list['印件名称A'] = $printNameA['yjmc'];
+        }
+        $printNameB = \db('工单_印件资料')->where('Yj_Gdbh',$list['工单编号B'])->field('rtrim(yj_yjmc) as yjmc')->find();
+        if (empty($printNameB)){
+            $list['印件名称B'] = '';
+        }else{
+            $list['印件名称B'] = $printNameB['yjmc'];
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 换型清场->当前设备清场记录
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ModelChangeRecord()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $date = date('Y-m-d 00:00:00',time()-3888000);
+        $nowTime = date('Y-m-d H:i:s',time());
+        $where = [
+            '日期' =>['between',[$date,$nowTime]],
+            '机台编号' => $param['machine'],
+            '工单编号A' => ['<>',''],
+            '工单编号B' => ['<>',''],
+        ];
+        $field = "rtrim(日期) as 日期,rtrim(机台编号) as 机台编号,rtrim(班组) as 班组,rtrim(工单编号A) as 工单编号A,rtrim(印件工序A) as 印件工序A,
+        rtrim(码包号A) as 码包号A,rtrim(工单编号B) as 工单编号B,rtrim(印件工序B) as 印件工序B,rtrim(码包号B) as 码包号B,rtrim(清场项目A) as 清场项目A,
+        rtrim(清场项目B) as 清场项目B,rtrim(清场项目C) as 清场项目C,rtrim(清场项目D) as 清场项目D,rtrim(清场项目E) as 清场项目E,rtrim(机长) as 机长,
+        rtrim(班长) as 班长,rtrim(质量巡查员) as 质量巡查员,rtrim(sys_rq) as 创建时间,rtrim(UniqId) as UNIQID";
+        $list = \db('制程_换型清场')
+            ->where($where)
+            ->field($field)
+            ->select();
+        if (empty($list)){
+            $this->success('未找到换型记录');
+        }
+        foreach ($list as $key=>$value){
+            $printNameA = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号A'])->value('rtrim(yj_yjmc) as yjmc');
+            if (empty($printNameA)){
+                $list[$key]['印件名称A'] = '';
+            }else{
+                $list[$key]['印件名称A'] = $printNameA;
+            }
+            $printNameB = \db('工单_印件资料')->where('Yj_Gdbh',$value['工单编号B'])->value('rtrim(yj_yjmc) as yjmc');
+            if (empty($printNameB)){
+                $list[$key]['印件名称B'] = '';
+            }else{
+                $list[$key]['印件名称B'] = $printNameB;
+            }
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 车间机台状态列表展示
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function MachineDetailList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $workshop = $param['workshop'];
+        $sql = "SELECT
+                    RTRIM( a.`设备编号` ) AS 设备编号,
+                    RTRIM( a.`设备名称` ) AS 设备名称,
+                    RTRIM( d.`当前状态` ) AS 状态
+                FROM
+                    `设备_基本资料` AS a
+                    JOIN (
+                    SELECT
+                        b.`设备编号`,
+                        b.`当前状态`,
+                        b.`开工时间` 
+                    FROM
+                        `设备_产量采集` AS b
+                        JOIN ( SELECT `设备编号`, MAX( `UniqId` ) AS `UniqId` FROM `设备_产量采集` GROUP BY `设备编号` ) AS c ON b.`设备编号` = c.`设备编号` 
+                        AND b.`UniqId` = c.`UniqId`  
+                    ) AS d ON a.`设备编号` = d.`设备编号`
+                WHERE
+                    a.`使用部门` = '{$workshop}' 
+                GROUP BY
+                    a.`设备编号`
+                ORDER BY 
+                    a.UniqId";
+        $list = \db()->query($sql);
+        foreach ($list as $key=>$value){
+            if ($value['状态'] == ''){
+                $list[$key]['状态'] = '待单';
+            }
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 机台当前参数展示
+     * @ApiMethod (GET)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function MachineDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $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 c.Gy0_sbbh LIKE CONCAT('%', a.设备编号, '%')")
+            ->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('设备_产量采集')
+            ->where('设备编号',$param['machine'])
+            ->where('开工时间',$param['start'])
+            ->field('rtrim(时间) as 时间,当班产量,rtrim(当前状态) as 状态,MAX(时间) as 最大时间,MAX(当班产量) as 最大产量')
+            ->group('当前状态')
+            ->select();
+        if (!empty($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{
+            $data['timeDifference'][0] = [
+                '时间' => 0,
+                '状态' => '待单'
+            ];
+            $data['当班产量'] = 0;
+        }
+        //机台产能/时间明细
+        $row = \db('设备_产量采集')
+            ->where('设备编号',$param['machine'])
+            ->where('开工时间',$param['start'])
+            ->where('当班产量','<>',-1)
+            ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
+            ->select();
+        if (empty($row)){
+            $data['row'] = [];
+        }
+        foreach ($row  as $key=>$value){
+            $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
+            $data['row'][$key]['状态'] = $value['状态'];
+            if ($key<2){
+                $data['row'][$key]['产能'] = 0;
+            }else{
+                $data['row'][$key]['产能'] = ($row[$key-1]['产量']-$row[$key-2]['产量'])*60;
+            }
+        }
+        //机台状态
+        $status = end($row);
+        if (empty($status['状态'])){
+            $data['status'] = '待单';
+        }else{
+            $data['status'] = $status['状态'];
+        }
+        //检验数据
+        $list = \db('制程检验_记录')
+            ->where('开工时间',$param['start'])
+            ->where('设备编号',$param['machine'])
+            ->where('sys_rq','>',$param['start'])
+            ->where('工单编号',$machineDetail['工单编号'])
+            ->field('rtrim(类别) as 类别,提交时间')
+            ->select();
+
+        $data['首件'] = $data['自检'] = $data['IPQC'] = [];
+        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'] = [];
+        }
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 制程检验记录->检验项目
+     * @ApiMethod (GET)
+     * @param void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProcessInspectionRecordsItem()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('制程检验_项目')
+            ->where('工序','like','%'.$param['process'].'%')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到检测项目');
+        }
+        $data = [];
+        foreach ($list as $key=>$value){
+            $data['首件']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['首件签样要求']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+            $data['机台检验']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['机台自检频率']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+            $data['IPQC']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['IPQC检验频率']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+        }
+        $row = \db('制程检验_项目附加')
+            ->where('工序','like','%'.$param['process'].'%')
+            ->select();
+        foreach ($row as $key=>$value){
+            $data['首件']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+            $data['机台检验']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+            $data['IPQC']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+        }
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 车间报工
+     * 制程检验记录->检测记录添加
+     */
+    public function ProcessInspectionRecordsItemAdd(){
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $startID = \db('制程检验_记录')->order('UniqId desc')->value('UniqId');
+        if (empty($startID)){
+            $startID = 0;
+        }
+        $process = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param[0]['workOrder'])
+            ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->find();
+        $startTime = \db('设备_产量采集')
+            ->where('设备编号', 'like', '%' . $param[0]['machine'] . '#%')
+            ->where('工单编号', $param[0]['workOrder'])
+            ->order('UniqId desc')
+            ->find();
+
+        // 解决车间因未更换班组,导致开工时间仍为前一个班次,导致下一个班组进行上报时数据录到了前一个班次中的问题
+        if (!$startTime) {
+            $this->error('未找到对应的开工时间');
+        }
+        /*
+         * 系统提交时间(应报工时间)和开工时间
+         */
+//        $startTime = $startTime['开工时间'];
+        $rqTime = isset($param[0]['rq']) ? $param[0]['rq'] :  date('Y-m-d H:i:s');
+        //转换为时间戳
+        $rqTimestamp = strtotime($rqTime);
+        $startTimestamp = strtotime($startTime['开工时间']);
+        // 计算时间差(秒)
+        $timeDiff = abs($rqTimestamp - $startTimestamp); // 取绝对值,防止负数
+        /*
+         * 计算时间差
+         */
+        // 转换时间差为 天、小时、分钟、秒
+        $days = floor($timeDiff / 86400);
+        $hours = floor(($timeDiff % 86400) / 3600);
+        $minutes = floor(($timeDiff % 3600) / 60);
+        $seconds = $timeDiff % 60;
+        // 格式化时间差
+        $formattedDiff = "";
+        if ($days > 0) $formattedDiff .= $days . "天";
+        if ($hours > 0) $formattedDiff .= $hours . "小时";
+        if ($minutes > 0) $formattedDiff .= $minutes . "分钟";
+        if ($seconds > 0) $formattedDiff .= $seconds . "秒";
+
+        //测试进行时间比较,查看时间判断是否正确
+//        echo "<pre>";
+//        print_r("系统提交时间:" .$rqTime);
+//        print_r("\n当前开工时间:" . $startTime);
+//        print_r("\n时间差:" . $formattedDiff);
+//        echo "<pre>";
+
+        // 判断是否超过 12 小时(12 * 3600 = 43200 秒)
+        if ($timeDiff > 43200) {
+            $this->error('请先更换班组后,再提交数据');
+        }
+
+        if ((int)$process['gxh']<10){
+            $process['gxh'] = '0'.$process['gxh'];
+        }
+        if ($process['add_gxmc'] !== ''){
+            $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
+        }else{
+            $printName = $process['gxh'].'-'.$process['gxmc'];
+        }
+        if (empty($process)){
+            $this->success('数据错误');
+        }
+
+        $data = [];
+        foreach ($param as $key=>$value){
+            $data[$key] = [
+                '类别' => $value['category'],
+                '工单编号' => $value['workOrder'],
+                '印件号' => $value['yjno'],
+                '工序名称' => $printName,
+                '流程单号' => $value['flow'],
+                '设备编号' => $value['machine'].'#',
+                '班组编号' => $startTime['班组编号'],
+                '检验项目' => $value['item'],
+                '相关标准' => $value['standard'],
+                '量测仪器' => $value['instrument'],
+                '检验结果' => $value['selected'],
+                '检验备注' => $value['remark'],
+                '提交时间' => date('Y-m-d H:i:s',time()),
+                '开工时间' => rtrim($startTime['开工时间']),
+                'sys_id' => '',
+                'sys_rq' => date('Y-m-d H:i:s',time()),
+                'mod_rq' => '0000-00-00 00:00:00',
+                'UniqId' => $startID + $key +1
+            ];
+        }
+        $res = \db('制程检验_记录')->insertAll($data);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 制程检验记录->附加检验记录添加
+     * @ApiMethod (POST)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function AdditionalInspectionRecordAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $startID = \db('制程检验_记录附加')->order('UniqId desc')->value('UniqId');
+        if (empty($startID)){
+            $startID = 0;
+        }
+        $process = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param[0]['workOrder'])
+            ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->find();
+        $startTime = \db('设备_产量采集')
+            ->where('设备编号','like','%'.$param[0]['machine'].'#%')
+            ->where('工单编号',$param[0]['workOrder'])
+            ->order('UniqId desc')
+            ->find();
+        if ((int)$process['gxh']<10){
+            $process['gxh'] = '0'.$process['gxh'];
+        }
+        if ($process['add_gxmc'] !== ''){
+            $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
+        }else{
+            $printName = $process['gxh'].'-'.$process['gxmc'];
+        }
+        if (empty($process)){
+            $this->success('数据错误');
+        }
+        $data = [];
+        foreach ($param as $key=>$value){
+            $data[$key] = [
+                '工单编号' => $value['workOrder'],
+                '印件号' => $value['yjno'],
+                '工序名称' => $printName,
+                '流程单号' => $value['flow'],
+                '设备编号' => $value['machine'],
+                '班组编号' => $startTime['班组编号'],
+                '缺陷备注' => $value['remark'],
+                '提交时间' => date('Y-m-d H:i:s',time()),
+                '开工时间' => rtrim($startTime['开工时间']),
+                'sys_id' => '',
+                'sys_rq' => date('Y-m-d H:i:s',time()),
+                'mod_rq' => '0000-00-00 00:00:00',
+                'UniqId' => $startID + $key +1
+            ];
+        }
+        $res = \db('制程检验_记录附加')->insertAll($data);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 客诉记录
+     * @ApiMethod (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+     public function ComplaintRecord()
+     {
+         if ($this->request->isGet() === false){
+             $this->error('请求错误');
+         }
+         $param = $this->request->param();
+         if (isset($param['productCode'])){
+             $where['产品编号'] = $param['productCode'];
+         }
+         $filed = "rtrim(产品编号) as 产品编号,rtrim(产品名称) as 产品名称,rtrim(客诉日期) as 客诉日期,rtrim(客诉单号) as 客诉单号,
+         rtrim(客诉方式) as 客诉方式,rtrim(订单编号) as 订单编号,rtrim(客户编号) as 客户编号,rtrim(客户名称) as 客户名称,
+         rtrim(客诉描述) as 客诉描述,rtrim(缺陷关键字) as 缺陷关键字,rtrim(客诉性质) as 客诉性质,rtrim(扣分) as 扣分,
+         rtrim(主要责任部门) as 主要责任部门,rtrim(次要责任部门) as 次要责任部门";
+         $list = \db('db_客诉记录')
+             ->where($where)
+             ->field($filed)
+             ->select();
+         if (empty($list)){
+             $this->success('未找到该产品客诉记录');
+         }
+         $this->success('成功',$list);
+     }
+
+    /**
+     * 设置机台班组信息
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function setMachineTeam()
+    {
+        if (Request::instance()->isPost() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params['machine']) || empty($params['machine'] )) {
+            $this->error('参数不能为空');
+        }
+        if (empty($params['team_id']) || empty($params['sczl_bzdh'])){
+            $this->error('请先选择班组成员');
+        }
+        $machine = $params['machine'] . '#';
+        $data = [];
+        $lastData = \db('设备_产量采集')
+            ->order('UniqId desc')
+            ->find();
+        $id = $lastData['UniqId']+1;
+        $data['当前状态'] = $params['status'];
+        $data['时间'] = date('Y-m-d H:i:s');
+        $data['设备编号'] = $machine;
+        $data['工单编号'] = empty($params['order']) ? '':$params['order'];
+        $data['印件号'] = empty($params['yjno']) ? '':$params['yjno'];
+        $data['工序号'] = empty($params['gy_name']) ? '' : (int)substr($params['gy_name'], 0, 2);
+        $data['工序名称'] = empty($params['gy_name']) ? '' : $params['gy_name'];
+        $data['当班产量'] = $params['production_now'];
+        $data['累计产量'] = $params['production_all'];
+        $data['班组编号'] = $params['sczl_bzdh'];
+        $data['班组ID'] = $params['team_id'];
+        // 获取当前时间
+        $current_time = time();
+        // 设置时间范围
+        $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
+        $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
+        $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
+        $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
+        $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $data['开工时间'] = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $data['开工时间'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
+            $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
+        }
+        if (!empty($params['order']) && !empty($params['yjno'])){
+            $option['Gy0_gdbh'] = $params['order'];
+            $option['Gy0_yjno'] = $params['yjno'];
+            $option['Gy0_gxh'] = $data['工序号'];
+            $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
+        }else{
+            $data['任务ID'] = '';
+        }
+        $data['UniqId'] = $id;
+        $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
+        $res = Db::query($sql);
+        if ($res === false) {
+            $this->error('设置失败');
+        } else {
+            $this->success('设置成功');
+        }
+    }
+
+    /**
+     * 首页数据
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function index()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $nowTime = date('Y-m-d H:i:s',time());
+        $oldTime = (date('Y')-1).'-'.date('m-d H:i:s');
+        $where =[
+            'Mod_rq' => ['between',[$oldTime,$nowTime]],
+            '行号' => '1'
+        ];
+        $data = [];
+        //按状态查询工单信息
+        $orderList = \db('工单_基本资料')
+            ->where($where)
+            ->field('count(Gd_gdbh) as 数量,rtrim(gd_statu) as 状态')
+            ->group('gd_statu')
+            ->select();
+        foreach ($orderList as $value){
+            if ($value['状态'] === '1-已完工'){
+                $data['workOrderData']['已完工'] = $value['数量'];
+            }
+            if ($value['状态'] === '3-计划中'){
+                $data['workOrderData']['计划中'] = $value['数量'];
+            }
+        }
+        $data['workOrderData']['排程中'] = db('工单_基本资料')->alias('a')
+            ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+            ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
+            ->where([
+                'a.gd_statu' => '2-生产中',
+                'a.行号' => '1',
+                'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'b.Gy0_sj1' => '1900-01-01 00:00:00',
+                'c.状态' => '',
+            ])
+            ->group('a.Gd_gdbh')
+            ->count();
+        $data['workOrderData']['制程中'] = db('工单_基本资料')->alias('a')
+            ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+            ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
+            ->where([
+                'a.gd_statu' => '2-生产中',
+                'a.行号' => '1',
+                'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
+                'c.状态' => '',
+            ])
+            ->group('a.Gd_gdbh')
+            ->count();
+        //按月份查询工单信息
+        $data['monthData'] = \db('工单_基本资料')
+            ->where('Mod_rq', 'between', [$oldTime, $nowTime])
+            ->field('DATE_FORMAT(Mod_rq, "%Y-%m") as month, COUNT(*) as count')
+            ->group('month')
+            ->order('month')
+            ->select();
+        //查询最近十条客诉信息
+        $data['customer'] = \db('db_客诉记录')
+            ->field('rtrim(客诉描述) as 客诉描述,DATE_FORMAT(客诉日期, "%Y-%m-%d") as 日期,rtrim(UniqID) as UniqId')
+            ->limit(10)
+            ->order('Sys_rq desc')
+            ->select();
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 员工信息获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function EmployeeData()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (isset($param['code']) === false){
+            $this->error('参数错误');
+        }
+        $res = \db('人事_基本资料')
+            ->where('员工编号','like',$param['code'].'%')
+            ->field('rtrim(员工编号) as 员工编号,rtrim(员工姓名) as 员工姓名')
+            ->select();
+        if (empty($res)){
+            $this->success('未找到该员工');
+        }
+        $this->success('成功',$res);
+    }
+
+    /**
+     * 换型清场添加
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function remodelDataAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $lastId = \db('制程_换型清场')->order('UniqId desc')->value('UniqId');
+        $param['sys_id'] = '['.$param['机台编号'].']';
+        $param['sys_rq'] = date('Y-m-d H:i:s',time());
+        $param['mod_rq'] = date('Y-m-d H:i:s',time());
+        $param['UniqId'] = $lastId + 1;
+        $sql = \db('制程_换型清场')->fetchSql(true)->insert($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 换型清场记录修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function remodelDataEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $param['mod_rq'] = date('Y-m-d H:i:s',time());
+        $sql = \db('制程_换型清场')->fetchSql(true)->update($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 换型清场记录删除
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function remodelDataDel()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $res = \db('制程_换型清场')->where('UniqId',$param['UniqId'])->delete();
+        if ($res !== false){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 印版领用记录添加
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintDetailAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $lastId = \db('工单_印版领用记录')->order('UniqID desc')->value('UniqID');
+        foreach ($param as $key=>$value){
+            $param[$key]['Yb_领用日期'] = date('Y-m-d H:i:s',time());
+            $param[$key]['Sys_rq'] = date('Y-m-d H:i:s',time());
+            $param[$key]['Mod_rq'] = date('Y-m-d H:i:s',time());
+            $param[$key]['UniqID'] = $lastId + $key +1;
+        }
+        $sql = \db('工单_印版领用记录')->fetchSql(true)->insertAll($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('添加成功');
+        }else{
+            $this->error('添加失败');
+        }
+    }
+
+    /**
+     * 印版领用记录退还
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintDetailEdit()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param) || !isset($param['id']) || !isset($param['number'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$param['id']);
+        $i = 0;
+        foreach ($idList as $key=>$value){
+            $data['Yb_退还日期'] = date('Y-m-d H:i:s',time());
+            $data['Mod_rq'] = date('Y-m-d H:i:s',time());
+            $data['Yb_印数'] = $param['number'];
+            $sql = \db('工单_印版领用记录')->where('UniqID',$value)->fetchSql(true)->update($data);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i !== 0){
+            $this->error('退还失败');
+        }else{
+            $this->success('退还成功');
+        }
+    }
+
+    /**
+     * 当班产量明细修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function chanliangEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $param['mod_rq'] = date('Y-m-d H:i:s',time());
+        $data = $param;
+        unset($data['UniqId']);
+        unset($data['sczl_rq']);
+        $sql = \db('设备_产量计酬')
+            ->where('UniqId',$param['UniqId'])
+            ->fetchSql(true)
+            ->update($data);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('修改成功');
+        }else {
+            $this->error('修改失败');
+        }
+    }
+
+    /**
+     * 获取当日上报产量详细数据
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function MachineChanliangDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as num,rtrim(sczl_sj1) as sj1,rtrim(sczl_ls) as 联数,
+        rtrim(sczl_sj2) as sj2,rtrim(sczl_cl) as 产量,rtrim(sczl_bzdh) as bzdh,rtrim(sczl_zcfp) as 制程废品,
+        rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,
+        rtrim(sczl_装版总工时) as 装版总工时,rtrim(sczl_打样总工时) as 打样总工时,
+        rtrim(sczl_装版工时) as 装版工时,rtrim(sczl_保养工时) as 保养工时,rtrim(sczl_打样工时) as 打样工时,
+        rtrim(sczl_异常停机工时) as 异常总工时,rtrim(sczl_设备运行工时) as 通电工时,
+        rtrim(码开始行) as 码开始行,rtrim(码结束行) as 码结束行,rtrim(码包) as 码包,rtrim(主电表) as 主电表,
+        rtrim(辅电表) as 辅电表,rtrim(sczl_ms) as 色度数,
+        rtrim(sczl_异常工时1) as 异常补时,rtrim(sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
+        rtrim(sczl_装版工时) as 装版补产工时,rtrim(sczl_打样工时) as 打样补产工时,
+        sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,
+        sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
+        sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId';
+        $list = \db('设备_产量计酬')->where('UniqId',$param['UniqId'])->field($field)->find();
+        if (empty($list)){
+            $this->success('未找到产量详情信息');
+        }
+        $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$list['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
+        $list['印件名称'] = $productName['cpmc'];
+        if (!empty($productName['成品名称'])){
+            $list['cpmc'] = $productName['成品名称'];
+        }elseif (empty($productName['成品名称']) && !empty($productName['cpmc'])){
+            $list['cpmc'] = $productName['cpmc'];
+        }else{
+            $list['cpmc'] = '';
+        }
+        for ($i=1;$i<11;$i++){
+            if (isset($list['sczl_bh'.$i])){
+                $name = \db('人事_基本资料')->where('员工编号',$list['sczl_bh'.$i])->field('rtrim(员工姓名) as name')->find();
+                if (isset($name['name'])){
+                    $list['组员'.$i] = [
+                        '编号' => $list['sczl_bh'.$i],
+                        '姓名' => $name['name'],
+                        '比例' => (float)$list['sczl_rate'.$i]
+                    ];
+                }
+            }
+            if (empty($list['sczl_bh'.$i])){
+                $list['组员'.$i] = [
+                    '编号' => '',
+                    '姓名' => '',
+                    '比例' => ''
+                ];
+            }
+
+            unset($list['sczl_bh'.$i],$list['sczl_rate'.$i]);
+        }
+        $list['拉料'] = [
+            '编号' => $list['sczl_bh98'],
+            '姓名' => \db('人事_基本资料')->where('员工编号',$list['sczl_bh98'])->value('rtrim(员工姓名)')
+        ];
+        unset($list['sczl_bh98']);
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 当日上报产量详细数据修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function MachineChanliangDetailEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param['UniqId'])){
+            $this->error('参数错误');
+        }
+        $param['sczl_type'] = $param['sczl_gxmc'];
+        $param['mod_rq'] = date('Y-m-d H:i:s',time());
+        $UnidId = $param['UniqId'];
+        unset($param['UniqId']);
+        unset($param['sczl_rq']);
+        $sql = \db('设备_产量计酬')->where('UniqId',$UnidId)->fetchSql(true)->update($param);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('修改成功');
+        }else{
+            $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('参数错误');
+        }
+        $idList = explode(',',$param['UniqId']);
+        foreach ($idList as $key=>$value){
+            $res = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->delete();
+        }
+        if ($res !== false){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 日产量上报添加
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function ChanliangAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['sczl_gdbh'])){
+            $this->error('参数错误');
+        }
+        $lastId = \db('设备_产量计酬')->order('UniqId desc')->value('rtrim(UniqId)');
+        $params['sczl_type'] = $params['sczl_gxmc'];
+        $params['sczl_wgsj'] = '1900-01-01 00:00:00';
+        $params['sczl_废品率系数'] = 0;
+        $params['sys_rq'] = date('Y-m-d H:i:s',time());
+        $params['mod_rq'] = date('Y-m-d H:i:s',time());
+        $params['UniqId'] = $lastId + 1;
+        $sql = \db('设备_产量计酬')->fetchSql(true)->insert($params);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 日产量上报添加获取工单信息
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangWorkorder()
+    {
+        if ($this->request->isGet() === false)
+        {
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+//        $where = [
+//            'b.Gy0_sbbh' => ['like','%'.$param['machine'].'%'],
+//        ];
+//        if (!empty($param['machine'])){
+//            $where = [
+//                'b.Gy0_sbbh' => ['like','%'.$param['machine'].'%'],
+//            ];
+//        }
+        if (!empty($param['search'])){
+            $where['b.Gy0_gdbh'] = ['like','%'.$param['search'].'%'];
+        }
+        $list = \db('工单_基本资料')
+            ->alias('a')
+            ->field('rtrim(Gd_gdbh) as gdbh,rtrim(成品名称) as cpmc')
+            ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh')
+            ->where($where)
+            ->select();
+        if (empty($list)){
+            $this->success('未找到相关工单');
+        }else{
+            $this->success('成功',$list);
+        }
+    }
+
+    /**
+     * 日产量上报工单印件资料
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangPrintDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['gdbh'])){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Yj_Gdbh' => $param['gdbh']
+        ];
+        $list = \db('工单_印件资料')
+            ->where($where)
+            ->field('rtrim(yj_Yjno) as yjno,rtrim(yj_yjmc) as yjmc,rtrim(yj_ls) as ls')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到印件资料');
+        }else{
+            $this->success('成功',$list);
+        }
+    }
+
+    /**
+     * 日产量上报工艺资料获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangProcessDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['gdbh'])){
+            $this->error('参数错误');
+        }
+//        $sys_bh = \db('dic_lzde')->where('适用机型',$param['machine'])->value('sys_bh');
+        $list = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param['gdbh'])
+            ->where('Gy0_yjno',$param['yjno'])
+//            ->where('Gy0_sbbh','like','%'.$param['machine'].'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->select();
+        if (empty($list)){
+            $this->success('未获取工序');
+        }
+//        $time = \db('设备_产量计酬')
+//            ->where('sczl_gdbh',$param['gdbh'])
+//            ->where('sczl_yjno',$param['yjno'])
+//            ->where('sczl_jtbh','like','%'.$param['machine'].'%')
+//            ->order('UniqId desc')
+//            ->value('sczl_sj2');
+//        $newTime = date('Y-m-d H:i:s');
+//        if ($newTime > date('Y-m-d 08:30:00') && $newTime < date('Y-m-d 20:30:00') && $time < date('Y-m-d 08:30:00')){
+//            $time = date('Y-m-d 08:30:00');
+//        }elseif ($newTime > date('Y-m-d 20:30:00') && $time < date('Y-m-d 20:30:00')){
+//            $time = date('Y-m-d 20:30:00');
+//        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['gxh'] < 10){
+                $value['gxh'] = '0'.$value['gxh'];
+            }
+            if (empty($value['add_gxmc'])){
+                $list[$key]['name'] = $value['gxh'].'-'.$value['gxmc'];
+            }else{
+                $list[$key]['name'] = $value['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
+            }
+            unset( $list[$key]['add_gxmc']);
+//            $list[$key]['time'] = $time;
+        }
+//        $list['sys_bh'] = $sys_bh;
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 工价系数修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function CoefficientEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$params['id']);
+        $i=0;
+        foreach ($idList as $key=>$value){
+            $sql = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->fetchSql(true)
+                ->update(['sczl_工价系数'=>$params['工价系数']]);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i!==0){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+
+    /**
+     * 色度系数修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function ChromaDataEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$params['id']);
+        $i=0;
+        foreach ($idList as $key=>$value){
+            $sql = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->fetchSql(true)
+                ->update(['sczl_ms'=>$params['ms']]);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i!==0){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+
+    /**
+     * 凹印版距修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function PrintingModeDataEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$params['id']);
+        //获取工单印件工序
+        $orderList = \db('设备_产量计酬')
+            ->where('UniqId',$idList[0])
+            ->field('rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as 印件号,rtrim(sczl_gxh) as 工序号')
+            ->find();
+        //修改工艺资料
+        $sql = \db('工单_工艺资料')
+            ->where([
+                'Gy0_gdbh'=>$orderList['工单编号'],
+                'Gy0_yjno'=>$orderList['印件号'],
+                'Gy0_gxh'=>$orderList['工序号']
+            ])
+            ->fetchSql(true)
+            ->update(['版距'=>$params['plate'],'印刷方式'=>$params['mode']]);
+        $res = \db()->query($sql);
+        if ($res === false){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+
+    /**
+     * 废品率系数批量修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function RejectionEdit()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$params['id']);
+        $i=0;
+        foreach ($idList as $key=>$value){
+            $sql = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->fetchSql(true)
+                ->update(['sczl_废品率系数'=>$params['rejection']]);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $i++;
+            }
+        }
+        if ($i!==0){
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
+
+    /**
+     * 日产量上报班组信息批量修改
+     * @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 YieldTeamEdit()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['Uniqid']) || empty($param['teamID'])){
+            $this->error('参数错误');
+        }
+        $idList = explode(',',$param['Uniqid']);
+        $teamList = \db('设备_班组资料')->where('UniqId',$param['teamID'])->find();
+        $data = [];
+        for ($i=1;$i<11;$i++){
+            $data['sczl_bh'.$i] = $teamList['sczl_bh'.$i];
+            $data['sczl_rate'.$i] = $teamList['sczl_rate'.$i];
+            $data['sczl_bzdh'] = $teamList['sczl_bzdh'];
+        }
+        $j = 0;
+        foreach ($idList as $key => $value){
+            $sql = \db('设备_产量计酬')
+                ->where('UniqId',$value)
+                ->fetchSql(true)
+                ->update($data);
+            $res = \db()->query($sql);
+            if ($res === false){
+                $j++;
+            }
+        }
+        if ($j === 0){
+            $this->success('修改成功');
+        }else{
+            $this->error('修改失败');
+        }
+    }
+
+    /**
+     * 检品机日产量上报数据修改
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function JpChanliangEdit()
+    {
+        if (Request::instance()->isPost() == false){
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['UniqId'])){
+            $this->error('参数错误');
+        }
+        $params['mod_rq'] = date('Y-m-d H:i:s');
+        $data = $params;
+        unset($data['UniqId']);
+        $sql = \db('设备_产量计酬')->where('UniqId',$params['UniqId'])->fetchSql(true)->update($data);
+        $res = \db()->query($sql);
+        if ($res === false){
+            $this->error('修改失败');
+        }else{
+            $this->success('成功');
+        }
+    }
+
+    /**
+     * 检品机日产量上报数据列表
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function JPmachineDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $machine = input('machine');
+        $date = input('date');
+        $where = [
+            'sczl_jtbh' => $machine,
+            'sczl_rq' => date('Y-m-d H:i:s',strtotime($date.' 00:00:00')),
+        ];
+        $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_dedh) as dedh,rtrim(sczl_yjno) as yjno,rtrim(sczl_gxh) as gxh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_type) as 检验类型,rtrim(sczl_num) as num,rtrim(sczl_cl) as 计件箱数,
+        rtrim(sczl_Pgcl) as 每箱数量,rtrim(sczl_bzdh) as bzdh,IF(sczl_废品率系数 = 0, "",sczl_废品率系数) as 废品率系数,IF(sczl_装版工时 = 0, "",sczl_装版工时) as 换膜补时, IF(sczl_保养工时 = 0, "",sczl_保养工时) as 保养工时,IF(sczl_异常停机工时 = 0, "",sczl_异常停机工时) as 异常总工时,IF(sczl_设备运行工时 = 0, "",sczl_设备运行工时) as 通电工时,
+        rtrim(sys_id) as 用户,rtrim(mod_rq) as 更新时间,IF(sczl_异常工时1 = 0, "",sczl_异常工时1) as 异常补时,IF(sczl_异常类型1 = 0, "",sczl_异常类型1) as 异常类型,sczl_bh1,sczl_bh2,
+        sczl_bh3,sczl_bh4,sczl_bh5,sczl_bh6,sczl_bh7,sczl_bh8,sczl_bh9,sczl_bh10,sczl_rate1,sczl_rate2,sczl_rate3,sczl_rate4,sczl_rate5,sczl_rate6,sczl_rate7,
+        sczl_rate8,sczl_rate9,sczl_rate10,sczl_bh98,rtrim(UniqId) as UniqId,rtrim(sczl_工价系数) as 难度系数,rtrim(sczl_dedh) as 定额代号,sczl_rq,sczl_装版总工时 as 换膜总工时';
+        //机台信息
+        $machineDetail = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额')->find();
+        //组员信息
+        $list = \db('设备_产量计酬')->where($where)->field($field)->select();
+        $totalA = \db('设备_产量计酬')
+            ->where($where)
+            ->where('sczl_bzdh','like','A%')
+            ->field('sczl_type as 检验类型,SUM(sczl_cl) as 箱数')
+            ->group('检验类型')
+            ->select();
+        $totalB = \db('设备_产量计酬')
+            ->where($where)
+            ->where('sczl_bzdh','like','B%')
+            ->field('sczl_type as 检验类型,SUM(sczl_cl) as 箱数')
+            ->group('检验类型')
+            ->select();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            //产品名称
+            $productName = \db('工单_基本资料')->whereIn('Gd_gdbh',$value['工单编号'])->field('rtrim(成品名称) as 成品名称,rtrim(Gd_cpmc) as cpmc')->find();
+            if (!empty($productName)){
+                if (!empty($productName['成品名称'])){
+                    $list[$key]['产品名称'] = $value['工单编号'].'---'.$productName['成品名称'];
+                    $list[$key]['cpmc'] = $productName['成品名称'];
+                }else{
+                    $list[$key]['产品名称'] = $value['工单编号'];
+                    $list[$key]['cpmc'] = '';
+                }
+            }else{
+                $list[$key]['产品名称'] = $value['工单编号'];
+                $list[$key]['cpmc'] = '';
+            }
+            if (empty($value['定额代号'])){
+                $list[$key]['千件工价'] = '';
+                $list[$key]['日定额'] = '';
+                $list[$key]['补产标准'] = '';
+            }else{
+                $row = \db('dic_lzde')->where('sys_bh',$value['定额代号'])->field('rtrim(千件工价) as 千件工价,rtrim(日定额) as 日定额,rtrim(补产标准) as 补产标准')->find();
+                $list[$key]['千件工价'] = $row['千件工价'];
+                $list[$key]['日定额'] = $row['日定额'];
+                $list[$key]['补产标准'] = $row['补产标准'];
+            }
+            $list[$key]['工序'] = $list[$key]['yjno'].'-'.$list[$key]['gxh'].'-'.$list[$key]['gxmc'];
+            for ($i=1;$i<11;$i++){
+                if (isset($value['sczl_bh'.$i])){
+                    $name = \db('人事_基本资料')->where('员工编号',$value['sczl_bh'.$i])->field('员工姓名 as name')->find();
+                    if (isset($name['name'])){
+                        $list[$key]['组员'.$i] = $value['sczl_bh'.$i].$name['name'].'('.((float)$value['sczl_rate'.$i]*100).'%'.')';
+                        $list[$key]['sczl_name'.$i] = $name['name'];
+                    }else{
+                        $list[$key]['sczl_name'.$i] = '';
+                    }
+                }
+            }
+        }
+        $list['totalA'] = $totalA;
+        $list['totalB'] = $totalB;
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 检品机每日上报数据修改页面数据获取接口
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function JPchanliangDetailList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('工单_基本资料 b','a.sczl_gdbh = b.Gd_gdbh AND a.sczl_yjno = b.行号')
+            ->field('rtrim(a.sczl_gdbh) as 工单编号,rtrim(a.sczl_dedh) as dedh,rtrim(a.sczl_yjno) as yjno,
+            rtrim(a.sczl_gxh) as gxh,rtrim(a.sczl_gxmc) as gxmc,rtrim(a.sczl_type) as 检验类型,rtrim(a.sczl_num) as num,
+            rtrim(a.sczl_cl) as 计件箱数,rtrim(a.sczl_Pgcl) as 每箱数量,rtrim(a.sczl_bzdh) as bzdh,
+            IF(a.sczl_废品率系数 = 0, "",a.sczl_废品率系数) as 废品率系数,IF(a.sczl_装版工时 = 0, "",a.sczl_装版工时) as 换膜补时,
+            IF(a.sczl_保养工时 = 0, "",a.sczl_保养工时) as 保养工时,IF(a.sczl_异常停机工时 = 0, "",a.sczl_异常停机工时) as 异常总工时,
+            IF(a.sczl_设备运行工时 = 0, "",a.sczl_设备运行工时) as 通电工时,rtrim(a.sys_id) as 用户,rtrim(a.mod_rq) as 更新时间,
+            IF(a.sczl_异常工时1 = 0, "",a.sczl_异常工时1) as 异常补时,IF(a.sczl_异常类型1 = 0, "",a.sczl_异常类型1) as 异常类型,
+            a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.sczl_bh5,a.sczl_bh6,a.sczl_bh7,a.sczl_bh8,a.sczl_bh9,a.sczl_bh10,
+            a.sczl_rate1,a.sczl_rate2,a.sczl_rate3,a.sczl_rate4,a.sczl_rate5,a.sczl_rate6,a.sczl_rate7,a.sczl_rate8,
+            a.sczl_rate9,a.sczl_rate10,a.sczl_bh98,rtrim(a.UniqId) as UniqId,rtrim(a.sczl_工价系数) as 难度系数,
+            rtrim(a.sczl_dedh) as 定额代号,a.sczl_rq,a.sczl_装版总工时 as 换膜总工时,rtrim(b.Gd_cpmc) as 产品名称,rtrim(b.成品名称) as 成品名称')
+            ->where('a.UniqId',$param['UniqId'])
+            ->find();
+        for ($i=1;$i<11;$i++){
+            if (isset($list['sczl_bh'.$i])){
+                $name = \db('人事_基本资料')->where('员工编号',$list['sczl_bh'.$i])->field('员工姓名 as name')->find();
+                if (isset($name['name'])){
+                    $list['组员'.$i] = $list['sczl_bh'.$i].$name['name'].'('.((float)$list['sczl_rate'.$i]*100).'%'.')';
+                    $list['sczl_name'.$i] = $name['name'];
+                }else{
+                    $list['sczl_name'.$i] = '';
+                }
+            }
+        }
+        if (!empty($list)){
+            $this->success('成功',$list);
+        }else{
+            $this->error('未找到数据');
+        }
+    }
+
+    /**
+     * 拉纸工数据导出
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function LazhiGongData()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['mouth'])){
+            $this->error('请选择月份');
+        }
+        $filed = [
+            'a.sczl_gdbh' => '工单编号',
+            'b.yj_yjmc'   => '产品名称',
+            'a.sczl_num'  => '流程单号',
+            'a.sczl_yjno' => '印件号',
+            'a.sczl_gxh'  => '工序号',
+            'a.sczl_jtbh' => '机台编号',
+            'a.sczl_rq'   => '日期',
+            'a.sczl_type' => '工序名称',
+            'a.sczl_cl'   => '产量',
+            'a.sczl_bh1'  => '机长工号',
+            'c1.员工姓名'  => '机长姓名',
+            'a.sczl_bh2'  => '组员工号1',
+            'c2.员工姓名'  => '组员姓名1',
+            'a.sczl_bh3'  => '组员工号2',
+            'c3.员工姓名'  => '组员姓名2',
+            'a.sczl_bh98' => '拉料工工号',
+            'c4.员工姓名'  => '拉料工姓名'
+        ];
+        $list = \db('设备_产量计酬')
+            ->alias('a')
+            ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh AND a.sczl_yjno = b.yj_Yjno')
+            ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
+            ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
+            ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
+            ->join('人事_基本资料 c4','a.sczl_bh98 = c4.员工编号','left')
+            ->field($filed)
+            ->where('a.sczl_rq','like',$param['mouth'].'%')
+            ->where('a.sczl_bh98','<>','')
+            ->order('a.sczl_rq,a.sczl_jtbh')
+            ->select();
+
+        if (!empty($list)){
+            $this->success('成功',$list);
+        }else{
+            $this->error('未找到相关数据');
+        }
+    }
+}

+ 545 - 0
application/api/controller/YxManufacture.php

@@ -1 +1,546 @@
 <?php
+
+
+namespace app\api\controller;
+
+
+use app\common\controller\Api;
+use think\Db;
+use think\Request;
+
+class YxManufacture extends Api
+{
+    protected $noNeedRight = ['*'];
+    protected $noNeedLogin = ['*'];
+
+
+
+    /**
+     * 计划中工单
+     * @ApiMethod (GET)
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function Project()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        if ($param['status'] === '计划中'){
+            $status = '3-计划中';
+        }else{
+            $status = '1-已完工';
+        }
+        $page = 0;
+        $limit = 15;
+        if (isset($param['page'])){
+            $page = $param['page'];
+        }
+        if (isset($param['limit'])){
+            $limit = $param['limit'];
+        }
+        $where = [
+            'gd_statu' => $status,
+//            '行号' => '1',
+
+        ];
+        $where['工单分类'] = ['in',[1,3]];
+        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('工单_基本资料')->where($where)->field($field)->limit(($page-1)*$limit,$limit)->order('Uniqid desc')->select();
+        $total = \db('工单_基本资料')->where($where)->count();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
+            $list[$key]['产品名称'] = $value['产品名称'] != '' ? $value['产品名称']:$value['成品名称'];
+            $number = \db('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
+            if ($number === 0){
+                $list[$key]['status'] = 0;
+            }else{
+                $list[$key]['status'] = 1;
+            }
+            unset($list[$key]['成品名称']);
+        }
+        $this->success('成功',['data'=>$list,'total'=>$total]);
+    }
+
+    /**
+     * 计划中工单->工艺资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function projectCraft()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Gy0_gdbh' => $Gd_gdbh
+        ];
+        $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(重点工序) as 重点工序,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(工序备注) as 工序备注,
+        rtrim(Gy0_sbbh) as 机组,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,
+        rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
+        $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['Gy0_yjno'] <10){
+                $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
+            }
+            if ((int)$value['Gy0_gxh'] <10){
+                $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
+            }
+            if (rtrim($value['Add_gxmc']) == ''){
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
+            }else{
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
+            }
+            unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
+        }
+        $this->success('成功',$list);
+    }
+
+
+    /**
+     * 计划中工单->印件资料
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function projectPrint()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Yj_Gdbh' => $Gd_gdbh,
+        ];
+        $field = 'rtrim(Yj_Gdbh) as 工单编号,rtrim(yj_Yjno) as 印件号,rtrim(yj_Yjdh) as 印件代号,rtrim(yj_yjmc) as 印件名称,
+        rtrim(yj_zzmc) as 纸张名称,rtrim(yj_tlgg) as 投料规格,rtrim(yj_成品数量) as 成品数量,rtrim(yj_实际投料) as 实际投料,
+        rtrim(yj_Dw) as  投料单位,rtrim(yj_平张投料) as 平张投料,rtrim(yj_ls) as 联数,rtrim(yj_ks) as 开数,rtrim(Sys_id) as 创建用户,
+        rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID';
+        $list = \db('工单_印件资料')->where($where)->field($field)->select();
+        if (empty($list)){
+            $this->success('');
+        }
+        foreach ($list as $key=>$value){
+            $list[$key]['成品数量'] = rtrim((float)$value['成品数量']);
+            $list[$key]['实际投料'] = rtrim((float)$value['实际投料']);
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 排程中/制程中工单
+     */
+    public function Schedule(){
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $where = '';
+        if (!empty($param['search'])){
+            $where = "
+                        a.Gd_gdbh LIKE '%{$param['search']}%' 
+                        OR a.`成品名称` LIKE '%{$param['search']}%' 
+                    ";
+        }
+        $where['工单分类'] = ['in',[1,3]];
+        if ($param['status'] === '制程中'){
+            $list = db('工单_基本资料')->alias('a')
+                ->field([
+                    'rtrim(a.Gd_gdbh)' => '工单编号',
+                    'rtrim(a.Gd_cpdh)' => '产品代号',
+                    'rtrim(a.Gd_cpmc)' => '产品名称',
+                    'rtrim(a.接单日期)' => '接单日期',
+                    'rtrim(a.交货日期)' => '交货日期',
+                    'rtrim(a.订单数量)' => '订单数量',
+                    'rtrim(a.计量单位)' => '计量单位',
+                    'rtrim(a.销售订单号)' => '销售订单号',
+                    'rtrim(a.Gd_客户代号)' => '客户编号',
+                    'rtrim(a.Gd_客户名称)' => '客户名称',
+                    'rtrim(a.客户料号)' => '客户料号',
+                    'rtrim(a.Uniqid)' => 'GDUID',
+                ])
+                ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+                ->where([
+                    'a.gd_statu' => '2-生产中',
+                    'b.PD_WG' => '1900-01-01 00:00:00',
+                    'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
+                ])
+                ->where($where)
+                ->group('a.Gd_gdbh')
+                ->select();
+        }else{
+            $list = db('工单_基本资料')->alias('a')
+                ->field([
+                    'rtrim(a.Gd_gdbh)' => '工单编号',
+                    'rtrim(a.Gd_cpdh)' => '产品代号',
+                    'rtrim(a.Gd_cpmc)' => '产品名称',
+                    'rtrim(a.接单日期)' => '接单日期',
+                    'rtrim(a.交货日期)' => '交货日期',
+                    'rtrim(a.订单数量)' => '订单数量',
+                    'rtrim(a.计量单位)' => '计量单位',
+                    'rtrim(a.销售订单号)' => '销售订单号',
+                    'rtrim(a.Gd_客户代号)' => '客户编号',
+                    'rtrim(a.Gd_客户名称)' => '客户名称',
+                    'rtrim(a.客户料号)' => '客户料号',
+                    'rtrim(a.Uniqid)' => 'GDUID',
+                ])
+                ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+                ->where([
+                    'a.gd_statu' => '2-生产中',
+                    'b.PD_WG' => '1900-01-01 00:00:00',
+                ])
+                ->where($where)
+//                ->whereNotExists(function ($query) {
+//                    $query->table('工单_工艺资料')->alias('b2')
+//                        ->where('b2.Gy0_gdbh = a.Gd_gdbh')
+//                        ->where('b2.Gy0_sj1 <> "1900-01-01 00:00:00"');
+//                })
+                ->group('a.Gd_gdbh')
+                ->select();
+        }
+        if (empty($list)){
+            $this->success('未找到工单信息');
+        }
+        $this->success('成功',$list);
+    }
+
+    /**
+     * 排程中/制程中工单->工序列表
+     * @ApiMethod (GET)
+     * @param string $Gd_gdbh   工单编号
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function ScheduleProcess()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $Gd_gdbh = input('Gd_gdbh');
+        if (empty($Gd_gdbh)){
+            $this->error('参数错误');
+        }
+        $sql = "SELECT rtrim(a.Gy0_gdbh) as 工单编号,a.Gy0_yjno,a.Gy0_gxh,a.Gy0_gxmc,a.Add_gxmc,rtrim(a.Gy0_sbbh) as 设备编号,rtrim(a.Gy0_小时产能) as 小时产能,
+                rtrim(a.工价系数) as 产能系数,rtrim(a.Gy0_生产工时) as 生产工时,rtrim(a.Gy0_辅助工时) as 辅助工时,rtrim(a.Gy0_最早开工时间) as 最早开工时间,
+                rtrim(a.Gy0_sj1) as 计划开工时间,rtrim(a.Gy0_sj2) as 计划完工时间,rtrim(a.Gy0_班次安排) as 班次安排,rtrim(a.工序备注) as 排单备注,
+                rtrim(a.PD_WG) as 工序完工,rtrim(a.UniqId) as UniqId,COALESCE(b.cl, 0) AS 产量,rtrim(d.计划投料) as 工序产量
+                FROM `工单_工艺资料` AS a
+                JOIN `工单_基本资料` As d ON a.Gy0_gdbh = d.Gd_Gdbh
+                LEFT JOIN (
+                        SELECT sczl_gdbh, sczl_gxh, SUM(sczl_cl) AS cl
+                        FROM `设备_产量计酬`
+                        GROUP BY sczl_gdbh, sczl_gxh
+                ) AS b ON a.Gy0_gdbh = b.sczl_gdbh AND (a.Gy0_gxh = b.sczl_gxh OR b.sczl_gxh IS NULL)
+                WHERE a.Gy0_gdbh = '{$Gd_gdbh}' AND a.Gy0_sbbh != ''
+                GROUP BY a.Gy0_yjno,a.Gy0_gxh";
+        $list = Db::query($sql);
+        if (empty($list)){
+            $this->success('未找到工序');
+        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['Gy0_yjno'] <10){
+                $value['Gy0_yjno'] = '0'.rtrim($value['Gy0_yjno']);
+            }
+            if ((int)$value['Gy0_gxh'] <10){
+                $value['Gy0_gxh'] = '0'.rtrim($value['Gy0_gxh']);
+            }
+            if (rtrim($value['Add_gxmc']) == ''){
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']);
+            }else{
+                $list[$key]['印件工序及名称'] = $value['Gy0_yjno'].'-'.$value['Gy0_gxh'].'-->'.rtrim($value['Gy0_gxmc']).'【'.rtrim($value['Add_gxmc']).'】';
+            }
+            unset($list[$key]['Gy0_gxmc'],$list[$key]['Add_gxmc']);
+            $list[$key]['机组'] = $value['设备编号'];
+            $list[$key]['剩余产量'] = (int)$list[$key]['工序产量']-(int)$list[$key]['产量'];
+        }
+        $this->success('成功',$list);
+    }
+    /**
+     * 排单页面左侧车间和机台菜单
+     * @ApiMethod (GET)
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function workbench()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $machineList = db('设备映射表')->column('MNmachine');
+        $where['设备编号'] = ['in',$machineList];
+        $data = [];
+        $department = \db('设备_基本资料')
+            ->distinct(true)
+            ->where('使用部门','<>','研发中心')
+            ->where('设备编组','<>','')
+            ->where('sys_sbID','<>','')
+            ->where($where)
+            ->order('设备编组')
+            ->column('使用部门');
+        if (empty($department)){
+            $this->success('为获取到机台数据');
+        }
+        foreach ($department as $value){
+            $benchClass = \db('设备_基本资料')
+                ->where('使用部门',$value)
+                ->where('设备编组','<>','')
+                ->where('sys_sbID','<>','')
+                ->distinct(true)
+                ->order('设备编组')
+                ->column('设备编组');
+            foreach ($benchClass as $v){
+                if (rtrim($v) !== ''){
+                    $machine = \db('设备_基本资料')
+                        ->alias('a')
+                        ->join('设备映射表 b','a.设备编号 = b.MNmachine')
+                        ->where('a.使用部门',$value)
+                        ->where('a.设备编组',$v)
+                        ->where('a.sys_sbID','<>','')
+                        ->field('rtrim(b.YXmachine) as 设备编号,rtrim(a.设备名称) as 设备名称')
+                        ->order('设备编号')
+                        ->select();
+                    foreach ($machine as $kk=>$vv){
+                        $data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
+                    }
+                }
+            }
+        }
+
+        $this->success('成功',$data);
+    }
+
+
+
+    /**
+     * 车间设备制程展示
+     * @ApiMethod (GET)
+     * @param  void $param
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function EquipmentScheduling()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('参数错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $MNmachine = $param['machine'];
+        $machine = db('设备映射表')
+            ->where('YXmachine',$MNmachine)
+            ->value('MNmachine');
+        $process = \db('dic_lzde')
+            ->where('适用机型',$machine)
+            ->column('rtrim(适用工序)');
+        $list = \db('工单_基本资料')
+            ->alias('a')
+            ->field([
+                'rtrim(b.Gy0_gdbh)' => '工单编号',
+                'rtrim(a.Gd_cpmc)' => '印件名称',
+                '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.Gd_gdbh = b.Gy0_gdbh AND a.行号 = b.Gy0_yjno')
+            ->join('设备_产量计酬 c','a.Gd_gdbh = c.sczl_gdbh AND a.行号 = c.sczl_yjno AND b.Gy0_gxh = c.sczl_gxh','LEFT')
+            ->where([
+                '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('b.Gy0_sj1','<','2099-01-01 00:00:00')
+            ->group('a.Gd_gdbh,c.sczl_gxh')
+            ->select();
+        foreach ($list as $key=>$value){
+            $list[$key]['计划接货数'] = (int)round($value['计划接货数']);
+            if ($value['yjno']<10){
+                $value['yjno'] = '0'.$value['yjno'];
+            }
+            if ($value['gxh']<10){
+                $value['gxh'] = '0'.$value['gxh'];
+            }
+            $list[$key]['印件/工序'] = $value['yjno'].'-'.$value['gxh'].'-'.$value['gxmc'];
+            unset($list[$key]['yjno'],$list[$key]['gxh'],$list[$key]['gxmc'],$list[$key]['ls']);
+        }
+        $this->success('成功',$list);
+    }
+
+
+    /**
+     * 机台工单展示
+     * @ApiMethod ()
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function MachineWorkOrderList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求失败');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $where = '';
+        if (isset($param['search'])){
+            $where = "
+                        b.Gd_gdbh LIKE '%{$param['search']}%' 
+                        OR b.`成品名称` LIKE '%{$param['search']}%' 
+                    ";
+        }
+        $machine = db('设备映射表')
+            ->where('YXmachine','like','%'.$param['machine'].'%')
+            ->value('MNmachine');
+        $list = \db('工单_工艺资料')
+            ->alias('a')
+            ->field([
+                'RTRIM( a.Gy0_yjno )' =>'yjno',
+                'RTRIM( a.Gy0_gxh )' => 'gxh',
+                'RTRIM( a.Gy0_gxmc )' => 'gxmc',
+                'RTRIM( a.Add_gxmc )' => 'Add_gxmc',
+                'RTRIM( c.yj_yjmc )' => '印件名称',
+                'RTRIM( a.`Gy0_计划接货数` )' => '计划接货数',
+                'RTRIM( a.`Gy0_小时产能` )' => '小时产能',
+                'RTRIM( a.`工价系数` )' => '产能系数',
+                'RTRIM( a.`Gy0_生产工时` )' => '生产工时',
+                'RTRIM( a.Gy0_ls )' => 'ls',
+                'RTRIM( a.`Gy0_辅助工时` )' => '辅助工时',
+                'RTRIM( a.`Gy0_最早开工时间` )' => '最早开工时间',
+                'RTRIM( a.Gy0_sj1 )' => '计划开工时间',
+                'RTRIM( a.Gy0_sj2 )' => '计划完工时间',
+                'RTRIM( a.`Gy0_班次安排` )' => '班次安排',
+                'RTRIM( a.`工序备注` )' => '排单备注',
+                'RTRIM( b.Gd_cpmc )' => '产品名称',
+                'RTRIM( b.`成品名称` )' => '成品名称',
+                'RTRIM( b.`订单数量` )' => '订单数量',
+                'RTRIM( b.`计量单位` )' => '计量单位',
+                'RTRIM( b.`交货日期` )' => '交货日期',
+                'RTRIM( b.Gd_cpdh )' => '产品代号',
+                'RTRIM( b.`成品代号` )' => '成品代号',
+                'RTRIM( e.YXmachine )' => '设备编号',
+                'RTRIM( a.Gy0_SITE )' => '车间名称',
+                'RTRIM( a.UniqId )' => 'GYUID',
+                'RTRIM( b.Uniqid )' => 'UNIQID',
+                'SUM( d.sczl_cl )' => '已完成产量',
+                'RTRIM( b.Gd_gdbh )' => '工单编号',
+                'RTRIM( b.`销售订单号` )' => '销售订单号',
+                'RTRIM( a.`版距` )' => '版距',
+                'RTRIM( a.`印刷方式` )' => '印刷方式'
+            ])
+            ->join('工单_印件资料 c','c.Yj_Gdbh = a.Gy0_gdbh AND c.yj_Yjno = a.Gy0_yjno')
+            ->join('工单_基本资料 b','b.Gd_gdbh = a.Gy0_gdbh AND b.行号 = a.Gy0_yjno')
+            ->join('设备_产量计酬 d','a.Gy0_gdbh = d.sczl_gdbh AND a.Gy0_yjno = d.sczl_yjno AND a.Gy0_gxh = d.sczl_gxh AND a.Gy0_sbbh = d.sczl_jtbh','LEFT')
+            ->join('设备映射表 e','d.sczl_jtbh = e.MNmachine')
+            ->where([
+                'b.gd_statu' => '2-生产中',
+                'a.Gy0_sbbh' => ['LIKE','%'.$machine.'%'],
+                'a.PD_WG' => '1900-01-01 00:00:00',
+            ])
+            ->where($where)
+            ->group('a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh')
+            ->order('Gy0_sj1')
+            ->select();
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        $data['制程'] = $data['排程'] = [];
+        foreach ($list as $key=>$value){
+            $machine = explode(' ',$list[$key]['设备编号']);
+            if (in_array($param['machine'],$machine)){
+                $list[$key]['设备编号'] = $param['machine'];
+                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]['Add_gxmc']);
+                if ($value['产品名称'] == ''){
+                    $list[$key]['产品名称'] = $value['成品名称'];
+                }
+                if ($value['产品代号'] == ''){
+                    $list[$key]['产品代号'] = $value['成品代号'];
+                }
+                if ($value['已完成产量'] !== 0 && $value['印刷方式'] === '卷对卷'){
+                    $list[$key]['已完成产量'] = round($value['已完成产量']/$value['版距'] * 1000);
+                }
+                unset($list[$key]['成品代号'],$list[$key]['成品名称']);
+                if ($list[$key]['计划开工时间'] !== '1900-01-01 00:00:00'){
+                    array_push($data['制程'],$list[$key]);
+                }else{
+                    array_push($data['排程'],$list[$key]);
+                }
+            }
+
+        }
+
+        $this->success('成功',$data);
+    }
+
+
+}